-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
no-else-return rule issue #9486
Comments
Hi @zahar-g, thanks for the issue. It looks like there's not enough information for us to know how to help you. If you're reporting a bug, please be sure to include:
(edited by @platinumazure) |
"scripts": {
...
"lint": "gulp lint",
...
},
...
"eslint": "^4.9.0",
"eslint-config-airbnb": "^16.1.0",
"eslint-formatter-pretty": "^1.1.0",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-react": "^7.4.0",
"eslint-plugin-jsx-a11y": "^6.0.2",
... .eslintrc {
"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"]
}
} gulp lint task gulp.task('lint', () => {
execSync('mkdir -p reports');
return gulp.src([
`${dirs.source}/scripts/**/*.js`,
`${dirs.source}/scripts/**/*.jsx`,
'gulpfile.js',
'!node_modules/**',
])
.pipe(eslint())
.pipe(eslint.format('node_modules/eslint-formatter-pretty'))
.pipe(eslint.format('checkstyle', fs.createWriteStream(`${dirs.reports}/eslint.xml`)))
.pipe(eslint.failAfterError());
}); I'm running npm run lint |
Never mind, I see now that this is a schema issue. Sorry about this. I'll analyze that shortly... |
@zahar-g Your schema looks valid according to the rule docs. Can you try running ESLint with the |
@platinumazure events.js:182
throw er; // Unhandled 'error' event
^
Error: /home/zakhargulchak/WebstormProjects/application-ngo2/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. |
With previous version of airbnb config I haven't such error. |
Downgraded airbnb plugin to stable one. And updated my own .eslintrc to: (changed {
"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": ["error", { "allowElseIf": true }],
"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"]
}
} and got error Error: /home/zakhargulchak/WebstormProjects/application-ngo2/.eslintrc:
Configuration for rule "no-else-return" is invalid:
Value "[object Object]" should NOT have more than 0 items. |
@platinumazure eslint --debug './src/scripts/**/*.js' Here is full output with debug eslint:cli Running on files +0ms
eslint:glob-util Creating list of files to process. +0ms
eslint:ignored-paths Looking for ignore file in /home/zakhargulchak/WebstormProjects/application-ngo2 +0ms
eslint:ignored-paths Loaded ignore file /home/zakhargulchak/WebstormProjects/application-ngo2/.eslintignore +0ms
eslint:ignored-paths Adding /home/zakhargulchak/WebstormProjects/application-ngo2/.eslintignore +0ms
eslint:cli-engine Processing /home/zakhargulchak/WebstormProjects/application-ngo2/src/scripts/__mocks__/audience-data.js +0ms
eslint:cli-engine Linting /home/zakhargulchak/WebstormProjects/application-ngo2/src/scripts/__mocks__/audience-data.js +0ms
eslint:config Constructing config file hierarchy for /home/zakhargulchak/WebstormProjects/application-ngo2/src/scripts/__mocks__ +0ms
eslint:config Using .eslintrc and package.json files +0ms
eslint:config Loading /home/zakhargulchak/WebstormProjects/application-ngo2/.eslintrc +1ms
eslint:config-file Loading config file: /home/zakhargulchak/WebstormProjects/application-ngo2/.eslintrc +0ms
/home/zakhargulchak/WebstormProjects/application-ngo2/.eslintrc:
Configuration for rule "no-else-return" is invalid:
Value "[object Object]" should NOT have more than 0 items.
Error: /home/zakhargulchak/WebstormProjects/application-ngo2/.eslintrc:
Configuration for rule "no-else-return" is invalid:
Value "[object Object]" should NOT have more than 0 items.
at validateRuleOptions (/home/zakhargulchak/.nvm/versions/node/v8.6.0/lib/node_modules/eslint/lib/config/config-validator.js:113:15)
at Object.keys.forEach.id (/home/zakhargulchak/.nvm/versions/node/v8.6.0/lib/node_modules/eslint/lib/config/config-validator.js:153:9)
at Array.forEach (<anonymous>)
at validateRules (/home/zakhargulchak/.nvm/versions/node/v8.6.0/lib/node_modules/eslint/lib/config/config-validator.js:152:30)
at Object.validate (/home/zakhargulchak/.nvm/versions/node/v8.6.0/lib/node_modules/eslint/lib/config/config-validator.js:230:5)
at loadFromDisk (/home/zakhargulchak/.nvm/versions/node/v8.6.0/lib/node_modules/eslint/lib/config/config-file.js:549:19)
at Object.load (/home/zakhargulchak/.nvm/versions/node/v8.6.0/lib/node_modules/eslint/lib/config/config-file.js:592:20)
at Config.getLocalConfigHierarchy (/home/zakhargulchak/.nvm/versions/node/v8.6.0/lib/node_modules/eslint/lib/config.js:226:44)
at Config.getConfigHierarchy (/home/zakhargulchak/.nvm/versions/node/v8.6.0/lib/node_modules/eslint/lib/config.js:180:43)
at Config.getConfigVector (/home/zakhargulchak/.nvm/versions/node/v8.6.0/lib/node_modules/eslint/lib/config.js:285:21)
|
I guess the rule |
@aladdin-add |
I see. |
@aladdin-add ./node_modules/.bin/eslint --debug './src/scripts/**/*.js' it's reading rules ok. |
Found problem. ├─┬ gulp-eslint@4.0.0
│ ├── eslint@4.8.0 Gulp-eslint is using own dependency. And not the latest version. |
we have added eslint version to error output (#9071), but seems not ideal. I was wondering adding version before every eslint running. thanks for the reporting! |
What did you do @zahar-g to resolve the issue? Currently gulp-eslint has a dependency to eslint@^4.0.0:
|
Tell us about your environment
What parser (default, Babel-ESLint, etc.) are you using?
Default
Please show your full configuration:
Configuration
What did you do? Please include the actual source code causing the issue.
Issue caused by eslint-config-airbnb-base@12.1.0
node_modules/eslint-config-airbnb-base/rules/best-practices.js:62
What did you expect to happen?
Run without error
What actually happened? Please include the actual, raw output from ESLint.
events.js:182
throw er; // Unhandled 'error' event
^
Error: /home/zakhargulchak/WebstormProjects/application-ngo2/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 text was updated successfully, but these errors were encountered: