no-shadow-restricted-names
eslint
No autofixRecommended
eslint.config.js
export default [
{
rules: {
"no-shadow-restricted-names": "error",
},
},
];Disallow identifiers from shadowing restricted names
function NaN(){}
!function(Infinity){};
const undefined = 5;
try {} catch(eval){}import NaN from "foo";
import { undefined } from "bar";
class Infinity {}let Object;
function f(a, b){}
// Exception: `undefined` may be shadowed if the variable is never assigned a value.
let undefined;import { undefined as undef } from "bar";Examples from the ESLint documentation.
no-shadow-restricted-names
eslint
export default [
{
rules: {
"no-shadow-restricted-names": "error",
},
},
];no-shadow-restricted-names
eslint plugin · correctness
{
"rules": {
"no-shadow-restricted-names": "error"
}
}suspicious/noShadowRestrictedNames
suspicious · since 1.0.0
{
"linter": {
"rules": {
"suspicious": {
"noShadowRestrictedNames": "error"
}
}
}
}Disallow assignments to native objects or read-only global variables
Disallow reassigning exceptions in catch clauses
Require calls to isNaN() when checking for NaN
Disallow assignment operators in conditional expressions
Disallow control characters in regular expressions