mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
feat(linter): Add --jsdoc-plugin flag (#2935)
Add flag to: ```sh $ oxlint --jsdoc-plugin ``` 
This commit is contained in:
parent
0c04bf743f
commit
ba2121f17d
4 changed files with 23 additions and 2 deletions
|
|
@ -165,6 +165,10 @@ pub struct EnablePlugins {
|
|||
#[bpaf(switch, hide_usage)]
|
||||
pub import_plugin: bool,
|
||||
|
||||
/// Enable the experimental jsdoc plugin and detect JSDoc problems
|
||||
#[bpaf(switch, hide_usage)]
|
||||
pub jsdoc_plugin: bool,
|
||||
|
||||
/// Enable the Jest plugin and detect test problems
|
||||
#[bpaf(switch, hide_usage)]
|
||||
pub jest_plugin: bool,
|
||||
|
|
|
|||
|
|
@ -95,6 +95,7 @@ impl Runner for LintRunner {
|
|||
.with_config_path(config)
|
||||
.with_fix(fix_options.fix)
|
||||
.with_import_plugin(enable_plugins.import_plugin)
|
||||
.with_jsdoc_plugin(enable_plugins.jsdoc_plugin)
|
||||
.with_jest_plugin(enable_plugins.jest_plugin)
|
||||
.with_jsx_a11y_plugin(enable_plugins.jsx_a11y_plugin)
|
||||
.with_nextjs_plugin(enable_plugins.nextjs_plugin)
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ pub struct LintOptions {
|
|||
pub fix: bool,
|
||||
pub timing: bool,
|
||||
pub import_plugin: bool,
|
||||
pub jsdoc_plugin: bool,
|
||||
pub jest_plugin: bool,
|
||||
pub jsx_a11y_plugin: bool,
|
||||
pub nextjs_plugin: bool,
|
||||
|
|
@ -39,6 +40,7 @@ impl Default for LintOptions {
|
|||
fix: false,
|
||||
timing: false,
|
||||
import_plugin: false,
|
||||
jsdoc_plugin: false,
|
||||
jest_plugin: false,
|
||||
jsx_a11y_plugin: false,
|
||||
nextjs_plugin: false,
|
||||
|
|
@ -81,6 +83,12 @@ impl LintOptions {
|
|||
self
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn with_jsdoc_plugin(mut self, yes: bool) -> Self {
|
||||
self.jsdoc_plugin = yes;
|
||||
self
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn with_jest_plugin(mut self, yes: bool) -> Self {
|
||||
self.jest_plugin = yes;
|
||||
|
|
@ -167,6 +175,8 @@ impl TryFrom<&Number> for AllowWarnDeny {
|
|||
}
|
||||
}
|
||||
|
||||
const IMPORT_PLUGIN_NAME: &str = "import";
|
||||
const JSDOC_PLUGIN_NAME: &str = "jsdoc";
|
||||
const JEST_PLUGIN_NAME: &str = "jest";
|
||||
const JSX_A11Y_PLUGIN_NAME: &str = "jsx_a11y";
|
||||
const NEXTJS_PLUGIN_NAME: &str = "nextjs";
|
||||
|
|
@ -236,7 +246,7 @@ impl LintOptions {
|
|||
Ok((rules, settings, env))
|
||||
}
|
||||
|
||||
// get final filtered rules by reading `self.jest_plugin` and `self.jsx_a11y_plugin`
|
||||
// get final filtered rules by reading `self.xxx_plugin`
|
||||
fn get_filtered_rules(&self) -> Vec<RuleEnum> {
|
||||
let mut rules = RULES.clone();
|
||||
|
||||
|
|
@ -246,6 +256,8 @@ impl LintOptions {
|
|||
}
|
||||
};
|
||||
|
||||
may_exclude_plugin_rules(self.import_plugin, IMPORT_PLUGIN_NAME);
|
||||
may_exclude_plugin_rules(self.jsdoc_plugin, JSDOC_PLUGIN_NAME);
|
||||
may_exclude_plugin_rules(self.jest_plugin, JEST_PLUGIN_NAME);
|
||||
may_exclude_plugin_rules(self.jsx_a11y_plugin, JSX_A11Y_PLUGIN_NAME);
|
||||
may_exclude_plugin_rules(self.nextjs_plugin, NEXTJS_PLUGIN_NAME);
|
||||
|
|
|
|||
|
|
@ -34,8 +34,12 @@ fn bench_linter(criterion: &mut Criterion) {
|
|||
.build(program);
|
||||
let lint_options = LintOptions::default()
|
||||
.with_filter(vec![(AllowWarnDeny::Deny, "all".into())])
|
||||
.with_import_plugin(true)
|
||||
.with_jsdoc_plugin(true)
|
||||
.with_jest_plugin(true)
|
||||
.with_jsx_a11y_plugin(true);
|
||||
.with_jsx_a11y_plugin(true)
|
||||
.with_nextjs_plugin(true)
|
||||
.with_react_perf_plugin(true);
|
||||
let linter = Linter::from_options(lint_options).unwrap();
|
||||
let semantic = Rc::new(semantic_ret.semantic);
|
||||
b.iter(|| {
|
||||
|
|
|
|||
Loading…
Reference in a new issue