Enhancement: [no-throw-literal] Specify allowed types #6226
Labels
accepting prs
Go ahead, send a pull request that resolves this issue
duplicate
This issue or pull request already exists
enhancement: plugin rule option
New rule option for an existing eslint-plugin rule
locked due to age
Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.
package: eslint-plugin
Issues related to @typescript-eslint/eslint-plugin
Before You File a Proposal Please Confirm You Have Done The Following...
My proposal is suitable for this project
Link to the rule's documentation
https://typescript-eslint.io/rules/no-throw-literal/
Description
I would like to add an additional option to this rule,
allowThrowingTypes
, that would allow users to override the current hard-coded behaviour of checking for the globalError
class.I'd find this useful in Remix projects, where you can throw a
Response
object. Currently, I have to disable this rule, when what I would prefer to do is only allowError
orResponse
objects to be thrown.I think this could potentially also be useful in codebases with custom error types, where you want to enforce usage of a more specific subtype of
Error
.I'm not sure what the syntax of the option should be - you would need be able to specify the import location and type, rather than just matching on the type name. Are there any other rules where it is possible to precisely specify types in this way?
Fail
Pass
Additional Info
No response
The text was updated successfully, but these errors were encountered: