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

no-unreachable not reporting all unreachable code #3939

Closed
jmccaskill opened this Issue Sep 25, 2015 · 4 comments

Comments

Projects
None yet
5 participants
@jmccaskill
Copy link

jmccaskill commented Sep 25, 2015

  1. The version of ESLint you are using.
    v1.5.1
  2. What you did.
    An if-else where the if and the else both have a return, so anything after the if-else is unreachable.
/* eslint no-unreachable: 2 */
'use strict';

function testCase(param) {
    if (param) {
        return true;
        console.log('this is unreachable code that is reported as an error.');
    }
    else {
        return false;
        console.log('this is also unreachable code that is reported as an error.');
    }

    console.error('this is unreachable code that is not reported as an error.');
}
  1. What you expected to happen.
    I expected the code after the if-else to be reported as unreachable.
  2. What actually happened.
    The code after the if-else was not reported as unreachable.
    My original test case just had the console.error at the bottom of the function. Just to make sure I didn't configure something incorrectly, I added the console.logs after the returns in the if and else, and those were both correctly reported as unreachable.
@eslintbot

This comment has been minimized.

Copy link

eslintbot commented Sep 25, 2015

Thanks for the issue! If you're reporting a bug, please be sure to include:

  1. The version of ESLint you are using (run eslint -v)
  2. What you did (the source code and ESLint configuration)
  3. The actual ESLint output complete with numbers
  4. What you expected to happen instead

Requesting a new rule? Please see Proposing a New Rule for instructions.

@ilyavolodin

This comment has been minimized.

Copy link
Member

ilyavolodin commented Sep 25, 2015

Code path analysis would be able to help with this.

@nzakas

This comment has been minimized.

Copy link
Member

nzakas commented Sep 25, 2015

Blocked on code path analysis. Cc @mysticatea

@mysticatea

This comment has been minimized.

Copy link
Member

mysticatea commented Sep 25, 2015

Yeah, I'm rewriting no-unreachable totally in #3559.
It should fix this.

@mysticatea mysticatea self-assigned this Sep 26, 2015

mysticatea added a commit to mysticatea/eslint that referenced this issue Oct 24, 2015

mysticatea added a commit to mysticatea/eslint that referenced this issue Nov 13, 2015

mysticatea added a commit to mysticatea/eslint that referenced this issue Dec 2, 2015

@nzakas nzakas closed this in #4253 Dec 6, 2015

@eslint eslint bot locked and limited conversation to collaborators Feb 7, 2018

@eslint eslint bot added the archived due to age label Feb 7, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.