'Parsing error: Unexpected token function' using async/await + ecmaVersion 2017
See original GitHub issueTell us about your environment
- ESLint Version: 3.18.0
- Node Version: 7.7.3
- npm Version: 4.1.2
What parser (default, Babel-ESLint, etc.) are you using? default
Please show your full configuration:
root: true,
parserOptions: {
ecmaVersion: 2017,
sourceType: 'module'
},
extends: ['eslint:recommended', 'airbnb-base'],
env: {
'node': true
},
rules: {
'import/no-unresolved': 'off',
'import/no-extraneous-dependencies': 'off',
'func-names': 'off',
'no-multi-spaces': 'off',
'spaced-comment': ["error", "always", { "markers": ["/"] }],
'comma-dangle': ['error', 'always-multiline'],
'padded-blocks': 'off',
'linebreak-style': 'off',
'class-methods-use-this': 'off',
'indent': ['error', 2],
'max-len': ['error', 120, 2, { ignoreComments: true }],
'no-unused-vars': ['error', { vars: 'local', args: 'after-used' }],
'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 1 }],
'no-nested-ternary': 'off',
'no-underscore-dangle': ['error', {'allow': ['_super', '_lookupFactory']}],
'object-shorthand': ['error', 'methods'],
}
What did you do? Please include the actual source code causing the issue.
describe('Some Mocha Test', () => {
let target, context, exampleGame;
...
const checkAttributes = function (callback) {
return async function () { // Error here
return callback(await target.getAttributesAsync(exampleGame, context));
};
};
}
What did you expect to happen? eslint passes
What actually happened? Please include the actual, raw output from ESLint. eslint fails with
error Parsing error: Unexpected token function
A similar issue happens with =>
, as noted here
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
eslint Parsing error: Unexpected token function with async
Just in case this is happening to people using async/await for the first time. This error also appears if you use await inside...
Read more >eslint/eslint - Gitter
Has anyone reported an issue with .eslintrc.js globals not working in a subdirectory? ... .com/questions/36001552/eslint-parsing-error-unexpected-token.
Read more >Js - Parsing Error For Async Function
Mar 30 2017 'Parsing error: Unexpected token function' using async/await #9761 ... This is the example code from my video about using async/await...
Read more >Unexpected token error after adding await keyword to ...
Dylan Sather (Pipedream) : Hi , getting used to async / await and asynchronous programming in JS can take a long time even...
Read more >How To Fix - "Parsing error: Unexpected Token" in React.js ...
This could be due to a typo mistake, missing something in the code etc. Also could be dev environment and ESLint parsing styles...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
To enable parsing for async functions, you should include this in your config:
Many Many Many Thanks 👍 👍 👍 👍