Skip to content

Commit 09ca386

Browse files
committed
chore(linter): remove unused builtin regex plugin (#16493)
Closes #11439 6 months after adding opening the eslint plugin regex issue, and adding support for regex rules in rule gen, we have implemented none of the regex rule. Given this, and the fact that these rules can be implemented via JS plugins, it makes a the most sense to remove support for this plugin. cc @connorshea
1 parent 0e59dcc commit 09ca386

File tree

10 files changed

+5
-32
lines changed

10 files changed

+5
-32
lines changed

apps/oxlint/src/command/lint.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,6 @@ pub struct EnablePlugins {
317317
#[bpaf(flag(OverrideToggle::Enable, OverrideToggle::NotSet), hide_usage)]
318318
pub node_plugin: OverrideToggle,
319319

320-
/// Enable the regex plugin and detect regex usage problems
321-
#[bpaf(flag(OverrideToggle::Enable, OverrideToggle::NotSet), hide_usage)]
322-
pub regex_plugin: OverrideToggle,
323-
324320
/// Enable the vue plugin and detect vue usage problems
325321
#[bpaf(flag(OverrideToggle::Enable, OverrideToggle::NotSet), hide_usage)]
326322
pub vue_plugin: OverrideToggle,
@@ -398,7 +394,6 @@ impl EnablePlugins {
398394
self.react_perf_plugin.inspect(|yes| plugins.set(LintPlugins::REACT_PERF, yes));
399395
self.promise_plugin.inspect(|yes| plugins.set(LintPlugins::PROMISE, yes));
400396
self.node_plugin.inspect(|yes| plugins.set(LintPlugins::NODE, yes));
401-
self.regex_plugin.inspect(|yes| plugins.set(LintPlugins::REGEX, yes));
402397
self.vue_plugin.inspect(|yes| plugins.set(LintPlugins::VUE, yes));
403398

404399
// Without this, jest plugins adapted to vitest will not be enabled.

crates/oxc_linter/src/config/oxlintrc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ mod test {
384384
serde_json::from_str(r#"{ "plugins": ["typescript", "unicorn"] }"#).unwrap();
385385
assert_eq!(config.plugins, Some(LintPlugins::TYPESCRIPT | LintPlugins::UNICORN));
386386
let config: Oxlintrc =
387-
serde_json::from_str(r#"{ "plugins": ["typescript", "unicorn", "react", "oxc", "import", "jsdoc", "jest", "vitest", "jsx-a11y", "nextjs", "react-perf", "promise", "node", "regex", "vue"] }"#).unwrap();
387+
serde_json::from_str(r#"{ "plugins": ["typescript", "unicorn", "react", "oxc", "import", "jsdoc", "jest", "vitest", "jsx-a11y", "nextjs", "react-perf", "promise", "node", "vue"] }"#).unwrap();
388388
assert_eq!(config.plugins, Some(LintPlugins::all()));
389389

390390
let config: Oxlintrc =

crates/oxc_linter/src/config/plugins.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,8 @@ bitflags! {
7878
const PROMISE = 1 << 11;
7979
/// `eslint-plugin-node`
8080
const NODE = 1 << 12;
81-
/// `eslint-plugin-regex`
82-
const REGEX = 1 << 13;
8381
/// `eslint-plugin-vue`
84-
const VUE = 1 << 14;
82+
const VUE = 1 << 13;
8583
}
8684
}
8785

@@ -145,7 +143,6 @@ impl TryFrom<&str> for LintPlugins {
145143
"react-perf" | "react_perf" => Ok(LintPlugins::REACT_PERF),
146144
"promise" => Ok(LintPlugins::PROMISE),
147145
"node" => Ok(LintPlugins::NODE),
148-
"regex" => Ok(LintPlugins::REGEX),
149146
"vue" => Ok(LintPlugins::VUE),
150147
// "eslint" is not really a plugin, so it's 'empty'. This has the added benefit of
151148
// making it the default value.
@@ -171,7 +168,6 @@ impl From<LintPlugins> for &'static str {
171168
LintPlugins::REACT_PERF => "react-perf",
172169
LintPlugins::PROMISE => "promise",
173170
LintPlugins::NODE => "node",
174-
LintPlugins::REGEX => "regex",
175171
LintPlugins::VUE => "vue",
176172
_ => "",
177173
}
@@ -243,7 +239,6 @@ impl JsonSchema for LintPlugins {
243239
ReactPerf,
244240
Promise,
245241
Node,
246-
Regex,
247242
Vue,
248243
}
249244

crates/oxc_linter/src/snapshots/schema_json.snap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,6 @@ expression: json
343343
"react-perf",
344344
"promise",
345345
"node",
346-
"regex",
347346
"vue"
348347
]
349348
},

justfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ new-react-perf-rule name: (new-rule name "react-perf")
170170
new-n-rule name: (new-rule name "n")
171171
new-promise-rule name: (new-rule name "promise")
172172
new-vitest-rule name: (new-rule name "vitest")
173-
new-regexp-rule name: (new-rule name "regexp")
174173
new-vue-rule name: (new-rule name "vue")
175174

176175
# Alias for backward compatibility

npm/oxlint/configuration_schema.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,6 @@
339339
"react-perf",
340340
"promise",
341341
"node",
342-
"regex",
343342
"vue"
344343
]
345344
},
@@ -661,4 +660,4 @@
661660
}
662661
},
663662
"markdownDescription": "Oxlint Configuration File\n\nThis configuration is aligned with ESLint v8's configuration schema (`eslintrc.json`).\n\nUsage: `oxlint -c oxlintrc.json --import-plugin`\n\n::: danger NOTE\n\nOnly the `.json` format is supported. You can use comments in configuration files.\n\n:::\n\nExample\n\n`.oxlintrc.json`\n\n```json\n{\n\"$schema\": \"./node_modules/oxlint/configuration_schema.json\",\n\"plugins\": [\"import\", \"typescript\", \"unicorn\"],\n\"env\": {\n\"browser\": true\n},\n\"globals\": {\n\"foo\": \"readonly\"\n},\n\"settings\": {\n},\n\"rules\": {\n\"eqeqeq\": \"warn\",\n\"import/no-cycle\": \"error\",\n\"react/self-closing-comp\": [\"error\", { \"html\": false }]\n},\n\"overrides\": [\n{\n\"files\": [\"*.test.ts\", \"*.spec.ts\"],\n\"rules\": {\n\"@typescript-eslint/no-explicit-any\": \"off\"\n}\n}\n]\n}\n```"
664-
}
663+
}

tasks/rulegen/src/main.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,6 @@ const VITEST_TEST_PATH: &str =
8686
const VITEST_RULES_PATH: &str =
8787
"https://raw.githubusercontent.com/veritem/eslint-plugin-vitest/main/src/rules";
8888

89-
const REGEXP_TEST_PATH: &str = "https://raw.githubusercontent.com/ota-meshi/eslint-plugin-regexp/refs/heads/master/tests/lib/rules";
90-
const REGEXP_RULES_PATH: &str =
91-
"https://raw.githubusercontent.com/ota-meshi/eslint-plugin-regexp/refs/heads/master/lib/rules";
92-
9389
const VUE_TEST_PATH: &str =
9490
"https://raw.githubusercontent.com/vuejs/eslint-plugin-vue/master/tests/lib/rules/";
9591
const VUE_RULES_PATH: &str =
@@ -1335,7 +1331,6 @@ pub enum RuleKind {
13351331
Node,
13361332
Promise,
13371333
Vitest,
1338-
Regexp,
13391334
Vue,
13401335
}
13411336

@@ -1358,7 +1353,6 @@ impl TryFrom<&str> for RuleKind {
13581353
"n" => Ok(Self::Node),
13591354
"promise" => Ok(Self::Promise),
13601355
"vitest" => Ok(Self::Vitest),
1361-
"regexp" => Ok(Self::Regexp),
13621356
"vue" => Ok(Self::Vue),
13631357
_ => Err(format!("Invalid `RuleKind`, got `{value}`")),
13641358
}
@@ -1382,7 +1376,6 @@ impl Display for RuleKind {
13821376
Self::Node => "eslint-plugin-n",
13831377
Self::Promise => "eslint-plugin-promise",
13841378
Self::Vitest => "eslint-plugin-vitest",
1385-
Self::Regexp => "eslint-plugin-regexp",
13861379
Self::Vue => "eslint-plugin-vue",
13871380
};
13881381
f.write_str(kind_name)
@@ -1414,7 +1407,6 @@ fn main() {
14141407
RuleKind::Node => format!("{NODE_TEST_PATH}/{kebab_rule_name}.js"),
14151408
RuleKind::Promise => format!("{PROMISE_TEST_PATH}/{kebab_rule_name}.js"),
14161409
RuleKind::Vitest => format!("{VITEST_TEST_PATH}/{kebab_rule_name}.test.ts"),
1417-
RuleKind::Regexp => format!("{REGEXP_TEST_PATH}/{kebab_rule_name}.ts"),
14181410
RuleKind::Vue => format!("{VUE_TEST_PATH}/{kebab_rule_name}.js"),
14191411
RuleKind::Oxc => String::new(),
14201412
};
@@ -1432,7 +1424,6 @@ fn main() {
14321424
RuleKind::Node => format!("{NODE_RULES_PATH}/{kebab_rule_name}.js"),
14331425
RuleKind::Promise => format!("{PROMISE_RULES_PATH}/{kebab_rule_name}.js"),
14341426
RuleKind::Vitest => format!("{VITEST_RULES_PATH}/{kebab_rule_name}.ts"),
1435-
RuleKind::Regexp => format!("{REGEXP_RULES_PATH}/{kebab_rule_name}.ts"),
14361427
RuleKind::Vue => format!("{VUE_RULES_PATH}/{kebab_rule_name}.js"),
14371428
RuleKind::Oxc => String::new(),
14381429
};
@@ -1638,7 +1629,6 @@ fn get_mod_name(rule_kind: RuleKind) -> String {
16381629
RuleKind::Promise => "promise".into(),
16391630
RuleKind::Vitest => "vitest".into(),
16401631
RuleKind::Node => "node".into(),
1641-
RuleKind::Regexp => "regexp".into(),
16421632
RuleKind::Vue => "vue".into(),
16431633
}
16441634
}

tasks/rulegen/src/template.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ impl<'a> Template<'a> {
4444
RuleKind::Node => Path::new("crates/oxc_linter/src/rules/node"),
4545
RuleKind::Promise => Path::new("crates/oxc_linter/src/rules/promise"),
4646
RuleKind::Vitest => Path::new("crates/oxc_linter/src/rules/vitest"),
47-
RuleKind::Regexp => Path::new("crates/oxc_linter/src/rules/regexp"),
4847
RuleKind::Vue => Path::new("crates/oxc_linter/src/rules/vue"),
4948
};
5049

tasks/website_linter/src/snapshots/cli.snap

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
source: tasks/website/src/linter/cli.rs
2+
source: tasks/website_linter/src/cli.rs
33
expression: snapshot
44
---
55
---
@@ -78,8 +78,6 @@ Arguments:
7878
Enable the promise plugin and detect promise usage problems
7979
- **` --node-plugin`** &mdash;
8080
Enable the node plugin and detect node usage problems
81-
- **` --regex-plugin`** &mdash;
82-
Enable the regex plugin and detect regex usage problems
8381
- **` --vue-plugin`** &mdash;
8482
Enable the vue plugin and detect vue usage problems
8583

tasks/website_linter/src/snapshots/cli_terminal.snap

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
source: tasks/website/src/linter/cli.rs
2+
source: tasks/website_linter/src/cli.rs
33
expression: snapshot
44
---
55
Usage: [-c=<./.oxlintrc.json>] [PATH]...
@@ -47,7 +47,6 @@ Enable/Disable Plugins
4747
problems
4848
--promise-plugin Enable the promise plugin and detect promise usage problems
4949
--node-plugin Enable the node plugin and detect node usage problems
50-
--regex-plugin Enable the regex plugin and detect regex usage problems
5150
--vue-plugin Enable the vue plugin and detect vue usage problems
5251

5352
Fix Problems

0 commit comments

Comments
 (0)