script/no-unstable-nested-components
Disallow component definitions inside setup or render functions
Default severity: warning
Presets: happy-path, ecosystem, nuxt, opinionated
Automatic fix: None; review the suggested change
Applies to: JS/TS scripts in Vue SFCs; examples show the relevant Options API or script setup form
Options: No rule-specific options. Severity and preset selection are configurable.
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({
lint: {
vize: {
"preset": "incremental",
"rules": {
"script/no-unstable-nested-components": "warn"
}
},
},
});
vp run lint
Bad
defineComponent runs inside the parent’s setup(), creating a new Child component definition whenever that setup executes.
<script lang="ts">
import { defineComponent } from "vue";
export default { setup() { const Child = defineComponent({ render() { return null; } }); return { Child }; } };
</script>
Good
The Child definition moves to module scope, and setup() returns that existing definition instead of recreating it.
<script lang="ts">
import { defineComponent } from "vue";
const Child = defineComponent({ render() { return null; } });
export default { setup() { return { Child }; } };
</script>
Good avoids this rule's finding under the configuration above; other rules may still report diagnostics.