Skip to content

feat: add new v-bind-same-name-style rule #2374

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

Closed
wants to merge 3 commits into from

Conversation

waynzh
Copy link
Member

@waynzh waynzh commented Jan 23, 2024

close #2359.

Still figuring out how to categorize and set default value for this new rule. For now, I've set never as the default to avoid causing any breaking changes.

@waynzh waynzh marked this pull request as ready for review January 23, 2024 17:02
@ota-meshi
Copy link
Member

Thank you for working on this change.
However, I would rather add new options to existing vue/v-bind-style rule than add new rule. What do you think?
(Sorry, I should have commented on this earlier.)

@waynzh
Copy link
Member Author

waynzh commented Jan 27, 2024

I would rather add new options to existing vue/v-bind-style rule

Thanks for your input.

I've been contemplating whether to integrate this feature within the existing rule or to implement it as a separate one. I'm later leaning towards a separate rule as this rule particularly targets for cases where the key and value are the same name, one could use in longform and still omit the value.

Before next move, I'd like to gather opinions on the best way to incorporate this feature in vue/v-bind-style. Here are some options I'm considering:

  1. Introduce a sameNameShorthand enum that keeps the rule in shorthand form (e.g., :foo=”bar”) and omits the value only when it has same name :foo="foo":foo .
  2. Modify the option to accept an array, allowing for combinations like ['longform', 'sameNameShorthand']. So they can be v-bind:foo="bar", but v-bind:foo="foo"v-bind:foo. (But ['longform', 'shorthand'] is invalid one.)
  3. I'm open to other suggestions as well.

What do you think? I'm looking forward to your insights.

@ota-meshi
Copy link
Member

My idea is to add a third object option.
This is probably what @FloEdelmann wrote in #2359.

{
   "vue/v-bind-style": [
     "error",
     "shorthand", // "shorthand", or "longform"
     {
       "sameNameShorthand": "ignore" // "always", "never", or "ignore"
     }
   ]
}

@waynzh
Copy link
Member Author

waynzh commented Jan 28, 2024

Yeah, that makes sense to me. I'll close this PR for now, and when I find some time, I'll complete it and then open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enforce/disallow v-bind same name shorthand style
2 participants