美文网首页Visual Studio Code
VS Code 不支持ES6语法 报错解决办法

VS Code 不支持ES6语法 报错解决办法

作者: 2f25a5d8710f | 来源:发表于2017-08-03 18:05 被阅读277次

案发现场

用VS Code开发ES6语法的项目,Promise等关键字和语法不识别,报错。

破案

在项目根目录下建两个文件: .eslintrc.js .eslintignore
.eslintrc.js


// http://eslint.org/docs/user-guide/configuring

module.exports = {
  root: true,
  parser: 'babel-eslint',
  parserOptions: {
    sourceType: 'module'
  },
  env: {
    browser: true,
  },
  // https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
  extends: 'standard',
  // required to lint *.vue files
  plugins: [
    'html'
  ],
  // add your custom rules here
  'rules': {
    // allow paren-less arrow functions
    'arrow-parens': 0,
    // allow async-await
    'generator-star-spacing': 0,
    // allow debugger during development
    'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
  }
}


.eslintignore

build/*.js
config/*.js

具体的配置项说明

相关文章

网友评论

    本文标题:VS Code 不支持ES6语法 报错解决办法

    本文链接:https://www.haomeiwen.com/subject/gioplxtx.html