Skip to content
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

vue/prefer-true-attribute-shorthand: add except option #2687

Open
FloEdelmann opened this issue Feb 18, 2025 · 0 comments
Open

vue/prefer-true-attribute-shorthand: add except option #2687

FloEdelmann opened this issue Feb 18, 2025 · 0 comments

Comments

@FloEdelmann
Copy link
Member

What rule do you want to change?
vue/prefer-true-attribute-shorthand

Does this change cause the rule to produce more or fewer warnings?
Depends on configuration. No changes by default.

How will the change be implemented? (New option, new default behavior, etc.)?
New option except that allows specifying attribute names that should be specified in longhand form if the rule is set to always or in shorthand form if the rule is set to never.

Please provide some example code that this change will affect:

{
  "vue/prefer-true-attribute-shorthand": ["error", "always", {
    "except": ["value", "/^foo-/"]
  }]
}
<template>
  <MyComponent is-shorthand :value="true" foo-bar />
</template>

What does the rule currently do for this code?
It doesn't warn for is-shorthand and foo-bar, but it warns for value.

What will the rule do after it's changed?
It still shouldn't warn for is-shorthand, but it shouldn't warn for value and should warn for foo-bar.

Additional context
The motivating example uses PrimeVue's RadioButton component:

<template>
  <RadioButton v-model="likesPizza" name="pizza" :value="true" />
  <RadioButton v-model="likesPizza" name="pizza" :value="false" />
</template>

Using the shorthand syntax for the first component's value prop would be less readable.

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

No branches or pull requests

1 participant