原来用vue脚手架搭建项目都是用vue ui,后来不知道为啥总报错,只能用命令行创建项目了,原来在vue ui里面的警告都不怎么管的,现在在powershell里面看着烦,来一起看看吧
Missing space before function parenthese
这个错误是eslint报的错误,报这个错误的原因是函数名称或function关键字与开始参数之间缺少空格,解决办法就是在eslint配置文件.eslintrc.js的rules中填入
"space-before-function-paren": 0
即
module.exports = {
……
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
"space-before-function-paren": 0
},
……
}
Strings must use singlequote
这个警告就是说字符串要使用单引号,这个好解决,在开发的使用记得使用单引号就是,不过对我这个喜欢双引号的来说就不友好了,我们可以在项目的根目录下创建一个“.prettierrc”的文件,添加以下配置
{
"semi": false, // 不显示分号
"singleQuote": true, // 使用单引号
// "printWidth": 200 // 这个的作用是当程序太长时,你可以设置每行最多有多少字符,剩下的字符会换行显示
}
这个配置文件是在你格式化代码时生效,我用的是vscode,格式化代码的快捷键时alt + shift + f
Newline required at end of file but not found (eol-last)
这个问题就奇葩了,说文件末尾没有换行符,在文件的最后一行敲一个回车就行了
Snipaste_2021-04-20_13-48-37.png
Extra semicolon (semi)
额外分号,多了分号,删除即可