@@ -238,30 +238,45 @@ impl Linter {
238238 }
239239 } else {
240240 for ( rule, ref ctx) in rules {
241- rule. run_once ( ctx) ;
242-
243- for symbol in semantic. scoping ( ) . symbol_ids ( ) {
244- rule. run_on_symbol ( symbol, ctx) ;
245- }
241+ let ( ast_types, all_types, only_runs_on_nodes) = rule. types_info ( ) ;
246242
247- // For smaller files, benchmarking showed it was faster to iterate over all rules and just check the
248- // node types as we go, rather than pre-bucketing rules by AST node type and doing extra allocations.
249- let ( ast_types, all_types, _) = rule. types_info ( ) ;
250- if all_types {
251- for node in semantic. nodes ( ) {
252- rule. run ( node, ctx) ;
243+ if only_runs_on_nodes {
244+ if all_types {
245+ for node in semantic. nodes ( ) {
246+ rule. run ( node, ctx) ;
247+ }
248+ } else {
249+ for node in semantic. nodes ( ) {
250+ if ast_types. has ( node. kind ( ) . ty ( ) ) {
251+ rule. run ( node, ctx) ;
252+ }
253+ }
253254 }
254255 } else {
255- for node in semantic. nodes ( ) {
256- if ast_types. has ( node. kind ( ) . ty ( ) ) {
256+ rule. run_once ( ctx) ;
257+
258+ for symbol in semantic. scoping ( ) . symbol_ids ( ) {
259+ rule. run_on_symbol ( symbol, ctx) ;
260+ }
261+
262+ // For smaller files, benchmarking showed it was faster to iterate over all rules and just check the
263+ // node types as we go, rather than pre-bucketing rules by AST node type and doing extra allocations.
264+ if all_types {
265+ for node in semantic. nodes ( ) {
257266 rule. run ( node, ctx) ;
258267 }
268+ } else {
269+ for node in semantic. nodes ( ) {
270+ if ast_types. has ( node. kind ( ) . ty ( ) ) {
271+ rule. run ( node, ctx) ;
272+ }
273+ }
259274 }
260- }
261275
262- if should_run_on_jest_node {
263- for jest_node in iter_possible_jest_call_node ( semantic) {
264- rule. run_on_jest_node ( & jest_node, ctx) ;
276+ if should_run_on_jest_node {
277+ for jest_node in iter_possible_jest_call_node ( semantic) {
278+ rule. run_on_jest_node ( & jest_node, ctx) ;
279+ }
265280 }
266281 }
267282 }
0 commit comments