Skip to content

Commit cff65c0

Browse files
committed
wip: skip rules that do not have any relevant node types
1 parent 95f9aa3 commit cff65c0

File tree

12 files changed

+4154
-22
lines changed

12 files changed

+4154
-22
lines changed

Cargo.lock

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/oxc_linter/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ mod module_graph_visitor;
2525
mod module_record;
2626
mod options;
2727
mod rule;
28+
mod rule_runner_impls;
2829
mod service;
2930
mod tsgolint;
3031
mod utils;
@@ -56,7 +57,7 @@ pub use crate::{
5657
module_record::ModuleRecord,
5758
options::LintOptions,
5859
options::{AllowWarnDeny, InvalidFilterKind, LintFilter, LintFilterKind},
59-
rule::{RuleCategory, RuleFixMeta, RuleMeta},
60+
rule::{RuleCategory, RuleFixMeta, RuleMeta, RuleRunner},
6061
service::{LintService, LintServiceOptions, RuntimeFileSystem},
6162
tsgolint::TsGoLintState,
6263
utils::{read_to_arena_str, read_to_string},

crates/oxc_linter/src/rule.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::{fmt, hash::Hash};
55
use schemars::{JsonSchema, SchemaGenerator, schema::Schema};
66
use serde::{Deserialize, Serialize};
77

8-
use oxc_semantic::SymbolId;
8+
use oxc_semantic::{AstTypesBitset, SymbolId};
99

1010
use crate::{
1111
AstNode, FixKind,
@@ -66,6 +66,16 @@ pub trait Rule: Sized + Default + fmt::Debug {
6666
}
6767
}
6868

69+
pub trait RuleRunner: Rule {
70+
/// `AstType`s that rule acts on
71+
const NODE_TYPES: &AstTypesBitset;
72+
/// `true` if codegen can't figure out what node types rule acts on
73+
const ANY_NODE_TYPE: bool;
74+
75+
fn types_info(&self) -> (&'static AstTypesBitset, bool) {
76+
(Self::NODE_TYPES, Self::ANY_NODE_TYPE)
77+
}
78+
}
6979
pub trait RuleMeta {
7080
const NAME: &'static str;
7181

0 commit comments

Comments
 (0)