Skip to content

Commit a54c151

Browse files
committed
perf(linter/no-restricted-types): skip running if config is empty
1 parent 4b24825 commit a54c151

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

crates/oxc_linter/src/rules/typescript/no_restricted_types.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,10 @@ impl Rule for NoRestrictedTypes {
255255
}
256256

257257
fn should_run(&self, ctx: &ContextHost) -> bool {
258-
ctx.source_type().is_typescript()
258+
if !ctx.source_type().is_typescript() || self.0.types.is_empty() {
259+
return false;
260+
}
261+
true
259262
}
260263
}
261264

@@ -330,6 +333,7 @@ fn test() {
330333
("let e: namespace.Object;", Some(serde_json::json!([{ "types": { "Object": true } }]))),
331334
("let value: _.NS.Banned;", Some(serde_json::json!([{ "types": { "NS.Banned": true } }]))),
332335
("let value: NS.Banned._;", Some(serde_json::json!([{ "types": { "NS.Banned": true } }]))),
336+
("let f: any = true", Some(serde_json::json!([{ "types": {} }]))),
333337
];
334338

335339
let fail = vec![

0 commit comments

Comments
 (0)