vue/prefer-single-event-payload
eslint-plugin-vue
No autofix
eslint.config.js
import vue from "eslint-plugin-vue";
export default [
{
plugins: { vue },
rules: {
"vue/prefer-single-event-payload": "error",
},
},
]; <button @click="$emit('update', value, extra)" />
</template>
<script>
export default {
emits: { update: (value, extra) => value != null,
},
methods: {
handleClick() { this.$emit('update', value, extra)
}
}
}
</script><button @click="$emit('update', { value, extra })" />change: (payload) => payload != null,this.$emit('change', { value, extra })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-single-event-payload
eslint-plugin-vue
import vue from "eslint-plugin-vue";
export default [
{
plugins: { vue },
rules: {
"vue/prefer-single-event-payload": "error",
},
},
];Oxlint does not have this rule.
nursery/useVueSingleEventPayload
nursery · since 2.6.5
{
"linter": {
"rules": {
"nursery": {
"useVueSingleEventPayload": "error"
}
}
}
}Enforce Boolean comes first in component prop types
Require shorthand form attribute when v-bind value is true
Require using useTemplateRef instead of ref/shallowRef for template refs
Disallow unnecessary concatenation of literals or template literals in <template>