Skip to content
Merged
Show file tree
Hide file tree
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
12 changes: 11 additions & 1 deletion apps/oxlint/src/command/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,14 @@ pub struct EnablePlugins {
/// Enable the node plugin and detect node usage problems
#[bpaf(flag(OverrideToggle::Enable, OverrideToggle::NotSet), hide_usage)]
pub node_plugin: OverrideToggle,

/// Enable the regex plugin and detect regex usage problems
#[bpaf(flag(OverrideToggle::Enable, OverrideToggle::NotSet), hide_usage)]
pub regex_plugin: OverrideToggle,

/// Enable the vue plugin and detect vue usage problems
#[bpaf(flag(OverrideToggle::Enable, OverrideToggle::NotSet), hide_usage)]
pub vue_plugin: OverrideToggle,
}

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

// Without this, jest plugins adapted to vitest will not be enabled.
if self.vitest_plugin.is_enabled() && self.jest_plugin.is_not_set() {
Expand All @@ -363,7 +373,7 @@ pub enum ReportUnusedDirectives {
/// Same as `--report-unused-disable-directives`, but allows you to specify the severity level of the reported errors.
/// Only one of these two options can be used at a time.
#[bpaf(
long("report-unused-disable-directives-severity"),
long("report-unused-disable-directives-severity"),
argument::<String>("SEVERITY"),
guard(|s| AllowWarnDeny::try_from(s.as_str()).is_ok(), "Invalid severity value"),
map(|s| AllowWarnDeny::try_from(s.as_str()).unwrap()), // guard ensures try_from will be Ok
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/config/oxlintrc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ mod test {
Some(BuiltinLintPlugins::TYPESCRIPT.union(BuiltinLintPlugins::UNICORN).into())
);
let config: Oxlintrc =
serde_json::from_str(r#"{ "plugins": ["typescript", "unicorn", "react", "oxc", "import", "jsdoc", "jest", "vitest", "jsx-a11y", "nextjs", "react-perf", "promise", "node"] }"#).unwrap();
serde_json::from_str(r#"{ "plugins": ["typescript", "unicorn", "react", "oxc", "import", "jsdoc", "jest", "vitest", "jsx-a11y", "nextjs", "react-perf", "promise", "node", "regex", "vue"] }"#).unwrap();
assert_eq!(config.plugins, Some(BuiltinLintPlugins::all().into()));

let config: Oxlintrc =
Expand Down
10 changes: 10 additions & 0 deletions crates/oxc_linter/src/config/plugins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ bitflags! {
const PROMISE = 1 << 11;
/// `eslint-plugin-node`
const NODE = 1 << 12;
/// `eslint-plugin-regex`
const REGEX = 1 << 13;
/// `eslint-plugin-vue`
const VUE = 1 << 14;
}
}

Expand Down Expand Up @@ -119,6 +123,8 @@ impl From<&str> for BuiltinLintPlugins {
"react-perf" | "react_perf" => BuiltinLintPlugins::REACT_PERF,
"promise" => BuiltinLintPlugins::PROMISE,
"node" => BuiltinLintPlugins::NODE,
"regex" => BuiltinLintPlugins::REGEX,
"vue" => BuiltinLintPlugins::VUE,
// "eslint" is not really a plugin, so it's 'empty'. This has the added benefit of
// making it the default value.
_ => BuiltinLintPlugins::empty(),
Expand All @@ -142,6 +148,8 @@ impl From<BuiltinLintPlugins> for &'static str {
BuiltinLintPlugins::REACT_PERF => "react-perf",
BuiltinLintPlugins::PROMISE => "promise",
BuiltinLintPlugins::NODE => "node",
BuiltinLintPlugins::REGEX => "regex",
BuiltinLintPlugins::VUE => "vue",
_ => "",
}
}
Expand Down Expand Up @@ -225,6 +233,8 @@ impl JsonSchema for LintPlugins {
ReactPerf,
Promise,
Node,
Regex,
Vue,
}

let enum_schema = r#gen.subschema_for::<LintPluginOptionsSchema>();
Expand Down
4 changes: 3 additions & 1 deletion crates/oxc_linter/src/snapshots/schema_json.snap
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,9 @@ expression: json
"nextjs",
"react-perf",
"promise",
"node"
"node",
"regex",
"vue"
]
},
"LintPlugins": {
Expand Down
4 changes: 3 additions & 1 deletion npm/oxlint/configuration_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,9 @@
"nextjs",
"react-perf",
"promise",
"node"
"node",
"regex",
"vue"
]
},
"LintPlugins": {
Expand Down
4 changes: 4 additions & 0 deletions tasks/website/src/linter/snapshots/cli.snap
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ Arguments:
Enable the promise plugin and detect promise usage problems
- **` --node-plugin`** &mdash;
Enable the node plugin and detect node usage problems
- **` --regex-plugin`** &mdash;
Enable the regex plugin and detect regex usage problems
- **` --vue-plugin`** &mdash;
Enable the vue plugin and detect vue usage problems



Expand Down
2 changes: 2 additions & 0 deletions tasks/website/src/linter/snapshots/cli_terminal.snap
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ Enable Plugins
problems
--promise-plugin Enable the promise plugin and detect promise usage problems
--node-plugin Enable the node plugin and detect node usage problems
--regex-plugin Enable the regex plugin and detect regex usage problems
--vue-plugin Enable the vue plugin and detect vue usage problems

Fix Problems
--fix Fix as many issues as possible. Only unfixed issues are reported in
Expand Down
Loading