In 1.71.0, eslint/no-restricted-globals reports identifiers that are local variables / function parameters which merely shadow a restricted global name. The rule is no longer scope-aware.
ESLint's no-restricted-globals only reports references that resolve to the actual global — a local binding with the same name must not be flagged. oxlint did this correctly in 1.60–1.70, and this regressed in 1.71.0.
Reproduction
.oxlintrc.json:
{ "rules": { "no-restricted-globals": ["error", "event"] } }
repro.js:
function handler(event) {
return event.target
}
Actual (1.71.0)
repro.js:2:10: error eslint(no-restricted-globals): Unexpected use of 'event'.
help: Use a local variable or function parameter instead of the restricted global.
event here is the function parameter handler(event), not the global. The help text even says "Use a local variable or function parameter instead" — which is exactly what the code already does.
A reference that does resolve to the global is still (correctly) reported:
function g() { return event } // correctly flagged
So in 1.71.0 both the shadowing local and the real global are reported; only the latter should be.
Expected
No diagnostic for the parameter/local event (matching ESLint and oxlint ≤ 1.70).
Version bisect
| oxlint |
local shadow flagged? |
| 1.0.0 – 1.50.0 |
yes (older behavior) |
| 1.60.0 – 1.70.0 |
no (correct, scope-aware) |
| 1.71.0 |
yes (regression) |
Likely cause
This looks introduced by the no-restricted-globals rewrite for the new option enum — #23663 (closes #23617), which shipped in 1.71.0. The rewrite appears to have dropped the scope-resolution check, so the rule now matches by identifier name rather than by resolved binding.
In
1.71.0,eslint/no-restricted-globalsreports identifiers that are local variables / function parameters which merely shadow a restricted global name. The rule is no longer scope-aware.ESLint's
no-restricted-globalsonly reports references that resolve to the actual global — a local binding with the same name must not be flagged. oxlint did this correctly in1.60–1.70, and this regressed in1.71.0.Reproduction
.oxlintrc.json:{ "rules": { "no-restricted-globals": ["error", "event"] } }repro.js:Actual (1.71.0)
eventhere is the function parameterhandler(event), not the global. The help text even says "Use a local variable or function parameter instead" — which is exactly what the code already does.A reference that does resolve to the global is still (correctly) reported:
So in 1.71.0 both the shadowing local and the real global are reported; only the latter should be.
Expected
No diagnostic for the parameter/local
event(matching ESLint and oxlint ≤ 1.70).Version bisect
Likely cause
This looks introduced by the
no-restricted-globalsrewrite for the new option enum — #23663 (closes #23617), which shipped in 1.71.0. The rewrite appears to have dropped the scope-resolution check, so the rule now matches by identifier name rather than by resolved binding.