Hi,
I've been trying to install version 15.0.1, but I'm encountering the following error:
ESLint configuration is invalid:
- Unexpected top-level property "ecmaFeatures".
Referenced from: airbnb
Referenced from: /app/.eslintrc Error: /app/node_modules/eslint-config-airbnb/rules/react-a11y.js:
ESLint configuration is invalid:
- Unexpected top-level property "ecmaFeatures".
I saw that arount one month ago a fix was released in the master channel, but no new version has been made available on npm/yarn.
Is there a way to pull the git repo directly? I don't know how to specify the subdirectory of the javascript project.
Thanks
We are not yet compatible with eslint v4; please use the install command in the package readme to ensure you have the proper peer deps. Also, npm ls will report errors for you - it has to exit zero before anything else will work properly.
See also, #1447.
Hi @ljharb thanks for the reply. I've manually run the info command and installed the correct eslint version, suggested by the deps (3.19.0). I'm using Atom with the eslint plugin, and I'm pretty sure it's using the local eslint, as I've not installed it gloablly (for double check, I've completely removed eslint and installed it again).
This is my package.json:
{
"name": "app",
"version": "0.1.0",
"private": true,
"dependencies": {
"babel-preset-stage-3": "^6.24.1",
"material-ui": "^0.18.3",
"react": "^15.6.0",
"react-dom": "^15.6.0",
"react-router": "^4.1.1",
"react-router-dom": "^4.1.1",
"react-tap-event-plugin": "^2.0.1"
},
"devDependencies": {
"eslint": "^3.19.0",
"eslint-config-airbnb": "git+ssh://[email protected]:airbnb/javascript.git",
"eslint-config-airbnb-base": "^11.2.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^5.0.1",
"eslint-plugin-react": "^7.0.1",
"react-scripts": "1.0.7"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
P.S.
Note that I'm pulling the repo now, using the following eslintrc file:
{
"extends": "airbnb/packages/eslint-config-airbnb"
}
(and including that change, it works)
I'm confused because eslint 3 doesn't validate configs; only eslint 4 does. So it shouldn't be possible to get that error unless you're on v4.
Are you sure react-scripts isn't bringing in eslint 4? What does npm ls say?
Hi @ljharb,
I'm confused, too. Here is the yarn list|grep eslint output:
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
β ββ eslint-import-resolver-node@^0.2.0
β ββ eslint-module-utils@^2.0.0
ββ [email protected]
ββ [email protected]
ββ [email protected]
β ββ [email protected]
β ββ eslint-config-react-app@^1.0.4
β ββ [email protected]
β ββ [email protected]
β ββ [email protected]
β ββ [email protected]
β ββ [email protected]
β ββ [email protected]
yarn.lock:
[email protected], eslint@^3.19.0:
version "3.19.0"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-3.19.0.tgz#c8fc6201c7f40dd08941b87c085767386a679acc"
dependencies:
babel-code-frame "^6.16.0"
chalk "^1.1.3"
concat-stream "^1.5.2"
debug "^2.1.1"
doctrine "^2.0.0"
escope "^3.6.0"
espree "^3.4.0"
esquery "^1.0.0"
estraverse "^4.2.0"
esutils "^2.0.2"
file-entry-cache "^2.0.0"
glob "^7.0.3"
globals "^9.14.0"
ignore "^3.2.0"
imurmurhash "^0.1.4"
inquirer "^0.12.0"
is-my-json-valid "^2.10.0"
is-resolvable "^1.0.0"
js-yaml "^3.5.1"
json-stable-stringify "^1.0.0"
levn "^0.3.0"
lodash "^4.0.0"
mkdirp "^0.5.0"
natural-compare "^1.4.0"
optionator "^0.8.2"
path-is-inside "^1.0.1"
pluralize "^1.2.1"
progress "^1.1.8"
require-uncached "^1.0.2"
shelljs "^0.7.5"
strip-bom "^3.0.0"
strip-json-comments "~2.0.1"
table "^3.7.8"
text-table "~0.2.0"
user-home "^2.0.0"
And the eslint's node_modules package.json shows "version": "3.19.0"
+1 with this problem. Hope eslint-config-airbnb will upgrade to compatible with eslint v4 soon π
@paranoidjk see #1447. There's nothing wrong with sticking with v3 in the meantime.
@ljharb it seems that the Atom's linter-eslint wasn't finding the eslint installation under node_modules, fallbacking to the eslint version shipped with the plugin. Today I've reconfigured the project and the editor and seems to work fine now :)
Thanks for the support :+1:
I have same issue with such config:
"babel-eslint": "^7.2.3",
"eslint": "^4.0.0",
"eslint-config-airbnb": "^15.0.1",
"eslint-plugin-import": "^2.3.0",
"eslint-plugin-jsx-a11y": "^5.0.3",
"eslint-plugin-react": "^7.1.0"
./node_modules/.bin/eslint . throws same error
ESLint configuration is invalid:
- Unexpected top-level property "ecmaFeatures".
It works fine with eslint v3 so i assume i should wait till config will be available for v4? Any help needed?
@artyomtrityak yes, npm ls will show an error because eslint v4 is not yet compatible with eslint-config-airbnb.
I could get rid of the errors by editing two files:
eslint-config-airbnb/rules/react eslint-config-airbnb/rules/react-a11yBe sure to not use ecmaFeatures as a top level configuration item:
module.exports = {
// ecmaFeatures: {
// jsx: true,
// },
// other config items
}
Instead, nest it into parserOptions:
module.exports = {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
// other config items
}
No idea, if that's the correct fix though, i just does not throw any errors anymore.
@alp82 yes, that's invalid in eslint 4 but is ignored in eslint 3. It's already removed in master; we just haven't released a version compatible with eslint 4 - which is why anybody running into this is using invalid dependencies.
Thanks for the response. Any ETA on when you plan to release the eslint 4 compatible version?
@alp82 follow #1447 for that - it's blocked by some peer deps, so it always takes a couple weeks. Luckily, there's no hurry, since eslint v3 continues to work fine.
I am having the same problem even after downgrading to [email protected] with Visual Studio Code (and the eslint plugin) and after wasting half a day trying to fix this without success I think I might just need to wait for v4 update before using airbnb.
@MFry are you sure VSC isn't using a global eslint v4? if so, you can surely configure it to use a locally installed eslint.
@ljharb I uninstalled every global except create-react-app.
I double checked yarn global ls and it confirmed it. I also tried the SO fix and it didn't work for either v3 or V4.
Presumably you've also restarted VSC after uninstalling those things⦠I'm not really sure :-/
It seems apparent that you have a copy of v4 somewhere and that's what VSC is running - you can certainly wait until #1447 is resolved, but then it'll just pop up again when v5, v6, etc comes out - so you may want to spend the time finding a proper fix now :-/
I was able to resolve this issue on my end by making a local .eslintrc.json file. I used the command in VS Code once provided by the ESLint extension, but here's the text of the file if anyone needs it:
{
"env": {
"browser": true,
"commonjs": true,
"es6": true,
"node": true
},
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"sourceType": "module"
},
"rules": {
"no-const-assign": "warn",
"no-this-before-super": "warn",
"no-undef": "warn",
"no-unreachable": "warn",
"no-unused-vars": "warn",
"constructor-super": "warn",
"valid-typeof": "warn"
}
}
@ScottRFrost you always need to have a local eslintrc file. in this case you're not extending the airbnb config tho?
Just mentioning that I had the same error and what I did to fix it in case others encountered the same. Nothing about the error would lead you to believe it's related to a missing config file. I'm not extending.
@ScottRFrost right, what i'm saying is that if you're not extending airbnb or airbnb-base, then this repo is irrelevant to your issue.
v16 is now released.
Most helpful comment
+1 with this problem. Hope eslint-config-airbnb will upgrade to compatible with eslint v4 soon π