-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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: add option closing-bracket-newline
for html beautify
#2316
base: main
Are you sure you want to change the base?
feat: add option closing-bracket-newline
for html beautify
#2316
Conversation
This option allow you put closing bracket to seperate line
I'm not directly opposed to adding another config option for this setting, but this project has too many options already. Similar to #1404 ... But for |
I understand your concerns a little bit. I opened this pr because js-beautify is the basic dependency of vscode built-in html-language-feature extension which used to format html code. There is no other way to let vscode add this option, the only way I found is open a pr in js-beautify and then wait for vscode update its dependency! I think this project should not be so cautious aboud adding new features, as mentioned above, this project is now a built-in feature of vscode, many html format issues in vscode are linked to this project. |
@zhaojjiang Do you want to take responsibility for potentially breaking millions of users? |
// Add newline before tag closing bracket: | ||
// 1. add newline only if 'force_expand_multiline' or 'closing-bracket-newline' is specified | ||
// 2. add newline only if tag has wrapped_attrs | ||
if ((this._is_wrap_attributes_force_expand_multiline || this._options.closing_bracket_newline) && last_tag_token.has_wrapped_attrs) { |
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.
This makes the behavior of this new option the same as force_expand_multiline
... If that is the case you don't need the new option. I think what you want is
if ((this._is_wrap_attributes_force_expand_multiline || this._options.closing_bracket_newline) && last_tag_token.has_wrapped_attrs) { | |
if ((this._is_wrap_attributes_force_expand_multiline && last_tag_token.has_wrapped_attrs) || this._options.closing_bracket_newline) { |
But that might not be it either...
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.
This makes the behavior of this new option the same as
force_expand_multiline
... If that is the case you don't need the new option.
Yes, it is. This new option should work only with a tag which has wrapped attributes, it should not work when tag has no attributes.
This option is added to implement prettier's
--bracket-same-line
behavior.Input code:
Output code:
Description
main
)Before Merge Checklist
These items can be completed after PR is created.
(Check any items that are not applicable (NA) for this PR)