diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_preserve_editor_jsonc_comments/snapshots/migration_preserve_editor_jsonc_comments.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_preserve_editor_jsonc_comments/snapshots/migration_preserve_editor_jsonc_comments.md index 27c3311b47..395dbbef4f 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_preserve_editor_jsonc_comments/snapshots/migration_preserve_editor_jsonc_comments.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_preserve_editor_jsonc_comments/snapshots/migration_preserve_editor_jsonc_comments.md @@ -37,7 +37,8 @@ top-level and nested comments survive; oxc settings are added without overwritin "[typescriptreact]": { "editor.defaultFormatter": "oxc.oxc-vscode" }, - "oxc.fmt.configPath": "./vite.config.ts", + "oxc.disableNestedConfig": true, + "oxc.fmt.disableNestedConfig": true, "editor.formatOnSave": true, "editor.formatOnSaveMode": "file", } diff --git a/docs/guide/fmt.md b/docs/guide/fmt.md index 3e3cc61cee..73bd9eee0c 100644 --- a/docs/guide/fmt.md +++ b/docs/guide/fmt.md @@ -20,11 +20,11 @@ vp fmt . --write Put formatting configuration directly in the `fmt` block in `vite.config.ts` so all your configuration stays in one place. We do not recommend using `.oxfmtrc.json` with Vite+. -For editors, point the formatter config path at `./vite.config.ts` so format-on-save uses the same `fmt` block: +For editors, disable nested formatter configs so format-on-save uses the root Vite+ `fmt` block: ```json [.vscode/settings.json] { - "oxc.fmt.configPath": "./vite.config.ts" + "oxc.fmt.disableNestedConfig": true } ``` diff --git a/docs/guide/ide-integration.md b/docs/guide/ide-integration.md index 554da52e4f..9710d76a85 100644 --- a/docs/guide/ide-integration.md +++ b/docs/guide/ide-integration.md @@ -26,7 +26,8 @@ You can also manually set up the VS Code config: "[javascriptreact]": { "editor.defaultFormatter": "oxc.oxc-vscode" }, "[typescript]": { "editor.defaultFormatter": "oxc.oxc-vscode" }, "[typescriptreact]": { "editor.defaultFormatter": "oxc.oxc-vscode" }, - "oxc.fmt.configPath": "./vite.config.ts", + "oxc.disableNestedConfig": true, + "oxc.fmt.disableNestedConfig": true, "editor.formatOnSave": true, "editor.formatOnSaveMode": "file", "editor.codeActionsOnSave": { @@ -35,7 +36,7 @@ You can also manually set up the VS Code config: } ``` -This gives the project a shared default formatter and enables Oxc-powered fix actions on save. The language-specific override blocks (`[javascript]`, `[typescript]`, etc.) are required because VS Code prioritizes user-level `[language]` settings over the workspace-level `editor.defaultFormatter` — without them, a global Prettier configuration would silently take over. Setting `oxc.fmt.configPath` to `./vite.config.ts` keeps editor format-on-save aligned with the `fmt` block in your Vite+ config. Vite+ uses `formatOnSaveMode: "file"` because Oxfmt does not support partial formatting. +This gives the project a shared default formatter and enables Oxc-powered fix actions on save. The language-specific override blocks (`[javascript]`, `[typescript]`, etc.) are required because VS Code prioritizes user-level `[language]` settings over the workspace-level `editor.defaultFormatter` — without them, a global Prettier configuration would silently take over. Setting `oxc.disableNestedConfig` and `oxc.fmt.disableNestedConfig` prevents nested Oxlint and Oxfmt configs from diverging from the root Vite+ config. Vite+ uses `formatOnSaveMode: "file"` because Oxfmt does not support partial formatting. To let the VS Code NPM Scripts panel run scripts through `vp`, add the following to your `.vscode/settings.json`: diff --git a/packages/cli/src/utils/__tests__/editor.spec.ts b/packages/cli/src/utils/__tests__/editor.spec.ts index 12eeabd64c..7af435ae0f 100644 --- a/packages/cli/src/utils/__tests__/editor.spec.ts +++ b/packages/cli/src/utils/__tests__/editor.spec.ts @@ -109,7 +109,8 @@ describe('writeEditorConfigs', () => { ) as Record; expect(settings['editor.defaultFormatter']).toBe('oxc.oxc-vscode'); - expect(settings['oxc.fmt.configPath']).toBe('./vite.config.ts'); + expect(settings['oxc.disableNestedConfig']).toBe(true); + expect(settings['oxc.fmt.disableNestedConfig']).toBe(true); expect(settings['editor.formatOnSave']).toBe(true); expect(settings['npm.scriptRunner']).toBeUndefined(); for (const lang of ['[javascript]', '[javascriptreact]', '[typescript]', '[typescriptreact]']) { @@ -182,7 +183,8 @@ describe('writeEditorConfigs', () => { // New keys are added expect(settings['editor.defaultFormatter']).toBe('oxc.oxc-vscode'); - expect(settings['oxc.fmt.configPath']).toBe('./vite.config.ts'); + expect(settings['oxc.disableNestedConfig']).toBe(true); + expect(settings['oxc.fmt.disableNestedConfig']).toBe(true); expect(settings['npm.scriptRunner']).toBe('vp'); for (const lang of ['[javascript]', '[javascriptreact]', '[typescriptreact]']) { expect(settings[lang]).toEqual({ 'editor.defaultFormatter': 'oxc.oxc-vscode' }); diff --git a/packages/cli/src/utils/editor.ts b/packages/cli/src/utils/editor.ts index c5bc47c890..2801e30749 100644 --- a/packages/cli/src/utils/editor.ts +++ b/packages/cli/src/utils/editor.ts @@ -26,7 +26,8 @@ const VSCODE_LANGUAGE_OVERRIDES = { const VSCODE_SETTINGS = { 'editor.defaultFormatter': 'oxc.oxc-vscode', ...VSCODE_LANGUAGE_OVERRIDES, - 'oxc.fmt.configPath': './vite.config.ts', + 'oxc.disableNestedConfig': true, + 'oxc.fmt.disableNestedConfig': true, 'editor.formatOnSave': true, // Oxfmt does not support partial formatting 'editor.formatOnSaveMode': 'file',