-
Notifications
You must be signed in to change notification settings - Fork 164
fix(cli)!: stop injecting -c config so oxlint/oxfmt pick up nested vite.config.ts #1378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
fengmk2
wants to merge
12
commits into
support-disable-nested-config
Choose a base branch
from
fix-nested-oxc-config
base: support-disable-nested-config
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
14547de
test(snap): add nested-oxc-config-proj-1 to reproduce nested vite.con…
fengmk2 38869d6
test(snap): exclude nested-oxc-config-proj-1 fixture from repo fmt
fengmk2 ed793f7
fix(cli): stop injecting -c config for oxlint/oxfmt
fengmk2 622da1d
test(snap): cover root-workspace fallback in nested-oxc-config-proj-1
fengmk2 899c1de
test(snap): drop unused pnpm-lock.yaml from nested-oxc-config-proj-1
fengmk2 920464b
perf(check): defer resolve_universal_vite_config to the lint branch
fengmk2 8c5c8d6
test(snap): cover root-cwd lint in workspace-lint-subpackage
fengmk2 a15e3db
test(snap): pin oxlint ignorePatterns + nested-config behavior
fengmk2 a2115d5
chore: add disable-nested-config
fengmk2 f1547b7
docs(guide): document vite.config.ts nested-config resolution
fengmk2 046831c
test(snap): cover bare `vp lint` / `vp fmt --check` at the workspace …
fengmk2 4102ae2
docs(guide): restructure nested-config resolution rules
fengmk2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| # Nested Configuration | ||
|
|
||
| Vite+ supports multiple `vite.config.ts` files in a repository, so packages in a monorepo can have their own lint and format settings while sharing a baseline. | ||
|
|
||
| ## How `vp lint` and `vp fmt` pick a config | ||
|
|
||
| Config resolution is driven by the current working directory (cwd): | ||
|
|
||
| - **`vp lint`** uses `<cwd>/vite.config.ts`. If that file is missing, built-in defaults apply — `vp lint` does **not** walk up the directory tree looking for a parent `vite.config.ts`. | ||
| - **`vp fmt`** walks up from cwd and uses the first `vite.config.ts` it finds. If none is found, built-in defaults apply. | ||
|
|
||
| In both cases, the selected config applies to every path in the run — there is no per-file resolution, and configs are never merged. | ||
|
|
||
| If your monorepo needs different settings per package, run `vp lint` / `vp fmt` from each package directory (for example, via `vp run -r lint`), or pin a specific config with `-c`. | ||
|
|
||
| If you only want to exclude files or folders from an otherwise-shared config, use [`lint.ignorePatterns`](/config/lint) or [`fmt.ignorePatterns`](/config/fmt) instead. | ||
|
|
||
| ::: tip Breaking change since the April 2026 release | ||
|
|
||
| Earlier versions of Vite+ pinned every `vp lint` / `vp fmt` invocation to the workspace-root `vite.config.ts`, regardless of cwd. Vite+ now lets cwd-based resolution select the config, so running from a sub-package picks up that sub-package's own `vite.config.ts`. See [#1378](https://github.com/voidzero-dev/vite-plus/pull/1378) for the migration notes. | ||
|
|
||
| ::: | ||
|
|
||
| ## Example | ||
|
|
||
| Given this layout: | ||
|
|
||
| ``` | ||
| my-project/ | ||
| ├── vite.config.ts | ||
| ├── src/ | ||
| │ └── index.ts | ||
| ├── package1/ | ||
| │ ├── vite.config.ts | ||
| │ └── src/index.ts | ||
| └── package2/ | ||
| └── src/index.ts | ||
| ``` | ||
|
|
||
| `vp lint`: | ||
|
|
||
| | cwd | config used | | ||
| | ---------------------------- | ----------------------------------- | | ||
| | `my-project/` | `my-project/vite.config.ts` | | ||
| | `my-project/package1/` | `my-project/package1/vite.config.ts`| | ||
| | `my-project/package1/src/` | built-in defaults (no walk-up) | | ||
| | `my-project/package2/` | built-in defaults (no walk-up) | | ||
|
|
||
| `vp fmt`: | ||
|
|
||
| | cwd | config used | | ||
| | ---------------------------- | ------------------------------------ | | ||
| | `my-project/` | `my-project/vite.config.ts` | | ||
| | `my-project/package1/` | `my-project/package1/vite.config.ts` | | ||
| | `my-project/package1/src/` | `my-project/package1/vite.config.ts` | | ||
| | `my-project/package2/` | `my-project/vite.config.ts` | | ||
|
|
||
| ## Pinning a config with `-c` | ||
|
|
||
| `-c` / `--config` bypasses cwd-based resolution. The specified file is used for every path in the run: | ||
|
|
||
| ```bash | ||
| vp lint -c vite.config.ts | ||
| vp fmt --check -c vite.config.ts | ||
| ``` | ||
|
|
||
| This also works when you need a one-off config, for example a permissive CI variant. | ||
|
|
||
| ## `--disable-nested-config` (lint only) | ||
|
|
||
| `vp lint` accepts `--disable-nested-config` to stop any auto-loading of nested lint configuration files that may exist in the tree: | ||
|
|
||
| ```bash | ||
| vp lint --disable-nested-config | ||
| vp check --disable-nested-config | ||
| ``` | ||
|
|
||
| This flag has no effect on `vite.config.ts` resolution, which is already cwd-only for `vp lint`. `vp fmt` has no equivalent flag; use `-c` to pin a single format config. | ||
|
|
||
| ## Monorepo pattern: share a base config | ||
|
|
||
| Configs are never merged automatically — the selected config fully replaces any other. To share a baseline, import the parent config and spread it: | ||
|
|
||
| ```ts [my-project/vite.config.ts] | ||
| import { defineConfig } from 'vite-plus'; | ||
|
|
||
| export default defineConfig({ | ||
| lint: { | ||
| rules: { | ||
| 'no-debugger': 'error', | ||
| }, | ||
| }, | ||
| }); | ||
| ``` | ||
|
|
||
| ```ts [my-project/package1/vite.config.ts] | ||
| import { defineConfig } from 'vite-plus'; | ||
| import baseConfig from '../vite.config.ts'; | ||
|
|
||
| export default defineConfig({ | ||
| ...baseConfig, | ||
| lint: { | ||
| ...baseConfig.lint, | ||
| rules: { | ||
| ...baseConfig.lint?.rules, | ||
| 'no-console': 'off', | ||
| }, | ||
| }, | ||
| }); | ||
| ``` | ||
|
|
||
| This keeps the shared baseline in one place and makes package configs small and focused. |
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "name": "docs-nested-config-test", | ||
| "version": "0.0.0", | ||
| "private": true, | ||
| "type": "module", | ||
| "packageManager": "pnpm@10.16.1" | ||
| } |
5 changes: 5 additions & 0 deletions
5
packages/cli/snap-tests/docs-nested-config/packages/pkg-a/package.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "name": "pkg-a", | ||
| "version": "0.0.0", | ||
| "private": true | ||
| } |
6 changes: 6 additions & 0 deletions
6
packages/cli/snap-tests/docs-nested-config/packages/pkg-a/src/index.js
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| function pkgA() { | ||
| debugger; | ||
| return "hello from pkg-a"; | ||
| } | ||
|
|
||
| export { pkgA }; |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@leaysgur @camc314 can we support disable nested config in
vite.config.tstoo?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're asking whether that applies even when using
vite.config.tsin VP mode, I think the answer is yes.