Skip to main content

js/noShadowRestrictedNames

disallow identifiers from shadowing restricted names

ESLint Equivalent: no-shadow-restricted-names

Examples

Invalid

function NaN() {}

 file.ts:1:9 lint/js/noShadowRestrictedNames ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  Do not shadow the global NaN property.

    function NaN() {}
             ^^^

  Consider renaming this variable. It's easy to confuse the origin of
    variables when they're named after a known global.


let Set;

 file.ts:1:4 lint/js/noShadowRestrictedNames ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  Do not shadow the global Set property.

    let Set;
        ^^^

  Consider renaming this variable. It's easy to confuse the origin of
    variables when they're named after a known global.


try {  } catch(Object) {}

 file.ts:1:15 lint/js/noShadowRestrictedNames ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  Do not shadow the global Object property.

    try {  } catch(Object) {}
                   ^^^^^^

  Consider renaming this variable. It's easy to confuse the origin of
    variables when they're named after a known global.


!function Array() {}

 file.ts:1:10 lint/js/noShadowRestrictedNames ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  Do not shadow the global Array property.

    !function Array() {}
              ^^^^^

  Consider renaming this variable. It's easy to confuse the origin of
    variables when they're named after a known global.


function test(JSON) {console.log(JSON)}

 file.ts:1:14 lint/js/noShadowRestrictedNames ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  Do not shadow the global JSON property.

    function test(JSON) {console.log(JSON)}
                  ^^^^

  Consider renaming this variable. It's easy to confuse the origin of
    variables when they're named after a known global.