@vitest/eslint-plugin 1.1.21 → 1.1.23
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 +7 -0
- package/dist/index.cjs +37 -35
- package/dist/index.d.cts +3 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +37 -35
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -178,6 +178,13 @@ export default [
|
|
|
178
178
|
| [no-standalone-expect](docs/rules/no-standalone-expect.md) | disallow using `expect` outside of `it` or `test` blocks | | 🌐 | | | |
|
|
179
179
|
| [no-test-prefixes](docs/rules/no-test-prefixes.md) | disallow using `test` as a prefix | | 🌐 | 🔧 | | |
|
|
180
180
|
| [no-test-return-statement](docs/rules/no-test-return-statement.md) | disallow return statements in tests | | 🌐 | | | |
|
|
181
|
+
| [padding-around-after-all-blocks](docs/rules/padding-around-after-all-blocks.md) | enforce padding around `afterAll` blocks | | 🌐 | 🔧 | | |
|
|
182
|
+
| [padding-around-after-each-blocks](docs/rules/padding-around-after-each-blocks.md) | enforce padding around `afterEach` blocks | | 🌐 | 🔧 | | |
|
|
183
|
+
| [padding-around-all](docs/rules/padding-around-all.md) | enforce padding around vitest functions | | 🌐 | 🔧 | | |
|
|
184
|
+
| [padding-around-before-all-blocks](docs/rules/padding-around-before-all-blocks.md) | enforce padding around `beforeAll` blocks | | 🌐 | 🔧 | | |
|
|
185
|
+
| [padding-around-before-each-blocks](docs/rules/padding-around-before-each-blocks.md) | enforce padding around `beforeEach` blocks | | 🌐 | 🔧 | | |
|
|
186
|
+
| [padding-around-describe-blocks](docs/rules/padding-around-describe-blocks.md) | enforce padding around `describe` blocks | | 🌐 | 🔧 | | |
|
|
187
|
+
| [padding-around-expect-groups](docs/rules/padding-around-expect-groups.md) | enforce padding around `expect` groups | | 🌐 | 🔧 | | |
|
|
181
188
|
| [prefer-called-with](docs/rules/prefer-called-with.md) | enforce using `toBeCalledWith()` or `toHaveBeenCalledWith()` | | 🌐 | 🔧 | | |
|
|
182
189
|
| [prefer-comparison-matcher](docs/rules/prefer-comparison-matcher.md) | enforce using the built-in comparison matchers | | 🌐 | 🔧 | | |
|
|
183
190
|
| [prefer-each](docs/rules/prefer-each.md) | enforce using `each` rather than manual loops | | 🌐 | | | |
|
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.
|
|
26
|
+
const version = "1.1.22";
|
|
27
27
|
|
|
28
28
|
function createEslintRule(rule) {
|
|
29
29
|
const createRule = utils.ESLintUtils.RuleCreator(
|
|
@@ -530,7 +530,7 @@ const maxNestedDescribe = createEslintRule({
|
|
|
530
530
|
}
|
|
531
531
|
],
|
|
532
532
|
messages: {
|
|
533
|
-
maxNestedDescribe: "Nested describe block should be less than set max value
|
|
533
|
+
maxNestedDescribe: "Nested describe block should be less than set max value"
|
|
534
534
|
}
|
|
535
535
|
},
|
|
536
536
|
defaultOptions: [
|
|
@@ -660,7 +660,7 @@ const noFocusedTests = createEslintRule({
|
|
|
660
660
|
}
|
|
661
661
|
],
|
|
662
662
|
messages: {
|
|
663
|
-
noFocusedTests: "Focused tests are not allowed
|
|
663
|
+
noFocusedTests: "Focused tests are not allowed"
|
|
664
664
|
}
|
|
665
665
|
},
|
|
666
666
|
defaultOptions: [{ fixable: true }],
|
|
@@ -721,7 +721,7 @@ const noConditionalTest = createEslintRule({
|
|
|
721
721
|
},
|
|
722
722
|
schema: [],
|
|
723
723
|
messages: {
|
|
724
|
-
noConditionalTests: "Avoid using if conditions in a test
|
|
724
|
+
noConditionalTests: "Avoid using if conditions in a test"
|
|
725
725
|
}
|
|
726
726
|
},
|
|
727
727
|
defaultOptions: [],
|
|
@@ -1141,7 +1141,7 @@ const consistentTestFilename = createEslintRule({
|
|
|
1141
1141
|
description: "require .spec test file pattern"
|
|
1142
1142
|
},
|
|
1143
1143
|
messages: {
|
|
1144
|
-
consistentTestFilename: "
|
|
1144
|
+
consistentTestFilename: "Use test file name pattern {{ pattern }}"
|
|
1145
1145
|
},
|
|
1146
1146
|
schema: [
|
|
1147
1147
|
{
|
|
@@ -1197,7 +1197,7 @@ const maxExpect = createEslintRule({
|
|
|
1197
1197
|
description: "enforce a maximum number of expect per test"
|
|
1198
1198
|
},
|
|
1199
1199
|
messages: {
|
|
1200
|
-
maxExpect: "Too many assertion calls ({{count}})
|
|
1200
|
+
maxExpect: "Too many assertion calls ({{ count }}) - maximum allowed is {{ max }}"
|
|
1201
1201
|
},
|
|
1202
1202
|
type: "suggestion",
|
|
1203
1203
|
schema: [
|
|
@@ -1310,7 +1310,7 @@ const noCommentedOutTests = createEslintRule({
|
|
|
1310
1310
|
recommended: false
|
|
1311
1311
|
},
|
|
1312
1312
|
messages: {
|
|
1313
|
-
noCommentedOutTests: "Remove commented out tests
|
|
1313
|
+
noCommentedOutTests: "Remove commented out tests - you may want to use `skip` or `only` instead"
|
|
1314
1314
|
},
|
|
1315
1315
|
schema: [],
|
|
1316
1316
|
type: "suggestion"
|
|
@@ -1479,8 +1479,8 @@ const noDisabledTests = createEslintRule({
|
|
|
1479
1479
|
pending: "Call to pending()",
|
|
1480
1480
|
pendingSuite: "Call to pending() within test suite",
|
|
1481
1481
|
pendingTest: "Call to pending() within test",
|
|
1482
|
-
disabledSuite: "Disabled test suite
|
|
1483
|
-
disabledTest: "Disabled test
|
|
1482
|
+
disabledSuite: "Disabled test suite - if you want to skip a test suite temporarily, use .todo() instead",
|
|
1483
|
+
disabledTest: "Disabled test - if you want to skip a test temporarily, use .todo() instead"
|
|
1484
1484
|
},
|
|
1485
1485
|
schema: []
|
|
1486
1486
|
},
|
|
@@ -1654,7 +1654,7 @@ const noDuplicateHooks = createEslintRule({
|
|
|
1654
1654
|
requiresTypeChecking: false
|
|
1655
1655
|
},
|
|
1656
1656
|
messages: {
|
|
1657
|
-
noDuplicateHooks: "Duplicate {{hook}} in describe block
|
|
1657
|
+
noDuplicateHooks: "Duplicate {{ hook }} in describe block"
|
|
1658
1658
|
},
|
|
1659
1659
|
schema: [],
|
|
1660
1660
|
type: "suggestion"
|
|
@@ -1832,7 +1832,7 @@ const noMocksImport = createEslintRule({
|
|
|
1832
1832
|
recommended: false
|
|
1833
1833
|
},
|
|
1834
1834
|
messages: {
|
|
1835
|
-
noMocksImport: `Mocks should not be manually imported from a ${mocksDirName} directory. Instead use \`vi.mock\` and import from the original module path
|
|
1835
|
+
noMocksImport: `Mocks should not be manually imported from a ${mocksDirName} directory. Instead use \`vi.mock\` and import from the original module path`
|
|
1836
1836
|
},
|
|
1837
1837
|
schema: []
|
|
1838
1838
|
},
|
|
@@ -1934,15 +1934,14 @@ const noStandaloneExpect = createEslintRule({
|
|
|
1934
1934
|
},
|
|
1935
1935
|
schema: [
|
|
1936
1936
|
{
|
|
1937
|
+
type: "object",
|
|
1937
1938
|
properties: {
|
|
1938
|
-
|
|
1939
|
-
// @ts-ignore
|
|
1939
|
+
additionalTestBlockFunctions: {
|
|
1940
1940
|
type: "array",
|
|
1941
|
-
|
|
1942
|
-
items: { type: `string` }
|
|
1941
|
+
items: { type: "string" }
|
|
1943
1942
|
}
|
|
1944
1943
|
},
|
|
1945
|
-
|
|
1944
|
+
additionalProperties: false
|
|
1946
1945
|
}
|
|
1947
1946
|
]
|
|
1948
1947
|
},
|
|
@@ -2005,7 +2004,7 @@ const noTestPrefixes = createEslintRule({
|
|
|
2005
2004
|
},
|
|
2006
2005
|
type: "suggestion",
|
|
2007
2006
|
messages: {
|
|
2008
|
-
usePreferredName: 'Use "{{preferredNodeName}}" instead'
|
|
2007
|
+
usePreferredName: 'Use "{{ preferredNodeName }}" instead'
|
|
2009
2008
|
},
|
|
2010
2009
|
fixable: "code",
|
|
2011
2010
|
schema: []
|
|
@@ -2176,14 +2175,14 @@ const validTitle = createEslintRule({
|
|
|
2176
2175
|
},
|
|
2177
2176
|
messages: {
|
|
2178
2177
|
titleMustBeString: "Test title must be a string, a function or class name",
|
|
2179
|
-
emptyTitle: "{{functionName}} should not have an empty title",
|
|
2178
|
+
emptyTitle: "{{ functionName }} should not have an empty title",
|
|
2180
2179
|
duplicatePrefix: "should not have duplicate prefix",
|
|
2181
2180
|
accidentalSpace: "should not have leading or trailing spaces",
|
|
2182
|
-
disallowedWord: '"{{word}}" is not allowed in test title',
|
|
2183
|
-
mustNotMatch: "{{functionName}} should not match {{pattern}}",
|
|
2184
|
-
mustMatch: "{{functionName}} should match {{pattern}}",
|
|
2185
|
-
mustNotMatchCustom: "{{message}}",
|
|
2186
|
-
mustMatchCustom: "{{message}}"
|
|
2181
|
+
disallowedWord: '"{{ word }}" is not allowed in test title',
|
|
2182
|
+
mustNotMatch: "{{ functionName }} should not match {{ pattern }}",
|
|
2183
|
+
mustMatch: "{{ functionName }} should match {{ pattern }}",
|
|
2184
|
+
mustNotMatchCustom: "{{ message }}",
|
|
2185
|
+
mustMatchCustom: "{{ message }}"
|
|
2187
2186
|
},
|
|
2188
2187
|
type: "suggestion",
|
|
2189
2188
|
schema: [
|
|
@@ -2242,7 +2241,9 @@ const validTitle = createEslintRule({
|
|
|
2242
2241
|
CallExpression(node) {
|
|
2243
2242
|
const vitestFnCall = parseVitestFnCall(node, context);
|
|
2244
2243
|
if (vitestFnCall?.type !== "describe" && vitestFnCall?.type !== "test" && vitestFnCall?.type !== "it") return;
|
|
2245
|
-
if (vitestFnCall.members.
|
|
2244
|
+
if (vitestFnCall.members && vitestFnCall.members[0] && vitestFnCall.members[0].type === utils.AST_NODE_TYPES.Identifier && vitestFnCall.members[0].name === "extend") {
|
|
2245
|
+
return;
|
|
2246
|
+
}
|
|
2246
2247
|
const [argument] = node.arguments;
|
|
2247
2248
|
if (settings.typecheck) {
|
|
2248
2249
|
const services = utils.ESLintUtils.getParserServices(context);
|
|
@@ -2395,13 +2396,13 @@ const validExpect = createEslintRule({
|
|
|
2395
2396
|
recommended: false
|
|
2396
2397
|
},
|
|
2397
2398
|
messages: {
|
|
2398
|
-
tooManyArgs: "Expect takes most {{ amount}} argument{{s}}",
|
|
2399
|
-
notEnoughArgs: "Expect requires
|
|
2400
|
-
modifierUnknown: "Expect has unknown modifier",
|
|
2401
|
-
matcherNotFound: "Expect must have a corresponding matcher call
|
|
2402
|
-
matcherNotCalled: "Matchers must be called to assert
|
|
2403
|
-
asyncMustBeAwaited: "Async assertions must be awaited{{orReturned}}",
|
|
2404
|
-
promisesWithAsyncAssertionsMustBeAwaited: "Promises which return async assertions must be awaited{{orReturned}}"
|
|
2399
|
+
tooManyArgs: "Expect takes at most {{ amount}} argument{{ s }}",
|
|
2400
|
+
notEnoughArgs: "Expect requires at least {{ amount }} argument{{ s }}",
|
|
2401
|
+
modifierUnknown: "Expect has an unknown modifier",
|
|
2402
|
+
matcherNotFound: "Expect must have a corresponding matcher call",
|
|
2403
|
+
matcherNotCalled: "Matchers must be called to assert",
|
|
2404
|
+
asyncMustBeAwaited: "Async assertions must be awaited{{ orReturned }}",
|
|
2405
|
+
promisesWithAsyncAssertionsMustBeAwaited: "Promises which return async assertions must be awaited{{ orReturned }}"
|
|
2405
2406
|
},
|
|
2406
2407
|
type: "suggestion",
|
|
2407
2408
|
fixable: "code",
|
|
@@ -2608,7 +2609,7 @@ const preferToBeObject = createEslintRule({
|
|
|
2608
2609
|
},
|
|
2609
2610
|
fixable: "code",
|
|
2610
2611
|
messages: {
|
|
2611
|
-
preferToBeObject: "Prefer toBeObject() to test if a value is an object
|
|
2612
|
+
preferToBeObject: "Prefer toBeObject() to test if a value is an object"
|
|
2612
2613
|
},
|
|
2613
2614
|
schema: []
|
|
2614
2615
|
},
|
|
@@ -3472,8 +3473,8 @@ const requireTopLevelDescribe = createEslintRule({
|
|
|
3472
3473
|
},
|
|
3473
3474
|
messages: {
|
|
3474
3475
|
tooManyDescribes: "There should not be more than {{ max }} describe{{ s }} at the top level",
|
|
3475
|
-
unexpectedTestCase: "All test cases must be wrapped in a describe block
|
|
3476
|
-
unexpectedHook: "All hooks must be wrapped in a describe block
|
|
3476
|
+
unexpectedTestCase: "All test cases must be wrapped in a describe block",
|
|
3477
|
+
unexpectedHook: "All hooks must be wrapped in a describe block"
|
|
3477
3478
|
},
|
|
3478
3479
|
type: "suggestion",
|
|
3479
3480
|
schema: [
|
|
@@ -4520,7 +4521,7 @@ const config = [
|
|
|
4520
4521
|
];
|
|
4521
4522
|
const paddingAroundTestBlocks = createPaddingRule(
|
|
4522
4523
|
RULE_NAME$2,
|
|
4523
|
-
"Enforce padding around
|
|
4524
|
+
"Enforce padding around `test` blocks",
|
|
4524
4525
|
config
|
|
4525
4526
|
);
|
|
4526
4527
|
|
|
@@ -4883,6 +4884,7 @@ const plugin = {
|
|
|
4883
4884
|
name: "vitest",
|
|
4884
4885
|
version
|
|
4885
4886
|
},
|
|
4887
|
+
configs: {},
|
|
4886
4888
|
rules: {
|
|
4887
4889
|
[RULE_NAME$Z]: lowerCaseTitle,
|
|
4888
4890
|
[RULE_NAME$Y]: maxNestedDescribe,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Linter, RuleModule } from '@typescript-eslint/utils/ts-eslint';
|
|
2
2
|
|
|
3
|
-
interface
|
|
3
|
+
interface VitestPlugin extends Linter.Plugin {
|
|
4
4
|
meta: {
|
|
5
5
|
name: string;
|
|
6
6
|
version: string;
|
|
7
7
|
};
|
|
8
8
|
rules: Record<string, RuleModule<any, any>>;
|
|
9
|
-
configs
|
|
9
|
+
configs: Record<string, any>;
|
|
10
10
|
environments?: Record<string, any>;
|
|
11
11
|
}
|
|
12
|
-
declare const plugin:
|
|
12
|
+
declare const plugin: VitestPlugin;
|
|
13
13
|
|
|
14
14
|
export { plugin as default };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Linter, RuleModule } from '@typescript-eslint/utils/ts-eslint';
|
|
2
2
|
|
|
3
|
-
interface
|
|
3
|
+
interface VitestPlugin extends Linter.Plugin {
|
|
4
4
|
meta: {
|
|
5
5
|
name: string;
|
|
6
6
|
version: string;
|
|
7
7
|
};
|
|
8
8
|
rules: Record<string, RuleModule<any, any>>;
|
|
9
|
-
configs
|
|
9
|
+
configs: Record<string, any>;
|
|
10
10
|
environments?: Record<string, any>;
|
|
11
11
|
}
|
|
12
|
-
declare const plugin:
|
|
12
|
+
declare const plugin: VitestPlugin;
|
|
13
13
|
|
|
14
14
|
export { plugin as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Linter, RuleModule } from '@typescript-eslint/utils/ts-eslint';
|
|
2
2
|
|
|
3
|
-
interface
|
|
3
|
+
interface VitestPlugin extends Linter.Plugin {
|
|
4
4
|
meta: {
|
|
5
5
|
name: string;
|
|
6
6
|
version: string;
|
|
7
7
|
};
|
|
8
8
|
rules: Record<string, RuleModule<any, any>>;
|
|
9
|
-
configs
|
|
9
|
+
configs: Record<string, any>;
|
|
10
10
|
environments?: Record<string, any>;
|
|
11
11
|
}
|
|
12
|
-
declare const plugin:
|
|
12
|
+
declare const plugin: VitestPlugin;
|
|
13
13
|
|
|
14
14
|
export { plugin as default };
|
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.
|
|
7
|
+
const version = "1.1.22";
|
|
8
8
|
|
|
9
9
|
function createEslintRule(rule) {
|
|
10
10
|
const createRule = ESLintUtils.RuleCreator(
|
|
@@ -511,7 +511,7 @@ const maxNestedDescribe = createEslintRule({
|
|
|
511
511
|
}
|
|
512
512
|
],
|
|
513
513
|
messages: {
|
|
514
|
-
maxNestedDescribe: "Nested describe block should be less than set max value
|
|
514
|
+
maxNestedDescribe: "Nested describe block should be less than set max value"
|
|
515
515
|
}
|
|
516
516
|
},
|
|
517
517
|
defaultOptions: [
|
|
@@ -641,7 +641,7 @@ const noFocusedTests = createEslintRule({
|
|
|
641
641
|
}
|
|
642
642
|
],
|
|
643
643
|
messages: {
|
|
644
|
-
noFocusedTests: "Focused tests are not allowed
|
|
644
|
+
noFocusedTests: "Focused tests are not allowed"
|
|
645
645
|
}
|
|
646
646
|
},
|
|
647
647
|
defaultOptions: [{ fixable: true }],
|
|
@@ -702,7 +702,7 @@ const noConditionalTest = createEslintRule({
|
|
|
702
702
|
},
|
|
703
703
|
schema: [],
|
|
704
704
|
messages: {
|
|
705
|
-
noConditionalTests: "Avoid using if conditions in a test
|
|
705
|
+
noConditionalTests: "Avoid using if conditions in a test"
|
|
706
706
|
}
|
|
707
707
|
},
|
|
708
708
|
defaultOptions: [],
|
|
@@ -1122,7 +1122,7 @@ const consistentTestFilename = createEslintRule({
|
|
|
1122
1122
|
description: "require .spec test file pattern"
|
|
1123
1123
|
},
|
|
1124
1124
|
messages: {
|
|
1125
|
-
consistentTestFilename: "
|
|
1125
|
+
consistentTestFilename: "Use test file name pattern {{ pattern }}"
|
|
1126
1126
|
},
|
|
1127
1127
|
schema: [
|
|
1128
1128
|
{
|
|
@@ -1178,7 +1178,7 @@ const maxExpect = createEslintRule({
|
|
|
1178
1178
|
description: "enforce a maximum number of expect per test"
|
|
1179
1179
|
},
|
|
1180
1180
|
messages: {
|
|
1181
|
-
maxExpect: "Too many assertion calls ({{count}})
|
|
1181
|
+
maxExpect: "Too many assertion calls ({{ count }}) - maximum allowed is {{ max }}"
|
|
1182
1182
|
},
|
|
1183
1183
|
type: "suggestion",
|
|
1184
1184
|
schema: [
|
|
@@ -1291,7 +1291,7 @@ const noCommentedOutTests = createEslintRule({
|
|
|
1291
1291
|
recommended: false
|
|
1292
1292
|
},
|
|
1293
1293
|
messages: {
|
|
1294
|
-
noCommentedOutTests: "Remove commented out tests
|
|
1294
|
+
noCommentedOutTests: "Remove commented out tests - you may want to use `skip` or `only` instead"
|
|
1295
1295
|
},
|
|
1296
1296
|
schema: [],
|
|
1297
1297
|
type: "suggestion"
|
|
@@ -1460,8 +1460,8 @@ const noDisabledTests = createEslintRule({
|
|
|
1460
1460
|
pending: "Call to pending()",
|
|
1461
1461
|
pendingSuite: "Call to pending() within test suite",
|
|
1462
1462
|
pendingTest: "Call to pending() within test",
|
|
1463
|
-
disabledSuite: "Disabled test suite
|
|
1464
|
-
disabledTest: "Disabled test
|
|
1463
|
+
disabledSuite: "Disabled test suite - if you want to skip a test suite temporarily, use .todo() instead",
|
|
1464
|
+
disabledTest: "Disabled test - if you want to skip a test temporarily, use .todo() instead"
|
|
1465
1465
|
},
|
|
1466
1466
|
schema: []
|
|
1467
1467
|
},
|
|
@@ -1635,7 +1635,7 @@ const noDuplicateHooks = createEslintRule({
|
|
|
1635
1635
|
requiresTypeChecking: false
|
|
1636
1636
|
},
|
|
1637
1637
|
messages: {
|
|
1638
|
-
noDuplicateHooks: "Duplicate {{hook}} in describe block
|
|
1638
|
+
noDuplicateHooks: "Duplicate {{ hook }} in describe block"
|
|
1639
1639
|
},
|
|
1640
1640
|
schema: [],
|
|
1641
1641
|
type: "suggestion"
|
|
@@ -1813,7 +1813,7 @@ const noMocksImport = createEslintRule({
|
|
|
1813
1813
|
recommended: false
|
|
1814
1814
|
},
|
|
1815
1815
|
messages: {
|
|
1816
|
-
noMocksImport: `Mocks should not be manually imported from a ${mocksDirName} directory. Instead use \`vi.mock\` and import from the original module path
|
|
1816
|
+
noMocksImport: `Mocks should not be manually imported from a ${mocksDirName} directory. Instead use \`vi.mock\` and import from the original module path`
|
|
1817
1817
|
},
|
|
1818
1818
|
schema: []
|
|
1819
1819
|
},
|
|
@@ -1915,15 +1915,14 @@ const noStandaloneExpect = createEslintRule({
|
|
|
1915
1915
|
},
|
|
1916
1916
|
schema: [
|
|
1917
1917
|
{
|
|
1918
|
+
type: "object",
|
|
1918
1919
|
properties: {
|
|
1919
|
-
|
|
1920
|
-
// @ts-ignore
|
|
1920
|
+
additionalTestBlockFunctions: {
|
|
1921
1921
|
type: "array",
|
|
1922
|
-
|
|
1923
|
-
items: { type: `string` }
|
|
1922
|
+
items: { type: "string" }
|
|
1924
1923
|
}
|
|
1925
1924
|
},
|
|
1926
|
-
|
|
1925
|
+
additionalProperties: false
|
|
1927
1926
|
}
|
|
1928
1927
|
]
|
|
1929
1928
|
},
|
|
@@ -1986,7 +1985,7 @@ const noTestPrefixes = createEslintRule({
|
|
|
1986
1985
|
},
|
|
1987
1986
|
type: "suggestion",
|
|
1988
1987
|
messages: {
|
|
1989
|
-
usePreferredName: 'Use "{{preferredNodeName}}" instead'
|
|
1988
|
+
usePreferredName: 'Use "{{ preferredNodeName }}" instead'
|
|
1990
1989
|
},
|
|
1991
1990
|
fixable: "code",
|
|
1992
1991
|
schema: []
|
|
@@ -2157,14 +2156,14 @@ const validTitle = createEslintRule({
|
|
|
2157
2156
|
},
|
|
2158
2157
|
messages: {
|
|
2159
2158
|
titleMustBeString: "Test title must be a string, a function or class name",
|
|
2160
|
-
emptyTitle: "{{functionName}} should not have an empty title",
|
|
2159
|
+
emptyTitle: "{{ functionName }} should not have an empty title",
|
|
2161
2160
|
duplicatePrefix: "should not have duplicate prefix",
|
|
2162
2161
|
accidentalSpace: "should not have leading or trailing spaces",
|
|
2163
|
-
disallowedWord: '"{{word}}" is not allowed in test title',
|
|
2164
|
-
mustNotMatch: "{{functionName}} should not match {{pattern}}",
|
|
2165
|
-
mustMatch: "{{functionName}} should match {{pattern}}",
|
|
2166
|
-
mustNotMatchCustom: "{{message}}",
|
|
2167
|
-
mustMatchCustom: "{{message}}"
|
|
2162
|
+
disallowedWord: '"{{ word }}" is not allowed in test title',
|
|
2163
|
+
mustNotMatch: "{{ functionName }} should not match {{ pattern }}",
|
|
2164
|
+
mustMatch: "{{ functionName }} should match {{ pattern }}",
|
|
2165
|
+
mustNotMatchCustom: "{{ message }}",
|
|
2166
|
+
mustMatchCustom: "{{ message }}"
|
|
2168
2167
|
},
|
|
2169
2168
|
type: "suggestion",
|
|
2170
2169
|
schema: [
|
|
@@ -2223,7 +2222,9 @@ const validTitle = createEslintRule({
|
|
|
2223
2222
|
CallExpression(node) {
|
|
2224
2223
|
const vitestFnCall = parseVitestFnCall(node, context);
|
|
2225
2224
|
if (vitestFnCall?.type !== "describe" && vitestFnCall?.type !== "test" && vitestFnCall?.type !== "it") return;
|
|
2226
|
-
if (vitestFnCall.members.
|
|
2225
|
+
if (vitestFnCall.members && vitestFnCall.members[0] && vitestFnCall.members[0].type === AST_NODE_TYPES.Identifier && vitestFnCall.members[0].name === "extend") {
|
|
2226
|
+
return;
|
|
2227
|
+
}
|
|
2227
2228
|
const [argument] = node.arguments;
|
|
2228
2229
|
if (settings.typecheck) {
|
|
2229
2230
|
const services = ESLintUtils.getParserServices(context);
|
|
@@ -2376,13 +2377,13 @@ const validExpect = createEslintRule({
|
|
|
2376
2377
|
recommended: false
|
|
2377
2378
|
},
|
|
2378
2379
|
messages: {
|
|
2379
|
-
tooManyArgs: "Expect takes most {{ amount}} argument{{s}}",
|
|
2380
|
-
notEnoughArgs: "Expect requires
|
|
2381
|
-
modifierUnknown: "Expect has unknown modifier",
|
|
2382
|
-
matcherNotFound: "Expect must have a corresponding matcher call
|
|
2383
|
-
matcherNotCalled: "Matchers must be called to assert
|
|
2384
|
-
asyncMustBeAwaited: "Async assertions must be awaited{{orReturned}}",
|
|
2385
|
-
promisesWithAsyncAssertionsMustBeAwaited: "Promises which return async assertions must be awaited{{orReturned}}"
|
|
2380
|
+
tooManyArgs: "Expect takes at most {{ amount}} argument{{ s }}",
|
|
2381
|
+
notEnoughArgs: "Expect requires at least {{ amount }} argument{{ s }}",
|
|
2382
|
+
modifierUnknown: "Expect has an unknown modifier",
|
|
2383
|
+
matcherNotFound: "Expect must have a corresponding matcher call",
|
|
2384
|
+
matcherNotCalled: "Matchers must be called to assert",
|
|
2385
|
+
asyncMustBeAwaited: "Async assertions must be awaited{{ orReturned }}",
|
|
2386
|
+
promisesWithAsyncAssertionsMustBeAwaited: "Promises which return async assertions must be awaited{{ orReturned }}"
|
|
2386
2387
|
},
|
|
2387
2388
|
type: "suggestion",
|
|
2388
2389
|
fixable: "code",
|
|
@@ -2589,7 +2590,7 @@ const preferToBeObject = createEslintRule({
|
|
|
2589
2590
|
},
|
|
2590
2591
|
fixable: "code",
|
|
2591
2592
|
messages: {
|
|
2592
|
-
preferToBeObject: "Prefer toBeObject() to test if a value is an object
|
|
2593
|
+
preferToBeObject: "Prefer toBeObject() to test if a value is an object"
|
|
2593
2594
|
},
|
|
2594
2595
|
schema: []
|
|
2595
2596
|
},
|
|
@@ -3453,8 +3454,8 @@ const requireTopLevelDescribe = createEslintRule({
|
|
|
3453
3454
|
},
|
|
3454
3455
|
messages: {
|
|
3455
3456
|
tooManyDescribes: "There should not be more than {{ max }} describe{{ s }} at the top level",
|
|
3456
|
-
unexpectedTestCase: "All test cases must be wrapped in a describe block
|
|
3457
|
-
unexpectedHook: "All hooks must be wrapped in a describe block
|
|
3457
|
+
unexpectedTestCase: "All test cases must be wrapped in a describe block",
|
|
3458
|
+
unexpectedHook: "All hooks must be wrapped in a describe block"
|
|
3458
3459
|
},
|
|
3459
3460
|
type: "suggestion",
|
|
3460
3461
|
schema: [
|
|
@@ -4501,7 +4502,7 @@ const config = [
|
|
|
4501
4502
|
];
|
|
4502
4503
|
const paddingAroundTestBlocks = createPaddingRule(
|
|
4503
4504
|
RULE_NAME$2,
|
|
4504
|
-
"Enforce padding around
|
|
4505
|
+
"Enforce padding around `test` blocks",
|
|
4505
4506
|
config
|
|
4506
4507
|
);
|
|
4507
4508
|
|
|
@@ -4864,6 +4865,7 @@ const plugin = {
|
|
|
4864
4865
|
name: "vitest",
|
|
4865
4866
|
version
|
|
4866
4867
|
},
|
|
4868
|
+
configs: {},
|
|
4867
4869
|
rules: {
|
|
4868
4870
|
[RULE_NAME$Z]: lowerCaseTitle,
|
|
4869
4871
|
[RULE_NAME$Y]: maxNestedDescribe,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitest/eslint-plugin",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.23",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Eslint plugin for vitest",
|
|
6
6
|
"repository": "vitest-dev/eslint-plugin-vitest",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@types/node": "^22.10.2",
|
|
36
36
|
"@typescript-eslint/eslint-plugin": "8.18.2",
|
|
37
37
|
"@typescript-eslint/parser": "8.18.2",
|
|
38
|
-
"@typescript-eslint/rule-tester": "8.18.
|
|
38
|
+
"@typescript-eslint/rule-tester": "8.18.2",
|
|
39
39
|
"@vitest/eslint-plugin": "^1.1.20",
|
|
40
40
|
"bumpp": "^9.9.2",
|
|
41
41
|
"concurrently": "^9.1.1",
|