feat(attributes-order): add slot attribute #1311
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
First of all thanks for such a great eslint plugin for Vue! It helps my team a lot to have consistent code practices.
Secondly, I'd like to improve the tool a little bit because in our case it wasn't possible to migrate some of the codebase to support eslint without changing plugin's code.
Motivation
There's a rule
attributes-order
that is included in the recommended ruleset which has predefined attributes set. This set is great, but in some cases might be a bit limiting. In particular, there's no separate treatment forkey
,ref
vsslot
andv-slot
right now (they are mutually controlled by theUNIQUE
option) and I would like to improve that.The reason for controlling them separately is that
ref
andkey
respond to the outer interface of the component, so I would like to have these attributes as high as possible. On the other side,slot
andv-slot
respond to the inner interface of the component by controlling it's ancestors placement within the component and passing data down the render tree. I would like to have that attribute as low as possible so it's closer to the actual elements it's controlling.Basic example of the attribute order I would like to have:
With this change in place users will be able to place slots as close to the ancestors as possible without affecting
ref
andkey
order.Implementation
This is not a breaking change. Users who don't want to control slot attribute position won't have to do so, it will inherit
UNIQUE
position by default. However if you do want to control it you can do it without breaking any existing rules.I've covered this change with a few tests, also updated the docs (version number might need a change though).