-
-
Notifications
You must be signed in to change notification settings - Fork 680
Rule Proposal: vue/component-tags-order
#140
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
Comments
vue/component-tags-order
Thank you for this proposal! Sounds good to me. |
We'll have to discuss the best default for this. I think
I'll ping some other contributors for their thoughts here. |
@chrisvfritz This make sense. |
@chrisvfritz We switched to script, template, style a while back at my company for the reasons you mentionned |
In my experience I've written components with no |
Some small thoughts on this enforcement. While consistency is a really good thing, there are some conditions that not one rule suits for every use case and component. template > style > scriptConsider when a component has a LOT of styles. Every time we need to check the relation between VM and template we need to either fold style tag or scroll a LOT to the end of the file to see the js part. template > script > styleThe same as previous, when there are LOTS of js logic. Adding any simple style needs LOTS of scrolling between template and style parts. Personally, I use a rule of the thumb that count/estimate lines of the code for each section in component and put the longest part to the end so the code is more READABLE. Suggestion for this rule proposal:
|
@pi0 This is considerably more complicated, and does not respond to the initial demand. Why not, but I think it should be added later as an option for this rule. |
I would like to have a rule like this. Is there anything I can do to help this to completion? |
@mario-d-s You'd be welcome to develop it! I'm thinking that for now though, this rule would remain uncategorized and therefore would have no default. Eventually, I'd probably like to make sure this rule supports autofix, then add it to the style guide under The only thing holding me back is that we've mostly encouraged |
Actually, we could add it to |
@chrisvfritz I'd be happy to give it a shot. Your suggestion about "optional" ordering looks good. Do note that I have zero experience writing ESLint rules so this will probably take me some time. |
Unfortunately it's not possible to implement at this moment @mario-d-s The Could we perhaps get the following AST @mysticatea?
It would make things easier, and maybe we wouldn't even need an extra template body visitor (though it's just my lucky guess).
Alternatively we might add an extra field next to Looking once again at I'm happy to help and hear your thoughts @mysticatea |
Please describe what the rule should do:
This rule warns about the order of the script, template & style tags.
What category of rule is this? (place an "X" next to just one item)
[x]
Enforces code style[ ]
Warns about a potential error[ ]
Suggests an alternate way of doing something[ ]
Other (please specify:)Provide 2-3 code examples that this rule will warn about:
vue/component-tags-order: ["warning", order: [ "script", "template", "style" ] ];
However, the following should be considered fine:
The text was updated successfully, but these errors were encountered: