-
-
Notifications
You must be signed in to change notification settings - Fork 0
refactor(eslint): reduce empty line rules #328
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Remove padding rules for variable declarations - Remove padding rules for block-like and return statements - Add padding rules for export statements - Add padding rules for function declarations - Add lines-between-class-members rule
🦋 Changeset detectedLatest commit: 639c675 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughA changeset introduces modifications to ESLint stylistic rules, reducing unnecessary empty lines by refactoring padding rules around exports and functions, and adding enforcement for blank lines between class members. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Suggested labels
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
PR Review: refactor(eslint): reduce empty line rulesOverviewThis PR refactors the stylistic ESLint rules to reduce the number of enforced empty lines, focusing on more meaningful code boundaries. Code Quality ✅Strengths:
Potential Issues
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/eslint-config/src/configs/stylistic.ts (2)
29-31: Consider removing redundant export spacing rule.The rule on line 29 (
export→export) is redundant since lines 30 and 31 together already enforce blank lines between consecutive exports:
- Line 30: requires blank line from
exportto any statement (includingexport)- Line 31: requires blank line from any statement (including
export) toexportWhile harmless, removing the redundant rule would simplify the configuration.
Apply this diff to remove the redundant rule:
{ blankLine: 'always', next: '*', prev: 'directive' }, { blankLine: 'any', next: 'directive', prev: 'directive' }, - { blankLine: 'always', next: 'export', prev: 'export' }, { blankLine: 'always', next: '*', prev: 'export' }, { blankLine: 'always', next: 'export', prev: '*' },
33-35: Consider removing redundant function spacing rule.Similar to the export rules, line 33 (
function→function) is redundant since lines 34 and 35 together already enforce blank lines between consecutive functions:
- Line 34: requires blank line from
functionto any statement (includingfunction)- Line 35: requires blank line from any statement (including
function) tofunctionRemoving this redundancy would keep the configuration consistent and simplified.
Apply this diff to remove the redundant rule:
{ blankLine: 'always', next: 'export', prev: '*' }, - { blankLine: 'always', next: 'function', prev: 'function' }, { blankLine: 'always', next: '*', prev: 'function' }, { blankLine: 'always', next: 'function', prev: '*' }, ],
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.changeset/reduce-empty-lines.md(1 hunks)packages/eslint-config/src/configs/stylistic.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/any-inside-generic-functions.mdc)
**/*.{ts,tsx}: When building generic functions in TypeScript, it is acceptable to use 'any' inside the function body if TypeScript cannot match runtime logic to type logic.
Outside of generic functions, use 'any' extremely sparingly in TypeScript code.Unless explicitly required by the framework, do not use default exports in TypeScript files.
**/*.{ts,tsx}: Use TypeScript for all code. Prefer interfaces over types.
Follow the ESLint rules.
Use "function" keyword for pure functions.
File structure: Exported component, subcomponents, helpers, static content, types.
Avoid unnecessary curly braces in conditional statements.
For single-line statements in conditionals, omit curly braces.
Use concise, one-line syntax for simple conditional statements (e.g., if (condition) doSomething()).
Handle errors and edge cases at the beginning of functions.
Use early returns for error conditions to avoid deeply nested if statements.
Place the happy path last in the function for improved readability.
Avoid unnecessary else statements; use if-return pattern instead.
Use guard clauses to handle preconditions and invalid states early.
Implement proper error logging and user-friendly error messages.
Consider using custom error types or error factories for consistent error handling.
Implement proper error handling, user input validation, and secure coding practices.
Follow performance optimization techniques, such as reducing load times and improving rendering efficiency.
Provide clear and concise comments for complex logic.
Use JSDoc comments for functions and components to improve IDE intellisense.
**/*.{ts,tsx}: Proactively use discriminated unions to model data that can be in one of a few different shapes.
Use switch statements to handle the results of discriminated unions.
Use discriminated unions to prevent the 'bag of optionals' problem (i.e., avoid interfaces with multiple optional properties that can represent impossible states).
**/*.{ts,tsx}: Do not introduce new en...
Files:
packages/eslint-config/src/configs/stylistic.ts
🧠 Learnings (1)
📚 Learning: 2025-10-21T05:24:57.572Z
Learnt from: mheob
Repo: mheob/config PR: 313
File: .changeset/funny-sloths-live.md:1-2
Timestamp: 2025-10-21T05:24:57.572Z
Learning: In the mheob/config repository, empty changeset files (containing only `---\n---`) are acceptable and used intentionally for documentation-only changes that don't require version bumps.
Applied to files:
.changeset/reduce-empty-lines.md
🔇 Additional comments (2)
.changeset/reduce-empty-lines.md (1)
1-11: LGTM! Changeset accurately documents the refactoring.The changeset file correctly documents the patch version bump and provides a clear, comprehensive list of changes that align with both the PR objectives and the actual code modifications.
packages/eslint-config/src/configs/stylistic.ts (1)
23-23: LGTM! Class member spacing rule added correctly.The
lines-between-class-membersrule is properly configured to require blank lines between class members, aligning with the PR's objective to enforce spacing at meaningful boundaries.
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @mheob/eslint-config@9.0.1 ### Patch Changes - [#328](#328) ([@mheob](https://github.com/mheob)): Refactor stylistic padding rules to reduce empty lines - Remove padding rules for variable declarations (const, let, var) - Remove padding rules for block-like statements and return statements - Add padding rules for export statements (blank lines between exports) - Add padding rules for function declarations (blank lines around functions) - Add `@stylistic/lines-between-class-members` rule requiring blank lines between class members - [#330](#330) ([@mheob](https://github.com/mheob)): Remove redundant padding line rules for exports and between consecutive functions. The existing rules for padding before/after functions already ensure proper spacing, making the removed rules unnecessary and potentially conflicting.



Summary
Refactor stylistic ESLint rules to reduce the number of enforced empty lines in code, making the formatting less aggressive while maintaining code readability.
Changes
const,let,var)@stylistic/lines-between-class-membersrule requiring blank lines between class membersMotivation
The previous configuration enforced too many empty lines throughout the code, particularly around variable declarations and return statements. This refactor focuses the empty line enforcement on more meaningful boundaries (exports, functions, class members) while allowing more natural grouping of related variable declarations and statements.
Summary by CodeRabbit
New Features
Refactor
✏️ Tip: You can customize this high-level summary in your review settings.