script/custom-event-name-casing
Enforce configured casing for emitted custom event names.
| Default severity | Presets | Automatic fix | Options |
|---|---|---|---|
error |
opinionated, nuxt |
No | Rule options |
Applies to: JS/TS scripts in Vue SFCs; examples show the relevant Options API or script setup form.
Bad
The emitted string my-event contains a hyphen and violates the default camelCase event naming policy.
<script setup lang="ts">
const emit = defineEmits(['my-event'])
emit('my-event') // kebab-case → report
</script>
Good
Both the declaration and call use myEvent, preserving agreement while satisfying the global camelCase default. The opinionated preset selects kebab-case instead, and explicit rule options can also select lowercase names such as transitionstart.
<script setup lang="ts">
const emit = defineEmits(['myEvent'])
emit('myEvent')
</script>
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"script/custom-event-name-casing": "error"
}
},
});
Then run vp run lint.