feat(cli,linter): add --disable-oxc-plugin (#3328)

closes #3316
This commit is contained in:
Boshen 2024-05-17 12:11:17 +00:00
parent 4f76cb6f38
commit e241136f91
3 changed files with 15 additions and 1 deletions

View file

@ -184,6 +184,10 @@ pub struct EnablePlugins {
#[bpaf(long("disable-unicorn-plugin"), flag(false, true), hide_usage)]
pub unicorn_plugin: bool,
/// Disable oxc unique rules, which is turned on by default
#[bpaf(long("disable-oxc-plugin"), flag(false, true), hide_usage)]
pub oxc_plugin: bool,
/// Disable TypeScript plugin, which is turned on by default
#[bpaf(long("disable-typescript-plugin"), flag(false, true), hide_usage)]
pub typescript_plugin: bool,

View file

@ -96,6 +96,7 @@ impl Runner for LintRunner {
.with_react_plugin(enable_plugins.react_plugin)
.with_unicorn_plugin(enable_plugins.unicorn_plugin)
.with_typescript_plugin(enable_plugins.typescript_plugin)
.with_oxc_plugin(enable_plugins.oxc_plugin)
.with_import_plugin(enable_plugins.import_plugin)
.with_jsdoc_plugin(enable_plugins.jsdoc_plugin)
.with_jest_plugin(enable_plugins.jest_plugin)

View file

@ -18,6 +18,7 @@ pub struct LintOptions {
pub react_plugin: bool,
pub unicorn_plugin: bool,
pub typescript_plugin: bool,
pub oxc_plugin: bool,
pub import_plugin: bool,
pub jsdoc_plugin: bool,
pub jest_plugin: bool,
@ -35,6 +36,7 @@ impl Default for LintOptions {
react_plugin: true,
unicorn_plugin: true,
typescript_plugin: true,
oxc_plugin: true,
import_plugin: false,
jsdoc_plugin: false,
jest_plugin: false,
@ -84,6 +86,12 @@ impl LintOptions {
self
}
#[must_use]
pub fn with_oxc_plugin(mut self, yes: bool) -> Self {
self.oxc_plugin = yes;
self
}
#[must_use]
pub fn with_import_plugin(mut self, yes: bool) -> Self {
self.import_plugin = yes;
@ -261,7 +269,8 @@ impl LintOptions {
"jsx_a11y" => self.jsx_a11y_plugin,
"nextjs" => self.nextjs_plugin,
"react_perf" => self.react_perf_plugin,
"eslint" | "oxc" | "tree_shaking" => true,
"oxc" => self.oxc_plugin,
"eslint" | "tree_shaking" => true,
name => panic!("Unhandled plugin: {name}"),
})
.cloned()