Skip to content

Commit 633ba30

Browse files
committed
fix(linter): false positive with unknown plugins when unmatched eslint rule (#12285)
What's happening is some config files have rules such as: `constructor-super`, this gets mapped to `unknown_plugin/constructor-super`, which means we try to load the "unknown_plugin" (which doesn't exist, hence causing the error). Since using only the rule's name as the rules identifier in the config file is only supported for eslint rules, we can just map this back to the `eslint` plugin
1 parent a8d1e22 commit 633ba30

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

crates/oxc_linter/src/config/rules.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,9 @@ fn parse_rule_key(name: &str) -> (String, String) {
225225
RULES
226226
.iter()
227227
.find(|r| r.name() == name)
228-
.map_or("unknown_plugin", RuleEnum::plugin_name)
228+
// plugins under the `eslint` scope are the only rules that are supported
229+
// to exist in the config file under just the rule name (no plugin)
230+
.map_or("eslint", RuleEnum::plugin_name)
229231
.to_string(),
230232
name.to_string(),
231233
);
@@ -344,7 +346,7 @@ mod test {
344346

345347
let r3 = rules.next().unwrap();
346348
assert_eq!(r3.rule_name, "dummy");
347-
assert_eq!(r3.plugin_name, "unknown_plugin");
349+
assert_eq!(r3.plugin_name, "eslint");
348350
assert!(r3.severity.is_warn_deny());
349351
assert_eq!(r3.config, Some(serde_json::json!(["arg1", "args2"])));
350352

0 commit comments

Comments
 (0)