2 title: no-promise-executor-return
6 - no-async-promise-executor
8 - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
12 The `new Promise` constructor accepts a single argument, called an *executor*.
15 const myPromise = new Promise(function executor(resolve, reject) {
16 readFile('foo.txt', function(err, result) {
26 The executor function usually initiates some asynchronous operation. Once it is finished, the executor should call `resolve` with the result, or `reject` if an error occurred.
28 The return value of the executor is ignored. Returning a value from an executor function is a possible error because the returned value cannot be used and it doesn't affect the promise in any way.
32 This rule disallows returning values from Promise executor functions.
34 Only `return` without a value is allowed, as it's a control flow statement.
36 Examples of **incorrect** code for this rule:
41 /*eslint no-promise-executor-return: "error"*/
43 new Promise((resolve, reject) => {
47 getSomething((err, result) => {
56 new Promise((resolve, reject) => getSomething((err, data) => {
71 Examples of **correct** code for this rule:
76 /*eslint no-promise-executor-return: "error"*/
78 new Promise((resolve, reject) => {
80 resolve(defaultResult);
83 getSomething((err, result) => {
92 new Promise((resolve, reject) => {
93 getSomething((err, data) => {