diff --git a/package-lock.json b/package-lock.json index 2200f7b..c617eff 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": { @@ -42,6 +43,11 @@ "peerDependencies": { "eslint": ">=8", "react": ">=16.8" + }, + "peerDependenciesMeta": { + "react": { + "optional": true + } } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -3634,6 +3640,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", @@ -9632,6 +9661,7 @@ "version": "18.2.0", "resolved": "https://registry.npmjs.org/react/-/react-18.2.0.tgz", "integrity": "sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==", + "optional": true, "peer": true, "dependencies": { "loose-envify": "^1.1.0" diff --git a/package.json b/package.json index 9e1631d..06cac39 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": { @@ -60,6 +61,11 @@ "eslint": ">=8", "react": ">=16.8" }, + "peerDependenciesMeta": { + "react": { + "optional": true + } + }, "publishConfig": { "access": "public" }, diff --git a/src/configs/node.ts b/src/configs/node.ts index 141dfb7..37d7aab 100644 --- a/src/configs/node.ts +++ b/src/configs/node.ts @@ -3,4 +3,12 @@ import { type ESLintConfig } from '../types' export const node: ESLintConfig = { plugins: ['@flaminc'], extends: ['plugin:n/recommended'], + overrides: [ + { + files: ['*.ts', '*.tsx'], + rules: { + 'n/no-missing-import': 'off', + }, + }, + ], } 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,