eslint-plugin-jest 26.7.0 → 26.8.7

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.
@@ -26,25 +26,25 @@ var _default = (0, _utils.createRule)({
26
26
  create(context) {
27
27
  return {
28
28
  CallExpression(node) {
29
- var _matcher$arguments;
29
+ const jestFnCall = (0, _utils.parseJestFnCall)(node, context);
30
30
 
31
- if (!(0, _utils.isExpectCall)(node)) {
31
+ if ((jestFnCall === null || jestFnCall === void 0 ? void 0 : jestFnCall.type) !== 'expect') {
32
32
  return;
33
33
  }
34
34
 
35
35
  const {
36
- matcher,
37
- modifier
38
- } = (0, _utils.parseExpectCall)(node);
36
+ matcher
37
+ } = jestFnCall;
38
+ const matcherName = (0, _utils.getAccessorValue)(matcher);
39
39
 
40
- if ((matcher === null || matcher === void 0 ? void 0 : (_matcher$arguments = matcher.arguments) === null || _matcher$arguments === void 0 ? void 0 : _matcher$arguments.length) === 0 && ['toThrow', 'toThrowError'].includes(matcher.name) && (!modifier || !(modifier.name === _utils.ModifierName.not || modifier.negation))) {
40
+ if (jestFnCall.args.length === 0 && ['toThrow', 'toThrowError'].includes(matcherName) && !jestFnCall.modifiers.some(nod => (0, _utils.getAccessorValue)(nod) === 'not')) {
41
41
  // Look for `toThrow` calls with no arguments.
42
42
  context.report({
43
43
  messageId: 'addErrorMessage',
44
44
  data: {
45
- matcherName: matcher.name
45
+ matcherName
46
46
  },
47
- node: matcher.node.property
47
+ node: matcher
48
48
  });
49
49
  }
50
50
  }
@@ -5,25 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _utils = require("./utils");
8
+ var _utils = require("@typescript-eslint/utils");
9
9
 
10
- const toThrowMatchers = ['toThrow', 'toThrowError', 'toThrowErrorMatchingSnapshot', 'toThrowErrorMatchingInlineSnapshot'];
11
-
12
- const isJestExpectToThrowCall = node => {
13
- if (!(0, _utils.isExpectCall)(node)) {
14
- return false;
15
- }
16
-
17
- const {
18
- matcher
19
- } = (0, _utils.parseExpectCall)(node);
20
-
21
- if (!matcher) {
22
- return false;
23
- }
10
+ var _utils2 = require("./utils");
24
11
 
25
- return !toThrowMatchers.includes(matcher.name);
26
- };
12
+ const toThrowMatchers = ['toThrow', 'toThrowError', 'toThrowErrorMatchingSnapshot', 'toThrowErrorMatchingInlineSnapshot'];
27
13
 
28
14
  const baseRule = (() => {
29
15
  try {
@@ -52,7 +38,7 @@ const tryCreateBaseRule = context => {
52
38
 
53
39
  const DEFAULT_MESSAGE = 'This rule requires `@typescript-eslint/eslint-plugin`';
54
40
 
55
- var _default = (0, _utils.createRule)({
41
+ var _default = (0, _utils2.createRule)({
56
42
  defaultOptions: [{
57
43
  ignoreStatic: false
58
44
  }],
@@ -60,9 +46,7 @@ var _default = (0, _utils.createRule)({
60
46
  name: __filename,
61
47
  meta: {
62
48
  messages: {
63
- // eslint-disable-next-line eslint-plugin/no-unused-message-ids
64
49
  unbound: DEFAULT_MESSAGE,
65
- // eslint-disable-next-line eslint-plugin/no-unused-message-ids
66
50
  unboundWithoutThisAnnotation: DEFAULT_MESSAGE
67
51
  },
68
52
  schema: [],
@@ -84,24 +68,23 @@ var _default = (0, _utils.createRule)({
84
68
  return {};
85
69
  }
86
70
 
87
- let inExpectToThrowCall = false;
88
71
  return { ...baseSelectors,
89
72
 
90
- CallExpression(node) {
91
- inExpectToThrowCall = isJestExpectToThrowCall(node);
92
- },
73
+ MemberExpression(node) {
74
+ var _node$parent, _baseSelectors$Member;
93
75
 
94
- 'CallExpression:exit'(node) {
95
- if (inExpectToThrowCall && isJestExpectToThrowCall(node)) {
96
- inExpectToThrowCall = false;
97
- }
98
- },
76
+ if (((_node$parent = node.parent) === null || _node$parent === void 0 ? void 0 : _node$parent.type) === _utils.AST_NODE_TYPES.CallExpression) {
77
+ const jestFnCall = (0, _utils2.parseJestFnCall)((0, _utils2.findTopMostCallExpression)(node.parent), context);
99
78
 
100
- MemberExpression(node) {
101
- var _baseSelectors$Member;
79
+ if ((jestFnCall === null || jestFnCall === void 0 ? void 0 : jestFnCall.type) === 'expect') {
80
+ const {
81
+ matcher
82
+ } = jestFnCall;
102
83
 
103
- if (inExpectToThrowCall) {
104
- return;
84
+ if (!toThrowMatchers.includes((0, _utils2.getAccessorValue)(matcher))) {
85
+ return;
86
+ }
87
+ }
105
88
  }
106
89
 
107
90
  (_baseSelectors$Member = baseSelectors.MemberExpression) === null || _baseSelectors$Member === void 0 ? void 0 : _baseSelectors$Member.call(baseSelectors, node);
@@ -67,17 +67,4 @@ Object.keys(_parseJestFnCall).forEach(function (key) {
67
67
  return _parseJestFnCall[key];
68
68
  }
69
69
  });
70
- });
71
-
72
- var _parseExpectCall = require("./parseExpectCall");
73
-
74
- Object.keys(_parseExpectCall).forEach(function (key) {
75
- if (key === "default" || key === "__esModule") return;
76
- if (key in exports && exports[key] === _parseExpectCall[key]) return;
77
- Object.defineProperty(exports, key, {
78
- enumerable: true,
79
- get: function () {
80
- return _parseExpectCall[key];
81
- }
82
- });
83
70
  });
@@ -3,9 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.createRule = exports.TestCaseName = exports.HookName = exports.DescribeAlias = void 0;
6
+ exports.getFirstMatcherArg = exports.findTopMostCallExpression = exports.createRule = exports.TestCaseName = exports.ModifierName = exports.HookName = exports.EqualityMatcher = exports.DescribeAlias = void 0;
7
7
  exports.getNodeName = getNodeName;
8
- exports.replaceAccessorFixer = exports.isFunction = exports.hasOnlyOneArgument = exports.getTestCallExpressionsFromDeclaredVariables = void 0;
8
+ exports.replaceAccessorFixer = exports.isFunction = exports.isBooleanLiteral = exports.hasOnlyOneArgument = exports.getTestCallExpressionsFromDeclaredVariables = void 0;
9
9
 
10
10
  var _path = require("path");
11
11
 
@@ -15,6 +15,8 @@ var _package = require("../../../package.json");
15
15
 
16
16
  var _accessors = require("./accessors");
17
17
 
18
+ var _followTypeAssertionChain = require("./followTypeAssertionChain");
19
+
18
20
  var _parseJestFnCall = require("./parseJestFnCall");
19
21
 
20
22
  const REPO_URL = 'https://github.com/jest-community/eslint-plugin-jest';
@@ -70,6 +72,24 @@ exports.HookName = HookName;
70
72
  HookName["afterEach"] = "afterEach";
71
73
  })(HookName || (exports.HookName = HookName = {}));
72
74
 
75
+ let ModifierName;
76
+ exports.ModifierName = ModifierName;
77
+
78
+ (function (ModifierName) {
79
+ ModifierName["not"] = "not";
80
+ ModifierName["rejects"] = "rejects";
81
+ ModifierName["resolves"] = "resolves";
82
+ })(ModifierName || (exports.ModifierName = ModifierName = {}));
83
+
84
+ let EqualityMatcher;
85
+ exports.EqualityMatcher = EqualityMatcher;
86
+
87
+ (function (EqualityMatcher) {
88
+ EqualityMatcher["toBe"] = "toBe";
89
+ EqualityMatcher["toEqual"] = "toEqual";
90
+ EqualityMatcher["toStrictEqual"] = "toStrictEqual";
91
+ })(EqualityMatcher || (exports.EqualityMatcher = EqualityMatcher = {}));
92
+
73
93
  const joinNames = (a, b) => a && b ? `${a}.${b}` : null;
74
94
 
75
95
  function getNodeName(node) {
@@ -117,4 +137,45 @@ const replaceAccessorFixer = (fixer, node, text) => {
117
137
  return fixer.replaceText(node, node.type === _utils.AST_NODE_TYPES.Identifier ? text : `'${text}'`);
118
138
  };
119
139
 
120
- exports.replaceAccessorFixer = replaceAccessorFixer;
140
+ exports.replaceAccessorFixer = replaceAccessorFixer;
141
+
142
+ const findTopMostCallExpression = node => {
143
+ let topMostCallExpression = node;
144
+ let {
145
+ parent
146
+ } = node;
147
+
148
+ while (parent) {
149
+ if (parent.type === _utils.AST_NODE_TYPES.CallExpression) {
150
+ topMostCallExpression = parent;
151
+ parent = parent.parent;
152
+ continue;
153
+ }
154
+
155
+ if (parent.type !== _utils.AST_NODE_TYPES.MemberExpression) {
156
+ break;
157
+ }
158
+
159
+ parent = parent.parent;
160
+ }
161
+
162
+ return topMostCallExpression;
163
+ };
164
+
165
+ exports.findTopMostCallExpression = findTopMostCallExpression;
166
+
167
+ const isBooleanLiteral = node => node.type === _utils.AST_NODE_TYPES.Literal && typeof node.value === 'boolean';
168
+
169
+ exports.isBooleanLiteral = isBooleanLiteral;
170
+
171
+ const getFirstMatcherArg = expectFnCall => {
172
+ const [firstArg] = expectFnCall.args;
173
+
174
+ if (firstArg.type === _utils.AST_NODE_TYPES.SpreadElement) {
175
+ return firstArg;
176
+ }
177
+
178
+ return (0, _followTypeAssertionChain.followTypeAssertionChain)(firstArg);
179
+ };
180
+
181
+ exports.getFirstMatcherArg = getFirstMatcherArg;
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getNodeChain = getNodeChain;
7
- exports.scopeHasLocalReference = exports.parseJestFnCall = exports.isTypeOfJestFnCall = void 0;
7
+ exports.scopeHasLocalReference = exports.parseJestFnCallWithReason = exports.parseJestFnCall = exports.isTypeOfJestFnCall = void 0;
8
8
 
9
9
  var _utils = require("@typescript-eslint/utils");
10
10
 
@@ -39,9 +39,10 @@ function getNodeChain(node) {
39
39
  }
40
40
 
41
41
  const determineJestFnType = name => {
42
- // if (name === 'expect') {
43
- // return 'expect';
44
- // }
42
+ if (name === 'expect') {
43
+ return 'expect';
44
+ }
45
+
45
46
  if (name === 'jest') {
46
47
  return 'jest';
47
48
  }
@@ -80,28 +81,40 @@ const resolvePossibleAliasedGlobal = (global, context) => {
80
81
  return null;
81
82
  };
82
83
 
84
+ const parseJestFnCallCache = new WeakMap();
85
+
83
86
  const parseJestFnCall = (node, context) => {
84
- var _node$parent, _node$parent2, _resolved$original;
87
+ const jestFnCall = parseJestFnCallWithReason(node, context);
85
88
 
86
- // ensure that we're at the "top" of the function call chain otherwise when
87
- // parsing e.g. x().y.z(), we'll incorrectly find & parse "x()" even though
88
- // the full chain is not a valid jest function call chain
89
- if (((_node$parent = node.parent) === null || _node$parent === void 0 ? void 0 : _node$parent.type) === _utils.AST_NODE_TYPES.CallExpression || ((_node$parent2 = node.parent) === null || _node$parent2 === void 0 ? void 0 : _node$parent2.type) === _utils.AST_NODE_TYPES.MemberExpression) {
89
+ if (typeof jestFnCall === 'string') {
90
90
  return null;
91
91
  }
92
92
 
93
- const chain = getNodeChain(node);
93
+ return jestFnCall;
94
+ };
94
95
 
95
- if (!(chain !== null && chain !== void 0 && chain.length)) {
96
- return null;
97
- } // check that every link in the chain except the last is a member expression
96
+ exports.parseJestFnCall = parseJestFnCall;
98
97
 
98
+ const parseJestFnCallWithReason = (node, context) => {
99
+ let parsedJestFnCall = parseJestFnCallCache.get(node);
99
100
 
100
- if (chain.slice(0, chain.length - 1).some(nod => {
101
- var _nod$parent;
101
+ if (parsedJestFnCall) {
102
+ return parsedJestFnCall;
103
+ }
102
104
 
103
- return ((_nod$parent = nod.parent) === null || _nod$parent === void 0 ? void 0 : _nod$parent.type) !== _utils.AST_NODE_TYPES.MemberExpression;
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) => {
113
+ var _resolved$original, _node$parent2, _node$parent3;
114
+
115
+ const chain = getNodeChain(node);
116
+
117
+ if (!(chain !== null && chain !== void 0 && chain.length)) {
105
118
  return null;
106
119
  }
107
120
 
@@ -127,21 +140,119 @@ const parseJestFnCall = (node, context) => {
127
140
  const name = (_resolved$original = resolved.original) !== null && _resolved$original !== void 0 ? _resolved$original : resolved.local;
128
141
  const links = [name, ...rest.map(link => (0, _utils2.getAccessorValue)(link))];
129
142
 
130
- if (name !== 'jest' && !ValidJestFnCallChains.includes(links.join('.'))) {
143
+ if (name !== 'jest' && name !== 'expect' && !ValidJestFnCallChains.includes(links.join('.'))) {
131
144
  return null;
132
145
  }
133
146
 
134
- return {
147
+ const parsedJestFnCall = {
135
148
  name,
136
- type: determineJestFnType(name),
137
149
  head: { ...resolved,
138
150
  node: first
139
151
  },
152
+ // every member node must have a member expression as their parent
153
+ // in order to be part of the call chain we're parsing
140
154
  members: rest
141
155
  };
156
+ const type = determineJestFnType(name);
157
+
158
+ if (type === 'expect') {
159
+ const result = parseJestExpectCall(parsedJestFnCall); // if the `expect` call chain is not valid, only report on the topmost node
160
+ // since all members in the chain are likely to get flagged for some reason
161
+
162
+ if (typeof result === 'string' && (0, _utils2.findTopMostCallExpression)(node) !== node) {
163
+ return null;
164
+ }
165
+
166
+ if (result === 'matcher-not-found') {
167
+ var _node$parent;
168
+
169
+ if (((_node$parent = node.parent) === null || _node$parent === void 0 ? void 0 : _node$parent.type) === _utils.AST_NODE_TYPES.MemberExpression) {
170
+ return 'matcher-not-called';
171
+ }
172
+ }
173
+
174
+ return result;
175
+ } // check that every link in the chain except the last is a member expression
176
+
177
+
178
+ if (chain.slice(0, chain.length - 1).some(nod => {
179
+ var _nod$parent;
180
+
181
+ return ((_nod$parent = nod.parent) === null || _nod$parent === void 0 ? void 0 : _nod$parent.type) !== _utils.AST_NODE_TYPES.MemberExpression;
182
+ })) {
183
+ return null;
184
+ } // ensure that we're at the "top" of the function call chain otherwise when
185
+ // parsing e.g. x().y.z(), we'll incorrectly find & parse "x()" even though
186
+ // the full chain is not a valid jest function call chain
187
+
188
+
189
+ if (((_node$parent2 = node.parent) === null || _node$parent2 === void 0 ? void 0 : _node$parent2.type) === _utils.AST_NODE_TYPES.CallExpression || ((_node$parent3 = node.parent) === null || _node$parent3 === void 0 ? void 0 : _node$parent3.type) === _utils.AST_NODE_TYPES.MemberExpression) {
190
+ return null;
191
+ }
192
+
193
+ return { ...parsedJestFnCall,
194
+ type
195
+ };
142
196
  };
143
197
 
144
- exports.parseJestFnCall = parseJestFnCall;
198
+ const findModifiersAndMatcher = members => {
199
+ const modifiers = [];
200
+
201
+ for (const member of members) {
202
+ var _member$parent, _member$parent$parent;
203
+
204
+ // check if the member is being called, which means it is the matcher
205
+ // (and also the end of the entire "expect" call chain)
206
+ if (((_member$parent = member.parent) === null || _member$parent === void 0 ? void 0 : _member$parent.type) === _utils.AST_NODE_TYPES.MemberExpression && ((_member$parent$parent = member.parent.parent) === null || _member$parent$parent === void 0 ? void 0 : _member$parent$parent.type) === _utils.AST_NODE_TYPES.CallExpression) {
207
+ return {
208
+ matcher: member,
209
+ args: member.parent.parent.arguments,
210
+ modifiers
211
+ };
212
+ } // otherwise, it should be a modifier
213
+
214
+
215
+ const name = (0, _utils2.getAccessorValue)(member);
216
+
217
+ if (modifiers.length === 0) {
218
+ // the first modifier can be any of the three modifiers
219
+ if (!_utils2.ModifierName.hasOwnProperty(name)) {
220
+ return 'modifier-unknown';
221
+ }
222
+ } else if (modifiers.length === 1) {
223
+ // the second modifier can only be "not"
224
+ if (name !== _utils2.ModifierName.not) {
225
+ return 'modifier-unknown';
226
+ }
227
+
228
+ const firstModifier = (0, _utils2.getAccessorValue)(modifiers[0]); // and the first modifier has to be either "resolves" or "rejects"
229
+
230
+ if (firstModifier !== _utils2.ModifierName.resolves && firstModifier !== _utils2.ModifierName.rejects) {
231
+ return 'modifier-unknown';
232
+ }
233
+ } else {
234
+ return 'modifier-unknown';
235
+ }
236
+
237
+ modifiers.push(member);
238
+ } // this will only really happen if there are no members
239
+
240
+
241
+ return 'matcher-not-found';
242
+ };
243
+
244
+ const parseJestExpectCall = typelessParsedJestFnCall => {
245
+ const modifiersAndMatcher = findModifiersAndMatcher(typelessParsedJestFnCall.members);
246
+
247
+ if (typeof modifiersAndMatcher === 'string') {
248
+ return modifiersAndMatcher;
249
+ }
250
+
251
+ return { ...typelessParsedJestFnCall,
252
+ type: 'expect',
253
+ ...modifiersAndMatcher
254
+ };
255
+ };
145
256
 
146
257
  const describeImportDefAsImport = def => {
147
258
  if (def.parent.type === _utils.AST_NODE_TYPES.TSImportEqualsDeclaration) {
@@ -29,29 +29,6 @@ const isPromiseChainCall = node => {
29
29
  return false;
30
30
  };
31
31
 
32
- const findTopMostCallExpression = node => {
33
- let topMostCallExpression = node;
34
- let {
35
- parent
36
- } = node;
37
-
38
- while (parent) {
39
- if (parent.type === _utils.AST_NODE_TYPES.CallExpression) {
40
- topMostCallExpression = parent;
41
- parent = parent.parent;
42
- continue;
43
- }
44
-
45
- if (parent.type !== _utils.AST_NODE_TYPES.MemberExpression) {
46
- break;
47
- }
48
-
49
- parent = parent.parent;
50
- }
51
-
52
- return topMostCallExpression;
53
- };
54
-
55
32
  const isTestCaseCallWithCallbackArg = (node, context) => {
56
33
  const jestCallFn = (0, _utils2.parseJestFnCall)(node, context);
57
34
 
@@ -173,7 +150,7 @@ const getLeftMostCallExpression = call => {
173
150
  */
174
151
 
175
152
 
176
- const isValueAwaitedOrReturned = (identifier, body) => {
153
+ const isValueAwaitedOrReturned = (identifier, body, context) => {
177
154
  const {
178
155
  name
179
156
  } = identifier;
@@ -197,13 +174,13 @@ const isValueAwaitedOrReturned = (identifier, body) => {
197
174
  }
198
175
 
199
176
  const leftMostCall = getLeftMostCallExpression(node.expression);
177
+ const jestFnCall = (0, _utils2.parseJestFnCall)(node.expression, context);
200
178
 
201
- if ((0, _utils2.isExpectCall)(leftMostCall) && leftMostCall.arguments.length > 0 && (0, _utils2.isIdentifier)(leftMostCall.arguments[0], name)) {
202
- const {
203
- modifier
204
- } = (0, _utils2.parseExpectCall)(leftMostCall);
205
-
206
- if ((modifier === null || modifier === void 0 ? void 0 : modifier.name) === _utils2.ModifierName.resolves || (modifier === null || modifier === void 0 ? void 0 : modifier.name) === _utils2.ModifierName.rejects) {
179
+ if ((jestFnCall === null || jestFnCall === void 0 ? void 0 : jestFnCall.type) === 'expect' && leftMostCall.arguments.length > 0 && (0, _utils2.isIdentifier)(leftMostCall.arguments[0], name)) {
180
+ if (jestFnCall.members.some(m => {
181
+ const v = (0, _utils2.getAccessorValue)(m);
182
+ return v === _utils2.ModifierName.resolves || v === _utils2.ModifierName.rejects;
183
+ })) {
207
184
  return true;
208
185
  }
209
186
  }
@@ -228,7 +205,7 @@ const isValueAwaitedOrReturned = (identifier, body) => {
228
205
  }
229
206
  }
230
207
 
231
- if (node.type === _utils.AST_NODE_TYPES.BlockStatement && isValueAwaitedOrReturned(identifier, node.body)) {
208
+ if (node.type === _utils.AST_NODE_TYPES.BlockStatement && isValueAwaitedOrReturned(identifier, node.body, context)) {
232
209
  return true;
233
210
  }
234
211
  }
@@ -269,7 +246,7 @@ const isDirectlyWithinTestCaseCall = (node, context) => {
269
246
  return false;
270
247
  };
271
248
 
272
- const isVariableAwaitedOrReturned = variable => {
249
+ const isVariableAwaitedOrReturned = (variable, context) => {
273
250
  const body = findFirstBlockBodyUp(variable); // it's pretty much impossible for us to track destructuring assignments,
274
251
  // so we return true to bailout gracefully
275
252
 
@@ -277,7 +254,7 @@ const isVariableAwaitedOrReturned = variable => {
277
254
  return true;
278
255
  }
279
256
 
280
- return isValueAwaitedOrReturned(variable.id, body);
257
+ return isValueAwaitedOrReturned(variable.id, body, context);
281
258
  };
282
259
 
283
260
  var _default = (0, _utils2.createRule)({
@@ -324,7 +301,7 @@ var _default = (0, _utils2.createRule)({
324
301
  // an expect call, mark the deepest chain as having an expect call
325
302
 
326
303
 
327
- if (chains.length > 0 && (0, _utils2.isExpectCall)(node)) {
304
+ if (chains.length > 0 && (0, _utils2.isTypeOfJestFnCall)(node, context, ['expect'])) {
328
305
  chains[0] = true;
329
306
  }
330
307
  },
@@ -356,7 +333,7 @@ var _default = (0, _utils2.createRule)({
356
333
 
357
334
  const {
358
335
  parent
359
- } = findTopMostCallExpression(node); // if we don't have a parent (which is technically impossible at runtime)
336
+ } = (0, _utils2.findTopMostCallExpression)(node); // if we don't have a parent (which is technically impossible at runtime)
360
337
  // or our parent is not directly within the test case, we stop checking
361
338
  // because we're most likely in the body of a function being defined
362
339
  // within the test, which we can't track
@@ -368,7 +345,7 @@ var _default = (0, _utils2.createRule)({
368
345
  switch (parent.type) {
369
346
  case _utils.AST_NODE_TYPES.VariableDeclarator:
370
347
  {
371
- if (isVariableAwaitedOrReturned(parent)) {
348
+ if (isVariableAwaitedOrReturned(parent, context)) {
372
349
  return;
373
350
  }
374
351
 
@@ -377,7 +354,7 @@ var _default = (0, _utils2.createRule)({
377
354
 
378
355
  case _utils.AST_NODE_TYPES.AssignmentExpression:
379
356
  {
380
- if (parent.left.type === _utils.AST_NODE_TYPES.Identifier && isValueAwaitedOrReturned(parent.left, findFirstBlockBodyUp(parent))) {
357
+ if (parent.left.type === _utils.AST_NODE_TYPES.Identifier && isValueAwaitedOrReturned(parent.left, findFirstBlockBodyUp(parent), context)) {
381
358
  return;
382
359
  }
383
360