diff --git a/apps/oxlint/src-js/package/config.generated.ts b/apps/oxlint/src-js/package/config.generated.ts index 00ca4ad859..9b989f0d77 100644 --- a/apps/oxlint/src-js/package/config.generated.ts +++ b/apps/oxlint/src-js/package/config.generated.ts @@ -189,6 +189,7 @@ export type ImportKind = "none" | "all" | "multiple" | "single"; */ export type SortOrder = "desc" | "asc"; export type ClassLiteralPropertyStyleOption = "fields" | "getters"; +export type PreferGenericType = "constructor" | "type-annotation"; export type ConsistentIndexedObjectStyleConfig = "record" | "index-signature"; export type ArrayLiteralTypeAssertions = "allow" | "allow-as-parameter" | "never"; export type AssertionStyle = "as" | "angle-bracket" | "never"; @@ -1286,7 +1287,7 @@ export interface DummyRuleMap { | AllowWarnDeny | [AllowWarnDeny] | [AllowWarnDeny, ClassLiteralPropertyStyleOption]; - "typescript/consistent-generic-constructors"?: DummyRule; + "typescript/consistent-generic-constructors"?: AllowWarnDeny | [AllowWarnDeny] | [AllowWarnDeny, PreferGenericType]; "typescript/consistent-indexed-object-style"?: | AllowWarnDeny | [AllowWarnDeny] diff --git a/crates/oxc_linter/src/utils/schemars.rs b/crates/oxc_linter/src/utils/schemars.rs index 15bac8ae7c..f327671719 100644 --- a/crates/oxc_linter/src/utils/schemars.rs +++ b/crates/oxc_linter/src/utils/schemars.rs @@ -13,7 +13,7 @@ use crate::rules::RuleEnum; /// These should return the DummyRule struct/schema instead of the actual rule struct/schema, /// until we verify that the rule's schema is valid and can be generated by schemars. #[cfg(feature = "ruledocs")] -const NO_VERIFIED_VALID_SCHEMA: [&str; 35] = [ +const NO_VERIFIED_VALID_SCHEMA: [&str; 34] = [ "eslint/func-name-matching", // second config can be on first position like [AllowWarnDeny, Config1, Config2] | [AllowWarnDeny, Config1] | [AllowWarnDeny, Config2] "eslint/no-restricted-globals", // uses spread syntax like [AllowWarnDeny, ...Config] "eslint/no-restricted-imports", // uses spread syntax like [AllowWarnDeny, ...Config] @@ -43,7 +43,6 @@ const NO_VERIFIED_VALID_SCHEMA: [&str; 35] = [ "react_perf/jsx-no-new-object-as-prop", "typescript/array-type", "typescript/ban-ts-comment", - "typescript/consistent-generic-constructors", "typescript/no-restricted-types", "unicorn/filename-case", "unicorn/import-style", diff --git a/npm/oxlint/configuration_schema.json b/npm/oxlint/configuration_schema.json index 2c7fc2bd90..641e7e50bd 100644 --- a/npm/oxlint/configuration_schema.json +++ b/npm/oxlint/configuration_schema.json @@ -6364,7 +6364,24 @@ ] }, "typescript/consistent-generic-constructors": { - "$ref": "#/definitions/DummyRule" + "anyOf": [ + { + "$ref": "#/definitions/AllowWarnDeny" + }, + { + "type": "array", + "items": [ + { + "$ref": "#/definitions/AllowWarnDeny" + }, + { + "$ref": "#/definitions/PreferGenericType" + } + ], + "maxItems": 2, + "minItems": 1 + } + ] }, "typescript/consistent-indexed-object-style": { "anyOf": [ @@ -14835,6 +14852,26 @@ }, "additionalProperties": false }, + "PreferGenericType": { + "oneOf": [ + { + "description": "Type arguments that only appear on the type annotation are disallowed.", + "type": "string", + "enum": [ + "constructor" + ], + "markdownDescription": "Type arguments that only appear on the type annotation are disallowed." + }, + { + "description": "Type arguments that only appear on the constructor are disallowed.", + "type": "string", + "enum": [ + "type-annotation" + ], + "markdownDescription": "Type arguments that only appear on the constructor are disallowed." + } + ] + }, "PreferImportInMockConfig": { "type": "object", "required": [ diff --git a/tasks/website_linter/src/snapshots/schema_json.snap b/tasks/website_linter/src/snapshots/schema_json.snap index c6332bb2f2..498c6f8a67 100644 --- a/tasks/website_linter/src/snapshots/schema_json.snap +++ b/tasks/website_linter/src/snapshots/schema_json.snap @@ -6368,7 +6368,24 @@ expression: json ] }, "typescript/consistent-generic-constructors": { - "$ref": "#/definitions/DummyRule" + "anyOf": [ + { + "$ref": "#/definitions/AllowWarnDeny" + }, + { + "type": "array", + "items": [ + { + "$ref": "#/definitions/AllowWarnDeny" + }, + { + "$ref": "#/definitions/PreferGenericType" + } + ], + "maxItems": 2, + "minItems": 1 + } + ] }, "typescript/consistent-indexed-object-style": { "anyOf": [ @@ -14839,6 +14856,26 @@ expression: json }, "additionalProperties": false }, + "PreferGenericType": { + "oneOf": [ + { + "description": "Type arguments that only appear on the type annotation are disallowed.", + "type": "string", + "enum": [ + "constructor" + ], + "markdownDescription": "Type arguments that only appear on the type annotation are disallowed." + }, + { + "description": "Type arguments that only appear on the constructor are disallowed.", + "type": "string", + "enum": [ + "type-annotation" + ], + "markdownDescription": "Type arguments that only appear on the constructor are disallowed." + } + ] + }, "PreferImportInMockConfig": { "type": "object", "required": [