Lint Rules

noShadowRestrictedNames (since v0.9.0)

This rule is recommended by Rome.

Disallow identifiers from shadowing restricted names.

Examples

Invalid

function NaN() {}
correctness/noShadowRestrictedNames.js:1:10 lint/correctness/noShadowRestrictedNames ━━━━━━━━━━━━━━━

   Do not shadow the global "NaN" property.
  
  > 1 │ function NaN() {}
            ^^^
    2 │ 
  
   Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.
  
let Set;
correctness/noShadowRestrictedNames.js:1:5 lint/correctness/noShadowRestrictedNames ━━━━━━━━━━━━━━━━

   Do not shadow the global "Set" property.
  
  > 1 │ let Set;
       ^^^
    2 │ 
  
   Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.
  
try {	} catch(Object) {}
correctness/noShadowRestrictedNames.js:1:15 lint/correctness/noShadowRestrictedNames ━━━━━━━━━━━━━━━

   Do not shadow the global "Object" property.
  
  > 1 │ try {	} catch(Object) {}
        	        ^^^^^^
    2 │ 
  
   Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.
  
function Array() {}
correctness/noShadowRestrictedNames.js:1:10 lint/correctness/noShadowRestrictedNames ━━━━━━━━━━━━━━━

   Do not shadow the global "Array" property.
  
  > 1 │ function Array() {}
            ^^^^^
    2 │ 
  
   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)}
correctness/noShadowRestrictedNames.js:1:15 lint/correctness/noShadowRestrictedNames ━━━━━━━━━━━━━━━

   Do not shadow the global "JSON" property.
  
  > 1 │ function test(JSON) {console.log(JSON)}
                 ^^^^
    2 │ 
  
   Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.