Skip to content

Commit 1dced5d

Browse files
committed
perflinter): refactor no-amd to do scope check after node type check
1 parent e1b25e3 commit 1dced5d

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

crates/oxc_linter/src/generated/rule_runner_impls.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,8 @@ impl RuleRunner for crate::rules::import::no_absolute_path::NoAbsolutePath {
10771077
}
10781078

10791079
impl RuleRunner for crate::rules::import::no_amd::NoAmd {
1080-
const NODE_TYPES: Option<&AstTypesBitset> = None;
1080+
const NODE_TYPES: Option<&AstTypesBitset> =
1081+
Some(&AstTypesBitset::from_types(&[AstType::CallExpression]));
10811082
const RUN_FUNCTIONS: RuleRunFunctionsImplemented = RuleRunFunctionsImplemented::Run;
10821083
}
10831084

crates/oxc_linter/src/rules/import/no_amd.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,10 @@ declare_oxc_lint!(
5151
/// <https://github.com/import-js/eslint-plugin-import/blob/v2.29.1/docs/rules/no-amd.md>
5252
impl Rule for NoAmd {
5353
fn run<'a>(&self, node: &AstNode<'a>, ctx: &LintContext<'a>) {
54-
// not in top level
55-
if node.scope_id() != ctx.scoping().root_scope_id() {
56-
return;
57-
}
5854
if let AstKind::CallExpression(call_expr) = node.kind()
5955
&& let Expression::Identifier(identifier) = &call_expr.callee
56+
// must be in top level
57+
&& node.scope_id() == ctx.scoping().root_scope_id()
6058
{
6159
if identifier.name != "define" && identifier.name != "require" {
6260
return;

0 commit comments

Comments
 (0)