vue/mustache-interpolation-spacing
mustache 内の空白を揃えます。
| 既定の重大度 | プリセット | 自動修正 | オプション |
|---|---|---|---|
warning |
happy-path, nuxt, ecosystem, opinionated |
あり | ルールのオプション |
適用範囲:Vue SFC のテンプレートと各ブロック。ルールに必要な script の文脈も例に含めています。
悪い例
補間の式と区切りの間で、片側または両側の空白がありません。
<template>
<div>{{text}}</div>
<div>{{ text}}</div>
<div>{{text }}</div>
</template>
良い例
式と mustache の開始・終了の区切りの間に、それぞれ空白を入れます。
<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 を実行します。