报错“Component name "Home" should always be multi-word.”
在根目录创建.eslintrc.js文件
module.exports = {
root: true,
env: {
node: true,
},
extends: ["plugin:vue/essential", "eslint:recommended"],
parserOptions: {
parser: "@babel/eslint-parser",
},
rules: {
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off", //在rules中添加自定义规则 //关闭组件命名规则
"vue/multi-word-component-names": "off",
"vue/no-multiple-template-root": "off"
},
overrides: [
{
files: [
"**/__tests__/*.{j,t}s?(x)",
"**/tests/unit/**/*.spec.{j,t}s?(x)",
],
env: {
jest: true,
},
},
],
};
2.创建interface报错(之前有个import type也报错,但是这样之后就好了,可能和这个也有关系)
Parsing error: The keyword 'interface' is reserved
后来发现以下方法可以解决问题:添加
.eslintrc.js文件
'parser': '@typescript-eslint/parser',记得需要安装依赖
npm install @typescript-eslint/parser --save-dev。
3.v-modal报错
'v-model' directives require no argument vue/no-v-model-argument

在
.eslintrc.js文件添加rules: {
"vue/no-v-model-argument": "off"
}
需要手动重启服务器
4.'xxxx' is defined but never used
.eslintrc.js中找到 eslintConfig 块,在其rules下加入"no-unused-vars": "off"即可
需要手动重启服务器
5.Ref<boolean>无法赋值给 <boolean>类型
const res = ref(true)
// 赋值的时候需要用 res.value
const temp:boolean = res.value
解决Vue项目中ESLint常见报错
923

被折叠的 条评论
为什么被折叠?



