Skip to content

Commit fbdff58

Browse files
committed
feat(rules): add prefer-early-return lint rule 👽
- Add createEarlyReturnFix function for auto-fixing nested conditions - Add documentation with valid/invalid examples - Add hasNestedConditions validator for detecting problematic patterns - Add PreferEarlyReturn rule implementation with auto-fix support - Add test cases for the new rule - Add type guards for BlockStatement, IfStatement, and ReturnStatement nodes - Register prefer-early-return rule in main plugin exports - Update README with new rule documentation
1 parent d00e2cc commit fbdff58

8 files changed

Lines changed: 1471 additions & 19 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Deno lint plugin collection for identifying and reporting on patterns found in c
1010
- [`prefer-nullish-coalescing`](./examples/prefer-nullish-coalescing.md) - Prefers nullish coalescing (??) over logical OR (||) for null/undefined checks
1111
- [`prefer-optional-chain`](./examples/prefer-optional-chain.md) - Prefers optional chaining (?.) over logical AND (&&) for property access
1212
- [`prefer-template-literals`](./examples/prefer-template-literals.md) - Prefers template literals over string concatenation
13+
- [`prefer-early-return`](./examples/prefer-early-return.md) - Prefers early returns over nested conditions for better readability
1314
- [`prefer-promise-reject-errors`](./examples/prefer-promise-reject-errors.md) - Enforces Error objects in Promise.reject() calls
1415
- [`require-error-handling`](./examples/require-error-handling.md) - Ensures Deno file operations are properly awaited
1516

0 commit comments

Comments
 (0)