W3cubDocs

/ESLint

Disallow Shadowing of Restricted Names (no-shadow-restricted-names)

ES5 §15.1.1 Value Properties of the Global Object (NaN, Infinity, undefined) as well as strict mode restricted identifiers eval and arguments are considered to be restricted names in JavaScript. Defining them to mean something else can have unintended consequences and confuse others reading the code. For example, there’s nothing prevent you from writing:

var undefined = "foo";

Then any code used within the same scope would not get the global undefined, but rather the local version with a very different meaning.

Rule Details

Examples of incorrect code for this rule:

/*eslint no-shadow-restricted-names: "error"*/

function NaN(){}

!function(Infinity){};

var undefined;

try {} catch(eval){}

Examples of correct code for this rule:

/*eslint no-shadow-restricted-names: "error"*/

var Object;

function f(a, b){}

Further Reading

Version

This rule was introduced in ESLint 0.1.4.

Resources

© JS Foundation and other contributors
Licensed under the MIT License.
https://eslint.org/docs/rules/no-shadow-restricted-names