mirror of
https://github.com/danbulant/oxc
synced 2026-05-22 05:38:54 +00:00
feat(tasks): add eslint-plugin-n rulegen (#2272)
related: https://github.com/oxc-project/oxc/issues/493 Support generate rules from [eslint-plugin-n](https://github.com/eslint-community/eslint-plugin-n).
This commit is contained in:
parent
d7feadedb4
commit
2ceba79dcd
3 changed files with 11 additions and 0 deletions
3
justfile
3
justfile
|
|
@ -112,6 +112,9 @@ new-jsdoc-rule name:
|
|||
new-react-perf-rule name:
|
||||
cargo run -p rulegen {{name}} react-perf
|
||||
|
||||
new-n-rule name:
|
||||
cargo run -p rulegen {{name}} n
|
||||
|
||||
# Sync all submodules with their own remote repos (this is for Boshen updating the submodules)
|
||||
sync-submodules:
|
||||
git submodule update --init --remote
|
||||
|
|
|
|||
|
|
@ -50,6 +50,9 @@ const JSDOC_TEST_PATH: &str =
|
|||
const REACT_PERF_TEST_PATH: &str =
|
||||
"https://raw.githubusercontent.com/cvazac/eslint-plugin-react-perf/main/tests/lib/rules";
|
||||
|
||||
const NODE_TEST_PATH: &str =
|
||||
"https://raw.githubusercontent.com/eslint-community/eslint-plugin-n/master/tests/lib/rules";
|
||||
|
||||
struct TestCase<'a> {
|
||||
source_text: String,
|
||||
code: Option<String>,
|
||||
|
|
@ -437,6 +440,7 @@ pub enum RuleKind {
|
|||
DeepScan,
|
||||
NextJS,
|
||||
JSDoc,
|
||||
Node,
|
||||
}
|
||||
|
||||
impl RuleKind {
|
||||
|
|
@ -452,6 +456,7 @@ impl RuleKind {
|
|||
"deepscan" => Self::DeepScan,
|
||||
"nextjs" => Self::NextJS,
|
||||
"jsdoc" => Self::JSDoc,
|
||||
"n" => Self::Node,
|
||||
_ => Self::ESLint,
|
||||
}
|
||||
}
|
||||
|
|
@ -471,6 +476,7 @@ impl Display for RuleKind {
|
|||
Self::Oxc => write!(f, "oxc"),
|
||||
Self::NextJS => write!(f, "eslint-plugin-next"),
|
||||
Self::JSDoc => write!(f, "eslint-plugin-jsdoc"),
|
||||
Self::Node => write!(f, "eslint-plugin-n"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -495,6 +501,7 @@ fn main() {
|
|||
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::Node => format!("{NODE_TEST_PATH}/{kebab_rule_name}.js"),
|
||||
RuleKind::Oxc | RuleKind::DeepScan => String::new(),
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ impl<'a> Template<'a> {
|
|||
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"),
|
||||
RuleKind::Node => Path::new("crates/oxc_linter/src/rules/node"),
|
||||
};
|
||||
|
||||
std::fs::create_dir_all(path)?;
|
||||
|
|
|
|||
Loading…
Reference in a new issue