eslint: no-else-return rule should work in try-catch block
Tell us about your environment
- ESLint Version: 5.16.0
- Node Version: 12.0.0
- npm Version: 6.9.0
What parser (default, Babel-ESLint, etc.) are you using? default Please show your full configuration:
Configuration
{
"env": {
"es6": true,
"node": true
},
"extends": "eslint:recommended",
"rules": {
"no-else-return": "error"
}
}
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
class C {
get(id) {
if (this._options.get) {
try {
return this._options.get(id);
} catch (error) {
return Promise.reject(error);
}
} else { // Should warn about unnecessary else block
return Promise.reject(new Error('Method not implemented'));
}
}
}
npx eslint test.js
What did you expect to happen?
It was expected to show an error that else
block is unnecessary.
What actually happened? Please include the actual, raw output from ESLint. No error displayed in the output, because there is a nested try-catch block inside the if block.
Are you willing to submit a pull request to fix this bug? Not yet.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 16 (14 by maintainers)
I would like to work on this, could you please assign this issue to me?
I’m still in favor of the proposal outlined in https://github.com/eslint/eslint/issues/8028. If someone is interested in championing that proposal, please feel free to create a new issue outlining where we landed in that issue.