vue/no-useless-mustaches
Disallow a mustache interpolation whose expression is a constant string literal.
| Default severity | Presets | Automatic fix | Options |
|---|---|---|---|
warning |
nuxt, opinionated |
No | None |
Applies to: Vue SFC templates and blocks, with script context where the rule requires it.
Bad
The interpolation contains only a constant string and does not need expression evaluation.
<template>
<div>{{ 'x' }}</div>
<div>{{ "x" }}</div>
<div>{{ `x` }}</div>
</template>
Good
Literal text is written directly; variable expressions, interpolated template strings, and intentional separator whitespace remain interpolation cases.
<template>
<div>x</div>
<div>{{ x }}</div>
<div>{{ `pre-${x}` }}</div>
<span>A</span> {{ " " }} <span>B</span>
</template>
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"vue/no-useless-mustaches": "warn"
}
},
});
Then run vp run lint.