vue/prefer-template
Prefer template literals in template expressions.
| 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
String concatenation mixes a literal with name.
<template>
<p>{{ "Hello " + name }}</p>
</template>
Good
A template literal keeps interpolation in one string.
<template>
<p>{{ `Hello ${name}` }}</p>
</template>
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"vue/prefer-template": "warn"
}
},
});
Then run vp run lint.