-
Notifications
You must be signed in to change notification settings - Fork 45
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
feat: adds customGroup.newlinesInside
option
#428
Conversation
25f887d
to
ead3cc3
Compare
customGroup.newlinesBetween
related optionscustomGroup.newlinesBetween
related options
7c6eb6c
to
a1c3d55
Compare
bd17725
to
36f886b
Compare
customGroup.newlinesBetween
related optionscustomGroup. newlinesInside
option
customGroup. newlinesInside
optioncustomGroup.newlinesInside
option
36f886b
to
dde07dd
Compare
- We are going to be adding the option in the next commit.
- We will be adding auto-fix for this reported error in a commit later.
…nodes - The `leftNum < rightNum` check is currently only made if `numberOfEmptyLinesBetween === 0` (as confirmed by passing tests). - With `newlinesBetween: always` and if `numberOfEmptyLinesBetween > 1`, we were not checking whether the two nodes were sorted or not before raising the spacing error. - This would result in two errors toward the same two nodes: - One related to invalid order. - The other related to invalid spacing. - A few tests had to be updated. - All of those errors targeted nodes that already had order errors reported for them.
…odes - The `leftNum < rightNum` check is not made when `newlinesBetween: never` either (as confirmed by passing tests). - A few tests had to be updated: - The fix itself has no change. There are only slightly less reported newlines errors. - All of those errors targeted nodes that already had order errors reported for them.
- Renames constants. - Simplifies `for` loop.
- Creates constants.
dde07dd
to
afaa54f
Compare
afaa54f
to
cb1f483
Compare
@OlivierZal 👋 Feel free to review this if you want 🙂 |
@@ -0,0 +1,205 @@ | |||
import { describe, expect, it } from 'vitest' |
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.
Can you move this file to test/utils/
?
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.
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.
Looks good to me!
@@ -290,13 +290,6 @@ describe(ruleName, () => { | |||
}, | |||
messageId: 'unexpectedImportsGroupOrder', | |||
}, | |||
{ |
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.
Can you tell me why you removed these tests?
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.
- The edited code responsible for those lines changes can be found here (see each commit's description)
- Those changes are not absolutely required:
- (1) Some spacing errors were reported after checking if
leftNum < rightNum
. - (2) Some other errors were not checking if
leftNum < rightNum
, leading to spacing errors being reported even when the nodes were not sorted. - I added the
leftNum < rightNum
for all cases => Spacing errors from (2) are now not reported.
- (1) Some spacing errors were reported after checking if
- If needed, I can revert these commits. 🙂
First PR aiming to partially resolve the issue #401.
customGroup.newlinesInside
option. We will take the opportunity to create agetNewlinesBetweenOption
method that will help us later to precisely customize newline behavior between two specific groups.Description
We currently have the
newlinesBetween
option, which applies the same newlines-related rules between all groups.This PR adds a sub-option for the new array-based
customGroups
:newlinesInside?: 'always' | 'never'
Here is the list of rules with this new addition:
sort-classes
sort-modules
sort-object-types
sort-interfaces
New option
customGroup.newlinesInside?: 'ignore' | 'always' | 'never'
Newlines rule that should be applied between two consecutive nodes of the same custom group.
Example: Enforce a newline between all class methods.
Other changes
leftNum < rightNum
check is currently only made ifnumberOfEmptyLinesBetween === 0
(as confirmed by passing tests).newlinesBetween: always
and ifnumberOfEmptyLinesBetween > 1
, we were not checking ifleftNum < rightNum
.leftNum < rightNum
check is not made whennewlinesBetween: never
either (as confirmed by passing tests).leftNum < rightNum
.What is the purpose of this pull request?