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 false positive with await and exponentiation operator #12739

Closed
mdjermanovic opened this issue Jan 3, 2020 · 4 comments
Closed

no-extra-parens false positive with await and exponentiation operator #12739

mdjermanovic opened this issue Jan 3, 2020 · 4 comments

Comments

@mdjermanovic
Copy link
Member

@mdjermanovic mdjermanovic commented Jan 3, 2020

Tell us about your environment

  • ESLint Version: v6.8.0
  • Node Version: v12.14.0
  • npm Version: v6.13.4

What parser (default, Babel-ESLint, etc.) are you using?

default

Please show your full configuration:

Configuration
module.exports = {
    parserOptions: {
        ecmaVersion: 2017,
    },
};

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

Online Demo Link

/* eslint no-extra-parens: "error"*/

async function foo () {
    (await a) ** b;
}
eslint index.js --fix

What did you expect to happen?

I believe no error.

By the spec, UnaryExpression can't be the left-hand side of an ExponentiationExpression.

await a ** b is parsing error for espree.

What actually happened? Please include the actual, raw output from ESLint.

Auto-fixed to:

/* eslint no-extra-parens: "error"*/

async function foo () {
    await a ** b;
}

Message after the fix:

4:13  error  Parsing error: Unexpected token **

Are you willing to submit a pull request to fix this bug?

Yes.

It would be good to verify is this really a bug in the rule, because await a ** b seems to be allowed in Chrome and Firefox. It's interpreted as (await a) ** b.

@mdjermanovic mdjermanovic changed the title Update: no-extra-parens false positive with await and exponentiation operator no-extra-parens false positive with await and exponentiation operator Jan 3, 2020
@kaicataldo
Copy link
Member

@kaicataldo kaicataldo commented Jan 4, 2020

I'm also not sure what the correct behavior is here. It looks like Esprima and Babel's parser also allow for await a ** b, while TypeScript and Espree throw a parsing error.

Loading

@eslint-deprecated
Copy link

@eslint-deprecated eslint-deprecated bot commented Feb 4, 2020

Unfortunately, it looks like there wasn't enough interest from the team
or community to implement this change. While we wish we'd be able to
accommodate everyone's requests, we do need to prioritize. We've found
that issues failing to reach accepted status after 21 days tend to
never be accepted, and as such, we close those issues.
This doesn't mean the idea isn't interesting or useful, just that it's
not something the team can commit to.

Thanks for contributing to ESLint and we appreciate your understanding.

Loading

@mdjermanovic mdjermanovic self-assigned this Feb 4, 2020
@mdjermanovic mdjermanovic reopened this Feb 4, 2020
@mdjermanovic
Copy link
Member Author

@mdjermanovic mdjermanovic commented Oct 4, 2020

Related discussion:

tc39/ecma262#2197

Loading

@mdjermanovic
Copy link
Member Author

@mdjermanovic mdjermanovic commented Dec 12, 2020

It was decided to leave the spec as-is:

https://github.com/tc39/notes/blob/master/meetings/2020-11/nov-16.md#handling-await-in-left-operands-of-exponentiation

meaning that await a ** b is a syntax error, so no-extra-parens should not report parens around await a.

Loading

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants