Skip to content

Commit 5e85f73

Browse files
authored
feat: add eslint-plugin-vitest (#24)
1 parent b030d4b commit 5e85f73

File tree

4 files changed

+67
-0
lines changed

4 files changed

+67
-0
lines changed

package-lock.json

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"eslint-plugin-security": "2.1.1",
2929
"eslint-plugin-sonarjs": "0.24.0",
3030
"eslint-plugin-unicorn": "51.0.1",
31+
"eslint-plugin-vitest": "0.3.26",
3132
"eslint-plugin-xss": "0.1.12"
3233
},
3334
"devDependencies": {

src/configs/vitest.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { type ESLintConfig } from '../types'
2+
3+
export const vitest: ESLintConfig = {
4+
plugins: ['@flaminc'],
5+
overrides: [
6+
{
7+
files: ['**/*.spec.ts'],
8+
plugins: ['vitest'],
9+
extends: ['plugin:vitest/recommended'],
10+
rules: {
11+
'vitest/consistent-test-it': [
12+
'error',
13+
{ fn: 'it', withinDescribe: 'it' },
14+
],
15+
'vitest/no-alias-methods': 'error',
16+
'vitest/no-conditional-expect': 'error',
17+
'vitest/no-conditional-in-test': 'error',
18+
'vitest/no-conditional-tests': 'error',
19+
'vitest/no-disabled-tests': 'warn',
20+
'vitest/no-focused-tests': 'error',
21+
'vitest/no-hooks': 'off',
22+
'vitest/no-standalone-expect': 'error',
23+
'vitest/prefer-each': 'error',
24+
'vitest/prefer-comparison-matcher': 'error',
25+
'vitest/prefer-equality-matcher': 'error',
26+
'vitest/prefer-expect-resolves': 'error',
27+
'vitest/prefer-hooks-in-order': 'error',
28+
'vitest/prefer-hooks-on-top': 'error',
29+
'vitest/prefer-lowercase-title': 'error',
30+
'vitest/prefer-mock-promise-shorthand': 'error',
31+
'vitest/prefer-spy-on': 'error',
32+
'vitest/prefer-strict-equal': 'error',
33+
'vitest/prefer-to-have-length': 'error',
34+
'vitest/prefer-todo': 'error',
35+
'vitest/require-hook': 'error',
36+
'vitest/require-top-level-describe': 'error',
37+
},
38+
},
39+
],
40+
}

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ import { name, version } from '../package.json'
55
import { node } from './configs/node'
66
import { react } from './configs/react'
77
import { recommended } from './configs/recommended'
8+
import { vitest } from './configs/vitest'
89

910
const plugin: ESLint.Plugin = {
1011
configs: {
1112
node,
1213
react,
1314
recommended,
15+
vitest,
1416
},
1517
meta: {
1618
name,

0 commit comments

Comments
 (0)