Babel-eslint: Error when linting valid async function with generator-star-spacing rule enabled

Created on 29 May 2016  路  6Comments  路  Source: babel/babel-eslint

Getting TypeError: Cannot read property 'value' of undefined error when linting valid _async function_ with generator-star-spacing rule enabled.
See minimum reproduce repository example:
https://github.com/doronpr/min-reproduce-eslint-generator-star-spacing

The problem is that babel-eslint creates AST with node.generator == true for async functions.

I believe that should be changed to false but I'm not sure what other implications it can have.

Note that this actually broke in eslint 2.11.0 in this commit (works in 2.10.*)

The following internal error is thrown:

TypeError: Cannot read property 'value' of undefined
    at getStarToken (~/src/min/node_modules/eslint/lib/rules/generator-star-spacing.js:69:25)
    at EventEmitter.checkFunction (~/src/min/node_modules/eslint/lib/rules/generator-star-spacing.js:124:29)

Most helpful comment

This workaround works for me:

parser: babel-eslint
extends: airbnb-base
rules:
  generator-star-spacing: 0

All 6 comments

@doronpr Are you using the patched version of generator-star-spacing from https://github.com/babel/eslint-plugin-babel? Babel-eslint's parser produces a different AST than ESLint's default parser and so these patched rules are needed to work correctly.

This workaround works for me:

parser: babel-eslint
extends: airbnb-base
rules:
  generator-star-spacing: 0

Just FYI this is because there is a conflict between 2 of the eslint rules such that one of them will alwys be wrong. This will eventually be fixed with https://github.com/babel/babel-eslint/issues/350 when ESLint supports async/await in the default parser and the rule is fixed.

eslint 3.6.0 supports es2017 now

The logic was added to support async/await for different rules with eslint before it was supported - https://github.com/babel/babel-eslint/issues/361

Was this page helpful?
0 / 5 - 0 ratings