eslint-plugin-jest 24.1.2 → 24.1.3
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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [24.1.3](https://github.com/jest-community/eslint-plugin-jest/compare/v24.1.2...v24.1.3) (2020-11-12)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* revert change causing regressions for test.each ([#713](https://github.com/jest-community/eslint-plugin-jest/issues/713)) ([7c8d75a](https://github.com/jest-community/eslint-plugin-jest/commit/7c8d75a4fcbd2c6ce005cf4f57d676c7c44ce0b2)), closes [#710](https://github.com/jest-community/eslint-plugin-jest/issues/710) [#711](https://github.com/jest-community/eslint-plugin-jest/issues/711)
|
|
7
|
+
|
|
1
8
|
## [24.1.2](https://github.com/jest-community/eslint-plugin-jest/compare/v24.1.1...v24.1.2) (2020-11-12)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -60,8 +60,6 @@ var _default = (0, _utils.createRule)({
|
|
|
60
60
|
describeNestingLevel++;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
const funcNode = node.callee.type === _experimentalUtils.AST_NODE_TYPES.TaggedTemplateExpression ? node.callee.tag : node.callee;
|
|
64
|
-
|
|
65
63
|
if ((0, _utils.isTestCase)(node) && describeNestingLevel === 0 && !nodeName.includes(testKeyword)) {
|
|
66
64
|
const oppositeTestKeyword = getOppositeTestKeyword(testKeyword);
|
|
67
65
|
context.report({
|
|
@@ -71,7 +69,7 @@ var _default = (0, _utils.createRule)({
|
|
|
71
69
|
testKeyword,
|
|
72
70
|
oppositeTestKeyword
|
|
73
71
|
},
|
|
74
|
-
fix: buildFixer(
|
|
72
|
+
fix: buildFixer(node.callee, nodeName, testKeyword)
|
|
75
73
|
});
|
|
76
74
|
}
|
|
77
75
|
|
|
@@ -84,7 +82,7 @@ var _default = (0, _utils.createRule)({
|
|
|
84
82
|
testKeywordWithinDescribe,
|
|
85
83
|
oppositeTestKeyword
|
|
86
84
|
},
|
|
87
|
-
fix: buildFixer(
|
|
85
|
+
fix: buildFixer(node.callee, nodeName, testKeywordWithinDescribe)
|
|
88
86
|
});
|
|
89
87
|
}
|
|
90
88
|
},
|
|
@@ -50,9 +50,7 @@ var _default = (0, _utils.createRule)({
|
|
|
50
50
|
},
|
|
51
51
|
|
|
52
52
|
CallExpression(node) {
|
|
53
|
-
const functionName = (0, _utils.getNodeName)(node.callee);
|
|
54
|
-
|
|
55
|
-
if (node.callee.type === 'CallExpression') return;
|
|
53
|
+
const functionName = (0, _utils.getNodeName)(node.callee);
|
|
56
54
|
|
|
57
55
|
switch (functionName) {
|
|
58
56
|
case 'describe.skip':
|
|
@@ -66,10 +64,6 @@ var _default = (0, _utils.createRule)({
|
|
|
66
64
|
case 'it.concurrent.skip':
|
|
67
65
|
case 'test.skip':
|
|
68
66
|
case 'test.concurrent.skip':
|
|
69
|
-
case 'it.skip.each':
|
|
70
|
-
case 'test.skip.each':
|
|
71
|
-
case 'xit.each':
|
|
72
|
-
case 'xtest.each':
|
|
73
67
|
context.report({
|
|
74
68
|
messageId: 'skippedTest',
|
|
75
69
|
node
|
|
@@ -9,11 +9,7 @@ var _experimentalUtils = require("@typescript-eslint/experimental-utils");
|
|
|
9
9
|
|
|
10
10
|
var _utils = require("./utils");
|
|
11
11
|
|
|
12
|
-
const findCallbackArg =
|
|
13
|
-
if (isJestEach) {
|
|
14
|
-
return node.arguments[1];
|
|
15
|
-
}
|
|
16
|
-
|
|
12
|
+
const findCallbackArg = node => {
|
|
17
13
|
if ((0, _utils.isHook)(node) && node.arguments.length >= 1) {
|
|
18
14
|
return node.arguments[0];
|
|
19
15
|
}
|
|
@@ -47,18 +43,13 @@ var _default = (0, _utils.createRule)({
|
|
|
47
43
|
create(context) {
|
|
48
44
|
return {
|
|
49
45
|
CallExpression(node) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
// done is the second argument for it.each, not the first
|
|
53
|
-
const isJestEach = (_getNodeName$endsWith = (_getNodeName = (0, _utils.getNodeName)(node.callee)) === null || _getNodeName === void 0 ? void 0 : _getNodeName.endsWith('.each')) !== null && _getNodeName$endsWith !== void 0 ? _getNodeName$endsWith : false;
|
|
54
|
-
const callback = findCallbackArg(node, isJestEach);
|
|
55
|
-
const callbackArgIndex = Number(isJestEach);
|
|
46
|
+
const callback = findCallbackArg(node);
|
|
56
47
|
|
|
57
|
-
if (!callback || !(0, _utils.isFunction)(callback) || callback.params.length !== 1
|
|
48
|
+
if (!callback || !(0, _utils.isFunction)(callback) || callback.params.length !== 1) {
|
|
58
49
|
return;
|
|
59
50
|
}
|
|
60
51
|
|
|
61
|
-
const argument = callback.params
|
|
52
|
+
const [argument] = callback.params;
|
|
62
53
|
|
|
63
54
|
if (argument.type !== _experimentalUtils.AST_NODE_TYPES.Identifier) {
|
|
64
55
|
context.report({
|
|
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var _experimentalUtils = require("@typescript-eslint/experimental-utils");
|
|
9
|
-
|
|
10
8
|
var _utils = require("./utils");
|
|
11
9
|
|
|
12
10
|
var _default = (0, _utils.createRule)({
|
|
@@ -33,7 +31,6 @@ var _default = (0, _utils.createRule)({
|
|
|
33
31
|
if (!nodeName || !(0, _utils.isDescribe)(node) && !(0, _utils.isTestCase)(node)) return;
|
|
34
32
|
const preferredNodeName = getPreferredNodeName(nodeName);
|
|
35
33
|
if (!preferredNodeName) return;
|
|
36
|
-
const funcNode = node.callee.type === _experimentalUtils.AST_NODE_TYPES.TaggedTemplateExpression ? node.callee.tag : node.callee;
|
|
37
34
|
context.report({
|
|
38
35
|
messageId: 'usePreferredName',
|
|
39
36
|
node: node.callee,
|
|
@@ -42,7 +39,7 @@ var _default = (0, _utils.createRule)({
|
|
|
42
39
|
},
|
|
43
40
|
|
|
44
41
|
fix(fixer) {
|
|
45
|
-
return [fixer.replaceText(
|
|
42
|
+
return [fixer.replaceText(node.callee, preferredNodeName)];
|
|
46
43
|
}
|
|
47
44
|
|
|
48
45
|
});
|
|
@@ -57,14 +54,13 @@ exports.default = _default;
|
|
|
57
54
|
|
|
58
55
|
function getPreferredNodeName(nodeName) {
|
|
59
56
|
const firstChar = nodeName.charAt(0);
|
|
60
|
-
const suffix = nodeName.endsWith('.each') ? '.each' : '';
|
|
61
57
|
|
|
62
58
|
if (firstChar === 'f') {
|
|
63
|
-
return `${nodeName.slice(1)
|
|
59
|
+
return `${nodeName.slice(1)}.only`;
|
|
64
60
|
}
|
|
65
61
|
|
|
66
62
|
if (firstChar === 'x') {
|
|
67
|
-
return `${nodeName.slice(1)
|
|
63
|
+
return `${nodeName.slice(1)}.skip`;
|
|
68
64
|
}
|
|
69
65
|
|
|
70
66
|
return null;
|
package/lib/rules/utils.js
CHANGED
|
@@ -363,9 +363,6 @@ function getNodeName(node) {
|
|
|
363
363
|
}
|
|
364
364
|
|
|
365
365
|
switch (node.type) {
|
|
366
|
-
case _experimentalUtils.AST_NODE_TYPES.TaggedTemplateExpression:
|
|
367
|
-
return getNodeName(node.tag);
|
|
368
|
-
|
|
369
366
|
case _experimentalUtils.AST_NODE_TYPES.MemberExpression:
|
|
370
367
|
return joinNames(getNodeName(node.object), getNodeName(node.property));
|
|
371
368
|
|
|
@@ -395,9 +392,7 @@ const getTestCallExpressionsFromDeclaredVariables = declaredVariables => {
|
|
|
395
392
|
|
|
396
393
|
exports.getTestCallExpressionsFromDeclaredVariables = getTestCallExpressionsFromDeclaredVariables;
|
|
397
394
|
|
|
398
|
-
const isTestCase = node => node.callee.type === _experimentalUtils.AST_NODE_TYPES.Identifier && TestCaseName.hasOwnProperty(node.callee.name) ||
|
|
399
|
-
node.callee.type === _experimentalUtils.AST_NODE_TYPES.TaggedTemplateExpression && node.callee.tag.type === _experimentalUtils.AST_NODE_TYPES.MemberExpression && isSupportedAccessor(node.callee.tag.property, TestCaseProperty.each) || // e.g. it.concurrent.{skip,only}
|
|
400
|
-
node.callee.type === _experimentalUtils.AST_NODE_TYPES.MemberExpression && node.callee.property.type === _experimentalUtils.AST_NODE_TYPES.Identifier && TestCaseProperty.hasOwnProperty(node.callee.property.name) && (node.callee.object.type === _experimentalUtils.AST_NODE_TYPES.Identifier && TestCaseName.hasOwnProperty(node.callee.object.name) || node.callee.object.type === _experimentalUtils.AST_NODE_TYPES.MemberExpression && node.callee.object.object.type === _experimentalUtils.AST_NODE_TYPES.Identifier && TestCaseName.hasOwnProperty(node.callee.object.object.name));
|
|
395
|
+
const isTestCase = node => node.callee.type === _experimentalUtils.AST_NODE_TYPES.Identifier && TestCaseName.hasOwnProperty(node.callee.name) || node.callee.type === _experimentalUtils.AST_NODE_TYPES.MemberExpression && node.callee.property.type === _experimentalUtils.AST_NODE_TYPES.Identifier && TestCaseProperty.hasOwnProperty(node.callee.property.name) && (node.callee.object.type === _experimentalUtils.AST_NODE_TYPES.Identifier && TestCaseName.hasOwnProperty(node.callee.object.name) || node.callee.object.type === _experimentalUtils.AST_NODE_TYPES.MemberExpression && node.callee.object.object.type === _experimentalUtils.AST_NODE_TYPES.Identifier && TestCaseName.hasOwnProperty(node.callee.object.object.name));
|
|
401
396
|
|
|
402
397
|
exports.isTestCase = isTestCase;
|
|
403
398
|
|