eslint-plugin-vue
eslint-plugin-vue copied to clipboard
`vue/padding-line-between-tags` Support singleline/multiline options
What rule do you want to change?
vue/padding-line-between-tags
Does this change cause the rule to produce more or fewer warnings?
More warnings.
How will the change be implemented? (New option, new default behavior, etc.)?
It could be an additional option like singleline/multiline.
{ "blankLine": "always", "prev": "div-singleline", "next": "span-multiline" }
But it might be a bad example as <div-singleline /> might be the correct tag/component. So it could be also:
{ "blankLine": "always", "prevMulti": "div", "nextSingle": "span" }
Please provide some example code that this change will affect:
<div>
This is a multiline tag
<div>
<span>This is a singleline tag</span>
Will trigger an error with configuration like that:
{ "blankLine": "always", "prevMulti": "div", "nextSingle": "span" }
Moreover, it will be possible to force the required padding line between multiline and singleline tags in general.
For the ruleset like this:
[
{ "blankLine": "always", "prevMulti": "*", "nextSingle": "*" },
{ "blankLine": "always", "prevSingle": "*", "nextMulti": "*" },
{ "blankLine": "always", "prevMulti": "*", "nextMulti": "*" },
{ "blankLine": "never", "prevSingle": "*", "nextSingle": "*" }
]
It will be possible to have code like this:
<div>
This is a multiline tag
<div>
<div>
This is a multiline tag
<div>
<div>
This is a multiline tag
<div>
<span>This is a singleline tag</span>
<span>This is a singleline tag</span>
<div>
This is a multiline tag
<div>
<span>This is a singleline tag</span>
<div>
This is a multiline tag
<div>
<span>This is a singleline tag</span>
<span>This is a singleline tag</span>
<span>This is a singleline tag</span>
CC @dev1437 and @amiranagram, follow-up to #1832 and #1966.
Should I just allow users to define their own regex? That would solve this problem and quite possibly future problems where people want more control. Thoughts? @FloEdelmann
I could provide some common use cases in the docs e.g. selecting a multiline or singleline tag
I don't think a regex would be very readable for this use case, and also: Don't parse HTML with regex :wink:
I like the prevMulti / prevSingle / nextMulti / nextSingle options better. But I don't know if this use case is common enough to consider implementing it.