Skip to content
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

False positive for no-useless-return #7477

Closed
fasttime opened this issue Oct 29, 2016 · 3 comments
Closed

False positive for no-useless-return #7477

fasttime opened this issue Oct 29, 2016 · 3 comments
Assignees
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly patch candidate This issue may necessitate a patch release in the next few days rule Relates to ESLint's core rules

Comments

@fasttime
Copy link
Member

So I decided to give a try to the new rule no-useless-return and I stumbled on what looks to me like too much of goodness.

Here is a minimal example to illustrate the issue (actual code is here: https://github.com/fasttime/JScrewIt/blob/b3cce7dbc33628c184a1d39bf827c5b5bb52877e/src/lib/encoder-base.js#L363).

function returnValidValueOrUndefined(value)
{
    if (!isValidValue(value))
        return; // Unnecessary return statement   no-useless-return
    return value;
}

Granted, there are plenty of ways to get rid of the expressionless return;, but it seems unfair to call it useless when the next statement would potentially return something different.

@eslintbot eslintbot added the triage An ESLint team member will look at this issue soon label Oct 29, 2016
@platinumazure platinumazure added bug ESLint is working incorrectly rule Relates to ESLint's core rules evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Oct 29, 2016
@platinumazure
Copy link
Member

Hmm... I agree, this seems like a bug.

@mysticatea, what do you think? Is this a bug, or working as designed?

@not-an-aardvark not-an-aardvark added accepted There is consensus among the team that this change meets the criteria for inclusion and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Oct 29, 2016
@not-an-aardvark
Copy link
Member

I agree, this is a bug.

@mysticatea
Copy link
Member

I agree, this is a bug.
I have forgotten to mark as used at return statements which have a return value.

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 6, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly patch candidate This issue may necessitate a patch release in the next few days rule Relates to ESLint's core rules
Projects
None yet
Development

No branches or pull requests

5 participants