Skip to content

Commit 3d98ce4

Browse files
committed
perf(linter): extract node types from more rules
1 parent 2381b5b commit 3d98ce4

File tree

3 files changed

+366
-131
lines changed

3 files changed

+366
-131
lines changed

crates/oxc_linter/src/rule.rs

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,39 @@ mod test {
369369
&[MethodDefinition],
370370
);
371371
assert_rule_runs_on_node_types(
372-
&import::no_mutable_exports::NoMutableExports,
373-
&[ExportNamedDeclaration, ExportDefaultDeclaration],
372+
&eslint::no_array_constructor::NoArrayConstructor,
373+
&[CallExpression, NewExpression],
374+
);
375+
assert_rule_runs_on_node_types(
376+
&eslint::no_console::NoConsole::default(),
377+
&[StaticMemberExpression, ComputedMemberExpression],
378+
);
379+
assert_rule_runs_on_node_types(
380+
&eslint::no_extra_label::NoExtraLabel,
381+
&[BreakStatement, ContinueStatement],
382+
);
383+
assert_rule_runs_on_node_types(
384+
&eslint::getter_return::GetterReturn::default(),
385+
&[Function, ArrowFunctionExpression],
386+
);
387+
assert_rule_runs_on_node_types(
388+
&eslint::new_cap::NewCap::default(),
389+
&[NewExpression, CallExpression],
390+
);
391+
assert_rule_runs_on_node_types(
392+
&eslint::no_cond_assign::NoCondAssign::default(),
393+
&[
394+
IfStatement,
395+
WhileStatement,
396+
DoWhileStatement,
397+
ForStatement,
398+
ConditionalExpression,
399+
AssignmentExpression,
400+
],
401+
);
402+
assert_rule_runs_on_node_types(
403+
&import::no_webpack_loader_syntax::NoWebpackLoaderSyntax,
404+
&[CallExpression, ImportDeclaration],
374405
);
375406
assert_rule_runs_on_node_types(
376407
&jest::prefer_jest_mocked::PreferJestMocked,
@@ -393,6 +424,10 @@ mod test {
393424
&oxc::bad_bitwise_operator::BadBitwiseOperator,
394425
&[BinaryExpression, AssignmentExpression],
395426
);
427+
assert_rule_runs_on_node_types(
428+
&oxc::only_used_in_recursion::OnlyUsedInRecursion,
429+
&[Function, ArrowFunctionExpression],
430+
);
396431
assert_rule_runs_on_node_types(
397432
&promise::prefer_await_to_callbacks::PreferAwaitToCallbacks,
398433
&[CallExpression, Function, ArrowFunctionExpression],
@@ -405,6 +440,10 @@ mod test {
405440
&typescript::ban_types::BanTypes,
406441
&[TSTypeReference, TSTypeLiteral],
407442
);
443+
assert_rule_runs_on_node_types(
444+
&typescript::no_wrapper_object_types::NoWrapperObjectTypes,
445+
&[TSTypeReference, TSClassImplements, TSInterfaceHeritage],
446+
);
408447
assert_rule_runs_on_node_types(
409448
&unicorn::explicit_length_check::ExplicitLengthCheck::default(),
410449
&[StaticMemberExpression],
@@ -413,6 +452,10 @@ mod test {
413452
&unicorn::no_zero_fractions::NoZeroFractions,
414453
&[NumericLiteral],
415454
);
455+
assert_rule_runs_on_node_types(
456+
&unicorn::prefer_array_find::PreferArrayFind,
457+
&[AssignmentExpression, CallExpression, ComputedMemberExpression, VariableDeclarator],
458+
);
416459

417460
assert!(!&jest::max_expects::MaxExpects::ONLY_RUNS_ON_NODES);
418461
}

0 commit comments

Comments
 (0)