-
-
Notifications
You must be signed in to change notification settings - Fork 675
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
vue/html-self-closing doesn't work when used with prettier #2232
Comments
That’s not true. As mentioned in the eslint-config-prettier docs you linked to:
The gist of it: {
"extends": [
"something-vue",
"prettier"
],
"rules": {
"vue/html-self-closing": [
"error",
{
"html": {
"void": "any"
}
}
]
}
} |
Sorry, I didn't explain it well enough. |
Yes; not everyone is using Prettier, but still most want to stick to some consistent formatting in the Vue SFC template block.
Why not change the default options in |
If the default options in |
Pardon my ignorance, but do we really need this rule? In the rule docs there's this bit:
But what do they mean by "not supported"? What should be expected by said support? Here's what the WHATWG specs say:
So even though it doesn't really "do" anything meaningful, it doesn't necessarily create an issue, either - especially considering that quotes can be enforced with vue/html-quotes (the problem mentioned in the second paragraph would never happen). I don't appreciate that Prettier enforces self-closing, either, but if it's not really a problem, why add it as |
I don't know why the default for
Hmm we also have other rules that enforce a style convention instead of preventing a problem. And it's in the "strongly recommended" preset config because it's included in the same section in the Style Guide: https://vuejs.org/style-guide/rules-strongly-recommended.html#self-closing-components Indeed, I like the explanation in prettier/prettier#5246 (comment):
I'd be fine with changing the default to |
Many of the stylistic rules in this plugin were released before Prettier full supported I don't want to change the rule defaults. This is because people who like the current style complain. |
Ah, I understand. So, we simply need to change the default values.
Indeed, some people might express dissatisfaction if void elements become self-closing. It's a trade-off. In that case, splitting the rules into two might be one way to go after all. |
@ota-meshi Should we reconsider this for v10? Some people will complain either way. But Prettier has become such a widely used tool that making the rule compatible with Prettier will likely benefit more people than leaving it as is. Also, people not using Prettier who like the current style can still override the default settings. |
What rule do you want to change?
vue/html-self-closing
Does this change cause the rule to produce more or fewer warnings?
No
How will the change be implemented? (New option, new default behavior, etc.)?
The change will be implemented by dividing the html.void option into two distinct rules.
Additional context
Currently the html.void option in vue/html-self-closing is causing conflicts with prettier, so vue/html-self-closing is turned off in eslint-config-prettier. Because of this, when ESLint and prettier are used together, vue/html-self-closing is not available by default even if plugin:vue/vue3-recommended is set.
I think the solution is to create another new rule with only the html.void option and turn off that option in eslint-config-prettier configuration file. What do you think?
Update:
I have an additional question. Is it necessary to lint tags other than Vue components using eslint-vue-plugin?
The text was updated successfully, but these errors were encountered: