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-extra-parens missing YieldExpression #4608

Closed
btmills opened this Issue Dec 4, 2015 · 1 comment

Comments

Projects
None yet
3 participants
@btmills
Copy link
Member

btmills commented Dec 4, 2015

While working on #4229, I came across this:

function *test() {
  yield 1;
  yield (2);
  yield       // 4:8 - Missing semicolon. (semi)
    3;
  yield (
    4
  );
  return (5); // 9:10 - Gratuitous parentheses around expression. (no-extra-parens)
}

for (let val of test()) {
  console.log(val); // 1 2 (blank) 4
}

I ran the above code in the demo with only no-extra-parens and semi enabled and pasted the errors inline. I included semi and the return as sanity checks.

I would expect a warning about excess parens on yield (2);, but there was none. Looking at the source, no-extra-parens doesn't check YieldExpressions, so hopefully the fix is as simple as adding that check.

Working on this.

@btmills btmills added bug rule labels Dec 4, 2015

btmills added a commit that referenced this issue Dec 4, 2015

@michaelficarra

This comment has been minimized.

Copy link
Member

michaelficarra commented Dec 4, 2015

Looks like the addition of YieldExpression support (#1992) only added support for YieldExpressions within other expressions, but not the other way around.

@nzakas nzakas added the accepted label Dec 5, 2015

btmills added a commit that referenced this issue Dec 5, 2015

btmills added a commit that referenced this issue Dec 5, 2015

@btmills btmills closed this in 677b9c6 Dec 5, 2015

nzakas added a commit that referenced this issue Dec 5, 2015

Merge pull request #4609 from eslint/issue4608
Fix: Check YieldExpression argument in no-extra-parens (fixes #4608)

@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.