[英]How to enforce lang="ts" in script tags with an ESLint rule in Vue
I'm looking for a way to enforce that everyone working on our code base use TypeScript for Single File Components.我正在寻找一种方法来强制执行我们代码库的每个人都将 TypeScript 用于单文件组件。 All the components use TypeScript, so disabling JavaScript is also an option.
所有组件都使用 TypeScript,因此禁用 JavaScript 也是一种选择。
I thought that this could be done with an ESLint rule, but I can't find it.我认为这可以通过 ESLint 规则来完成,但我找不到。
This feature is now available in eslint-plugin-vue
.此功能现在在
eslint-plugin-vue
中可用。 Use the vue/block-lang
rule.使用
vue/block-lang
规则。
// .eslintrc.json
{
"vue/block-lang": ["error",
{
"script": {
"lang": "ts"
}
}
]
}
https://eslint.vuejs.org/rules/block-lang.html#vue-block-lang https://eslint.vuejs.org/rules/block-lang.html#vue-block-lang
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.