Skip to content

perf(linter): optimize no-loop-func#22491

Merged
graphite-app[bot] merged 1 commit into
mainfrom
05-16-perf_linter_optimize_no-loop-func_
May 17, 2026
Merged

perf(linter): optimize no-loop-func#22491
graphite-app[bot] merged 1 commit into
mainfrom
05-16-perf_linter_optimize_no-loop-func_

Conversation

@camchenry

@camchenry camchenry commented May 17, 2026

Copy link
Copy Markdown
Member

Currently the no-loop-func rule looks at all function expressions and then checks if they are inside of loops. In addition, some of the helpers iterate over many nodes trying to determine the context.

I've optimized this rule to only look at loop nodes first and then find functions inside of them. This still involves a fair amount of traversing the AST, but we can at least guarantee we will never traverse the whole entire thing, which was possible for. In addition, it is now compatible with the linter codegen automatically, so this rule will be skipped in files with no loops (which is probably quite a few).

The general flow now is:

  1. Find loop nodes
  2. Look for functions inside of the loop (AST visitor)
  3. Check each function in the loop:
    • Like before, check for IIFEs and nested functions
    • Report if unsafe references

Running locally on the actualbudget/actual repository this improves the performance considerably:

  • Before: 410ms (for only this rule)
  • After: 2ms

Produced with the help of AI.

@github-actions github-actions Bot added the A-linter Area - Linter label May 17, 2026

Copy link
Copy Markdown
Member Author

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent changes, fast-track this PR to the front of the merge queue

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@codspeed-hq

codspeed-hq Bot commented May 17, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 4 untouched benchmarks
⏩ 47 skipped benchmarks1


Comparing 05-16-perf_linter_optimize_no-loop-func_ (572ed30) with main (98be95c)

Open in CodSpeed

Footnotes

  1. 47 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@camchenry camchenry marked this pull request as ready for review May 17, 2026 01:00
@camchenry camchenry requested a review from camc314 as a code owner May 17, 2026 01:00
@camchenry camchenry added the 0-merge Merge with Graphite Merge Queue label May 17, 2026

camchenry commented May 17, 2026

Copy link
Copy Markdown
Member Author

Merge activity

- supersedes #22476
- closes #22471

Currently the `no-loop-func` rule looks at _all_ function expressions and then checks if they are inside of loops. In addition, some of the helpers iterate over many nodes trying to determine the context.

I've optimized this rule to only look at loop nodes first and then find functions inside of them. This still involves a fair amount of traversing the AST, but we can at least guarantee we will never traverse the whole entire thing, which was possible for. In addition, it is now compatible with the linter codegen automatically, so this rule will be skipped in files with no loops (which is probably quite a few).

The general flow now is:

1. Find loop nodes
2. Look for functions inside of the loop (AST visitor)
3. Check each function in the loop:
    - Like before, check for IIFEs and nested functions
    - Report if unsafe references

Running locally on the `actualbudget/actual` repository this improves the performance considerably:

- Before: 410ms (for only this rule)
- After: 2ms

Produced with the help of AI.
@graphite-app graphite-app Bot force-pushed the 05-16-perf_linter_optimize_no-loop-func_ branch from 572ed30 to 2afef79 Compare May 17, 2026 20:10
@graphite-app graphite-app Bot merged commit 2afef79 into main May 17, 2026
28 checks passed
@graphite-app graphite-app Bot deleted the 05-16-perf_linter_optimize_no-loop-func_ branch May 17, 2026 20:13
@graphite-app graphite-app Bot removed the 0-merge Merge with Graphite Merge Queue label May 17, 2026
camc314 pushed a commit that referenced this pull request May 18, 2026
# Oxlint
### 🚀 Features

- 1ae291e linter/no-underscore-dangle: Add `allowInUsingDeclarations`
option (#22483) (吴杨帆)
- 0440b0f linter/eslint: Implement `id-match` rule (#22379) (Vladislav
Sayapin)
- 65bf119 linter: Implement react no-object-type-as-default-prop
(#22481) (uhyo)
- 2a6ddce linter/eslint: Implement `no-implied-eval` rule (#22391)
(Vladislav Sayapin)
- d3a3c1d linter: Auto detect agents from CLI and transition to the
agent output format (#22068) (Jovi De Croock)
- 625758a linter/vitest: Implement padding-around-after-all-blocks rule
(#21788) (kapobajza)
- 37680b0 linter: Implement react no-unstable-nested-components (#22248)
(Jovi De Croock)
- d8d9c74 linter: Implement import/newline-after-import rule (#19142)
(Ryuya Yanagi)

### 🐛 Bug Fixes

- 3f59e03 linter: Only call rayon/miette/tracing inits once (#21899)
(Matiss Janis Aboltins)
- 602dfd6 linter/promise/no-return-wrap: Detect Promise calls in all
branches (#22474) (zennnnnnn11)
- e182aee linter: Allow dialogs and popovers for no_autofocus (#22289)
(mehm8128)
- 7ffb710 linter/jest/vitest: Jest/no-standalone-expect ignores
additionalTestBlockFunctions option for jest/vitest hooks (#22477)
(kapobajza)
- c6f2d3f linter: Add more expression support for iframe-has-title
(#22460) (mehm8128)
- 5747ff1 linter: Avoid enabling jest with vitest plugin (#22499)
(camc314)
- 863984f linter/no-find-dom-node: Run on all files (#22479) (bab)

### ⚡ Performance

- 2afef79 linter: Optimize `no-loop-func` (#22491) (camchenry)
- 4c9ca72 oxlint: Align walker thread count with rayon pool (#22494)
(Boshen)

### 📚 Documentation

- f7967c7 linter/id-match: Clarify `onlyDeclarations` config docs
(#22523) (camc314)
- 1e0c97f linter: Fix closing code block in documentation for
`padding-around-after-all-blocks` rule. (#22513) (connorshea)
- a9049fd linter: Exclude directly provide autoFocus to dialog pattern
(#22510) (mehm8128)
# Oxfmt
### 🐛 Bug Fixes

- 8ee946f formatter/sort_imports: Use label to classify lines (#22512)
(leaysgur)
- 8c1da44 formatter: Normalize destructuring keys in DCR (#22478)
(camc314)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

linter: Speed up no-loop-func rule

1 participant