vue/mustache-interpolation-spacing
要求双花括号插值内部的空格保持一致。
| 默认严重程度 | 预设 | 自动修复 | 选项 |
|---|---|---|---|
warning |
happy-path, nuxt, ecosystem, opinionated |
支持 | 规则选项 |
适用范围:Vue SFC 模板和代码块,包括规则所需的脚本上下文。
错误示例
文本插值在一个或两个分隔符边界处缺少空格。
<template>
<div>{{text}}</div>
<div>{{ text}}</div>
<div>{{text }}</div>
</template>
正确示例
表达式与双花括号的起止分隔符之间均有空格。
<template>
<div>{{ text }}</div>
<div>{{ foo.bar }}</div>
<div>{{ foo + bar }}</div>
</template>
配置(Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"vue/mustache-interpolation-spacing": "warn"
}
},
});
然后运行 vp run lint。