🚀 Feature: Find or create a lint rule to prefer inverting a single 'if' to reduce nesting #1267
Open
3 tasks done
Labels
status: accepting prs
Please, send a pull request to resolve this!
type: feature
New enhancement or request
Bug Report Checklist
main
branch of the repository.Overview
I often see functions like:
If a function consists entirely of an
if
and thatif
contains a declaration, I'd generally consider it cleaner to instead invert the if to reduce nesting:Let's find or create an ESLint plugin to do this.
Additional Info
https://stackoverflow.com/questions/268132/invert-if-statement-to-reduce-nesting goes into the reasoning for this nicely.
This was proposed to ESLint in eslint/eslint#10120 but never ratified.
The text was updated successfully, but these errors were encountered: