Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
feat(eslint-plugin): [only-throw-error] add optionallowRethrowing
#11075
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
feat(eslint-plugin): [only-throw-error] add optionallowRethrowing
#11075
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Thanks for the PR,@kirkwaiblinger! typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community. The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately. Thanks again! 🙏Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently onhttps://opencollective.com/typescript-eslint. |
netlifybot commentedApr 15, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
✅ Deploy Preview fortypescript-eslint ready!
To edit notification comments on pull requests, go to yourNetlify site configuration. |
Uh oh!
There was an error while loading.Please reload this page.
nx-cloudbot commentedApr 15, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
codecovbot commentedApr 15, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@## main #11075 +/- ##==========================================+ Coverage 90.83% 90.93% +0.09%========================================== Files 497 499 +2 Lines 50279 50789 +510 Branches 8297 8368 +71 ==========================================+ Hits 45672 46183 +511+ Misses 4592 4591 -1 Partials 15 15
Flags with carried forward coverage won't be shown.Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Really nifty stuff! I like the extraction+reuse for Promise detection. Left a few comments, nothing close to blocking IMO. 🔥
Uh oh!
There was an error while loading.Please reload this page.
* | ||
* @default false | ||
*/ | ||
allowRethrowing?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
[Docs] The options mentions in this page don't explain why any of the options exist. I suppose that's existing/separate docs work for the other ones. But do you think it'd be reasonable to at least mentionallowRethrowing
in this PR?
If you'd rather them all tackled together as a followup, I wouldn't block.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Josh Goldberg ✨ <git@joshuakgoldberg.com>
.vscode/extensions.json Outdated
@@ -6,7 +6,8 @@ | |||
"esbenp.prettier-vscode", | |||
"streetsidesoftware.code-spell-checker", | |||
"tlent.jest-snapshot-language-support", | |||
"mrmlnc.vscode-json5" | |||
"mrmlnc.vscode-json5", | |||
"unifiedjs.vscode-mdx" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Unrelated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I removed this just to be able to merge before the release today - but I wouldn't be against the extension in general
29ea555
intotypescript-eslint:mainUh oh!
There was an error while loading.Please reload this page.
| datasource | package | from | to || ---------- | -------------------------------- | ------ | ------ || npm | @typescript-eslint/eslint-plugin | 8.31.0 | 8.32.0 || npm | @typescript-eslint/parser | 8.31.0 | 8.32.0 |## [v8.32.0](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#8320-2025-05-05)##### 🚀 Features- **eslint-plugin:** \[only-throw-error] add option `allowRethrowing` ([#11075](typescript-eslint/typescript-eslint#11075))- **eslint-plugin:** \[no-unnecessary-type-conversion] add rule ([#10182](typescript-eslint/typescript-eslint#10182))##### 🩹 Fixes- **eslint-plugin:** \[prefer-nullish-coalescing] fix parenthesization bug in suggestion ([#11098](typescript-eslint/typescript-eslint#11098))- **eslint-plugin:** \[unified-signatures] exempt `this` from optional parameter overload check ([#11005](typescript-eslint/typescript-eslint#11005))- **eslint-plugin:** \[no-unnecessary-type-parameters] should parenthesize type in suggestion fixer if necessary ([#10907](typescript-eslint/typescript-eslint#10907))##### ❤️ Thank You- Andy Edwards- Kirk Waiblinger [@kirkwaiblinger](https://github.com/kirkwaiblinger)- mdm317- Sasha Kondrashov- Yukihiro Hasegawa [@y-hsgw](https://github.com/y-hsgw)You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.## [v8.31.1](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#8311-2025-04-28)##### 🩹 Fixes- **eslint-plugin:** \[no-unnecessary-condition] downgrade fix to suggestion ([#11081](typescript-eslint/typescript-eslint#11081))##### ❤️ Thank You- Kirk Waiblinger [@kirkwaiblinger](https://github.com/kirkwaiblinger)You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.
| datasource | package | from | to || ---------- | -------------------------------- | ------ | ------ || npm | @typescript-eslint/eslint-plugin | 8.31.0 | 8.32.0 || npm | @typescript-eslint/parser | 8.31.0 | 8.32.0 |## [v8.32.0](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#8320-2025-05-05)##### 🚀 Features- **eslint-plugin:** \[only-throw-error] add option `allowRethrowing` ([#11075](typescript-eslint/typescript-eslint#11075))- **eslint-plugin:** \[no-unnecessary-type-conversion] add rule ([#10182](typescript-eslint/typescript-eslint#10182))##### 🩹 Fixes- **eslint-plugin:** \[prefer-nullish-coalescing] fix parenthesization bug in suggestion ([#11098](typescript-eslint/typescript-eslint#11098))- **eslint-plugin:** \[unified-signatures] exempt `this` from optional parameter overload check ([#11005](typescript-eslint/typescript-eslint#11005))- **eslint-plugin:** \[no-unnecessary-type-parameters] should parenthesize type in suggestion fixer if necessary ([#10907](typescript-eslint/typescript-eslint#10907))##### ❤️ Thank You- Andy Edwards- Kirk Waiblinger [@kirkwaiblinger](https://github.com/kirkwaiblinger)- mdm317- Sasha Kondrashov- Yukihiro Hasegawa [@y-hsgw](https://github.com/y-hsgw)You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.## [v8.31.1](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#8311-2025-04-28)##### 🩹 Fixes- **eslint-plugin:** \[no-unnecessary-condition] downgrade fix to suggestion ([#11081](typescript-eslint/typescript-eslint#11081))##### ❤️ Thank You- Kirk Waiblinger [@kirkwaiblinger](https://github.com/kirkwaiblinger)You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.
| datasource | package | from | to || ---------- | -------------------------------- | ------ | ------ || npm | @typescript-eslint/eslint-plugin | 8.31.0 | 8.32.0 || npm | @typescript-eslint/parser | 8.31.0 | 8.32.0 |## [v8.32.0](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#8320-2025-05-05)##### 🚀 Features- **eslint-plugin:** \[only-throw-error] add option `allowRethrowing` ([#11075](typescript-eslint/typescript-eslint#11075))- **eslint-plugin:** \[no-unnecessary-type-conversion] add rule ([#10182](typescript-eslint/typescript-eslint#10182))##### 🩹 Fixes- **eslint-plugin:** \[prefer-nullish-coalescing] fix parenthesization bug in suggestion ([#11098](typescript-eslint/typescript-eslint#11098))- **eslint-plugin:** \[unified-signatures] exempt `this` from optional parameter overload check ([#11005](typescript-eslint/typescript-eslint#11005))- **eslint-plugin:** \[no-unnecessary-type-parameters] should parenthesize type in suggestion fixer if necessary ([#10907](typescript-eslint/typescript-eslint#10907))##### ❤️ Thank You- Andy Edwards- Kirk Waiblinger [@kirkwaiblinger](https://github.com/kirkwaiblinger)- mdm317- Sasha Kondrashov- Yukihiro Hasegawa [@y-hsgw](https://github.com/y-hsgw)You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.## [v8.31.1](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#8311-2025-04-28)##### 🩹 Fixes- **eslint-plugin:** \[no-unnecessary-condition] downgrade fix to suggestion ([#11081](typescript-eslint/typescript-eslint#11081))##### ❤️ Thank You- Kirk Waiblinger [@kirkwaiblinger](https://github.com/kirkwaiblinger)You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.
Uh oh!
There was an error while loading.Please reload this page.
PR Checklist
Overview
There's some doubt over whether a captured catch variable should be considered a rethrow... For example, is this a rethrow?
For now, I've implemented it thatyes, that's a rethrow, but we could also demand that rethrows must occur within the same function scope as they're caught. This would "false positive" on synchronously executed functions, though, like
IMO, calling that a rethrow is really a stretch, so I'm gently in favor of banning captured variable rethrows, but I could be convinced either way.
Also included some minor refactoring to use common utilities for parsing
.then()
/.catch()
calls.