2021 Update: Be sure you're using @babel/eslint-parser
and not the deprecated babel-eslint
- Remove the old package if necessary:
yarn remove babel-eslint
or npm uninstall babel-eslint
yarn add --dev @babel/eslint-parser
or npm install --save-dev @babel/eslint-parser
- In
.eslintrc
add "parser": "@babel/eslint-parser"
Optionally, this answer suggests including "requireConfigFile": false
in .eslintrc
to prevent eslint from searching for unnecessary config files:
{
...
"parserOptions": {
...
"requireConfigFile": false,
}
}
If this still doesn't work, try checking whether your system is using a globally installed eslint (and removing it).
My other problem was eslint was using a globally installed version instead of my local version, and the global eslint can't access my locally installed babel-eslint parser. Further, since my globally installed eslint was installed on a different version of node, removing it was non-trivial.
Checking if your system is using global versus local eslint.
- Install
babel-eslint
following @spencer.sm's answer for your local eslint.
- From the terminal, check if you get different output from running
eslint .
and npx eslint .
. If you get different output it's likely that it's your global eslint running that can't access babel-eslint.
Uninstalling the global eslint
For most people, the following commands should uninstall eslint with npm (uninstall global package with npm) and yarn (uninstall global package with yarn):
# npm
npm uninstall -g eslint
npm uninstall eslint
# yarn
yarn global remove eslint
Next, run npx eslint .
to see if things work. If it doesn't, which it didn't for me, you need to take an extra step to remove the globally installed eslint.
From this answer, I learned that I had installed eslint on a system version of Node instead of my current version of Node (I use nvm). Follow these simple steps to remove the global eslint and you should be good to go!
arrowFunctions
you already include should cover it. This may be an unsupported case, a bug or against the convention stylebabel-eslint
as my linter. It's a drop in replacement for eslint with a babel parser stuck on the end. Thanks to all of you who chimed in.