noShadowRestrictedNames
Summary
Section titled “Summary”- Rule available since:
v1.0.0
- Diagnostic Category:
lint/suspicious/noShadowRestrictedNames
- This rule is recommended, which means is enabled by default.
- This rule doesn’t have a fix.
- The default severity of this rule is error.
- Sources:
- Same as
no-shadow-restricted-names
- Same as
Description
Section titled “Description”Disallow identifiers from shadowing restricted names.
See also: noShadow
Examples
Section titled “Examples”Invalid
Section titled “Invalid”function NaN() {}
code-block.js:1:10 lint/suspicious/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;
code-block.js:1:5 lint/suspicious/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) {}
code-block.js:1:15 lint/suspicious/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() {}
code-block.js:1:10 lint/suspicious/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)}
code-block.js:1:15 lint/suspicious/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.
How to configure
Section titled “How to configure”{ "linter": { "rules": { "suspicious": { "noShadowRestrictedNames": "error" } } }}