eslint-plugin-jest
Advanced tools
Comparing version 25.0.5 to 25.0.6
@@ -0,1 +1,9 @@ | ||
## [25.0.6](https://github.com/jest-community/eslint-plugin-jest/compare/v25.0.5...v25.0.6) (2021-10-14) | ||
### Bug Fixes | ||
* **valid-expect-in-promise:** allow `expect.resolve` & `expect.reject` ([#948](https://github.com/jest-community/eslint-plugin-jest/issues/948)) ([71b7e17](https://github.com/jest-community/eslint-plugin-jest/commit/71b7e17953b4310a4f2845adc951c68cf062cdc1)), closes [#947](https://github.com/jest-community/eslint-plugin-jest/issues/947) | ||
* **valid-expect-in-promise:** support `await` in arrays ([#949](https://github.com/jest-community/eslint-plugin-jest/issues/949)) ([a62130c](https://github.com/jest-community/eslint-plugin-jest/commit/a62130c28d01dea065cc6900a062180de2079876)) | ||
## [25.0.5](https://github.com/jest-community/eslint-plugin-jest/compare/v25.0.4...v25.0.5) (2021-10-11) | ||
@@ -2,0 +10,0 @@ |
@@ -108,2 +108,21 @@ "use strict"; | ||
* Attempts to determine if the runtime value represented by the given `identifier` | ||
* is `await`ed within the given array of elements | ||
*/ | ||
const isValueAwaitedInElements = (name, elements) => { | ||
for (const element of elements) { | ||
if (element.type === _experimentalUtils.AST_NODE_TYPES.AwaitExpression && (0, _utils.isIdentifier)(element.argument, name)) { | ||
return true; | ||
} | ||
if (element.type === _experimentalUtils.AST_NODE_TYPES.ArrayExpression && isValueAwaitedInElements(name, element.elements)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}; | ||
/** | ||
* Attempts to determine if the runtime value represented by the given `identifier` | ||
* is `await`ed as an argument along the given call expression | ||
@@ -118,6 +137,4 @@ */ | ||
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; | ||
} | ||
if (isValueAwaitedInElements(name, node.arguments)) { | ||
return true; | ||
} | ||
@@ -137,2 +154,22 @@ | ||
}; | ||
const getLeftMostCallExpression = call => { | ||
let leftMostCallExpression = call; | ||
let node = call; | ||
while (node) { | ||
if (node.type === _experimentalUtils.AST_NODE_TYPES.CallExpression) { | ||
leftMostCallExpression = node; | ||
node = node.callee; | ||
} | ||
if (node.type !== _experimentalUtils.AST_NODE_TYPES.MemberExpression) { | ||
break; | ||
} | ||
node = node.object; | ||
} | ||
return leftMostCallExpression; | ||
}; | ||
/** | ||
@@ -162,4 +199,18 @@ * Attempts to determine if the runtime value represented by the given `identifier` | ||
// 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.CallExpression) { | ||
if (isValueAwaitedInArguments(name, node.expression)) { | ||
return true; | ||
} | ||
const leftMostCall = getLeftMostCallExpression(node.expression); | ||
if ((0, _utils.isExpectCall)(leftMostCall) && leftMostCall.arguments.length > 0 && (0, _utils.isIdentifier)(leftMostCall.arguments[0], name)) { | ||
const { | ||
modifier | ||
} = (0, _utils.parseExpectCall)(leftMostCall); | ||
if ((modifier === null || modifier === void 0 ? void 0 : modifier.name) === _utils.ModifierName.resolves || (modifier === null || modifier === void 0 ? void 0 : modifier.name) === _utils.ModifierName.rejects) { | ||
return true; | ||
} | ||
} | ||
} | ||
@@ -166,0 +217,0 @@ |
{ | ||
"name": "eslint-plugin-jest", | ||
"version": "25.0.5", | ||
"version": "25.0.6", | ||
"description": "Eslint rules for Jest", | ||
@@ -63,6 +63,6 @@ "keywords": [ | ||
"displayName": "test", | ||
"testEnvironment": "node", | ||
"testPathIgnorePatterns": [ | ||
"<rootDir>/lib/.*", | ||
"<rootDir>/src/rules/__tests__/fixtures/*" | ||
"<rootDir>/src/rules/__tests__/fixtures/*", | ||
"<rootDir>/src/rules/__tests__/test-utils.ts" | ||
] | ||
@@ -109,3 +109,3 @@ }, | ||
"eslint-plugin-eslint-plugin": "^3.5.3", | ||
"eslint-plugin-import": "^2.20.2", | ||
"eslint-plugin-import": "^2.25.1", | ||
"eslint-plugin-node": "^11.0.0", | ||
@@ -116,7 +116,6 @@ "eslint-plugin-prettier": "^3.4.1", | ||
"jest": "^27.0.0", | ||
"jest-runner-eslint": "^0.11.0", | ||
"jest-runner-eslint": "^1.0.0", | ||
"lint-staged": "^11.1.2", | ||
"pinst": "^2.0.0", | ||
"prettier": "^2.0.5", | ||
"resolve-from": "^5.0.0", | ||
"rimraf": "^3.0.0", | ||
@@ -123,0 +122,0 @@ "semantic-release": "^18.0.0", |
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
290359
38
4326