eslint-plugin-jest 26.8.0 → 26.8.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.
@@ -56,7 +56,11 @@ var _default = (0, _utils2.createRule)({
56
56
  ArrowFunctionExpression: onFunctionExpressionEnter,
57
57
 
58
58
  CallExpression(node) {
59
- if (!(0, _utils2.isTypeOfJestFnCall)(node, context, ['expect'])) {
59
+ var _jestFnCall$head$node;
60
+
61
+ const jestFnCall = (0, _utils2.parseJestFnCall)(node, context);
62
+
63
+ if ((jestFnCall === null || jestFnCall === void 0 ? void 0 : jestFnCall.type) !== 'expect' || ((_jestFnCall$head$node = jestFnCall.head.node.parent) === null || _jestFnCall$head$node === void 0 ? void 0 : _jestFnCall$head$node.type) === _utils.AST_NODE_TYPES.MemberExpression) {
60
64
  return;
61
65
  }
62
66
 
@@ -75,13 +75,15 @@ var _default = (0, _utils2.createRule)({
75
75
 
76
76
  return {
77
77
  CallExpression(node) {
78
- var _parseJestFnCall;
78
+ const jestFnCall = (0, _utils2.parseJestFnCall)(node, context);
79
79
 
80
- const {
81
- type: jestFnCallType
82
- } = (_parseJestFnCall = (0, _utils2.parseJestFnCall)(node, context)) !== null && _parseJestFnCall !== void 0 ? _parseJestFnCall : {};
80
+ if ((jestFnCall === null || jestFnCall === void 0 ? void 0 : jestFnCall.type) === 'expect') {
81
+ var _jestFnCall$head$node;
82
+
83
+ 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
+ return;
85
+ }
83
86
 
84
- if (jestFnCallType === 'expect') {
85
87
  const parent = callStack[callStack.length - 1];
86
88
 
87
89
  if (!parent || parent === _utils2.DescribeAlias.describe) {
@@ -94,7 +96,7 @@ var _default = (0, _utils2.createRule)({
94
96
  return;
95
97
  }
96
98
 
97
- if (jestFnCallType === 'test' || isCustomTestBlockFunction(node)) {
99
+ if ((jestFnCall === null || jestFnCall === void 0 ? void 0 : jestFnCall.type) === 'test' || isCustomTestBlockFunction(node)) {
98
100
  callStack.push('test');
99
101
  }
100
102
 
@@ -46,9 +46,7 @@ var _default = (0, _utils2.createRule)({
46
46
  name: __filename,
47
47
  meta: {
48
48
  messages: {
49
- // eslint-disable-next-line eslint-plugin/no-unused-message-ids
50
49
  unbound: DEFAULT_MESSAGE,
51
- // eslint-disable-next-line eslint-plugin/no-unused-message-ids
52
50
  unboundWithoutThisAnnotation: DEFAULT_MESSAGE
53
51
  },
54
52
  schema: [],
@@ -81,6 +81,8 @@ const resolvePossibleAliasedGlobal = (global, context) => {
81
81
  return null;
82
82
  };
83
83
 
84
+ const parseJestFnCallCache = new WeakMap();
85
+
84
86
  const parseJestFnCall = (node, context) => {
85
87
  const jestFnCall = parseJestFnCallWithReason(node, context);
86
88
 
@@ -94,6 +96,20 @@ const parseJestFnCall = (node, context) => {
94
96
  exports.parseJestFnCall = parseJestFnCall;
95
97
 
96
98
  const parseJestFnCallWithReason = (node, context) => {
99
+ let parsedJestFnCall = parseJestFnCallCache.get(node);
100
+
101
+ if (parsedJestFnCall) {
102
+ return parsedJestFnCall;
103
+ }
104
+
105
+ parsedJestFnCall = parseJestFnCallWithReasonInner(node, context);
106
+ parseJestFnCallCache.set(node, parsedJestFnCall);
107
+ return parsedJestFnCall;
108
+ };
109
+
110
+ exports.parseJestFnCallWithReason = parseJestFnCallWithReason;
111
+
112
+ const parseJestFnCallWithReasonInner = (node, context) => {
97
113
  var _resolved$original, _node$parent2, _node$parent3;
98
114
 
99
115
  const chain = getNodeChain(node);
@@ -179,8 +195,6 @@ const parseJestFnCallWithReason = (node, context) => {
179
195
  };
180
196
  };
181
197
 
182
- exports.parseJestFnCallWithReason = parseJestFnCallWithReason;
183
-
184
198
  const findModifiersAndMatcher = members => {
185
199
  const modifiers = [];
186
200
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-jest",
3
- "version": "26.8.0",
3
+ "version": "26.8.3",
4
4
  "description": "ESLint rules for Jest",
5
5
  "keywords": [
6
6
  "eslint",
@@ -120,7 +120,7 @@
120
120
  "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0",
121
121
  "eslint-config-prettier": "^8.3.0",
122
122
  "eslint-plugin-eslint-comments": "^3.1.2",
123
- "eslint-plugin-eslint-plugin": "^5.0.0",
123
+ "eslint-plugin-eslint-plugin": "^4.0.0",
124
124
  "eslint-plugin-import": "^2.25.1",
125
125
  "eslint-plugin-node": "^11.0.0",
126
126
  "eslint-plugin-prettier": "^3.4.1",