mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
feat(tasks): Add eslint-plugin-jsdoc rulegen (#1965)
Hello. 👋🏻 This PR makes `just new-jsdoc-rule xxxx` command works. --- Initially, I planned to implement some basic rules later. However, after struggling for half a day, I realized that it would be challenging for a beginner like me to do it now. 😓 Once I have looked for something else I can do, and/or read more into the codebase, I hope to be able to try again at some point.
This commit is contained in:
parent
4706765d2a
commit
8a7efc2c3b
3 changed files with 12 additions and 0 deletions
3
justfile
3
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
|
||||
|
|
|
|||
|
|
@ -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<String>,
|
||||
|
|
@ -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(),
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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)?;
|
||||
|
|
|
|||
Loading…
Reference in a new issue