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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` | `<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.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` | `<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` | `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. |
Expand Down
8 changes: 5 additions & 3 deletions client/tools/linter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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,
Expand All @@ -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);
Expand Down
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
},
{
Expand All @@ -299,6 +302,7 @@
"id": "jsonc",
"filenames": [
".oxlintrc.json",
".oxlintrc.jsonc",
".oxfmtrc.json",
".oxfmtrc.jsonc"
]
Expand Down