javascript: Configuration for rule "no-else-return" is invalid

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

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 8
  • Comments: 16

Most upvoted comments

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>)

The option was added in eslint 4.9. Probably your atom-plugin uses an outdated version of eslint.

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.

I had just encountered the same issue. Solved it by upgrading the version of eslint to 4.9.0

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?

All editors, but Atom in particular, are very brittle, and need a restart whenever anything in node_modules changes.

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?