From c631db46b7e1c35337bfc31ea86b2659c3225a8d Mon Sep 17 00:00:00 2001 From: "capitN.flam" Date: Sun, 17 Mar 2024 21:18:05 +0100 Subject: [PATCH] feat: add eslint-plugin-vitest --- package-lock.json | 24 ++++++++++++++++++++++++ package.json | 1 + src/configs/vitest.ts | 40 ++++++++++++++++++++++++++++++++++++++++ src/index.ts | 2 ++ 4 files changed, 67 insertions(+) create mode 100644 src/configs/vitest.ts diff --git a/package-lock.json b/package-lock.json index ade336a..b0d6f9a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,6 +22,7 @@ "eslint-plugin-security": "2.1.1", "eslint-plugin-sonarjs": "0.24.0", "eslint-plugin-unicorn": "51.0.1", + "eslint-plugin-vitest": "0.3.26", "eslint-plugin-xss": "0.1.12" }, "devDependencies": { @@ -3634,6 +3635,29 @@ "node": ">=8" } }, + "node_modules/eslint-plugin-vitest": { + "version": "0.3.26", + "resolved": "https://registry.npmjs.org/eslint-plugin-vitest/-/eslint-plugin-vitest-0.3.26.tgz", + "integrity": "sha512-oxe5JSPgRjco8caVLTh7Ti8PxpwJdhSV0hTQAmkFcNcmy/9DnqLB/oNVRA11RmVRP//2+jIIT6JuBEcpW3obYg==", + "dependencies": { + "@typescript-eslint/utils": "^7.1.1" + }, + "engines": { + "node": "^18.0.0 || >= 20.0.0" + }, + "peerDependencies": { + "eslint": ">=8.0.0", + "vitest": "*" + }, + "peerDependenciesMeta": { + "@typescript-eslint/eslint-plugin": { + "optional": true + }, + "vitest": { + "optional": true + } + } + }, "node_modules/eslint-plugin-xss": { "version": "0.1.12", "resolved": "https://registry.npmjs.org/eslint-plugin-xss/-/eslint-plugin-xss-0.1.12.tgz", diff --git a/package.json b/package.json index c448b27..5274e0a 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "eslint-plugin-security": "2.1.1", "eslint-plugin-sonarjs": "0.24.0", "eslint-plugin-unicorn": "51.0.1", + "eslint-plugin-vitest": "0.3.26", "eslint-plugin-xss": "0.1.12" }, "devDependencies": { diff --git a/src/configs/vitest.ts b/src/configs/vitest.ts new file mode 100644 index 0000000..d1067ac --- /dev/null +++ b/src/configs/vitest.ts @@ -0,0 +1,40 @@ +import { type ESLintConfig } from '../types' + +export const vitest: ESLintConfig = { + plugins: ['@flaminc'], + overrides: [ + { + files: ['**/*.spec.ts'], + plugins: ['vitest'], + extends: ['plugin:vitest/recommended'], + rules: { + 'vitest/consistent-test-it': [ + 'error', + { fn: 'it', withinDescribe: 'it' }, + ], + 'vitest/no-alias-methods': 'error', + 'vitest/no-conditional-expect': 'error', + 'vitest/no-conditional-in-test': 'error', + 'vitest/no-conditional-tests': 'error', + 'vitest/no-disabled-tests': 'warn', + 'vitest/no-focused-tests': 'error', + 'vitest/no-hooks': 'off', + 'vitest/no-standalone-expect': 'error', + 'vitest/prefer-each': 'error', + 'vitest/prefer-comparison-matcher': 'error', + 'vitest/prefer-equality-matcher': 'error', + 'vitest/prefer-expect-resolves': 'error', + 'vitest/prefer-hooks-in-order': 'error', + 'vitest/prefer-hooks-on-top': 'error', + 'vitest/prefer-lowercase-title': 'error', + 'vitest/prefer-mock-promise-shorthand': 'error', + 'vitest/prefer-spy-on': 'error', + 'vitest/prefer-strict-equal': 'error', + 'vitest/prefer-to-have-length': 'error', + 'vitest/prefer-todo': 'error', + 'vitest/require-hook': 'error', + 'vitest/require-top-level-describe': 'error', + }, + }, + ], +} diff --git a/src/index.ts b/src/index.ts index 4b91693..9467150 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,12 +5,14 @@ import { name, version } from '../package.json' import { node } from './configs/node' import { react } from './configs/react' import { recommended } from './configs/recommended' +import { vitest } from './configs/vitest' const plugin: ESLint.Plugin = { configs: { node, react, recommended, + vitest, }, meta: { name,