I get this error on save with atom. I've tried to fiddle around with versions and re-install everything. Looks like there is a bad config option in the eslint-config-airbnb-base.
node_modules/eslint-config-airbnb-base/rules/best-practices.js: Configuration for rule "no-else-return" is invalid: Value "[object Object]" should NOT have more than 0 items.
The rule in best-practices.js looks like this:
// disallow else after a return in an if
// https://eslint.org/docs/rules/no-else-return
// TODO: semver-major, set allowElseIf to false
'no-else-return': ['error', { allowElseIf: true }],
My dependencies:
"devDependencies": {
"babel-eslint": "^8.0.1",
"eslint": "^4.9.0",
"eslint-config-airbnb": "^16.1.0",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-meteor": "^4.1.4",
"eslint-plugin-react": "^7.4.0"
},
The option was added in eslint 4.9. Probably your atom-plugin uses an outdated version of eslint.
I had the same problem with VSCode (which takes the eslint version it finds in the project). The issue seemed to be this one Linting doesn't update after ESLint package upgrade.
So I restarted VSCode and it worked again. Maybe it solves the problem for atom as well?
All editors, but Atom in particular, are very brittle, and need a restart whenever anything in node_modules changes.
Have the same issue when running eslint from command line. So it's not related with IDE.
Looks like it's [email protected] issue.
Created issue in eslint project https://github.com/eslint/eslint/issues/9486
@zahar-g what's your .eslintrc look like?
@ljharb
{
"extends": [
"airbnb"
],
"globals": {
"fetch": false
},
"rules": {
"indent": ["error", 4, {"SwitchCase": 1}],
"react/jsx-indent": ["error", 4],
"quote-props": "off",
"react/sort-comp": 1,
"func-names": 1,
"object-shorthand": [2, "properties"],
"object-curly-newline": 1,
"arrow-parens": [2, "always"],
"default-case": 0,
"prefer-const": 1,
"space-before-function-paren": 1,
"max-len": ["warn", 100],
"prefer-template": 1,
"consistent-return": 1,
"global-require": 1,
"vars-on-top": 1,
"function-paren-newline": 1,
"prefer-arrow-callback": 1,
"spaced-comment": 1,
"prefer-destructuring": 1,
"prefer-promise-reject-errors": 1,
"prefer-spread": 1,
"radix": 1,
"dot-notation": 1,
"one-var": 1,
"one-var-declaration-per-line": 1,
"operator-assignment": 1,
"array-callback-return": 1,
"wrap-iife": 1,
"guard-for-in": 1,
"strict": 1,
"lines-around-directive": 1,
"no-prototype-builtins": 1,
"no-useless-concat": 1,
"no-restricted-syntax": 1,
"no-restricted-globals": 1,
"no-multi-assign": 1,
"no-confusing-arrow": ["warn", {"allowParens": true}],
"no-use-before-define": 1,
"no-empty": 1,
"no-mixed-operators": 1,
"no-var": 1,
"no-unused-vars": 1,
"no-unused-expressions": 1,
"no-param-reassign": 1,
"no-useless-return": 1,
"no-nested-ternary": 1,
"no-shadow": 1,
"no-lonely-if": 1,
"no-undef": 1,
"no-case-declarations": 1,
"no-underscore-dangle": 1,
"no-plusplus": 1,
"no-else-return": 1,
"no-bitwise": 1,
"class-methods-use-this": ["warn", {"exceptMethods": []}],
"array-bracket-spacing": ["warn", "never"],
"arrow-body-style": ["warn", "as-needed"],
"linebreak-style": ["warn", "unix"],
"import/extensions": [1, "never", {"js": "never", "jsx": "never"}],
"import/no-extraneous-dependencies": 1,
"import/no-unresolved": 1,
"import/no-mutable-exports": 1,
"import/first": 1,
"import/newline-after-import": 1,
"import/prefer-default-export": 1,
"jsx-quotes": ["warn", "prefer-single"],
"react/react-in-jsx-scope": 1,
"react/jsx-indent-props": ["error", 4],
"react/jsx-first-prop-new-line": ["warn", "multiline-multidrop"],
"react/jsx-closing-bracket-location": ["warn", "line-aligned"],
"react/jsx-closing-tag-location": 1,
"react/no-string-refs": 1,
"react/no-unused-prop-types": 1,
"react/no-children-prop": 1,
"react/no-find-dom-node": 1,
"react/no-array-index": 1,
"react/require-default-props": 1,
"react/jsx-no-bind": 1,
"react/jsx-curly-brace-presence": ["warn", {"props": "never", "children": "never"}],
"react/forbid-prop-types": ["warn", {"forbid": ["any", "array", "object"]}],
"react/no-unescaped-entities": 1,
"react/no-unused-state": 1,
"react/no-array-index-key": 1,
"react/no-did-mount-set-state": 1,
"react/no-did-update-set-state": 1,
"react/jsx-no-target-blank": 1,
"react/jsx-wrap-multilines": 1,
"react/sort-prop-types": [1, { "ignoreCase": true }],
"jsx-a11y/no-noninteractive-element-interactions": 1,
"jsx-a11y/click-events-have-key-events": 1,
"jsx-a11y/label-has-for": 1,
"jsx-a11y/alt-text": 1,
"jsx-a11y/no-static-element-interactions": 1,
"jsx-a11y/anchor-is-valid": 1,
"jsx-a11y/no-redundant-roles": 1,
"jsx-a11y/scope": 1,
"jsx-a11y/interactive-supports-focus": 1,
"comma-dangle": [2, "always-multiline"]
}
}
While that’s a lot of warnings that should be errors, it seems like the issue is that you’re somehow not using eslint 4.9+. Are you sure you have 4.9 installed locally, and that vscode is using the local one? Can you npm uninstall -g eslint just in case?
@ljharb Very close. But gulp task return the same error, when next command not.
./node_modules/.bin/eslint --debug './src/scripts/**/*.js'
think it doesn't related with airbnb-config, but with gulp-eslint maybe.
Ah, yes it's almost always a problem with gulp-eslint not updating fast enough :-) I'm quite sure if you check npm ls you'll see gulp-eslint brings in an outdated eslint.
@ljharb true!
├─┬ [email protected]
│ ├── [email protected]
@krazyjakee happy to reopen this if restarting atom didn't fix it, and it's not because of gulp-eslint
I got this exact error today, this should be reopen, here is my eslint config:
{
"parser": "babel-eslint",
"env": {
"browser": true,
"jest": true,
"node": true
},
"extends": ["airbnb", "prettier"],
"plugins": ["prettier"],
"rules": {
"prettier/prettier": "error",
"react/jsx-indent": 0,
"no-else-return": 0
}
}
And I get the error while building the project:
Module build failed: Error: C:\Users\klnhat\code\my-book-list\client-my-book-list\node_modules\eslint-config-airbnb-base\rules\best-practices.js:
Configuration for rule "no-else-return" is invalid:
Value "[object Object]" should NOT have more than 0 items.
Referenced from: C:\Users\klnhat\code\my-book-list\client-my-book-list\node_modules\eslint-config-airbnb-base\index.js
Referenced from: C:\Users\klnhat\code\my-book-list\client-my-book-list\node_modules\eslint-config-airbnb\index.js
Referenced from: C:\Users\klnhat\code\my-book-list\client-my-book-list\.eslintrc
at Array.forEach (<anonymous>)
at Array.reduceRight (<anonymous>)
at Array.reduceRight (<anonymous>)
@lednhatkhanh what does npm ls say?
I had just encountered the same issue.
Solved it by upgrading the version of eslint to 4.9.0
@lednhatkhanh hey! have u solved that issue? because i'm having the exact problem :face_with_thermometer:
@jeromelachaud it works
Most helpful comment
I got this exact error today, this should be reopen, here is my eslint config:
And I get the error while building the project: