Javascript: Invalid config for react/jsx-uses-react?

Created on 12 Aug 2016  路  5Comments  路  Source: airbnb/javascript

I'm using atom, with the nuclide plugin and sometimes, the linter doesn't work.

Here's the error I see in the console:

/Users/tommy.leunen/.atom/packages/nuclide/pkg/nuclide-diagnostics-store/lib/LinterAdapter.js:20 Uncaught (in promise) Error: /Users/tommy.leunen/dev/project/node_modules/eslint-config-airbnb/rules/react.js:
    Configuration for rule "react/jsx-uses-react" is invalid:
    Value "[object Object]" has more items than allowed.

Referenced from: airbnb
Referenced from: /Users/tommy.leunen/dev/project/.eslintrc
    at validateRuleOptions (/Users/tommy.leunen/dev/project/node_modules/eslint/lib/config/config-validator.js:116:15)
    at /Users/tommy.leunen/dev/project/node_modules/eslint/lib/config/config-validator.js:163:13
    at Array.forEach (native)
    at Object.validate (/Users/tommy.leunen/dev/project/node_modules/eslint/lib/config/config-validator.js:162:35)
    at load (/Users/tommy.leunen/dev/project/node_modules/eslint/lib/config/config-file.js:523:19)
    at /Users/tommy.leunen/dev/project/node_modules/eslint/lib/config/config-file.js:392:36
    at Array.reduceRight (native)
    at applyExtends (/Users/tommy.leunen/dev/project/node_modules/eslint/lib/config/config-file.js:363:28)
    at load (/Users/tommy.leunen/dev/project/node_modules/eslint/lib/config/config-file.js:530:22)
    at /Users/tommy.leunen/dev/project/node_modules/eslint/lib/config/config-file.js:392:36
    at Array.reduceRight (native)
    at applyExtends (/Users/tommy.leunen/dev/project/node_modules/eslint/lib/config/config-file.js:363:28)
    at Object.load (/Users/tommy.leunen/dev/project/node_modules/eslint/lib/config/config-file.js:530:22)
    at loadConfig (/Users/tommy.leunen/dev/project/node_modules/eslint/lib/config.js:64:33)
    at new Config (/Users/tommy.leunen/dev/project/node_modules/eslint/lib/config.js:233:38)
    at CLIEngine.executeOnText (/Users/tommy.leunen/dev/project/node_modules/eslint/lib/cli-engine.js:748:28)

I don't override the jsx-uses-react rule.
[email protected]
[email protected]

It looks like this happen when linting a file that doesn't have any JSX.

Most helpful comment

The usual cause of this error is that your editor is using the global eslint instead of the local one - although the stack trace doesn't seem to indicate that.

You may want to update to the latest eslint, eslint-config-airbnb, and eslint-plugin-react, but I'm not sure why your error is happening.

All 5 comments

The usual cause of this error is that your editor is using the global eslint instead of the local one - although the stack trace doesn't seem to indicate that.

You may want to update to the latest eslint, eslint-config-airbnb, and eslint-plugin-react, but I'm not sure why your error is happening.

I don't have any global eslint :/

But I restarted atom and the issue is gone. I wonder if this happened because I opened the editor while on a branch with different version of eslint/airbnb config, clean my dependencies, reinstalled them, etc... Maybe atom/eslint was confused.

That's happened to me with sublime - I think editors need to be restarted when dep versions change :-)

@ljharb happened to me with atom

    "eslint": "^2.5.3",
    "eslint-config-airbnb": "^6.1.0",
    "eslint-plugin-import": "^2.0.1",
    "eslint-plugin-jsx-a11y": "^2.2.3",
    "eslint-plugin-react": "^4.2.3",

removing the "global eslint instead of the local one" solved this for me

npm info "eslint-config-airbnb-base@latest" peerDependencies
npm install -g install-peerdeps
install-peerdeps --dev eslint-config-airbnb-base

Add "extends": "airbnb-base" to .eslintrc file.
Finally, SUCCESS eslint-config-airbnb-base and its peerDeps were installed successfully.

Was this page helpful?
0 / 5 - 0 ratings