vue/no-literals-in-template
Disallow object, array and function literals in v-bind.
| Default severity | Presets | Automatic fix | Options |
|---|---|---|---|
warning |
None | No | None |
Applies to: Vue SFC templates and blocks, with script context where the rule requires it.
Bad
The object literal creates a new binding value during rendering.
<template>
<Widget :options="{ eager: true }" />
</template>
Good
A stable script binding supplies the options object.
<template>
<Widget :options="options" />
</template>
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"vue/no-literals-in-template": "warn"
}
},
});
Then run vp run lint.