Skip to content

fix(oxlint,oxfmt): resolve Vite+ config root from the config file directory - #28801

Merged
leaysgur merged 5 commits into
oxc-project:mainfrom
fengmk2:fix/vite-plus-config-root
Nov 6, 2026
Merged

leaysgur merged 5 commits into
oxc-project:mainfrom
fengmk2:fix/vite-plus-config-root

Conversation

@fengmk2

@fengmk2 fengmk2 commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

In Vite+ mode, Oxlint and Oxfmt loaded vite.config.* with resolveConfig({ configFile }, "build"). Vite resolves an unset or relative root from process.cwd(). The LSP cwd can be another folder of a multi-root workspace. Plugins such as TanStack Start then read files from the wrong project, and the config fails to load.

This PR uses resolveConfigFromFile() from vite-plus 1.5.0 (voidzero-dev/vite-plus#3249). It resolves an unset or relative root from the config file's directory and keeps the user's root.

Assume the cwd is /work/editor and the config is /repo/vite.config.ts:

Config root Before After
Unset /work/editor /repo
"app" /work/editor/app /repo/app
"/srv/site" /srv/site /srv/site
  • If the installed vite-plus does not export resolveConfigFromFile (older than 1.5.0), the loader falls back to resolveConfig() and keeps the old cwd-based behavior. The optional peer range is "vite-plus": "*", so older versions can still occur.
  • The vite-plus catalog moves to 1.5.0.
  • A scoped override vite-plus>vite: npm:@voidzero-dev/vite-plus-core@1.5.0 keeps the Vite+ core for vite-plus. The global vite override replaced the core with upstream Vite, which ignores the internal option that resolveConfigFromFile uses. Keep this override in sync with the vite-plus catalog version.
  • The Oxfmt CLI output normalizer now matches the shorter diagnostic format that the Vite+ core prints.

The LSP binary selection in multi-root workspaces (the first problem in the issue) is tracked in oxc-project/oxc-vscode#145 and oxc-project/oxc-vscode#418.

Refs voidzero-dev/vite-plus#3217

This PR was prepared with AI assistance (Claude Code).

🤖 Generated with Claude Code

fengmk2 and others added 2 commits November 4, 2026 19:54
…ectory

In Vite+ mode, Oxlint and Oxfmt loaded `vite.config.*` with
`resolveConfig({ configFile }, "build")`, so an unset or relative `root`
came from `process.cwd()`. The LSP cwd can be another folder of a
multi-root workspace, and plugins then read files from the wrong project.

Use `resolveConfigFromFile()` from `vite-plus` >= 1.5.0, which resolves
`root` from the config file's directory. Fall back to `resolveConfig()`
when an older `vite-plus` does not export it.

Bump the `vite-plus` catalog to 1.5.0, and keep its own Vite core with a
scoped `vite-plus>vite` override. The global `vite` override replaced the
core with upstream Vite, which ignores the option that the helper uses.

Refs voidzero-dev/vite-plus#3217

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Vite+ core prints a code frame box after the warning line. When the
checkout path makes the source line long, it prints ` - ...` detail lines
instead. Match both forms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fengmk2
fengmk2 marked this pull request as ready for review November 4, 2026 11:55
@fengmk2
fengmk2 force-pushed the fix/vite-plus-config-root branch from 1fa867e to 0e63759 Compare November 4, 2026 11:55
leaysgur and others added 3 commits November 5, 2026 10:51
Nothing in the workspace depends on `vite` directly; it only arrives as Vitest 5's peer.
The global `vite` override also replaced `vite-plus`'s Vite+ core with upstream Vite,
which needed the scoped `vite-plus>vite` override kept in sync by hand.
Dropping both keeps Vitest on `vite@8.3.4` via the lockfile and lets `vite-plus` use its own core.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-plus`

`vite-plus` pins Oxlint and Oxfmt, so versions with this code only ship with `vite-plus` >= 1.5.0,
which always has `resolveConfigFromFile`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Move the Oxfmt case into the existing `vite_plus` fixtures, keeping only the unset `root` case
- Use `import.meta.dirname` in the fixture configs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@leaysgur

leaysgur commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Thanks! I pushed a few follow-up commits:

  • Dropped the vite catalog entry and both vite overrides.
    • Nothing here depends on vite directly; it only comes in as Vitest 5's peer, and the lockfile still pins it to vite@8.3.4.
    • vite-plus now gets its own core without a version to keep in sync by hand.
  • Removed the resolveConfig fallback.
    • vite-plus bundles Oxlint and Oxfmt, so versions with this code only ship with vite-plus >= 1.5.0.
  • Made the tests smaller
    • Oxfmt case now lives in the existing vite_plus fixtures, with only the unset root case, and the fixtures use import.meta.dirname.

Let me know if there are any issues. If everything looks good, I'll go ahead and merge it~.

@github-actions github-actions Bot added A-linter Area - Linter (oxlint): rules, config, diagnostics, fixes. Add L-* labels for details A-cli Area - oxlint / oxfmt common CLI behavior: flags, ignore files, oxc_config A-formatter Area - Formatter (oxfmt). Add F-* labels for details L-js-plugins Linter > JS plugins (ESLint-compatible plugin API) labels Nov 5, 2026
@fengmk2

fengmk2 commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

@leaysgur LGTM!

@leaysgur leaysgur added the 0-merge Merge with Graphite Merge Queue label Nov 6, 2026
@graphite-app

graphite-app Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Merge activity

  • Nov 6, 4:14 AM UTC: @fengmk2 we removed the merge queue label because we could not find a Graphite account associated with your GitHub profile.

You must have a Graphite account in order to use the merge queue. Create an account and try again using this link

@graphite-app graphite-app Bot removed the 0-merge Merge with Graphite Merge Queue label Nov 6, 2026
@leaysgur
leaysgur merged commit fa66fde into oxc-project:main Nov 6, 2026
30 checks passed
graphite-app Bot pushed a commit that referenced this pull request Nov 6, 2026
# Oxlint
### 🚀 Features

- 4a52ba2 oxlint: Discover tsrs for type-aware linting (#28751) (camc314)
- b7d2c75 linter/eslint/no-redeclare: Add `ignoreDeclarationMerge` option (#28816) (Cam McHenry)

### 🐛 Bug Fixes

- fa66fde oxlint,oxfmt: Resolve Vite+ config root from the config file directory (#28801) (MK (fengmk2))
- 2091564 linter/jsdoc/require-param: Ignore enclosing function JSDoc (#28866) (camc314)
- c6ec50b linter/react/only-export-components: Classify JSX values as non-components (#28761) (camc314)
- 3c051ab linter/vitest/prefer-called-exactly-once-with: Preserve neighboring code in autofix (#28864) (camc314)
- 674b962 linter/eslint/no-misleading-character-class: Use lazy regex for combining marks (#28822) (Sysix)
- 838d339 linter/vitest/prefer-called-exactly-once-with: Avoid panic on non-ASCII text (#28850) (YT)
- 8d24c26 linter/jsx-a11y/aria-role: Allow role={undefined} (#28804) (Abhay Godavarthy)
- a7143bf linter/eslint/no-restricted-imports: Respect allowTypeImports correctly for empty patterns (#28842) (Cam McHenry)
- 3d3a6f4 react-compiler: Ignore callback-local reassignments (#28820) (camc314)
- 0cc6515 linter/unicorn/prefer-type-error: Report throws in unbraced if branches (#28819) (camc314)
- ae43c80 linter/unicorn/prefer-single-call: Remove duplicate fix status (#28763) (Mikhail Baev)
- a8a621a linter/eslint/no-fallthrough: Ignore unreachable exits from infinite loops (#28755) (camc314)
- 7a17a80 linter/eslint/prefer-spread: Report calls on non-member expressions (#28753) (camc314)
- 28442f7 oxlint: Prevent --init from overwriting existing configs (#28754) (camc314)
- 0ae350d linter/unicorn/no-zero-fractions: Preserve exponent case (#28752) (camc314)
- b5b3f3f linter/eslint/no-misleading-character-class: Detect more combining characters (#28733) (Sysix)

### ⚡ Performance

- 74d50c1 linter: Overlap import graph batches instead of polling on a pool worker (#28323) (Dunqing)
# Oxfmt
### 💥 BREAKING CHANGES

- 00d1a67 oxfmt: [**BREAKING**] Format `parser:vue` files by `oxc_formatter_htmlish` (#28848) (leaysgur)

### 🚀 Features

- 9a81e58 formatter_htmlish: Format Vue templates (#28847) (leaysgur)
- 119d82f formatter: Format a template's expressions and handlers as `JsRoot` (#28846) (leaysgur)

### 🐛 Bug Fixes

- fa66fde oxlint,oxfmt: Resolve Vite+ config root from the config file directory (#28801) (MK (fengmk2))
- 4d4104d formatter_htmlish: Preserve `doctype` case in embedded (#28797) (leaysgur)
- ebfd40a formatter: Sort Tailwind calls printed as member chains (#28800) (Yuji Sugiura)
- e62e5cb formatter: Decide quotes of a Tailwind key printed as one class (#28798) (Yuji Sugiura)
- 959edc1 formatter: Don't sort templates in nested non-Tailwind calls (#28794) (Yuji Sugiura)
- 6ffbe32 formatter/jsdoc: Prevent `@tag` from being moved to the line start (#28835) (leaysgur)
- 94fbef5 formatter_css: Treat comments in `style` attr as fill items (#28832) (leaysgur)
- e4a80f7 formatter_css: Normalize selectors inside `:deep`, `:slotted` and `:local` (#28805) (leaysgur)
- 255c5cc formatter: Measure Tailwind class argument after collapsing whitespace (#28745) (Lee Jaeha / Adam)
- e6c4fef formatter: Decide template and object key layouts from collapsed Tailwind classes (#28791) (Yuji Sugiura)
- 0b44164 formatter: Decide JSX opening element layout from collapsed Tailwind class string (#28744) (Lee Jaeha / Adam)
- b8ba9ae formatter: Print decorators on rest parameters (#28731) (YT)

### ⚡ Performance

- 2766d07 oxfmt: Spawn Prettier workers on demand (#28789) (YT)
- 07627f7 oxfmt: Use worker_threads for tinypool again (#28787) (Yuji Sugiura)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cli Area - oxlint / oxfmt common CLI behavior: flags, ignore files, oxc_config A-formatter Area - Formatter (oxfmt). Add F-* labels for details A-linter Area - Linter (oxlint): rules, config, diagnostics, fixes. Add L-* labels for details L-js-plugins Linter > JS plugins (ESLint-compatible plugin API)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants