Open
Description
What rule do you want to change?
I suggest a new option for vue/padding-line-between-tags
to allow conditional tags to be placed together.
Currently, the following doesn't work with the default settings:
This rule has been my favorite addition to eslint-plugin-vue, but our team prefers grouping conditional tags together, since it's easy to identify that there's a conditional element just by looking whether there's a newline between them or not.
Activity
LoiLock commentedon Jun 16, 2023
I'll probably take a look at submitting a pr myself, but I don't know what the best name for the config option would be. Any suggestions?
FloEdelmann commentedon Jun 16, 2023
Maybe, to build upon the current syntax (which looks like CSS selectors), something like this? But it's quite verbose for a possibly common use case.
Or it could be shortened by allowing selector lists:
LoiLock commentedon Jun 16, 2023
I was thinking of
excludeConditional
, very simple and straight to the point, or perhaps addnon-conditional
toblankLine
?LoiLock commentedon Jun 16, 2023
The only thing I don't like about this is how it quickly becomes quite messy to catch all conditional blocks.
Looking at it now, perhaps
conditional
with the optionsalways
andnever
would be more consistent?FloEdelmann commentedon Jun 16, 2023
excludeConditional
has the problem that you can't enforce no blank lines between conditional tags."non-conditional"
option inblankLine
has the problem that you can't use it together withconsistent
.conditional
with the optionsalways
andnever
sounds wrong, since you're actually controlling the blank line between conditional tags.Maybe
{ "blankLine": "never", "betweenConditionalTags": true }
?LoiLock commentedon Jun 16, 2023
I'll go with
{ "blankLine": "never", "betweenConditionalTags": true }
LoiLock commentedon Jun 16, 2023
@FloEdelmann I've made some changes. Could you (if you have time, of course) check it out and give me some feedback? I'm missing quite a few tests, and I see that there's a ton of tests for various edge cases, and I'm not sure for which scenarios to test.
I don't want to pollute the pull requests with broken code. As far as I know, everything works so far, the existing tests are all still working. I've made sure it works with
consistent
, and it should work with a variety of edge cases.Sorry, it's my first time working on a linter rule 😅
https://github.com/LoiLock/eslint-plugin-vue
FloEdelmann commentedon Jun 22, 2023
I had a quick look at the test cases (at master...LoiLock:eslint-plugin-vue:master).
Could you please change the first two added
valid
cases like this, to make it more clear what happens:{ blankLine: 'always', prev: '*', next: '*', betweenConditionalTags: false }
(your third test case can then be deleted, as this one has the same options)
{ blankLine: 'always', prev: '*', next: '*', betweenConditionalTags: true }
Also, could you please add more
invalid
test cases and morevalid
test cases withnever
andconsistent
?