A personal enhanced fork of the Oxc VS Code extension, providing editor integration for oxlint (linter) and oxfmt (formatter).
Origin / 原始插件
This extension is based on the official Oxc VS Code extension: marketplace.visualstudio.com — oxc.oxc-vscode
The original extension provides:
- Oxlint diagnostics (warnings / errors highlighting, quick fixes, fix-all command)
- Oxfmt document formatting via
source.format.oxccode action - JSON schema validation for oxlint config files
- Multi-root workspace support
- Type-aware linting with
oxlint-tsgolint
Enhancements / 增强说明
1. source.format.oxc works without editor.defaultFormatter
EN: The original extension required editor.defaultFormatter to be set before source.format.oxc could be used in editor.codeActionsOnSave. This fork removes that dependency — the code action now works independently via codeActionsOnSave without any defaultFormatter configuration.
中文: 原插件中,source.format.oxc 通过 codeActionsOnSave 触发时,隐式依赖 editor.defaultFormatter 已被设置。本 fork 移除了这一依赖,source.format.oxc 现在可以完全独立通过 codeActionsOnSave 使用,无需配置 defaultFormatter。
2. Independent requireConfig for linter and formatter / 独立的 requireConfig 控制
EN: The original oxc.requireConfig only controlled whether oxlint required a config file to start; oxfmt always started regardless. This fork introduces:
oxc.lint.requireConfig— controls oxlint independently (takes priority overoxc.requireConfig)oxc.fmt.requireConfig— controls oxfmt independently; recognized config files:.oxfmtrc.json,.oxfmtrc.jsonc,oxfmt.config.tsoxc.requireConfig— retained as a backward-compatible alias foroxc.lint.requireConfig
中文: 原插件的 oxc.requireConfig 仅对 oxlint 生效,oxfmt 始终启动。本 fork 新增:
oxc.lint.requireConfig— 单独控制 oxlint,优先级高于oxc.requireConfigoxc.fmt.requireConfig— 单独控制 oxfmt;支持的配置文件:.oxfmtrc.json、.oxfmtrc.jsonc、oxfmt.config.tsoxc.requireConfig— 保留,作为oxc.lint.requireConfig的向后兼容别名
3. Formatter workspace boundary guard / Formatter workspace 边界守卫
EN: In the original extension, source.format.oxc was offered as a code action for any file opened in VS Code, including files outside all workspace folders. This fork restricts the code action to files within a workspace folder only. Files opened from outside the workspace are unaffected.
Note: when editor.defaultFormatter is explicitly set to this extension, formatting still works for all files — that is a separate VS Code code path and is intentional.
中文: 原插件中,source.format.oxc code action 对所有打开的文件生效,包括 workspace 以外打开的文件。本 fork 将此 code action 限定为仅对 workspace 内的文件提供。
注意:如果显式配置了 editor.defaultFormatter 指向本插件,则所有文件仍可正常格式化——这是 VS Code 的独立路径,属于预期行为。
Usage / 完整用法
Oxlint
// .vscode/settings.json
// Run linter on save only (default: onType)
{
"oxc.lint.run": "onSave"
}
// Only start oxlint when a config file exists in the workspace
{
"oxc.lint.requireConfig": true
}
// Apply all auto-fixable lint issues on save
{
"editor.codeActionsOnSave": {
"source.fixAll.oxc": "always"
}
}
Oxfmt
Default formatter (recommended for manual formatting):
{
"editor.defaultFormatter": "alphatr.oxc-vscode-enhance",
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "file"
}
Code action on save (no defaultFormatter required):
{
"editor.codeActionsOnSave": {
"source.format.oxc": "always"
}
}
Formatter + linter on save (order matters):
{
"editor.defaultFormatter": "alphatr.oxc-vscode-enhance",
"editor.formatOnSave": false,
"editor.codeActionsOnSave": {
"source.format.oxc": "always",
"source.fixAll.oxc": "always"
}
}
Only start oxfmt when a config file exists:
{
"oxc.fmt.requireConfig": true
}
Recognized oxfmt config files: .oxfmtrc.json, .oxfmtrc.jsonc, oxfmt.config.ts.
Specify formatter config explicitly per workspace folder:
{
"oxc.fmt.configPath": "./oxfmt.config.ts"
}
Configuration
Window Configuration
Following configurations are supported via settings.json and affect the window editor:
| Key | Default Value | Possible Values | Description |
|---|---|---|---|
oxc.enable |
null |
true | false | <null> |
This is a master toggle for both oxc.enable.oxlint and oxc.enable.oxfmt. |
oxc.enable.oxfmt |
true |
true | false |
Enable oxfmt (formatter). Falls back to oxc.enable if not set. |
oxc.enable.oxlint |
true |
true | false |
Enable oxlint (linter). Falls back to oxc.enable if not set. |
oxc.fmt.requireConfig |
false |
true | false |
Start oxfmt only when a .oxfmtrc.json(c) or oxfmt.config.ts file exists in one of the workspaces. |
oxc.lint.requireConfig |
null |
true | false | <null> |
Start oxlint only when a .oxlintrc.json(c) or oxlint.config.ts file exists in one of the workspaces. Takes priority over oxc.requireConfig when set to a non-null value. |
oxc.path.node |
- | <string> |
Path to a Node.js binary. Will be added to the oxfmt and oxlint PATH environment. |
oxc.path.oxfmt |
- | <string> |
Path to an Oxc formatter binary. Default: auto detection in node_modules. |
oxc.path.oxlint |
- | <string> |
Path to an Oxc linter binary. Default: auto detection in node_modules. |
oxc.path.tsgolint |
- | <string> |
Path to an Oxc tsgolint binary. Default: auto detection from oxlint. |
oxc.requireConfig |
false |
true | false |
Alias for oxc.lint.requireConfig. Start oxlint only when a .oxlintrc.json(c) or oxlint.config.ts file exists in one of the workspaces. oxc.lint.requireConfig takes priority when both are set. |
oxc.suppressProgramErrors |
false |
true | false |
Suppress tsconfig errors from tsgolint and still lint files under partially-valid tsconfig projects. When enabled, sets OXLINT_TSGOLINT_DANGEROUSLY_SUPPRESS_PROGRAM_DIAGNOSTICS=true. Note: Type-aware lint rules may produce degraded results when the tsconfig is broken. |
oxc.trace.server |
off |
off | messages | verbose |
Traces the communication between VS Code and the language server. |
oxc.useExecPath |
false |
true | false |
Whether to use the extension's execPath (Electron's bundled Node.js) as the JavaScript runtime for running Oxc tools, instead of looking for a system Node.js installation. |
| Deprecated | |||
oxc.path.server |
- | <string> |
Path to Oxc language server binary. Mostly for testing the language server. |
Workspace Configuration
Following configurations are supported via settings.json and can be changed for each workspace:
| Key | Default Value | Possible Values | Description |
|---|---|---|---|
oxc.configPath |
null |
<string> | <null> |
Path to oxlint configuration. Keep it empty to enable nested configuration. |
oxc.disableNestedConfig |
false |
true | false |
Disable searching for nested configuration files. When set to true, only the configuration file specified in oxc.configPath (if any) will be used. |
oxc.fixKind |
null |
safe_fix | safe_fix_or_suggestion | dangerous_fix | dangerous_fix_or_suggestion | none | all |
Specify the kind of fixes to suggest/apply. |
oxc.fmt.configPath |
null |
<string> | <null> |
Path to an oxfmt configuration file |
oxc.lint.run |
onType |
onSave | onType |
Run the linter on save (onSave) or on type (onType) |
oxc.tsConfigPath |
null |
<string> | <null> |
Path to the project's TypeScript config file. If your tsconfig.json is not at the root, you will need this set for the import plugin rules to resolve imports correctly. |
oxc.typeAware |
null |
true | false | <null> |
Forces type-aware linting. Requires the oxlint-tsgolint package. It is preferred to use options.typeAware in your configuration file |
oxc.unusedDisableDirectives |
null |
allow | warn | deny |
Define how directive comments like // oxlint-disable-line should be reported, when no errors would have been reported on that line anyway. It is preferred to use options.reportUnusedDisableDirectives in your configuration file |
| Deprecated | |||
oxc.flags |
{} |
Record<string, string> |
Specific Oxlint flags to pass to the language server. |
oxc.fmt.experimental |
true |
true | false |
Enable Oxfmt formatting support. |
FixKind
"safe_fix"(default)"safe_fix_or_suggestion""dangerous_fix""dangerous_fix_or_suggestion""none""all"
RulesCustomization
Each rule name maps to an object with the following optional properties:
autofix:true|false— Whether autofix should be disabled for this rule.severity:"error"|"warning"|"info"|"hint"|"off"— Diagnostic severity override for this rule.
Example:
{
"oxc.lint.customization": {
"no-unused-vars": {
"severity": "warning",
"autofix": false
}
}
}
Acknowledgment / 致谢
This extension is forked from the official oxc-vscode extension, maintained by the Oxc project. All core functionality — the LSP client architecture, binary resolution, workspace configuration system, and the oxlint / oxfmt integrations — is built on their excellent work.
本插件 fork 自 oxc-project/oxc-vscode,感谢 Oxc 团队构建了如此出色的工具链与编辑器集成基础。