@vitest/eslint-plugin 1.6.10 → 1.6.12
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/dist/index.cjs +23 -54
- package/dist/index.mjs +22 -53
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
let _typescript_eslint_utils = require("@typescript-eslint/utils");
|
|
2
|
-
let node_module = require("node:module");
|
|
3
2
|
let node_path = require("node:path");
|
|
3
|
+
let node_module = require("node:module");
|
|
4
4
|
let _typescript_eslint_scope_manager = require("@typescript-eslint/scope-manager");
|
|
5
5
|
|
|
6
6
|
//#region package.json
|
|
7
|
-
var version = "1.6.
|
|
7
|
+
var version = "1.6.12";
|
|
8
8
|
|
|
9
9
|
//#endregion
|
|
10
10
|
//#region src/utils/index.ts
|
|
@@ -82,10 +82,6 @@ const isParsedInstanceOfMatcherCall = (expectFnCall, classArg) => {
|
|
|
82
82
|
return getAccessorValue(expectFnCall.matcher) === "toBeInstanceOf" && expectFnCall.args.length === 1 && isSupportedAccessor(expectFnCall.args[0], classArg);
|
|
83
83
|
};
|
|
84
84
|
|
|
85
|
-
//#endregion
|
|
86
|
-
//#region src/utils/require.ts
|
|
87
|
-
const require$1 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
|
|
88
|
-
|
|
89
85
|
//#endregion
|
|
90
86
|
//#region src/utils/types.ts
|
|
91
87
|
let UtilName = /* @__PURE__ */ function(UtilName) {
|
|
@@ -139,9 +135,7 @@ let EqualityMatcher = /* @__PURE__ */ function(EqualityMatcher) {
|
|
|
139
135
|
return EqualityMatcher;
|
|
140
136
|
}({});
|
|
141
137
|
function isClassOrFunctionType(type) {
|
|
142
|
-
|
|
143
|
-
const ts = require$1("typescript");
|
|
144
|
-
return type.getSymbol()?.getDeclarations()?.some((declaration) => ts.isArrowFunction(declaration) || ts.isClassDeclaration(declaration) || ts.isClassExpression(declaration) || ts.isFunctionDeclaration(declaration) || ts.isFunctionExpression(declaration) || ts.isMethodDeclaration(declaration) || ts.isFunctionTypeNode(declaration)) ?? false;
|
|
138
|
+
return type.getCallSignatures().length > 0 || type.getConstructSignatures().length > 0;
|
|
145
139
|
}
|
|
146
140
|
|
|
147
141
|
//#endregion
|
|
@@ -2392,7 +2386,7 @@ var no_alias_methods_default = createEslintRule({
|
|
|
2392
2386
|
toReturnWith: "toHaveReturnedWith",
|
|
2393
2387
|
lastReturnedWith: "toHaveLastReturnedWith",
|
|
2394
2388
|
nthReturnedWith: "toHaveNthReturnedWith",
|
|
2395
|
-
|
|
2389
|
+
toThrowError: "toThrow"
|
|
2396
2390
|
};
|
|
2397
2391
|
return { CallExpression(node) {
|
|
2398
2392
|
const vitestFnCall = parseVitestFnCall(node, context);
|
|
@@ -2785,16 +2779,6 @@ var no_duplicate_hooks_default = createEslintRule({
|
|
|
2785
2779
|
//#endregion
|
|
2786
2780
|
//#region src/rules/no-focused-tests.ts
|
|
2787
2781
|
const RULE_NAME$64 = "no-focused-tests";
|
|
2788
|
-
const isTestOrDescribe = (node) => {
|
|
2789
|
-
return node.type === "Identifier" && [
|
|
2790
|
-
"it",
|
|
2791
|
-
"test",
|
|
2792
|
-
"describe"
|
|
2793
|
-
].includes(node.name);
|
|
2794
|
-
};
|
|
2795
|
-
const isOnly = (node) => {
|
|
2796
|
-
return node.type === "Identifier" && node.name === "only";
|
|
2797
|
-
};
|
|
2798
2782
|
var no_focused_tests_default = createEslintRule({
|
|
2799
2783
|
name: RULE_NAME$64,
|
|
2800
2784
|
meta: {
|
|
@@ -2817,40 +2801,21 @@ var no_focused_tests_default = createEslintRule({
|
|
|
2817
2801
|
},
|
|
2818
2802
|
create: (context, options) => {
|
|
2819
2803
|
const fixable = options[0].fixable;
|
|
2820
|
-
return {
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
fix: (fixer) => fixable ? fixer.removeRange([tagCall.property.range[0] - 1, tagCall.property.range[1]]) : null
|
|
2836
|
-
});
|
|
2837
|
-
}
|
|
2838
|
-
}
|
|
2839
|
-
},
|
|
2840
|
-
CallExpression(node) {
|
|
2841
|
-
if (node.callee.type === "CallExpression") {
|
|
2842
|
-
const { callee } = node.callee;
|
|
2843
|
-
if (callee.type === "MemberExpression" && callee.object.type === "MemberExpression" && isTestOrDescribe(callee.object.object) && isOnly(callee.object.property) && callee.property.type === "Identifier" && callee.property.name === "each") {
|
|
2844
|
-
const onlyCallee = callee.object.property;
|
|
2845
|
-
context.report({
|
|
2846
|
-
node: callee.object.property,
|
|
2847
|
-
messageId: "noFocusedTests",
|
|
2848
|
-
fix: (fixer) => fixable ? fixer.removeRange([onlyCallee.range[0] - 1, onlyCallee.range[1]]) : null
|
|
2849
|
-
});
|
|
2850
|
-
}
|
|
2851
|
-
}
|
|
2852
|
-
}
|
|
2853
|
-
};
|
|
2804
|
+
return { CallExpression(node) {
|
|
2805
|
+
const vitestFnCall = parseVitestFnCall(node, context);
|
|
2806
|
+
if (!vitestFnCall) return;
|
|
2807
|
+
const isTestOrDescribe = [
|
|
2808
|
+
"it",
|
|
2809
|
+
"test",
|
|
2810
|
+
"describe"
|
|
2811
|
+
].includes(vitestFnCall.name);
|
|
2812
|
+
const onlyNode = vitestFnCall.members.find((m) => getAccessorValue(m) === "only");
|
|
2813
|
+
if (isTestOrDescribe && onlyNode) context.report({
|
|
2814
|
+
node: onlyNode,
|
|
2815
|
+
messageId: "noFocusedTests",
|
|
2816
|
+
fix: (fixer) => fixable ? fixer.removeRange([onlyNode.range[0] - 1, onlyNode.range[1]]) : null
|
|
2817
|
+
});
|
|
2818
|
+
} };
|
|
2854
2819
|
}
|
|
2855
2820
|
});
|
|
2856
2821
|
|
|
@@ -6495,6 +6460,10 @@ var valid_expect_default = createEslintRule({
|
|
|
6495
6460
|
}
|
|
6496
6461
|
});
|
|
6497
6462
|
|
|
6463
|
+
//#endregion
|
|
6464
|
+
//#region src/utils/require.ts
|
|
6465
|
+
const require$1 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
|
|
6466
|
+
|
|
6498
6467
|
//#endregion
|
|
6499
6468
|
//#region src/rules/valid-title.ts
|
|
6500
6469
|
const RULE_NAME$3 = "valid-title";
|
package/dist/index.mjs
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.6.
|
|
7
|
+
var version = "1.6.12";
|
|
8
8
|
|
|
9
9
|
//#endregion
|
|
10
10
|
//#region src/utils/index.ts
|
|
@@ -82,10 +82,6 @@ const isParsedInstanceOfMatcherCall = (expectFnCall, classArg) => {
|
|
|
82
82
|
return getAccessorValue(expectFnCall.matcher) === "toBeInstanceOf" && expectFnCall.args.length === 1 && isSupportedAccessor(expectFnCall.args[0], classArg);
|
|
83
83
|
};
|
|
84
84
|
|
|
85
|
-
//#endregion
|
|
86
|
-
//#region src/utils/require.ts
|
|
87
|
-
const require = createRequire(import.meta.url);
|
|
88
|
-
|
|
89
85
|
//#endregion
|
|
90
86
|
//#region src/utils/types.ts
|
|
91
87
|
let UtilName = /* @__PURE__ */ function(UtilName) {
|
|
@@ -139,9 +135,7 @@ let EqualityMatcher = /* @__PURE__ */ function(EqualityMatcher) {
|
|
|
139
135
|
return EqualityMatcher;
|
|
140
136
|
}({});
|
|
141
137
|
function isClassOrFunctionType(type) {
|
|
142
|
-
|
|
143
|
-
const ts = require("typescript");
|
|
144
|
-
return type.getSymbol()?.getDeclarations()?.some((declaration) => ts.isArrowFunction(declaration) || ts.isClassDeclaration(declaration) || ts.isClassExpression(declaration) || ts.isFunctionDeclaration(declaration) || ts.isFunctionExpression(declaration) || ts.isMethodDeclaration(declaration) || ts.isFunctionTypeNode(declaration)) ?? false;
|
|
138
|
+
return type.getCallSignatures().length > 0 || type.getConstructSignatures().length > 0;
|
|
145
139
|
}
|
|
146
140
|
|
|
147
141
|
//#endregion
|
|
@@ -2392,7 +2386,7 @@ var no_alias_methods_default = createEslintRule({
|
|
|
2392
2386
|
toReturnWith: "toHaveReturnedWith",
|
|
2393
2387
|
lastReturnedWith: "toHaveLastReturnedWith",
|
|
2394
2388
|
nthReturnedWith: "toHaveNthReturnedWith",
|
|
2395
|
-
|
|
2389
|
+
toThrowError: "toThrow"
|
|
2396
2390
|
};
|
|
2397
2391
|
return { CallExpression(node) {
|
|
2398
2392
|
const vitestFnCall = parseVitestFnCall(node, context);
|
|
@@ -2785,16 +2779,6 @@ var no_duplicate_hooks_default = createEslintRule({
|
|
|
2785
2779
|
//#endregion
|
|
2786
2780
|
//#region src/rules/no-focused-tests.ts
|
|
2787
2781
|
const RULE_NAME$64 = "no-focused-tests";
|
|
2788
|
-
const isTestOrDescribe = (node) => {
|
|
2789
|
-
return node.type === "Identifier" && [
|
|
2790
|
-
"it",
|
|
2791
|
-
"test",
|
|
2792
|
-
"describe"
|
|
2793
|
-
].includes(node.name);
|
|
2794
|
-
};
|
|
2795
|
-
const isOnly = (node) => {
|
|
2796
|
-
return node.type === "Identifier" && node.name === "only";
|
|
2797
|
-
};
|
|
2798
2782
|
var no_focused_tests_default = createEslintRule({
|
|
2799
2783
|
name: RULE_NAME$64,
|
|
2800
2784
|
meta: {
|
|
@@ -2817,40 +2801,21 @@ var no_focused_tests_default = createEslintRule({
|
|
|
2817
2801
|
},
|
|
2818
2802
|
create: (context, options) => {
|
|
2819
2803
|
const fixable = options[0].fixable;
|
|
2820
|
-
return {
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
fix: (fixer) => fixable ? fixer.removeRange([tagCall.property.range[0] - 1, tagCall.property.range[1]]) : null
|
|
2836
|
-
});
|
|
2837
|
-
}
|
|
2838
|
-
}
|
|
2839
|
-
},
|
|
2840
|
-
CallExpression(node) {
|
|
2841
|
-
if (node.callee.type === "CallExpression") {
|
|
2842
|
-
const { callee } = node.callee;
|
|
2843
|
-
if (callee.type === "MemberExpression" && callee.object.type === "MemberExpression" && isTestOrDescribe(callee.object.object) && isOnly(callee.object.property) && callee.property.type === "Identifier" && callee.property.name === "each") {
|
|
2844
|
-
const onlyCallee = callee.object.property;
|
|
2845
|
-
context.report({
|
|
2846
|
-
node: callee.object.property,
|
|
2847
|
-
messageId: "noFocusedTests",
|
|
2848
|
-
fix: (fixer) => fixable ? fixer.removeRange([onlyCallee.range[0] - 1, onlyCallee.range[1]]) : null
|
|
2849
|
-
});
|
|
2850
|
-
}
|
|
2851
|
-
}
|
|
2852
|
-
}
|
|
2853
|
-
};
|
|
2804
|
+
return { CallExpression(node) {
|
|
2805
|
+
const vitestFnCall = parseVitestFnCall(node, context);
|
|
2806
|
+
if (!vitestFnCall) return;
|
|
2807
|
+
const isTestOrDescribe = [
|
|
2808
|
+
"it",
|
|
2809
|
+
"test",
|
|
2810
|
+
"describe"
|
|
2811
|
+
].includes(vitestFnCall.name);
|
|
2812
|
+
const onlyNode = vitestFnCall.members.find((m) => getAccessorValue(m) === "only");
|
|
2813
|
+
if (isTestOrDescribe && onlyNode) context.report({
|
|
2814
|
+
node: onlyNode,
|
|
2815
|
+
messageId: "noFocusedTests",
|
|
2816
|
+
fix: (fixer) => fixable ? fixer.removeRange([onlyNode.range[0] - 1, onlyNode.range[1]]) : null
|
|
2817
|
+
});
|
|
2818
|
+
} };
|
|
2854
2819
|
}
|
|
2855
2820
|
});
|
|
2856
2821
|
|
|
@@ -6495,6 +6460,10 @@ var valid_expect_default = createEslintRule({
|
|
|
6495
6460
|
}
|
|
6496
6461
|
});
|
|
6497
6462
|
|
|
6463
|
+
//#endregion
|
|
6464
|
+
//#region src/utils/require.ts
|
|
6465
|
+
const require = createRequire(import.meta.url);
|
|
6466
|
+
|
|
6498
6467
|
//#endregion
|
|
6499
6468
|
//#region src/rules/valid-title.ts
|
|
6500
6469
|
const RULE_NAME$3 = "valid-title";
|