zoukankan      html  css  js  c++  java
  • Vue项目中eslint报错提示记录

    使用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、其他,基本都是空格问题

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

      

  • 相关阅读:
    HDU 1507 Uncle Tom's Inherited Land*
    HDU 2527 Safe Or Unsafe (哈夫曼树)
    HDU More lumber is required
    HDU Machine Schedule
    HDU 3709 Balanced Number (数位DP)
    HDU Number Sequence (容斥原理)
    csharp: word or excel Convert to PDF
    csharp: winform using Microsoft.Ink(Tablet PC API) create Signature image
    Create Ms Word doc using Javascript And vbscript
    sql distinct
  • 原文地址:https://www.cnblogs.com/cdj61/p/14797421.html
Copyright © 2011-2022 走看看