Vue.js eslint解析错误。:意外令牌 [英] Vue.js eslint Parsing error .: unexpected token

查看:413
本文介绍了Vue.js eslint解析错误。:意外令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am getting this error on a state.js file ( at => in the const profile ) cannot understand why ... thanks for feedback

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

来自vue-cli的标准eslint conf。 webpack init

standard eslint conf from vue-cli . webpack init

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

错误

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'


推荐答案

打开ES6:

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

应该是:

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

这篇关于Vue.js eslint解析错误。:意外令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆