-
Notifications
You must be signed in to change notification settings - Fork 24
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
Custom import order separation #12
Conversation
fc4db3c
to
2fe5b78
Compare
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.
Your example test cases look great, and your documentation changes look like a good fit.
I see that the tests are executed in CI, so I don't have any objections to this PR :)
*/ | ||
export const adjustCommentsOnSortedNodes = ( | ||
nodes: ImportDeclaration[], | ||
finalNodes: ImportOrLine[], | ||
) => { | ||
// maintain a copy of the nodes to extract comments from | ||
// We will mutate a copy of the finalNodes, and extract comments from the original |
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.
Great clarification
@blutorange I'm going to merge this, but let me know if you want any changes and I can make them in a follow-up. |
`getSortedNodesByImportOrder` includes a check for `importOrderSeparation`, and adds newlines when it's true, so we should include that in our tests.
But the last snapshot is wrong, will fix in next commit
Mutating the original nodes causes strange effects, as seen in the snapshot
2fe5b78
to
b601cd8
Compare
Closes #11
This is an adaptation of trivago/prettier-plugin-sort-imports#42 from @atombrenner. I wasn't able to use most of the commits from the original branch, because our approach is different in this project, but I did pull in his commit with tests.
The other change I needed to make here was to modify the cloned nodes in
adjustCommentsOnSortedNodes
, rather than mutating the original, which was leading to some strange bugs in the tests.