-
-
Notifications
You must be signed in to change notification settings - Fork 681
Rule proposal: padding-line-between-component-options
#1817
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
Thank you for your proposal. Do you have any ideas to clarify those roles? |
This suggested rule focuses solely on 'top-level' options (i.e. data, props, computed, ...), while the My team and I style components with padding lines in top-level, but not nested properties: export default {
name: 'QIcon',
props: {
value: {
type: String,
required: true
},
focused: {
type: Boolean,
default: false,
required: true
},
label: String,
icon: String
},
computed: {
that() {
return true
},
these () {
return false
}
}
} I think there is room for both behaviours, but this rule's behaviour could be toggled by an option (e.g. Finally, the other rule's naming might be ambiguous, as I did not interpret "new-line" to be the same as an "empty line" or "padding line". I did search for existing similar rules but missed How would you suggest we proceed? |
empty-line-between-options
padding-line-between-component-options
I think we need to deprecate the The new rule should be able to set the cc @FloEdelmann
Since there is no rule naming convention, the rule name is determined by the rule proposer, implementer, and reviewer when the rule is implemented. So the rule names may not be unified. However, it is difficult to make a breaking change to rename after adding a rule. |
Ah, I reckoned there was a similar rule, but couldn't find it either. I also support to deprecate
|
We cannot add an option to specify the number of rows in the empty lines. Forcing more than one empty line conflicts with ESLint's core rule no-multiple-empty-lines. https://eslint.org/docs/rules/no-multiple-empty-lines The rule should only check if it has empty lines. I don't think the name {
computed: {
myProp: {
get () {
// ...
},
set (newValue) {
// ...
}
}
},
watch: {
myProp: {
handler (val, oldVal) {
// ...
},
deep: true
},
}
} |
I noticed how I had to consider whether to check |
That suggestion was based on the current options of
If we decide to not check for a specific number, these names are good. I also updated my comment to change
Unfortunately, I couldn't come up with a better name. What do you suggest instead?
Ah, indeed. I added it to my comment. |
The number specified in the options of the
I haven't formed an opinion yet, but what about using the name |
|
Ah, you're right.
Nevermind, I changed my mind during writing this comment. This suggestion gets too messy. DetailsEach rule could then have one string option (
|
Since "vue/padding-lines-in-component-definition": {
"padding": "always" | "never" | "ignore"
// defaults to value of "padding"
"options": "always" | "never" | "ignore"
// defaults to value of "padding"
"computed": "always" | "never" | "ignore"
// ...
} |
@barthy-koeln's suggestion goes in a similar direction as the one that I rejected during writing. So maybe it's worth to go that route. Combining my original suggestion with @barthy-koeln's: 1. Add a new rule with the following options: "vue/padding-lines-in-component-definition": {
// top level
"options": "always" | "never" | "ignore", // e.g. between `props` and `data`, defaults to "always"
// second level
"emits": "always" | "never" | "ignore", // also checks `defineEmits`, defaults to "always"
"props": "always" | "never" | "ignore", // also checks `defineProps`, defaults to "always"
"computed": "always" | "never" | "ignore", // defaults to "always"
"watch": "always" | "never" | "ignore", // defaults to "always"
"methods": "always" | "never" | "ignore", // defaults to "always"
// third level
"computedOptions": "always" | "never" | "ignore", // e.g. between `get` and `set`, defaults to "always"
"watchOptions": "always" | "never" | "ignore", // e.g. between `handler` and `deep`, defaults to "always"
"groupSingleLineProperties": true | false, // defaults to true
} | "always" | "never" // shortcut to set them all 2. Deprecate the Changes to @barthy-koeln's suggestion:
|
FYI I have some time off (18.03. - 28.03.) and would like to submit an implementation once we agree on a schema. |
See #1390 |
@ota-meshi @barthy-koeln What do you think about my last suggestion? I think if you both give it a thumbs-up, then it's ready to be implemented. @inker Thanks for linking #1390. The consensus in both that issue and this one seems to be that it's necessary to add the possibility to specify the padding per scope. What do you think about the last suggestion? |
I think the options @FloEdelmann have suggested are mostly good. "vue/padding-lines-in-component-definition": {
// top level
"options": "always" | "never" | "ignore", // e.g. between `props` and `data`, defaults to "always"
// second level
"properties": { // There may be a better name.
// Vue builtin
"emits": "always" | "never" | "ignore", // also checks `defineEmits`, defaults to "always"
"props": "always" | "never" | "ignore", // also checks `defineProps`, defaults to "always"
"data": "always" | "never" | "ignore",
"methods": "always" | "never" | "ignore",
"computed": {
// second level
"keys": /*There may be a better name.*/ "always" | "never" | "ignore",
// third level
"options": /*There may be a better name.*/ "always" | "never" | "ignore",
},
// Custom
"foo": "always" | "never" | "ignore",
"bar": {
"keys": "always" | "never" | "ignore",
"options": "always" | "never" | "ignore",
},
// ..
},
"groupSingleLineProperties": true | false, // defaults to true
} I haven't yet checked if there are any well-known custom options for which this rule should be applied. |
I like the freedom of configuration this provides, but I'm not happy with the names yet. We always configure either padding lines between items or within each item. Here's an attempt to clarify this: "vue/padding-lines-in-component-definition": {
"betweenOptions": "always" | "never" | "ignore", // e.g. between `props` and `data`, defaults to 'always'
"withinOption": {
"emits": "always" | "never" | "ignore", // padding between two emit definitions
"props": {
"betweenItems": "always" | "never" | "ignore", // padding between two props
"withinEach": "always" | "never" | "ignore", // padding between `type`, `default`, `required`, ...
} | "always" | "never" | "ignore", // shortcut to set both
"computed": {
"betweenItems": "always" | "never" | "ignore", // padding between two computed properties
"withinEach": "always" | "never" | "ignore", // padding between `get` and `set` methods
} | "always" | "never" | "ignore", // shortcut to set both
// ...
},
"groupSingleLineProperties": true | false, // defaults to true
} | "always" | "never", // shortcut to set all This can be read as understandable sentences:
|
Thanks @ota-meshi for the thumbs-up, can I understand this as an approval? @FloEdelmann any further notes? |
Yes! I think the option you proposed is good. |
I don't have any further notes, the suggestions looks fine. |
Please describe what the rule should do:
Enforces empty lines between top-level options of Vue components.
What category should the rule belong to?
Provide 2-3 code examples that this rule should warn about:
Additional context
The text was updated successfully, but these errors were encountered: