Vue rules
These 23 rules layer on top of SAFE-TS's core rules, which also apply inside .vue templates and scripts as well as composables (.ts files importing vue). In the oxlint preset, vue-render-cost, vue-deep-watch, and vue-prefer-shallow-ref default to warnings; all other Vue rules are errors.
vue-sfcerrorComponents
A Vue component the checker can't see into: a <script> without lang="ts", or a component without <script setup> written with the Options API (data(), methods). A defineComponent({ setup() { ... } }) is plain code the rules can follow, and isn't reported.
vue-ref-valueerrorFixComponents
A ref used without .value where its value was meant: as a condition, with !, &&, || or ??, or in a template string.
vue-lost-reactivityerrorFixComponents
Reactive state read once where it should stay connected: destructuring a reactive() object, the props or a Pinia store; watching a value read from one (watch(props.id, ...)); or passing such a value to a composable (useUser(props.id)).
vue-setup-after-awaiterrorComponents
A lifecycle hook, watcher, computed, provide/inject or similar Vue API called after an await in a function.
vue-side-effect-in-rendererrorComponents
State changed in a computed getter or while the template renders: an assignment, ++/--, or a method that changes its object (push, sort, reverse, splice, set, delete, ...). Also an async computed getter.
vue-inject-keyerrorComponents
provide or inject with a string as the key.
vue-async-raceerrorAsync and errors
An async watcher that changes state after an await, without cancelling the run before it.
vue-split-stateerrorAsync and errors
Async state kept by hand in refs, set around an await:
vue-ref-without-valueerrorAsync and errors
A ref() made without a value (ref<User>()), set after an await, and shown in the template.
vue-async-componenterrorAsync and errors
defineAsyncComponent(...) without an errorComponent or onError.
vue-matcherrorTemplates
<Match :value="state"> must have a slot for every variant of state's enum type (or #_ for the rest), and every slot must name a variant.
vue-exhaustive-v-iferrorTemplates
A v-if / v-else-if chain that tests the same value's .tag against two or more variants, doesn't end with v-else, and misses a variant of the value's enum type.
vue-maybe-undefinederrorTemplates
The template reads a field or index of a value that may be undefined (x.name, x[0]), and no v-if, &&, ? : or ?. around the read checks it.
vue-template-referrorTemplates
useElement("name") from @evobug_com/safe-ts-vue/element gives the element with ref="name", typed without null. That holds when the element is always rendered and is read after the component is mounted. This rule checks both:
vue-v-for-keyerrorTemplates
A v-for without a :key, keyed by its position in a row that keeps state, or keyed by a new object or array.
vue-v-if-with-v-forerrorTemplates
v-if and v-for on the same element.
vue-render-costwarnPerformance
Work in the template that repeats on every render: sorting, filtering or reducing a whole list, a lookup in a list inside v-for, or a new Intl formatter.
vue-deep-watchwarnPerformance
A deep watcher: watch on a whole reactive() object, the props or a store (which is deep by default), or with { deep: true }.
vue-prefer-shallow-refwarnFixPerformance
ref<T>(...) where T is readonly: readonly T[], Readonly<...>, ReadonlyArray, ReadonlyMap, ReadonlySet.
vue-v-htmlerrorSecurity
v-html with a value that isn't a constant string, the result of a sanitizer, or typed Html.
vue-unsafe-urlerrorSecurity
A bound URL that isn't checked: :href, :action, :formaction, :xlink:href, or :src on an <iframe>.
vue-ssr-browser-globalerrorServer-side rendering
A browser global used while the component is set up or rendered, in an app that also renders on a server: window, document, localStorage, sessionStorage, navigator, location, matchMedia, requestAnimationFrame, innerWidth, innerHeight, getComputedStyle.
vue-hydration-mismatcherrorServer-side rendering
A value that differs between the server and the browser, computed while the component is set up or rendered: Date.now(), new Date(), Math.random(), crypto.randomUUID(), performance.now().
Core rules you'll meet in Vue components
| Rule | In a component |
|---|---|
no-mutable-global | state in a plain <script> block or at the top of a composable file (State) |
no-param-mutation | changing props, v-model on a prop (State) |
uncaught-propagation | a PropagateError leaving an event handler (Errors) |
floating-rejection | an async handler that can reject (Errors) |
must-use-result | a Result returned from a handler (Errors) |
unhandled-failure | JSON.parse in a template, router.push() with the vue-router pack (vue-router) |
listener-cleanup | listeners and intervals a component starts and never stops (Cleanup) |