What version of Oxlint are you using?
1.57.0
What command did you run?
oxlint -c .oxlintrc.json
What does your .oxlintrc.json (or oxlint.config.ts) config file look like?
What happened?
no-restricted-globals incorrectly flags a local variable when the same file also contains an unresolved global reference with the same name.
The rule checks root_unresolved_references().contains_key(&ident.name) which matches by name (string), not by specific ReferenceId. So if any reference named location is unresolved (the global), all references named location get flagged -- including correctly resolved local variables.
Minimal reproduction
Bug case -- oxlint reports 2 errors, ESLint reports 1 error:
const globalPath = location.pathname // global (should be flagged)
function test(history: {location: {pathname: string}}) {
const {location} = history
return location.pathname // local (should NOT be flagged) -- false positive
}
export {test, globalPath}
Clean case -- removing the global reference, oxlint correctly reports 0 errors:
function test(history: {location: {pathname: string}}) {
const {location} = history
return location.pathname // correctly NOT flagged
}
export {test}
Expected behavior
Only location on line 1 should be flagged (unresolved global reference). The destructured const {location} = history on line 4 creates a local binding -- references to it on line 5 should not be flagged.
ESLint handles this correctly.
Root cause
In no_restricted_globals.rs line 97:
if ctx.scoping().root_unresolved_references().contains_key(&ident.name) {
This checks if any reference with the name "location" is unresolved, not whether this specific IdentifierReference is unresolved.
Environment
- oxlint 1.57.0
- Tested on macOS, Node 24.12.0
What version of Oxlint are you using?
1.57.0
What command did you run?
oxlint -c .oxlintrc.jsonWhat does your
.oxlintrc.json(oroxlint.config.ts) config file look like?{ "rules": { "eslint/no-restricted-globals": ["error", {"name": "location", "message": "Use router."}] } }What happened?
no-restricted-globalsincorrectly flags a local variable when the same file also contains an unresolved global reference with the same name.The rule checks
root_unresolved_references().contains_key(&ident.name)which matches by name (string), not by specificReferenceId. So if any reference namedlocationis unresolved (the global), all references namedlocationget flagged -- including correctly resolved local variables.Minimal reproduction
Bug case -- oxlint reports 2 errors, ESLint reports 1 error:
Clean case -- removing the global reference, oxlint correctly reports 0 errors:
Expected behavior
Only
locationon line 1 should be flagged (unresolved global reference). The destructuredconst {location} = historyon line 4 creates a local binding -- references to it on line 5 should not be flagged.ESLint handles this correctly.
Root cause
In
no_restricted_globals.rsline 97:This checks if any reference with the name
"location"is unresolved, not whether this specificIdentifierReferenceis unresolved.Environment