diff --git a/README.md b/README.md index 4c1948b..403c313 100644 --- a/README.md +++ b/README.md @@ -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` | `` \| `` | 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` | `` \| `` | 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` | `` \| `` | 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` \| `` | 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` | 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` | `` \| `` | 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` | `` \| `` | 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` | `` \| `` | 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` \| `` | 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` | Specific Oxlint flags to pass to the language server. | +| `oxc.fmt.experimental` | `true` | `true` \| `false` | Enable Oxfmt formatting support. | #### FixKind diff --git a/client/WorkspaceConfig.ts b/client/WorkspaceConfig.ts index 6e6bb13..6e8a0a0 100644 --- a/client/WorkspaceConfig.ts +++ b/client/WorkspaceConfig.ts @@ -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). @@ -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; @@ -140,7 +141,7 @@ export class WorkspaceConfig { this._configPath = this.configuration.get("configPath") ?? null; this._tsConfigPath = this.configuration.get("tsConfigPath") ?? null; this._unusedDisableDirectives = - this.configuration.get("unusedDisableDirectives") ?? "allow"; + this.configuration.get("unusedDisableDirectives") ?? null; this._typeAware = this.configuration.get("typeAware") ?? null; this._disableNestedConfig = disableNestedConfig ?? false; this._fixKind = fixKind ?? FixKind.SafeFix; @@ -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 { + updateUnusedDisableDirectives(value: UnusedDisableDirectives | null): PromiseLike { this._unusedDisableDirectives = value; return this.configuration.update( "unusedDisableDirectives", @@ -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, diff --git a/package.json b/package.json index 4cbd938..d4769a8 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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": [ diff --git a/tests/unit/WorkspaceConfig.spec.ts b/tests/unit/WorkspaceConfig.spec.ts index 940e2e0..dbae3ad 100644 --- a/tests/unit/WorkspaceConfig.spec.ts +++ b/tests/unit/WorkspaceConfig.spec.ts @@ -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"); @@ -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");