eslint-plugin-vue icon indicating copy to clipboard operation
eslint-plugin-vue copied to clipboard

`vue/padding-line-between-tags` Support singleline/multiline options

Open Ky6uk opened this issue 3 years ago • 5 comments

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>

Ky6uk avatar Sep 16 '22 11:09 Ky6uk

CC @dev1437 and @amiranagram, follow-up to #1832 and #1966.

FloEdelmann avatar Sep 16 '22 14:09 FloEdelmann

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

dev1437 avatar Sep 17 '22 12:09 dev1437

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.

FloEdelmann avatar Sep 17 '22 13:09 FloEdelmann