Skip to content

Commit ee2f718

Browse files
nopelessmdjermanovic
andauthoredAug 20, 2023
feat: Allow void in rule no-promise-executor-return (#17282)
* feat: Allow `void` in `no-promise-executor-return` (#17278) * feat: Autofix and suggestions for `no-promise-executor-return` * fix: update behavior for `no-promise-executor-return` * fix: update suggestion behavior * docs: update to match code * docs: misc fixes * fix: refactors * fix: parentheses issues * Update docs/src/rules/no-promise-executor-return.md Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com> * Update docs/src/rules/no-promise-executor-return.md Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com> * Update lib/rules/no-promise-executor-return.js Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com> * fix: adjacent token issue * fix comments --------- Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>
1 parent 9e9edf9 commit ee2f718

File tree

3 files changed

+518
-50
lines changed

3 files changed

+518
-50
lines changed
 

‎docs/src/rules/no-promise-executor-return.md

+47
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ new Promise((resolve, reject) => getSomething((err, data) => {
6363
new Promise(() => {
6464
return 1;
6565
});
66+
67+
new Promise(r => r(1));
6668
```
6769

6870
:::
@@ -74,6 +76,7 @@ Examples of **correct** code for this rule:
7476
```js
7577
/*eslint no-promise-executor-return: "error"*/
7678

79+
// Turn return inline into two lines
7780
new Promise((resolve, reject) => {
7881
if (someCondition) {
7982
resolve(defaultResult);
@@ -88,6 +91,7 @@ new Promise((resolve, reject) => {
8891
});
8992
});
9093

94+
// Add curly braces
9195
new Promise((resolve, reject) => {
9296
getSomething((err, data) => {
9397
if (err) {
@@ -98,7 +102,50 @@ new Promise((resolve, reject) => {
98102
});
99103
});
100104

105+
new Promise(r => { r(1) });
106+
// or just use Promise.resolve
101107
Promise.resolve(1);
102108
```
103109

104110
:::
111+
112+
## Options
113+
114+
This rule takes one option, an object, with the following properties:
115+
116+
* `allowVoid`: If set to `true` (`false` by default), this rule will allow returning void values.
117+
118+
### allowVoid
119+
120+
Examples of **correct** code for this rule with the `{ "allowVoid": true }` option:
121+
122+
::: correct
123+
124+
```js
125+
/*eslint no-promise-executor-return: ["error", { allowVoid: true }]*/
126+
127+
new Promise((resolve, reject) => {
128+
if (someCondition) {
129+
return void resolve(defaultResult);
130+
}
131+
getSomething((err, result) => {
132+
if (err) {
133+
reject(err);
134+
} else {
135+
resolve(result);
136+
}
137+
});
138+
});
139+
140+
new Promise((resolve, reject) => void getSomething((err, data) => {
141+
if (err) {
142+
reject(err);
143+
} else {
144+
resolve(data);
145+
}
146+
}));
147+
148+
new Promise(r => void r(1));
149+
```
150+
151+
:::

‎lib/rules/no-promise-executor-return.js

+154-16
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
//------------------------------------------------------------------------------
1111

1212
const { findVariable } = require("@eslint-community/eslint-utils");
13+
const astUtils = require("./utils/ast-utils");
1314

1415
//------------------------------------------------------------------------------
1516
// Helpers
@@ -59,6 +60,78 @@ function isPromiseExecutor(node, scope) {
5960
isGlobalReference(parent.callee, getOuterScope(scope));
6061
}
6162

63+
/**
64+
* Checks if the given node is a void expression.
65+
* @param {ASTNode} node The node to check.
66+
* @returns {boolean} - `true` if the node is a void expression
67+
*/
68+
function expressionIsVoid(node) {
69+
return node.type === "UnaryExpression" && node.operator === "void";
70+
}
71+
72+
/**
73+
* Fixes the linting error by prepending "void " to the given node
74+
* @param {Object} sourceCode context given by context.sourceCode
75+
* @param {ASTNode} node The node to fix.
76+
* @param {Object} fixer The fixer object provided by ESLint.
77+
* @returns {Array<Object>} - An array of fix objects to apply to the node.
78+
*/
79+
function voidPrependFixer(sourceCode, node, fixer) {
80+
81+
const requiresParens =
82+
83+
// prepending `void ` will fail if the node has a lower precedence than void
84+
astUtils.getPrecedence(node) < astUtils.getPrecedence({ type: "UnaryExpression", operator: "void" }) &&
85+
86+
// check if there are parentheses around the node to avoid redundant parentheses
87+
!astUtils.isParenthesised(sourceCode, node);
88+
89+
// avoid parentheses issues
90+
const returnOrArrowToken = sourceCode.getTokenBefore(
91+
node,
92+
node.parent.type === "ArrowFunctionExpression"
93+
? astUtils.isArrowToken
94+
95+
// isReturnToken
96+
: token => token.type === "Keyword" && token.value === "return"
97+
);
98+
99+
const firstToken = sourceCode.getTokenAfter(returnOrArrowToken);
100+
101+
const prependSpace =
102+
103+
// is return token, as => allows void to be adjacent
104+
returnOrArrowToken.value === "return" &&
105+
106+
// If two tokens (return and "(") are adjacent
107+
returnOrArrowToken.range[1] === firstToken.range[0];
108+
109+
return [
110+
fixer.insertTextBefore(firstToken, `${prependSpace ? " " : ""}void ${requiresParens ? "(" : ""}`),
111+
fixer.insertTextAfter(node, requiresParens ? ")" : "")
112+
];
113+
}
114+
115+
/**
116+
* Fixes the linting error by `wrapping {}` around the given node's body.
117+
* @param {Object} sourceCode context given by context.sourceCode
118+
* @param {ASTNode} node The node to fix.
119+
* @param {Object} fixer The fixer object provided by ESLint.
120+
* @returns {Array<Object>} - An array of fix objects to apply to the node.
121+
*/
122+
function curlyWrapFixer(sourceCode, node, fixer) {
123+
124+
// https://github.com/eslint/eslint/pull/17282#issuecomment-1592795923
125+
const arrowToken = sourceCode.getTokenBefore(node.body, astUtils.isArrowToken);
126+
const firstToken = sourceCode.getTokenAfter(arrowToken);
127+
const lastToken = sourceCode.getLastToken(node);
128+
129+
return [
130+
fixer.insertTextBefore(firstToken, "{"),
131+
fixer.insertTextAfter(lastToken, "}")
132+
];
133+
}
134+
62135
//------------------------------------------------------------------------------
63136
// Rule Definition
64137
//------------------------------------------------------------------------------
@@ -74,37 +147,80 @@ module.exports = {
74147
url: "https://eslint.org/docs/latest/rules/no-promise-executor-return"
75148
},
76149

77-
schema: [],
150+
hasSuggestions: true,
151+
152+
schema: [{
153+
type: "object",
154+
properties: {
155+
allowVoid: {
156+
type: "boolean",
157+
default: false
158+
}
159+
},
160+
additionalProperties: false
161+
}],
78162

79163
messages: {
80-
returnsValue: "Return values from promise executor functions cannot be read."
164+
returnsValue: "Return values from promise executor functions cannot be read.",
165+
166+
// arrow and function suggestions
167+
prependVoid: "Prepend `void` to the expression.",
168+
169+
// only arrow suggestions
170+
wrapBraces: "Wrap the expression in `{}`."
81171
}
82172
},
83173

84174
create(context) {
85175

86176
let funcInfo = null;
87177
const sourceCode = context.sourceCode;
88-
89-
/**
90-
* Reports the given node.
91-
* @param {ASTNode} node Node to report.
92-
* @returns {void}
93-
*/
94-
function report(node) {
95-
context.report({ node, messageId: "returnsValue" });
96-
}
178+
const {
179+
allowVoid = false
180+
} = context.options[0] || {};
97181

98182
return {
99183

100184
onCodePathStart(_, node) {
101185
funcInfo = {
102186
upper: funcInfo,
103-
shouldCheck: functionTypesToCheck.has(node.type) && isPromiseExecutor(node, sourceCode.getScope(node))
187+
shouldCheck:
188+
functionTypesToCheck.has(node.type) &&
189+
isPromiseExecutor(node, sourceCode.getScope(node))
104190
};
105191

106-
if (funcInfo.shouldCheck && node.type === "ArrowFunctionExpression" && node.expression) {
107-
report(node.body);
192+
if (// Is a Promise executor
193+
funcInfo.shouldCheck &&
194+
node.type === "ArrowFunctionExpression" &&
195+
node.expression &&
196+
197+
// Except void
198+
!(allowVoid && expressionIsVoid(node.body))
199+
) {
200+
const suggest = [];
201+
202+
// prevent useless refactors
203+
if (allowVoid) {
204+
suggest.push({
205+
messageId: "prependVoid",
206+
fix(fixer) {
207+
return voidPrependFixer(sourceCode, node.body, fixer);
208+
}
209+
});
210+
}
211+
212+
suggest.push({
213+
messageId: "wrapBraces",
214+
fix(fixer) {
215+
return curlyWrapFixer(sourceCode, node, fixer);
216+
}
217+
});
218+
219+
context.report({
220+
node: node.body,
221+
messageId: "returnsValue",
222+
suggest
223+
});
108224
}
109225
},
110226

@@ -113,9 +229,31 @@ module.exports = {
113229
},
114230

115231
ReturnStatement(node) {
116-
if (funcInfo.shouldCheck && node.argument) {
117-
report(node);
232+
if (!(funcInfo.shouldCheck && node.argument)) {
233+
return;
118234
}
235+
236+
// node is `return <expression>`
237+
if (!allowVoid) {
238+
context.report({ node, messageId: "returnsValue" });
239+
return;
240+
}
241+
242+
if (expressionIsVoid(node.argument)) {
243+
return;
244+
}
245+
246+
// allowVoid && !expressionIsVoid
247+
context.report({
248+
node,
249+
messageId: "returnsValue",
250+
suggest: [{
251+
messageId: "prependVoid",
252+
fix(fixer) {
253+
return voidPrependFixer(sourceCode, node.argument, fixer);
254+
}
255+
}]
256+
});
119257
}
120258
};
121259
}

‎tests/lib/rules/no-promise-executor-return.js

+317-34
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const { RuleTester } = require("../../../lib/rule-tester");
2222
* @param {string} [type="ReturnStatement"] Reported node type.
2323
* @returns {Object} The error object.
2424
*/
25-
function error(column, type = "ReturnStatement") {
25+
function eReturnsValue(column, type = "ReturnStatement") {
2626
const errorObject = {
2727
messageId: "returnsValue",
2828
type
@@ -35,6 +35,26 @@ function error(column, type = "ReturnStatement") {
3535
return errorObject;
3636
}
3737

38+
39+
/**
40+
* Creates invalid object
41+
* @param {Object} [properties] suggestion properties
42+
* @param {string} [properties.code] code
43+
* @param {number} [properties.options] rule options
44+
* @param {string[]} [fixes] Code suggestions
45+
* @returns {Object} The invalid object.
46+
*/
47+
function suggestion(properties, fixes = []) {
48+
return {
49+
...properties,
50+
errors: [{
51+
suggestions: fixes.map(fix => ({
52+
output: fix
53+
}))
54+
}]
55+
};
56+
}
57+
3858
//------------------------------------------------------------------------------
3959
// Tests
4060
//------------------------------------------------------------------------------
@@ -149,7 +169,37 @@ ruleTester.run("no-promise-executor-return", rule, {
149169
{
150170
code: "new Promise(function (resolve, reject) {}); return 1;",
151171
env: { node: true }
152-
}
172+
},
173+
174+
/*
175+
* allowVoid: true
176+
* `=> void` and `return void` are allowed
177+
*/
178+
{
179+
code: "new Promise((r) => void cbf(r));",
180+
options: [{
181+
allowVoid: true
182+
}]
183+
},
184+
{
185+
code: "new Promise(r => void 0)",
186+
options: [{
187+
allowVoid: true
188+
}]
189+
},
190+
{
191+
code: "new Promise(r => { return void 0 })",
192+
options: [{
193+
allowVoid: true
194+
}]
195+
},
196+
{
197+
code: "new Promise(r => { if (foo) { return void 0 } return void 0 })",
198+
options: [{
199+
allowVoid: true
200+
}]
201+
},
202+
"new Promise(r => {0})"
153203
],
154204

155205
invalid: [
@@ -161,143 +211,376 @@ ruleTester.run("no-promise-executor-return", rule, {
161211
},
162212
{
163213
code: "new Promise((resolve, reject) => resolve(1))",
164-
errors: [{ message: "Return values from promise executor functions cannot be read.", type: "CallExpression", column: 34, endColumn: 44 }]
214+
options: [{
215+
allowVoid: true
216+
}],
217+
errors: [{
218+
message: "Return values from promise executor functions cannot be read.",
219+
type: "CallExpression",
220+
column: 34,
221+
endColumn: 44,
222+
suggestions: [
223+
{ output: "new Promise((resolve, reject) => void resolve(1))" },
224+
{ output: "new Promise((resolve, reject) => {resolve(1)})" }
225+
]
226+
}]
227+
},
228+
{
229+
code: "new Promise((resolve, reject) => { return 1 })",
230+
options: [{
231+
allowVoid: true
232+
}],
233+
errors: [{
234+
message: "Return values from promise executor functions cannot be read.",
235+
type: "ReturnStatement",
236+
column: 36,
237+
endColumn: 44,
238+
suggestions: [
239+
{ output: "new Promise((resolve, reject) => { return void 1 })" }
240+
]
241+
}]
165242
},
166243

244+
// suggestions arrow function expression
245+
suggestion({
246+
code: "new Promise(r => 1)",
247+
options: [{
248+
allowVoid: true
249+
}]
250+
}, [
251+
"new Promise(r => void 1)",
252+
"new Promise(r => {1})"
253+
]),
254+
suggestion({
255+
code: "new Promise(r => 1 ? 2 : 3)",
256+
options: [{
257+
allowVoid: true
258+
}]
259+
}, [
260+
"new Promise(r => void (1 ? 2 : 3))",
261+
"new Promise(r => {1 ? 2 : 3})"
262+
]),
263+
suggestion({
264+
code: "new Promise(r => (1 ? 2 : 3))",
265+
options: [{
266+
allowVoid: true
267+
}]
268+
}, [
269+
"new Promise(r => void (1 ? 2 : 3))",
270+
"new Promise(r => {(1 ? 2 : 3)})"
271+
]),
272+
suggestion({
273+
code:
274+
"new Promise(r => (1))",
275+
options: [{
276+
allowVoid: true
277+
}]
278+
}, [
279+
"new Promise(r => void (1))",
280+
"new Promise(r => {(1)})"
281+
]),
282+
suggestion({
283+
code:
284+
"new Promise(r => () => {})",
285+
options: [{
286+
allowVoid: true
287+
}]
288+
}, [
289+
"new Promise(r => void (() => {}))",
290+
"new Promise(r => {() => {}})"
291+
]),
292+
293+
// primitives
294+
suggestion({
295+
code:
296+
"new Promise(r => null)",
297+
options: [{
298+
allowVoid: true
299+
}]
300+
}, [
301+
"new Promise(r => void null)",
302+
"new Promise(r => {null})"
303+
]),
304+
suggestion({
305+
code:
306+
"new Promise(r => null)",
307+
options: [{
308+
allowVoid: false
309+
}]
310+
}, [
311+
"new Promise(r => {null})"
312+
]),
313+
314+
// inline comments
315+
suggestion({
316+
code:
317+
"new Promise(r => /*hi*/ ~0)",
318+
options: [{
319+
allowVoid: true
320+
}]
321+
}, [
322+
"new Promise(r => /*hi*/ void ~0)",
323+
"new Promise(r => /*hi*/ {~0})"
324+
]),
325+
suggestion({
326+
code:
327+
"new Promise(r => /*hi*/ ~0)",
328+
options: [{
329+
allowVoid: false
330+
}]
331+
}, [
332+
"new Promise(r => /*hi*/ {~0})"
333+
]),
334+
335+
// suggestions function
336+
suggestion({
337+
code:
338+
"new Promise(r => { return 0 })",
339+
options: [{
340+
allowVoid: true
341+
}]
342+
}, [
343+
"new Promise(r => { return void 0 })"
344+
]),
345+
suggestion({
346+
code:
347+
"new Promise(r => { return 0 })",
348+
options: [{
349+
allowVoid: false
350+
}]
351+
}),
352+
353+
// multiple returns
354+
suggestion({
355+
code:
356+
"new Promise(r => { if (foo) { return void 0 } return 0 })",
357+
options: [{
358+
allowVoid: true
359+
}]
360+
}, [
361+
"new Promise(r => { if (foo) { return void 0 } return void 0 })"
362+
]),
363+
364+
// return assignment
365+
suggestion({
366+
code: "new Promise(resolve => { return (foo = resolve(1)); })",
367+
options: [{
368+
allowVoid: true
369+
}]
370+
}, [
371+
"new Promise(resolve => { return void (foo = resolve(1)); })"
372+
]),
373+
suggestion({
374+
code: "new Promise(resolve => r = resolve)",
375+
options: [{
376+
allowVoid: true
377+
}]
378+
}, [
379+
"new Promise(resolve => void (r = resolve))",
380+
"new Promise(resolve => {r = resolve})"
381+
]),
382+
383+
// return<immediate token> (range check)
384+
suggestion({
385+
code:
386+
"new Promise(r => { return(1) })",
387+
options: [{
388+
allowVoid: true
389+
}]
390+
}, [
391+
"new Promise(r => { return void (1) })"
392+
]),
393+
suggestion({
394+
code:
395+
"new Promise(r =>1)",
396+
options: [{
397+
allowVoid: true
398+
}]
399+
}, [
400+
"new Promise(r =>void 1)",
401+
"new Promise(r =>{1})"
402+
]),
403+
404+
// snapshot
405+
suggestion({
406+
code:
407+
"new Promise(r => ((1)))",
408+
options: [{
409+
allowVoid: true
410+
}]
411+
}, [
412+
"new Promise(r => void ((1)))",
413+
"new Promise(r => {((1))})"
414+
]),
415+
167416
// other basic tests
168417
{
169418
code: "new Promise(function foo(resolve, reject) { return 1; })",
170-
errors: [error()]
419+
errors: [eReturnsValue()]
171420
},
172421
{
173422
code: "new Promise((resolve, reject) => { return 1; })",
174-
errors: [error()]
423+
errors: [eReturnsValue()]
175424
},
176425

177426
// any returned value
178427
{
179428
code: "new Promise(function (resolve, reject) { return undefined; })",
180-
errors: [error()]
429+
errors: [eReturnsValue()]
181430
},
182431
{
183432
code: "new Promise((resolve, reject) => { return null; })",
184-
errors: [error()]
433+
errors: [eReturnsValue()]
185434
},
186435
{
187436
code: "new Promise(function (resolve, reject) { return false; })",
188-
errors: [error()]
437+
errors: [eReturnsValue()]
189438
},
190439
{
191440
code: "new Promise((resolve, reject) => resolve)",
192-
errors: [error(34, "Identifier")]
441+
errors: [eReturnsValue(34, "Identifier")]
193442
},
194443
{
195444
code: "new Promise((resolve, reject) => null)",
196-
errors: [error(34, "Literal")]
445+
errors: [eReturnsValue(34, "Literal")]
197446
},
198447
{
199448
code: "new Promise(function (resolve, reject) { return resolve(foo); })",
200-
errors: [error()]
449+
errors: [eReturnsValue()]
201450
},
202451
{
203452
code: "new Promise((resolve, reject) => { return reject(foo); })",
204-
errors: [error()]
453+
errors: [eReturnsValue()]
205454
},
206455
{
207456
code: "new Promise((resolve, reject) => x + y)",
208-
errors: [error(34, "BinaryExpression")]
457+
errors: [eReturnsValue(34, "BinaryExpression")]
209458
},
210459
{
211460
code: "new Promise((resolve, reject) => { return Promise.resolve(42); })",
212-
errors: [error()]
461+
errors: [eReturnsValue()]
213462
},
214463

215464
// any return statement location
216465
{
217466
code: "new Promise(function (resolve, reject) { if (foo) { return 1; } })",
218-
errors: [error()]
467+
errors: [eReturnsValue()]
219468
},
220469
{
221470
code: "new Promise((resolve, reject) => { try { return 1; } catch(e) {} })",
222-
errors: [error()]
471+
errors: [eReturnsValue()]
223472
},
224473
{
225474
code: "new Promise(function (resolve, reject) { while (foo){ if (bar) break; else return 1; } })",
226-
errors: [error()]
475+
errors: [eReturnsValue()]
476+
},
477+
478+
// `return void` is not allowed without `allowVoid: true`
479+
{
480+
code: "new Promise(() => { return void 1; })",
481+
errors: [eReturnsValue()]
482+
},
483+
484+
{
485+
code: "new Promise(() => (1))",
486+
errors: [eReturnsValue(20, "Literal")]
487+
},
488+
{
489+
code: "() => new Promise(() => ({}));",
490+
errors: [eReturnsValue(26, "ObjectExpression")]
227491
},
228492

229493
// absence of arguments has no effect
230494
{
231495
code: "new Promise(function () { return 1; })",
232-
errors: [error()]
496+
errors: [eReturnsValue()]
233497
},
234498
{
235499
code: "new Promise(() => { return 1; })",
236-
errors: [error()]
500+
errors: [eReturnsValue()]
237501
},
238502
{
239503
code: "new Promise(() => 1)",
240-
errors: [error(19, "Literal")]
504+
errors: [eReturnsValue(19, "Literal")]
241505
},
242506

243507
// various scope tracking tests
244508
{
245509
code: "function foo() {} new Promise(function () { return 1; });",
246-
errors: [error(45)]
510+
errors: [eReturnsValue(45)]
247511
},
248512
{
249513
code: "function foo() { return; } new Promise(() => { return 1; });",
250-
errors: [error(48)]
514+
errors: [eReturnsValue(48)]
251515
},
252516
{
253517
code: "function foo() { return 1; } new Promise(() => { return 2; });",
254-
errors: [error(50)]
518+
errors: [eReturnsValue(50)]
255519
},
256520
{
257521
code: "function foo () { return new Promise(function () { return 1; }); }",
258-
errors: [error(52)]
522+
errors: [eReturnsValue(52)]
259523
},
260524
{
261525
code: "function foo() { return new Promise(() => { bar(() => { return 1; }); return false; }); }",
262-
errors: [error(71)]
526+
errors: [eReturnsValue(71)]
263527
},
264528
{
265529
code: "() => new Promise(() => { if (foo) { return 0; } else bar(() => { return 1; }); })",
266-
errors: [error(38)]
530+
errors: [eReturnsValue(38)]
267531
},
268532
{
269533
code: "function foo () { return 1; return new Promise(function () { return 2; }); return 3;}",
270-
errors: [error(62)]
534+
errors: [eReturnsValue(62)]
271535
},
272536
{
273537
code: "() => 1; new Promise(() => { return 1; })",
274-
errors: [error(30)]
538+
errors: [eReturnsValue(30)]
275539
},
276540
{
277541
code: "new Promise(function () { return 1; }); function foo() { return 1; } ",
278-
errors: [error(27)]
542+
errors: [eReturnsValue(27)]
279543
},
280544
{
281545
code: "() => new Promise(() => { return 1; });",
282-
errors: [error(27)]
546+
errors: [eReturnsValue(27)]
283547
},
284548
{
285549
code: "() => new Promise(() => 1);",
286-
errors: [error(25, "Literal")]
550+
errors: [eReturnsValue(25, "Literal")]
287551
},
288552
{
289553
code: "() => new Promise(() => () => 1);",
290-
errors: [error(25, "ArrowFunctionExpression")]
554+
errors: [eReturnsValue(25, "ArrowFunctionExpression")]
555+
},
556+
{
557+
code: "() => new Promise(() => async () => 1);",
558+
parserOptions: { ecmaVersion: 2017 },
559+
560+
// for async
561+
errors: [eReturnsValue(25, "ArrowFunctionExpression")]
562+
},
563+
{
564+
code: "() => new Promise(() => function () {});",
565+
errors: [eReturnsValue(25, "FunctionExpression")]
566+
},
567+
{
568+
code: "() => new Promise(() => function foo() {});",
569+
errors: [eReturnsValue(25, "FunctionExpression")]
570+
},
571+
{
572+
code: "() => new Promise(() => []);",
573+
errors: [eReturnsValue(25, "ArrayExpression")]
291574
},
292575

293576
// edge cases for global Promise reference
294577
{
295578
code: "new Promise((Promise) => { return 1; })",
296-
errors: [error()]
579+
errors: [eReturnsValue()]
297580
},
298581
{
299582
code: "new Promise(function Promise(resolve, reject) { return 1; })",
300-
errors: [error()]
583+
errors: [eReturnsValue()]
301584
}
302585
]
303586
});

0 commit comments

Comments
 (0)
Please sign in to comment.