Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion crates/oxc_linter/src/rules/eslint/no_restricted_globals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ impl Rule for NoRestrictedGlobals {
};

if ctx.scoping().root_unresolved_references().contains_key(ident.name.as_str()) {
ctx.diagnostic(no_restricted_globals(&ident.name, message, ident.span));
let reference = ctx.scoping().get_reference(ident.reference_id());
if !reference.is_type() {
ctx.diagnostic(no_restricted_globals(&ident.name, message, ident.span));
}
}
}
}
Expand All @@ -99,6 +102,13 @@ fn test() {
const CUSTOM_MESSAGE: &str = "Use bar instead.";

let pass = vec![
(
"let a: Date;",
Some(
serde_json::json!([{ "name": "Date", "message": "Use helpers or date-fns instead", }]),
),
None,
),
("foo", None, None),
("foo", Some(serde_json::json!(["bar"])), None),
("var foo = 1;", Some(serde_json::json!(["foo"])), None),
Expand Down
Loading