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:
argumentsevalInfinityNaNundefined
Examples
Section titled “Examples”function processValue(undefined) { if (undefined === null) { return 0; } return undefined;}
let NaN = 123;
class Infinity { value = 100;}function processValue(value) { if (value === undefined) { return 0; } return value;}
let notANumber = NaN;
class InfiniteValue { value = Infinity;}Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”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.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- Biome:
noShadowRestrictedNames - Deno:
no-shadow-restricted-names - ESLint:
no-shadow-restricted-names - Oxlint:
eslint/no-shadow-restricted-names