script/valid-next-tick
Require the result of a nextTick() call to be awaited, chained, or given a callback.
| Default severity | Presets | Automatic fix | Options |
|---|---|---|---|
warning |
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 imported nextTick() is a bare expression with no callback, so its returned Promise is ignored and no work waits for the DOM flush.
<script setup lang="ts">
import { nextTick } from "vue";
nextTick();
</script>
Good
await nextTick() consumes the Promise and explicitly waits for the next DOM update before subsequent setup code continues.
<script setup lang="ts">
import { nextTick } from "vue";
await nextTick();
</script>
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"script/valid-next-tick": "warn"
}
},
});
Then run vp run lint.