vue/prefer-true-attribute-shorthand
eslint-plugin-vue
Suggestion
eslint.config.js
import vue from "eslint-plugin-vue";
export default [
{
plugins: { vue },
rules: {
"vue/prefer-true-attribute-shorthand": "error",
},
},
];Require shorthand form attribute when v-bind value is true
<MyComponent v-bind:show="true" />
<MyComponent :show="true" /><MyComponent show /><MyComponent show />
<MyComponent :value="true" />
<MyComponent :foo-bar="true" /> <MyComponent show />
<MyComponent another-prop="true" />
</template> <MyComponent :show="true" />
<MyComponent v-bind:show="true" />
</template> <MyComponent :show="true" />
<MyComponent value />
<MyComponent foo-bar />
</template>Examples from the ESLint documentation.
No tracked preset enables this rule, so it has no reach yet.
None of the tracked presets enable this rule. Turn it on with the config below.
vue/prefer-true-attribute-shorthand
eslint-plugin-vue
import vue from "eslint-plugin-vue";
export default [
{
plugins: { vue },
rules: {
"vue/prefer-true-attribute-shorthand": "error",
},
},
];Oxlint does not have this rule.
nursery/useVueConsistentBooleanPropStyle
nursery · since 2.6.5
{
"linter": {
"rules": {
"nursery": {
"useVueConsistentBooleanPropStyle": "error"
}
}
}
}Enforce passing a single argument to custom event emissions
Require using useTemplateRef instead of ref/shallowRef for template refs
Enforce Boolean comes first in component prop types