script/valid-define-emits
Enforce valid defineEmits() usage (no type+runtime args, no local references, single call).
| Default severity | Presets | Automatic fix | Options |
|---|---|---|---|
error |
essential, happy-path, ecosystem, nuxt, opinionated |
No | None |
Applies to: JS/TS scripts in Vue SFCs; examples show the relevant Options API or script setup form.
Bad
The same defineEmits call supplies both a type argument and the runtime array ["save"], mixing two mutually exclusive declarations.
<script setup lang="ts">
defineEmits<{ save: [] }>(["save"]);
</script>
Good
Removing the runtime argument leaves a single type-based event declaration for save.
<script setup lang="ts">
defineEmits<{ save: [] }>();
</script>
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"script/valid-define-emits": "error"
}
},
});
Then run vp run lint.