Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ new-vitest-rule name:
new-regexp-rule name:
cargo run -p rulegen {{name}} regexp

new-vue-rule name:
cargo run -p rulegen {{name}} vue

[unix]
clone-submodule dir url sha:
cd {{dir}} || git init {{dir}}
Expand Down
8 changes: 8 additions & 0 deletions tasks/rulegen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ const VITEST_TEST_PATH: &str =

const REGEXP_TEST_PATH: &str = "https://raw.githubusercontent.com/ota-meshi/eslint-plugin-regexp/refs/heads/master/tests/lib/rules";

const VUE_TEST_PATH: &str =
"https://raw.githubusercontent.com/vuejs/eslint-plugin-vue/master/tests/lib/rules/";

struct TestCase {
source_text: String,
code: Option<String>,
Expand Down Expand Up @@ -600,6 +603,7 @@ pub enum RuleKind {
Promise,
Vitest,
Regexp,
Vue,
}

impl RuleKind {
Expand All @@ -619,6 +623,7 @@ impl RuleKind {
"promise" => Self::Promise,
"vitest" => Self::Vitest,
"regexp" => Self::Regexp,
"vue" => Self::Vue,
_ => Self::ESLint,
}
}
Expand All @@ -642,6 +647,7 @@ impl Display for RuleKind {
Self::Promise => "eslint-plugin-promise",
Self::Vitest => "eslint-plugin-vitest",
Self::Regexp => "eslint-plugin-regexp",
Self::Vue => "eslint-plugin-vue",
};
f.write_str(kind_name)
}
Expand Down Expand Up @@ -671,6 +677,7 @@ fn main() {
RuleKind::Promise => format!("{PROMISE_TEST_PATH}/{kebab_rule_name}.js"),
RuleKind::Vitest => format!("{VITEST_TEST_PATH}/{kebab_rule_name}.test.ts"),
RuleKind::Regexp => format!("{REGEXP_TEST_PATH}/{kebab_rule_name}.ts"),
RuleKind::Vue => format!("{VUE_TEST_PATH}/{kebab_rule_name}.js"),
RuleKind::Oxc => String::new(),
};
let language = match rule_kind {
Expand Down Expand Up @@ -794,6 +801,7 @@ fn get_mod_name(rule_kind: RuleKind) -> String {
RuleKind::Vitest => "vitest".into(),
RuleKind::Node => "node".into(),
RuleKind::Regexp => "regexp".into(),
RuleKind::Vue => "vue".into(),
}
}

Expand Down
1 change: 1 addition & 0 deletions tasks/rulegen/src/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ impl<'a> Template<'a> {
RuleKind::Promise => Path::new("crates/oxc_linter/src/rules/promise"),
RuleKind::Vitest => Path::new("crates/oxc_linter/src/rules/vitest"),
RuleKind::Regexp => Path::new("crates/oxc_linter/src/rules/regexp"),
RuleKind::Vue => Path::new("crates/oxc_linter/src/rules/vue"),
};

std::fs::create_dir_all(path)?;
Expand Down
Loading