Skip to content

Commit c5268f1

Browse files
committed
refactor(linter): add vue and regex to BuiltinLintPlugins
1 parent cc19c8b commit c5268f1

File tree

7 files changed

+34
-4
lines changed

7 files changed

+34
-4
lines changed

apps/oxlint/src/command/lint.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,14 @@ pub struct EnablePlugins {
267267
/// Enable the node plugin and detect node usage problems
268268
#[bpaf(flag(OverrideToggle::Enable, OverrideToggle::NotSet), hide_usage)]
269269
pub node_plugin: OverrideToggle,
270+
271+
/// Enable the regex plugin and detect regex usage problems
272+
#[bpaf(flag(OverrideToggle::Enable, OverrideToggle::NotSet), hide_usage)]
273+
pub regex_plugin: OverrideToggle,
274+
275+
/// Enable the vue plugin and detect vue usage problems
276+
#[bpaf(flag(OverrideToggle::Enable, OverrideToggle::NotSet), hide_usage)]
277+
pub vue_plugin: OverrideToggle,
270278
}
271279

272280
/// Enables or disables a boolean option, or leaves it unset.
@@ -343,6 +351,8 @@ impl EnablePlugins {
343351
.inspect(|yes| plugins.builtin.set(BuiltinLintPlugins::REACT_PERF, yes));
344352
self.promise_plugin.inspect(|yes| plugins.builtin.set(BuiltinLintPlugins::PROMISE, yes));
345353
self.node_plugin.inspect(|yes| plugins.builtin.set(BuiltinLintPlugins::NODE, yes));
354+
self.regex_plugin.inspect(|yes| plugins.builtin.set(BuiltinLintPlugins::REGEX, yes));
355+
self.vue_plugin.inspect(|yes| plugins.builtin.set(BuiltinLintPlugins::VUE, yes));
346356

347357
// Without this, jest plugins adapted to vitest will not be enabled.
348358
if self.vitest_plugin.is_enabled() && self.jest_plugin.is_not_set() {
@@ -363,7 +373,7 @@ pub enum ReportUnusedDirectives {
363373
/// Same as `--report-unused-disable-directives`, but allows you to specify the severity level of the reported errors.
364374
/// Only one of these two options can be used at a time.
365375
#[bpaf(
366-
long("report-unused-disable-directives-severity"),
376+
long("report-unused-disable-directives-severity"),
367377
argument::<String>("SEVERITY"),
368378
guard(|s| AllowWarnDeny::try_from(s.as_str()).is_ok(), "Invalid severity value"),
369379
map(|s| AllowWarnDeny::try_from(s.as_str()).unwrap()), // guard ensures try_from will be Ok

crates/oxc_linter/src/config/oxlintrc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ mod test {
263263
Some(BuiltinLintPlugins::TYPESCRIPT.union(BuiltinLintPlugins::UNICORN).into())
264264
);
265265
let config: Oxlintrc =
266-
serde_json::from_str(r#"{ "plugins": ["typescript", "unicorn", "react", "oxc", "import", "jsdoc", "jest", "vitest", "jsx-a11y", "nextjs", "react-perf", "promise", "node"] }"#).unwrap();
266+
serde_json::from_str(r#"{ "plugins": ["typescript", "unicorn", "react", "oxc", "import", "jsdoc", "jest", "vitest", "jsx-a11y", "nextjs", "react-perf", "promise", "node", "regex", "vue"] }"#).unwrap();
267267
assert_eq!(config.plugins, Some(BuiltinLintPlugins::all().into()));
268268

269269
let config: Oxlintrc =

crates/oxc_linter/src/config/plugins.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ bitflags! {
4747
const PROMISE = 1 << 11;
4848
/// `eslint-plugin-node`
4949
const NODE = 1 << 12;
50+
/// `eslint-plugin-regex`
51+
const REGEX = 1 << 13;
52+
/// `eslint-plugin-vue`
53+
const VUE = 1 << 14;
5054
}
5155
}
5256

@@ -119,6 +123,8 @@ impl From<&str> for BuiltinLintPlugins {
119123
"react-perf" | "react_perf" => BuiltinLintPlugins::REACT_PERF,
120124
"promise" => BuiltinLintPlugins::PROMISE,
121125
"node" => BuiltinLintPlugins::NODE,
126+
"regex" => BuiltinLintPlugins::REGEX,
127+
"vue" => BuiltinLintPlugins::VUE,
122128
// "eslint" is not really a plugin, so it's 'empty'. This has the added benefit of
123129
// making it the default value.
124130
_ => BuiltinLintPlugins::empty(),
@@ -142,6 +148,8 @@ impl From<BuiltinLintPlugins> for &'static str {
142148
BuiltinLintPlugins::REACT_PERF => "react-perf",
143149
BuiltinLintPlugins::PROMISE => "promise",
144150
BuiltinLintPlugins::NODE => "node",
151+
BuiltinLintPlugins::REGEX => "regex",
152+
BuiltinLintPlugins::VUE => "vue",
145153
_ => "",
146154
}
147155
}
@@ -225,6 +233,8 @@ impl JsonSchema for LintPlugins {
225233
ReactPerf,
226234
Promise,
227235
Node,
236+
Regex,
237+
Vue,
228238
}
229239

230240
let enum_schema = r#gen.subschema_for::<LintPluginOptionsSchema>();

crates/oxc_linter/src/snapshots/schema_json.snap

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,9 @@ expression: json
289289
"nextjs",
290290
"react-perf",
291291
"promise",
292-
"node"
292+
"node",
293+
"regex",
294+
"vue"
293295
]
294296
},
295297
"LintPlugins": {

npm/oxlint/configuration_schema.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,9 @@
285285
"nextjs",
286286
"react-perf",
287287
"promise",
288-
"node"
288+
"node",
289+
"regex",
290+
"vue"
289291
]
290292
},
291293
"LintPlugins": {

tasks/website/src/linter/snapshots/cli.snap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ Arguments:
7171
Enable the promise plugin and detect promise usage problems
7272
- **` --node-plugin`** &mdash;
7373
Enable the node plugin and detect node usage problems
74+
- **` --regex-plugin`** &mdash;
75+
Enable the regex plugin and detect regex usage problems
76+
- **` --vue-plugin`** &mdash;
77+
Enable the vue plugin and detect vue usage problems
7478

7579

7680

tasks/website/src/linter/snapshots/cli_terminal.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ Enable Plugins
4444
problems
4545
--promise-plugin Enable the promise plugin and detect promise usage problems
4646
--node-plugin Enable the node plugin and detect node usage problems
47+
--regex-plugin Enable the regex plugin and detect regex usage problems
48+
--vue-plugin Enable the vue plugin and detect vue usage problems
4749

4850
Fix Problems
4951
--fix Fix as many issues as possible. Only unfixed issues are reported in

0 commit comments

Comments
 (0)