Appearance
vue/block-lang
禁止使用除可用
lang
之外的其他操作¥disallow use other than available
lang
📖 规则详情
此规则禁止在块元素的 lang 属性中使用除应用中可用的语言以外的其他语言。
¥This rule disallows the use of languages other than those available in the your application for the lang attribute of block elements.
🔧选项
¥🔧 Options
json
{
"vue/block-lang": ["error",
{
"script": {
"lang": "ts"
}
}
]
}
为选项对象的键指定块名称。你可以将对象用作值并使用以下属性:
¥Specify the block name for the key of the option object.\ You can use the object as a value and use the following properties:
lang
...指定块的lang
属性的可用值。如果有多种语言可用,请将它们指定为数组。如果你不指定它,将禁止任何语言。¥
lang
... Specifies the available value for thelang
attribute of the block. If multiple languages are available, specify them as an array. If you do not specify it, will disallow any language.allowNoLang
...如果是true
,则允许不指定lang
属性(允许使用块的默认语言)。¥
allowNoLang
... Iftrue
, allows thelang
attribute not to be specified (allows the use of the default language of block).
注意
如果为 <template>
、<style>
和 <script>
的 lang
选项指定了默认语言,则将强制不指定 lang
属性。这是为了防止 Vetur 出现意外问题。
¥If the default language is specified for lang
option of <template>
, <style>
and <script>
, it will be enforced to not specify lang
attribute.\ This is to prevent unintended problems with Vetur.
另请参阅 Vetur - 语法高亮。
¥See also Vetur - Syntax Highlighting.
{ script: { lang: 'js' } }
与 { script: { allowNoLang: true } }
相同。
¥Same as { script: { allowNoLang: true } }
.
🚀版本
¥🚀 Version
此规则在 eslint-plugin-vue v7.15.0 中引入
¥This rule was introduced in eslint-plugin-vue v7.15.0
🔍代码实现
¥🔍 Implementation