eslint-plugin-jest 26.3.0 → 26.4.0

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.
@@ -53,11 +53,13 @@ const findTopMostCallExpression = node => {
53
53
  };
54
54
 
55
55
  const isTestCaseCallWithCallbackArg = (node, scope) => {
56
- if (!(0, _utils2.isTestCaseCall)(node, scope)) {
56
+ const jestCallFn = (0, _utils2.parseJestFnCall)(node, scope);
57
+
58
+ if ((jestCallFn === null || jestCallFn === void 0 ? void 0 : jestCallFn.type) !== 'test') {
57
59
  return false;
58
60
  }
59
61
 
60
- const isJestEach = (0, _utils2.getNodeName)(node).endsWith('.each');
62
+ const isJestEach = jestCallFn.members.some(s => (0, _utils2.getAccessorValue)(s) === 'each');
61
63
 
62
64
  if (isJestEach && node.callee.type !== _utils.AST_NODE_TYPES.TaggedTemplateExpression) {
63
65
  // isJestEach but not a TaggedTemplateExpression, so this must be
@@ -67,13 +69,9 @@ const isTestCaseCallWithCallbackArg = (node, scope) => {
67
69
  return true;
68
70
  }
69
71
 
70
- if (isJestEach || node.arguments.length >= 2) {
71
- const [, callback] = node.arguments;
72
- const callbackArgIndex = Number(isJestEach);
73
- return callback && (0, _utils2.isFunction)(callback) && callback.params.length === 1 + callbackArgIndex;
74
- }
75
-
76
- return false;
72
+ const [, callback] = node.arguments;
73
+ const callbackArgIndex = Number(isJestEach);
74
+ return callback && (0, _utils2.isFunction)(callback) && callback.params.length === 1 + callbackArgIndex;
77
75
  };
78
76
 
79
77
  const isPromiseMethodThatUsesValue = (node, identifier) => {
@@ -262,7 +260,7 @@ const isDirectlyWithinTestCaseCall = (node, scope) => {
262
260
  var _parent;
263
261
 
264
262
  parent = parent.parent;
265
- return !!(((_parent = parent) === null || _parent === void 0 ? void 0 : _parent.type) === _utils.AST_NODE_TYPES.CallExpression && (0, _utils2.isTestCaseCall)(parent, scope));
263
+ return ((_parent = parent) === null || _parent === void 0 ? void 0 : _parent.type) === _utils.AST_NODE_TYPES.CallExpression && (0, _utils2.isTypeOfJestFnCall)(parent, scope, ['test']);
266
264
  }
267
265
 
268
266
  parent = parent.parent;
@@ -336,7 +334,7 @@ var _default = (0, _utils2.createRule)({
336
334
  // make promises containing expects safe in a test for us to be able to
337
335
  // accurately check, so we just bail out completely if it's present
338
336
  if (inTestCaseWithDoneCallback) {
339
- if ((0, _utils2.isTestCaseCall)(node, context.getScope())) {
337
+ if ((0, _utils2.isTypeOfJestFnCall)(node, context.getScope(), ['test'])) {
340
338
  inTestCaseWithDoneCallback = false;
341
339
  }
342
340
 
@@ -131,8 +131,9 @@ var _default = (0, _utils2.createRule)({
131
131
  var _mustNotMatchPatterns, _mustMatchPatterns$je;
132
132
 
133
133
  const scope = context.getScope();
134
+ const jestFnCall = (0, _utils2.parseJestFnCall)(node, scope);
134
135
 
135
- if (!(0, _utils2.isDescribeCall)(node, scope) && !(0, _utils2.isTestCaseCall)(node, scope)) {
136
+ if ((jestFnCall === null || jestFnCall === void 0 ? void 0 : jestFnCall.type) !== 'describe' && (jestFnCall === null || jestFnCall === void 0 ? void 0 : jestFnCall.type) !== 'test') {
136
137
  return;
137
138
  }
138
139
 
@@ -147,7 +148,7 @@ var _default = (0, _utils2.createRule)({
147
148
  return;
148
149
  }
149
150
 
150
- if (argument.type !== _utils.AST_NODE_TYPES.TemplateLiteral && !(ignoreTypeOfDescribeName && (0, _utils2.isDescribeCall)(node, scope))) {
151
+ if (argument.type !== _utils.AST_NODE_TYPES.TemplateLiteral && !(ignoreTypeOfDescribeName && jestFnCall.type === 'describe')) {
151
152
  context.report({
152
153
  messageId: 'titleMustBeString',
153
154
  loc: argument.loc
@@ -163,7 +164,7 @@ var _default = (0, _utils2.createRule)({
163
164
  context.report({
164
165
  messageId: 'emptyTitle',
165
166
  data: {
166
- jestFunctionName: (0, _utils2.isDescribeCall)(node, scope) ? _utils2.DescribeAlias.describe : _utils2.TestCaseName.test
167
+ jestFunctionName: jestFnCall.type === 'describe' ? _utils2.DescribeAlias.describe : _utils2.TestCaseName.test
167
168
  },
168
169
  node
169
170
  });
@@ -193,10 +194,10 @@ var _default = (0, _utils2.createRule)({
193
194
  });
194
195
  }
195
196
 
196
- const nodeName = trimFXprefix((0, _utils2.getNodeName)(node));
197
+ const unprefixedName = trimFXprefix(jestFnCall.name);
197
198
  const [firstWord] = title.split(' ');
198
199
 
199
- if (firstWord.toLowerCase() === nodeName) {
200
+ if (firstWord.toLowerCase() === unprefixedName) {
200
201
  context.report({
201
202
  messageId: 'duplicatePrefix',
202
203
  node: argument,
@@ -204,7 +205,7 @@ var _default = (0, _utils2.createRule)({
204
205
  });
205
206
  }
206
207
 
207
- const [jestFunctionName] = nodeName.split('.');
208
+ const jestFunctionName = unprefixedName;
208
209
  const [mustNotMatchPattern, mustNotMatchMessage] = (_mustNotMatchPatterns = mustNotMatchPatterns[jestFunctionName]) !== null && _mustNotMatchPatterns !== void 0 ? _mustNotMatchPatterns : [];
209
210
 
210
211
  if (mustNotMatchPattern) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-jest",
3
- "version": "26.3.0",
3
+ "version": "26.4.0",
4
4
  "description": "ESLint rules for Jest",
5
5
  "keywords": [
6
6
  "eslint",