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
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,20 @@ Following configurations are supported via `settings.json` and affect the window

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` | `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(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` | `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` | `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. |
| 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. |
| 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` | `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(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` | `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

Expand Down
17 changes: 9 additions & 8 deletions client/WorkspaceConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,14 @@ interface WorkspaceConfigInterface {

/**
* Define how directive comments like `// oxlint-disable-line` should be reported,
* when no errors would have been reported on that line anyway
* when no errors would have been reported on that line anyway.
* Boolean or null (from configuration file).
*
* `oxc.unusedDisableDirectives`
*
* @default 'allow'
* @default null
*/
unusedDisableDirectives?: UnusedDisableDirectives;
unusedDisableDirectives?: UnusedDisableDirectives | null;

/**
* Whether to enable type-aware linting. Boolean or null (from configuration file).
Expand Down Expand Up @@ -101,7 +102,7 @@ export class WorkspaceConfig {
private _configPath: string | null = null;
private _tsConfigPath: string | null = null;
private _runTrigger: DiagnosticPullMode = DiagnosticPullMode.onType;
private _unusedDisableDirectives: UnusedDisableDirectives = "allow";
private _unusedDisableDirectives: UnusedDisableDirectives | null = null;
private _typeAware: boolean | null = null;
private _disableNestedConfig: boolean = false;
private _fixKind: FixKind = FixKind.SafeFix;
Expand Down Expand Up @@ -140,7 +141,7 @@ export class WorkspaceConfig {
this._configPath = this.configuration.get<string | null>("configPath") ?? null;
this._tsConfigPath = this.configuration.get<string | null>("tsConfigPath") ?? null;
this._unusedDisableDirectives =
this.configuration.get<UnusedDisableDirectives>("unusedDisableDirectives") ?? "allow";
this.configuration.get<UnusedDisableDirectives | null>("unusedDisableDirectives") ?? null;
this._typeAware = this.configuration.get<boolean | null>("typeAware") ?? null;
this._disableNestedConfig = disableNestedConfig ?? false;
this._fixKind = fixKind ?? FixKind.SafeFix;
Expand Down Expand Up @@ -217,11 +218,11 @@ export class WorkspaceConfig {
return this.configuration.update("tsConfigPath", value, ConfigurationTarget.WorkspaceFolder);
}

get unusedDisableDirectives(): UnusedDisableDirectives {
get unusedDisableDirectives(): UnusedDisableDirectives | null {
return this._unusedDisableDirectives;
}

updateUnusedDisableDirectives(value: UnusedDisableDirectives): PromiseLike<void> {
updateUnusedDisableDirectives(value: UnusedDisableDirectives | null): PromiseLike<void> {
this._unusedDisableDirectives = value;
return this.configuration.update(
"unusedDisableDirectives",
Expand Down Expand Up @@ -278,7 +279,7 @@ export class WorkspaceConfig {
return {
configPath: this.configPath ?? undefined,
tsConfigPath: this.tsConfigPath ?? undefined,
unusedDisableDirectives: this.unusedDisableDirectives,
unusedDisableDirectives: this.unusedDisableDirectives ?? undefined,
typeAware: this.typeAware ?? undefined,
disableNestedConfig: this.disableNestedConfig,
fixKind: this.fixKind,
Expand Down
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,10 @@
"markdownDescription": "Path to the project's TypeScript config file. \n\nIf your `tsconfig.json` is not at the root, you will need this set for the `import` plugin rules to resolve imports correctly."
},
"oxc.unusedDisableDirectives": {
"type": "string",
"type": [
"string",
"null"
],
"scope": "resource",
"enum": [
"allow",
Expand All @@ -190,8 +193,8 @@
"Warn about `oxlint-disable` and `eslint-disable` directives that do nothing.",
"Error on `oxlint-disable` and `eslint-disable` directives that do nothing."
],
"default": "allow",
"markdownDescription": "Define how directive comments like `// oxlint-disable-line` should be reported, when no errors would have been reported on that line anyway."
"default": null,
"markdownDescription": "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"
},
"oxc.typeAware": {
"type": [
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/WorkspaceConfig.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ suite("WorkspaceConfig", () => {
strictEqual(config.runTrigger, "onType");
strictEqual(config.configPath, null);
strictEqual(config.tsConfigPath, null);
strictEqual(config.unusedDisableDirectives, "allow");
strictEqual(config.unusedDisableDirectives, null);
strictEqual(config.typeAware, null);
strictEqual(config.disableNestedConfig, false);
strictEqual(config.fixKind, "safe_fix");
Expand Down Expand Up @@ -94,7 +94,7 @@ suite("WorkspaceConfig", () => {
strictEqual(oxlintConfig.run, "onType");
strictEqual(oxlintConfig.configPath, undefined);
strictEqual(oxlintConfig.tsConfigPath, undefined);
strictEqual(oxlintConfig.unusedDisableDirectives, "allow");
strictEqual(oxlintConfig.unusedDisableDirectives, undefined);
strictEqual(oxlintConfig.typeAware, undefined);
strictEqual(oxlintConfig.disableNestedConfig, false);
strictEqual(oxlintConfig.fixKind, "safe_fix");
Expand Down