eslint-plugin-jest 25.0.1 → 25.0.5
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,31 @@
|
|
|
1
|
+
## [25.0.5](https://github.com/jest-community/eslint-plugin-jest/compare/v25.0.4...v25.0.5) (2021-10-11)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* support `@typescript-eslint/eslint-plugin@5` ([#942](https://github.com/jest-community/eslint-plugin-jest/issues/942)) ([9b842a3](https://github.com/jest-community/eslint-plugin-jest/commit/9b842a309fb8e4263896f3e5b5150cf091d48698))
|
|
7
|
+
|
|
8
|
+
## [25.0.4](https://github.com/jest-community/eslint-plugin-jest/compare/v25.0.3...v25.0.4) (2021-10-11)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* update `@typescript-eslint/experimental-utils` to v5 ([#941](https://github.com/jest-community/eslint-plugin-jest/issues/941)) ([afad49a](https://github.com/jest-community/eslint-plugin-jest/commit/afad49a885eeb1ac52f00d8e1666259210a4b675))
|
|
14
|
+
|
|
15
|
+
## [25.0.3](https://github.com/jest-community/eslint-plugin-jest/compare/v25.0.2...v25.0.3) (2021-10-11)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* **valid-expect-in-promise:** support awaited promises in arguments ([#936](https://github.com/jest-community/eslint-plugin-jest/issues/936)) ([bd2c33c](https://github.com/jest-community/eslint-plugin-jest/commit/bd2c33c858573d5414d8bc0d401eb6f27801ad2b))
|
|
21
|
+
|
|
22
|
+
## [25.0.2](https://github.com/jest-community/eslint-plugin-jest/compare/v25.0.1...v25.0.2) (2021-10-11)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* **valid-expect-in-promise:** support out of order awaits ([#939](https://github.com/jest-community/eslint-plugin-jest/issues/939)) ([07d2137](https://github.com/jest-community/eslint-plugin-jest/commit/07d213719de974d6b5a1cab75e836dc39b432f87))
|
|
28
|
+
|
|
1
29
|
## [25.0.1](https://github.com/jest-community/eslint-plugin-jest/compare/v25.0.0...v25.0.1) (2021-10-10)
|
|
2
30
|
|
|
3
31
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.preprocess = exports.postprocess = void 0;
|
|
7
7
|
|
|
8
8
|
// https://eslint.org/docs/developer-guide/working-with-plugins#processors-in-plugins
|
|
9
9
|
// https://github.com/typescript-eslint/typescript-eslint/issues/808
|
package/lib/rules/utils.js
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.getAccessorValue = exports.followTypeAssertionChain = exports.createRule = exports.TestCaseProperty = exports.TestCaseName = exports.ModifierName = exports.HookName = exports.EqualityMatcher = exports.DescribeProperty = exports.DescribeAlias = void 0;
|
|
6
7
|
exports.getNodeName = getNodeName;
|
|
7
|
-
exports.scopeHasLocalReference = exports.
|
|
8
|
+
exports.scopeHasLocalReference = exports.parseExpectCall = exports.isTestCaseCall = exports.isSupportedAccessor = exports.isStringNode = exports.isParsedEqualityMatcherCall = exports.isIdentifier = exports.isHook = exports.isFunction = exports.isExpectMember = exports.isExpectCall = exports.isDescribeCall = exports.hasOnlyOneArgument = exports.getTestCallExpressionsFromDeclaredVariables = exports.getStringValue = void 0;
|
|
8
9
|
|
|
9
10
|
var _path = require("path");
|
|
10
11
|
|
|
@@ -61,7 +62,8 @@ const isStringLiteral = (node, value) => node.type === _experimentalUtils.AST_NO
|
|
|
61
62
|
*
|
|
62
63
|
* @template V
|
|
63
64
|
*/
|
|
64
|
-
const isTemplateLiteral = (node, value) => node.type === _experimentalUtils.AST_NODE_TYPES.TemplateLiteral && node.quasis.length === 1 && (
|
|
65
|
+
const isTemplateLiteral = (node, value) => node.type === _experimentalUtils.AST_NODE_TYPES.TemplateLiteral && node.quasis.length === 1 && ( // bail out if not simple
|
|
66
|
+
value === undefined || node.quasis[0].value.raw === value);
|
|
65
67
|
|
|
66
68
|
/**
|
|
67
69
|
* Checks if the given `node` is a {@link StringNode}.
|
|
@@ -101,7 +101,36 @@ const isPromiseMethodThatUsesValue = (node, identifier) => {
|
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
return
|
|
104
|
+
return (0, _utils.isIdentifier)(node.argument, name);
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Attempts to determine if the runtime value represented by the given `identifier`
|
|
108
|
+
* is `await`ed as an argument along the given call expression
|
|
109
|
+
*/
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
const isValueAwaitedInArguments = (name, call) => {
|
|
113
|
+
let node = call;
|
|
114
|
+
|
|
115
|
+
while (node) {
|
|
116
|
+
if (node.type === _experimentalUtils.AST_NODE_TYPES.CallExpression) {
|
|
117
|
+
for (const argument of node.arguments) {
|
|
118
|
+
if (argument.type === _experimentalUtils.AST_NODE_TYPES.AwaitExpression && (0, _utils.isIdentifier)(argument.argument, name)) {
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
node = node.callee;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (node.type !== _experimentalUtils.AST_NODE_TYPES.MemberExpression) {
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
node = node.object;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return false;
|
|
105
134
|
};
|
|
106
135
|
/**
|
|
107
136
|
* Attempts to determine if the runtime value represented by the given `identifier`
|
|
@@ -126,8 +155,13 @@ const isValueAwaitedOrReturned = (identifier, body) => {
|
|
|
126
155
|
}
|
|
127
156
|
|
|
128
157
|
if (node.type === _experimentalUtils.AST_NODE_TYPES.ExpressionStatement) {
|
|
129
|
-
|
|
130
|
-
|
|
158
|
+
// it's possible that we're awaiting the value as an argument
|
|
159
|
+
if (node.expression.type === _experimentalUtils.AST_NODE_TYPES.CallExpression && isValueAwaitedInArguments(name, node.expression)) {
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (node.expression.type === _experimentalUtils.AST_NODE_TYPES.AwaitExpression && isPromiseMethodThatUsesValue(node.expression, identifier)) {
|
|
164
|
+
return true;
|
|
131
165
|
} // (re)assignment changes the runtime value, so if we've not found an
|
|
132
166
|
// await or return already we act as if we've reached the end of the body
|
|
133
167
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-jest",
|
|
3
|
-
"version": "25.0.
|
|
3
|
+
"version": "25.0.5",
|
|
4
4
|
"description": "Eslint rules for Jest",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
]
|
|
80
80
|
},
|
|
81
81
|
"dependencies": {
|
|
82
|
-
"@typescript-eslint/experimental-utils": "^
|
|
82
|
+
"@typescript-eslint/experimental-utils": "^5.0.0"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
85
|
"@babel/cli": "^7.4.4",
|
|
@@ -95,8 +95,8 @@
|
|
|
95
95
|
"@types/jest": "^27.0.0",
|
|
96
96
|
"@types/node": "^14.0.0",
|
|
97
97
|
"@types/prettier": "^2.0.0",
|
|
98
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
99
|
-
"@typescript-eslint/parser": "^
|
|
98
|
+
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
|
99
|
+
"@typescript-eslint/parser": "^5.0.0",
|
|
100
100
|
"babel-jest": "^27.0.0",
|
|
101
101
|
"babel-plugin-replace-ts-export-assignment": "^0.0.2",
|
|
102
102
|
"dedent": "^0.7.0",
|
|
@@ -123,7 +123,7 @@
|
|
|
123
123
|
"typescript": "^4.4.0"
|
|
124
124
|
},
|
|
125
125
|
"peerDependencies": {
|
|
126
|
-
"@typescript-eslint/eslint-plugin": "^4.0.0",
|
|
126
|
+
"@typescript-eslint/eslint-plugin": "^4.0.0 || ^5.0.0",
|
|
127
127
|
"eslint": "^6.0.0 || ^7.0.0"
|
|
128
128
|
},
|
|
129
129
|
"peerDependenciesMeta": {
|