-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Rule proposal: disallow unused return types #6442
Copy link
Copy link
Open
Labels
accepting prsGo ahead, send a pull request that resolves this issueGo ahead, send a pull request that resolves this issueenhancement: new plugin ruleNew rule request for eslint-pluginNew rule request for eslint-pluginpackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugin
Metadata
Metadata
Assignees
Labels
accepting prsGo ahead, send a pull request that resolves this issueGo ahead, send a pull request that resolves this issueenhancement: new plugin ruleNew rule request for eslint-pluginNew rule request for eslint-pluginpackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues 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
Description
Paired with explicit-function-return-types, it's possible to include extraneous return types that are never used. This can happen when refactoring code meaning that some code branches might become impossible to reach.
For example you might have this function:
where the return types are correct, but then it's refactored to
and let's assume it's being used in a codebase before param is required:
since the return type is unchanged, the null check branch might not be removed during refactoring, and neither the linter or tsc will complain about it.
Fail Cases
Pass Cases
Additional Info
It's totally possible I missed an issue that matched this proposal, but I couldn't find any.