Skip to content

Commit d096731

Browse files
authored
feat(oxlint-config): check test files and titles with the vitest plugin (#216)
1 parent f4fc671 commit d096731

1 file changed

Lines changed: 42 additions & 2 deletions

File tree

‎packages/oxlint-config/src/test.js‎

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,25 @@ import { testFiles } from './subconfigs/files.js'
66

77
export default {
88
overrides: [
9+
{
10+
// Tests live in `*.spec.*` files beside their code, never in `*.test.*` ones
11+
files: ['**/*'],
12+
plugins: ['vitest'],
13+
rules: {
14+
'vitest/consistent-test-filename': [
15+
'error',
16+
{
17+
pattern: '.*\\.spec\\.[jt]sx?$'
18+
}
19+
]
20+
}
21+
},
922
{
1023
files: testFiles,
1124
env: {
1225
vitest: true
1326
},
14-
plugins: ['typescript'],
27+
plugins: ['typescript', 'vitest'],
1528
jsPlugins: ['@trigen/oxlint-config/plugin'],
1629
rules: {
1730
'eslint/max-classes-per-file': 'off',
@@ -34,7 +47,34 @@ export default {
3447
'eslint/no-useless-assignment': 'off',
3548
'eslint/no-empty-function': 'off',
3649
'trigen/naming-convention': 'off',
37-
'trigen/func-style': 'off'
50+
'trigen/func-style': 'off',
51+
'vitest/consistent-test-it': [
52+
'error',
53+
{
54+
fn: 'it',
55+
withinDescribe: 'it'
56+
}
57+
],
58+
'vitest/no-disabled-tests': 'error',
59+
'vitest/no-focused-tests': 'error',
60+
'vitest/no-identical-title': 'error',
61+
'vitest/no-standalone-expect': 'error',
62+
'vitest/prefer-importing-vitest-globals': 'error',
63+
// The unit's address is a chain of describes, each with its own segment
64+
'vitest/require-top-level-describe': 'error',
65+
'vitest/valid-describe-callback': 'error',
66+
'vitest/valid-expect': 'error',
67+
'vitest/valid-title': [
68+
'error',
69+
{
70+
mustMatch: {
71+
it: '^should '
72+
},
73+
mustNotMatch: {
74+
describe: '/'
75+
}
76+
}
77+
]
3878

3979
// Unsupported by Oxlint
4080
// 'eslint/camelcase': 'off',

0 commit comments

Comments
 (0)