Vue.js eslint解析错误。:意外令牌

时间:2018-03-06 11:04:30

标签: javascript vue.js eslint

我在state.js文件中遇到此错误(在const配置文件中at =>) 无法理解为什么......感谢您的反馈

create global temporary table temp (
  col1 ...
  col2 );
来自vue-cli的标准eslint conf。 webpack init

.eslintrc.js

const credentials = {
  email: '',
  password: ''
}
const profile = {
=>    userId: '',
  gender: '',
  firstName: '',
  lastName: '',
  address: '',
  zipCode: '',
  city: '',
  country: 'France',
  musician: false,
  musicInstruments: [],
  yearsPlaying: 0
}
export default {
  credentials,
  profile
}

错误

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

module.exports = {
  root: true,
  parserOptions: {
    parser: 'babel-eslint'
  },
  env: {
    browser: true,
  },
  extends: [
    // https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention
    // consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules.
    'plugin:vue/essential', 
    // https://github.com/standard/standard/blob/master/docs/RULES-en.md
    'standard'
  ],
  // required to lint *.vue files
  plugins: [
    'vue'
  ],
  // add your custom rules here
  rules: {
    // allow async-await
    'generator-star-spacing': 'off',
    // allow debugger during development
    'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
  }
}

1 个答案:

答案 0 :(得分:1)

开启ES6:

  parserOptions: {
    parser: 'babel-eslint'
  },

应该是:

  parserOptions: {
    parser: 'babel-eslint',
    "ecmaVersion": 6,
  },