script/no-next-tick
Disallow nextTick() usage in Vapor-oriented components.
| Default severity | Presets | Automatic fix | Options |
|---|---|---|---|
error |
None | No | None |
Applies to: Vapor-oriented script checks; explicit enablement also applies the restriction to ordinary scripts.
Bad
The Vapor-oriented component imports and awaits nextTick, introducing the DOM-flush scheduling dependency that this migration rule rejects.
<script setup lang="ts" vapor>
import { nextTick } from "vue";
await nextTick();
</script>
Good
The input is obtained through useTemplateRef and focused at onMounted. The explicit mount boundary replaces the example’s nextTick dependency.
<script setup lang="ts" vapor>
import { onMounted, useTemplateRef } from "vue";
const input = useTemplateRef<HTMLInputElement>("input");
onMounted(() => { input.value?.focus(); });
</script>
<template><input ref="input"></template>
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"script/no-next-tick": "error"
}
},
});
Then run vp run lint.