Eslint-plugin-vue: Unexpected token after `async`

Created on 11 Aug 2017  Â·  8Comments  Â·  Source: vuejs/eslint-plugin-vue

Tell us about your environment

  • ESLint Version: 4.3
  • eslint-plugin-vue Version: 3.11.0
  • Node Version: 8.1.4

Please show your full configuration:

module.exports = {
  root: true,
  extends: [
    'dwing',
    'plugin:vue/recommended'
  ],
  rules: {
    'global-require': 0,
    'import/extensions': [2, 'always', { js: 'never', vue: 'never' }]
  },
  settings: {
    'import/resolver': {
      webpack: {
        config: 'build/webpack.config.js'
      }
    }
  }
};

What did you do? Please include the actual source code causing the issue.

const actions = {
  async getAllData({ commit }) {
    await this.getAllData();
  }
};

export default actions;
// or this 
export const getAllData = async ({ commit }) => {
   await this.getAllData();
}

What did you expect to happen?

What actually happened? Please include the actual, raw output from ESLint.

file: 'file:///Users/willin/Desktop/vuetify-demo/src/store/actions.js' severity: '错误' message: 'Parsing error: Unexpected token getAllData' at: '2,9' source: 'eslint'

Most helpful comment

Async functions have been added in ECMAScript 2017. You have to have ecmaVersion: 2017 or ecmaVersion: 8.

All 8 comments

@willin you have to add to parserOptions: ecmaVersion: 7

ofcourse. in dwing

Async functions have been added in ECMAScript 2017. You have to have ecmaVersion: 2017 or ecmaVersion: 8.

@armano2 @mysticatea @michalsnik Are you sure? I'm always using ecmaVersion: 2017, but this error still occurs.

@JounQin I'm sure because I implemented it.

@mysticatea Please check https://github.com/JounQin/eslint-plugin-vue/tree/async_issue , just run npn run test

/local/GitHub/eslint-plugin-vue/tests/integrations/eslint-plugin-import/a.vue
  6:15  warning  Parse errors in imported module './b.vue': Unexpected token test (8:10)  import/namespace
  6:15  warning  Parse errors in imported module './b.vue': Unexpected token test (8:10)  import/default

✖ 2 problems (0 errors, 2 warnings)

@JounQin ES2015 does not support async functions.

Emm... OK, I found out maybe there is something error in my eslint configuration. thx any way

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sqal picture sqal  Â·  3Comments

armano2 picture armano2  Â·  4Comments

Mouvedia picture Mouvedia  Â·  3Comments

chrisvfritz picture chrisvfritz  Â·  3Comments

casprwang picture casprwang  Â·  4Comments