vue/no-bare-strings-in-template
禁止在
<template>
中使用裸字符串
📖 规则详情
此规则禁止在 <template>
中使用裸字符串。
为了能够国际化您的应用程序,您需要避免在模板中使用纯字符串。相反,您需要使用专门用于翻译的模板助手。
此规则的灵感来自 ember-template-lint 中的 no-bare-strings 规则。
正在加载...
提示
此规则不检查绑定和花括号插值中的字符串字面量。这是因为它看起来是一个有意识的决定。
如果您想报告这些字符串字面量,请启用 vue/no-useless-v-bind 和 vue/no-useless-mustaches 规则并修复无用的字符串字面量。
🔧 选项
js
{
"vue/no-bare-strings-in-template": ["error", {
"allowlist": [
"(", ")", ",", ".", "&", "+", "-", "=", "*", "/", "#", "%", "!", "?", ":", "[", "]", "{", "}", "<", ">", "\u00b7", "\u2022", "\u2010", "\u2013", "\u2014", "\u2212", "|"
],
"attributes": {
"/.+/": ["title", "aria-label", "aria-placeholder", "aria-roledescription", "aria-valuetext"],
"input": ["placeholder"],
"img": ["alt"]
},
"directives": ["v-text"]
}]
}
allowlist
... 允许的字符串数组。attributes
... 一个对象,其键是标签名称或模式,其值为要检查该标签名称的属性数组。directives
... 要检查文字值的指令名称数组。
👫 相关规则
🚀 版本
此规则在 eslint-plugin-vue v7.0.0 中引入