eslint-plugin-jest 27.1.2 → 27.1.3

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.
Files changed (60) hide show
  1. package/lib/index.js +8 -16
  2. package/lib/processors/snapshot-processor.js +3 -5
  3. package/lib/rules/consistent-test-it.js +0 -18
  4. package/lib/rules/expect-expect.js +0 -15
  5. package/lib/rules/max-expects.js +0 -16
  6. package/lib/rules/max-nested-describe.js +0 -13
  7. package/lib/rules/no-alias-methods.js +0 -9
  8. package/lib/rules/no-commented-out-tests.js +0 -10
  9. package/lib/rules/no-conditional-expect.js +0 -19
  10. package/lib/rules/no-conditional-in-test.js +0 -9
  11. package/lib/rules/no-deprecated-functions.js +2 -18
  12. package/lib/rules/no-disabled-tests.js +2 -18
  13. package/lib/rules/no-done-callback.js +1 -30
  14. package/lib/rules/no-duplicate-hooks.js +0 -12
  15. package/lib/rules/no-export.js +0 -12
  16. package/lib/rules/no-focused-tests.js +0 -15
  17. package/lib/rules/no-hooks.js +0 -7
  18. package/lib/rules/no-identical-title.js +0 -19
  19. package/lib/rules/no-if.js +0 -24
  20. package/lib/rules/no-interpolation-in-snapshots.js +0 -9
  21. package/lib/rules/no-jasmine-globals.js +0 -22
  22. package/lib/rules/no-large-snapshots.js +2 -20
  23. package/lib/rules/no-mocks-import.js +0 -12
  24. package/lib/rules/no-restricted-jest-methods.js +1 -11
  25. package/lib/rules/no-restricted-matchers.js +0 -11
  26. package/lib/rules/no-standalone-expect.js +7 -33
  27. package/lib/rules/no-test-prefixes.js +0 -12
  28. package/lib/rules/no-test-return-statement.js +0 -12
  29. package/lib/rules/prefer-called-with.js +0 -10
  30. package/lib/rules/prefer-comparison-matcher.js +8 -33
  31. package/lib/rules/prefer-each.js +0 -18
  32. package/lib/rules/prefer-equality-matcher.js +11 -23
  33. package/lib/rules/prefer-expect-assertions.js +4 -51
  34. package/lib/rules/prefer-expect-resolves.js +0 -12
  35. package/lib/rules/prefer-hooks-in-order.js +2 -16
  36. package/lib/rules/prefer-hooks-on-top.js +0 -9
  37. package/lib/rules/prefer-lowercase-title.js +0 -23
  38. package/lib/rules/prefer-mock-promise-shorthand.js +5 -26
  39. package/lib/rules/prefer-snapshot-hint.js +7 -31
  40. package/lib/rules/prefer-spy-on.js +0 -17
  41. package/lib/rules/prefer-strict-equal.js +0 -9
  42. package/lib/rules/prefer-to-be.js +1 -30
  43. package/lib/rules/prefer-to-contain.js +11 -21
  44. package/lib/rules/prefer-to-have-length.js +4 -16
  45. package/lib/rules/prefer-todo.js +2 -18
  46. package/lib/rules/require-hook.js +0 -22
  47. package/lib/rules/require-to-throw-message.js +0 -9
  48. package/lib/rules/require-top-level-describe.js +0 -15
  49. package/lib/rules/unbound-method.js +2 -21
  50. package/lib/rules/utils/accessors.js +6 -18
  51. package/lib/rules/utils/detectJestVersion.js +2 -7
  52. package/lib/rules/utils/followTypeAssertionChain.js +0 -4
  53. package/lib/rules/utils/index.js +0 -10
  54. package/lib/rules/utils/misc.js +2 -46
  55. package/lib/rules/utils/parseJestFnCall.js +39 -114
  56. package/lib/rules/valid-describe-callback.js +0 -17
  57. package/lib/rules/valid-expect-in-promise.js +26 -93
  58. package/lib/rules/valid-expect.js +5 -48
  59. package/lib/rules/valid-title.js +0 -33
  60. package/package.json +1 -1
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _utils = require("@typescript-eslint/utils");
9
-
10
8
  var _utils2 = require("./utils");
11
-
12
9
  var _default = (0, _utils2.createRule)({
13
10
  name: __filename,
14
11
  meta: {
@@ -29,7 +26,6 @@ var _default = (0, _utils2.createRule)({
29
26
  type: 'suggestion'
30
27
  },
31
28
  defaultOptions: [],
32
-
33
29
  create(context) {
34
30
  return {
35
31
  CallExpression(node) {
@@ -37,17 +33,14 @@ var _default = (0, _utils2.createRule)({
37
33
  callee
38
34
  } = node;
39
35
  const calleeName = (0, _utils2.getNodeName)(callee);
40
-
41
36
  if (!calleeName) {
42
37
  return;
43
38
  }
44
-
45
39
  if (calleeName === 'spyOn' || calleeName === 'spyOnProperty' || calleeName === 'fail' || calleeName === 'pending') {
46
40
  if ((0, _utils2.scopeHasLocalReference)(context.getScope(), calleeName)) {
47
41
  // It's a local variable, not a jasmine global.
48
42
  return;
49
43
  }
50
-
51
44
  switch (calleeName) {
52
45
  case 'spyOn':
53
46
  case 'spyOnProperty':
@@ -60,14 +53,12 @@ var _default = (0, _utils2.createRule)({
60
53
  }
61
54
  });
62
55
  break;
63
-
64
56
  case 'fail':
65
57
  context.report({
66
58
  node,
67
59
  messageId: 'illegalFail'
68
60
  });
69
61
  break;
70
-
71
62
  case 'pending':
72
63
  context.report({
73
64
  node,
@@ -75,13 +66,10 @@ var _default = (0, _utils2.createRule)({
75
66
  });
76
67
  break;
77
68
  }
78
-
79
69
  return;
80
70
  }
81
-
82
71
  if (callee.type === _utils.AST_NODE_TYPES.MemberExpression && calleeName.startsWith('jasmine.')) {
83
72
  const functionName = calleeName.replace('jasmine.', '');
84
-
85
73
  if (functionName === 'any' || functionName === 'anything' || functionName === 'arrayContaining' || functionName === 'objectContaining' || functionName === 'stringMatching') {
86
74
  context.report({
87
75
  fix: fixer => [fixer.replaceText(callee.object, 'expect')],
@@ -94,7 +82,6 @@ var _default = (0, _utils2.createRule)({
94
82
  });
95
83
  return;
96
84
  }
97
-
98
85
  if (functionName === 'addMatchers') {
99
86
  context.report({
100
87
  node,
@@ -106,7 +93,6 @@ var _default = (0, _utils2.createRule)({
106
93
  });
107
94
  return;
108
95
  }
109
-
110
96
  if (functionName === 'createSpy') {
111
97
  context.report({
112
98
  node,
@@ -118,27 +104,23 @@ var _default = (0, _utils2.createRule)({
118
104
  });
119
105
  return;
120
106
  }
121
-
122
107
  context.report({
123
108
  node,
124
109
  messageId: 'illegalJasmine'
125
110
  });
126
111
  }
127
112
  },
128
-
129
113
  MemberExpression(node) {
130
114
  if ((0, _utils2.isSupportedAccessor)(node.object, 'jasmine')) {
131
115
  const {
132
116
  parent,
133
117
  property
134
118
  } = node;
135
-
136
119
  if (parent && parent.type === _utils.AST_NODE_TYPES.AssignmentExpression) {
137
120
  if ((0, _utils2.isSupportedAccessor)(property, 'DEFAULT_TIMEOUT_INTERVAL')) {
138
121
  const {
139
122
  right
140
123
  } = parent;
141
-
142
124
  if (right.type === _utils.AST_NODE_TYPES.Literal) {
143
125
  context.report({
144
126
  fix: fixer => [fixer.replaceText(parent, `jest.setTimeout(${right.value})`)],
@@ -148,7 +130,6 @@ var _default = (0, _utils2.createRule)({
148
130
  return;
149
131
  }
150
132
  }
151
-
152
133
  context.report({
153
134
  node,
154
135
  messageId: 'illegalJasmine'
@@ -156,10 +137,7 @@ var _default = (0, _utils2.createRule)({
156
137
  }
157
138
  }
158
139
  }
159
-
160
140
  };
161
141
  }
162
-
163
142
  });
164
-
165
143
  exports.default = _default;
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _path = require("path");
9
-
10
8
  var _utils = require("@typescript-eslint/utils");
11
-
12
9
  var _utils2 = require("./utils");
13
-
14
10
  const reportOnViolation = (context, node, {
15
11
  maxSize: lineLimit = 50,
16
12
  allowedSnapshots = {}
@@ -19,29 +15,23 @@ const reportOnViolation = (context, node, {
19
15
  const endLine = node.loc.end.line;
20
16
  const lineCount = endLine - startLine;
21
17
  const allPathsAreAbsolute = Object.keys(allowedSnapshots).every(_path.isAbsolute);
22
-
23
18
  if (!allPathsAreAbsolute) {
24
19
  throw new Error('All paths for allowedSnapshots must be absolute. You can use JS config and `path.resolve`');
25
20
  }
26
-
27
21
  let isAllowed = false;
28
-
29
22
  if (node.type === _utils.AST_NODE_TYPES.ExpressionStatement && 'left' in node.expression && node.expression.left.type === _utils.AST_NODE_TYPES.MemberExpression && (0, _utils2.isSupportedAccessor)(node.expression.left.property)) {
30
23
  const fileName = context.getFilename();
31
24
  const allowedSnapshotsInFile = allowedSnapshots[fileName];
32
-
33
25
  if (allowedSnapshotsInFile) {
34
26
  const snapshotName = (0, _utils2.getAccessorValue)(node.expression.left.property);
35
27
  isAllowed = allowedSnapshotsInFile.some(name => {
36
28
  if (name instanceof RegExp) {
37
29
  return name.test(snapshotName);
38
30
  }
39
-
40
31
  return snapshotName === name;
41
32
  });
42
33
  }
43
34
  }
44
-
45
35
  if (!isAllowed && lineCount > lineLimit) {
46
36
  context.report({
47
37
  messageId: lineLimit === 0 ? 'noSnapshot' : 'tooLongSnapshots',
@@ -53,7 +43,6 @@ const reportOnViolation = (context, node, {
53
43
  });
54
44
  }
55
45
  };
56
-
57
46
  var _default = (0, _utils2.createRule)({
58
47
  name: __filename,
59
48
  meta: {
@@ -87,35 +76,28 @@ var _default = (0, _utils2.createRule)({
87
76
  }]
88
77
  },
89
78
  defaultOptions: [{}],
90
-
91
79
  create(context, [options]) {
92
80
  if (context.getFilename().endsWith('.snap')) {
93
81
  return {
94
82
  ExpressionStatement(node) {
95
83
  reportOnViolation(context, node, options);
96
84
  }
97
-
98
85
  };
99
86
  }
100
-
101
87
  return {
102
88
  CallExpression(node) {
103
89
  const jestFnCall = (0, _utils2.parseJestFnCall)(node, context);
104
-
105
90
  if ((jestFnCall === null || jestFnCall === void 0 ? void 0 : jestFnCall.type) !== 'expect') {
106
91
  return;
107
92
  }
108
-
109
93
  if (['toMatchInlineSnapshot', 'toThrowErrorMatchingInlineSnapshot'].includes((0, _utils2.getAccessorValue)(jestFnCall.matcher)) && jestFnCall.args.length) {
110
- reportOnViolation(context, jestFnCall.args[0], { ...options,
94
+ reportOnViolation(context, jestFnCall.args[0], {
95
+ ...options,
111
96
  maxSize: options.inlineMaxSize ?? options.maxSize
112
97
  });
113
98
  }
114
99
  }
115
-
116
100
  };
117
101
  }
118
-
119
102
  });
120
-
121
103
  exports.default = _default;
@@ -4,17 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _path = require("path");
9
-
10
8
  var _utils = require("./utils");
11
-
12
9
  const mocksDirName = '__mocks__';
13
-
14
10
  const isMockPath = path => path.split(_path.posix.sep).includes(mocksDirName);
15
-
16
11
  const isMockImportLiteral = expression => (0, _utils.isStringNode)(expression) && isMockPath((0, _utils.getStringValue)(expression));
17
-
18
12
  var _default = (0, _utils.createRule)({
19
13
  name: __filename,
20
14
  meta: {
@@ -30,7 +24,6 @@ var _default = (0, _utils.createRule)({
30
24
  schema: []
31
25
  },
32
26
  defaultOptions: [],
33
-
34
27
  create(context) {
35
28
  return {
36
29
  ImportDeclaration(node) {
@@ -41,10 +34,8 @@ var _default = (0, _utils.createRule)({
41
34
  });
42
35
  }
43
36
  },
44
-
45
37
  'CallExpression[callee.name="require"]'(node) {
46
38
  const [arg] = node.arguments;
47
-
48
39
  if (arg && isMockImportLiteral(arg)) {
49
40
  context.report({
50
41
  node: arg,
@@ -52,10 +43,7 @@ var _default = (0, _utils.createRule)({
52
43
  });
53
44
  }
54
45
  }
55
-
56
46
  };
57
47
  }
58
-
59
48
  });
60
-
61
49
  exports.default = _default;
@@ -4,14 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _utils = require("./utils");
9
-
10
8
  const messages = {
11
9
  restrictedJestMethod: 'Use of `{{ restriction }}` is disallowed',
12
10
  restrictedJestMethodWithMessage: '{{ message }}'
13
11
  };
14
-
15
12
  var _default = (0, _utils.createRule)({
16
13
  name: __filename,
17
14
  meta: {
@@ -30,18 +27,14 @@ var _default = (0, _utils.createRule)({
30
27
  messages
31
28
  },
32
29
  defaultOptions: [{}],
33
-
34
30
  create(context, [restrictedMethods]) {
35
31
  return {
36
32
  CallExpression(node) {
37
33
  const jestFnCall = (0, _utils.parseJestFnCall)(node, context);
38
-
39
- if ((jestFnCall === null || jestFnCall === void 0 ? void 0 : jestFnCall.type) !== 'jest') {
34
+ if ((jestFnCall === null || jestFnCall === void 0 ? void 0 : jestFnCall.type) !== 'jest' || jestFnCall.members.length === 0) {
40
35
  return;
41
36
  }
42
-
43
37
  const method = (0, _utils.getAccessorValue)(jestFnCall.members[0]);
44
-
45
38
  if (method in restrictedMethods) {
46
39
  const message = restrictedMethods[method];
47
40
  context.report({
@@ -57,10 +50,7 @@ var _default = (0, _utils.createRule)({
57
50
  });
58
51
  }
59
52
  }
60
-
61
53
  };
62
54
  }
63
-
64
55
  });
65
-
66
56
  exports.default = _default;
@@ -4,17 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _utils = require("./utils");
9
-
10
8
  const isChainRestricted = (chain, restriction) => {
11
9
  if (_utils.ModifierName.hasOwnProperty(restriction) || restriction.endsWith('.not')) {
12
10
  return chain.startsWith(restriction);
13
11
  }
14
-
15
12
  return chain === restriction;
16
13
  };
17
-
18
14
  var _default = (0, _utils.createRule)({
19
15
  name: __filename,
20
16
  meta: {
@@ -36,18 +32,14 @@ var _default = (0, _utils.createRule)({
36
32
  }
37
33
  },
38
34
  defaultOptions: [{}],
39
-
40
35
  create(context, [restrictedChains]) {
41
36
  return {
42
37
  CallExpression(node) {
43
38
  const jestFnCall = (0, _utils.parseJestFnCall)(node, context);
44
-
45
39
  if ((jestFnCall === null || jestFnCall === void 0 ? void 0 : jestFnCall.type) !== 'expect') {
46
40
  return;
47
41
  }
48
-
49
42
  const chain = jestFnCall.members.map(nod => (0, _utils.getAccessorValue)(nod)).join('.');
50
-
51
43
  for (const [restriction, message] of Object.entries(restrictedChains)) {
52
44
  if (isChainRestricted(chain, restriction)) {
53
45
  context.report({
@@ -65,10 +57,7 @@ var _default = (0, _utils.createRule)({
65
57
  }
66
58
  }
67
59
  }
68
-
69
60
  };
70
61
  }
71
-
72
62
  });
73
-
74
63
  exports.default = _default;
@@ -4,40 +4,35 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _utils = require("@typescript-eslint/utils");
9
-
10
8
  var _utils2 = require("./utils");
11
-
12
9
  const getBlockType = (statement, context) => {
13
10
  const func = statement.parent;
14
- /* istanbul ignore if */
15
11
 
12
+ /* istanbul ignore if */
16
13
  if (!func) {
17
14
  throw new Error(`Unexpected BlockStatement. No parent defined. - please file a github issue at https://github.com/jest-community/eslint-plugin-jest`);
18
- } // functionDeclaration: function func() {}
19
-
15
+ }
20
16
 
17
+ // functionDeclaration: function func() {}
21
18
  if (func.type === _utils.AST_NODE_TYPES.FunctionDeclaration) {
22
19
  return 'function';
23
20
  }
24
-
25
21
  if ((0, _utils2.isFunction)(func) && func.parent) {
26
- const expr = func.parent; // arrow function or function expr
22
+ const expr = func.parent;
27
23
 
24
+ // arrow function or function expr
28
25
  if (expr.type === _utils.AST_NODE_TYPES.VariableDeclarator) {
29
26
  return 'function';
30
- } // if it's not a variable, it will be callExpr, we only care about describe
31
-
27
+ }
32
28
 
29
+ // if it's not a variable, it will be callExpr, we only care about describe
33
30
  if (expr.type === _utils.AST_NODE_TYPES.CallExpression && (0, _utils2.isTypeOfJestFnCall)(expr, context, ['describe'])) {
34
31
  return 'describe';
35
32
  }
36
33
  }
37
-
38
34
  return null;
39
35
  };
40
-
41
36
  var _default = (0, _utils2.createRule)({
42
37
  name: __filename,
43
38
  meta: {
@@ -65,85 +60,64 @@ var _default = (0, _utils2.createRule)({
65
60
  defaultOptions: [{
66
61
  additionalTestBlockFunctions: []
67
62
  }],
68
-
69
63
  create(context, [{
70
64
  additionalTestBlockFunctions = []
71
65
  }]) {
72
66
  const callStack = [];
73
-
74
67
  const isCustomTestBlockFunction = node => additionalTestBlockFunctions.includes((0, _utils2.getNodeName)(node) || '');
75
-
76
68
  return {
77
69
  CallExpression(node) {
78
70
  const jestFnCall = (0, _utils2.parseJestFnCall)(node, context);
79
-
80
71
  if ((jestFnCall === null || jestFnCall === void 0 ? void 0 : jestFnCall.type) === 'expect') {
81
72
  var _jestFnCall$head$node;
82
-
83
73
  if (((_jestFnCall$head$node = jestFnCall.head.node.parent) === null || _jestFnCall$head$node === void 0 ? void 0 : _jestFnCall$head$node.type) === _utils.AST_NODE_TYPES.MemberExpression && jestFnCall.members.length === 1 && !['assertions', 'hasAssertions'].includes((0, _utils2.getAccessorValue)(jestFnCall.members[0]))) {
84
74
  return;
85
75
  }
86
-
87
76
  const parent = callStack[callStack.length - 1];
88
-
89
77
  if (!parent || parent === _utils2.DescribeAlias.describe) {
90
78
  context.report({
91
79
  node,
92
80
  messageId: 'unexpectedExpect'
93
81
  });
94
82
  }
95
-
96
83
  return;
97
84
  }
98
-
99
85
  if ((jestFnCall === null || jestFnCall === void 0 ? void 0 : jestFnCall.type) === 'test' || isCustomTestBlockFunction(node)) {
100
86
  callStack.push('test');
101
87
  }
102
-
103
88
  if (node.callee.type === _utils.AST_NODE_TYPES.TaggedTemplateExpression) {
104
89
  callStack.push('template');
105
90
  }
106
91
  },
107
-
108
92
  'CallExpression:exit'(node) {
109
93
  const top = callStack[callStack.length - 1];
110
-
111
94
  if (top === 'test' && ((0, _utils2.isTypeOfJestFnCall)(node, context, ['test']) || isCustomTestBlockFunction(node)) && node.callee.type !== _utils.AST_NODE_TYPES.MemberExpression || top === 'template' && node.callee.type === _utils.AST_NODE_TYPES.TaggedTemplateExpression) {
112
95
  callStack.pop();
113
96
  }
114
97
  },
115
-
116
98
  BlockStatement(statement) {
117
99
  const blockType = getBlockType(statement, context);
118
-
119
100
  if (blockType) {
120
101
  callStack.push(blockType);
121
102
  }
122
103
  },
123
-
124
104
  'BlockStatement:exit'(statement) {
125
105
  if (callStack[callStack.length - 1] === getBlockType(statement, context)) {
126
106
  callStack.pop();
127
107
  }
128
108
  },
129
-
130
109
  ArrowFunctionExpression(node) {
131
110
  var _node$parent;
132
-
133
111
  if (((_node$parent = node.parent) === null || _node$parent === void 0 ? void 0 : _node$parent.type) !== _utils.AST_NODE_TYPES.CallExpression) {
134
112
  callStack.push('arrow');
135
113
  }
136
114
  },
137
-
138
115
  'ArrowFunctionExpression:exit'() {
139
116
  if (callStack[callStack.length - 1] === 'arrow') {
140
117
  callStack.pop();
141
118
  }
142
119
  }
143
-
144
120
  };
145
121
  }
146
-
147
122
  });
148
-
149
123
  exports.default = _default;
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _utils = require("@typescript-eslint/utils");
9
-
10
8
  var _utils2 = require("./utils");
11
-
12
9
  var _default = (0, _utils2.createRule)({
13
10
  name: __filename,
14
11
  meta: {
@@ -25,20 +22,16 @@ var _default = (0, _utils2.createRule)({
25
22
  type: 'suggestion'
26
23
  },
27
24
  defaultOptions: [],
28
-
29
25
  create(context) {
30
26
  return {
31
27
  CallExpression(node) {
32
28
  const jestFnCall = (0, _utils2.parseJestFnCall)(node, context);
33
-
34
29
  if ((jestFnCall === null || jestFnCall === void 0 ? void 0 : jestFnCall.type) !== 'describe' && (jestFnCall === null || jestFnCall === void 0 ? void 0 : jestFnCall.type) !== 'test') {
35
30
  return;
36
31
  }
37
-
38
32
  if (jestFnCall.name[0] !== 'f' && jestFnCall.name[0] !== 'x') {
39
33
  return;
40
34
  }
41
-
42
35
  const preferredNodeName = [jestFnCall.name.slice(1), jestFnCall.name[0] === 'f' ? 'only' : 'skip', ...jestFnCall.members.map(s => (0, _utils2.getAccessorValue)(s))].join('.');
43
36
  const funcNode = node.callee.type === _utils.AST_NODE_TYPES.TaggedTemplateExpression ? node.callee.tag : node.callee.type === _utils.AST_NODE_TYPES.CallExpression ? node.callee.callee : node.callee;
44
37
  context.report({
@@ -47,17 +40,12 @@ var _default = (0, _utils2.createRule)({
47
40
  data: {
48
41
  preferredNodeName
49
42
  },
50
-
51
43
  fix(fixer) {
52
44
  return [fixer.replaceText(funcNode, preferredNodeName)];
53
45
  }
54
-
55
46
  });
56
47
  }
57
-
58
48
  };
59
49
  }
60
-
61
50
  });
62
-
63
51
  exports.default = _default;
@@ -4,21 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _utils = require("@typescript-eslint/utils");
9
-
10
8
  var _utils2 = require("./utils");
11
-
12
9
  const getBody = args => {
13
10
  const [, secondArg] = args;
14
-
15
11
  if (secondArg && (0, _utils2.isFunction)(secondArg) && secondArg.body.type === _utils.AST_NODE_TYPES.BlockStatement) {
16
12
  return secondArg.body.body;
17
13
  }
18
-
19
14
  return [];
20
15
  };
21
-
22
16
  var _default = (0, _utils2.createRule)({
23
17
  name: __filename,
24
18
  meta: {
@@ -34,14 +28,12 @@ var _default = (0, _utils2.createRule)({
34
28
  type: 'suggestion'
35
29
  },
36
30
  defaultOptions: [],
37
-
38
31
  create(context) {
39
32
  return {
40
33
  CallExpression(node) {
41
34
  if (!(0, _utils2.isTypeOfJestFnCall)(node, context, ['test'])) {
42
35
  return;
43
36
  }
44
-
45
37
  const body = getBody(node.arguments);
46
38
  const returnStmt = body.find(t => t.type === _utils.AST_NODE_TYPES.ReturnStatement);
47
39
  if (!returnStmt) return;
@@ -50,7 +42,6 @@ var _default = (0, _utils2.createRule)({
50
42
  node: returnStmt
51
43
  });
52
44
  },
53
-
54
45
  FunctionDeclaration(node) {
55
46
  const declaredVariables = context.getDeclaredVariables(node);
56
47
  const testCallExpressions = (0, _utils2.getTestCallExpressionsFromDeclaredVariables)(declaredVariables, context);
@@ -62,10 +53,7 @@ var _default = (0, _utils2.createRule)({
62
53
  node: returnStmt
63
54
  });
64
55
  }
65
-
66
56
  };
67
57
  }
68
-
69
58
  });
70
-
71
59
  exports.default = _default;
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _utils = require("./utils");
9
-
10
8
  var _default = (0, _utils.createRule)({
11
9
  name: __filename,
12
10
  meta: {
@@ -22,25 +20,20 @@ var _default = (0, _utils.createRule)({
22
20
  schema: []
23
21
  },
24
22
  defaultOptions: [],
25
-
26
23
  create(context) {
27
24
  return {
28
25
  CallExpression(node) {
29
26
  const jestFnCall = (0, _utils.parseJestFnCall)(node, context);
30
-
31
27
  if ((jestFnCall === null || jestFnCall === void 0 ? void 0 : jestFnCall.type) !== 'expect') {
32
28
  return;
33
29
  }
34
-
35
30
  if (jestFnCall.modifiers.some(nod => (0, _utils.getAccessorValue)(nod) === 'not')) {
36
31
  return;
37
32
  }
38
-
39
33
  const {
40
34
  matcher
41
35
  } = jestFnCall;
42
36
  const matcherName = (0, _utils.getAccessorValue)(matcher);
43
-
44
37
  if (['toBeCalled', 'toHaveBeenCalled'].includes(matcherName)) {
45
38
  context.report({
46
39
  data: {
@@ -51,10 +44,7 @@ var _default = (0, _utils.createRule)({
51
44
  });
52
45
  }
53
46
  }
54
-
55
47
  };
56
48
  }
57
-
58
49
  });
59
-
60
50
  exports.default = _default;