vue/no-bare-strings-in-template
Disallow raw human-readable text in the template that should be internationalized
Default severity: warning
Presets: none
Automatic fix: None; review the suggested change
Applies to: Vue SFC templates and blocks, with script context where the rule requires it
Options: No rule-specific options. Severity and preset selection are configurable.
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({
lint: {
vize: {
"preset": "incremental",
"rules": {
"vue/no-bare-strings-in-template": "warn"
}
},
},
});
vp run lint
Bad
Visible text and naming attributes embed untranslated strings directly in the template.
<template>
<div>hello</div>
<img alt="a cat" />
<input placeholder="Search" />
<button title="Close">x</button>
</template>
Good
Translatable content calls $t; the punctuation and numeric-only examples are allowed exceptions.
<template>
<div>{{ $t('hello') }}</div>
<img :alt="$t('cat')" />
<div>-</div>
<div>123</div>
<button :title="$t('close')">{{ $t('x') }}</button>
</template>
Good avoids this rule's finding under the configuration above; other rules may still report diagnostics.