简体   繁体   English

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

[英]Vue.js eslint Parsing error .: unexpected token

I am getting this error on a state.js file ( at => in the const profile ) cannot understand why... thanks for feedback我在 state.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
}

standard eslint conf from vue-cli.来自 vue-cli 的标准 eslint conf。 webpack init网络包初始化

.eslintrc.js .eslintrc.js

// 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'
  }
}

the error错误

file: 'file:///Users/yves/Developments/WIP/FIREBASE/vue-firebase-tutorial-store-user/src/store/state.js'
severity: 'Error'
message: 'Parsing error: Unexpected token

[0m [90m 4 | [39m}[0m
[0m [90m 5 | [39m[36mconst[39m profil[0m
[0m[31m[1m>[22m[39m[90m 6 | [39m[36mexport[39m [36mdefault[39m {[0m
[0m [90m   | [39m[31m[1m^[22m[39m[0m
[0m [90m 7 | [39m  credentials[0m
[0m [90m 8 | [39m}[0m
[0m [90m 9 | [39m[0m'
at: '6,1'
source: 'eslint'
code: 'undefined'

Turn on ES6:开启 ES6:

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

should be:应该:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM