首页 > 其他 > 详细

Vue项目中eslint报错提示记录

时间:2021-05-21 23:58:42      阅读:47      评论:0      收藏:0      [点我收藏+]

技术分享图片

使用eslint,严格模式时

0、设置vscode缩进4格更改为2格

 

1、Missing space before function parentheses的问题,解决:打开.eslint.js文件,在rules中添加下行代码

"space-before-function-paren": 0,

完整版:

module.exports = {
  root: true,
  env: {
    node: true
  },
  extends: [
    ‘plugin:vue/essential‘,
    ‘@vue/standard‘
  ],
  parserOptions: {
    parser: ‘babel-eslint‘
  },
  rules: {
    "space-before-function-paren": 0,
    ‘no-console‘: process.env.NODE_ENV === ‘production‘ ? ‘warn‘ : ‘off‘,
    ‘no-debugger‘: process.env.NODE_ENV === ‘production‘ ? ‘warn‘ : ‘off‘
  }
}

 

2、Expected space or tab after ‘//‘ in comment (spaced-comment)

说明:注释后面需要加tab空格

技术分享图片

技术分享图片 

 

3、报错:error Extra semicolon  (semi)

说明:项目中使用了 Eslint semi 功能,该功能强制使代码必须使用分号( ; ),或者必须不能加( ; ),此项目中使用的是不能加分号功能,将对应行的 分号删除

return;  更改为 return // 删除结尾分号

 

4、Error:Strings must use singlequote(quotes)

说明:vue-cli脚手架创建的项目使用了Eslint严格模式,对于字符串类型的数据String必须要使用单引号,不能使用双引号,否则会报异常。报错信息由第几行标注,将项目中使用双引号的地方更改为单引号

current: "/"   更改为    current: ‘/‘

 

5、报错:error  Unexpected trailing comma  

说明:对象最后一个数据不需要写逗号,删除报错行号后面对应的逗号,

技术分享图片

 

 

6、报错:error Newline required at end of file but

说明:文件的末尾需要有空的一行。在最后加上一行空白

技术分享图片

 

 

7、其他,基本都是空格问题

 

重启浏览器运行项目:正常

 

 

  

 

Vue项目中eslint报错提示记录

原文:https://www.cnblogs.com/cdj61/p/14797421.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!