Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[eslint-config-airbnb] Unexpected top-level property "ecmaFeatures". #1454

Closed
elegos opened this issue Jun 14, 2017 · 23 comments
Closed

[eslint-config-airbnb] Unexpected top-level property "ecmaFeatures". #1454

elegos opened this issue Jun 14, 2017 · 23 comments
Labels

Comments

@elegos
Copy link

elegos commented Jun 14, 2017

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

@ljharb
Copy link
Collaborator

ljharb commented Jun 14, 2017

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.

@elegos
Copy link
Author

elegos commented Jun 14, 2017

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://git@github.com: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)

@ljharb
Copy link
Collaborator

ljharb commented Jun 14, 2017

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.

@ljharb
Copy link
Collaborator

ljharb commented Jun 14, 2017

Are you sure react-scripts isn't bringing in eslint 4? What does npm ls say?

@elegos
Copy link
Author

elegos commented Jun 15, 2017

Hi @ljharb,

I'm confused, too. Here is the yarn list|grep eslint output:

├─ babel-eslint@7.2.3
├─ eslint-config-airbnb-base@11.2.0
├─ eslint-config-airbnb@2.0.0
├─ eslint-config-react-app@1.0.4
├─ eslint-import-resolver-node@0.2.3
├─ eslint-loader@1.7.1
├─ eslint-module-utils@2.0.0
├─ eslint-plugin-flowtype@2.33.0
├─ eslint-plugin-import@2.2.0
│  ├─ eslint-import-resolver-node@^0.2.0
│  ├─ eslint-module-utils@^2.0.0
├─ eslint-plugin-jsx-a11y@5.0.3
├─ eslint-plugin-react@7.0.1
├─ eslint@3.19.0
│  ├─ babel-eslint@7.2.3
│  ├─ eslint-config-react-app@^1.0.4
│  ├─ eslint-loader@1.7.1
│  ├─ eslint-plugin-flowtype@2.33.0
│  ├─ eslint-plugin-import@2.2.0
│  ├─ eslint-plugin-jsx-a11y@5.0.3
│  ├─ eslint-plugin-react@7.0.1
│  ├─ eslint@3.19.0

yarn.lock:

eslint@3.19.0, 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"

@paranoidjk
Copy link

+1 with this problem. Hope eslint-config-airbnb will upgrade to compatible with eslint v4 soon 😄

paranoidjk added a commit to ant-design/ant-design-mobile that referenced this issue Jun 15, 2017
@ljharb
Copy link
Collaborator

ljharb commented Jun 15, 2017

@paranoidjk see #1447. There's nothing wrong with sticking with v3 in the meantime.

@elegos
Copy link
Author

elegos commented Jun 16, 2017

@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 👍

@elegos elegos closed this as completed Jun 16, 2017
@ljharb ljharb added the invalid label Jun 16, 2017
@artyomtrityak
Copy link

artyomtrityak commented Jun 22, 2017

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?

@ljharb
Copy link
Collaborator

ljharb commented Jun 22, 2017

@artyomtrityak yes, npm ls will show an error because eslint v4 is not yet compatible with eslint-config-airbnb.

@alp82
Copy link

alp82 commented Jun 23, 2017

I could get rid of the errors by editing two files:

  1. eslint-config-airbnb/rules/react
  2. eslint-config-airbnb/rules/react-a11y

Be 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.

@ljharb
Copy link
Collaborator

ljharb commented Jun 23, 2017

@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.

@alp82
Copy link

alp82 commented Jun 23, 2017

Thanks for the response. Any ETA on when you plan to release the eslint 4 compatible version?

@ljharb
Copy link
Collaborator

ljharb commented Jun 23, 2017

@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.

@MFry
Copy link

MFry commented Jul 4, 2017

I am having the same problem even after downgrading to eslint@3.19.0 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.

@ljharb
Copy link
Collaborator

ljharb commented Jul 4, 2017

@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.

@MFry
Copy link

MFry commented Jul 4, 2017

@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.

@ljharb
Copy link
Collaborator

ljharb commented Jul 4, 2017

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 :-/

@ScottRFrost
Copy link

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"
    }
}

@ljharb
Copy link
Collaborator

ljharb commented Jul 7, 2017

@ScottRFrost you always need to have a local eslintrc file. in this case you're not extending the airbnb config tho?

@ScottRFrost
Copy link

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.

@ljharb
Copy link
Collaborator

ljharb commented Jul 7, 2017

@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.

@ljharb
Copy link
Collaborator

ljharb commented Oct 6, 2017

v16 is now released.

lixiaoyang1992 pushed a commit to lixiaoyang1992/ant-design-mobile that referenced this issue Apr 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants