eslint-plugin-jest 25.7.0 → 26.1.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.
Files changed (38) hide show
  1. package/README.md +2 -1
  2. package/docs/rules/no-conditional-in-test.md +79 -0
  3. package/docs/rules/no-if.md +5 -0
  4. package/docs/rules/prefer-snapshot-hint.md +188 -0
  5. package/lib/rules/consistent-test-it.js +20 -20
  6. package/lib/rules/expect-expect.js +9 -9
  7. package/lib/rules/max-nested-describe.js +5 -5
  8. package/lib/rules/no-conditional-expect.js +9 -9
  9. package/lib/rules/no-conditional-in-test.js +60 -0
  10. package/lib/rules/no-deprecated-functions.js +6 -6
  11. package/lib/rules/no-done-callback.js +10 -10
  12. package/lib/rules/no-export.js +6 -6
  13. package/lib/rules/no-focused-tests.js +11 -11
  14. package/lib/rules/no-if.js +13 -11
  15. package/lib/rules/no-interpolation-in-snapshots.js +6 -6
  16. package/lib/rules/no-jasmine-globals.js +10 -10
  17. package/lib/rules/no-large-snapshots.js +8 -8
  18. package/lib/rules/no-standalone-expect.js +14 -14
  19. package/lib/rules/no-test-prefixes.js +6 -6
  20. package/lib/rules/no-test-return-statement.js +8 -8
  21. package/lib/rules/prefer-comparison-matcher.js +10 -10
  22. package/lib/rules/prefer-equality-matcher.js +10 -10
  23. package/lib/rules/prefer-expect-assertions.js +12 -12
  24. package/lib/rules/prefer-expect-resolves.js +4 -4
  25. package/lib/rules/prefer-snapshot-hint.js +112 -0
  26. package/lib/rules/prefer-spy-on.js +9 -9
  27. package/lib/rules/prefer-to-be.js +15 -15
  28. package/lib/rules/prefer-to-contain.js +11 -11
  29. package/lib/rules/prefer-to-have-length.js +6 -6
  30. package/lib/rules/prefer-todo.js +9 -9
  31. package/lib/rules/require-hook.js +12 -12
  32. package/lib/rules/utils.js +27 -27
  33. package/lib/rules/valid-describe-callback.js +9 -9
  34. package/lib/rules/valid-expect-in-promise.js +44 -44
  35. package/lib/rules/valid-expect.js +18 -18
  36. package/lib/rules/valid-title.js +14 -14
  37. package/package.json +9 -7
  38. package/CHANGELOG.md +0 -846
@@ -5,11 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _experimentalUtils = require("@typescript-eslint/experimental-utils");
8
+ var _utils = require("@typescript-eslint/utils");
9
9
 
10
- var _utils = require("./utils");
10
+ var _utils2 = require("./utils");
11
11
 
12
- const isBooleanLiteral = node => node.type === _experimentalUtils.AST_NODE_TYPES.Literal && typeof node.value === 'boolean';
12
+ const isBooleanLiteral = node => node.type === _utils.AST_NODE_TYPES.Literal && typeof node.value === 'boolean';
13
13
 
14
14
  /**
15
15
  * Checks if the given `ParsedExpectMatcher` is a call to one of the equality matchers,
@@ -23,9 +23,9 @@ const isBooleanLiteral = node => node.type === _experimentalUtils.AST_NODE_TYPES
23
23
  *
24
24
  * @return {matcher is ParsedBooleanEqualityMatcher}
25
25
  */
26
- const isBooleanEqualityMatcher = matcher => (0, _utils.isParsedEqualityMatcherCall)(matcher) && isBooleanLiteral((0, _utils.followTypeAssertionChain)(matcher.arguments[0]));
26
+ const isBooleanEqualityMatcher = matcher => (0, _utils2.isParsedEqualityMatcherCall)(matcher) && isBooleanLiteral((0, _utils2.followTypeAssertionChain)(matcher.arguments[0]));
27
27
 
28
- var _default = (0, _utils.createRule)({
28
+ var _default = (0, _utils2.createRule)({
29
29
  name: __filename,
30
30
  meta: {
31
31
  docs: {
@@ -47,7 +47,7 @@ var _default = (0, _utils.createRule)({
47
47
  create(context) {
48
48
  return {
49
49
  CallExpression(node) {
50
- if (!(0, _utils.isExpectCall)(node)) {
50
+ if (!(0, _utils2.isExpectCall)(node)) {
51
51
  return;
52
52
  }
53
53
 
@@ -58,13 +58,13 @@ var _default = (0, _utils.createRule)({
58
58
  },
59
59
  matcher,
60
60
  modifier
61
- } = (0, _utils.parseExpectCall)(node);
61
+ } = (0, _utils2.parseExpectCall)(node);
62
62
 
63
- if (!matcher || (comparison === null || comparison === void 0 ? void 0 : comparison.type) !== _experimentalUtils.AST_NODE_TYPES.BinaryExpression || comparison.operator !== '===' && comparison.operator !== '!==' || !isBooleanEqualityMatcher(matcher)) {
63
+ if (!matcher || (comparison === null || comparison === void 0 ? void 0 : comparison.type) !== _utils.AST_NODE_TYPES.BinaryExpression || comparison.operator !== '===' && comparison.operator !== '!==' || !isBooleanEqualityMatcher(matcher)) {
64
64
  return;
65
65
  }
66
66
 
67
- const matcherValue = (0, _utils.followTypeAssertionChain)(matcher.arguments[0]).value; // we need to negate the expectation if the current expected
67
+ const matcherValue = (0, _utils2.followTypeAssertionChain)(matcher.arguments[0]).value; // we need to negate the expectation if the current expected
68
68
  // value is itself negated by the "not" modifier
69
69
 
70
70
  const addNotModifier = (comparison.operator === '!==' ? !matcherValue : matcherValue) === !!modifier;
@@ -73,7 +73,7 @@ var _default = (0, _utils.createRule)({
73
73
  const sourceCode = context.getSourceCode();
74
74
  return [// replace the comparison argument with the left-hand side of the comparison
75
75
  fixer.replaceText(comparison, sourceCode.getText(comparison.left)), // replace the current matcher & modifier with the preferred matcher
76
- fixer.replaceTextRange([expectCallEnd, matcher.node.range[1]], addNotModifier ? `.${_utils.ModifierName.not}.${equalityMatcher}` : `.${equalityMatcher}`), // replace the matcher argument with the right-hand side of the comparison
76
+ fixer.replaceTextRange([expectCallEnd, matcher.node.range[1]], addNotModifier ? `.${_utils2.ModifierName.not}.${equalityMatcher}` : `.${equalityMatcher}`), // replace the matcher argument with the right-hand side of the comparison
77
77
  fixer.replaceText(matcher.arguments[0], sourceCode.getText(comparison.right))];
78
78
  };
79
79
 
@@ -5,13 +5,13 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _experimentalUtils = require("@typescript-eslint/experimental-utils");
8
+ var _utils = require("@typescript-eslint/utils");
9
9
 
10
- var _utils = require("./utils");
10
+ var _utils2 = require("./utils");
11
11
 
12
- const isExpectAssertionsOrHasAssertionsCall = expression => expression.type === _experimentalUtils.AST_NODE_TYPES.CallExpression && expression.callee.type === _experimentalUtils.AST_NODE_TYPES.MemberExpression && (0, _utils.isSupportedAccessor)(expression.callee.object, 'expect') && (0, _utils.isSupportedAccessor)(expression.callee.property) && ['assertions', 'hasAssertions'].includes((0, _utils.getAccessorValue)(expression.callee.property));
12
+ const isExpectAssertionsOrHasAssertionsCall = expression => expression.type === _utils.AST_NODE_TYPES.CallExpression && expression.callee.type === _utils.AST_NODE_TYPES.MemberExpression && (0, _utils2.isSupportedAccessor)(expression.callee.object, 'expect') && (0, _utils2.isSupportedAccessor)(expression.callee.property) && ['assertions', 'hasAssertions'].includes((0, _utils2.getAccessorValue)(expression.callee.property));
13
13
 
14
- const isFirstLineExprStmt = functionBody => functionBody[0] && functionBody[0].type === _experimentalUtils.AST_NODE_TYPES.ExpressionStatement;
14
+ const isFirstLineExprStmt = functionBody => functionBody[0] && functionBody[0].type === _utils.AST_NODE_TYPES.ExpressionStatement;
15
15
 
16
16
  const suggestRemovingExtraArguments = (args, extraArgsStartAt) => ({
17
17
  messageId: 'suggestRemovingExtraArguments',
@@ -20,7 +20,7 @@ const suggestRemovingExtraArguments = (args, extraArgsStartAt) => ({
20
20
 
21
21
  const suggestions = [['suggestAddingHasAssertions', 'expect.hasAssertions();'], ['suggestAddingAssertions', 'expect.assertions();']];
22
22
 
23
- var _default = (0, _utils.createRule)({
23
+ var _default = (0, _utils2.createRule)({
24
24
  name: __filename,
25
25
  meta: {
26
26
  docs: {
@@ -116,12 +116,12 @@ var _default = (0, _utils.createRule)({
116
116
  'ForOfStatement:exit': exitForLoop,
117
117
 
118
118
  CallExpression(node) {
119
- if ((0, _utils.isTestCaseCall)(node)) {
119
+ if ((0, _utils2.isTestCaseCall)(node)) {
120
120
  inTestCaseCall = true;
121
121
  return;
122
122
  }
123
123
 
124
- if ((0, _utils.isExpectCall)(node) && inTestCaseCall) {
124
+ if ((0, _utils2.isExpectCall)(node) && inTestCaseCall) {
125
125
  if (inForLoop) {
126
126
  hasExpectInLoop = true;
127
127
  }
@@ -133,7 +133,7 @@ var _default = (0, _utils.createRule)({
133
133
  },
134
134
 
135
135
  'CallExpression:exit'(node) {
136
- if (!(0, _utils.isTestCaseCall)(node)) {
136
+ if (!(0, _utils2.isTestCaseCall)(node)) {
137
137
  return;
138
138
  }
139
139
 
@@ -143,7 +143,7 @@ var _default = (0, _utils.createRule)({
143
143
 
144
144
  const [, testFn] = node.arguments;
145
145
 
146
- if (!(0, _utils.isFunction)(testFn) || testFn.body.type !== _experimentalUtils.AST_NODE_TYPES.BlockStatement) {
146
+ if (!(0, _utils2.isFunction)(testFn) || testFn.body.type !== _utils.AST_NODE_TYPES.BlockStatement) {
147
147
  return;
148
148
  }
149
149
 
@@ -181,7 +181,7 @@ var _default = (0, _utils.createRule)({
181
181
  return;
182
182
  }
183
183
 
184
- if ((0, _utils.isSupportedAccessor)(testFuncFirstLine.callee.property, 'hasAssertions')) {
184
+ if ((0, _utils2.isSupportedAccessor)(testFuncFirstLine.callee.property, 'hasAssertions')) {
185
185
  if (testFuncFirstLine.arguments.length) {
186
186
  context.report({
187
187
  messageId: 'hasAssertionsTakesNoArguments',
@@ -193,7 +193,7 @@ var _default = (0, _utils.createRule)({
193
193
  return;
194
194
  }
195
195
 
196
- if (!(0, _utils.hasOnlyOneArgument)(testFuncFirstLine)) {
196
+ if (!(0, _utils2.hasOnlyOneArgument)(testFuncFirstLine)) {
197
197
  let {
198
198
  loc
199
199
  } = testFuncFirstLine.callee.property;
@@ -214,7 +214,7 @@ var _default = (0, _utils.createRule)({
214
214
 
215
215
  const [arg] = testFuncFirstLine.arguments;
216
216
 
217
- if (arg.type === _experimentalUtils.AST_NODE_TYPES.Literal && typeof arg.value === 'number' && Number.isInteger(arg.value)) {
217
+ if (arg.type === _utils.AST_NODE_TYPES.Literal && typeof arg.value === 'number' && Number.isInteger(arg.value)) {
218
218
  return;
219
219
  }
220
220
 
@@ -5,11 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _experimentalUtils = require("@typescript-eslint/experimental-utils");
8
+ var _utils = require("@typescript-eslint/utils");
9
9
 
10
- var _utils = require("./utils");
10
+ var _utils2 = require("./utils");
11
11
 
12
- var _default = (0, _utils.createRule)({
12
+ var _default = (0, _utils2.createRule)({
13
13
  name: __filename,
14
14
  meta: {
15
15
  docs: {
@@ -29,7 +29,7 @@ var _default = (0, _utils.createRule)({
29
29
  CallExpression(node) {
30
30
  const [awaitNode] = node.arguments;
31
31
 
32
- if ((0, _utils.isExpectCall)(node) && (awaitNode === null || awaitNode === void 0 ? void 0 : awaitNode.type) === _experimentalUtils.AST_NODE_TYPES.AwaitExpression) {
32
+ if ((0, _utils2.isExpectCall)(node) && (awaitNode === null || awaitNode === void 0 ? void 0 : awaitNode.type) === _utils.AST_NODE_TYPES.AwaitExpression) {
33
33
  context.report({
34
34
  node: node.arguments[0],
35
35
  messageId: 'expectResolves',
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _utils = require("./utils");
9
+
10
+ const snapshotMatchers = ['toMatchSnapshot', 'toThrowErrorMatchingSnapshot'];
11
+
12
+ const isSnapshotMatcher = matcher => {
13
+ return snapshotMatchers.includes(matcher.name);
14
+ };
15
+
16
+ const isSnapshotMatcherWithoutHint = matcher => {
17
+ var _matcher$arguments;
18
+
19
+ const expectedNumberOfArgumentsWithHint = 1 + Number(matcher.name === 'toMatchSnapshot');
20
+ return ((_matcher$arguments = matcher.arguments) === null || _matcher$arguments === void 0 ? void 0 : _matcher$arguments.length) !== expectedNumberOfArgumentsWithHint;
21
+ };
22
+
23
+ const messages = {
24
+ missingHint: 'You should provide a hint for this snapshot'
25
+ };
26
+
27
+ var _default = (0, _utils.createRule)({
28
+ name: __filename,
29
+ meta: {
30
+ docs: {
31
+ category: 'Best Practices',
32
+ description: 'Prefer including a hint with external snapshots',
33
+ recommended: false
34
+ },
35
+ messages,
36
+ type: 'suggestion',
37
+ schema: [{
38
+ type: 'string',
39
+ enum: ['always', 'multi']
40
+ }]
41
+ },
42
+ defaultOptions: ['multi'],
43
+
44
+ create(context, [mode]) {
45
+ const snapshotMatchers = [];
46
+ let expressionDepth = 0;
47
+
48
+ const reportSnapshotMatchersWithoutHints = () => {
49
+ for (const snapshotMatcher of snapshotMatchers) {
50
+ if (isSnapshotMatcherWithoutHint(snapshotMatcher)) {
51
+ context.report({
52
+ messageId: 'missingHint',
53
+ node: snapshotMatcher.node.property
54
+ });
55
+ }
56
+ }
57
+ };
58
+
59
+ const enterExpression = () => {
60
+ expressionDepth++;
61
+ };
62
+
63
+ const exitExpression = () => {
64
+ expressionDepth--;
65
+
66
+ if (mode === 'always') {
67
+ reportSnapshotMatchersWithoutHints();
68
+ snapshotMatchers.length = 0;
69
+ }
70
+
71
+ if (mode === 'multi' && expressionDepth === 0) {
72
+ if (snapshotMatchers.length > 1) {
73
+ reportSnapshotMatchersWithoutHints();
74
+ }
75
+
76
+ snapshotMatchers.length = 0;
77
+ }
78
+ };
79
+
80
+ return {
81
+ 'Program:exit'() {
82
+ enterExpression();
83
+ exitExpression();
84
+ },
85
+
86
+ FunctionExpression: enterExpression,
87
+ 'FunctionExpression:exit': exitExpression,
88
+ ArrowFunctionExpression: enterExpression,
89
+ 'ArrowFunctionExpression:exit': exitExpression,
90
+
91
+ CallExpression(node) {
92
+ if (!(0, _utils.isExpectCall)(node)) {
93
+ return;
94
+ }
95
+
96
+ const {
97
+ matcher
98
+ } = (0, _utils.parseExpectCall)(node);
99
+
100
+ if (!matcher || !isSnapshotMatcher(matcher)) {
101
+ return;
102
+ }
103
+
104
+ snapshotMatchers.push(matcher);
105
+ }
106
+
107
+ };
108
+ }
109
+
110
+ });
111
+
112
+ exports.default = _default;
@@ -5,16 +5,16 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _experimentalUtils = require("@typescript-eslint/experimental-utils");
8
+ var _utils = require("@typescript-eslint/utils");
9
9
 
10
- var _utils = require("./utils");
10
+ var _utils2 = require("./utils");
11
11
 
12
12
  const findNodeObject = node => {
13
13
  if ('object' in node) {
14
14
  return node.object;
15
15
  }
16
16
 
17
- if (node.callee.type === _experimentalUtils.AST_NODE_TYPES.MemberExpression) {
17
+ if (node.callee.type === _utils.AST_NODE_TYPES.MemberExpression) {
18
18
  return node.callee.object;
19
19
  }
20
20
 
@@ -22,7 +22,7 @@ const findNodeObject = node => {
22
22
  };
23
23
 
24
24
  const getJestFnCall = node => {
25
- if (node.type !== _experimentalUtils.AST_NODE_TYPES.CallExpression && node.type !== _experimentalUtils.AST_NODE_TYPES.MemberExpression) {
25
+ if (node.type !== _utils.AST_NODE_TYPES.CallExpression && node.type !== _utils.AST_NODE_TYPES.MemberExpression) {
26
26
  return null;
27
27
  }
28
28
 
@@ -32,14 +32,14 @@ const getJestFnCall = node => {
32
32
  return null;
33
33
  }
34
34
 
35
- if (obj.type === _experimentalUtils.AST_NODE_TYPES.Identifier) {
36
- return node.type === _experimentalUtils.AST_NODE_TYPES.CallExpression && (0, _utils.getNodeName)(node.callee) === 'jest.fn' ? node : null;
35
+ if (obj.type === _utils.AST_NODE_TYPES.Identifier) {
36
+ return node.type === _utils.AST_NODE_TYPES.CallExpression && (0, _utils2.getNodeName)(node.callee) === 'jest.fn' ? node : null;
37
37
  }
38
38
 
39
39
  return getJestFnCall(obj);
40
40
  };
41
41
 
42
- var _default = (0, _utils.createRule)({
42
+ var _default = (0, _utils2.createRule)({
43
43
  name: __filename,
44
44
  meta: {
45
45
  docs: {
@@ -63,7 +63,7 @@ var _default = (0, _utils.createRule)({
63
63
  left,
64
64
  right
65
65
  } = node;
66
- if (left.type !== _experimentalUtils.AST_NODE_TYPES.MemberExpression) return;
66
+ if (left.type !== _utils.AST_NODE_TYPES.MemberExpression) return;
67
67
  const jestFnCall = getJestFnCall(right);
68
68
  if (!jestFnCall) return;
69
69
  context.report({
@@ -71,7 +71,7 @@ var _default = (0, _utils.createRule)({
71
71
  messageId: 'useJestSpyOn',
72
72
 
73
73
  fix(fixer) {
74
- const leftPropQuote = left.property.type === _experimentalUtils.AST_NODE_TYPES.Identifier ? "'" : '';
74
+ const leftPropQuote = left.property.type === _utils.AST_NODE_TYPES.Identifier ? "'" : '';
75
75
  const [arg] = jestFnCall.arguments;
76
76
  const argSource = arg && context.getSourceCode().getText(arg);
77
77
  const mockImplementation = argSource ? `.mockImplementation(${argSource})` : '.mockImplementation()';
@@ -5,11 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _experimentalUtils = require("@typescript-eslint/experimental-utils");
8
+ var _utils = require("@typescript-eslint/utils");
9
9
 
10
- var _utils = require("./utils");
10
+ var _utils2 = require("./utils");
11
11
 
12
- const isNullLiteral = node => node.type === _experimentalUtils.AST_NODE_TYPES.Literal && node.value === null;
12
+ const isNullLiteral = node => node.type === _utils.AST_NODE_TYPES.Literal && node.value === null;
13
13
  /**
14
14
  * Checks if the given `ParsedEqualityMatcherCall` is a call to one of the equality matchers,
15
15
  * with a `null` literal as the sole argument.
@@ -18,26 +18,26 @@ const isNullLiteral = node => node.type === _experimentalUtils.AST_NODE_TYPES.Li
18
18
 
19
19
  const isNullEqualityMatcher = matcher => isNullLiteral(getFirstArgument(matcher));
20
20
 
21
- const isFirstArgumentIdentifier = (matcher, name) => (0, _utils.isIdentifier)(getFirstArgument(matcher), name);
21
+ const isFirstArgumentIdentifier = (matcher, name) => (0, _utils2.isIdentifier)(getFirstArgument(matcher), name);
22
22
 
23
23
  const shouldUseToBe = matcher => {
24
24
  const firstArg = getFirstArgument(matcher);
25
25
 
26
- if (firstArg.type === _experimentalUtils.AST_NODE_TYPES.Literal) {
26
+ if (firstArg.type === _utils.AST_NODE_TYPES.Literal) {
27
27
  // regex literals are classed as literals, but they're actually objects
28
28
  // which means "toBe" will give different results than other matchers
29
29
  return !('regex' in firstArg);
30
30
  }
31
31
 
32
- return firstArg.type === _experimentalUtils.AST_NODE_TYPES.TemplateLiteral;
32
+ return firstArg.type === _utils.AST_NODE_TYPES.TemplateLiteral;
33
33
  };
34
34
 
35
35
  const getFirstArgument = matcher => {
36
- return (0, _utils.followTypeAssertionChain)(matcher.arguments[0]);
36
+ return (0, _utils2.followTypeAssertionChain)(matcher.arguments[0]);
37
37
  };
38
38
 
39
39
  const reportPreferToBe = (context, whatToBe, matcher, modifier) => {
40
- const modifierNode = (modifier === null || modifier === void 0 ? void 0 : modifier.negation) || (modifier === null || modifier === void 0 ? void 0 : modifier.name) === _utils.ModifierName.not && (modifier === null || modifier === void 0 ? void 0 : modifier.node);
40
+ const modifierNode = (modifier === null || modifier === void 0 ? void 0 : modifier.negation) || (modifier === null || modifier === void 0 ? void 0 : modifier.name) === _utils2.ModifierName.not && (modifier === null || modifier === void 0 ? void 0 : modifier.node);
41
41
  context.report({
42
42
  messageId: `useToBe${whatToBe}`,
43
43
 
@@ -61,7 +61,7 @@ const reportPreferToBe = (context, whatToBe, matcher, modifier) => {
61
61
  });
62
62
  };
63
63
 
64
- var _default = (0, _utils.createRule)({
64
+ var _default = (0, _utils2.createRule)({
65
65
  name: __filename,
66
66
  meta: {
67
67
  docs: {
@@ -85,25 +85,25 @@ var _default = (0, _utils.createRule)({
85
85
  create(context) {
86
86
  return {
87
87
  CallExpression(node) {
88
- if (!(0, _utils.isExpectCall)(node)) {
88
+ if (!(0, _utils2.isExpectCall)(node)) {
89
89
  return;
90
90
  }
91
91
 
92
92
  const {
93
93
  matcher,
94
94
  modifier
95
- } = (0, _utils.parseExpectCall)(node);
95
+ } = (0, _utils2.parseExpectCall)(node);
96
96
 
97
97
  if (!matcher) {
98
98
  return;
99
99
  }
100
100
 
101
- if (((modifier === null || modifier === void 0 ? void 0 : modifier.name) === _utils.ModifierName.not || modifier !== null && modifier !== void 0 && modifier.negation) && ['toBeUndefined', 'toBeDefined'].includes(matcher.name)) {
101
+ if (((modifier === null || modifier === void 0 ? void 0 : modifier.name) === _utils2.ModifierName.not || modifier !== null && modifier !== void 0 && modifier.negation) && ['toBeUndefined', 'toBeDefined'].includes(matcher.name)) {
102
102
  reportPreferToBe(context, matcher.name === 'toBeDefined' ? 'Undefined' : 'Defined', matcher, modifier);
103
103
  return;
104
104
  }
105
105
 
106
- if (!(0, _utils.isParsedEqualityMatcherCall)(matcher)) {
106
+ if (!(0, _utils2.isParsedEqualityMatcherCall)(matcher)) {
107
107
  return;
108
108
  }
109
109
 
@@ -113,7 +113,7 @@ var _default = (0, _utils.createRule)({
113
113
  }
114
114
 
115
115
  if (isFirstArgumentIdentifier(matcher, 'undefined')) {
116
- const name = (modifier === null || modifier === void 0 ? void 0 : modifier.name) === _utils.ModifierName.not || modifier !== null && modifier !== void 0 && modifier.negation ? 'Defined' : 'Undefined';
116
+ const name = (modifier === null || modifier === void 0 ? void 0 : modifier.name) === _utils2.ModifierName.not || modifier !== null && modifier !== void 0 && modifier.negation ? 'Defined' : 'Undefined';
117
117
  reportPreferToBe(context, name, matcher, modifier);
118
118
  return;
119
119
  }
@@ -123,7 +123,7 @@ var _default = (0, _utils.createRule)({
123
123
  return;
124
124
  }
125
125
 
126
- if (shouldUseToBe(matcher) && matcher.name !== _utils.EqualityMatcher.toBe) {
126
+ if (shouldUseToBe(matcher) && matcher.name !== _utils2.EqualityMatcher.toBe) {
127
127
  reportPreferToBe(context, '', matcher);
128
128
  }
129
129
  }
@@ -5,11 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _experimentalUtils = require("@typescript-eslint/experimental-utils");
8
+ var _utils = require("@typescript-eslint/utils");
9
9
 
10
- var _utils = require("./utils");
10
+ var _utils2 = require("./utils");
11
11
 
12
- const isBooleanLiteral = node => node.type === _experimentalUtils.AST_NODE_TYPES.Literal && typeof node.value === 'boolean';
12
+ const isBooleanLiteral = node => node.type === _utils.AST_NODE_TYPES.Literal && typeof node.value === 'boolean';
13
13
 
14
14
  /**
15
15
  * Checks if the given `ParsedExpectMatcher` is a call to one of the equality matchers,
@@ -23,7 +23,7 @@ const isBooleanLiteral = node => node.type === _experimentalUtils.AST_NODE_TYPES
23
23
  *
24
24
  * @return {matcher is ParsedBooleanEqualityMatcher}
25
25
  */
26
- const isBooleanEqualityMatcher = matcher => (0, _utils.isParsedEqualityMatcherCall)(matcher) && isBooleanLiteral((0, _utils.followTypeAssertionChain)(matcher.arguments[0]));
26
+ const isBooleanEqualityMatcher = matcher => (0, _utils2.isParsedEqualityMatcherCall)(matcher) && isBooleanLiteral((0, _utils2.followTypeAssertionChain)(matcher.arguments[0]));
27
27
 
28
28
  /**
29
29
  * Checks if the given `node` is a `CallExpression` representing the calling
@@ -33,10 +33,10 @@ const isBooleanEqualityMatcher = matcher => (0, _utils.isParsedEqualityMatcherCa
33
33
  *
34
34
  * @return {node is FixableIncludesCallExpression}
35
35
  */
36
- const isFixableIncludesCallExpression = node => node.type === _experimentalUtils.AST_NODE_TYPES.CallExpression && node.callee.type === _experimentalUtils.AST_NODE_TYPES.MemberExpression && (0, _utils.isSupportedAccessor)(node.callee.property, 'includes') && (0, _utils.hasOnlyOneArgument)(node); // expect(array.includes(<value>)[not.]{toBe,toEqual}(<boolean>)
36
+ const isFixableIncludesCallExpression = node => node.type === _utils.AST_NODE_TYPES.CallExpression && node.callee.type === _utils.AST_NODE_TYPES.MemberExpression && (0, _utils2.isSupportedAccessor)(node.callee.property, 'includes') && (0, _utils2.hasOnlyOneArgument)(node); // expect(array.includes(<value>)[not.]{toBe,toEqual}(<boolean>)
37
37
 
38
38
 
39
- var _default = (0, _utils.createRule)({
39
+ var _default = (0, _utils2.createRule)({
40
40
  name: __filename,
41
41
  meta: {
42
42
  docs: {
@@ -56,7 +56,7 @@ var _default = (0, _utils.createRule)({
56
56
  create(context) {
57
57
  return {
58
58
  CallExpression(node) {
59
- if (!(0, _utils.isExpectCall)(node)) {
59
+ if (!(0, _utils2.isExpectCall)(node)) {
60
60
  return;
61
61
  }
62
62
 
@@ -67,9 +67,9 @@ var _default = (0, _utils.createRule)({
67
67
  },
68
68
  matcher,
69
69
  modifier
70
- } = (0, _utils.parseExpectCall)(node);
70
+ } = (0, _utils2.parseExpectCall)(node);
71
71
 
72
- if (!matcher || !includesCall || modifier && modifier.name !== _utils.ModifierName.not || !isBooleanEqualityMatcher(matcher) || !isFixableIncludesCallExpression(includesCall)) {
72
+ if (!matcher || !includesCall || modifier && modifier.name !== _utils2.ModifierName.not || !isBooleanEqualityMatcher(matcher) || !isFixableIncludesCallExpression(includesCall)) {
73
73
  return;
74
74
  }
75
75
 
@@ -78,10 +78,10 @@ var _default = (0, _utils.createRule)({
78
78
  const sourceCode = context.getSourceCode(); // we need to negate the expectation if the current expected
79
79
  // value is itself negated by the "not" modifier
80
80
 
81
- const addNotModifier = (0, _utils.followTypeAssertionChain)(matcher.arguments[0]).value === !!modifier;
81
+ const addNotModifier = (0, _utils2.followTypeAssertionChain)(matcher.arguments[0]).value === !!modifier;
82
82
  return [// remove the "includes" call entirely
83
83
  fixer.removeRange([includesCall.callee.property.range[0] - 1, includesCall.range[1]]), // replace the current matcher with "toContain", adding "not" if needed
84
- fixer.replaceTextRange([expectCallEnd, matcher.node.range[1]], addNotModifier ? `.${_utils.ModifierName.not}.toContain` : '.toContain'), // replace the matcher argument with the value from the "includes"
84
+ fixer.replaceTextRange([expectCallEnd, matcher.node.range[1]], addNotModifier ? `.${_utils2.ModifierName.not}.toContain` : '.toContain'), // replace the matcher argument with the value from the "includes"
85
85
  fixer.replaceText(matcher.arguments[0], sourceCode.getText(includesCall.arguments[0]))];
86
86
  },
87
87
 
@@ -5,11 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _experimentalUtils = require("@typescript-eslint/experimental-utils");
8
+ var _utils = require("@typescript-eslint/utils");
9
9
 
10
- var _utils = require("./utils");
10
+ var _utils2 = require("./utils");
11
11
 
12
- var _default = (0, _utils.createRule)({
12
+ var _default = (0, _utils2.createRule)({
13
13
  name: __filename,
14
14
  meta: {
15
15
  docs: {
@@ -29,7 +29,7 @@ var _default = (0, _utils.createRule)({
29
29
  create(context) {
30
30
  return {
31
31
  CallExpression(node) {
32
- if (!(0, _utils.isExpectCall)(node)) {
32
+ if (!(0, _utils2.isExpectCall)(node)) {
33
33
  return;
34
34
  }
35
35
 
@@ -38,9 +38,9 @@ var _default = (0, _utils.createRule)({
38
38
  arguments: [argument]
39
39
  },
40
40
  matcher
41
- } = (0, _utils.parseExpectCall)(node);
41
+ } = (0, _utils2.parseExpectCall)(node);
42
42
 
43
- if (!matcher || !(0, _utils.isParsedEqualityMatcherCall)(matcher) || (argument === null || argument === void 0 ? void 0 : argument.type) !== _experimentalUtils.AST_NODE_TYPES.MemberExpression || !(0, _utils.isSupportedAccessor)(argument.property, 'length')) {
43
+ if (!matcher || !(0, _utils2.isParsedEqualityMatcherCall)(matcher) || (argument === null || argument === void 0 ? void 0 : argument.type) !== _utils.AST_NODE_TYPES.MemberExpression || !(0, _utils2.isSupportedAccessor)(argument.property, 'length')) {
44
44
  return;
45
45
  }
46
46
 
@@ -5,26 +5,26 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _experimentalUtils = require("@typescript-eslint/experimental-utils");
8
+ var _utils = require("@typescript-eslint/utils");
9
9
 
10
- var _utils = require("./utils");
10
+ var _utils2 = require("./utils");
11
11
 
12
12
  function isEmptyFunction(node) {
13
- if (!(0, _utils.isFunction)(node)) {
13
+ if (!(0, _utils2.isFunction)(node)) {
14
14
  return false;
15
15
  }
16
16
 
17
- return node.body.type === _experimentalUtils.AST_NODE_TYPES.BlockStatement && !node.body.body.length;
17
+ return node.body.type === _utils.AST_NODE_TYPES.BlockStatement && !node.body.body.length;
18
18
  }
19
19
 
20
20
  function createTodoFixer(node, fixer) {
21
- const testName = (0, _utils.getNodeName)(node).split('.').shift();
21
+ const testName = (0, _utils2.getNodeName)(node).split('.').shift();
22
22
  return fixer.replaceText(node.callee, `${testName}.todo`);
23
23
  }
24
24
 
25
- const isTargetedTestCase = node => (0, _utils.isTestCaseCall)(node) && [_utils.TestCaseName.it, _utils.TestCaseName.test, 'it.skip', 'test.skip'].includes((0, _utils.getNodeName)(node));
25
+ const isTargetedTestCase = node => (0, _utils2.isTestCaseCall)(node) && [_utils2.TestCaseName.it, _utils2.TestCaseName.test, 'it.skip', 'test.skip'].includes((0, _utils2.getNodeName)(node));
26
26
 
27
- var _default = (0, _utils.createRule)({
27
+ var _default = (0, _utils2.createRule)({
28
28
  name: __filename,
29
29
  meta: {
30
30
  docs: {
@@ -47,7 +47,7 @@ var _default = (0, _utils.createRule)({
47
47
  CallExpression(node) {
48
48
  const [title, callback] = node.arguments;
49
49
 
50
- if (!title || !isTargetedTestCase(node) || !(0, _utils.isStringNode)(title)) {
50
+ if (!title || !isTargetedTestCase(node) || !(0, _utils2.isStringNode)(title)) {
51
51
  return;
52
52
  }
53
53
 
@@ -59,7 +59,7 @@ var _default = (0, _utils.createRule)({
59
59
  });
60
60
  }
61
61
 
62
- if ((0, _utils.hasOnlyOneArgument)(node)) {
62
+ if ((0, _utils2.hasOnlyOneArgument)(node)) {
63
63
  context.report({
64
64
  messageId: 'unimplementedTest',
65
65
  node,