fix(linter/plugins): reset visitor compilation state if error during compilation#20166
Merged
graphite-app[bot] merged 1 commit intomainfrom Mar 10, 2026
Conversation
Member
Author
How to use the Graphite Merge QueueAdd either label to this PR to merge it via 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. |
This was referenced Mar 10, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a JS-plugin linting bug where an exception during visitor compilation could leave compilation state “dirty”, causing visitor functions from a failed file to leak into subsequent files.
Changes:
- Reset visitor compilation state on error by calling
finalizeCompiledVisitor()fromresetStateAfterError(). - Add an end-to-end fixture that reproduces invalid-visitor compilation failure and asserts no visitor leakage across files.
- Run the fixture single-threaded to make the file order deterministic for the test.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| apps/oxlint/src-js/plugins/lint.ts | Ensures visitor compilation state is cleaned up when lintFile() catches an error. |
| apps/oxlint/test/fixtures/lint_invalid_visitor/plugin.ts | Fixture plugin that intentionally returns an invalid visitor on the first file to trigger compilation failure. |
| apps/oxlint/test/fixtures/lint_invalid_visitor/output.snap.md | Snapshot asserting the compilation error is reported and only the second file’s visitor runs on file 2. |
| apps/oxlint/test/fixtures/lint_invalid_visitor/options.json | Forces --threads 1 to make lint order deterministic for the fixture. |
| apps/oxlint/test/fixtures/lint_invalid_visitor/files/1.js | First file used to trigger the invalid visitor compilation path. |
| apps/oxlint/test/fixtures/lint_invalid_visitor/files/2.js | Second file used to verify no visitor bleed-through. |
| apps/oxlint/test/fixtures/lint_invalid_visitor/.oxlintrc.json | Enables the fixture plugin/rule for the test run. |
69d2c89 to
02cc349
Compare
fdb28de to
425b8be
Compare
Contributor
Merge activity
|
…compilation (#20166) Fix a bug where internal state of visitor compilation could fail to be reset if an error is thrown during compilation, for example due to an invalid visitor being passed. If this happens, previously some of the visitor functions defined for one file could stick around, and be erroneously included in the compiled visitor for next file, leading to them firing on that 2nd file when they shouldn't. Fix that by resetting visitor compilation state in the `try` / `catch` which wraps the whole linting process.
425b8be to
3dabb8e
Compare
02cc349 to
c4812ec
Compare
Base automatically changed from
om/03-09-test_linter_plugins_run_rules_in_predictable_order_in_tests
to
main
March 10, 2026 01:58
graphite-app bot
pushed a commit
that referenced
this pull request
Mar 10, 2026
Perf optimization to visitor compilation. Previously the flow for compiling and using a visitor was: 1. Call `initCompiledVisitor`. 2. Call `addVisitorToCompiled` with each visitor object. 3. Call `finalizeVisitor`. 4. Walk AST with compiled visitor. `initCompiledVisitor` resets state after previous compilation. Change this to: 1. Call `addVisitorToCompiled` with each visitor object. 2. Call `finalizeVisitor`. 3. Walk AST with compiled visitor. 4. Call `resetCompiledVisitor`. The difference is that resetting state now happens at *end* of linting a file, rather than at the start of linting the *next* file. The previous lifecycle design was motivated by needing to ensure state is reset even if an error is thrown during linting, but this case is now handled correctly by another means (#20166). The reset-at-the-end lifecycle makes more sense. It also has a perf benefit: Visit functions are freed earlier, so they can be garbage collected. This reduces the chance of ephemeral visit functions being pointlessly migrated to "old space" before they're deleted, which makes garbage collection cheaper. Also, they can now be garbage collected *between* linting files, while Rust side code is busy doing other tasks - rather than GC having to happen during linting on JS side, blocking main JS thread.
leaysgur
added a commit
that referenced
this pull request
Mar 11, 2026
# Oxlint ### 🚀 Features - 04a5ce0 oxlint: Support `vite.config.ts` `.lint` field (#20214) (leaysgur) - 1735215 linter: Implement `react/no-clone-element` rule. (#20129) (connorshea) - 68e6f6f linter: Implement `react/no-react-children` rule. (#20104) (connorshea) - fe3b32e linter/plugins: Add `oxlint-plugin-eslint` package (#20009) (overlookmotel) ### 🐛 Bug Fixes - 05f6a09 linter/no-inline-comments: Deserialize rule options with serde (#20207) (camc314) - c7eb09d linter/default-case: Deserialize rule options with serde (#20206) (camc314) - f85e16c linter/plugins: Fix types for visitor compilation (#20203) (overlookmotel) - 44e24e0 linter/exhaustive-deps: Ignore type-only typeof deps (#20201) (camc314) - 0b04998 linter/no-fallthrough: Deserialize rule options with serde (#20192) (camc314) - a1031cb linter/new-cap: Deserialize rule options with serde (#20161) (camc314) - ad27fd6 linter: Add help messages to import plugin diagnostics (#20158) (John Costa) - 1340307 linter/plugins: Ensure `after` hooks always run (#20167) (overlookmotel) - c4812ec linter/plugins: Reset visitor compilation state if error during compilation (#20166) (overlookmotel) - 887eecc linter/plugins: Add license notice to `oxlint-plugin-eslint` package (#20164) (overlookmotel) - e1713a4 linter/plugins: Include common chunks in `oxlint-plugin-eslint` package (#20163) (overlookmotel) - a9acb2b linter: Check `globals` entry for `no-undef`, only check es2026 globals for `no-extend-native` and `no-constant-binary-expression` (#20089) (Sysix) - 5559f0d linter/no-unused-vars: `reportUsedIgnorePattern` should not report used rest siblings (#20108) (Don Isaac) - de7c0e2 linter/plugins: Correct error message for `markVariableAsUsed` (#20152) (overlookmotel) ### ⚡ Performance - 3a86427 linter/plugins: Pre-populate cache of `EnterExit` objects at startup (#20194) (overlookmotel) - d243391 linter/plugins: Replace arrays with `Uint8Array`s (#20190) (overlookmotel) - 8742f8b linter/plugins: Pre-populate cache of `VisitProp` objects (#20189) (overlookmotel) - 3061acb linter/plugins: Pre-populate cache of `EnterExit` objects (#20187) (overlookmotel) - c73912b linter/plugins: Free visit functions earlier (#20186) (overlookmotel) - d9f8ff4 linter/plugins: Faster reset of visitor state (#20185) (overlookmotel) - 42aff15 oxlint/lsp: Avoid computing diagnostics for non invoked code actions requests (#20080) (Sysix) ### 📚 Documentation - a080650 linter/plugins: Fix documentation of visitor compilation (#20202) (overlookmotel) - 542a04a linter: Add a link to the cyclomatic complexity Wikipedia article in `eslint/complexity` (#20174) (connorshea) # Oxfmt ### 🚀 Features - 95943aa oxfmt: Support `vite.config.*` `.fmt` field (#20197) (leaysgur) - 172fc07 oxfmt: .js/.ts config file support (#20135) (leaysgur) ### 🐛 Bug Fixes - e483569 oxfmt: Avoid double-escaping in css-in-js (#20211) (leaysgur) Co-authored-by: leaysgur <6259812+leaysgur@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fix a bug where internal state of visitor compilation could fail to be reset if an error is thrown during compilation, for example due to an invalid visitor being passed.
If this happens, previously some of the visitor functions defined for one file could stick around, and be erroneously included in the compiled visitor for next file, leading to them firing on that 2nd file when they shouldn't.
Fix that by resetting visitor compilation state in the
try/catchwhich wraps the whole linting process.