Javascript Vue.js eslint分析错误:意外标记
我在state.js文件(const配置文件中的at=>中)中遇到此错误 我不明白为什么。。。谢谢你的反馈Javascript Vue.js eslint分析错误:意外标记,javascript,vue.js,eslint,Javascript,Vue.js,Eslint,我在state.js文件(const配置文件中的at=>中)中遇到此错误 我不明白为什么。。。谢谢你的反馈 const credentials = { email: '', password: '' } const profile = { => userId: '', gender: '', firstName: '', lastName: '', address: '', zipCode: '', city: '', country: 'Fran
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配置。网页包初始化
.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
},
谢谢。。。关于single state.js文件的帮助,使用模块时没有错误这对我不起作用。我尝试将
ecmaVersion
设置为6
和2017
。为了防止有人犯了与我相同的错误,我在尝试运行warn install
时,在位置处得到了一个JSON中的意外标记,该错误可以通过删除“ecmaVersion”:6