refactor(linter): add missing should_run implementations (#6666)

Added some `should_run` implementations that probably should exist but didn't previously.
This commit is contained in:
camchenry 2024-10-19 17:54:25 +00:00
parent 34fe7c00a3
commit 2eb984ab05
3 changed files with 11 additions and 11 deletions

View file

@ -39,9 +39,6 @@ declare_oxc_lint!(
impl Rule for NoUnusedLabels {
fn run_once(&self, ctx: &LintContext) {
if ctx.file_path().extension().is_some_and(|ext| ext == "svelte") {
return;
}
for id in ctx.semantic().unused_labels() {
let node = ctx.semantic().nodes().get_node(*id);
let AstKind::LabeledStatement(stmt) = node.kind() else {
@ -53,6 +50,10 @@ impl Rule for NoUnusedLabels {
);
}
}
fn should_run(&self, ctx: &crate::context::ContextHost) -> bool {
ctx.file_path().extension().is_some_and(|ext| ext != "svelte")
}
}
#[test]

View file

@ -93,14 +93,14 @@ declare_oxc_lint!(
impl Rule for NoUntypedMockFactory {
fn run_once(&self, ctx: &LintContext<'_>) {
if !ctx.source_type().is_typescript() {
return;
}
for possible_jest_node in &collect_possible_jest_call_node(ctx) {
Self::run(possible_jest_node, ctx);
}
}
fn should_run(&self, ctx: &crate::context::ContextHost) -> bool {
ctx.source_type().is_typescript()
}
}
impl NoUntypedMockFactory {

View file

@ -83,10 +83,6 @@ impl Rule for NoNamespace {
return;
}
if self.allow_definition_files && ctx.source_type().is_typescript_definition() {
return;
}
let declaration_code = declaration.span.source_text(ctx.source_text());
let span = match declaration.kind {
@ -104,6 +100,9 @@ impl Rule for NoNamespace {
}
fn should_run(&self, ctx: &ContextHost) -> bool {
if self.allow_definition_files && ctx.source_type().is_typescript_definition() {
return false;
}
ctx.source_type().is_typescript()
}
}