Skip to content

Base rule extension: [prefer-promise-reject-errors] #7687

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
5 tasks done
DetachHead opened this issue Sep 22, 2023 · 1 comment · Fixed by #8011
Closed
5 tasks done

Base rule extension: [prefer-promise-reject-errors] #7687

DetachHead opened this issue Sep 22, 2023 · 1 comment · Fixed by #8011
Labels
accepting prs Go ahead, send a pull request that resolves this issue enhancement: new base rule extension New base rule extension required to handle a TS specific case package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@DetachHead
Copy link

Before You File a Proposal Please Confirm You Have Done The Following...

My proposal is suitable for this project

  • My proposal specifically checks TypeScript syntax, or it proposes a check that requires type information to be accurate.
  • I believe my proposal would be useful to the broader TypeScript community (meaning it is not a niche proposal).

Link to the base rule

https://eslint.org/docs/latest/rules/prefer-promise-reject-errors

Description

the prefer-promise-reject-errors rule should be extended as the base rule does not catch cases where the value is not a literal

Fail

const foo = "asdf"
Promise.reject(foo) // no error

Pass

const foo = new Error("asdf")
Promise.reject(foo) // no error

Additional Info

originally raised #7673 and eslint/eslint#17592 for no-throw-literal because i wasn't aware there was already a base rule for this

@DetachHead DetachHead added enhancement: new base rule extension New base rule extension required to handle a TS specific case package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Sep 22, 2023
@DetachHead DetachHead changed the title Base rule extension: [rule-name] <a short description of my proposal> Base rule extension: [prefer-promise-reject-errors] Sep 22, 2023
@JoshuaKGoldberg
Copy link
Member

Heh, we've really given you a convoluted path to go down. @typescript-eslint/no-throw-literal -> no-throw-literal -> prefer-promise-reject-errors -> 🆕 @typescript-eslint/prefer-promise-reject-errors. And then taking a few weeks to respond to this latest one! Sorry for the delay.

Agreed, prefer-promise-reject-errors looks augmentable with type information in roughly the same way that no-throw-literal is. Thanks for filing! Accepting PRs. 🚀

@JoshuaKGoldberg JoshuaKGoldberg added accepting prs Go ahead, send a pull request that resolves this issue and removed triage Waiting for team members to take a look labels Oct 19, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepting prs Go ahead, send a pull request that resolves this issue enhancement: new base rule extension New base rule extension required to handle a TS specific case package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants