noShadowRestrictedNames (since v0.9.0)
This rule is recommended by Rome.
Disallow identifiers from shadowing restricted names.
Examples
Invalid
function NaN() {} error[js/noShadowRestrictedNames]: Do not shadow the global "NaN" property.
┌─ js/noShadowRestrictedNames.js:1:10
│
1 │ function NaN() {}
│ ^^^
= note: Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.
let Set; error[js/noShadowRestrictedNames]: Do not shadow the global "Set" property.
┌─ js/noShadowRestrictedNames.js:1:5
│
1 │ let Set;
│ ^^^
= note: Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.
try { } catch(Object) {} error[js/noShadowRestrictedNames]: Do not shadow the global "Object" property.
┌─ js/noShadowRestrictedNames.js:1:15
│
1 │ try { } catch(Object) {}
│ ^^^^^^
= note: Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.
function Array() {} error[js/noShadowRestrictedNames]: Do not shadow the global "Array" property.
┌─ js/noShadowRestrictedNames.js:1:10
│
1 │ function Array() {}
│ ^^^^^
= note: 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)} error[js/noShadowRestrictedNames]: Do not shadow the global "JSON" property.
┌─ js/noShadowRestrictedNames.js:1:15
│
1 │ function test(JSON) {console.log(JSON)}
│ ^^^^
= note: Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.