mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
fix(oxlint): rules in the configuration file are not being correctly … (#4949)
closes #4701 BTW, which one should have higher priority between the rules in the command line and those in the configuration file? Is the current design reasonable?
This commit is contained in:
parent
5d0fb979cb
commit
5f8a7c22e4
1 changed files with 13 additions and 3 deletions
|
|
@ -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";
|
||||
|
|
@ -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 {
|
||||
|
|
@ -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"])));
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue