Skip to content

shadowedRestrictedNames

Reports variable declarations that shadow JavaScript's restricted names.

✅ This rule is included in the ts untyped preset.

JavaScript provides a set of built-in global identifiers with well-known names. When you declare a variable, function, or class with one of these names, it “shadows” the global identifier and can cause unexpected behavior or make code harder to understand.

This rule reports shadowing of the most common global names that developers sometimes unintentionally shadow:

  • arguments
  • eval
  • Infinity
  • NaN
  • undefined
function processValue(undefined) {
if (undefined === null) {
return 0;
}
return undefined;
}
let NaN = 123;
class Infinity {
value = 100;
}

This rule is not configurable.

If you are working in a large legacy project that came before modern practices, you might find that these names are too difficult to refactor away from. You might consider using Flint disable comments and/or configuration file disables for those specific situations instead of completely disabling this rule.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.