fix(linter/plugins): fire after hook after CFG events in ESLint compat#20720
Merged
graphite-app[bot] merged 1 commit intomainfrom Mar 25, 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. |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes ESLint-compat behavior in eslintCompatPlugin so createOnce after hooks run after all AST visitor callbacks and CFG event handlers (notably onCodePathEnd on the root Program).
Changes:
- Switch
afterhook execution from aProgram:exitselector to a wrappedonCodePathEndhandler gated on the rootProgramnode. - Add an ESLint compat fixture rule exercising CFG callbacks and asserting
afterruns last. - Update fixture configs and snapshots to include an isolated
cfg.jsrun.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| apps/oxlint/src-js/package/compat.ts | Run after via onCodePathEnd on the root Program, ensuring it fires after CFG events. |
| apps/oxlint/test/fixtures/eslintCompat/plugin.ts | Add a fixture rule that records CFG events and asserts after ordering. |
| apps/oxlint/test/fixtures/eslintCompat/files/cfg.js | New fixture input designed to produce CFG events. |
| apps/oxlint/test/fixtures/eslintCompat/eslint.config.js | Split ESLint config so only the CFG rule runs on cfg.js. |
| apps/oxlint/test/fixtures/eslintCompat/.oxlintrc.json | Split oxlint config similarly using overrides for cfg.js. |
| apps/oxlint/test/fixtures/eslintCompat/output.snap.md | Update oxlint snapshot output to include the new CFG fixture run. |
| apps/oxlint/test/fixtures/eslintCompat/eslint.snap.md | Update ESLint snapshot output to include the new CFG fixture run. |
Contributor
Merge activity
|
…pat (#20720) Fix a bug in `eslintCompatPlugin`. `after` hooks should fire after all other visit functions, including CFG event handlers. Previously `eslintCompatPlugin` added a `Program:exit` visit function to run the `after` hook, but it turns out this isn't the last to fire during AST visitation - last is the `onCodePathEnd` CFG event on `Program` node. Fix this by running `after` hook in `onCodePathEnd` event handler instead. This simplifies the code somewhat as we no longer need to make sure that the visit function's key is a selector with higher specificity than all other `:exit` visit functions. The downside is that the `onCodePathEnd` handler needs to check each time that the node it's called with is root `Program` node. But we make that check as cheap as possible by keeping a reference to `Program` node in a local var.
694fdb1 to
31145a9
Compare
graphite-app bot
pushed a commit
that referenced
this pull request
Mar 30, 2026
# Oxlint ### 💥 BREAKING CHANGES - c0ebbce linter: [**BREAKING**] Report error on unknown builtin rule (#20464) (camc314) ### 🚀 Features - 04f85e5 linter/no-unused-vars: Add safe-fix option for import fixes (#20839) (Marcell Toth) - 32a3706 linter/eslint-vitest-plugin: Implements `require-test-timeout` rule (#20806) (Said Atrahouch) - ae03653 linter: Implement suggestion for `eslint/no-useless-computed-key` rule (#20805) (Mikhail Baev) - 6624513 linter/prefer-string-starts-ends-with: Move rule from nursery to style (#20797) (camc314) - 58941f8 linter/prefer-readonly: Move rule from nursery to style (#20796) (camc314) - 8837ffd linter/prefer-regexp-exec: Move rule from nursery to style (#20795) (camc314) - 7e88871 linter/prefer-find: Move rule out of nursery (#20794) (camc314) - ca6e5bc linter/vitest: Implement prefer-called-exactly-once-with (#17562) (Said Atrahouch) - e80c0bf linter/eslint-plugin-vitest: Implement `require-mock-type-parameters` (#20785) (Said Atrahouch) - cec8b8f linter/vitest: Implement require-awaited-expect-poll rule (#20702) (Said Atrahouch) - d8e9d01 linter/eslint-plugin-vitest: Set `prefer-to-have-been-called-times` compatible with jest (#20703) (Said Atrahouch) - caf8231 linter: Enhance import plugin diagnostics with help messages (#20766) (离谱) - f44adfa linter: Improve the oxlint config generated by `--init`. (#20632) (connorshea) - 43f4827 linter: Add help text to jest and promise diagnostics (#20640) (kszongic) - 16516de linter: Enhance types for `DummyRule` (#20751) (camc314) - 27374e8 linter: Add hint about node version when ts config fail to import (#20570) (camc314) - 8e34150 linter/eslint-plugin-vitest: Sync rule with JS implementation (#20679) (Said Atrahouch) ### 🐛 Bug Fixes - df057d5 linter/no-noninteractive-tabindex: Add missing composite widget … (#20860) (bab) - bb34073 linter: Mark vitest/valid-title as a compatible jest rules (#20463) (Nicolas Le Cam) - bd2c76b linter: Handle shadowed locals in no-restricted-globals (#20811) (Ulrich Stark) - 62e39be linter: Sort nested object keys in fix of `eslint/sort-keys` in one pass (#20838) (Ulrich Stark) - 3ef37da oxlint/lsp: Error on unknown command (#20841) (Sysix) - ab1070d oxlint/cli: Skip parsing base config again for nested config search (#20809) (Sysix) - 2be3728 oxlint/lsp: Skip parsing base config again for nested config search (#20808) (Sysix) - 6171217 oxlint: Respect `NO_COLOR` env for `format=stylish` (#20804) (Sysix) - d89ae8f linter/plugins: Patch `WeakMap` to emulate `WeakMap`s keyed by `sourceCode` (#20799) (overlookmotel) - c610666 linter/no-shadow: Respect env settings when builtinGlobals is enabled (#20429) (vvnikita74) - 6bb502f linter/no-invalid-void-type: Allow void generic args in heritage clauses (#20780) (camc314) - 365bb7d linter: Skip typed nested literals in explicit-module-boundary-types (#20776) (camc314) - 0aa1ff0 linter/plugins: Ensure `after` hook is always called in ESLint compat mode (#20721) (overlookmotel) - 31145a9 linter/plugins: Fire `after` hook after CFG events in ESLint compat (#20720) (overlookmotel) - c09a5ab diagnostics: Skip minified fallback for single-line reporters (#20716) (camc314) - e4dc9a1 linter: Isolate `--init` config writes from parallel tests (#20717) (camc314) - 7e394ec linter: Clarify empty replacement fixer help text (#20698) (camc314) - d15a99c linter/jsx-curly-brace-presence: Flag empty string literals (#20690) (camc314) ### 📚 Documentation - c722495 linter: Update JS Plugins + LS references (#20843) (camc314) - e1f9748 linter/jsdoc/require-property: Fix typo (#20792) (Benjaming61001) - be3dcc1 linter: Add note about node version + custom TS plugin (#19381) (camc314) # Oxfmt ### 🚀 Features - 6ef440a oxfmt: Support bool for object style options (#20853) (leaysgur) - 23050fa oxfmt: Support markdown-in-js substitution (#20683) (leaysgur) - 4087295 oxfmt: Support angular-in-js substitution (#20676) (leaysgur)
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 in
eslintCompatPlugin.afterhooks should fire after all other visit functions, including CFG event handlers.Previously
eslintCompatPluginadded aProgram:exitvisit function to run theafterhook, but it turns out this isn't the last to fire during AST visitation - last is theonCodePathEndCFG event onProgramnode.Fix this by running
afterhook inonCodePathEndevent handler instead. This simplifies the code somewhat as we no longer need to make sure that the visit function's key is a selector with higher specificity than all other:exitvisit functions.The downside is that the
onCodePathEndhandler needs to check each time that the node it's called with is rootProgramnode. But we make that check as cheap as possible by keeping a reference toProgramnode in a local var.