Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
Expand Down
4 changes: 2 additions & 2 deletions docs/guide/fmt.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
```

Expand Down
5 changes: 3 additions & 2 deletions docs/guide/ide-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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`:

Expand Down
6 changes: 4 additions & 2 deletions packages/cli/src/utils/__tests__/editor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ describe('writeEditorConfigs', () => {
) as Record<string, unknown>;

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]']) {
Expand Down Expand Up @@ -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' });
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/utils/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Loading