You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Rule Change: no-promise-executor-return should allow arrow functions with no {...} #17278
How do you think the change should be implemented?
Change default behavior
Example code
// case 1constsleep=(t)=>newPromise(r=>setTimeout(r,t))constapiPromise=newPromise(r=>apiRequestWithCallback("...",r));// case 2letgetResolver;// might be frowned uponnewPromise(r=>j=r);
What does the rule currently do for this code?
does not allow this syntax because it is returning a value
What will the rule do after it's changed?
for case 1. require void in front of the arrow function
for case 2. ignore assignment returns
I believe these should be the default (not an option proposal)
Participation
I am willing to submit a pull request to implement this change.
This was already discussed in #13668. I'd personally only support adding an option that allows => void <expression> and return void <expression>. Curios what other team members think about this.
This was already discussed in #13668. I'd personally only support adding an option that allows => void <expression> and return void <expression>. Curios what other team members think about this.
Oops, I did search for this rule proposal, I accidentally missed it, sorry
I don't see how case 2 isn't in your favor though, I'd like to hear your thoughts
I don't see how case 2 isn't in your favor though, I'd like to hear your thoughts
I don't think this rule should be deciding which patterns look like intent to return a value and which don't. void as an indication that there is no intent to return a value seems fine to me.
This was already discussed in #13668. I'd personally only support adding an option that allows => void and return void . Curios what other team members think about this.
I'm 👍 for this to cover case 1. It's a clear signal that you know you're not returning a value.
I'm 👎 for covering case 2.
@nopeless do you want to submit a pull request for that change?
I don't see how case 2 isn't in your favor though, I'd like to hear your thoughts
I don't think this rule should be deciding which patterns look like intent to return a value and which don't. void as an indication that there is no intent to return a value seems fine to me.
Maybe my thinking is wrong, but I don't think there exists a developer smart enough to know that the assignment operator in js also returns the LHS value but ignorant enough to think that the function's return value has some sort of meaning.
I did see some new developers struggling to debug their code because they used if (a = b). I personally use let result; if (result = someFunction()) {} pattern a lot. (this is prevented by no-cond-assign)
However, I don't mind putting {} around assignments. Its a rather rare case to do so
This was already discussed in #13668. I'd personally only support adding an option that allows => void and return void . Curios what other team members think about this.
I'm 👍 for this to cover case 1. It's a clear signal that you know you're not returning a value.
I'm 👎 for covering case 2.
@nopeless do you want to submit a pull request for that change?
I'd sure love to try, I'll look at the contributing guide
On allowing .forEach(() => void...) in array-callback-return? Yes, that seems similar and we can discuss it, and yes it would be better to submit a separate issue.
Activity
mdjermanovic commentedon Jun 13, 2023
Hi @nopeless, thanks for the issue!
This was already discussed in #13668. I'd personally only support adding an option that allows
=> void <expression>andreturn void <expression>. Curios what other team members think about this.nopeless commentedon Jun 13, 2023
Oops, I did search for this rule proposal, I accidentally missed it, sorry
I don't see how case 2 isn't in your favor though, I'd like to hear your thoughts
Thanks for looking into the issue
mdjermanovic commentedon Jun 13, 2023
I don't think this rule should be deciding which patterns look like intent to return a value and which don't.
voidas an indication that there is no intent to return a value seems fine to me.nzakas commentedon Jun 13, 2023
I'm 👍 for this to cover case 1. It's a clear signal that you know you're not returning a value.
I'm 👎 for covering case 2.
@nopeless do you want to submit a pull request for that change?
nopeless commentedon Jun 13, 2023
Maybe my thinking is wrong, but I don't think there exists a developer smart enough to know that the assignment operator in js also returns the LHS value but ignorant enough to think that the function's return value has some sort of meaning.
I did see some new developers struggling to debug their code because they used
if (a = b). I personally uselet result; if (result = someFunction()) {}pattern a lot. (this is prevented byno-cond-assign)However, I don't mind putting
{}around assignments. Its a rather rare case to do sonopeless commentedon Jun 13, 2023
I'd sure love to try, I'll look at the contributing guide
feat: Allow `void` in `no-promise-executor-return` (eslint#17278)
nopeless commentedon Jun 14, 2023
Meanwhile, this seems like a similar issue to
array-callback-returnrule. Should I submit a different issue for that?nopeless commentedon Jun 14, 2023
@mdjermanovic I'd like your opinion on this
mdjermanovic commentedon Jun 14, 2023
On allowing
.forEach(() => void...)inarray-callback-return? Yes, that seems similar and we can discuss it, and yes it would be better to submit a separate issue.feat: Allow `void` in rule `no-promise-executor-return` (#17282)