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
16 changes: 13 additions & 3 deletions crates/oxc_linter/src/config/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ use serde::{
Deserialize,
};

use crate::AllowWarnDeny;
use crate::{
rules::{RuleEnum, RULES},
AllowWarnDeny,
};

// TS type is `Record<string, RuleConf>`
// - type SeverityConf = 0 | 1 | 2 | "off" | "warn" | "error";
Expand Down Expand Up @@ -92,7 +95,14 @@ impl<'de> Deserialize<'de> for OxlintRules {

fn parse_rule_key(name: &str) -> (String, String) {
let Some((plugin_name, rule_name)) = name.split_once('/') else {
return ("eslint".to_string(), name.to_string());
return (
RULES
.iter()
.find(|r| r.name() == name)
.map_or("unknown_plugin", RuleEnum::plugin_name)
.to_string(),
name.to_string(),
);
};

let (oxlint_plugin_name, rule_name) = match plugin_name {
Expand Down Expand Up @@ -193,7 +203,7 @@ mod test {

let r3 = rules.next().unwrap();
assert_eq!(r3.rule_name, "dummy");
assert_eq!(r3.plugin_name, "eslint");
assert_eq!(r3.plugin_name, "unknown_plugin");
assert!(r3.severity.is_warn_deny());
assert_eq!(r3.config, Some(serde_json::json!(["arg1", "args2"])));

Expand Down