question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Conflict no-useless-undefined with consistent-return

See original GitHub issue

Thanks 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:closed
  • Created 2 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
crystalfpcommented, Apr 27, 2021

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.

1reaction
fiskercommented, Apr 21, 2021

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?

Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found