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 · Fixed by #13923
Closed

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

mdjermanovic opened this issue Jan 3, 2020 · 4 comments · Fixed by #13923
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 rule Relates to ESLint's core rules

Comments

@mdjermanovic
Copy link
Member

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 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 labels Jan 3, 2020
@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

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.

@eslint-deprecated eslint-deprecated bot added the auto closed The bot closed this issue label Feb 4, 2020
@eslint-deprecated
Copy link

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.

@mdjermanovic mdjermanovic removed the auto closed The bot closed this issue label Feb 4, 2020
@mdjermanovic mdjermanovic self-assigned this Feb 4, 2020
@mdjermanovic mdjermanovic reopened this Feb 4, 2020
@mdjermanovic
Copy link
Member Author

Related discussion:

tc39/ecma262#2197

@mdjermanovic
Copy link
Member Author

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.

@mdjermanovic mdjermanovic 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 Dec 12, 2020
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Jun 17, 2021
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Jun 17, 2021
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 rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants