diff --git a/apps/oxlint/src-js/package/config.generated.ts b/apps/oxlint/src-js/package/config.generated.ts index 6a0368ed76..9efda5949f 100644 --- a/apps/oxlint/src-js/package/config.generated.ts +++ b/apps/oxlint/src-js/package/config.generated.ts @@ -234,6 +234,7 @@ export type NoInstanceofBuiltinsStrategy = "strict" | "loose"; export type PreferTernaryOption = "always" | "only-single-line"; export type RelativeUrlStyleConfig = "never" | "always"; export type SwitchCaseBracesConfig = "always" | "avoid"; +export type VitestFnName = "vi" | "vitest"; export type CaseType = "PascalCase" | "kebab-case"; export type DeclarationStyle = "type-based" | "type-literal" | "runtime"; export type DeclarationStyle2 = "type-based" | "runtime"; @@ -1536,7 +1537,7 @@ export interface DummyRuleMap { "vitest/consistent-each-for"?: DummyRule; "vitest/consistent-test-filename"?: DummyRule; "vitest/consistent-test-it"?: AllowWarnDeny | [AllowWarnDeny] | [AllowWarnDeny, ConsistentTestItConfig]; - "vitest/consistent-vitest-vi"?: DummyRule; + "vitest/consistent-vitest-vi"?: AllowWarnDeny | [AllowWarnDeny] | [AllowWarnDeny, ConsistentVitestConfig]; "vitest/expect-expect"?: AllowWarnDeny | [AllowWarnDeny] | [AllowWarnDeny, ExpectExpectConfig]; "vitest/hoisted-apis-on-top"?: RuleNoConfig; "vitest/max-expects"?: AllowWarnDeny | [AllowWarnDeny] | [AllowWarnDeny, MaxExpectsConfig]; @@ -5304,6 +5305,12 @@ export interface ValidTypeof { */ requireStringLiterals?: boolean; } +export interface ConsistentVitestConfig { + /** + * Decides whether to prefer vitest function accessor + */ + fn?: VitestFnName; +} export interface PreferImportInMockConfig { /** * Whether the rule should generate fixes or not. diff --git a/crates/oxc_linter/src/utils/schemars.rs b/crates/oxc_linter/src/utils/schemars.rs index 3173a0d37d..eb86606e79 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; 55] = [ +const NO_VERIFIED_VALID_SCHEMA: [&str; 54] = [ "eslint/func-name-matching", "eslint/no-restricted-globals", "eslint/no-restricted-imports", @@ -66,7 +66,6 @@ const NO_VERIFIED_VALID_SCHEMA: [&str; 55] = [ "unicorn/prefer-at", "vitest/consistent-each-for", "vitest/consistent-test-filename", - "vitest/consistent-vitest-vi", "vitest/prefer-lowercase-title", "vitest/valid-title", ]; diff --git a/npm/oxlint/configuration_schema.json b/npm/oxlint/configuration_schema.json index 6355e19001..b46845a9d3 100644 --- a/npm/oxlint/configuration_schema.json +++ b/npm/oxlint/configuration_schema.json @@ -1052,6 +1052,22 @@ }, "additionalProperties": false }, + "ConsistentVitestConfig": { + "type": "object", + "properties": { + "fn": { + "description": "Decides whether to prefer vitest function accessor", + "default": "vi", + "allOf": [ + { + "$ref": "#/definitions/VitestFnName" + } + ], + "markdownDescription": "Decides whether to prefer vitest function accessor" + } + }, + "additionalProperties": false + }, "CountThis": { "oneOf": [ { @@ -7712,7 +7728,24 @@ ] }, "vitest/consistent-vitest-vi": { - "$ref": "#/definitions/DummyRule" + "anyOf": [ + { + "$ref": "#/definitions/AllowWarnDeny" + }, + { + "type": "array", + "items": [ + { + "$ref": "#/definitions/AllowWarnDeny" + }, + { + "$ref": "#/definitions/ConsistentVitestConfig" + } + ], + "maxItems": 2, + "minItems": 1 + } + ] }, "vitest/expect-expect": { "anyOf": [ @@ -14995,6 +15028,13 @@ } ] }, + "VitestFnName": { + "type": "string", + "enum": [ + "vi", + "vitest" + ] + }, "VitestPluginSettings": { "description": "Configure Vitest plugin rules.\n\nSee [eslint-plugin-vitest](https://github.com/vitest-dev/eslint-plugin-vitest)'s\nconfiguration for a full reference.", "type": "object", @@ -15041,4 +15081,4 @@ } }, "markdownDescription": "Oxlint Configuration File\n\nThis configuration is aligned with ESLint v8's configuration schema (`eslintrc.json`).\n\nUsage: `oxlint -c oxlintrc.json`\n\nExample\n\n`.oxlintrc.json`\n\n```json\n{\n\"$schema\": \"./node_modules/oxlint/configuration_schema.json\",\n\"plugins\": [\"import\", \"typescript\", \"unicorn\"],\n\"env\": {\n\"browser\": true\n},\n\"globals\": {\n\"foo\": \"readonly\"\n},\n\"settings\": {\n\"react\": {\n\"version\": \"18.2.0\"\n},\n\"custom\": { \"option\": true }\n},\n\"rules\": {\n\"eqeqeq\": \"warn\",\n\"import/no-cycle\": \"error\",\n\"react/self-closing-comp\": [\"error\", { \"html\": false }]\n},\n\"overrides\": [\n{\n\"files\": [\"*.test.ts\", \"*.spec.ts\"],\n\"rules\": {\n\"@typescript-eslint/no-explicit-any\": \"off\"\n}\n}\n]\n}\n```\n\n`oxlint.config.ts`\n\n```ts\nimport { defineConfig } from \"oxlint\";\n\nexport default defineConfig({\nplugins: [\"import\", \"typescript\", \"unicorn\"],\nenv: {\n\"browser\": true\n},\nglobals: {\n\"foo\": \"readonly\"\n},\nsettings: {\nreact: {\nversion: \"18.2.0\"\n},\ncustom: { option: true }\n},\nrules: {\n\"eqeqeq\": \"warn\",\n\"import/no-cycle\": \"error\",\n\"react/self-closing-comp\": [\"error\", { \"html\": false }]\n},\noverrides: [\n{\nfiles: [\"*.test.ts\", \"*.spec.ts\"],\nrules: {\n\"@typescript-eslint/no-explicit-any\": \"off\"\n}\n}\n]\n});\n```" -} \ No newline at end of file +} diff --git a/tasks/website_linter/src/snapshots/schema_json.snap b/tasks/website_linter/src/snapshots/schema_json.snap index 42ebd420bf..1aeea3eb87 100644 --- a/tasks/website_linter/src/snapshots/schema_json.snap +++ b/tasks/website_linter/src/snapshots/schema_json.snap @@ -1056,6 +1056,22 @@ expression: json }, "additionalProperties": false }, + "ConsistentVitestConfig": { + "type": "object", + "properties": { + "fn": { + "description": "Decides whether to prefer vitest function accessor", + "default": "vi", + "allOf": [ + { + "$ref": "#/definitions/VitestFnName" + } + ], + "markdownDescription": "Decides whether to prefer vitest function accessor" + } + }, + "additionalProperties": false + }, "CountThis": { "oneOf": [ { @@ -7716,7 +7732,24 @@ expression: json ] }, "vitest/consistent-vitest-vi": { - "$ref": "#/definitions/DummyRule" + "anyOf": [ + { + "$ref": "#/definitions/AllowWarnDeny" + }, + { + "type": "array", + "items": [ + { + "$ref": "#/definitions/AllowWarnDeny" + }, + { + "$ref": "#/definitions/ConsistentVitestConfig" + } + ], + "maxItems": 2, + "minItems": 1 + } + ] }, "vitest/expect-expect": { "anyOf": [ @@ -14999,6 +15032,13 @@ expression: json } ] }, + "VitestFnName": { + "type": "string", + "enum": [ + "vi", + "vitest" + ] + }, "VitestPluginSettings": { "description": "Configure Vitest plugin rules.\n\nSee [eslint-plugin-vitest](https://github.com/vitest-dev/eslint-plugin-vitest)'s\nconfiguration for a full reference.", "type": "object",