@vitest/eslint-plugin 1.1.11 → 1.1.13

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 CHANGED
@@ -106,6 +106,39 @@ export default [
106
106
  ]
107
107
  ```
108
108
 
109
+ ### Shareable configurations
110
+
111
+ #### Recommended
112
+ This plugin exports a recommended configuration that enforces good testing practices.
113
+
114
+ To enable this configuration with `eslint.config.js`, use `vitest.configs.recommended`:
115
+
116
+ ```js
117
+ import vitest from "@vitest/eslint-plugin";
118
+
119
+ export default [
120
+ {
121
+ files: ["tests/**"], // or any other pattern
122
+ ...vitest.configs.recommended,
123
+ }
124
+ ]
125
+ ```
126
+
127
+
128
+ #### All
129
+ If you want to enable all rules instead of only some you can do so by adding the all configuration to your `eslint.config.js` config file:
130
+
131
+ ```js
132
+ import vitest from "@vitest/eslint-plugin";
133
+
134
+ export default [
135
+ {
136
+ files: ["tests/**"], // or any other pattern
137
+ ...vitest.configs.all,
138
+ }
139
+ ]
140
+ ```
141
+
109
142
  ### Rules
110
143
 
111
144
  <!-- begin auto-generated rules list -->
@@ -122,11 +155,11 @@ export default [
122
155
  | :----------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------- | :- | :- | :- | :- | :- |
123
156
  | [consistent-test-filename](docs/rules/consistent-test-filename.md) | require .spec test file pattern | | 🌐 | | | |
124
157
  | [consistent-test-it](docs/rules/consistent-test-it.md) | enforce using test or it but not both | | 🌐 | 🔧 | | |
125
- | [expect-expect](docs/rules/expect-expect.md) | enforce having expectation in test body | ✅ | | | | |
158
+ | [expect-expect](docs/rules/expect-expect.md) | enforce having expectation in test body | ✅ | 🌐 | | | |
126
159
  | [max-expects](docs/rules/max-expects.md) | enforce a maximum number of expect per test | | 🌐 | | | |
127
160
  | [max-nested-describe](docs/rules/max-nested-describe.md) | require describe block to be less than set max value or default value | | 🌐 | | | |
128
161
  | [no-alias-methods](docs/rules/no-alias-methods.md) | disallow alias methods | | 🌐 | 🔧 | | |
129
- | [no-commented-out-tests](docs/rules/no-commented-out-tests.md) | disallow commented out tests | ✅ | | | | |
162
+ | [no-commented-out-tests](docs/rules/no-commented-out-tests.md) | disallow commented out tests | ✅ | 🌐 | | | |
130
163
  | [no-conditional-expect](docs/rules/no-conditional-expect.md) | disallow conditional expects | | 🌐 | | | |
131
164
  | [no-conditional-in-test](docs/rules/no-conditional-in-test.md) | disallow conditional tests | | 🌐 | | | |
132
165
  | [no-conditional-tests](docs/rules/no-conditional-tests.md) | disallow conditional tests | | 🌐 | | | |
@@ -135,8 +168,8 @@ export default [
135
168
  | [no-duplicate-hooks](docs/rules/no-duplicate-hooks.md) | disallow duplicate hooks and teardown hooks | | 🌐 | | | |
136
169
  | [no-focused-tests](docs/rules/no-focused-tests.md) | disallow focused tests | | 🌐 | 🔧 | | |
137
170
  | [no-hooks](docs/rules/no-hooks.md) | disallow setup and teardown hooks | | 🌐 | | | |
138
- | [no-identical-title](docs/rules/no-identical-title.md) | disallow identical titles | ✅ | | 🔧 | | |
139
- | [no-import-node-test](docs/rules/no-import-node-test.md) | disallow importing `node:test` | ✅ | | 🔧 | | |
171
+ | [no-identical-title](docs/rules/no-identical-title.md) | disallow identical titles | ✅ | 🌐 | 🔧 | | |
172
+ | [no-import-node-test](docs/rules/no-import-node-test.md) | disallow importing `node:test` | ✅ | 🌐 | 🔧 | | |
140
173
  | [no-interpolation-in-snapshots](docs/rules/no-interpolation-in-snapshots.md) | disallow string interpolation in snapshots | | 🌐 | 🔧 | | |
141
174
  | [no-large-snapshots](docs/rules/no-large-snapshots.md) | disallow large snapshots | | 🌐 | | | |
142
175
  | [no-mocks-import](docs/rules/no-mocks-import.md) | disallow importing from __mocks__ directory | | 🌐 | | | |
@@ -167,12 +200,12 @@ export default [
167
200
  | [prefer-todo](docs/rules/prefer-todo.md) | enforce using `test.todo` | | 🌐 | 🔧 | | |
168
201
  | [prefer-vi-mocked](docs/rules/prefer-vi-mocked.md) | Prefer `vi.mocked()` over `fn as Mock` | | 🌐 | 🔧 | | |
169
202
  | [require-hook](docs/rules/require-hook.md) | require setup and teardown to be within a hook | | 🌐 | | | |
170
- | [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 | ✅ | | | | |
203
+ | [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 | ✅ | 🌐 | | | |
171
204
  | [require-to-throw-message](docs/rules/require-to-throw-message.md) | require toThrow() to be called with an error message | | 🌐 | | | |
172
205
  | [require-top-level-describe](docs/rules/require-top-level-describe.md) | enforce that all tests are in a top-level describe | | 🌐 | | | |
173
- | [valid-describe-callback](docs/rules/valid-describe-callback.md) | enforce valid describe callback | ✅ | | | | |
174
- | [valid-expect](docs/rules/valid-expect.md) | enforce valid `expect()` usage | ✅ | | 🔧 | | |
175
- | [valid-title](docs/rules/valid-title.md) | enforce valid titles | ✅ | | 🔧 | | |
206
+ | [valid-describe-callback](docs/rules/valid-describe-callback.md) | enforce valid describe callback | ✅ | 🌐 | | | |
207
+ | [valid-expect](docs/rules/valid-expect.md) | enforce valid `expect()` usage | ✅ | 🌐 | 🔧 | | |
208
+ | [valid-title](docs/rules/valid-title.md) | enforce valid titles | ✅ | 🌐 | 🔧 | | |
176
209
 
177
210
  <!-- end auto-generated rules list -->
178
211
 
package/dist/index.cjs CHANGED
@@ -23,7 +23,7 @@ function _interopNamespaceCompat(e) {
23
23
  const path__namespace = /*#__PURE__*/_interopNamespaceCompat(path);
24
24
  const ts__default = /*#__PURE__*/_interopDefaultCompat(ts);
25
25
 
26
- const version = "1.1.10";
26
+ const version = "1.1.12";
27
27
 
28
28
  function createEslintRule(rule) {
29
29
  const createRule = utils.ESLintUtils.RuleCreator(
@@ -105,6 +105,15 @@ var ModifierName = /* @__PURE__ */ ((ModifierName2) => {
105
105
  ModifierName2["not"] = "not";
106
106
  ModifierName2["rejects"] = "rejects";
107
107
  ModifierName2["resolves"] = "resolves";
108
+ ModifierName2["returns"] = "returns";
109
+ ModifierName2["branded"] = "branded";
110
+ ModifierName2["asserts"] = "asserts";
111
+ ModifierName2["constructorParameters"] = "constructorParameters";
112
+ ModifierName2["parameters"] = "parameters";
113
+ ModifierName2["thisParameter"] = "thisParameter";
114
+ ModifierName2["guards"] = "guards";
115
+ ModifierName2["instance"] = "instance";
116
+ ModifierName2["items"] = "items";
108
117
  return ModifierName2;
109
118
  })(ModifierName || {});
110
119
  var EqualityMatcher = /* @__PURE__ */ ((EqualityMatcher2) => {
@@ -2443,6 +2452,7 @@ const validExpect = createEslintRule({
2443
2452
  return {
2444
2453
  CallExpression(node) {
2445
2454
  const vitestFnCall = parseVitestFnCallWithReason(node, context);
2455
+ const settings = parsePluginSettings(context.settings);
2446
2456
  if (typeof vitestFnCall === "string") {
2447
2457
  const reportingNode = node.parent?.type === utils.AST_NODE_TYPES.MemberExpression ? findTopMostMemberExpression(node.parent).property : node;
2448
2458
  if (vitestFnCall === "matcher-not-found") {
@@ -2466,6 +2476,8 @@ const validExpect = createEslintRule({
2466
2476
  return;
2467
2477
  }
2468
2478
  return;
2479
+ } else if (vitestFnCall?.type === "expectTypeOf" && settings.typecheck) {
2480
+ return;
2469
2481
  } else if (vitestFnCall?.type !== "expect") {
2470
2482
  return;
2471
2483
  }
@@ -4830,7 +4842,15 @@ const allRules = {
4830
4842
  [RULE_NAME$4]: "warn",
4831
4843
  [RULE_NAME$3]: "warn",
4832
4844
  [RULE_NAME$2]: "warn",
4833
- [RULE_NAME]: "warn"
4845
+ [RULE_NAME]: "warn",
4846
+ [RULE_NAME$U]: "warn",
4847
+ [RULE_NAME$X]: "warn",
4848
+ [RULE_NAME$M]: "warn",
4849
+ [RULE_NAME$x]: "warn",
4850
+ [RULE_NAME$w]: "warn",
4851
+ [RULE_NAME$i]: "warn",
4852
+ [RULE_NAME$e]: "warn",
4853
+ [RULE_NAME$K]: "warn"
4834
4854
  };
4835
4855
  const recommended = {
4836
4856
  [RULE_NAME$U]: "error",
package/dist/index.d.cts CHANGED
@@ -153,6 +153,14 @@ declare const plugin: {
153
153
  readonly "vitest/padding-around-expect-groups": "warn";
154
154
  readonly "vitest/padding-around-test-blocks": "warn";
155
155
  readonly "vitest/valid-expect-in-promise": "warn";
156
+ readonly "vitest/expect-expect": "warn";
157
+ readonly "vitest/no-identical-title": "warn";
158
+ readonly "vitest/no-commented-out-tests": "warn";
159
+ readonly "vitest/valid-title": "warn";
160
+ readonly "vitest/valid-expect": "warn";
161
+ readonly "vitest/valid-describe-callback": "warn";
162
+ readonly "vitest/require-local-test-context-for-concurrent-snapshots": "warn";
163
+ readonly "vitest/no-import-node-test": "warn";
156
164
  };
157
165
  };
158
166
  env: {
package/dist/index.d.mts CHANGED
@@ -153,6 +153,14 @@ declare const plugin: {
153
153
  readonly "vitest/padding-around-expect-groups": "warn";
154
154
  readonly "vitest/padding-around-test-blocks": "warn";
155
155
  readonly "vitest/valid-expect-in-promise": "warn";
156
+ readonly "vitest/expect-expect": "warn";
157
+ readonly "vitest/no-identical-title": "warn";
158
+ readonly "vitest/no-commented-out-tests": "warn";
159
+ readonly "vitest/valid-title": "warn";
160
+ readonly "vitest/valid-expect": "warn";
161
+ readonly "vitest/valid-describe-callback": "warn";
162
+ readonly "vitest/require-local-test-context-for-concurrent-snapshots": "warn";
163
+ readonly "vitest/no-import-node-test": "warn";
156
164
  };
157
165
  };
158
166
  env: {
package/dist/index.d.ts CHANGED
@@ -153,6 +153,14 @@ declare const plugin: {
153
153
  readonly "vitest/padding-around-expect-groups": "warn";
154
154
  readonly "vitest/padding-around-test-blocks": "warn";
155
155
  readonly "vitest/valid-expect-in-promise": "warn";
156
+ readonly "vitest/expect-expect": "warn";
157
+ readonly "vitest/no-identical-title": "warn";
158
+ readonly "vitest/no-commented-out-tests": "warn";
159
+ readonly "vitest/valid-title": "warn";
160
+ readonly "vitest/valid-expect": "warn";
161
+ readonly "vitest/valid-describe-callback": "warn";
162
+ readonly "vitest/require-local-test-context-for-concurrent-snapshots": "warn";
163
+ readonly "vitest/no-import-node-test": "warn";
156
164
  };
157
165
  };
158
166
  env: {
package/dist/index.mjs CHANGED
@@ -4,7 +4,7 @@ import { isAbsolute, posix } from 'node:path';
4
4
  import ts from 'typescript';
5
5
  import { createRequire } from 'node:module';
6
6
 
7
- const version = "1.1.10";
7
+ const version = "1.1.12";
8
8
 
9
9
  function createEslintRule(rule) {
10
10
  const createRule = ESLintUtils.RuleCreator(
@@ -86,6 +86,15 @@ var ModifierName = /* @__PURE__ */ ((ModifierName2) => {
86
86
  ModifierName2["not"] = "not";
87
87
  ModifierName2["rejects"] = "rejects";
88
88
  ModifierName2["resolves"] = "resolves";
89
+ ModifierName2["returns"] = "returns";
90
+ ModifierName2["branded"] = "branded";
91
+ ModifierName2["asserts"] = "asserts";
92
+ ModifierName2["constructorParameters"] = "constructorParameters";
93
+ ModifierName2["parameters"] = "parameters";
94
+ ModifierName2["thisParameter"] = "thisParameter";
95
+ ModifierName2["guards"] = "guards";
96
+ ModifierName2["instance"] = "instance";
97
+ ModifierName2["items"] = "items";
89
98
  return ModifierName2;
90
99
  })(ModifierName || {});
91
100
  var EqualityMatcher = /* @__PURE__ */ ((EqualityMatcher2) => {
@@ -2424,6 +2433,7 @@ const validExpect = createEslintRule({
2424
2433
  return {
2425
2434
  CallExpression(node) {
2426
2435
  const vitestFnCall = parseVitestFnCallWithReason(node, context);
2436
+ const settings = parsePluginSettings(context.settings);
2427
2437
  if (typeof vitestFnCall === "string") {
2428
2438
  const reportingNode = node.parent?.type === AST_NODE_TYPES.MemberExpression ? findTopMostMemberExpression(node.parent).property : node;
2429
2439
  if (vitestFnCall === "matcher-not-found") {
@@ -2447,6 +2457,8 @@ const validExpect = createEslintRule({
2447
2457
  return;
2448
2458
  }
2449
2459
  return;
2460
+ } else if (vitestFnCall?.type === "expectTypeOf" && settings.typecheck) {
2461
+ return;
2450
2462
  } else if (vitestFnCall?.type !== "expect") {
2451
2463
  return;
2452
2464
  }
@@ -4811,7 +4823,15 @@ const allRules = {
4811
4823
  [RULE_NAME$4]: "warn",
4812
4824
  [RULE_NAME$3]: "warn",
4813
4825
  [RULE_NAME$2]: "warn",
4814
- [RULE_NAME]: "warn"
4826
+ [RULE_NAME]: "warn",
4827
+ [RULE_NAME$U]: "warn",
4828
+ [RULE_NAME$X]: "warn",
4829
+ [RULE_NAME$M]: "warn",
4830
+ [RULE_NAME$x]: "warn",
4831
+ [RULE_NAME$w]: "warn",
4832
+ [RULE_NAME$i]: "warn",
4833
+ [RULE_NAME$e]: "warn",
4834
+ [RULE_NAME$K]: "warn"
4815
4835
  };
4816
4836
  const recommended = {
4817
4837
  [RULE_NAME$U]: "error",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitest/eslint-plugin",
3
- "version": "1.1.11",
3
+ "version": "1.1.13",
4
4
  "license": "MIT",
5
5
  "description": "Eslint plugin for vitest",
6
6
  "repository": "vitest-dev/eslint-plugin-vitest",
@@ -29,24 +29,24 @@
29
29
  "dist"
30
30
  ],
31
31
  "devDependencies": {
32
- "@stylistic/eslint-plugin": "^2.10.1",
32
+ "@stylistic/eslint-plugin": "^2.11.0",
33
33
  "@types/eslint": "^9.6.1",
34
- "@types/mocha": "^10.0.9",
35
- "@types/node": "^20.17.6",
34
+ "@types/mocha": "^10.0.10",
35
+ "@types/node": "^20.17.9",
36
36
  "@typescript-eslint/eslint-plugin": "8.0.0",
37
37
  "@typescript-eslint/parser": "8.0.0",
38
38
  "@typescript-eslint/rule-tester": "8.0.0",
39
- "@vitest/eslint-plugin": "^1.1.8",
39
+ "@vitest/eslint-plugin": "^1.1.12",
40
40
  "bumpp": "^9.8.1",
41
41
  "concurrently": "^8.2.2",
42
- "eslint": "^9.14.0",
42
+ "eslint": "^9.16.0",
43
43
  "eslint-doc-generator": "^1.7.1",
44
- "eslint-plugin-eslint-plugin": "^6.3.1",
44
+ "eslint-plugin-eslint-plugin": "^6.3.2",
45
45
  "eslint-remote-tester": "^4.0.1",
46
46
  "eslint-remote-tester-repositories": "^2.0.0",
47
47
  "importx": "^0.3.11",
48
48
  "tsx": "^4.19.2",
49
- "typescript": "^5.6.3",
49
+ "typescript": "^5.7.2",
50
50
  "unbuild": "^2.0.0",
51
51
  "vitest": "^1.6.0"
52
52
  },