Skip to content

vue/html-self-closing-bracket-newline #1794

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

Closed
olemarius opened this issue Feb 8, 2022 · 4 comments · Fixed by #2346
Closed

vue/html-self-closing-bracket-newline #1794

olemarius opened this issue Feb 8, 2022 · 4 comments · Fixed by #2346

Comments

@olemarius
Copy link

Please describe what the rule should do:

I'd like to set multiline: 'always' for self-closing tags

<MyComp
    :foo="bar"
/>

And singleline: 'never'

<MyComp :foo="bar" />

And multiline: 'never' for tags with content.

<MyComp
    :foo="bar">
    Hello World
</MyComp>

What category should the rule belong to?

[x] Enforces code style (layout)
[ ] Warns about a potential error (problem)
[ ] Suggests an alternate way of doing something (suggestion)
[ ] Other (please specify:)

Provide 2-3 code examples that this rule should warn about:

// singleline: 'never'
<MyComp :foo="bar"
/>
// multiline: 'always'    
<MyComp 
  :foo="bar" />

Additional context

@ota-meshi
Copy link
Member

Thank you for the rule proposal.
The rule you suggested should be an option for the existing rule vue/html-closing-bracket-newline. Otherwise, the rules will conflict.
https://eslint.vuejs.org/rules/html-closing-bracket-newline.html

I think it would be nice to add an option like selfClosingTag.

<!-- { "selfClosingTag": { "singleline": "never" } } -->
<!-- ✗ BAD -->
<MyComp :foo="bar"
/>
<!-- ✓ GOOD -->
<MyComp :foo="bar"/>
<!-- { "selfClosingTag": { "multiline": "always" } } -->
<!-- ✗ BAD -->
<MyComp 
  :foo="bar" />
<!-- ✓ GOOD -->
<MyComp 
  :foo="bar"
/>

@ashutosh887
Copy link

I would like to work on this @ota-meshi

@mussinbenarbia
Copy link
Contributor

@ota-meshi @FloEdelmann Is it ok if I pick this up? I have a working implementation ready

@ota-meshi
Copy link
Member

ota-meshi commented Nov 29, 2023

@mussinbenarbia Thank you! Welcome pull request!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants