@vitest/eslint-plugin 1.4.4 β 1.5.0
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 +81 -81
- package/dist/index.cjs +17 -6
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +17 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -185,86 +185,86 @@ export default defineConfig({
|
|
|
185
185
|
π Requires [type information](https://typescript-eslint.io/linting/typed-linting).\
|
|
186
186
|
β Deprecated.
|
|
187
187
|
|
|
188
|
-
| NameΒ Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β | Description | πΌ | β οΈ
|
|
189
|
-
| :----------------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------- | :-- |
|
|
190
|
-
| [consistent-each-for](docs/rules/consistent-each-for.md) | enforce using `.each` or `.for` consistently | | π
|
|
191
|
-
| [consistent-test-filename](docs/rules/consistent-test-filename.md) | require test file pattern | | π
|
|
192
|
-
| [consistent-test-it](docs/rules/consistent-test-it.md) | enforce using test or it but not both | | π
|
|
193
|
-
| [consistent-vitest-vi](docs/rules/consistent-vitest-vi.md) | enforce using vitest or vi but not both | | π
|
|
194
|
-
| [expect-expect](docs/rules/expect-expect.md) | enforce having expectation in test body | β
| π
|
|
195
|
-
| [hoisted-apis-on-top](docs/rules/hoisted-apis-on-top.md) | enforce hoisted APIs to be on top of the file | | π
|
|
196
|
-
| [max-expects](docs/rules/max-expects.md) | enforce a maximum number of expect per test | | π
|
|
197
|
-
| [max-nested-describe](docs/rules/max-nested-describe.md) | require describe block to be less than set max value or default value | | π
|
|
198
|
-
| [no-alias-methods](docs/rules/no-alias-methods.md) | disallow alias methods | | π
|
|
199
|
-
| [no-commented-out-tests](docs/rules/no-commented-out-tests.md) | disallow commented out tests | β
| π
|
|
200
|
-
| [no-conditional-expect](docs/rules/no-conditional-expect.md) | disallow conditional expects |
|
|
201
|
-
| [no-conditional-in-test](docs/rules/no-conditional-in-test.md) | disallow conditional tests | | π
|
|
202
|
-
| [no-conditional-tests](docs/rules/no-conditional-tests.md) | disallow conditional tests | | π
|
|
203
|
-
| [no-disabled-tests](docs/rules/no-disabled-tests.md) | disallow disabled tests | | π
|
|
204
|
-
| [no-done-callback](docs/rules/no-done-callback.md) | disallow using a callback in asynchronous tests and hooks | |
|
|
205
|
-
| [no-duplicate-hooks](docs/rules/no-duplicate-hooks.md) | disallow duplicate hooks and teardown hooks | | π
|
|
206
|
-
| [no-focused-tests](docs/rules/no-focused-tests.md) | disallow focused tests |
|
|
207
|
-
| [no-hooks](docs/rules/no-hooks.md) | disallow setup and teardown hooks | | π
|
|
208
|
-
| [no-identical-title](docs/rules/no-identical-title.md) | disallow identical titles | β
| π
|
|
209
|
-
| [no-import-node-test](docs/rules/no-import-node-test.md) | disallow importing `node:test` | β
| π
|
|
210
|
-
| [no-importing-vitest-globals](docs/rules/no-importing-vitest-globals.md) | disallow importing Vitest globals | |
|
|
211
|
-
| [no-interpolation-in-snapshots](docs/rules/no-interpolation-in-snapshots.md) | disallow string interpolation in snapshots |
|
|
212
|
-
| [no-large-snapshots](docs/rules/no-large-snapshots.md) | disallow large snapshots | | π
|
|
213
|
-
| [no-mocks-import](docs/rules/no-mocks-import.md) | disallow importing from **mocks** directory |
|
|
214
|
-
| [no-restricted-matchers](docs/rules/no-restricted-matchers.md) | disallow the use of certain matchers | | π
|
|
215
|
-
| [no-restricted-vi-methods](docs/rules/no-restricted-vi-methods.md) | disallow specific `vi.` methods | | π
|
|
216
|
-
| [no-standalone-expect](docs/rules/no-standalone-expect.md) | disallow using `expect` outside of `it` or `test` blocks |
|
|
217
|
-
| [no-test-prefixes](docs/rules/no-test-prefixes.md) | disallow using the `f` and `x` prefixes in favour of `.only` and `.skip` | | π
|
|
218
|
-
| [no-test-return-statement](docs/rules/no-test-return-statement.md) | disallow return statements in tests | | π
|
|
219
|
-
| [padding-around-after-all-blocks](docs/rules/padding-around-after-all-blocks.md) | Enforce padding around `afterAll` blocks | | π
|
|
220
|
-
| [padding-around-after-each-blocks](docs/rules/padding-around-after-each-blocks.md) | Enforce padding around `afterEach` blocks | | π
|
|
221
|
-
| [padding-around-all](docs/rules/padding-around-all.md) | Enforce padding around vitest functions | | π
|
|
222
|
-
| [padding-around-before-all-blocks](docs/rules/padding-around-before-all-blocks.md) | Enforce padding around `beforeAll` blocks | | π
|
|
223
|
-
| [padding-around-before-each-blocks](docs/rules/padding-around-before-each-blocks.md) | Enforce padding around `beforeEach` blocks | | π
|
|
224
|
-
| [padding-around-describe-blocks](docs/rules/padding-around-describe-blocks.md) | Enforce padding around `describe` blocks | | π
|
|
225
|
-
| [padding-around-expect-groups](docs/rules/padding-around-expect-groups.md) | Enforce padding around `expect` groups | | π
|
|
226
|
-
| [padding-around-test-blocks](docs/rules/padding-around-test-blocks.md) | Enforce padding around `test` blocks | | π
|
|
227
|
-
| [prefer-called-exactly-once-with](docs/rules/prefer-called-exactly-once-with.md) | Prefer `toHaveBeenCalledExactlyOnceWith` over `toHaveBeenCalledOnce` and `toHaveBeenCalledWith` | β
| π
|
|
228
|
-
| [prefer-called-once](docs/rules/prefer-called-once.md) | enforce using `toBeCalledOnce()` or `toHaveBeenCalledOnce()` | |
|
|
229
|
-
| [prefer-called-times](docs/rules/prefer-called-times.md) | enforce using `toBeCalledTimes(1)` or `toHaveBeenCalledTimes(1)` | | π
|
|
230
|
-
| [prefer-called-with](docs/rules/prefer-called-with.md) | enforce using `toBeCalledWith()` or `toHaveBeenCalledWith()` | | π
|
|
231
|
-
| [prefer-comparison-matcher](docs/rules/prefer-comparison-matcher.md) | enforce using the built-in comparison matchers | | π
|
|
232
|
-
| [prefer-describe-function-title](docs/rules/prefer-describe-function-title.md) | enforce using a function as a describe title over an equivalent string | | π
|
|
233
|
-
| [prefer-each](docs/rules/prefer-each.md) | enforce using `each` rather than manual loops | | π
|
|
234
|
-
| [prefer-equality-matcher](docs/rules/prefer-equality-matcher.md) | enforce using the built-in equality matchers | | π
|
|
235
|
-
| [prefer-expect-assertions](docs/rules/prefer-expect-assertions.md) | enforce using expect assertions instead of callbacks | | π
|
|
236
|
-
| [prefer-expect-resolves](docs/rules/prefer-expect-resolves.md) | enforce using `expect().resolves` over `expect(await ...)` syntax | | π
|
|
237
|
-
| [prefer-expect-type-of](docs/rules/prefer-expect-type-of.md) | enforce using `expectTypeOf` instead of `expect(typeof ...)` | | π
|
|
238
|
-
| [prefer-hooks-in-order](docs/rules/prefer-hooks-in-order.md) | enforce having hooks in consistent order | | π
|
|
239
|
-
| [prefer-hooks-on-top](docs/rules/prefer-hooks-on-top.md) | enforce having hooks before any test cases | | π
|
|
240
|
-
| [prefer-import-in-mock](docs/rules/prefer-import-in-mock.md) | prefer dynamic import in mock | | π
|
|
241
|
-
| [prefer-importing-vitest-globals](docs/rules/prefer-importing-vitest-globals.md) | enforce importing Vitest globals | | π
|
|
242
|
-
| [prefer-lowercase-title](docs/rules/prefer-lowercase-title.md) | enforce lowercase titles | | π
|
|
243
|
-
| [prefer-mock-promise-shorthand](docs/rules/prefer-mock-promise-shorthand.md) | enforce mock resolved/rejected shorthands for promises | | π
|
|
244
|
-
| [prefer-snapshot-hint](docs/rules/prefer-snapshot-hint.md) | enforce including a hint with external snapshots | | π
|
|
245
|
-
| [prefer-spy-on](docs/rules/prefer-spy-on.md) | enforce using `vi.spyOn` | | π
|
|
246
|
-
| [prefer-strict-boolean-matchers](docs/rules/prefer-strict-boolean-matchers.md) | enforce using `toBe(true)` and `toBe(false)` over matchers that coerce types to boolean | | π
|
|
247
|
-
| [prefer-strict-equal](docs/rules/prefer-strict-equal.md) | enforce strict equal over equal | | π
|
|
248
|
-
| [prefer-to-be](docs/rules/prefer-to-be.md) | enforce using toBe() | | π
|
|
249
|
-
| [prefer-to-be-falsy](docs/rules/prefer-to-be-falsy.md) | enforce using toBeFalsy() | |
|
|
250
|
-
| [prefer-to-be-object](docs/rules/prefer-to-be-object.md) | enforce using toBeObject() | | π
|
|
251
|
-
| [prefer-to-be-truthy](docs/rules/prefer-to-be-truthy.md) | enforce using `toBeTruthy` | |
|
|
252
|
-
| [prefer-to-contain](docs/rules/prefer-to-contain.md) | enforce using toContain() | | π
|
|
253
|
-
| [prefer-to-have-length](docs/rules/prefer-to-have-length.md) | enforce using toHaveLength() | | π
|
|
254
|
-
| [prefer-todo](docs/rules/prefer-todo.md) | enforce using `test.todo` | | π
|
|
255
|
-
| [prefer-vi-mocked](docs/rules/prefer-vi-mocked.md) | require `vi.mocked()` over `fn as Mock` | | π
|
|
256
|
-
| [require-awaited-expect-poll](docs/rules/require-awaited-expect-poll.md) | ensure that every `expect.poll` call is awaited | | π
|
|
257
|
-
| [require-hook](docs/rules/require-hook.md) | require setup and teardown to be within a hook | | π
|
|
258
|
-
| [require-import-vi-mock](docs/rules/require-import-vi-mock.md) | require usage of import in vi.mock() | | π
|
|
259
|
-
| [require-local-test-context-for-concurrent-snapshots](docs/rules/require-local-test-context-for-concurrent-snapshots.md) | require local Test Context for concurrent snapshot tests | β
| π
|
|
260
|
-
| [require-mock-type-parameters](docs/rules/require-mock-type-parameters.md) | enforce using type parameters with vitest mock functions | | π
|
|
261
|
-
| [require-to-throw-message](docs/rules/require-to-throw-message.md) | require toThrow() to be called with an error message | | π
|
|
262
|
-
| [require-top-level-describe](docs/rules/require-top-level-describe.md) | enforce that all tests are in a top-level describe | | π
|
|
263
|
-
| [valid-describe-callback](docs/rules/valid-describe-callback.md) | enforce valid describe callback | β
| π
|
|
264
|
-
| [valid-expect](docs/rules/valid-expect.md) | enforce valid `expect()` usage | β
| π
|
|
265
|
-
| [valid-expect-in-promise](docs/rules/valid-expect-in-promise.md) | require promises that have expectations in their chain to be valid |
|
|
266
|
-
| [valid-title](docs/rules/valid-title.md) | enforce valid titles | β
| π
|
|
267
|
-
| [warn-todo](docs/rules/warn-todo.md) | disallow `.todo` usage | |
|
|
188
|
+
| NameΒ Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β | Description | πΌ | β οΈ | π« | π§ | π‘ | π | β |
|
|
189
|
+
| :----------------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------- | :-- | :---- | :-- | :-- | :-- | :-- | :-- |
|
|
190
|
+
| [consistent-each-for](docs/rules/consistent-each-for.md) | enforce using `.each` or `.for` consistently | | π | | | | | |
|
|
191
|
+
| [consistent-test-filename](docs/rules/consistent-test-filename.md) | require test file pattern | | π | | | | | |
|
|
192
|
+
| [consistent-test-it](docs/rules/consistent-test-it.md) | enforce using test or it but not both | | π | | π§ | | | |
|
|
193
|
+
| [consistent-vitest-vi](docs/rules/consistent-vitest-vi.md) | enforce using vitest or vi but not both | | π | | π§ | | | |
|
|
194
|
+
| [expect-expect](docs/rules/expect-expect.md) | enforce having expectation in test body | β
| π | | | | | |
|
|
195
|
+
| [hoisted-apis-on-top](docs/rules/hoisted-apis-on-top.md) | enforce hoisted APIs to be on top of the file | | π | | | π‘ | | |
|
|
196
|
+
| [max-expects](docs/rules/max-expects.md) | enforce a maximum number of expect per test | | π | | | | | |
|
|
197
|
+
| [max-nested-describe](docs/rules/max-nested-describe.md) | require describe block to be less than set max value or default value | | π | | | | | |
|
|
198
|
+
| [no-alias-methods](docs/rules/no-alias-methods.md) | disallow alias methods | | π | | π§ | | | |
|
|
199
|
+
| [no-commented-out-tests](docs/rules/no-commented-out-tests.md) | disallow commented out tests | β
| π | | | | | |
|
|
200
|
+
| [no-conditional-expect](docs/rules/no-conditional-expect.md) | disallow conditional expects | β
| π | | | | | |
|
|
201
|
+
| [no-conditional-in-test](docs/rules/no-conditional-in-test.md) | disallow conditional tests | | π | | | | | |
|
|
202
|
+
| [no-conditional-tests](docs/rules/no-conditional-tests.md) | disallow conditional tests | | π | | | | | |
|
|
203
|
+
| [no-disabled-tests](docs/rules/no-disabled-tests.md) | disallow disabled tests | | π β
| | | | | |
|
|
204
|
+
| [no-done-callback](docs/rules/no-done-callback.md) | disallow using a callback in asynchronous tests and hooks | | | | | π‘ | | β |
|
|
205
|
+
| [no-duplicate-hooks](docs/rules/no-duplicate-hooks.md) | disallow duplicate hooks and teardown hooks | | π | | | | | |
|
|
206
|
+
| [no-focused-tests](docs/rules/no-focused-tests.md) | disallow focused tests | β
| π | | π§ | | | |
|
|
207
|
+
| [no-hooks](docs/rules/no-hooks.md) | disallow setup and teardown hooks | | π | | | | | |
|
|
208
|
+
| [no-identical-title](docs/rules/no-identical-title.md) | disallow identical titles | β
| π | | π§ | | | |
|
|
209
|
+
| [no-import-node-test](docs/rules/no-import-node-test.md) | disallow importing `node:test` | β
| π | | π§ | | | |
|
|
210
|
+
| [no-importing-vitest-globals](docs/rules/no-importing-vitest-globals.md) | disallow importing Vitest globals | | | π | π§ | | | |
|
|
211
|
+
| [no-interpolation-in-snapshots](docs/rules/no-interpolation-in-snapshots.md) | disallow string interpolation in snapshots | β
| π | | π§ | | | |
|
|
212
|
+
| [no-large-snapshots](docs/rules/no-large-snapshots.md) | disallow large snapshots | | π | | | | | |
|
|
213
|
+
| [no-mocks-import](docs/rules/no-mocks-import.md) | disallow importing from **mocks** directory | β
| π | | | | | |
|
|
214
|
+
| [no-restricted-matchers](docs/rules/no-restricted-matchers.md) | disallow the use of certain matchers | | π | | | | | |
|
|
215
|
+
| [no-restricted-vi-methods](docs/rules/no-restricted-vi-methods.md) | disallow specific `vi.` methods | | π | | | | | |
|
|
216
|
+
| [no-standalone-expect](docs/rules/no-standalone-expect.md) | disallow using `expect` outside of `it` or `test` blocks | β
| π | | | | | |
|
|
217
|
+
| [no-test-prefixes](docs/rules/no-test-prefixes.md) | disallow using the `f` and `x` prefixes in favour of `.only` and `.skip` | | π | | π§ | | | |
|
|
218
|
+
| [no-test-return-statement](docs/rules/no-test-return-statement.md) | disallow return statements in tests | | π | | | | | |
|
|
219
|
+
| [padding-around-after-all-blocks](docs/rules/padding-around-after-all-blocks.md) | Enforce padding around `afterAll` blocks | | π | | π§ | | | |
|
|
220
|
+
| [padding-around-after-each-blocks](docs/rules/padding-around-after-each-blocks.md) | Enforce padding around `afterEach` blocks | | π | | π§ | | | |
|
|
221
|
+
| [padding-around-all](docs/rules/padding-around-all.md) | Enforce padding around vitest functions | | π | | π§ | | | |
|
|
222
|
+
| [padding-around-before-all-blocks](docs/rules/padding-around-before-all-blocks.md) | Enforce padding around `beforeAll` blocks | | π | | π§ | | | |
|
|
223
|
+
| [padding-around-before-each-blocks](docs/rules/padding-around-before-each-blocks.md) | Enforce padding around `beforeEach` blocks | | π | | π§ | | | |
|
|
224
|
+
| [padding-around-describe-blocks](docs/rules/padding-around-describe-blocks.md) | Enforce padding around `describe` blocks | | π | | π§ | | | |
|
|
225
|
+
| [padding-around-expect-groups](docs/rules/padding-around-expect-groups.md) | Enforce padding around `expect` groups | | π | | π§ | | | |
|
|
226
|
+
| [padding-around-test-blocks](docs/rules/padding-around-test-blocks.md) | Enforce padding around `test` blocks | | π | | π§ | | | |
|
|
227
|
+
| [prefer-called-exactly-once-with](docs/rules/prefer-called-exactly-once-with.md) | Prefer `toHaveBeenCalledExactlyOnceWith` over `toHaveBeenCalledOnce` and `toHaveBeenCalledWith` | β
| π | | π§ | | | |
|
|
228
|
+
| [prefer-called-once](docs/rules/prefer-called-once.md) | enforce using `toBeCalledOnce()` or `toHaveBeenCalledOnce()` | | | π | π§ | | | |
|
|
229
|
+
| [prefer-called-times](docs/rules/prefer-called-times.md) | enforce using `toBeCalledTimes(1)` or `toHaveBeenCalledTimes(1)` | | π | | π§ | | | |
|
|
230
|
+
| [prefer-called-with](docs/rules/prefer-called-with.md) | enforce using `toBeCalledWith()` or `toHaveBeenCalledWith()` | | π | | π§ | | | |
|
|
231
|
+
| [prefer-comparison-matcher](docs/rules/prefer-comparison-matcher.md) | enforce using the built-in comparison matchers | | π | | π§ | | | |
|
|
232
|
+
| [prefer-describe-function-title](docs/rules/prefer-describe-function-title.md) | enforce using a function as a describe title over an equivalent string | | π | | π§ | | | |
|
|
233
|
+
| [prefer-each](docs/rules/prefer-each.md) | enforce using `each` rather than manual loops | | π | | | | | |
|
|
234
|
+
| [prefer-equality-matcher](docs/rules/prefer-equality-matcher.md) | enforce using the built-in equality matchers | | π | | | π‘ | | |
|
|
235
|
+
| [prefer-expect-assertions](docs/rules/prefer-expect-assertions.md) | enforce using expect assertions instead of callbacks | | π | | | π‘ | | |
|
|
236
|
+
| [prefer-expect-resolves](docs/rules/prefer-expect-resolves.md) | enforce using `expect().resolves` over `expect(await ...)` syntax | | π | | π§ | | | |
|
|
237
|
+
| [prefer-expect-type-of](docs/rules/prefer-expect-type-of.md) | enforce using `expectTypeOf` instead of `expect(typeof ...)` | | π | | π§ | | | |
|
|
238
|
+
| [prefer-hooks-in-order](docs/rules/prefer-hooks-in-order.md) | enforce having hooks in consistent order | | π | | | | | |
|
|
239
|
+
| [prefer-hooks-on-top](docs/rules/prefer-hooks-on-top.md) | enforce having hooks before any test cases | | π | | | | | |
|
|
240
|
+
| [prefer-import-in-mock](docs/rules/prefer-import-in-mock.md) | prefer dynamic import in mock | | π | | π§ | | | |
|
|
241
|
+
| [prefer-importing-vitest-globals](docs/rules/prefer-importing-vitest-globals.md) | enforce importing Vitest globals | | π | | π§ | | | |
|
|
242
|
+
| [prefer-lowercase-title](docs/rules/prefer-lowercase-title.md) | enforce lowercase titles | | π | | π§ | | | |
|
|
243
|
+
| [prefer-mock-promise-shorthand](docs/rules/prefer-mock-promise-shorthand.md) | enforce mock resolved/rejected shorthands for promises | | π | | π§ | | | |
|
|
244
|
+
| [prefer-snapshot-hint](docs/rules/prefer-snapshot-hint.md) | enforce including a hint with external snapshots | | π | | | | | |
|
|
245
|
+
| [prefer-spy-on](docs/rules/prefer-spy-on.md) | enforce using `vi.spyOn` | | π | | π§ | | | |
|
|
246
|
+
| [prefer-strict-boolean-matchers](docs/rules/prefer-strict-boolean-matchers.md) | enforce using `toBe(true)` and `toBe(false)` over matchers that coerce types to boolean | | π | | π§ | | | |
|
|
247
|
+
| [prefer-strict-equal](docs/rules/prefer-strict-equal.md) | enforce strict equal over equal | | π | | | π‘ | | |
|
|
248
|
+
| [prefer-to-be](docs/rules/prefer-to-be.md) | enforce using toBe() | | π | | π§ | | | |
|
|
249
|
+
| [prefer-to-be-falsy](docs/rules/prefer-to-be-falsy.md) | enforce using toBeFalsy() | | | π | π§ | | | |
|
|
250
|
+
| [prefer-to-be-object](docs/rules/prefer-to-be-object.md) | enforce using toBeObject() | | π | | π§ | | | |
|
|
251
|
+
| [prefer-to-be-truthy](docs/rules/prefer-to-be-truthy.md) | enforce using `toBeTruthy` | | | π | π§ | | | |
|
|
252
|
+
| [prefer-to-contain](docs/rules/prefer-to-contain.md) | enforce using toContain() | | π | | π§ | | | |
|
|
253
|
+
| [prefer-to-have-length](docs/rules/prefer-to-have-length.md) | enforce using toHaveLength() | | π | | π§ | | | |
|
|
254
|
+
| [prefer-todo](docs/rules/prefer-todo.md) | enforce using `test.todo` | | π | | π§ | | | |
|
|
255
|
+
| [prefer-vi-mocked](docs/rules/prefer-vi-mocked.md) | require `vi.mocked()` over `fn as Mock` | | π | | π§ | | π | |
|
|
256
|
+
| [require-awaited-expect-poll](docs/rules/require-awaited-expect-poll.md) | ensure that every `expect.poll` call is awaited | | π | | | | | |
|
|
257
|
+
| [require-hook](docs/rules/require-hook.md) | require setup and teardown to be within a hook | | π | | | | | |
|
|
258
|
+
| [require-import-vi-mock](docs/rules/require-import-vi-mock.md) | require usage of import in vi.mock() | | π | | π§ | | | |
|
|
259
|
+
| [require-local-test-context-for-concurrent-snapshots](docs/rules/require-local-test-context-for-concurrent-snapshots.md) | require local Test Context for concurrent snapshot tests | β
| π | | | | | |
|
|
260
|
+
| [require-mock-type-parameters](docs/rules/require-mock-type-parameters.md) | enforce using type parameters with vitest mock functions | | π | | π§ | | | |
|
|
261
|
+
| [require-to-throw-message](docs/rules/require-to-throw-message.md) | require toThrow() to be called with an error message | | π | | | | | |
|
|
262
|
+
| [require-top-level-describe](docs/rules/require-top-level-describe.md) | enforce that all tests are in a top-level describe | | π | | | | | |
|
|
263
|
+
| [valid-describe-callback](docs/rules/valid-describe-callback.md) | enforce valid describe callback | β
| π | | | | | |
|
|
264
|
+
| [valid-expect](docs/rules/valid-expect.md) | enforce valid `expect()` usage | β
| π | | π§ | | | |
|
|
265
|
+
| [valid-expect-in-promise](docs/rules/valid-expect-in-promise.md) | require promises that have expectations in their chain to be valid | β
| π | | | | | |
|
|
266
|
+
| [valid-title](docs/rules/valid-title.md) | enforce valid titles | β
| π | | π§ | | | |
|
|
267
|
+
| [warn-todo](docs/rules/warn-todo.md) | disallow `.todo` usage | | | | | | | |
|
|
268
268
|
|
|
269
269
|
<!-- end auto-generated rules list -->
|
|
270
270
|
|
|
@@ -275,4 +275,4 @@ export default defineConfig({
|
|
|
275
275
|
|
|
276
276
|
### Licence
|
|
277
277
|
|
|
278
|
-
[MIT](https://github.com/veritem/eslint-plugin-vitest/blob/main/LICENSE) Licence © 2022 - present [veritem](https://github.com/veritem) and contributors
|
|
278
|
+
[MIT](https://github.com/veritem/eslint-plugin-vitest/blob/main/LICENSE) Licence © 2022 - present by [veritem](https://github.com/veritem) and contributors
|
package/dist/index.cjs
CHANGED
|
@@ -31,7 +31,7 @@ let __typescript_eslint_scope_manager = require("@typescript-eslint/scope-manage
|
|
|
31
31
|
__typescript_eslint_scope_manager = __toESM(__typescript_eslint_scope_manager);
|
|
32
32
|
|
|
33
33
|
//#region package.json
|
|
34
|
-
var version = "1.
|
|
34
|
+
var version = "1.5.0";
|
|
35
35
|
|
|
36
36
|
//#endregion
|
|
37
37
|
//#region src/utils/index.ts
|
|
@@ -1969,6 +1969,7 @@ var consistent_test_it_default = createEslintRule({
|
|
|
1969
1969
|
const testFnKeyWork = fn || TestCaseName.test;
|
|
1970
1970
|
const testKeywordWithinDescribe = withinDescribe || fn || TestCaseName.it;
|
|
1971
1971
|
const testFnDisabled = testFnKeyWork === testKeywordWithinDescribe ? testFnKeyWork : void 0;
|
|
1972
|
+
const { sourceCode } = context;
|
|
1972
1973
|
let describeNestingLevel = 0;
|
|
1973
1974
|
return {
|
|
1974
1975
|
ImportDeclaration(node) {
|
|
@@ -1978,8 +1979,8 @@ var consistent_test_it_default = createEslintRule({
|
|
|
1978
1979
|
for (const specifier of node.specifiers) {
|
|
1979
1980
|
if (specifier.type !== "ImportSpecifier") continue;
|
|
1980
1981
|
if (specifier.imported.type !== "Identifier") continue;
|
|
1981
|
-
if (specifier.
|
|
1982
|
-
|
|
1982
|
+
if (specifier.imported.name !== oppositeTestKeyword) continue;
|
|
1983
|
+
context.report({
|
|
1983
1984
|
node: specifier,
|
|
1984
1985
|
data: {
|
|
1985
1986
|
testFnKeyWork,
|
|
@@ -1987,14 +1988,17 @@ var consistent_test_it_default = createEslintRule({
|
|
|
1987
1988
|
},
|
|
1988
1989
|
messageId: "consistentMethod",
|
|
1989
1990
|
fix: (fixer) => {
|
|
1990
|
-
const remainingSpecifiers = node.specifiers.filter((spec) => spec
|
|
1991
|
+
const remainingSpecifiers = node.specifiers.filter((spec) => spec !== specifier);
|
|
1991
1992
|
if (remainingSpecifiers.length > 0) {
|
|
1992
|
-
const
|
|
1993
|
+
const hasPreferredSpecifier = remainingSpecifiers.some((spec) => spec.type === __typescript_eslint_utils.AST_NODE_TYPES.ImportSpecifier && spec.imported.type === __typescript_eslint_utils.AST_NODE_TYPES.Identifier && spec.imported.name === testFnDisabled);
|
|
1994
|
+
const importNames = remainingSpecifiers.map((spec) => sourceCode.getText(spec));
|
|
1995
|
+
if (!hasPreferredSpecifier) importNames.push(testFnDisabled);
|
|
1996
|
+
const importText = importNames.join(", ");
|
|
1993
1997
|
const lastSpecifierRange = node.specifiers.at(-1)?.range;
|
|
1994
1998
|
if (!lastSpecifierRange) return null;
|
|
1995
1999
|
return fixer.replaceTextRange([node.specifiers[0].range[0], lastSpecifierRange[1]], importText);
|
|
1996
2000
|
}
|
|
1997
|
-
return fixer.replaceText(specifier
|
|
2001
|
+
return fixer.replaceText(specifier, testFnDisabled);
|
|
1998
2002
|
}
|
|
1999
2003
|
});
|
|
2000
2004
|
}
|
|
@@ -6780,13 +6784,20 @@ const allRules = {
|
|
|
6780
6784
|
};
|
|
6781
6785
|
const recommendedRules = {
|
|
6782
6786
|
"expect-expect": "error",
|
|
6787
|
+
"no-conditional-expect": "error",
|
|
6788
|
+
"no-disabled-tests": "warn",
|
|
6789
|
+
"no-focused-tests": "error",
|
|
6783
6790
|
"no-commented-out-tests": "error",
|
|
6784
6791
|
"no-identical-title": "error",
|
|
6785
6792
|
"no-import-node-test": "error",
|
|
6793
|
+
"no-interpolation-in-snapshots": "error",
|
|
6794
|
+
"no-mocks-import": "error",
|
|
6795
|
+
"no-standalone-expect": "error",
|
|
6786
6796
|
"prefer-called-exactly-once-with": "error",
|
|
6787
6797
|
"require-local-test-context-for-concurrent-snapshots": "error",
|
|
6788
6798
|
"valid-describe-callback": "error",
|
|
6789
6799
|
"valid-expect": "error",
|
|
6800
|
+
"valid-expect-in-promise": "error",
|
|
6790
6801
|
"valid-title": "error"
|
|
6791
6802
|
};
|
|
6792
6803
|
const plugin = {
|
package/dist/index.d.cts
CHANGED
|
@@ -46,13 +46,20 @@ declare const plugin: {
|
|
|
46
46
|
};
|
|
47
47
|
readonly rules: {
|
|
48
48
|
readonly "vitest/expect-expect": "error";
|
|
49
|
+
readonly "vitest/no-conditional-expect": "error";
|
|
50
|
+
readonly "vitest/no-disabled-tests": "warn";
|
|
51
|
+
readonly "vitest/no-focused-tests": "error";
|
|
49
52
|
readonly "vitest/no-commented-out-tests": "error";
|
|
50
53
|
readonly "vitest/no-identical-title": "error";
|
|
51
54
|
readonly "vitest/no-import-node-test": "error";
|
|
55
|
+
readonly "vitest/no-interpolation-in-snapshots": "error";
|
|
56
|
+
readonly "vitest/no-mocks-import": "error";
|
|
57
|
+
readonly "vitest/no-standalone-expect": "error";
|
|
52
58
|
readonly "vitest/prefer-called-exactly-once-with": "error";
|
|
53
59
|
readonly "vitest/require-local-test-context-for-concurrent-snapshots": "error";
|
|
54
60
|
readonly "vitest/valid-describe-callback": "error";
|
|
55
61
|
readonly "vitest/valid-expect": "error";
|
|
62
|
+
readonly "vitest/valid-expect-in-promise": "error";
|
|
56
63
|
readonly "vitest/valid-title": "error";
|
|
57
64
|
};
|
|
58
65
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -46,13 +46,20 @@ declare const plugin: {
|
|
|
46
46
|
};
|
|
47
47
|
readonly rules: {
|
|
48
48
|
readonly "vitest/expect-expect": "error";
|
|
49
|
+
readonly "vitest/no-conditional-expect": "error";
|
|
50
|
+
readonly "vitest/no-disabled-tests": "warn";
|
|
51
|
+
readonly "vitest/no-focused-tests": "error";
|
|
49
52
|
readonly "vitest/no-commented-out-tests": "error";
|
|
50
53
|
readonly "vitest/no-identical-title": "error";
|
|
51
54
|
readonly "vitest/no-import-node-test": "error";
|
|
55
|
+
readonly "vitest/no-interpolation-in-snapshots": "error";
|
|
56
|
+
readonly "vitest/no-mocks-import": "error";
|
|
57
|
+
readonly "vitest/no-standalone-expect": "error";
|
|
52
58
|
readonly "vitest/prefer-called-exactly-once-with": "error";
|
|
53
59
|
readonly "vitest/require-local-test-context-for-concurrent-snapshots": "error";
|
|
54
60
|
readonly "vitest/valid-describe-callback": "error";
|
|
55
61
|
readonly "vitest/valid-expect": "error";
|
|
62
|
+
readonly "vitest/valid-expect-in-promise": "error";
|
|
56
63
|
readonly "vitest/valid-title": "error";
|
|
57
64
|
};
|
|
58
65
|
};
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { isAbsolute, posix } from "node:path";
|
|
|
4
4
|
import { DefinitionType } from "@typescript-eslint/scope-manager";
|
|
5
5
|
|
|
6
6
|
//#region package.json
|
|
7
|
-
var version = "1.
|
|
7
|
+
var version = "1.5.0";
|
|
8
8
|
|
|
9
9
|
//#endregion
|
|
10
10
|
//#region src/utils/index.ts
|
|
@@ -1942,6 +1942,7 @@ var consistent_test_it_default = createEslintRule({
|
|
|
1942
1942
|
const testFnKeyWork = fn || TestCaseName.test;
|
|
1943
1943
|
const testKeywordWithinDescribe = withinDescribe || fn || TestCaseName.it;
|
|
1944
1944
|
const testFnDisabled = testFnKeyWork === testKeywordWithinDescribe ? testFnKeyWork : void 0;
|
|
1945
|
+
const { sourceCode } = context;
|
|
1945
1946
|
let describeNestingLevel = 0;
|
|
1946
1947
|
return {
|
|
1947
1948
|
ImportDeclaration(node) {
|
|
@@ -1951,8 +1952,8 @@ var consistent_test_it_default = createEslintRule({
|
|
|
1951
1952
|
for (const specifier of node.specifiers) {
|
|
1952
1953
|
if (specifier.type !== "ImportSpecifier") continue;
|
|
1953
1954
|
if (specifier.imported.type !== "Identifier") continue;
|
|
1954
|
-
if (specifier.
|
|
1955
|
-
|
|
1955
|
+
if (specifier.imported.name !== oppositeTestKeyword) continue;
|
|
1956
|
+
context.report({
|
|
1956
1957
|
node: specifier,
|
|
1957
1958
|
data: {
|
|
1958
1959
|
testFnKeyWork,
|
|
@@ -1960,14 +1961,17 @@ var consistent_test_it_default = createEslintRule({
|
|
|
1960
1961
|
},
|
|
1961
1962
|
messageId: "consistentMethod",
|
|
1962
1963
|
fix: (fixer) => {
|
|
1963
|
-
const remainingSpecifiers = node.specifiers.filter((spec) => spec
|
|
1964
|
+
const remainingSpecifiers = node.specifiers.filter((spec) => spec !== specifier);
|
|
1964
1965
|
if (remainingSpecifiers.length > 0) {
|
|
1965
|
-
const
|
|
1966
|
+
const hasPreferredSpecifier = remainingSpecifiers.some((spec) => spec.type === AST_NODE_TYPES.ImportSpecifier && spec.imported.type === AST_NODE_TYPES.Identifier && spec.imported.name === testFnDisabled);
|
|
1967
|
+
const importNames = remainingSpecifiers.map((spec) => sourceCode.getText(spec));
|
|
1968
|
+
if (!hasPreferredSpecifier) importNames.push(testFnDisabled);
|
|
1969
|
+
const importText = importNames.join(", ");
|
|
1966
1970
|
const lastSpecifierRange = node.specifiers.at(-1)?.range;
|
|
1967
1971
|
if (!lastSpecifierRange) return null;
|
|
1968
1972
|
return fixer.replaceTextRange([node.specifiers[0].range[0], lastSpecifierRange[1]], importText);
|
|
1969
1973
|
}
|
|
1970
|
-
return fixer.replaceText(specifier
|
|
1974
|
+
return fixer.replaceText(specifier, testFnDisabled);
|
|
1971
1975
|
}
|
|
1972
1976
|
});
|
|
1973
1977
|
}
|
|
@@ -6753,13 +6757,20 @@ const allRules = {
|
|
|
6753
6757
|
};
|
|
6754
6758
|
const recommendedRules = {
|
|
6755
6759
|
"expect-expect": "error",
|
|
6760
|
+
"no-conditional-expect": "error",
|
|
6761
|
+
"no-disabled-tests": "warn",
|
|
6762
|
+
"no-focused-tests": "error",
|
|
6756
6763
|
"no-commented-out-tests": "error",
|
|
6757
6764
|
"no-identical-title": "error",
|
|
6758
6765
|
"no-import-node-test": "error",
|
|
6766
|
+
"no-interpolation-in-snapshots": "error",
|
|
6767
|
+
"no-mocks-import": "error",
|
|
6768
|
+
"no-standalone-expect": "error",
|
|
6759
6769
|
"prefer-called-exactly-once-with": "error",
|
|
6760
6770
|
"require-local-test-context-for-concurrent-snapshots": "error",
|
|
6761
6771
|
"valid-describe-callback": "error",
|
|
6762
6772
|
"valid-expect": "error",
|
|
6773
|
+
"valid-expect-in-promise": "error",
|
|
6763
6774
|
"valid-title": "error"
|
|
6764
6775
|
};
|
|
6765
6776
|
const plugin = {
|