eslint-plugin-jest
Advanced tools
Comparing version 24.3.2 to 24.3.3
@@ -0,1 +1,9 @@ | ||
## [24.3.3](https://github.com/jest-community/eslint-plugin-jest/compare/v24.3.2...v24.3.3) (2021-04-02) | ||
### Bug Fixes | ||
* **no-duplicate-hooks:** support `describe.each` ([#797](https://github.com/jest-community/eslint-plugin-jest/issues/797)) ([243cb4f](https://github.com/jest-community/eslint-plugin-jest/commit/243cb4f970e40aa195a3bffa0528dbdbfef7c4f5)), closes [#642](https://github.com/jest-community/eslint-plugin-jest/issues/642) | ||
* **prefer-expect-assertions:** support `.each` ([#798](https://github.com/jest-community/eslint-plugin-jest/issues/798)) ([f758243](https://github.com/jest-community/eslint-plugin-jest/commit/f75824359f2242f53997c59c238d83a59badeea3)), closes [#676](https://github.com/jest-community/eslint-plugin-jest/issues/676) | ||
## [24.3.2](https://github.com/jest-community/eslint-plugin-jest/compare/v24.3.1...v24.3.2) (2021-03-16) | ||
@@ -2,0 +10,0 @@ |
@@ -20,5 +20,3 @@ "use strict"; | ||
if ((0, _utils.isEachCall)(node)) { | ||
var _node$parent; | ||
if (((_node$parent = node.parent) === null || _node$parent === void 0 ? void 0 : _node$parent.type) === _experimentalUtils.AST_NODE_TYPES.CallExpression && hasStringAsFirstArgument(node.parent)) { | ||
if (node.parent.arguments.length > 0 && (0, _utils.isStringNode)(node.parent.arguments[0])) { | ||
return [node.callee.object.name, node.parent.arguments[0]]; | ||
@@ -25,0 +23,0 @@ } |
@@ -58,3 +58,3 @@ "use strict"; | ||
'CallExpression:exit'(node) { | ||
if ((0, _utils.isDescribe)(node)) { | ||
if ((0, _utils.isDescribe)(node) && !(0, _utils.isEachCall)(node)) { | ||
hookContexts.pop(); | ||
@@ -61,0 +61,0 @@ } |
@@ -58,9 +58,21 @@ "use strict"; | ||
return { | ||
'CallExpression[callee.name=/^(it|test)$/][arguments.1.body.body]'(node) { | ||
if (options.onlyFunctionsWithAsyncKeyword && !node.arguments[1].async) { | ||
CallExpression(node) { | ||
if (!(0, _utils.isTestCase)(node)) { | ||
return; | ||
} | ||
const testFuncBody = node.arguments[1].body.body; | ||
const args = (0, _utils.isEachCall)(node) ? node.parent.arguments : node.arguments; | ||
if (args.length < 2) { | ||
return; | ||
} | ||
const [, testFn] = args; | ||
if (!(0, _utils.isFunction)(testFn) || testFn.body.type !== _experimentalUtils.AST_NODE_TYPES.BlockStatement || options.onlyFunctionsWithAsyncKeyword && !testFn.async) { | ||
return; | ||
} | ||
const testFuncBody = testFn.body.body; | ||
if (!isFirstLineExprStmt(testFuncBody)) { | ||
@@ -72,3 +84,3 @@ context.report({ | ||
messageId, | ||
fix: fixer => fixer.insertTextBeforeRange([node.arguments[1].body.range[0] + 1, node.arguments[1].body.range[1]], text) | ||
fix: fixer => fixer.insertTextBeforeRange([testFn.body.range[0] + 1, testFn.body.range[1]], text) | ||
})) | ||
@@ -75,0 +87,0 @@ }); |
@@ -406,8 +406,8 @@ "use strict"; | ||
/** | ||
* Checks if the given node` is a call to `<describe|test|it>.each(...)`. | ||
* If `true`, the code must look like `<method>.each(...)`. | ||
* Checks if the given node` is a call to `<describe|test|it>.each(...)()`. | ||
* If `true`, the code must look like `<method>.each(...)()`. | ||
* | ||
* @param {JestFunctionCallExpression<DescribeAlias | TestCaseName>} node | ||
* | ||
* @return {node is JestFunctionCallExpressionWithMemberExpressionCallee<DescribeAlias | TestCaseName, DescribeProperty.each | TestCaseProperty.each>} | ||
* @return {node is JestFunctionCallExpressionWithMemberExpressionCallee<DescribeAlias | TestCaseName, DescribeProperty.each | TestCaseProperty.each> & {parent: TSESTree.CallExpression}} | ||
*/ | ||
@@ -418,3 +418,7 @@ | ||
const isEachCall = node => node.callee.type === _experimentalUtils.AST_NODE_TYPES.MemberExpression && isSupportedAccessor(node.callee.property, DescribeProperty.each); | ||
const isEachCall = node => { | ||
var _node$parent; | ||
return ((_node$parent = node.parent) === null || _node$parent === void 0 ? void 0 : _node$parent.type) === _experimentalUtils.AST_NODE_TYPES.CallExpression && node.callee.type === _experimentalUtils.AST_NODE_TYPES.MemberExpression && isSupportedAccessor(node.callee.property, DescribeProperty.each); | ||
}; | ||
/** | ||
@@ -421,0 +425,0 @@ * Gets the arguments of the given `JestFunctionCallExpression`. |
{ | ||
"name": "eslint-plugin-jest", | ||
"version": "24.3.2", | ||
"version": "24.3.3", | ||
"description": "Eslint rules for Jest", | ||
@@ -111,3 +111,3 @@ "keywords": [ | ||
"eslint-plugin-prettier": "^3.0.0", | ||
"husky": "^5.1.3", | ||
"husky": "^6.0.0", | ||
"is-ci": "^3.0.0", | ||
@@ -114,0 +114,0 @@ "jest": "^26.0.1", |
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
253679
4085