Skip to content
Merged
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
11 changes: 10 additions & 1 deletion crates/oxc_linter/src/rules/eslint/no_this_before_super.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use oxc_ast::{
AstKind,
AstKind, AstType,
ast::{Argument, Expression, MethodDefinitionKind},
};
use oxc_cfg::{
Expand Down Expand Up @@ -58,6 +58,11 @@ enum DefinitelyCallsThisBeforeSuper {
Maybe(BlockNodeId),
}

/// Node types that should be in the file in order to run this analysis. Otherwise, the AST
/// will be skipped for linting.
const NEEDED_NODE_TYPES: &AstTypesBitset =
&AstTypesBitset::from_types(&[AstType::ThisExpression, AstType::Super]);

impl Rule for NoThisBeforeSuper {
fn run_once(&self, ctx: &LintContext) {
let cfg = ctx.cfg();
Expand Down Expand Up @@ -132,6 +137,10 @@ impl Rule for NoThisBeforeSuper {
}
}
}

fn should_run(&self, ctx: &crate::context::ContextHost) -> bool {
ctx.semantic().nodes().contains_any(NEEDED_NODE_TYPES)
}
}

impl NoThisBeforeSuper {
Expand Down
Loading