@vitest/eslint-plugin 1.5.1 → 1.5.4
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 +1 -0
- package/dist/index.cjs +205 -157
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +205 -157
- package/package.json +1 -1
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.5.
|
|
7
|
+
var version = "1.5.4";
|
|
8
8
|
|
|
9
9
|
//#endregion
|
|
10
10
|
//#region src/utils/index.ts
|
|
@@ -1778,7 +1778,7 @@ const followTypeAssertionChain$1 = (expression) => isTypeCastExpression$1(expres
|
|
|
1778
1778
|
|
|
1779
1779
|
//#endregion
|
|
1780
1780
|
//#region src/rules/consistent-each-for.ts
|
|
1781
|
-
const RULE_NAME$
|
|
1781
|
+
const RULE_NAME$77 = "consistent-each-for";
|
|
1782
1782
|
const BASE_FN_NAMES = [
|
|
1783
1783
|
"test",
|
|
1784
1784
|
"it",
|
|
@@ -1786,7 +1786,7 @@ const BASE_FN_NAMES = [
|
|
|
1786
1786
|
"suite"
|
|
1787
1787
|
];
|
|
1788
1788
|
var consistent_each_for_default = createEslintRule({
|
|
1789
|
-
name: RULE_NAME$
|
|
1789
|
+
name: RULE_NAME$77,
|
|
1790
1790
|
meta: {
|
|
1791
1791
|
type: "suggestion",
|
|
1792
1792
|
docs: {
|
|
@@ -1846,11 +1846,11 @@ var consistent_each_for_default = createEslintRule({
|
|
|
1846
1846
|
|
|
1847
1847
|
//#endregion
|
|
1848
1848
|
//#region src/rules/consistent-test-filename.ts
|
|
1849
|
-
const RULE_NAME$
|
|
1849
|
+
const RULE_NAME$76 = "consistent-test-filename";
|
|
1850
1850
|
const defaultPattern = /.*\.test\.[tj]sx?$/;
|
|
1851
1851
|
const defaultTestsPattern = /.*\.(test|spec)\.[tj]sx?$/;
|
|
1852
1852
|
var consistent_test_filename_default = createEslintRule({
|
|
1853
|
-
name: RULE_NAME$
|
|
1853
|
+
name: RULE_NAME$76,
|
|
1854
1854
|
meta: {
|
|
1855
1855
|
type: "problem",
|
|
1856
1856
|
docs: {
|
|
@@ -1898,7 +1898,7 @@ var consistent_test_filename_default = createEslintRule({
|
|
|
1898
1898
|
|
|
1899
1899
|
//#endregion
|
|
1900
1900
|
//#region src/rules/consistent-test-it.ts
|
|
1901
|
-
const RULE_NAME$
|
|
1901
|
+
const RULE_NAME$75 = "consistent-test-it";
|
|
1902
1902
|
const buildFixer = (callee, nodeName, preferredTestKeyword) => (fixer) => [fixer.replaceText(callee.type === AST_NODE_TYPES.MemberExpression ? callee.object : callee, getPreferredNodeName(nodeName, preferredTestKeyword))];
|
|
1903
1903
|
function getPreferredNodeName(nodeName, preferredTestKeyword) {
|
|
1904
1904
|
if (nodeName === TestCaseName.fit) return "test.only";
|
|
@@ -1909,7 +1909,7 @@ function getOppositeTestKeyword(test) {
|
|
|
1909
1909
|
return TestCaseName.test;
|
|
1910
1910
|
}
|
|
1911
1911
|
var consistent_test_it_default = createEslintRule({
|
|
1912
|
-
name: RULE_NAME$
|
|
1912
|
+
name: RULE_NAME$75,
|
|
1913
1913
|
meta: {
|
|
1914
1914
|
type: "suggestion",
|
|
1915
1915
|
fixable: "code",
|
|
@@ -2018,10 +2018,10 @@ var consistent_test_it_default = createEslintRule({
|
|
|
2018
2018
|
|
|
2019
2019
|
//#endregion
|
|
2020
2020
|
//#region src/rules/consistent-vitest-vi.ts
|
|
2021
|
-
const RULE_NAME$
|
|
2021
|
+
const RULE_NAME$74 = "consistent-vitest-vi";
|
|
2022
2022
|
const getOppositeVitestUtilKeyword = (util) => util === UtilName.vi ? UtilName.vitest : UtilName.vi;
|
|
2023
2023
|
var consistent_vitest_vi_default = createEslintRule({
|
|
2024
|
-
name: RULE_NAME$
|
|
2024
|
+
name: RULE_NAME$74,
|
|
2025
2025
|
meta: {
|
|
2026
2026
|
type: "suggestion",
|
|
2027
2027
|
fixable: "code",
|
|
@@ -2101,9 +2101,9 @@ function parsePluginSettings(settings) {
|
|
|
2101
2101
|
|
|
2102
2102
|
//#endregion
|
|
2103
2103
|
//#region src/rules/expect-expect.ts
|
|
2104
|
-
const RULE_NAME$
|
|
2104
|
+
const RULE_NAME$73 = "expect-expect";
|
|
2105
2105
|
var expect_expect_default = createEslintRule({
|
|
2106
|
-
name: RULE_NAME$
|
|
2106
|
+
name: RULE_NAME$73,
|
|
2107
2107
|
meta: {
|
|
2108
2108
|
type: "suggestion",
|
|
2109
2109
|
docs: {
|
|
@@ -2179,14 +2179,14 @@ function buildPatternRegexp(pattern) {
|
|
|
2179
2179
|
|
|
2180
2180
|
//#endregion
|
|
2181
2181
|
//#region src/rules/hoisted-apis-on-top.ts
|
|
2182
|
-
const RULE_NAME$
|
|
2182
|
+
const RULE_NAME$72 = "hoisted-apis-on-top";
|
|
2183
2183
|
const hoistedAPIs = [
|
|
2184
2184
|
"mock",
|
|
2185
2185
|
"hoisted",
|
|
2186
2186
|
"unmock"
|
|
2187
2187
|
];
|
|
2188
2188
|
var hoisted_apis_on_top_default = createEslintRule({
|
|
2189
|
-
name: RULE_NAME$
|
|
2189
|
+
name: RULE_NAME$72,
|
|
2190
2190
|
meta: {
|
|
2191
2191
|
hasSuggestions: true,
|
|
2192
2192
|
type: "suggestion",
|
|
@@ -2253,9 +2253,9 @@ var hoisted_apis_on_top_default = createEslintRule({
|
|
|
2253
2253
|
|
|
2254
2254
|
//#endregion
|
|
2255
2255
|
//#region src/rules/max-expects.ts
|
|
2256
|
-
const RULE_NAME$
|
|
2256
|
+
const RULE_NAME$71 = "max-expects";
|
|
2257
2257
|
var max_expects_default = createEslintRule({
|
|
2258
|
-
name: RULE_NAME$
|
|
2258
|
+
name: RULE_NAME$71,
|
|
2259
2259
|
meta: {
|
|
2260
2260
|
docs: {
|
|
2261
2261
|
requiresTypeChecking: false,
|
|
@@ -2300,9 +2300,9 @@ var max_expects_default = createEslintRule({
|
|
|
2300
2300
|
|
|
2301
2301
|
//#endregion
|
|
2302
2302
|
//#region src/rules/max-nested-describe.ts
|
|
2303
|
-
const RULE_NAME$
|
|
2303
|
+
const RULE_NAME$70 = "max-nested-describe";
|
|
2304
2304
|
var max_nested_describe_default = createEslintRule({
|
|
2305
|
-
name: RULE_NAME$
|
|
2305
|
+
name: RULE_NAME$70,
|
|
2306
2306
|
meta: {
|
|
2307
2307
|
type: "problem",
|
|
2308
2308
|
docs: {
|
|
@@ -2344,9 +2344,9 @@ var max_nested_describe_default = createEslintRule({
|
|
|
2344
2344
|
|
|
2345
2345
|
//#endregion
|
|
2346
2346
|
//#region src/rules/no-alias-methods.ts
|
|
2347
|
-
const RULE_NAME$
|
|
2347
|
+
const RULE_NAME$69 = "no-alias-methods";
|
|
2348
2348
|
var no_alias_methods_default = createEslintRule({
|
|
2349
|
-
name: RULE_NAME$
|
|
2349
|
+
name: RULE_NAME$69,
|
|
2350
2350
|
meta: {
|
|
2351
2351
|
docs: {
|
|
2352
2352
|
description: "disallow alias methods",
|
|
@@ -2396,12 +2396,12 @@ var no_alias_methods_default = createEslintRule({
|
|
|
2396
2396
|
|
|
2397
2397
|
//#endregion
|
|
2398
2398
|
//#region src/rules/no-commented-out-tests.ts
|
|
2399
|
-
const RULE_NAME$
|
|
2399
|
+
const RULE_NAME$68 = "no-commented-out-tests";
|
|
2400
2400
|
function hasTests(node) {
|
|
2401
2401
|
return /^\s*[xf]?(test|it|describe)(\.\w+|\[['"]\w+['"]\])?\s*\(/mu.test(node.value);
|
|
2402
2402
|
}
|
|
2403
2403
|
var no_commented_out_tests_default = createEslintRule({
|
|
2404
|
-
name: RULE_NAME$
|
|
2404
|
+
name: RULE_NAME$68,
|
|
2405
2405
|
meta: {
|
|
2406
2406
|
docs: {
|
|
2407
2407
|
description: "disallow commented out tests",
|
|
@@ -2430,10 +2430,10 @@ var no_commented_out_tests_default = createEslintRule({
|
|
|
2430
2430
|
|
|
2431
2431
|
//#endregion
|
|
2432
2432
|
//#region src/rules/no-conditional-expect.ts
|
|
2433
|
-
const RULE_NAME$
|
|
2433
|
+
const RULE_NAME$67 = "no-conditional-expect";
|
|
2434
2434
|
const isCatchCall = (node) => node.callee.type === AST_NODE_TYPES.MemberExpression && isSupportedAccessor(node.callee.property, "catch");
|
|
2435
2435
|
var no_conditional_expect_default = createEslintRule({
|
|
2436
|
-
name: RULE_NAME$
|
|
2436
|
+
name: RULE_NAME$67,
|
|
2437
2437
|
meta: {
|
|
2438
2438
|
type: "problem",
|
|
2439
2439
|
docs: {
|
|
@@ -2488,9 +2488,9 @@ var no_conditional_expect_default = createEslintRule({
|
|
|
2488
2488
|
|
|
2489
2489
|
//#endregion
|
|
2490
2490
|
//#region src/rules/no-conditional-in-test.ts
|
|
2491
|
-
const RULE_NAME$
|
|
2491
|
+
const RULE_NAME$66 = "no-conditional-in-test";
|
|
2492
2492
|
var no_conditional_in_test_default = createEslintRule({
|
|
2493
|
-
name: RULE_NAME$
|
|
2493
|
+
name: RULE_NAME$66,
|
|
2494
2494
|
meta: {
|
|
2495
2495
|
docs: {
|
|
2496
2496
|
description: "disallow conditional tests",
|
|
@@ -2514,9 +2514,9 @@ var no_conditional_in_test_default = createEslintRule({
|
|
|
2514
2514
|
|
|
2515
2515
|
//#endregion
|
|
2516
2516
|
//#region src/rules/no-conditional-tests.ts
|
|
2517
|
-
const RULE_NAME$
|
|
2517
|
+
const RULE_NAME$65 = "no-conditional-tests";
|
|
2518
2518
|
var no_conditional_tests_default = createEslintRule({
|
|
2519
|
-
name: RULE_NAME$
|
|
2519
|
+
name: RULE_NAME$65,
|
|
2520
2520
|
meta: {
|
|
2521
2521
|
type: "problem",
|
|
2522
2522
|
docs: {
|
|
@@ -2545,9 +2545,9 @@ var no_conditional_tests_default = createEslintRule({
|
|
|
2545
2545
|
|
|
2546
2546
|
//#endregion
|
|
2547
2547
|
//#region src/rules/no-disabled-tests.ts
|
|
2548
|
-
const RULE_NAME$
|
|
2548
|
+
const RULE_NAME$64 = "no-disabled-tests";
|
|
2549
2549
|
var no_disabled_tests_default = createEslintRule({
|
|
2550
|
-
name: RULE_NAME$
|
|
2550
|
+
name: RULE_NAME$64,
|
|
2551
2551
|
meta: {
|
|
2552
2552
|
type: "suggestion",
|
|
2553
2553
|
docs: {
|
|
@@ -2613,7 +2613,7 @@ var no_disabled_tests_default = createEslintRule({
|
|
|
2613
2613
|
|
|
2614
2614
|
//#endregion
|
|
2615
2615
|
//#region src/rules/no-done-callback.ts
|
|
2616
|
-
const RULE_NAME$
|
|
2616
|
+
const RULE_NAME$63 = "no-done-callback";
|
|
2617
2617
|
const findCallbackArg = (node, isVitestEach, context) => {
|
|
2618
2618
|
if (isVitestEach) return node.arguments[1];
|
|
2619
2619
|
const vitestFnCall = parseVitestFnCall(node, context);
|
|
@@ -2622,7 +2622,7 @@ const findCallbackArg = (node, isVitestEach, context) => {
|
|
|
2622
2622
|
return null;
|
|
2623
2623
|
};
|
|
2624
2624
|
var no_done_callback_default = createEslintRule({
|
|
2625
|
-
name: RULE_NAME$
|
|
2625
|
+
name: RULE_NAME$63,
|
|
2626
2626
|
meta: {
|
|
2627
2627
|
type: "suggestion",
|
|
2628
2628
|
docs: {
|
|
@@ -2707,9 +2707,9 @@ var no_done_callback_default = createEslintRule({
|
|
|
2707
2707
|
|
|
2708
2708
|
//#endregion
|
|
2709
2709
|
//#region src/rules/no-duplicate-hooks.ts
|
|
2710
|
-
const RULE_NAME$
|
|
2710
|
+
const RULE_NAME$62 = "no-duplicate-hooks";
|
|
2711
2711
|
var no_duplicate_hooks_default = createEslintRule({
|
|
2712
|
-
name: RULE_NAME$
|
|
2712
|
+
name: RULE_NAME$62,
|
|
2713
2713
|
meta: {
|
|
2714
2714
|
docs: {
|
|
2715
2715
|
recommended: false,
|
|
@@ -2746,7 +2746,7 @@ var no_duplicate_hooks_default = createEslintRule({
|
|
|
2746
2746
|
|
|
2747
2747
|
//#endregion
|
|
2748
2748
|
//#region src/rules/no-focused-tests.ts
|
|
2749
|
-
const RULE_NAME$
|
|
2749
|
+
const RULE_NAME$61 = "no-focused-tests";
|
|
2750
2750
|
const isTestOrDescribe = (node) => {
|
|
2751
2751
|
return node.type === "Identifier" && [
|
|
2752
2752
|
"it",
|
|
@@ -2758,7 +2758,7 @@ const isOnly = (node) => {
|
|
|
2758
2758
|
return node.type === "Identifier" && node.name === "only";
|
|
2759
2759
|
};
|
|
2760
2760
|
var no_focused_tests_default = createEslintRule({
|
|
2761
|
-
name: RULE_NAME$
|
|
2761
|
+
name: RULE_NAME$61,
|
|
2762
2762
|
meta: {
|
|
2763
2763
|
type: "problem",
|
|
2764
2764
|
docs: {
|
|
@@ -2818,9 +2818,9 @@ var no_focused_tests_default = createEslintRule({
|
|
|
2818
2818
|
|
|
2819
2819
|
//#endregion
|
|
2820
2820
|
//#region src/rules/no-hooks.ts
|
|
2821
|
-
const RULE_NAME$
|
|
2821
|
+
const RULE_NAME$60 = "no-hooks";
|
|
2822
2822
|
var no_hooks_default = createEslintRule({
|
|
2823
|
-
name: RULE_NAME$
|
|
2823
|
+
name: RULE_NAME$60,
|
|
2824
2824
|
meta: {
|
|
2825
2825
|
type: "suggestion",
|
|
2826
2826
|
docs: {
|
|
@@ -2863,13 +2863,13 @@ var no_hooks_default = createEslintRule({
|
|
|
2863
2863
|
|
|
2864
2864
|
//#endregion
|
|
2865
2865
|
//#region src/rules/no-identical-title.ts
|
|
2866
|
-
const RULE_NAME$
|
|
2866
|
+
const RULE_NAME$59 = "no-identical-title";
|
|
2867
2867
|
const newDescribeContext = () => ({
|
|
2868
2868
|
describeTitles: [],
|
|
2869
2869
|
testTitles: []
|
|
2870
2870
|
});
|
|
2871
2871
|
var no_identical_title_default = createEslintRule({
|
|
2872
|
-
name: RULE_NAME$
|
|
2872
|
+
name: RULE_NAME$59,
|
|
2873
2873
|
meta: {
|
|
2874
2874
|
type: "problem",
|
|
2875
2875
|
docs: {
|
|
@@ -2919,9 +2919,9 @@ var no_identical_title_default = createEslintRule({
|
|
|
2919
2919
|
|
|
2920
2920
|
//#endregion
|
|
2921
2921
|
//#region src/rules/no-import-node-test.ts
|
|
2922
|
-
const RULE_NAME$
|
|
2922
|
+
const RULE_NAME$58 = "no-import-node-test";
|
|
2923
2923
|
var no_import_node_test_default = createEslintRule({
|
|
2924
|
-
name: RULE_NAME$
|
|
2924
|
+
name: RULE_NAME$58,
|
|
2925
2925
|
meta: {
|
|
2926
2926
|
docs: {
|
|
2927
2927
|
description: "disallow importing `node:test`",
|
|
@@ -3018,9 +3018,9 @@ const removeNodeFromArray = (fixer, nodes, target) => {
|
|
|
3018
3018
|
|
|
3019
3019
|
//#endregion
|
|
3020
3020
|
//#region src/rules/no-importing-vitest-globals.ts
|
|
3021
|
-
const RULE_NAME$
|
|
3021
|
+
const RULE_NAME$57 = "no-importing-vitest-globals";
|
|
3022
3022
|
var no_importing_vitest_globals_default = createEslintRule({
|
|
3023
|
-
name: RULE_NAME$
|
|
3023
|
+
name: RULE_NAME$57,
|
|
3024
3024
|
meta: {
|
|
3025
3025
|
type: "suggestion",
|
|
3026
3026
|
docs: {
|
|
@@ -3076,9 +3076,9 @@ var no_importing_vitest_globals_default = createEslintRule({
|
|
|
3076
3076
|
|
|
3077
3077
|
//#endregion
|
|
3078
3078
|
//#region src/rules/no-interpolation-in-snapshots.ts
|
|
3079
|
-
const RULE_NAME$
|
|
3079
|
+
const RULE_NAME$56 = "no-interpolation-in-snapshots";
|
|
3080
3080
|
var no_interpolation_in_snapshots_default = createEslintRule({
|
|
3081
|
-
name: RULE_NAME$
|
|
3081
|
+
name: RULE_NAME$56,
|
|
3082
3082
|
meta: {
|
|
3083
3083
|
type: "problem",
|
|
3084
3084
|
docs: {
|
|
@@ -3106,7 +3106,7 @@ var no_interpolation_in_snapshots_default = createEslintRule({
|
|
|
3106
3106
|
|
|
3107
3107
|
//#endregion
|
|
3108
3108
|
//#region src/rules/no-large-snapshots.ts
|
|
3109
|
-
const RULE_NAME$
|
|
3109
|
+
const RULE_NAME$55 = "no-large-snapshots";
|
|
3110
3110
|
const reportOnViolation = (context, node, { maxSize: lineLimit = 50, allowedSnapshots = {} }) => {
|
|
3111
3111
|
const startLine = node.loc.start.line;
|
|
3112
3112
|
const lineCount = node.loc.end.line - startLine;
|
|
@@ -3132,7 +3132,7 @@ const reportOnViolation = (context, node, { maxSize: lineLimit = 50, allowedSnap
|
|
|
3132
3132
|
});
|
|
3133
3133
|
};
|
|
3134
3134
|
var no_large_snapshots_default = createEslintRule({
|
|
3135
|
-
name: RULE_NAME$
|
|
3135
|
+
name: RULE_NAME$55,
|
|
3136
3136
|
meta: {
|
|
3137
3137
|
docs: {
|
|
3138
3138
|
description: "disallow large snapshots",
|
|
@@ -3177,9 +3177,9 @@ var no_large_snapshots_default = createEslintRule({
|
|
|
3177
3177
|
const mocksDirName = "__mocks__";
|
|
3178
3178
|
const isMockPath = (path) => path.split(posix.sep).includes(mocksDirName);
|
|
3179
3179
|
const isMockImportLiteral = (expression) => isStringNode(expression) && isMockPath(getStringValue(expression));
|
|
3180
|
-
const RULE_NAME$
|
|
3180
|
+
const RULE_NAME$54 = "no-mocks-import";
|
|
3181
3181
|
var no_mocks_import_default = createEslintRule({
|
|
3182
|
-
name: RULE_NAME$
|
|
3182
|
+
name: RULE_NAME$54,
|
|
3183
3183
|
meta: {
|
|
3184
3184
|
type: "problem",
|
|
3185
3185
|
docs: {
|
|
@@ -3211,13 +3211,13 @@ var no_mocks_import_default = createEslintRule({
|
|
|
3211
3211
|
|
|
3212
3212
|
//#endregion
|
|
3213
3213
|
//#region src/rules/no-restricted-matchers.ts
|
|
3214
|
-
const RULE_NAME$
|
|
3214
|
+
const RULE_NAME$53 = "no-restricted-matchers";
|
|
3215
3215
|
const isChainRestricted = (chain, restriction) => {
|
|
3216
3216
|
if (Object.prototype.hasOwnProperty.call(ModifierName, restriction) || restriction.endsWith(".not")) return chain.startsWith(restriction);
|
|
3217
3217
|
return chain === restriction;
|
|
3218
3218
|
};
|
|
3219
3219
|
var no_restricted_matchers_default = createEslintRule({
|
|
3220
|
-
name: RULE_NAME$
|
|
3220
|
+
name: RULE_NAME$53,
|
|
3221
3221
|
meta: {
|
|
3222
3222
|
docs: {
|
|
3223
3223
|
description: "disallow the use of certain matchers",
|
|
@@ -3259,9 +3259,9 @@ var no_restricted_matchers_default = createEslintRule({
|
|
|
3259
3259
|
|
|
3260
3260
|
//#endregion
|
|
3261
3261
|
//#region src/rules/no-restricted-vi-methods.ts
|
|
3262
|
-
const RULE_NAME$
|
|
3262
|
+
const RULE_NAME$52 = "no-restricted-vi-methods";
|
|
3263
3263
|
var no_restricted_vi_methods_default = createEslintRule({
|
|
3264
|
-
name: RULE_NAME$
|
|
3264
|
+
name: RULE_NAME$52,
|
|
3265
3265
|
meta: {
|
|
3266
3266
|
type: "suggestion",
|
|
3267
3267
|
docs: {
|
|
@@ -3303,7 +3303,7 @@ var no_restricted_vi_methods_default = createEslintRule({
|
|
|
3303
3303
|
|
|
3304
3304
|
//#endregion
|
|
3305
3305
|
//#region src/rules/no-standalone-expect.ts
|
|
3306
|
-
const RULE_NAME$
|
|
3306
|
+
const RULE_NAME$51 = "no-standalone-expect";
|
|
3307
3307
|
const getBlockType = (statement, context) => {
|
|
3308
3308
|
const func = statement.parent;
|
|
3309
3309
|
if (!func) throw new Error("Unexpected block statement. If you feel like this is a bug report https://github.com/veritem/eslint-plugin-vitest/issues/new");
|
|
@@ -3316,7 +3316,7 @@ const getBlockType = (statement, context) => {
|
|
|
3316
3316
|
return null;
|
|
3317
3317
|
};
|
|
3318
3318
|
var no_standalone_expect_default = createEslintRule({
|
|
3319
|
-
name: RULE_NAME$
|
|
3319
|
+
name: RULE_NAME$51,
|
|
3320
3320
|
meta: {
|
|
3321
3321
|
docs: {
|
|
3322
3322
|
description: "disallow using `expect` outside of `it` or `test` blocks",
|
|
@@ -3375,9 +3375,9 @@ var no_standalone_expect_default = createEslintRule({
|
|
|
3375
3375
|
|
|
3376
3376
|
//#endregion
|
|
3377
3377
|
//#region src/rules/no-test-prefixes.ts
|
|
3378
|
-
const RULE_NAME$
|
|
3378
|
+
const RULE_NAME$50 = "no-test-prefixes";
|
|
3379
3379
|
var no_test_prefixes_default = createEslintRule({
|
|
3380
|
-
name: RULE_NAME$
|
|
3380
|
+
name: RULE_NAME$50,
|
|
3381
3381
|
meta: {
|
|
3382
3382
|
docs: {
|
|
3383
3383
|
description: "disallow using the `f` and `x` prefixes in favour of `.only` and `.skip`",
|
|
@@ -3412,14 +3412,14 @@ var no_test_prefixes_default = createEslintRule({
|
|
|
3412
3412
|
|
|
3413
3413
|
//#endregion
|
|
3414
3414
|
//#region src/rules/no-test-return-statement.ts
|
|
3415
|
-
const RULE_NAME$
|
|
3415
|
+
const RULE_NAME$49 = "no-test-return-statement";
|
|
3416
3416
|
const getBody = (args) => {
|
|
3417
3417
|
const [, secondArg] = args;
|
|
3418
3418
|
if (secondArg && isFunction(secondArg) && secondArg.body.type === AST_NODE_TYPES.BlockStatement) return secondArg.body.body;
|
|
3419
3419
|
return [];
|
|
3420
3420
|
};
|
|
3421
3421
|
var no_test_return_statement_default = createEslintRule({
|
|
3422
|
-
name: RULE_NAME$
|
|
3422
|
+
name: RULE_NAME$49,
|
|
3423
3423
|
meta: {
|
|
3424
3424
|
type: "problem",
|
|
3425
3425
|
docs: {
|
|
@@ -3690,7 +3690,7 @@ const createPaddingRule = (name, description, configs, deprecated = false) => {
|
|
|
3690
3690
|
|
|
3691
3691
|
//#endregion
|
|
3692
3692
|
//#region src/rules/padding-around-after-all-blocks.ts
|
|
3693
|
-
const RULE_NAME$
|
|
3693
|
+
const RULE_NAME$48 = "padding-around-after-all-blocks";
|
|
3694
3694
|
const config = [{
|
|
3695
3695
|
paddingType: PaddingType.Always,
|
|
3696
3696
|
prevStatementType: StatementType.Any,
|
|
@@ -3700,11 +3700,11 @@ const config = [{
|
|
|
3700
3700
|
prevStatementType: StatementType.AfterAllToken,
|
|
3701
3701
|
nextStatementType: StatementType.Any
|
|
3702
3702
|
}];
|
|
3703
|
-
var padding_around_after_all_blocks_default = createPaddingRule(RULE_NAME$
|
|
3703
|
+
var padding_around_after_all_blocks_default = createPaddingRule(RULE_NAME$48, "Enforce padding around `afterAll` blocks", config);
|
|
3704
3704
|
|
|
3705
3705
|
//#endregion
|
|
3706
3706
|
//#region src/rules/padding-around-after-each-blocks.ts
|
|
3707
|
-
const RULE_NAME$
|
|
3707
|
+
const RULE_NAME$47 = "padding-around-after-each-blocks";
|
|
3708
3708
|
const config$1 = [{
|
|
3709
3709
|
paddingType: PaddingType.Always,
|
|
3710
3710
|
prevStatementType: StatementType.Any,
|
|
@@ -3714,11 +3714,11 @@ const config$1 = [{
|
|
|
3714
3714
|
prevStatementType: StatementType.AfterEachToken,
|
|
3715
3715
|
nextStatementType: StatementType.Any
|
|
3716
3716
|
}];
|
|
3717
|
-
var padding_around_after_each_blocks_default = createPaddingRule(RULE_NAME$
|
|
3717
|
+
var padding_around_after_each_blocks_default = createPaddingRule(RULE_NAME$47, "Enforce padding around `afterEach` blocks", config$1);
|
|
3718
3718
|
|
|
3719
3719
|
//#endregion
|
|
3720
3720
|
//#region src/rules/padding-around-before-all-blocks.ts
|
|
3721
|
-
const RULE_NAME$
|
|
3721
|
+
const RULE_NAME$46 = "padding-around-before-all-blocks";
|
|
3722
3722
|
const config$2 = [{
|
|
3723
3723
|
paddingType: PaddingType.Always,
|
|
3724
3724
|
prevStatementType: StatementType.Any,
|
|
@@ -3728,11 +3728,11 @@ const config$2 = [{
|
|
|
3728
3728
|
prevStatementType: StatementType.BeforeAllToken,
|
|
3729
3729
|
nextStatementType: StatementType.Any
|
|
3730
3730
|
}];
|
|
3731
|
-
var padding_around_before_all_blocks_default = createPaddingRule(RULE_NAME$
|
|
3731
|
+
var padding_around_before_all_blocks_default = createPaddingRule(RULE_NAME$46, "Enforce padding around `beforeAll` blocks", config$2);
|
|
3732
3732
|
|
|
3733
3733
|
//#endregion
|
|
3734
3734
|
//#region src/rules/padding-around-before-each-blocks.ts
|
|
3735
|
-
const RULE_NAME$
|
|
3735
|
+
const RULE_NAME$45 = "padding-around-before-each-blocks";
|
|
3736
3736
|
const config$3 = [{
|
|
3737
3737
|
paddingType: PaddingType.Always,
|
|
3738
3738
|
prevStatementType: StatementType.Any,
|
|
@@ -3742,11 +3742,11 @@ const config$3 = [{
|
|
|
3742
3742
|
prevStatementType: StatementType.BeforeEachToken,
|
|
3743
3743
|
nextStatementType: StatementType.Any
|
|
3744
3744
|
}];
|
|
3745
|
-
var padding_around_before_each_blocks_default = createPaddingRule(RULE_NAME$
|
|
3745
|
+
var padding_around_before_each_blocks_default = createPaddingRule(RULE_NAME$45, "Enforce padding around `beforeEach` blocks", config$3);
|
|
3746
3746
|
|
|
3747
3747
|
//#endregion
|
|
3748
3748
|
//#region src/rules/padding-around-describe-blocks.ts
|
|
3749
|
-
const RULE_NAME$
|
|
3749
|
+
const RULE_NAME$44 = "padding-around-describe-blocks";
|
|
3750
3750
|
const config$4 = [{
|
|
3751
3751
|
paddingType: PaddingType.Always,
|
|
3752
3752
|
prevStatementType: StatementType.Any,
|
|
@@ -3764,11 +3764,11 @@ const config$4 = [{
|
|
|
3764
3764
|
],
|
|
3765
3765
|
nextStatementType: StatementType.Any
|
|
3766
3766
|
}];
|
|
3767
|
-
var padding_around_describe_blocks_default = createPaddingRule(RULE_NAME$
|
|
3767
|
+
var padding_around_describe_blocks_default = createPaddingRule(RULE_NAME$44, "Enforce padding around `describe` blocks", config$4);
|
|
3768
3768
|
|
|
3769
3769
|
//#endregion
|
|
3770
3770
|
//#region src/rules/padding-around-expect-groups.ts
|
|
3771
|
-
const RULE_NAME$
|
|
3771
|
+
const RULE_NAME$43 = "padding-around-expect-groups";
|
|
3772
3772
|
const config$5 = [
|
|
3773
3773
|
{
|
|
3774
3774
|
paddingType: PaddingType.Always,
|
|
@@ -3801,11 +3801,11 @@ const config$5 = [
|
|
|
3801
3801
|
nextStatementType: StatementType.ExpectTypeOfToken
|
|
3802
3802
|
}
|
|
3803
3803
|
];
|
|
3804
|
-
var padding_around_expect_groups_default = createPaddingRule(RULE_NAME$
|
|
3804
|
+
var padding_around_expect_groups_default = createPaddingRule(RULE_NAME$43, "Enforce padding around `expect` groups", config$5);
|
|
3805
3805
|
|
|
3806
3806
|
//#endregion
|
|
3807
3807
|
//#region src/rules/padding-around-test-blocks.ts
|
|
3808
|
-
const RULE_NAME$
|
|
3808
|
+
const RULE_NAME$42 = "padding-around-test-blocks";
|
|
3809
3809
|
const config$6 = [{
|
|
3810
3810
|
paddingType: PaddingType.Always,
|
|
3811
3811
|
prevStatementType: StatementType.Any,
|
|
@@ -3827,12 +3827,12 @@ const config$6 = [{
|
|
|
3827
3827
|
],
|
|
3828
3828
|
nextStatementType: StatementType.Any
|
|
3829
3829
|
}];
|
|
3830
|
-
var padding_around_test_blocks_default = createPaddingRule(RULE_NAME$
|
|
3830
|
+
var padding_around_test_blocks_default = createPaddingRule(RULE_NAME$42, "Enforce padding around `test` blocks", config$6);
|
|
3831
3831
|
|
|
3832
3832
|
//#endregion
|
|
3833
3833
|
//#region src/rules/padding-around-all.ts
|
|
3834
|
-
const RULE_NAME$
|
|
3835
|
-
var padding_around_all_default = createPaddingRule(RULE_NAME$
|
|
3834
|
+
const RULE_NAME$41 = "padding-around-all";
|
|
3835
|
+
var padding_around_all_default = createPaddingRule(RULE_NAME$41, "Enforce padding around vitest functions", [
|
|
3836
3836
|
...config,
|
|
3837
3837
|
...config$1,
|
|
3838
3838
|
...config$2,
|
|
@@ -3844,7 +3844,7 @@ var padding_around_all_default = createPaddingRule(RULE_NAME$40, "Enforce paddin
|
|
|
3844
3844
|
|
|
3845
3845
|
//#endregion
|
|
3846
3846
|
//#region src/rules/prefer-called-exactly-once-with.ts
|
|
3847
|
-
const RULE_NAME$
|
|
3847
|
+
const RULE_NAME$40 = "prefer-called-exactly-once-with";
|
|
3848
3848
|
const MATCHERS_TO_COMBINE = ["toHaveBeenCalledOnce", "toHaveBeenCalledWith"];
|
|
3849
3849
|
const MOCK_CALL_RESET_METHODS = [
|
|
3850
3850
|
"mockClear",
|
|
@@ -3903,7 +3903,7 @@ const hasMockResetBetween = (body, firstCallExpression, secondCallExpression) =>
|
|
|
3903
3903
|
};
|
|
3904
3904
|
const getMemberProperty = (expression) => expression.callee.type === AST_NODE_TYPES.MemberExpression ? expression.callee.property : null;
|
|
3905
3905
|
var prefer_called_exactly_once_with_default = createEslintRule({
|
|
3906
|
-
name: RULE_NAME$
|
|
3906
|
+
name: RULE_NAME$40,
|
|
3907
3907
|
meta: {
|
|
3908
3908
|
docs: { description: "Prefer `toHaveBeenCalledExactlyOnceWith` over `toHaveBeenCalledOnce` and `toHaveBeenCalledWith`" },
|
|
3909
3909
|
messages: { preferCalledExactlyOnceWith: "Using `toHaveBeenCalledOnce` and `toHaveBeenCalledWith` on the same target; prefer `toHaveBeenCalledExactlyOnceWith` instead." },
|
|
@@ -3971,10 +3971,10 @@ var prefer_called_exactly_once_with_default = createEslintRule({
|
|
|
3971
3971
|
|
|
3972
3972
|
//#endregion
|
|
3973
3973
|
//#region src/rules/prefer-called-once.ts
|
|
3974
|
-
const RULE_NAME$
|
|
3974
|
+
const RULE_NAME$39 = "prefer-called-once";
|
|
3975
3975
|
const isOneLiteral = (node) => node.type === AST_NODE_TYPES.Literal && node.value === 1;
|
|
3976
3976
|
var prefer_called_once_default = createEslintRule({
|
|
3977
|
-
name: RULE_NAME$
|
|
3977
|
+
name: RULE_NAME$39,
|
|
3978
3978
|
meta: {
|
|
3979
3979
|
docs: {
|
|
3980
3980
|
description: "enforce using `toBeCalledOnce()` or `toHaveBeenCalledOnce()`",
|
|
@@ -4007,9 +4007,9 @@ var prefer_called_once_default = createEslintRule({
|
|
|
4007
4007
|
|
|
4008
4008
|
//#endregion
|
|
4009
4009
|
//#region src/rules/prefer-called-times.ts
|
|
4010
|
-
const RULE_NAME$
|
|
4010
|
+
const RULE_NAME$38 = "prefer-called-times";
|
|
4011
4011
|
var prefer_called_times_default = createEslintRule({
|
|
4012
|
-
name: RULE_NAME$
|
|
4012
|
+
name: RULE_NAME$38,
|
|
4013
4013
|
meta: {
|
|
4014
4014
|
docs: {
|
|
4015
4015
|
description: "enforce using `toBeCalledTimes(1)` or `toHaveBeenCalledTimes(1)`",
|
|
@@ -4042,9 +4042,9 @@ var prefer_called_times_default = createEslintRule({
|
|
|
4042
4042
|
|
|
4043
4043
|
//#endregion
|
|
4044
4044
|
//#region src/rules/prefer-called-with.ts
|
|
4045
|
-
const RULE_NAME$
|
|
4045
|
+
const RULE_NAME$37 = "prefer-called-with";
|
|
4046
4046
|
var prefer_called_with_default = createEslintRule({
|
|
4047
|
-
name: RULE_NAME$
|
|
4047
|
+
name: RULE_NAME$37,
|
|
4048
4048
|
meta: {
|
|
4049
4049
|
docs: {
|
|
4050
4050
|
description: "enforce using `toBeCalledWith()` or `toHaveBeenCalledWith()`",
|
|
@@ -4092,7 +4092,7 @@ const hasOnlyOneArgument = (call) => call.arguments.length === 1;
|
|
|
4092
4092
|
|
|
4093
4093
|
//#endregion
|
|
4094
4094
|
//#region src/rules/prefer-comparison-matcher.ts
|
|
4095
|
-
const RULE_NAME$
|
|
4095
|
+
const RULE_NAME$36 = "prefer-comparison-matcher";
|
|
4096
4096
|
const isString = (node) => {
|
|
4097
4097
|
return isStringNode(node) || node?.type === AST_NODE_TYPES.TemplateLiteral;
|
|
4098
4098
|
};
|
|
@@ -4118,7 +4118,7 @@ const determineMatcher = (operator, negated) => {
|
|
|
4118
4118
|
return null;
|
|
4119
4119
|
};
|
|
4120
4120
|
var prefer_comparison_matcher_default = createEslintRule({
|
|
4121
|
-
name: RULE_NAME$
|
|
4121
|
+
name: RULE_NAME$36,
|
|
4122
4122
|
meta: {
|
|
4123
4123
|
type: "suggestion",
|
|
4124
4124
|
docs: {
|
|
@@ -4164,9 +4164,9 @@ var prefer_comparison_matcher_default = createEslintRule({
|
|
|
4164
4164
|
|
|
4165
4165
|
//#endregion
|
|
4166
4166
|
//#region src/rules/prefer-describe-function-title.ts
|
|
4167
|
-
const RULE_NAME$
|
|
4167
|
+
const RULE_NAME$35 = "prefer-describe-function-title";
|
|
4168
4168
|
var prefer_describe_function_title_default = createEslintRule({
|
|
4169
|
-
name: RULE_NAME$
|
|
4169
|
+
name: RULE_NAME$35,
|
|
4170
4170
|
meta: {
|
|
4171
4171
|
type: "problem",
|
|
4172
4172
|
docs: {
|
|
@@ -4216,9 +4216,9 @@ var prefer_describe_function_title_default = createEslintRule({
|
|
|
4216
4216
|
|
|
4217
4217
|
//#endregion
|
|
4218
4218
|
//#region src/rules/prefer-each.ts
|
|
4219
|
-
const RULE_NAME$
|
|
4219
|
+
const RULE_NAME$34 = "prefer-each";
|
|
4220
4220
|
var prefer_each_default = createEslintRule({
|
|
4221
|
-
name: RULE_NAME$
|
|
4221
|
+
name: RULE_NAME$34,
|
|
4222
4222
|
meta: {
|
|
4223
4223
|
type: "suggestion",
|
|
4224
4224
|
docs: {
|
|
@@ -4271,9 +4271,9 @@ var prefer_each_default = createEslintRule({
|
|
|
4271
4271
|
|
|
4272
4272
|
//#endregion
|
|
4273
4273
|
//#region src/rules/prefer-equality-matcher.ts
|
|
4274
|
-
const RULE_NAME$
|
|
4274
|
+
const RULE_NAME$33 = "prefer-equality-matcher";
|
|
4275
4275
|
var prefer_equality_matcher_default = createEslintRule({
|
|
4276
|
-
name: RULE_NAME$
|
|
4276
|
+
name: RULE_NAME$33,
|
|
4277
4277
|
meta: {
|
|
4278
4278
|
type: "suggestion",
|
|
4279
4279
|
docs: {
|
|
@@ -4491,9 +4491,9 @@ var prefer_expect_assertions_default = createEslintRule({
|
|
|
4491
4491
|
|
|
4492
4492
|
//#endregion
|
|
4493
4493
|
//#region src/rules/prefer-expect-resolves.ts
|
|
4494
|
-
const RULE_NAME$
|
|
4494
|
+
const RULE_NAME$32 = "prefer-expect-resolves";
|
|
4495
4495
|
var prefer_expect_resolves_default = createEslintRule({
|
|
4496
|
-
name: RULE_NAME$
|
|
4496
|
+
name: RULE_NAME$32,
|
|
4497
4497
|
meta: {
|
|
4498
4498
|
type: "suggestion",
|
|
4499
4499
|
docs: {
|
|
@@ -4527,7 +4527,7 @@ var prefer_expect_resolves_default = createEslintRule({
|
|
|
4527
4527
|
|
|
4528
4528
|
//#endregion
|
|
4529
4529
|
//#region src/rules/prefer-expect-type-of.ts
|
|
4530
|
-
const RULE_NAME$
|
|
4530
|
+
const RULE_NAME$31 = "prefer-expect-type-of";
|
|
4531
4531
|
const typeMatchers = {
|
|
4532
4532
|
string: "toBeString",
|
|
4533
4533
|
number: "toBeNumber",
|
|
@@ -4539,7 +4539,7 @@ const typeMatchers = {
|
|
|
4539
4539
|
undefined: "toBeUndefined"
|
|
4540
4540
|
};
|
|
4541
4541
|
var prefer_expect_type_of_default = createEslintRule({
|
|
4542
|
-
name: RULE_NAME$
|
|
4542
|
+
name: RULE_NAME$31,
|
|
4543
4543
|
meta: {
|
|
4544
4544
|
type: "suggestion",
|
|
4545
4545
|
docs: {
|
|
@@ -4588,7 +4588,7 @@ var prefer_expect_type_of_default = createEslintRule({
|
|
|
4588
4588
|
|
|
4589
4589
|
//#endregion
|
|
4590
4590
|
//#region src/rules/prefer-hooks-in-order.ts
|
|
4591
|
-
const RULE_NAME$
|
|
4591
|
+
const RULE_NAME$30 = "prefer-hooks-in-order";
|
|
4592
4592
|
const HooksOrder = [
|
|
4593
4593
|
"beforeAll",
|
|
4594
4594
|
"beforeEach",
|
|
@@ -4596,7 +4596,7 @@ const HooksOrder = [
|
|
|
4596
4596
|
"afterAll"
|
|
4597
4597
|
];
|
|
4598
4598
|
var prefer_hooks_in_order_default = createEslintRule({
|
|
4599
|
-
name: RULE_NAME$
|
|
4599
|
+
name: RULE_NAME$30,
|
|
4600
4600
|
meta: {
|
|
4601
4601
|
type: "suggestion",
|
|
4602
4602
|
docs: {
|
|
@@ -4649,9 +4649,9 @@ var prefer_hooks_in_order_default = createEslintRule({
|
|
|
4649
4649
|
|
|
4650
4650
|
//#endregion
|
|
4651
4651
|
//#region src/rules/prefer-hooks-on-top.ts
|
|
4652
|
-
const RULE_NAME$
|
|
4652
|
+
const RULE_NAME$29 = "prefer-hooks-on-top";
|
|
4653
4653
|
var prefer_hooks_on_top_default = createEslintRule({
|
|
4654
|
-
name: RULE_NAME$
|
|
4654
|
+
name: RULE_NAME$29,
|
|
4655
4655
|
meta: {
|
|
4656
4656
|
type: "suggestion",
|
|
4657
4657
|
docs: {
|
|
@@ -4666,7 +4666,9 @@ var prefer_hooks_on_top_default = createEslintRule({
|
|
|
4666
4666
|
const hooksContext = [false];
|
|
4667
4667
|
return {
|
|
4668
4668
|
CallExpression(node) {
|
|
4669
|
-
|
|
4669
|
+
const vitestFnCall = parseVitestFnCall(node, context);
|
|
4670
|
+
const hasExemptModifier = vitestFnCall?.members?.some((member) => ["extend", "scoped"].includes(getAccessorValue(member)));
|
|
4671
|
+
if (vitestFnCall?.type && ["test", "it"].includes(vitestFnCall.type) && !hasExemptModifier) hooksContext[hooksContext.length - 1] = true;
|
|
4670
4672
|
if (hooksContext[hooksContext.length - 1] && isTypeOfVitestFnCall(node, context, ["hook"])) context.report({
|
|
4671
4673
|
messageId: "noHookOnTop",
|
|
4672
4674
|
node
|
|
@@ -4682,9 +4684,9 @@ var prefer_hooks_on_top_default = createEslintRule({
|
|
|
4682
4684
|
|
|
4683
4685
|
//#endregion
|
|
4684
4686
|
//#region src/rules/prefer-import-in-mock.ts
|
|
4685
|
-
const RULE_NAME$
|
|
4687
|
+
const RULE_NAME$28 = "prefer-import-in-mock";
|
|
4686
4688
|
var prefer_import_in_mock_default = createEslintRule({
|
|
4687
|
-
name: RULE_NAME$
|
|
4689
|
+
name: RULE_NAME$28,
|
|
4688
4690
|
meta: {
|
|
4689
4691
|
fixable: "code",
|
|
4690
4692
|
type: "suggestion",
|
|
@@ -4714,9 +4716,9 @@ var prefer_import_in_mock_default = createEslintRule({
|
|
|
4714
4716
|
|
|
4715
4717
|
//#endregion
|
|
4716
4718
|
//#region src/rules/prefer-importing-vitest-globals.ts
|
|
4717
|
-
const RULE_NAME$
|
|
4719
|
+
const RULE_NAME$27 = "prefer-importing-vitest-globals";
|
|
4718
4720
|
var prefer_importing_vitest_globals_default = createEslintRule({
|
|
4719
|
-
name: RULE_NAME$
|
|
4721
|
+
name: RULE_NAME$27,
|
|
4720
4722
|
meta: {
|
|
4721
4723
|
type: "suggestion",
|
|
4722
4724
|
docs: {
|
|
@@ -4789,7 +4791,7 @@ var prefer_importing_vitest_globals_default = createEslintRule({
|
|
|
4789
4791
|
|
|
4790
4792
|
//#endregion
|
|
4791
4793
|
//#region src/rules/prefer-lowercase-title.ts
|
|
4792
|
-
const RULE_NAME$
|
|
4794
|
+
const RULE_NAME$26 = "prefer-lowercase-title";
|
|
4793
4795
|
const hasStringAsFirstArgument = (node) => node.arguments[0] && isStringNode(node.arguments[0]);
|
|
4794
4796
|
const populateIgnores = (ignore) => {
|
|
4795
4797
|
const ignores = [];
|
|
@@ -4799,7 +4801,7 @@ const populateIgnores = (ignore) => {
|
|
|
4799
4801
|
return ignores;
|
|
4800
4802
|
};
|
|
4801
4803
|
var prefer_lowercase_title_default = createEslintRule({
|
|
4802
|
-
name: RULE_NAME$
|
|
4804
|
+
name: RULE_NAME$26,
|
|
4803
4805
|
meta: {
|
|
4804
4806
|
type: "problem",
|
|
4805
4807
|
docs: {
|
|
@@ -4886,7 +4888,7 @@ var prefer_lowercase_title_default = createEslintRule({
|
|
|
4886
4888
|
|
|
4887
4889
|
//#endregion
|
|
4888
4890
|
//#region src/rules/prefer-mock-promise-shorthand.ts
|
|
4889
|
-
const RULE_NAME$
|
|
4891
|
+
const RULE_NAME$25 = "prefer-mock-promise-shorthand";
|
|
4890
4892
|
const withOnce = (name, addOnce) => {
|
|
4891
4893
|
return `${name}${addOnce ? "Once" : ""}`;
|
|
4892
4894
|
};
|
|
@@ -4896,7 +4898,7 @@ const findSingleReturnArgumentNode = (fnNode) => {
|
|
|
4896
4898
|
return null;
|
|
4897
4899
|
};
|
|
4898
4900
|
var prefer_mock_promise_shorthand_default = createEslintRule({
|
|
4899
|
-
name: RULE_NAME$
|
|
4901
|
+
name: RULE_NAME$25,
|
|
4900
4902
|
meta: {
|
|
4901
4903
|
type: "suggestion",
|
|
4902
4904
|
docs: {
|
|
@@ -4941,7 +4943,7 @@ var prefer_mock_promise_shorthand_default = createEslintRule({
|
|
|
4941
4943
|
|
|
4942
4944
|
//#endregion
|
|
4943
4945
|
//#region src/rules/prefer-snapshot-hint.ts
|
|
4944
|
-
const RULE_NAME$
|
|
4946
|
+
const RULE_NAME$24 = "prefer-snapshot-hint";
|
|
4945
4947
|
const snapshotMatcherNames = ["toMatchSnapshot", "toThrowErrorMatchingSnapshot"];
|
|
4946
4948
|
const isSnapshotMatcherWithoutHint = (expectFnCall) => {
|
|
4947
4949
|
if (expectFnCall.args.length === 0) return true;
|
|
@@ -4951,7 +4953,7 @@ const isSnapshotMatcherWithoutHint = (expectFnCall) => {
|
|
|
4951
4953
|
return !isStringNode(arg);
|
|
4952
4954
|
};
|
|
4953
4955
|
var prefer_snapshot_hint_default = createEslintRule({
|
|
4954
|
-
name: RULE_NAME$
|
|
4956
|
+
name: RULE_NAME$24,
|
|
4955
4957
|
meta: {
|
|
4956
4958
|
type: "suggestion",
|
|
4957
4959
|
docs: {
|
|
@@ -5020,7 +5022,7 @@ var prefer_snapshot_hint_default = createEslintRule({
|
|
|
5020
5022
|
|
|
5021
5023
|
//#endregion
|
|
5022
5024
|
//#region src/rules/prefer-spy-on.ts
|
|
5023
|
-
const RULE_NAME$
|
|
5025
|
+
const RULE_NAME$23 = "prefer-spy-on";
|
|
5024
5026
|
const findNodeObject = (node) => {
|
|
5025
5027
|
if ("object" in node) return node.object;
|
|
5026
5028
|
if (node.callee.type === AST_NODE_TYPES.MemberExpression) return node.callee.object;
|
|
@@ -5040,7 +5042,7 @@ const getAutoFixMockImplementation = (vitestFnCall, context) => {
|
|
|
5040
5042
|
return argSource ? `.mockImplementation(${argSource})` : ".mockImplementation()";
|
|
5041
5043
|
};
|
|
5042
5044
|
var prefer_spy_on_default = createEslintRule({
|
|
5043
|
-
name: RULE_NAME$
|
|
5045
|
+
name: RULE_NAME$23,
|
|
5044
5046
|
meta: {
|
|
5045
5047
|
type: "suggestion",
|
|
5046
5048
|
docs: {
|
|
@@ -5077,9 +5079,9 @@ var prefer_spy_on_default = createEslintRule({
|
|
|
5077
5079
|
|
|
5078
5080
|
//#endregion
|
|
5079
5081
|
//#region src/rules/prefer-strict-boolean-matchers.ts
|
|
5080
|
-
const RULE_NAME$
|
|
5082
|
+
const RULE_NAME$22 = "prefer-strict-boolean-matchers";
|
|
5081
5083
|
var prefer_strict_boolean_matchers_default = createEslintRule({
|
|
5082
|
-
name: RULE_NAME$
|
|
5084
|
+
name: RULE_NAME$22,
|
|
5083
5085
|
meta: {
|
|
5084
5086
|
type: "suggestion",
|
|
5085
5087
|
docs: {
|
|
@@ -5115,9 +5117,9 @@ var prefer_strict_boolean_matchers_default = createEslintRule({
|
|
|
5115
5117
|
|
|
5116
5118
|
//#endregion
|
|
5117
5119
|
//#region src/rules/prefer-strict-equal.ts
|
|
5118
|
-
const RULE_NAME$
|
|
5120
|
+
const RULE_NAME$21 = "prefer-strict-equal";
|
|
5119
5121
|
var prefer_strict_equal_default = createEslintRule({
|
|
5120
|
-
name: RULE_NAME$
|
|
5122
|
+
name: RULE_NAME$21,
|
|
5121
5123
|
meta: {
|
|
5122
5124
|
type: "suggestion",
|
|
5123
5125
|
docs: {
|
|
@@ -5151,10 +5153,10 @@ var prefer_strict_equal_default = createEslintRule({
|
|
|
5151
5153
|
|
|
5152
5154
|
//#endregion
|
|
5153
5155
|
//#region src/rules/prefer-to-be-falsy.ts
|
|
5154
|
-
const RULE_NAME$
|
|
5156
|
+
const RULE_NAME$20 = "prefer-to-be-falsy";
|
|
5155
5157
|
const isFalseLiteral = (node) => node.type === AST_NODE_TYPES.Literal && node.value === false;
|
|
5156
5158
|
var prefer_to_be_falsy_default = createEslintRule({
|
|
5157
|
-
name: RULE_NAME$
|
|
5159
|
+
name: RULE_NAME$20,
|
|
5158
5160
|
meta: {
|
|
5159
5161
|
type: "suggestion",
|
|
5160
5162
|
docs: {
|
|
@@ -5181,9 +5183,9 @@ var prefer_to_be_falsy_default = createEslintRule({
|
|
|
5181
5183
|
|
|
5182
5184
|
//#endregion
|
|
5183
5185
|
//#region src/rules/prefer-to-be-object.ts
|
|
5184
|
-
const RULE_NAME$
|
|
5186
|
+
const RULE_NAME$19 = "prefer-to-be-object";
|
|
5185
5187
|
var prefer_to_be_object_default = createEslintRule({
|
|
5186
|
-
name: RULE_NAME$
|
|
5188
|
+
name: RULE_NAME$19,
|
|
5187
5189
|
meta: {
|
|
5188
5190
|
type: "suggestion",
|
|
5189
5191
|
docs: {
|
|
@@ -5235,10 +5237,10 @@ var prefer_to_be_object_default = createEslintRule({
|
|
|
5235
5237
|
|
|
5236
5238
|
//#endregion
|
|
5237
5239
|
//#region src/rules/prefer-to-be-truthy.ts
|
|
5238
|
-
const RULE_NAME$
|
|
5240
|
+
const RULE_NAME$18 = "prefer-to-be-truthy";
|
|
5239
5241
|
const isTrueLiteral = (node) => node.type === AST_NODE_TYPES.Literal && node.value === true;
|
|
5240
5242
|
var prefer_to_be_truthy_default = createEslintRule({
|
|
5241
|
-
name: RULE_NAME$
|
|
5243
|
+
name: RULE_NAME$18,
|
|
5242
5244
|
meta: {
|
|
5243
5245
|
type: "suggestion",
|
|
5244
5246
|
docs: {
|
|
@@ -5265,7 +5267,7 @@ var prefer_to_be_truthy_default = createEslintRule({
|
|
|
5265
5267
|
|
|
5266
5268
|
//#endregion
|
|
5267
5269
|
//#region src/rules/prefer-to-be.ts
|
|
5268
|
-
const RULE_NAME$
|
|
5270
|
+
const RULE_NAME$17 = "prefer-to-be";
|
|
5269
5271
|
const isNullLiteral = (node) => node.type === AST_NODE_TYPES.Literal && node.value === null;
|
|
5270
5272
|
const isNullEqualityMatcher = (expectFnCall) => isNullLiteral(getFirstMatcherArg(expectFnCall));
|
|
5271
5273
|
const isFirstArgumentIdentifier = (expectFnCall, name) => isIdentifier(getFirstMatcherArg(expectFnCall), name);
|
|
@@ -5290,7 +5292,7 @@ const reportPreferToBe = (context, whatToBe, expectFnCall, func, modifierNode) =
|
|
|
5290
5292
|
});
|
|
5291
5293
|
};
|
|
5292
5294
|
var prefer_to_be_default = createEslintRule({
|
|
5293
|
-
name: RULE_NAME$
|
|
5295
|
+
name: RULE_NAME$17,
|
|
5294
5296
|
meta: {
|
|
5295
5297
|
type: "suggestion",
|
|
5296
5298
|
docs: {
|
|
@@ -5338,10 +5340,10 @@ var prefer_to_be_default = createEslintRule({
|
|
|
5338
5340
|
|
|
5339
5341
|
//#endregion
|
|
5340
5342
|
//#region src/rules/prefer-to-contain.ts
|
|
5341
|
-
const RULE_NAME$
|
|
5343
|
+
const RULE_NAME$16 = "prefer-to-contain";
|
|
5342
5344
|
const isFixableIncludesCallExpression = (node) => node.type === AST_NODE_TYPES.CallExpression && node.callee.type === AST_NODE_TYPES.MemberExpression && isSupportedAccessor(node.callee.property, "includes") && hasOnlyOneArgument(node) && node.arguments[0].type !== AST_NODE_TYPES.SpreadElement;
|
|
5343
5345
|
var prefer_to_contain_default = createEslintRule({
|
|
5344
|
-
name: RULE_NAME$
|
|
5346
|
+
name: RULE_NAME$16,
|
|
5345
5347
|
meta: {
|
|
5346
5348
|
docs: {
|
|
5347
5349
|
description: "enforce using toContain()",
|
|
@@ -5383,9 +5385,9 @@ var prefer_to_contain_default = createEslintRule({
|
|
|
5383
5385
|
|
|
5384
5386
|
//#endregion
|
|
5385
5387
|
//#region src/rules/prefer-to-have-length.ts
|
|
5386
|
-
const RULE_NAME$
|
|
5388
|
+
const RULE_NAME$15 = "prefer-to-have-length";
|
|
5387
5389
|
var prefer_to_have_length_default = createEslintRule({
|
|
5388
|
-
name: RULE_NAME$
|
|
5390
|
+
name: RULE_NAME$15,
|
|
5389
5391
|
meta: {
|
|
5390
5392
|
type: "suggestion",
|
|
5391
5393
|
docs: {
|
|
@@ -5419,7 +5421,7 @@ var prefer_to_have_length_default = createEslintRule({
|
|
|
5419
5421
|
|
|
5420
5422
|
//#endregion
|
|
5421
5423
|
//#region src/rules/prefer-todo.ts
|
|
5422
|
-
const RULE_NAME$
|
|
5424
|
+
const RULE_NAME$14 = "prefer-todo";
|
|
5423
5425
|
const isTargetedTestCase = (vitestFnCall) => {
|
|
5424
5426
|
if (vitestFnCall.members.some((s) => getAccessorValue(s) !== "skip")) return false;
|
|
5425
5427
|
if (vitestFnCall.name.startsWith("x")) return false;
|
|
@@ -5434,7 +5436,7 @@ function createTodoFixer(vitestFnCall, fixer) {
|
|
|
5434
5436
|
return fixer.replaceText(vitestFnCall.head.node, `${vitestFnCall.head.local}.todo`);
|
|
5435
5437
|
}
|
|
5436
5438
|
var prefer_todo_default = createEslintRule({
|
|
5437
|
-
name: RULE_NAME$
|
|
5439
|
+
name: RULE_NAME$14,
|
|
5438
5440
|
meta: {
|
|
5439
5441
|
type: "layout",
|
|
5440
5442
|
docs: {
|
|
@@ -5470,7 +5472,7 @@ var prefer_todo_default = createEslintRule({
|
|
|
5470
5472
|
|
|
5471
5473
|
//#endregion
|
|
5472
5474
|
//#region src/rules/prefer-vi-mocked.ts
|
|
5473
|
-
const RULE_NAME$
|
|
5475
|
+
const RULE_NAME$13 = "prefer-vi-mocked";
|
|
5474
5476
|
const mockTypes = [
|
|
5475
5477
|
"Mock",
|
|
5476
5478
|
"MockedFunction",
|
|
@@ -5478,7 +5480,7 @@ const mockTypes = [
|
|
|
5478
5480
|
"MockedObject"
|
|
5479
5481
|
];
|
|
5480
5482
|
var prefer_vi_mocked_default = createEslintRule({
|
|
5481
|
-
name: RULE_NAME$
|
|
5483
|
+
name: RULE_NAME$13,
|
|
5482
5484
|
meta: {
|
|
5483
5485
|
type: "suggestion",
|
|
5484
5486
|
docs: {
|
|
@@ -5521,9 +5523,9 @@ var prefer_vi_mocked_default = createEslintRule({
|
|
|
5521
5523
|
|
|
5522
5524
|
//#endregion
|
|
5523
5525
|
//#region src/rules/require-awaited-expect-poll.ts
|
|
5524
|
-
const RULE_NAME$
|
|
5526
|
+
const RULE_NAME$12 = "require-awaited-expect-poll";
|
|
5525
5527
|
var require_awaited_expect_poll_default = createEslintRule({
|
|
5526
|
-
name: RULE_NAME$
|
|
5528
|
+
name: RULE_NAME$12,
|
|
5527
5529
|
meta: {
|
|
5528
5530
|
docs: {
|
|
5529
5531
|
requiresTypeChecking: false,
|
|
@@ -5570,7 +5572,7 @@ function skipSequenceExpressions(node) {
|
|
|
5570
5572
|
|
|
5571
5573
|
//#endregion
|
|
5572
5574
|
//#region src/rules/require-hook.ts
|
|
5573
|
-
const RULE_NAME$
|
|
5575
|
+
const RULE_NAME$11 = "require-hook";
|
|
5574
5576
|
const isVitestFnCall = (node, context) => {
|
|
5575
5577
|
if (parseVitestFnCall(node, context)) return true;
|
|
5576
5578
|
return !!getNodeName(node)?.startsWith("vi");
|
|
@@ -5589,7 +5591,7 @@ const shouldBeInHook = (node, context, allowedFunctionCalls = []) => {
|
|
|
5589
5591
|
}
|
|
5590
5592
|
};
|
|
5591
5593
|
var require_hook_default = createEslintRule({
|
|
5592
|
-
name: RULE_NAME$
|
|
5594
|
+
name: RULE_NAME$11,
|
|
5593
5595
|
meta: {
|
|
5594
5596
|
docs: {
|
|
5595
5597
|
description: "require setup and teardown to be within a hook",
|
|
@@ -5630,9 +5632,9 @@ var require_hook_default = createEslintRule({
|
|
|
5630
5632
|
|
|
5631
5633
|
//#endregion
|
|
5632
5634
|
//#region src/rules/require-import-vi-mock.ts
|
|
5633
|
-
const RULE_NAME$
|
|
5635
|
+
const RULE_NAME$10 = "require-import-vi-mock";
|
|
5634
5636
|
var require_import_vi_mock_default = createEslintRule({
|
|
5635
|
-
name: RULE_NAME$
|
|
5637
|
+
name: RULE_NAME$10,
|
|
5636
5638
|
meta: {
|
|
5637
5639
|
fixable: "code",
|
|
5638
5640
|
type: "suggestion",
|
|
@@ -5666,9 +5668,9 @@ var require_import_vi_mock_default = createEslintRule({
|
|
|
5666
5668
|
|
|
5667
5669
|
//#endregion
|
|
5668
5670
|
//#region src/rules/require-local-test-context-for-concurrent-snapshots.ts
|
|
5669
|
-
const RULE_NAME$
|
|
5671
|
+
const RULE_NAME$9 = "require-local-test-context-for-concurrent-snapshots";
|
|
5670
5672
|
var require_local_test_context_for_concurrent_snapshots_default = createEslintRule({
|
|
5671
|
-
name: RULE_NAME$
|
|
5673
|
+
name: RULE_NAME$9,
|
|
5672
5674
|
meta: {
|
|
5673
5675
|
docs: {
|
|
5674
5676
|
description: "require local Test Context for concurrent snapshot tests",
|
|
@@ -5709,9 +5711,9 @@ var require_local_test_context_for_concurrent_snapshots_default = createEslintRu
|
|
|
5709
5711
|
|
|
5710
5712
|
//#endregion
|
|
5711
5713
|
//#region src/rules/require-mock-type-parameters.ts
|
|
5712
|
-
const RULE_NAME$
|
|
5714
|
+
const RULE_NAME$8 = "require-mock-type-parameters";
|
|
5713
5715
|
var require_mock_type_parameters_default = createEslintRule({
|
|
5714
|
-
name: RULE_NAME$
|
|
5716
|
+
name: RULE_NAME$8,
|
|
5715
5717
|
meta: {
|
|
5716
5718
|
type: "suggestion",
|
|
5717
5719
|
docs: {
|
|
@@ -5748,9 +5750,9 @@ var require_mock_type_parameters_default = createEslintRule({
|
|
|
5748
5750
|
|
|
5749
5751
|
//#endregion
|
|
5750
5752
|
//#region src/rules/require-to-throw-message.ts
|
|
5751
|
-
const RULE_NAME$
|
|
5753
|
+
const RULE_NAME$7 = "require-to-throw-message";
|
|
5752
5754
|
var require_to_throw_message_default = createEslintRule({
|
|
5753
|
-
name: RULE_NAME$
|
|
5755
|
+
name: RULE_NAME$7,
|
|
5754
5756
|
meta: {
|
|
5755
5757
|
type: "suggestion",
|
|
5756
5758
|
docs: {
|
|
@@ -5778,9 +5780,9 @@ var require_to_throw_message_default = createEslintRule({
|
|
|
5778
5780
|
|
|
5779
5781
|
//#endregion
|
|
5780
5782
|
//#region src/rules/require-top-level-describe.ts
|
|
5781
|
-
const RULE_NAME$
|
|
5783
|
+
const RULE_NAME$6 = "require-top-level-describe";
|
|
5782
5784
|
var require_top_level_describe_default = createEslintRule({
|
|
5783
|
-
name: RULE_NAME$
|
|
5785
|
+
name: RULE_NAME$6,
|
|
5784
5786
|
meta: {
|
|
5785
5787
|
docs: {
|
|
5786
5788
|
description: "enforce that all tests are in a top-level describe",
|
|
@@ -5849,7 +5851,7 @@ var require_top_level_describe_default = createEslintRule({
|
|
|
5849
5851
|
|
|
5850
5852
|
//#endregion
|
|
5851
5853
|
//#region src/rules/valid-describe-callback.ts
|
|
5852
|
-
const RULE_NAME$
|
|
5854
|
+
const RULE_NAME$5 = "valid-describe-callback";
|
|
5853
5855
|
const paramsLocation = (params) => {
|
|
5854
5856
|
const [first] = params;
|
|
5855
5857
|
const last = params[params.length - 1];
|
|
@@ -5871,7 +5873,7 @@ const reportUnexpectedReturnInDescribe = (blockStatement, context) => {
|
|
|
5871
5873
|
});
|
|
5872
5874
|
};
|
|
5873
5875
|
var valid_describe_callback_default = createEslintRule({
|
|
5874
|
-
name: RULE_NAME$
|
|
5876
|
+
name: RULE_NAME$5,
|
|
5875
5877
|
meta: {
|
|
5876
5878
|
type: "problem",
|
|
5877
5879
|
docs: {
|
|
@@ -5938,7 +5940,7 @@ var valid_describe_callback_default = createEslintRule({
|
|
|
5938
5940
|
|
|
5939
5941
|
//#endregion
|
|
5940
5942
|
//#region src/rules/valid-expect-in-promise.ts
|
|
5941
|
-
const RULE_NAME$
|
|
5943
|
+
const RULE_NAME$4 = "valid-expect-in-promise";
|
|
5942
5944
|
const defaultAsyncMatchers$1 = ["toRejectWith", "toResolveWith"];
|
|
5943
5945
|
const isPromiseChainCall = (node) => {
|
|
5944
5946
|
if (node.type === AST_NODE_TYPES.CallExpression && node.callee.type === AST_NODE_TYPES.MemberExpression && isSupportedAccessor(node.callee.property)) {
|
|
@@ -6070,7 +6072,7 @@ const isVariableAwaitedOrReturned = (variable, context) => {
|
|
|
6070
6072
|
return isValueAwaitedOrReturned(variable.id, body, context);
|
|
6071
6073
|
};
|
|
6072
6074
|
var valid_expect_in_promise_default = createEslintRule({
|
|
6073
|
-
name: RULE_NAME$
|
|
6075
|
+
name: RULE_NAME$4,
|
|
6074
6076
|
meta: {
|
|
6075
6077
|
docs: { description: "require promises that have expectations in their chain to be valid" },
|
|
6076
6078
|
messages: { expectInFloatingPromise: "This promise should either be returned or awaited to ensure the expects in its chain are called" },
|
|
@@ -6130,7 +6132,7 @@ var valid_expect_in_promise_default = createEslintRule({
|
|
|
6130
6132
|
|
|
6131
6133
|
//#endregion
|
|
6132
6134
|
//#region src/rules/valid-expect.ts
|
|
6133
|
-
const RULE_NAME$
|
|
6135
|
+
const RULE_NAME$3 = "valid-expect";
|
|
6134
6136
|
const defaultAsyncMatchers = ["toReject", "toResolve"];
|
|
6135
6137
|
/**
|
|
6136
6138
|
* Async assertions might be called in Promise
|
|
@@ -6165,7 +6167,7 @@ const isAcceptableReturnNode = (node, allowReturn) => {
|
|
|
6165
6167
|
return [AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.AwaitExpression].includes(node.type);
|
|
6166
6168
|
};
|
|
6167
6169
|
var valid_expect_default = createEslintRule({
|
|
6168
|
-
name: RULE_NAME$
|
|
6170
|
+
name: RULE_NAME$3,
|
|
6169
6171
|
meta: {
|
|
6170
6172
|
docs: {
|
|
6171
6173
|
description: "enforce valid `expect()` usage",
|
|
@@ -6358,7 +6360,7 @@ var valid_expect_default = createEslintRule({
|
|
|
6358
6360
|
|
|
6359
6361
|
//#endregion
|
|
6360
6362
|
//#region src/rules/valid-title.ts
|
|
6361
|
-
const RULE_NAME$
|
|
6363
|
+
const RULE_NAME$2 = "valid-title";
|
|
6362
6364
|
const trimFXPrefix = (word) => ["f", "x"].includes(word.charAt(0)) ? word.substring(1) : word;
|
|
6363
6365
|
const quoteStringValue = (node) => node.type === AST_NODE_TYPES.TemplateLiteral ? `\`${node.quasis[0].value.raw}\`` : node.raw;
|
|
6364
6366
|
const MatcherAndMessageSchema = {
|
|
@@ -6397,7 +6399,7 @@ const doesBinaryExpressionContainStringNode = (binaryExp) => {
|
|
|
6397
6399
|
return isStringNode(binaryExp.left);
|
|
6398
6400
|
};
|
|
6399
6401
|
var valid_title_default = createEslintRule({
|
|
6400
|
-
name: RULE_NAME$
|
|
6402
|
+
name: RULE_NAME$2,
|
|
6401
6403
|
meta: {
|
|
6402
6404
|
docs: {
|
|
6403
6405
|
description: "enforce valid titles",
|
|
@@ -6464,7 +6466,7 @@ var valid_title_default = createEslintRule({
|
|
|
6464
6466
|
return { CallExpression(node) {
|
|
6465
6467
|
const vitestFnCall = parseVitestFnCall(node, context);
|
|
6466
6468
|
if (vitestFnCall?.type !== "describe" && vitestFnCall?.type !== "test" && vitestFnCall?.type !== "it") return;
|
|
6467
|
-
if (vitestFnCall.members
|
|
6469
|
+
if (vitestFnCall.members.some((member) => ["extend", "scoped"].includes(getAccessorValue(member)))) return;
|
|
6468
6470
|
const reportEmptyTitle = (node$1) => {
|
|
6469
6471
|
context.report({
|
|
6470
6472
|
messageId: "emptyTitle",
|
|
@@ -6550,9 +6552,9 @@ var valid_title_default = createEslintRule({
|
|
|
6550
6552
|
|
|
6551
6553
|
//#endregion
|
|
6552
6554
|
//#region src/rules/warn-todo.ts
|
|
6553
|
-
const RULE_NAME = "warn-todo";
|
|
6555
|
+
const RULE_NAME$1 = "warn-todo";
|
|
6554
6556
|
var warn_todo_default = createEslintRule({
|
|
6555
|
-
name: RULE_NAME,
|
|
6557
|
+
name: RULE_NAME$1,
|
|
6556
6558
|
meta: {
|
|
6557
6559
|
docs: {
|
|
6558
6560
|
description: "disallow `.todo` usage",
|
|
@@ -6577,6 +6579,49 @@ var warn_todo_default = createEslintRule({
|
|
|
6577
6579
|
}
|
|
6578
6580
|
});
|
|
6579
6581
|
|
|
6582
|
+
//#endregion
|
|
6583
|
+
//#region src/rules/no-unneeded-async-expect-function.ts
|
|
6584
|
+
const RULE_NAME = "no-unneeded-async-expect-function";
|
|
6585
|
+
const getAwaitedCallExpression = (expression) => {
|
|
6586
|
+
if (!expression.async) return null;
|
|
6587
|
+
if (expression.type === AST_NODE_TYPES.ArrowFunctionExpression && expression.body.type === AST_NODE_TYPES.AwaitExpression && expression.body.argument.type === AST_NODE_TYPES.CallExpression) return expression.body.argument;
|
|
6588
|
+
if (expression.body.type !== AST_NODE_TYPES.BlockStatement || expression.body.body.length !== 1) return null;
|
|
6589
|
+
const [callback] = expression.body.body;
|
|
6590
|
+
if (callback.type === AST_NODE_TYPES.ExpressionStatement && callback.expression.type === AST_NODE_TYPES.AwaitExpression && callback.expression.argument.type === AST_NODE_TYPES.CallExpression) return callback.expression.argument;
|
|
6591
|
+
return null;
|
|
6592
|
+
};
|
|
6593
|
+
var no_unneeded_async_expect_function_default = createEslintRule({
|
|
6594
|
+
name: RULE_NAME,
|
|
6595
|
+
meta: {
|
|
6596
|
+
docs: { description: "Disallow unnecessary async function wrapper for expected promises" },
|
|
6597
|
+
fixable: "code",
|
|
6598
|
+
messages: { noAsyncWrapperForExpectedPromise: "Unnecessary async function wrapper" },
|
|
6599
|
+
schema: [],
|
|
6600
|
+
type: "suggestion"
|
|
6601
|
+
},
|
|
6602
|
+
defaultOptions: [],
|
|
6603
|
+
create(context) {
|
|
6604
|
+
return { CallExpression(node) {
|
|
6605
|
+
const vitestFnCall = parseVitestFnCall(node, context);
|
|
6606
|
+
if (vitestFnCall?.type !== "expect") return;
|
|
6607
|
+
const { parent } = vitestFnCall.head.node;
|
|
6608
|
+
if (parent?.type !== AST_NODE_TYPES.CallExpression) return;
|
|
6609
|
+
const [awaitNode] = parent.arguments;
|
|
6610
|
+
if (!awaitNode || !isFunction(awaitNode)) return;
|
|
6611
|
+
const innerAsyncFuncCall = getAwaitedCallExpression(awaitNode);
|
|
6612
|
+
if (!innerAsyncFuncCall) return;
|
|
6613
|
+
context.report({
|
|
6614
|
+
node: awaitNode,
|
|
6615
|
+
messageId: "noAsyncWrapperForExpectedPromise",
|
|
6616
|
+
fix(fixer) {
|
|
6617
|
+
const { sourceCode } = context;
|
|
6618
|
+
return [fixer.replaceTextRange(awaitNode.range, sourceCode.getText(innerAsyncFuncCall))];
|
|
6619
|
+
}
|
|
6620
|
+
});
|
|
6621
|
+
} };
|
|
6622
|
+
}
|
|
6623
|
+
});
|
|
6624
|
+
|
|
6580
6625
|
//#endregion
|
|
6581
6626
|
//#region src/rules/index.ts
|
|
6582
6627
|
const rules = {
|
|
@@ -6609,6 +6654,7 @@ const rules = {
|
|
|
6609
6654
|
"no-standalone-expect": no_standalone_expect_default,
|
|
6610
6655
|
"no-test-prefixes": no_test_prefixes_default,
|
|
6611
6656
|
"no-test-return-statement": no_test_return_statement_default,
|
|
6657
|
+
"no-unneeded-async-expect-function": no_unneeded_async_expect_function_default,
|
|
6612
6658
|
"padding-around-after-all-blocks": padding_around_after_all_blocks_default,
|
|
6613
6659
|
"padding-around-after-each-blocks": padding_around_after_each_blocks_default,
|
|
6614
6660
|
"padding-around-all": padding_around_all_default,
|
|
@@ -6706,6 +6752,7 @@ const allRules = {
|
|
|
6706
6752
|
"no-standalone-expect": "warn",
|
|
6707
6753
|
"no-test-prefixes": "warn",
|
|
6708
6754
|
"no-test-return-statement": "warn",
|
|
6755
|
+
"no-unneeded-async-expect-function": "warn",
|
|
6709
6756
|
"padding-around-after-all-blocks": "warn",
|
|
6710
6757
|
"padding-around-after-each-blocks": "warn",
|
|
6711
6758
|
"padding-around-all": "warn",
|
|
@@ -6766,6 +6813,7 @@ const recommendedRules = {
|
|
|
6766
6813
|
"no-interpolation-in-snapshots": "error",
|
|
6767
6814
|
"no-mocks-import": "error",
|
|
6768
6815
|
"no-standalone-expect": "error",
|
|
6816
|
+
"no-unneeded-async-expect-function": "error",
|
|
6769
6817
|
"prefer-called-exactly-once-with": "error",
|
|
6770
6818
|
"require-local-test-context-for-concurrent-snapshots": "error",
|
|
6771
6819
|
"valid-describe-callback": "error",
|