Type and script rules
Checks for <script> and <script setup>: compiler macros, reactivity, props and emits, and rules that use TypeScript type information.
Each rule page shows a failing example, a passing example, and the configuration that turns the rule on.
Essential (39)
Correctness rules in the essential preset.
| Rule | What it checks | Auto-fix |
|---|---|---|
script/no-arrow-functions-in-watch |
Disallow arrow functions as Options API watch handlers. | |
script/no-async-in-computed |
Disallow async functions in computed properties. | |
script/no-computed-properties-in-data |
Disallow using computed properties inside the component data function. | |
script/no-deprecated-data-object-declaration |
Disallow an object literal as the component data option (Vue 3 requires a function). | |
script/no-deprecated-delete-set |
Disallow Vue 2 $set and $delete, which were removed in Vue 3. | |
script/no-deprecated-destroyed-lifecycle |
Disallow deprecated destroyed and beforeDestroy lifecycle hooks. | ✓ |
script/no-deprecated-dollar-listeners-api |
Disallow the $listeners instance property removed in Vue 3 (merged into $attrs). | |
script/no-deprecated-dollar-scopedslots-api |
Disallow the $scopedSlots instance property removed in Vue 3 (use $slots). | |
script/no-deprecated-events-api |
Disallow the removed Vue 2 events API ($on / $off / $once). | |
script/no-deprecated-model-definition |
Disallow the Vue 2 model option, which was removed in Vue 3. | |
script/no-deprecated-props-default-this |
Disallow this inside a prop default/validator function (removed in Vue 3). |
|
script/no-deprecated-vue-config-keycodes |
Disallow Vue.config.keyCodes, which was removed in Vue 3. | |
script/no-dupe-keys |
Disallow duplicate keys across Options API props/data/computed/methods/setup/inject. | |
script/no-duplicate-attr-inheritance |
Flag a component that applies its fallthrough attributes twice. | |
script/no-export-in-script-setup |
Disallow export statements inside <script setup>. | |
script/no-expose-after-await |
Disallow expose() and defineExpose() after an await. | |
script/no-import-compiler-macros |
Disallow importing Vue compiler macros that are auto-imported. | |
script/no-internal-imports |
Disallow importing from Vue internal modules. | |
script/no-lifecycle-after-await |
Disallow lifecycle hooks registered after an await in setup(). | |
script/no-potential-component-option-typo |
Flag likely typos in Options API component option names. | |
script/no-ref-as-operand |
Require ref-bound variables to be accessed via .value when used as an operand. |
|
script/no-required-prop-with-default |
Disallow a prop that is both required: true and has a default. | |
script/no-reserved-identifiers |
Disallow using Vue compiler reserved identifiers. | |
script/no-reserved-keys |
Disallow Vue-reserved names as Options API props/data/computed/methods/setup keys. | |
script/no-reserved-props |
Disallow reserved names in a component's props declaration. | |
script/no-side-effects-in-computed-properties |
Disallow side effects in Options API computed getters. | |
script/no-use-computed-property-like-method |
Disallow calling an Options API computed property like a method. | |
script/no-watch-after-await |
Disallow watchers registered after an await in setup() without keeping their stop handle. | |
script/prefer-import-from-vue |
Prefer importing from 'vue' instead of internal packages. | ✓ |
script/require-prop-type-constructor |
Require prop type values to be constructors rather than string literals. |
|
script/require-render-return |
Require the component render function to return a value. | |
script/require-slots-as-functions |
Require $slots properties to be called as functions. | |
script/require-valid-default-prop |
Require a prop's default value to be valid for its declared type. | |
script/return-in-computed-property |
Require a return value in every computed getter. | |
script/return-in-emits-validator |
Require a return value in every Vue emits validator. | |
script/valid-define-emits |
Enforce valid defineEmits() usage (no type+runtime args, no local references, single call). | |
script/valid-define-options |
Enforce valid defineOptions() usage (single object arg, no props/emits/expose/slots). | |
script/valid-define-props |
Enforce valid defineProps() usage (single call, not both type and runtime args, no local references). | |
script/valid-next-tick |
Require the result of a nextTick() call to be awaited, chained, or given a callback. |
Default (5)
Added by happy-path, the default preset.
| Rule | What it checks | Auto-fix |
|---|---|---|
script/no-multiple-slot-args |
Disallow passing more than one argument to a scoped-slot function call. | |
script/no-unstable-nested-components |
Disallow component definitions inside setup or render functions. | |
script/require-explicit-emits |
Require emitted events to be declared in defineEmits or the emits option. | |
type/require-typed-emits |
Require type definition for defineEmits. | |
type/require-typed-props |
Require type definition for defineProps. |
Stricter presets (22)
Only in opinionated, nuxt or ecosystem. The Presets column lists which.
| Rule | What it checks | Presets | Auto-fix |
|---|---|---|---|
script/component-options-name-casing |
Enforce PascalCase for the component name option. |
opinionated, nuxt |
|
script/custom-event-name-casing |
Enforce configured casing for emitted custom event names. | opinionated, nuxt |
|
script/define-emits-declaration |
Enforce the type-based defineEmits<{}>() form over the runtime/array form. | opinionated, nuxt |
|
script/define-macros-order |
Enforce a consistent order of the Vue compiler macros in <script setup>. | opinionated, nuxt |
|
script/define-props-declaration |
Enforce type-based defineProps<{ ... }>() over the runtime/object form. | opinionated, nuxt |
|
script/no-boolean-default |
Disallow a default on a Boolean prop. | opinionated, nuxt |
|
script/no-deep-destructure-in-props |
Disallow deeply nested destructuring in defineProps. | opinionated, nuxt |
|
script/no-get-current-instance |
Disallow getCurrentInstance() in Vapor mode (returns null). | opinionated |
|
script/no-options-api |
Disallow Options API patterns in Vapor mode. | opinionated |
|
script/no-unused-emit-declarations |
Flag declared events that are never emitted. | opinionated, nuxt |
|
script/no-with-defaults |
Discourage withDefaults in favor of destructuring defaults (Vue 3.5+). | opinionated |
|
script/one-component-per-file |
Disallow more than one component definition in a file. | opinionated, nuxt |
|
script/order-in-components |
Enforce the default order of properties in component options. | opinionated, nuxt |
|
script/prefer-define-options |
Prefer defineOptions() over a plain <script> that only sets name/inheritAttrs. | opinionated, nuxt |
|
script/prefer-use-template-ref |
Recommend useTemplateRef over ref for template references (Vue 3.5+). | opinionated, nuxt |
|
script/require-default-prop |
Require a default value for every optional, non-Boolean prop. | opinionated, nuxt |
|
script/require-explicit-slots |
Require slots consumed via useSlots() to be explicitly typed with defineSlots<...>(). | opinionated, nuxt |
|
script/require-prop-types |
Require every prop to declare a type. | opinionated |
|
script/require-typed-object-prop |
Require an explicit type on a prop whose runtime type is Object or Array. |
opinionated, nuxt |
|
type/no-floating-promises |
Disallow floating (unhandled) Promises. | nuxt, opinionated |
|
type/no-reactivity-loss |
Disallow plain snapshots of reactive values across assignments and calls. | nuxt, opinionated |
|
type/no-unsafe-template-binding |
Disallow template bindings that resolve to unsafe types. | nuxt, opinionated |
Opt-in (16)
Not in any preset. Turn them on by name in the linter.rules passed to withVue.
| Rule | What it checks | Auto-fix |
|---|---|---|
script/define-props-destructuring |
Enforce consistent style for defineProps destructuring in <script setup>. | |
script/no-next-tick |
Disallow nextTick() usage in Vapor-oriented components. | |
script/no-reactive-destructure |
Disallow destructuring reactive objects which loses reactivity. | |
script/no-restricted-globals |
Disallow references to runtime-environment globals that must go through a typed wrapper. | |
script/no-restricted-members |
Disallow project-configured object.property member accesses. | |
script/no-top-level-ref-in-script |
Disallow top-level ref/reactive to prevent Cross-Request State Pollution. | |
script/prefer-computed |
Prefer computed() for derived reactive state. | |
script/prefer-define-emits-binding |
Prefer the captured defineEmits function over template $emit. | ✓ |
script/prefer-ref-over-reactive |
Recommend using ref() over reactive() for state management. | |
script/prefer-use-attrs |
Recommend using useAttrs() over context.attrs. | |
script/prefer-use-id |
Recommend using useId() for generating unique IDs (Vue 3.5+). | |
script/prefer-use-slots |
Recommend using useSlots() over context.slots. | |
script/require-function-return-type |
Require return type annotations on functions. | |
script/require-symbol-provide |
Recommend using Symbol as injection key for provide/inject. | |
script/require-typed-ref |
Require an explicit type argument on a ref() initialized with no value, null, or undefined. | |
type/strict-boolean-expressions |
Require safe boolean expressions in script and template conditions. |