Question: Why allow empty reject on the `prefer-promise-reject-errors` rule?

4
closed
yvele
yvele
Posted 2 months ago

Question: Why allow empty reject on the `prefer-promise-reject-errors` rule? #2709

Just a question: Why do you allow empty reject on the prefer-promise-reject-errors rule? I've seen no comment or reason 🤔 is it for legacy reason? 🤔

https://github.com/airbnb/javascript/blob/0d747c6d96f94e54d24d8c005da0c87105bf0fd5/packages/eslint-config-airbnb-base/rules/best-practices.js#L377-L379

Thanks for any information you can give me regarding best practices.

ljharb
ljharb
Created 2 months ago

because there's nothing wrong with Promise.reject(), it's a very useful placeholder value in a number of cases.

yvele
yvele
Created 2 months ago

because there's nothing wrong with Promise.reject()

Yeah technically it's ok.. but in my opinion it's ALWAYS better to enforce having an explicit "reason" (a proper Error) for a rejection.

it's a very useful placeholder value in a number of cases.

What kind of use cases? 🤔 My team and I we never had any use use case with a no error rejection.. I can't figure out any use case 🤔

ljharb
ljharb
Created 2 months ago

I don't agree that it's always better. Promise rejections are NOT exceptions, and it's perfectly fine to use a Promise to encapsulate two different code paths.

yvele
yvele
Created 2 months ago

I don't fully understand but yeah rejection !== exception (but in my use cases I've never had to differentiate the "no exception rejection code path").

Thanks for your time @ljharb I've seen you in many issues and I know you are generous about sharing good practices ;)