Skip to content

fix(linter/plugins): fix interaction between JS plugins and Vue rules - #26080

Merged
graphite-app[bot] merged 1 commit into
mainfrom
om/08-25-fix_linter_plugins_fix_interaction_between_js_plugins_and_vue_rules
Aug 25, 2026
Merged

graphite-app[bot] merged 1 commit into
mainfrom
om/08-25-fix_linter_plugins_fix_interaction_between_js_plugins_and_vue_rules

Conversation

@overlookmotel

@overlookmotel overlookmotel commented Aug 25, 2026 •

Copy link
Copy Markdown
Member

While working on #26077, Claude spotted another related bug.

JS plugins have to run last because they need to mutate the AST, and in the process they destroy the stored AST.

For files with multiple sections (Vue, Astro, Svelte), we ran native rules then JS rules for each section in turn. That appeared fine - JS rules do run last. But the problem is that some rules e.g. vue/valid-define-emits also access earlier sections. Because JS plugins already ran on those previous sections, their ASTs have been discarded already, leading to incorrect results.

Instead, lint in 3 separate passes which each run on all sections before going on to the next pass:

  1. Native rules.
  2. JS rules.
  3. Unused directives.

i.e.:

  • Before: section 1 native, section 1 JS, section 2 native, section 2 JS.
  • After: section 1 native, section 2 native, section 1 JS, section 2 JS.

Unused directives check has to be in a separate final pass, as it requires both native rules and JS rules to have run before it.

Looping over sections is cheap compared to the work that happens in each turn of the loops, so I very much doubt this has a measurable impact on perf.

This change does have one visible effect: The order of diagnostics will change for multi-section files. Previously diagnostics would be output in section order, now they're in rule type (native/JS) order. I don't think that matters.

overlookmotel commented Aug 25, 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

codspeed Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 5 untouched benchmarks
⏩ 76 skipped benchmarks1


Comparing om/08-25-fix_linter_plugins_fix_interaction_between_js_plugins_and_vue_rules (c42adb9) with main (b13215f)

Open in CodSpeed

Footnotes

  1. 76 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. ↩

@overlookmotel
overlookmotel force-pushed the om/08-25-fix_linter_plugins_fix_interaction_between_js_plugins_and_vue_rules branch from c92f96b to 763a0bb Compare August 25, 2026 12:09
@overlookmotel
overlookmotel force-pushed the om/08-25-refactor_linter_remove_source_text_field_from_contextsubhost_ branch from 2eb6e11 to 4ae1e2f Compare August 25, 2026 12:09
@overlookmotel
overlookmotel requested a review from camc314 August 25, 2026 12:24
@overlookmotel
overlookmotel marked this pull request as ready for review August 25, 2026 12:24
Copilot AI lite review requested due to automatic review settings August 25, 2026 12:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@overlookmotel

overlookmotel commented Aug 25, 2026 •

Copy link
Copy Markdown
Member Author

@camc314 This is the part I'm not sure about:

The order of diagnostics will change for multi-section files. Previously diagnostics would be output in section order, now they're in rule type (native/JS) order. I don't think that matters.

Can you please confirm/deny?

@overlookmotel
overlookmotel force-pushed the om/08-25-refactor_linter_remove_source_text_field_from_contextsubhost_ branch from 4ae1e2f to 829764f Compare August 25, 2026 12:38
@overlookmotel
overlookmotel force-pushed the om/08-25-fix_linter_plugins_fix_interaction_between_js_plugins_and_vue_rules branch from 763a0bb to 8912279 Compare August 25, 2026 12:38
@overlookmotel
overlookmotel force-pushed the om/08-25-fix_linter_plugins_fix_interaction_between_js_plugins_and_vue_rules branch from 8912279 to efcb238 Compare August 25, 2026 12:40
@overlookmotel
overlookmotel force-pushed the om/08-25-refactor_linter_remove_source_text_field_from_contextsubhost_ branch from 829764f to dcfc1ec Compare August 25, 2026 12:40
@graphite-app
graphite-app Bot changed the base branch from om/08-25-refactor_linter_remove_source_text_field_from_contextsubhost_ to graphite-base/26080 August 25, 2026 13:00
@graphite-app
graphite-app Bot force-pushed the om/08-25-fix_linter_plugins_fix_interaction_between_js_plugins_and_vue_rules branch from efcb238 to c00d33b Compare August 25, 2026 13:04
@graphite-app
graphite-app Bot force-pushed the graphite-base/26080 branch from dcfc1ec to b13215f Compare August 25, 2026 13:04
@graphite-app
graphite-app Bot changed the base branch from graphite-base/26080 to main August 25, 2026 13:05
@graphite-app
graphite-app Bot force-pushed the om/08-25-fix_linter_plugins_fix_interaction_between_js_plugins_and_vue_rules branch from c00d33b to c42adb9 Compare August 25, 2026 13:05
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Aug 25, 2026

camc314 commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Merge activity

@camc314

camc314 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

@camc314 This is the part I'm not sure about:

The order of diagnostics will change for multi-section files. Previously diagnostics would be output in section order, now they're in rule type (native/JS) order. I don't think that matters.

Can you please confirm/deny?

order of diagnostics doesn't matter.

They're sorted in tests for consistent snapshots, but we don't guarantee the order.

…#26080)

While working on #26077, Claude spotted another related bug.

JS plugins have to run last because they need to mutate the AST, and in the process they destroy the stored AST.

For files with multiple sections (Vue, Astro, Svelte), we ran native rules then JS rules for each section in turn. That appeared fine - JS rules do run last. But the problem is that some rules e.g. `vue/valid-define-emits` also access _earlier_ sections. Because JS plugins already ran on those previous sections, their ASTs have been discarded already, leading to incorrect results.

Instead, lint in 3 separate passes which each run on _all_ sections before going on to the next pass:

1. Native rules.
2. JS rules.
3. Unused directives.

i.e.:

- Before: section 1 native, section 1 JS, section 2 native, section 2 JS.
- After: section 1 native, section 2 native, section 1 JS, section 2 JS.

Unused directives check has to be in a separate final pass, as it requires both native rules and JS rules to have run before it.

Looping over sections is cheap compared to the work that happens in each turn of the loops, so I very much doubt this has a measurable impact on perf.

This change does have one visible effect: The order of diagnostics will change for multi-section files. Previously diagnostics would be output in section order, now they're in rule type (native/JS) order. I don't _think_ that matters.
@graphite-app
graphite-app Bot force-pushed the om/08-25-fix_linter_plugins_fix_interaction_between_js_plugins_and_vue_rules branch from c42adb9 to 047f7ca Compare August 25, 2026 13:20
@graphite-app
graphite-app Bot merged commit 047f7ca into main Aug 25, 2026
31 checks passed
@graphite-app graphite-app Bot removed the 0-merge Merge with Graphite Merge Queue label Aug 25, 2026
@graphite-app
graphite-app Bot deleted the om/08-25-fix_linter_plugins_fix_interaction_between_js_plugins_and_vue_rules branch August 25, 2026 13:24
graphite-app Bot pushed a commit that referenced this pull request Sep 1, 2026
# Oxlint
### 🚀 Features

- 60b945d linter/nextjs/no-typos: Implement suggestion (#26091) (Mikhail Baev)

### 🐛 Bug Fixes

- 33ac4b0 linter/lsp: Prevent tsgolint from holding onto processes (#25570) (Adrian Schaedle)
- baf4b1e linter/import/no-empty-named-blocks: Make empty value import removal a suggestion (#26155) (camc314)
- 77cfaec linter/eslint/object-shorthand: Preserve `__proto__` semantics (#26154) (camc314)
- fa3c082 linter/unicorn/prefer-set-size: Ignore shadowed `Set` constructors (#26153) (camc314)
- e412cf2 linter: Clamp invalid JS plugin locations (#26144) (camc314)
- d86c113 linter: Normalize reversed JS plugin locations (#26138) (camc314)
- 73c09b2 linter/eslint/no-use-before-define: Run on JS, JSX files (#26114) (camc314)
- 03ef0f2 linter/unicorn/no-useless-spread: Treat typed arrays as a distinct value hint (#26067) (Aadharsh  Pannirselvam)
- bd15905 linter/react/no-unstable-nested-components: Check nested component object property names (#26101) (camc314)
- 3910e2b linter/eslint/no-unassigned-vars: Skip Svelte and Vue files (#26042) (Hamody We)
- 047f7ca linter/plugins: Fix interaction between JS plugins and Vue rules (#26080) (overlookmotel)
- 8531b9b linter/plugins: Alter method for obtaining mutable `Program` when sending AST to JS plugins (#26077) (overlookmotel)
- dc464ff linter/unicorn/prefer-math-min-max: Avoid unsafe autofix (#26060) (camc314)

### 📚 Documentation

- 464ddd1 linter: Support a shared short description for jest/vitest rules (#26186) (connorshea)
- 9db5ad3 linter: Add short description to `vue/no-dupe-keys` (#26183) (connorshea)
- db66f58 linter: Correct export/import mismatch in bar and foo example (#25927) (billychannnnnn)
- d5be037 linter/typescript/switch-exhaustiveness-check: Clarify default case comment pattern (#26100) (camc314)
# Oxfmt
### 🚀 Features

- 1fb37b6 formatter/css: Format declaration-shaped raw-prelude rules (postcss nested config blocks) (#26194) (leaysgur)

### 🐛 Bug Fixes

- 57e8e22 formatter_css: Space a folded sign after a call in Less operations (#26134) (leaysgur)
- e4298fb formatter/jsdoc: Follow CommonMark for interrupting lists and guard wrapping from creating them (#26098) (leaysgur)
- a1e21c2 formatter: Apply head body policy everywhere (#26074) (leaysgur)
- 676b7e1 formatter: Keep comments in their for-head slot, before an empty-statement body and do-while (#26073) (leaysgur)
- 3bbcea6 formatter: Keep comments between a head and its body out of the braces across all constructs (#26071) (leaysgur)
- 57537a2 formatter: Place comments between a head and open paren (#26058) (leaysgur)
- e2d53e7 formatter: Place comments between a statement head and its body (#26043) (leaysgur)
- 662556c formatter: Print the idempotent placement for comments in dropped parens (#26041) (leaysgur)
- faf11d9 formatter_yaml: Keep trailing whitespace in block scalars (#26072) (leaysgur)

### ⚡ Performance

- ac4785a diagnostics: Use fixed ANSI styles (#26130) (Boshen)

### 📚 Documentation

- b879608 formatter,formatter_graphql,formatter_yaml: Annotate own-line comment inlining as known policy violation (#26131) (leaysgur)
- 181953b oxfmt,formatter_core,formatter,formatter_yaml,formatter_css,formatter_graphql: Extract `DIVERGENCES.md` out from `AGENTS.md` (#26121) (leaysgur)
- a67cb9d formatter,formatter_core: Document comment moving policy (#26075) (leaysgur)
- fc175b0 formatter_core: Clarify idempotency test infra (#26069) (leaysgur)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cli Area - CLI A-linter Area - Linter A-linter-plugins Area - Linter JS plugins

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Sponsor
SponsoredKunjungi sekarang
Promo