Skip to content

prefer-early-return doesn't work when there is a variable #314

@BenjaminVanRyseghem

Description

@BenjaminVanRyseghem

Overview

When extracting the if condition into a variable, the rule is suddenly satisfied.

Not sure if it's a bug or not, but this feel like it could be at least improved (yet I don't know if it's really feasible)

Examples:

The following is considered warning

	foo() {
		if (a) {
			b();
			c();
		}
	}

yet, the following is not

	foo() {
        var bar = a;
		if (bar) {
			b();
			c();
		}
	}

Checklist

  • Please delete the labels section before submitting your issue
  • I have described this issue in a way that is actionable (if possible)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions