-
Notifications
You must be signed in to change notification settings - Fork 75
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
Grouping all comments in a chain at the beginning of it #708
base: main
Are you sure you want to change the base?
Conversation
return false; | ||
} | ||
|
||
module.exports = handleMemberAccessComments; |
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 this file be called also handleMemberAccessComments.js
perhaps?
text, | ||
precedingNode, | ||
enclosingNode, | ||
followingNode, | ||
comment |
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.
not all these params have been used; maybe pass an object into the function instead of all these params?
// Comment before chain | ||
// CONFIG | ||
// Comment 1 | ||
// Comment 2 | ||
// Comment 3 | ||
// Comment 4 | ||
// Comment 5 |
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.
Is this what we would like to achieve? Move all the comments above the chain?
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.
Yes
Have a look at #644 and also try it on Prettier JS to see what they are doing at the moment.
It's not perfect but there is something nice in it.
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.
I'll give it a try
addressing some issues with comments in chains. #644
For now we are grouping comments at the beginning of the chain.
This is a good first step however we must address some questions if we want to continue with this approach.
first of all in this scenario:
This is the expected behaviour but the order of the comments is not the same anymore. Therefore the AST comparison will fail.
Shall we remove the comments from the AST comparison understanding that Prettier already has a lot of security making sure that each comment will be printed?
In this case we are making new advances since Prettier JS does mess up with the order of the comments when the chain get a bit complex and also the indentation.
Thoughts @fvictorio @mattiaerre
there are some more ideas I have but for now this is a good first step.