@wistia/oxlint-config 0.7.1 → 0.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/package.json +3 -3
- package/rules/vitest.mjs +154 -146
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ yarn add -D @wistia/oxlint-config oxlint
|
|
|
19
19
|
|
|
20
20
|
Create an `oxlint.config.ts` in your project root:
|
|
21
21
|
|
|
22
|
-
**TypeScript project** (most common):
|
|
22
|
+
**TypeScript & React project** (most common):
|
|
23
23
|
|
|
24
24
|
```ts
|
|
25
25
|
import { defineConfig } from 'oxlint';
|
|
@@ -58,11 +58,11 @@ Feature configs wrap their rules in `overrides` with default file patterns, so t
|
|
|
58
58
|
| ------------------------ | ----------------------------------------- | ------------------------------------- |
|
|
59
59
|
| `reactConfig` | all files (global) | React component + accessibility rules |
|
|
60
60
|
| `styledComponentsConfig` | all files (global) | Styled Components accessibility rules |
|
|
61
|
-
| `vitestConfig` | `**/*.{test,spec,vitest}.{ts,tsx,js,jsx}` | Vitest testing rules |
|
|
62
|
-
| `testingLibraryConfig` | `**/*.{test,spec,vitest}.{ts,tsx,js,jsx}` | Testing Library + jest-dom rules |
|
|
63
|
-
| `storybookConfig` | `**/*.stories.{ts,tsx,js,jsx}` | Storybook story conventions |
|
|
64
61
|
| `nodeConfig` | `**/*.{mts,mjs,cjs}` | Node.js-specific rules |
|
|
62
|
+
| `vitestConfig` | `**/*.{test,vitest}.{ts,tsx,js,jsx}` | Vitest testing rules |
|
|
63
|
+
| `testingLibraryConfig` | `**/*.{test,vitest}.{ts,tsx,js,jsx}` | Testing Library + jest-dom rules |
|
|
65
64
|
| `playwrightConfig` | `**/*.spec.{ts,tsx,js}`, `**/e2e/**/*.ts` | Playwright E2E testing rules |
|
|
65
|
+
| `storybookConfig` | `**/*.stories.{ts,tsx,js,jsx}` | Storybook story conventions |
|
|
66
66
|
|
|
67
67
|
**Composing configs:**
|
|
68
68
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wistia/oxlint-config",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"description": "Wistia's Oxlint configurations",
|
|
5
5
|
"packageManager": "yarn@4.14.1",
|
|
6
6
|
"type": "module",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"oxlint-tsgolint": ">= 1.0.0"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@eslint-react/eslint-plugin": "^5.7.
|
|
57
|
+
"@eslint-react/eslint-plugin": "^5.7.6",
|
|
58
58
|
"@vitest/eslint-plugin": "^1.6.16",
|
|
59
59
|
"confusing-browser-globals": "^1.0.11",
|
|
60
60
|
"eslint-plugin-barrel-files": "^3.0.1",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"@changesets/cli": "^2.31.0",
|
|
75
75
|
"eslint": "^10.3.0",
|
|
76
76
|
"oxfmt": "^0.48.0",
|
|
77
|
-
"oxlint": "^1.
|
|
77
|
+
"oxlint": "^1.64.0",
|
|
78
78
|
"oxlint-tsgolint": "^0.22.1",
|
|
79
79
|
"storybook": "^10.3.6",
|
|
80
80
|
"vitest": "^4.1.5"
|
package/rules/vitest.mjs
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
//
|
|
2
|
-
// - "vitest/" for rules that are vitest-specific (no Jest equivalent)
|
|
3
|
-
// - "jest/" for rules that originated in eslint-plugin-jest and are shared with vitest
|
|
4
|
-
// Both namespaces are used here for VITEST projects only. Despite the "jest/" prefix,
|
|
5
|
-
// these rules apply to vitest code. This is an oxlint naming convention, not a dependency on Jest.
|
|
1
|
+
// Native oxlint vitest rules + jsPlugin rules from @vitest/eslint-plugin and eslint-plugin-no-only-tests
|
|
6
2
|
export const vitestRules = {
|
|
7
|
-
plugins: ['vitest'
|
|
3
|
+
plugins: ['vitest'],
|
|
8
4
|
jsPlugins: [
|
|
9
5
|
{ name: 'vitest-js', specifier: '@vitest/eslint-plugin' },
|
|
10
6
|
'eslint-plugin-no-only-tests',
|
|
@@ -40,7 +36,7 @@ export const vitestRules = {
|
|
|
40
36
|
|
|
41
37
|
// Prefer toHaveBeenCalledOnce() over toHaveBeenCalledTimes(1)
|
|
42
38
|
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/prefer-called-once.html
|
|
43
|
-
// decision: conflicts with prefer-called-times (
|
|
39
|
+
// decision: conflicts with prefer-called-times (vitest plugin), which is enabled
|
|
44
40
|
'vitest/prefer-called-once': 'off',
|
|
45
41
|
|
|
46
42
|
// Prefer toHaveBeenCalledTimes over multiple assertions
|
|
@@ -110,191 +106,199 @@ export const vitestRules = {
|
|
|
110
106
|
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/prefer-snapshot-hint.html
|
|
111
107
|
'vitest/prefer-snapshot-hint': 'error',
|
|
112
108
|
|
|
113
|
-
//
|
|
109
|
+
// Disallow importing vitest globals
|
|
110
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/no-importing-vitest-globals.html
|
|
111
|
+
// decision: prefer-importing-vitest-globals is already enabled, which serves opposite purpose
|
|
112
|
+
'vitest/no-importing-vitest-globals': 'off',
|
|
113
|
+
|
|
114
|
+
// Suggest using expect.assertions
|
|
115
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/prefer-expect-assertions.html
|
|
116
|
+
// decision: too strict for general use, matching vitest-js/prefer-expect-assertions
|
|
117
|
+
'vitest/prefer-expect-assertions': 'off',
|
|
118
|
+
|
|
119
|
+
// Prefer toHaveBeenCalledTimes over multiple assertions
|
|
120
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/prefer-to-have-been-called-times.html
|
|
121
|
+
'vitest/prefer-to-have-been-called-times': 'error',
|
|
122
|
+
|
|
123
|
+
// Require test timeout
|
|
124
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/require-test-timeout.html
|
|
125
|
+
// decision: too strict for general use, matching vitest-js/require-test-timeout
|
|
126
|
+
'vitest/require-test-timeout': 'off',
|
|
127
|
+
|
|
128
|
+
// Enforce valid expect in promise
|
|
129
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/valid-expect-in-promise.html
|
|
130
|
+
// decision: too strict for general use, matching vitest-js/valid-expect-in-promise
|
|
131
|
+
'vitest/valid-expect-in-promise': 'off',
|
|
114
132
|
|
|
115
133
|
// Prefer test or it but not both
|
|
116
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
117
|
-
'
|
|
134
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/consistent-test-it.html
|
|
135
|
+
'vitest/consistent-test-it': 'error',
|
|
118
136
|
|
|
119
137
|
// Enforce having expectation in test body
|
|
120
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
121
|
-
'
|
|
138
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/expect-expect.html
|
|
139
|
+
'vitest/expect-expect': 'error',
|
|
122
140
|
|
|
123
141
|
// Enforce a maximum number of expect per test
|
|
124
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
125
|
-
'
|
|
126
|
-
'error',
|
|
127
|
-
{
|
|
128
|
-
max: 15,
|
|
129
|
-
},
|
|
130
|
-
],
|
|
142
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/max-expects.html
|
|
143
|
+
'vitest/max-expects': ['error', { max: 15 }],
|
|
131
144
|
|
|
132
145
|
// Nested describe block should be less than set max value or default value
|
|
133
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
134
|
-
'
|
|
146
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/max-nested-describe.html
|
|
147
|
+
'vitest/max-nested-describe': 'error',
|
|
135
148
|
|
|
136
149
|
// Disallow alias methods
|
|
137
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
138
|
-
'
|
|
150
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/no-alias-methods.html
|
|
151
|
+
'vitest/no-alias-methods': 'error',
|
|
139
152
|
|
|
140
153
|
// Disallow commented out tests
|
|
141
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
142
|
-
'
|
|
154
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/no-commented-out-tests.html
|
|
155
|
+
'vitest/no-commented-out-tests': 'error',
|
|
143
156
|
|
|
144
157
|
// Disallow conditional expects
|
|
145
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
146
|
-
'
|
|
158
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/no-conditional-expect.html
|
|
159
|
+
'vitest/no-conditional-expect': 'error',
|
|
147
160
|
|
|
148
161
|
// Disallow disabled tests
|
|
149
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
162
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/no-disabled-tests.html
|
|
150
163
|
// decision: it is often useful to be allowed to add a .skip
|
|
151
|
-
'
|
|
164
|
+
'vitest/no-disabled-tests': 'off',
|
|
152
165
|
|
|
153
166
|
// Disallow duplicate hooks and teardown hooks
|
|
154
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
155
|
-
'
|
|
167
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/no-duplicate-hooks.html
|
|
168
|
+
'vitest/no-duplicate-hooks': 'error',
|
|
156
169
|
|
|
157
170
|
// Disallow focused tests
|
|
158
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
159
|
-
'
|
|
171
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/no-focused-tests.html
|
|
172
|
+
'vitest/no-focused-tests': 'error',
|
|
160
173
|
|
|
161
174
|
// Disallow setup and teardown hooks
|
|
162
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
163
|
-
'
|
|
175
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/no-hooks.html
|
|
176
|
+
'vitest/no-hooks': 'off',
|
|
164
177
|
|
|
165
178
|
// Disallow identical titles
|
|
166
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
167
|
-
'
|
|
179
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/no-identical-title.html
|
|
180
|
+
'vitest/no-identical-title': 'error',
|
|
168
181
|
|
|
169
182
|
// Disallow string interpolation in snapshots
|
|
170
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
171
|
-
'
|
|
183
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/no-interpolation-in-snapshots.html
|
|
184
|
+
'vitest/no-interpolation-in-snapshots': 'error',
|
|
172
185
|
|
|
173
186
|
// Disallow large snapshots
|
|
174
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
175
|
-
'
|
|
176
|
-
'error',
|
|
177
|
-
{
|
|
178
|
-
maxSize: 500,
|
|
179
|
-
},
|
|
180
|
-
],
|
|
187
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/no-large-snapshots.html
|
|
188
|
+
'vitest/no-large-snapshots': ['error', { maxSize: 500 }],
|
|
181
189
|
|
|
182
190
|
// Disallow importing from mocks directory
|
|
183
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
184
|
-
'
|
|
191
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/no-mocks-import.html
|
|
192
|
+
'vitest/no-mocks-import': 'error',
|
|
185
193
|
|
|
186
194
|
// Disallow the use of certain matchers
|
|
187
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
188
|
-
'
|
|
195
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/no-restricted-matchers.html
|
|
196
|
+
'vitest/no-restricted-matchers': 'error',
|
|
189
197
|
|
|
190
198
|
// Disallow using expect outside of it or test blocks
|
|
191
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
192
|
-
'
|
|
199
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/no-standalone-expect.html
|
|
200
|
+
'vitest/no-standalone-expect': 'error',
|
|
193
201
|
|
|
194
202
|
// Disallow using test as a prefix
|
|
195
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
196
|
-
'
|
|
203
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/no-test-prefixes.html
|
|
204
|
+
'vitest/no-test-prefixes': 'error',
|
|
197
205
|
|
|
198
206
|
// Disallow return statements in tests
|
|
199
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
200
|
-
'
|
|
207
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/no-test-return-statement.html
|
|
208
|
+
'vitest/no-test-return-statement': 'error',
|
|
201
209
|
|
|
202
210
|
// Disallow unnecessary async in expect functions
|
|
203
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
204
|
-
'
|
|
205
|
-
|
|
206
|
-
// Enforce padding around test blocks
|
|
207
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/jest/padding-around-test-blocks.html
|
|
208
|
-
'jest/padding-around-test-blocks': 'error',
|
|
211
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/no-unneeded-async-expect-function.html
|
|
212
|
+
'vitest/no-unneeded-async-expect-function': 'error',
|
|
209
213
|
|
|
210
214
|
// Suggest using toBeCalledWith() or toHaveBeenCalledWith()
|
|
211
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
212
|
-
'
|
|
215
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/prefer-called-with.html
|
|
216
|
+
'vitest/prefer-called-with': 'error',
|
|
213
217
|
|
|
214
218
|
// Suggest using the built-in comparison matchers
|
|
215
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
216
|
-
'
|
|
219
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/prefer-comparison-matcher.html
|
|
220
|
+
'vitest/prefer-comparison-matcher': 'error',
|
|
217
221
|
|
|
218
222
|
// Prefer each rather than manual loops
|
|
219
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
220
|
-
'
|
|
223
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/prefer-each.html
|
|
224
|
+
'vitest/prefer-each': 'error',
|
|
221
225
|
|
|
222
226
|
// Suggest using the built-in equality matchers
|
|
223
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
224
|
-
'
|
|
227
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/prefer-equality-matcher.html
|
|
228
|
+
'vitest/prefer-equality-matcher': 'error',
|
|
225
229
|
|
|
226
230
|
// Suggest using expect().resolves over expect(await ...) syntax
|
|
227
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
228
|
-
'
|
|
231
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/prefer-expect-resolves.html
|
|
232
|
+
'vitest/prefer-expect-resolves': 'error',
|
|
229
233
|
|
|
230
234
|
// Prefer having hooks in consistent order
|
|
231
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
232
|
-
'
|
|
235
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/prefer-hooks-in-order.html
|
|
236
|
+
'vitest/prefer-hooks-in-order': 'error',
|
|
233
237
|
|
|
234
238
|
// Suggest having hooks before any test cases
|
|
235
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
236
|
-
'
|
|
239
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/prefer-hooks-on-top.html
|
|
240
|
+
'vitest/prefer-hooks-on-top': 'error',
|
|
237
241
|
|
|
238
242
|
// Enforce lowercase titles
|
|
239
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
243
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/prefer-lowercase-title.html
|
|
240
244
|
'vitest/prefer-lowercase-title': 'off',
|
|
241
245
|
|
|
242
246
|
// Prefer mock resolved/rejected shorthands for promises
|
|
243
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
244
|
-
'
|
|
247
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/prefer-mock-promise-shorthand.html
|
|
248
|
+
'vitest/prefer-mock-promise-shorthand': 'error',
|
|
245
249
|
|
|
246
250
|
// Prefer mock return shorthands
|
|
247
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
248
|
-
'
|
|
251
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/prefer-mock-return-shorthand.html
|
|
252
|
+
'vitest/prefer-mock-return-shorthand': 'error',
|
|
249
253
|
|
|
250
254
|
// Suggest using vi.spyOn
|
|
251
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
252
|
-
'
|
|
255
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/prefer-spy-on.html
|
|
256
|
+
'vitest/prefer-spy-on': 'error',
|
|
253
257
|
|
|
254
258
|
// Prefer strict equal over equal
|
|
255
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
256
|
-
'
|
|
259
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/prefer-strict-equal.html
|
|
260
|
+
'vitest/prefer-strict-equal': 'error',
|
|
257
261
|
|
|
258
262
|
// Suggest using toBe()
|
|
259
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
260
|
-
'
|
|
263
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/prefer-to-be.html
|
|
264
|
+
'vitest/prefer-to-be': 'error',
|
|
261
265
|
|
|
262
266
|
// Prefer using toContain()
|
|
263
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
264
|
-
'
|
|
267
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/prefer-to-contain.html
|
|
268
|
+
'vitest/prefer-to-contain': 'error',
|
|
265
269
|
|
|
266
270
|
// Suggest using toHaveLength()
|
|
267
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
268
|
-
'
|
|
271
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/prefer-to-have-length.html
|
|
272
|
+
'vitest/prefer-to-have-length': 'error',
|
|
269
273
|
|
|
270
274
|
// Suggest using test.todo
|
|
271
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
272
|
-
'
|
|
275
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/prefer-todo.html
|
|
276
|
+
'vitest/prefer-todo': 'error',
|
|
273
277
|
|
|
274
278
|
// Require setup and teardown to be within a hook
|
|
275
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
276
|
-
'
|
|
279
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/require-hook.html
|
|
280
|
+
'vitest/require-hook': 'error',
|
|
277
281
|
|
|
278
282
|
// Require toThrow() to be called with an error message
|
|
279
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
280
|
-
'
|
|
283
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/require-to-throw-message.html
|
|
284
|
+
'vitest/require-to-throw-message': 'error',
|
|
281
285
|
|
|
282
286
|
// Enforce that all tests are in a top-level describe
|
|
283
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
284
|
-
'
|
|
287
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/require-top-level-describe.html
|
|
288
|
+
'vitest/require-top-level-describe': 'error',
|
|
285
289
|
|
|
286
290
|
// Enforce valid describe callback
|
|
287
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
288
|
-
'
|
|
291
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/valid-describe-callback.html
|
|
292
|
+
'vitest/valid-describe-callback': 'error',
|
|
289
293
|
|
|
290
294
|
// Enforce valid expect() usage
|
|
291
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
292
|
-
'
|
|
295
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/valid-expect.html
|
|
296
|
+
'vitest/valid-expect': 'error',
|
|
293
297
|
|
|
294
298
|
// Enforce valid titles
|
|
295
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
299
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/valid-title.html
|
|
296
300
|
// decision: `allowArguments` avoids conflict with `prefer-describe-function-title` rule, which is enabled
|
|
297
|
-
'
|
|
301
|
+
'vitest/valid-title': ['error', { allowArguments: true }],
|
|
298
302
|
|
|
299
303
|
//rules via jsPlugins (@vitest/eslint-plugin + no-only-tests)
|
|
300
304
|
|
|
@@ -358,7 +362,7 @@ export const vitestRules = {
|
|
|
358
362
|
|
|
359
363
|
// Prefer test or it but not both
|
|
360
364
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/consistent-test-it.md
|
|
361
|
-
// decision: handled by native
|
|
365
|
+
// decision: handled by native vitest/consistent-test-it
|
|
362
366
|
'vitest-js/consistent-test-it': 'off',
|
|
363
367
|
|
|
364
368
|
// Enforce consistent usage of vi vs vitest
|
|
@@ -368,7 +372,7 @@ export const vitestRules = {
|
|
|
368
372
|
|
|
369
373
|
// Enforce having expectation in test body
|
|
370
374
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/expect-expect.md
|
|
371
|
-
// decision: handled by native
|
|
375
|
+
// decision: handled by native vitest/expect-expect
|
|
372
376
|
'vitest-js/expect-expect': 'off',
|
|
373
377
|
|
|
374
378
|
// Ensure hoisted APIs (vi.mock, vi.hoisted, etc.) are at the top
|
|
@@ -378,27 +382,27 @@ export const vitestRules = {
|
|
|
378
382
|
|
|
379
383
|
// Enforce a maximum number of expect per test
|
|
380
384
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/max-expects.md
|
|
381
|
-
// decision: handled by native
|
|
385
|
+
// decision: handled by native vitest/max-expects
|
|
382
386
|
'vitest-js/max-expects': 'off',
|
|
383
387
|
|
|
384
388
|
// Nested describe block should be less than set max value or default value
|
|
385
389
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/max-nested-describe.md
|
|
386
|
-
// decision: handled by native
|
|
390
|
+
// decision: handled by native vitest/max-nested-describe
|
|
387
391
|
'vitest-js/max-nested-describe': 'off',
|
|
388
392
|
|
|
389
393
|
// Disallow alias methods
|
|
390
394
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-alias-methods.md
|
|
391
|
-
// decision: handled by native
|
|
395
|
+
// decision: handled by native vitest/no-alias-methods
|
|
392
396
|
'vitest-js/no-alias-methods': 'off',
|
|
393
397
|
|
|
394
398
|
// Disallow commented out tests
|
|
395
399
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-commented-out-tests.md
|
|
396
|
-
// decision: handled by native
|
|
400
|
+
// decision: handled by native vitest/no-commented-out-tests
|
|
397
401
|
'vitest-js/no-commented-out-tests': 'off',
|
|
398
402
|
|
|
399
403
|
// Disallow conditional expects
|
|
400
404
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-conditional-expect.md
|
|
401
|
-
// decision: handled by native
|
|
405
|
+
// decision: handled by native vitest/no-conditional-expect
|
|
402
406
|
'vitest-js/no-conditional-expect': 'off',
|
|
403
407
|
|
|
404
408
|
// Disallow conditional tests
|
|
@@ -413,27 +417,31 @@ export const vitestRules = {
|
|
|
413
417
|
|
|
414
418
|
// Disallow disabled tests
|
|
415
419
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-disabled-tests.md
|
|
416
|
-
// decision: handled by native
|
|
420
|
+
// decision: handled by native vitest/no-disabled-tests
|
|
417
421
|
'vitest-js/no-disabled-tests': 'off',
|
|
418
422
|
|
|
423
|
+
// Disallow done callbacks in tests
|
|
424
|
+
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-done-callback.md
|
|
425
|
+
'vitest-js/no-done-callback': 'error',
|
|
426
|
+
|
|
419
427
|
// Disallow duplicate hooks and teardown hooks
|
|
420
428
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-duplicate-hooks.md
|
|
421
|
-
// decision: handled by native
|
|
429
|
+
// decision: handled by native vitest/no-duplicate-hooks
|
|
422
430
|
'vitest-js/no-duplicate-hooks': 'off',
|
|
423
431
|
|
|
424
432
|
// Disallow focused tests
|
|
425
433
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-focused-tests.md
|
|
426
|
-
// decision: handled by native
|
|
434
|
+
// decision: handled by native vitest/no-focused-tests
|
|
427
435
|
'vitest-js/no-focused-tests': 'off',
|
|
428
436
|
|
|
429
437
|
// Disallow setup and teardown hooks
|
|
430
438
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-hooks.md
|
|
431
|
-
// decision: handled by native
|
|
439
|
+
// decision: handled by native vitest/no-hooks
|
|
432
440
|
'vitest-js/no-hooks': 'off',
|
|
433
441
|
|
|
434
442
|
// Disallow identical titles
|
|
435
443
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-identical-title.md
|
|
436
|
-
// decision: handled by native
|
|
444
|
+
// decision: handled by native vitest/no-identical-title
|
|
437
445
|
'vitest-js/no-identical-title': 'off',
|
|
438
446
|
|
|
439
447
|
// Disallow importing node:test
|
|
@@ -448,42 +456,42 @@ export const vitestRules = {
|
|
|
448
456
|
|
|
449
457
|
// Disallow string interpolation in snapshots
|
|
450
458
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-interpolation-in-snapshots.md
|
|
451
|
-
// decision: handled by native
|
|
459
|
+
// decision: handled by native vitest/no-interpolation-in-snapshots
|
|
452
460
|
'vitest-js/no-interpolation-in-snapshots': 'off',
|
|
453
461
|
|
|
454
462
|
// Disallow large snapshots
|
|
455
463
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-large-snapshots.md
|
|
456
|
-
// decision: handled by native
|
|
464
|
+
// decision: handled by native vitest/no-large-snapshots
|
|
457
465
|
'vitest-js/no-large-snapshots': 'off',
|
|
458
466
|
|
|
459
467
|
// Disallow importing from mocks directory
|
|
460
468
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-mocks-import.md
|
|
461
|
-
// decision: handled by native
|
|
469
|
+
// decision: handled by native vitest/no-mocks-import
|
|
462
470
|
'vitest-js/no-mocks-import': 'off',
|
|
463
471
|
|
|
464
472
|
// Disallow the use of certain matchers
|
|
465
473
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-restricted-matchers.md
|
|
466
|
-
// decision: handled by native
|
|
474
|
+
// decision: handled by native vitest/no-restricted-matchers
|
|
467
475
|
'vitest-js/no-restricted-matchers': 'off',
|
|
468
476
|
|
|
469
477
|
// Disallow using expect outside of it or test blocks
|
|
470
478
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-standalone-expect.md
|
|
471
|
-
// decision: handled by native
|
|
479
|
+
// decision: handled by native vitest/no-standalone-expect
|
|
472
480
|
'vitest-js/no-standalone-expect': 'off',
|
|
473
481
|
|
|
474
482
|
// Disallow using test as a prefix
|
|
475
483
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-test-prefixes.md
|
|
476
|
-
// decision: handled by native
|
|
484
|
+
// decision: handled by native vitest/no-test-prefixes
|
|
477
485
|
'vitest-js/no-test-prefixes': 'off',
|
|
478
486
|
|
|
479
487
|
// Disallow return statements in tests
|
|
480
488
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-test-return-statement.md
|
|
481
|
-
// decision: handled by native
|
|
489
|
+
// decision: handled by native vitest/no-test-return-statement
|
|
482
490
|
'vitest-js/no-test-return-statement': 'off',
|
|
483
491
|
|
|
484
492
|
// Disallow unnecessary async in expect functions
|
|
485
493
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-unneeded-async-expect-function.md
|
|
486
|
-
// decision: handled by native
|
|
494
|
+
// decision: handled by native vitest/no-unneeded-async-expect-function
|
|
487
495
|
'vitest-js/no-unneeded-async-expect-function': 'off',
|
|
488
496
|
|
|
489
497
|
// Enforce padding around all blocks
|
|
@@ -493,7 +501,7 @@ export const vitestRules = {
|
|
|
493
501
|
|
|
494
502
|
// Enforce padding around test blocks
|
|
495
503
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/padding-around-test-blocks.md
|
|
496
|
-
// decision: handled by native
|
|
504
|
+
// decision: handled by native vitest/padding-around-test-blocks
|
|
497
505
|
'vitest-js/padding-around-test-blocks': 'off',
|
|
498
506
|
|
|
499
507
|
// Prefer toHaveBeenCalledOnce() over toHaveBeenCalledTimes(1)
|
|
@@ -508,12 +516,12 @@ export const vitestRules = {
|
|
|
508
516
|
|
|
509
517
|
// Suggest using toBeCalledWith() or toHaveBeenCalledWith()
|
|
510
518
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-called-with.md
|
|
511
|
-
// decision: handled by native
|
|
519
|
+
// decision: handled by native vitest/prefer-called-with
|
|
512
520
|
'vitest-js/prefer-called-with': 'off',
|
|
513
521
|
|
|
514
522
|
// Suggest using the built-in comparison matchers
|
|
515
523
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-comparison-matcher.md
|
|
516
|
-
// decision: handled by native
|
|
524
|
+
// decision: handled by native vitest/prefer-comparison-matcher
|
|
517
525
|
'vitest-js/prefer-comparison-matcher': 'off',
|
|
518
526
|
|
|
519
527
|
// Enforce describe titles to match function names
|
|
@@ -523,12 +531,12 @@ export const vitestRules = {
|
|
|
523
531
|
|
|
524
532
|
// Prefer each rather than manual loops
|
|
525
533
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-each.md
|
|
526
|
-
// decision: handled by native
|
|
534
|
+
// decision: handled by native vitest/prefer-each
|
|
527
535
|
'vitest-js/prefer-each': 'off',
|
|
528
536
|
|
|
529
537
|
// Suggest using the built-in equality matchers
|
|
530
538
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-equality-matcher.md
|
|
531
|
-
// decision: handled by native
|
|
539
|
+
// decision: handled by native vitest/prefer-equality-matcher
|
|
532
540
|
'vitest-js/prefer-equality-matcher': 'off',
|
|
533
541
|
|
|
534
542
|
// Suggest using expect.assertions
|
|
@@ -538,7 +546,7 @@ export const vitestRules = {
|
|
|
538
546
|
|
|
539
547
|
// Suggest using expect().resolves over expect(await ...) syntax
|
|
540
548
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-expect-resolves.md
|
|
541
|
-
// decision: handled by native
|
|
549
|
+
// decision: handled by native vitest/prefer-expect-resolves
|
|
542
550
|
'vitest-js/prefer-expect-resolves': 'off',
|
|
543
551
|
|
|
544
552
|
// Prefer expect.typeOf() usage
|
|
@@ -548,12 +556,12 @@ export const vitestRules = {
|
|
|
548
556
|
|
|
549
557
|
// Prefer having hooks in consistent order
|
|
550
558
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-hooks-in-order.md
|
|
551
|
-
// decision: handled by native
|
|
559
|
+
// decision: handled by native vitest/prefer-hooks-in-order
|
|
552
560
|
'vitest-js/prefer-hooks-in-order': 'off',
|
|
553
561
|
|
|
554
562
|
// Suggest having hooks before any test cases
|
|
555
563
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-hooks-on-top.md
|
|
556
|
-
// decision: handled by native
|
|
564
|
+
// decision: handled by native vitest/prefer-hooks-on-top
|
|
557
565
|
'vitest-js/prefer-hooks-on-top': 'off',
|
|
558
566
|
|
|
559
567
|
// Prefer vi.importActual/vi.importMock in vi.mock factories
|
|
@@ -568,12 +576,12 @@ export const vitestRules = {
|
|
|
568
576
|
|
|
569
577
|
// Prefer mock resolved/rejected shorthands for promises
|
|
570
578
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-mock-promise-shorthand.md
|
|
571
|
-
// decision: handled by native
|
|
579
|
+
// decision: handled by native vitest/prefer-mock-promise-shorthand
|
|
572
580
|
'vitest-js/prefer-mock-promise-shorthand': 'off',
|
|
573
581
|
|
|
574
582
|
// Suggest using vi.spyOn
|
|
575
583
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-spy-on.md
|
|
576
|
-
// decision: handled by native
|
|
584
|
+
// decision: handled by native vitest/prefer-spy-on
|
|
577
585
|
'vitest-js/prefer-spy-on': 'off',
|
|
578
586
|
|
|
579
587
|
// Prefer strict boolean matchers (toBe(true) over toBeTruthy())
|
|
@@ -583,12 +591,12 @@ export const vitestRules = {
|
|
|
583
591
|
|
|
584
592
|
// Prefer strict equal over equal
|
|
585
593
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-strict-equal.md
|
|
586
|
-
// decision: handled by native
|
|
594
|
+
// decision: handled by native vitest/prefer-strict-equal
|
|
587
595
|
'vitest-js/prefer-strict-equal': 'off',
|
|
588
596
|
|
|
589
597
|
// Suggest using toBe()
|
|
590
598
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-be.md
|
|
591
|
-
// decision: handled by native
|
|
599
|
+
// decision: handled by native vitest/prefer-to-be
|
|
592
600
|
'vitest-js/prefer-to-be': 'off',
|
|
593
601
|
|
|
594
602
|
// Suggest using toBeFalsy()
|
|
@@ -608,7 +616,7 @@ export const vitestRules = {
|
|
|
608
616
|
|
|
609
617
|
// Prefer using toContain()
|
|
610
618
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-contain.md
|
|
611
|
-
// decision: handled by native
|
|
619
|
+
// decision: handled by native vitest/prefer-to-contain
|
|
612
620
|
'vitest-js/prefer-to-contain': 'off',
|
|
613
621
|
|
|
614
622
|
// Prefer toHaveBeenCalledTimes over multiple assertions
|
|
@@ -618,12 +626,12 @@ export const vitestRules = {
|
|
|
618
626
|
|
|
619
627
|
// Suggest using toHaveLength()
|
|
620
628
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-have-length.md
|
|
621
|
-
// decision: handled by native
|
|
629
|
+
// decision: handled by native vitest/prefer-to-have-length
|
|
622
630
|
'vitest-js/prefer-to-have-length': 'off',
|
|
623
631
|
|
|
624
632
|
// Suggest using test.todo
|
|
625
633
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-todo.md
|
|
626
|
-
// decision: handled by native
|
|
634
|
+
// decision: handled by native vitest/prefer-todo
|
|
627
635
|
'vitest-js/prefer-todo': 'off',
|
|
628
636
|
|
|
629
637
|
// Prefer vi.mocked() over type casting
|
|
@@ -637,7 +645,7 @@ export const vitestRules = {
|
|
|
637
645
|
|
|
638
646
|
// Require setup and teardown to be within a hook
|
|
639
647
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/require-hook.md
|
|
640
|
-
// decision: handled by native
|
|
648
|
+
// decision: handled by native vitest/require-hook
|
|
641
649
|
'vitest-js/require-hook': 'off',
|
|
642
650
|
|
|
643
651
|
// Require local Test Context for concurrent snapshot tests
|
|
@@ -657,12 +665,12 @@ export const vitestRules = {
|
|
|
657
665
|
|
|
658
666
|
// Require toThrow() to be called with an error message
|
|
659
667
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/require-to-throw-message.md
|
|
660
|
-
// decision: handled by native
|
|
668
|
+
// decision: handled by native vitest/require-to-throw-message
|
|
661
669
|
'vitest-js/require-to-throw-message': 'off',
|
|
662
670
|
|
|
663
671
|
// Enforce that all tests are in a top-level describe
|
|
664
672
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/require-top-level-describe.md
|
|
665
|
-
// decision: handled by native
|
|
673
|
+
// decision: handled by native vitest/require-top-level-describe
|
|
666
674
|
'vitest-js/require-top-level-describe': 'off',
|
|
667
675
|
|
|
668
676
|
// Enforce unbound methods are called with their expected scope
|
|
@@ -672,12 +680,12 @@ export const vitestRules = {
|
|
|
672
680
|
|
|
673
681
|
// Enforce valid describe callback
|
|
674
682
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/valid-describe-callback.md
|
|
675
|
-
// decision: handled by native
|
|
683
|
+
// decision: handled by native vitest/valid-describe-callback
|
|
676
684
|
'vitest-js/valid-describe-callback': 'off',
|
|
677
685
|
|
|
678
686
|
// Enforce valid expect() usage
|
|
679
687
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/valid-expect.md
|
|
680
|
-
// decision: handled by native
|
|
688
|
+
// decision: handled by native vitest/valid-expect
|
|
681
689
|
'vitest-js/valid-expect': 'off',
|
|
682
690
|
|
|
683
691
|
// Enforce valid expect in promise
|
|
@@ -687,7 +695,7 @@ export const vitestRules = {
|
|
|
687
695
|
|
|
688
696
|
// Enforce valid titles
|
|
689
697
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/valid-title.md
|
|
690
|
-
// decision: handled by native
|
|
698
|
+
// decision: handled by native vitest/valid-title
|
|
691
699
|
'vitest-js/valid-title': 'off',
|
|
692
700
|
},
|
|
693
701
|
};
|