Skip to content

shadowedRestrictedNames

Reports variable declarations that shadow JavaScript's restricted names.

✅ This rule is included in the ts untyped presets.

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
function processValue(undefined: any): any
processValue
(
undefined: any
undefined
) {
if (
undefined: any
undefined
=== null) {
return 0;
}
return
undefined: any
undefined
;
}
let
let NaN: number
NaN
= 123;
class
class Infinity
Infinity
{
Infinity.value: number
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 ❤️‍🔥 around the world by the Flint team and contributors.