Conflict no-useless-undefined with consistent-return
See original GitHub issueThanks for all the eslint-plugin-unicorn checks! Very useful.
When I enable the eslint-plugin-unicorn/no-useless-undefined
rule, and have consistent-return
rule enabled too the following code gives one violation in the first rule. But if I change return undefined
to return
the later rule signals a violation.
Maybe the no-useless-undefined
rule is missing an option to skip this kind of code.
eslint-plugin-unicorn/no-useless-undefined
This simplified example removed the needed await calls present in the real code. Changing undefined to null trigger another violation. Well, I could disable the rule for this line, but there are many similar ones.
async compute(arg: number): Promise<number|undefined> {
if(arg === 42) return undefined;
return arg;
}
Thanks for looking mario
Issue Analytics
- State:
- Created 2 years ago
- Comments:8
Top Results From Across the Web
Conflict no-useless-undefined with consistent-return #1199
This simplified example removed the needed await calls present in the real code. Changing undefined to null trigger another violation.
Read more >eslint-plugin-unicorn/no-useless-undefined.md at main - GitHub
Disallow the use of undefined at the end of function call arguments. Pass checkArguments: false to disable checking them. Fail. // eslint unicorn/no-useless- ......
Read more >How can I have consistent-return with exhaustive switch-case ...
Probably the better way of doing it is to disable consistent-return and then to use typescript-lint's explicit-function-return-type or even no- ...
Read more >consistent-return - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >inconsistent-return-statements / R1710 - Pylint 2.16.0-dev ...
Either all return statements in a function should return an expression, or none of them should. Description: According to PEP8, if any return...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
As I wrote, disabling the rule. Eslint should help developing clean code, but too many false positive, or unfixable issues do not help in this.
Your code seems not parse able, is it TypeScript? I think https://github.com/sindresorhus/eslint-plugin-unicorn/pull/1165 already fixed it, are you sure your version is v30?