Skip to content

Commit 62a892a

Browse files
committed
docs(guide): restructure nested-config resolution rules
Drop oxlint/oxfmt internals from the user-facing guide, lead with the three rules (default cwd resolution, `-c` pins, `--disable-nested-config`), and replace the per-cwd bullet lists with tables. Also drop the unverified `typeAware`/`typeCheck` root-only caveat — current code does not enforce it.
1 parent 3656047 commit 62a892a

File tree

2 files changed

+42
-32
lines changed

2 files changed

+42
-32
lines changed

docs/guide/nested-config.md

Lines changed: 41 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
# Nested Configuration
22

3-
Vite+ supports multiple `vite.config.ts` files in the same repository, so packages in a monorepo can have their own lint and format settings while sharing a baseline.
3+
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.
44

5-
`vp lint` and `vp fmt` resolve configuration from the **current working directory** (cwd), but with one subtle difference:
5+
## How `vp lint` and `vp fmt` pick a config
66

7-
- **`vp lint`** — cwd-only. Uses `<cwd>/vite.config.ts` if it exists. If not, falls back to Oxlint's built-in defaults — it does **not** walk up to find an ancestor config.
8-
- **`vp fmt`** — cwd walk-up. Walks up from cwd and uses the first `vite.config.ts` it finds. If none is found anywhere up to the filesystem root, falls back to Oxfmt defaults.
7+
Config resolution is driven by the current working directory (cwd):
98

10-
In both cases, the selected config applies to every path in the run.
9+
- **`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`.
10+
- **`vp fmt`** walks up from cwd and uses the first `vite.config.ts` it finds. If none is found, built-in defaults apply.
1111

12-
If you only need to exclude files or folders, use [`lint.ignorePatterns`](/config/lint) or [`fmt.ignorePatterns`](/config/fmt) instead.
12+
In both cases, the selected config applies to every path in the run — there is no per-file resolution, and configs are never merged.
1313

14-
## How it works
14+
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`.
1515

16-
Given the following structure:
16+
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.
17+
18+
::: tip Breaking change since the April 2026 release
19+
20+
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.
21+
22+
:::
23+
24+
## Example
25+
26+
Given this layout:
1727

1828
```
1929
my-project/
@@ -29,48 +39,47 @@ my-project/
2939

3040
`vp lint`:
3141

32-
- From `my-project/` → uses `my-project/vite.config.ts` for every file (including files under `package1/` and `package2/`).
33-
- From `my-project/package1/` → uses `my-project/package1/vite.config.ts`.
34-
- From `my-project/package2/` → no local `vite.config.ts`, so Oxlint's built-in defaults are used.
35-
- From `my-project/package1/src/` → no local `vite.config.ts`, so Oxlint's built-in defaults are used even though `package1/vite.config.ts` exists one level up.
42+
| cwd | config used |
43+
| ---------------------------- | ----------------------------------- |
44+
| `my-project/` | `my-project/vite.config.ts` |
45+
| `my-project/package1/` | `my-project/package1/vite.config.ts`|
46+
| `my-project/package1/src/` | built-in defaults (no walk-up) |
47+
| `my-project/package2/` | built-in defaults (no walk-up) |
3648

3749
`vp fmt`:
3850

39-
- From `my-project/` → uses `my-project/vite.config.ts`.
40-
- From `my-project/package1/` → uses `my-project/package1/vite.config.ts`.
41-
- From `my-project/package2/` → walks up past `package2/` and uses `my-project/vite.config.ts`.
42-
- From `my-project/package1/src/` → walks up past `src/` and uses `my-project/package1/vite.config.ts`.
51+
| cwd | config used |
52+
| ---------------------------- | ------------------------------------ |
53+
| `my-project/` | `my-project/vite.config.ts` |
54+
| `my-project/package1/` | `my-project/package1/vite.config.ts` |
55+
| `my-project/package1/src/` | `my-project/package1/vite.config.ts` |
56+
| `my-project/package2/` | `my-project/vite.config.ts` |
4357

44-
If your monorepo needs different settings per package, run `vp lint` / `vp fmt` from each package directory (for example, via a `vp run -r lint` task), or pin a specific config with `-c`.
58+
## Pinning a config with `-c`
4559

46-
## What to expect
60+
`-c` / `--config` bypasses cwd-based resolution. The specified file is used for every path in the run:
4761

48-
Configuration files are not automatically merged. When a file is selected, it fully replaces any other config — there is no parent/child layering. To share settings, import the parent config and spread it; see the [monorepo pattern](#monorepo-pattern-share-a-base-config) below.
62+
```bash
63+
vp lint -c vite.config.ts
64+
vp fmt --check -c vite.config.ts
65+
```
4966

50-
Command-line options override configuration files.
67+
This also works when you need a one-off config, for example a permissive CI variant.
5168

52-
Passing an explicit config file location using `-c` or `--config` bypasses cwd-based resolution entirely, and only that single configuration file is used — for both `vp lint` and `vp fmt`.
69+
## `--disable-nested-config` (lint only)
5370

54-
For lint, you can also pass `--disable-nested-config` to stop Oxlint from picking up any stray legacy config files that may exist in the tree:
71+
`vp lint` accepts `--disable-nested-config` to stop any auto-loading of nested lint configuration files that may exist in the tree:
5572

5673
```bash
5774
vp lint --disable-nested-config
5875
vp check --disable-nested-config
5976
```
6077

61-
There is no equivalent flag for `vp fmt`; pass `-c` if you need to pin a single format config.
62-
63-
`options.typeAware` and `options.typeCheck` are root-config-only. If either is set in a nested `vite.config.ts` that ends up being selected as the lint config, `vp lint` reports an error.
64-
65-
::: tip Breaking change since the April 2026 release
66-
67-
Earlier versions of Vite+ always injected the workspace-root `vite.config.ts` into every `vp lint` / `vp fmt` invocation, regardless of cwd. Vite+ now lets cwd-based resolution select the config, so running `vp lint` / `vp fmt` from inside 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.
68-
69-
:::
78+
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.
7079

7180
## Monorepo pattern: share a base config
7281

73-
In a monorepo, you often want one shared baseline at the root and small package-specific adjustments. Import the root `vite.config.ts` from the nested one and spread it:
82+
Configs are never merged automatically — the selected config fully replaces any other. To share a baseline, import the parent config and spread it:
7483

7584
```ts [my-project/vite.config.ts]
7685
import { defineConfig } from 'vite-plus';

vite.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export default defineConfig({
7171
'packages/cli/snap-tests/fmt-ignore-patterns/src/ignored',
7272
'packages/cli/snap-tests/nested-oxc-config-proj-1/**',
7373
'packages/cli/snap-tests-global/migration-lint-staged-ts-config',
74+
'packages/cli/snap-tests/docs-nested-config',
7475
'docs/**',
7576
'ecosystem-ci/*/**',
7677
'packages/test/**.cjs',

0 commit comments

Comments
 (0)