eslint-plugin-jest
Advanced tools
Comparing version 25.0.2 to 25.0.3
@@ -0,1 +1,8 @@ | ||
## [25.0.3](https://github.com/jest-community/eslint-plugin-jest/compare/v25.0.2...v25.0.3) (2021-10-11) | ||
### Bug Fixes | ||
* **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)) | ||
## [25.0.2](https://github.com/jest-community/eslint-plugin-jest/compare/v25.0.1...v25.0.2) (2021-10-11) | ||
@@ -2,0 +9,0 @@ |
@@ -108,2 +108,31 @@ "use strict"; | ||
* Attempts to determine if the runtime value represented by the given `identifier` | ||
* is `await`ed as an argument along the given call expression | ||
*/ | ||
const isValueAwaitedInArguments = (name, call) => { | ||
let node = call; | ||
while (node) { | ||
if (node.type === _experimentalUtils.AST_NODE_TYPES.CallExpression) { | ||
for (const argument of node.arguments) { | ||
if (argument.type === _experimentalUtils.AST_NODE_TYPES.AwaitExpression && (0, _utils.isIdentifier)(argument.argument, name)) { | ||
return true; | ||
} | ||
} | ||
node = node.callee; | ||
} | ||
if (node.type !== _experimentalUtils.AST_NODE_TYPES.MemberExpression) { | ||
break; | ||
} | ||
node = node.object; | ||
} | ||
return false; | ||
}; | ||
/** | ||
* Attempts to determine if the runtime value represented by the given `identifier` | ||
* is `await`ed or `return`ed within the given `body` of statements | ||
@@ -130,2 +159,7 @@ */ | ||
if (node.type === _experimentalUtils.AST_NODE_TYPES.ExpressionStatement) { | ||
// it's possible that we're awaiting the value as an argument | ||
if (node.expression.type === _experimentalUtils.AST_NODE_TYPES.CallExpression && isValueAwaitedInArguments(name, node.expression)) { | ||
return true; | ||
} | ||
if (node.expression.type === _experimentalUtils.AST_NODE_TYPES.AwaitExpression && isPromiseMethodThatUsesValue(node.expression, identifier)) { | ||
@@ -132,0 +166,0 @@ return true; |
{ | ||
"name": "eslint-plugin-jest", | ||
"version": "25.0.2", | ||
"version": "25.0.3", | ||
"description": "Eslint rules for Jest", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
287450
4287