diff --git a/README.md b/README.md index f7cdfbd..6a87c15 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ Following configurations are supported via `settings.json` and can be changed fo | `oxc.fixKind` | `safe_fix` | `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` | `` \| `` | Path to an oxfmt configuration file | | `oxc.lint.run` | `onType` | `onSave` \| `onType` | Run the linter on save (onSave) or on type (onType) | -| `oxc.requireConfig` | `false` | `true` \| `false` | Start the language server only when a `.oxlintrc.json` or `oxlint.config.ts` file exists in one of the workspaces. | +| `oxc.requireConfig` | `false` | `true` \| `false` | Start the language server only when a `.oxlintrc.json(c)` or `oxlint.config.ts` file exists in one of the workspaces. | | `oxc.tsConfigPath` | `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` | `false` | `true` \| `false` | Enable type-aware linting. Requires the `oxlint-tsgolint` package. See [the oxc website](https://oxc.rs/docs/guide/usage/linter/type-aware.html) for more information. | | `oxc.unusedDisableDirectives` | `allow` | `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. | diff --git a/client/tools/linter.ts b/client/tools/linter.ts index 8104573..f6d8464 100644 --- a/client/tools/linter.ts +++ b/client/tools/linter.ts @@ -36,6 +36,8 @@ const enum LspCommands { FixAll = "oxc.fixAll", } +const oxlintConfigDefaultFilePattern = `**/{.oxlintrc.json,.oxlintrc.jsonc,oxlint.config.ts}`; + export default class LinterTool implements ToolInterface { // Global flag to check if the user allows us to start the server. // When `oxc.requireConfig` is `true`, make sure one `.oxlintrc.json` file is present. @@ -76,7 +78,7 @@ export default class LinterTool implements ToolInterface { } this.allowedToStartServer = configService.vsCodeConfig.requireConfig - ? (await workspace.findFiles(`**/{.oxlintrc.json,oxlint.config.ts}`, "**/node_modules/**", 1)) + ? (await workspace.findFiles(oxlintConfigDefaultFilePattern, "**/node_modules/**", 1)) .length > 0 : true; @@ -354,7 +356,7 @@ export default class LinterTool implements ToolInterface { statusBarItemHandler: StatusBarItemHandler, ): void { const watcher = workspace.createFileSystemWatcher( - "**/{.oxlintrc.json,oxlint.config.ts}", + oxlintConfigDefaultFilePattern, false, true, !config.requireConfig, @@ -370,7 +372,7 @@ export default class LinterTool implements ToolInterface { watcher.onDidDelete(async () => { // only can be called when config.requireConfig this.allowedToStartServer = - (await workspace.findFiles(`**/{.oxlintrc.json,oxlint.config.ts}`, "**/node_modules/**", 1)) + (await workspace.findFiles(oxlintConfigDefaultFilePattern, "**/node_modules/**", 1)) .length > 0; if (!this.allowedToStartServer) { this.updateStatusBar(statusBarItemHandler, false); diff --git a/package.json b/package.json index ba7a84a..0e5dbea 100644 --- a/package.json +++ b/package.json @@ -141,7 +141,7 @@ "scope": "resource", "type": "boolean", "default": false, - "markdownDescription": "Start the language server only when a `.oxlintrc.json` or `oxlint.config.ts` file exists in one of the workspaces." + "markdownDescription": "Start the language server only when a `.oxlintrc.json(c)` or `oxlint.config.ts` file exists in one of the workspaces." }, "oxc.trace.server": { "type": "string", @@ -283,7 +283,10 @@ }, "jsonValidation": [ { - "fileMatch": ".oxlintrc.json", + "fileMatch": [ + ".oxlintrc.json", + ".oxlintrc.jsonc" + ], "url": "https://raw.githubusercontent.com/oxc-project/oxc/main/npm/oxlint/configuration_schema.json" }, { @@ -299,6 +302,7 @@ "id": "jsonc", "filenames": [ ".oxlintrc.json", + ".oxlintrc.jsonc", ".oxfmtrc.json", ".oxfmtrc.jsonc" ]