Skip to content

Commit 18d736f

Browse files
committed
perf(linter): no-this-before-super: only run when file contains super or this
1 parent cef7b00 commit 18d736f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

crates/oxc_linter/src/rules/eslint/no_this_before_super.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use oxc_ast::{
2-
AstKind,
2+
AstKind, AstType,
33
ast::{Argument, Expression, MethodDefinitionKind},
44
};
55
use oxc_cfg::{
@@ -58,6 +58,11 @@ enum DefinitelyCallsThisBeforeSuper {
5858
Maybe(BlockNodeId),
5959
}
6060

61+
/// Node types that should be in the file in order to run this analysis. Otherwise, the AST
62+
/// will be skipped for linting.
63+
const NEEDED_NODE_TYPES: &AstTypesBitset =
64+
&AstTypesBitset::from_types(&[AstType::ThisExpression, AstType::Super]);
65+
6166
impl Rule for NoThisBeforeSuper {
6267
fn run_once(&self, ctx: &LintContext) {
6368
let cfg = ctx.cfg();
@@ -132,6 +137,10 @@ impl Rule for NoThisBeforeSuper {
132137
}
133138
}
134139
}
140+
141+
fn should_run(&self, ctx: &crate::context::ContextHost) -> bool {
142+
ctx.semantic().nodes().contains_any(NEEDED_NODE_TYPES)
143+
}
135144
}
136145

137146
impl NoThisBeforeSuper {

0 commit comments

Comments
 (0)