diff --git a/justfile b/justfile index 04fb14fd4e201..942318799b2e2 100755 --- a/justfile +++ b/justfile @@ -102,6 +102,9 @@ new-oxc-rule name: new-nextjs-rule name: cargo run -p rulegen {{name}} nextjs +new-jsdoc-rule name: + cargo run -p rulegen {{name}} jsdoc + # Sync all submodules with their own remote repos (this is for Boshen updating the submodules) sync: git submodule update --init --remote diff --git a/tasks/rulegen/src/main.rs b/tasks/rulegen/src/main.rs index 66152279239eb..79ea64fc9bf94 100644 --- a/tasks/rulegen/src/main.rs +++ b/tasks/rulegen/src/main.rs @@ -44,6 +44,9 @@ const JSX_A11Y_TEST_PATH: &str = const NEXT_JS_TEST_PATH: &str = "https://raw.githubusercontent.com/vercel/next.js/canary/test/unit/eslint-plugin-next"; +const JSDOC_TEST_PATH: &str = + "https://raw.githubusercontent.com/gajus/eslint-plugin-jsdoc/main/test/rules/assertions"; + struct TestCase<'a> { source_text: String, code: Option, @@ -422,6 +425,7 @@ pub enum RuleKind { Oxc, DeepScan, NextJS, + JSDoc, } impl RuleKind { @@ -435,6 +439,7 @@ impl RuleKind { "oxc" => Self::Oxc, "deepscan" => Self::DeepScan, "nextjs" => Self::NextJS, + "jsdoc" => Self::JSDoc, _ => Self::ESLint, } } @@ -452,6 +457,7 @@ impl Display for RuleKind { Self::DeepScan => write!(f, "deepscan"), Self::Oxc => write!(f, "oxc"), Self::NextJS => write!(f, "eslint-plugin-next"), + Self::JSDoc => write!(f, "eslint-plugin-jsdoc"), } } } @@ -463,6 +469,7 @@ fn main() { let rule_name = args.next().expect("expected rule name").to_case(Case::Snake); let rule_kind = args.next().map_or(RuleKind::ESLint, |kind| RuleKind::from(&kind)); let kebab_rule_name = rule_name.to_case(Case::Kebab); + let camel_rule_name = rule_name.to_case(Case::Camel); let plugin_name = rule_kind.to_string(); let rule_test_path = match rule_kind { @@ -473,6 +480,7 @@ fn main() { RuleKind::React => format!("{REACT_TEST_PATH}/{kebab_rule_name}.js"), RuleKind::JSXA11y => format!("{JSX_A11Y_TEST_PATH}/{kebab_rule_name}-test.js"), RuleKind::NextJS => format!("{NEXT_JS_TEST_PATH}/{kebab_rule_name}.test.ts"), + RuleKind::JSDoc => format!("{JSDOC_TEST_PATH}/{camel_rule_name}.js"), RuleKind::Oxc | RuleKind::DeepScan => String::new(), }; diff --git a/tasks/rulegen/src/template.rs b/tasks/rulegen/src/template.rs index ed7c7523f29ee..8d9ce4d99d7ac 100644 --- a/tasks/rulegen/src/template.rs +++ b/tasks/rulegen/src/template.rs @@ -39,6 +39,7 @@ impl<'a> Template<'a> { RuleKind::Oxc => Path::new("crates/oxc_linter/src/rules/oxc"), RuleKind::DeepScan => Path::new("crates/oxc_linter/src/rules/deepscan"), RuleKind::NextJS => Path::new("crates/oxc_linter/src/rules/nextjs"), + RuleKind::JSDoc => Path::new("crates/oxc_linter/src/rules/jsdoc"), }; std::fs::create_dir_all(path)?;