Async Arrow Function "Unexpected token ="
See original GitHub issueTell us about your environment
- ESLint Version: 4.18.1
- Node Version: 8.9.1
- npm Version: 5.5.1
What parser (default, Babel-ESLint, etc.) are you using? Babel-ESlint
Please show your full configuration:
Configuration
{
"extends": "airbnb",
"parserOptions": {
"ecmaVersion": 8
},
"env": {
"jest": true,
"browser": true
},
"rules": {
"semi": [
2,
"never"
],
"no-unexpected-multiline": 2,
"import/no-named-as-default": 0,
"import/no-named-as-default-member": 0,
"react/prop-types": 0,
"react/jsx-filename-extension": [
1,
{
"extensions": [
".js",
".jsx"
]
}
],
"jsx-a11y/anchor-is-valid": [
"error",
{
"components": [
"Link"
],
"specialLink": [
"to"
]
}
],
"no-unused-expressions": [
"error",
{
"allowTernary": true
}
]
}
}
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
callApi = async (url) => {
const response = await fetch(url)
const body = await response.json()
if (response.status !== 200) {
throw Error(body.message)
}
return body
}
eslint src
What did you expect to happen? ESLint done.
What actually happened? Please include the actual, raw output from ESLint. " error Parsing error: Unexpected token = " [ callApi = async (url) … is the problem ]
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:16 (7 by maintainers)
Top Results From Across the Web
ESLint parsing error when using arrow syntax with async
async / await is an ECMAScript 2017 feature, so if you change ecmaVersion: 8 instead of 6, this should work!
Read more >Arrow function expressions - JavaScript - MDN Web Docs
Arrow functions can be async by prefixing the expression with the ... const func = (a, b, c) => 1; // SyntaxError: Unexpected...
Read more >[Solved]-Syntax error on async arrow function-node.js
[Solved]-Syntax error on async arrow function-node.js ... The function syntax seems correct. ... How to fix 'Unexpected Token' error with async function ...
Read more >async arrow function expected a return value - You.com
Async arrow function expected no return value ... token') // <-- unexpected we should throw } const session = await Iron.unseal(token, TOKEN_SECRET, ...
Read more >Arrow Functions in JavaScript: Fat & Concise Syntax - SitePoint
Learn how to use JavaScript arrow functions, understand fat and concise ... Uncaught SyntaxError: unexpected token: ':' const seriesList ...
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
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
@codeblooded I think your error is unrelated. In the
parserOptions
section, you have:This should just be:
ecmaVersion
generally isn’t supposed to go in theecmaFeatures
object.@platinumazure.
specifying the node version in the engines field of my package.json fixed the problem. Thanks!