vue/next-tick-style
Exige le style Promise pour nextTick.
| Gravité par défaut | Préréglages | Correction automatique | Options |
|---|---|---|---|
warning |
Aucune | Non | Aucune |
Champ d’application : Templates et blocs des SFC Vue, avec le contexte du script requis par la règle.
Mauvais
Un callback est passé à nextTick.
<script setup>
import { nextTick } from "vue"
nextTick(() => focusInput())
</script>
<template />
Bon
Le code attend la Promise avant de continuer.
<script setup>
import { nextTick } from "vue"
await nextTick()
focusInput()
</script>
<template />
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"vue/next-tick-style": "warn"
}
},
});
Lancez ensuite vp run lint.