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-sequences]: allowInParentheses ain't work with arrows #14263

Closed
bricss opened this issue Mar 29, 2021 · 3 comments · Fixed by #14313
Closed

[no-sequences]: allowInParentheses ain't work with arrows #14263

bricss opened this issue Mar 29, 2021 · 3 comments · Fixed by #14313
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 documentation Relates to ESLint's documentation rule Relates to ESLint's core rules
Projects

Comments

@bricss
Copy link

bricss commented Mar 29, 2021

  • ESLint Version: 7.23 + @babel/eslint-parser
  • Node Version: 15.12.0
  • npm Version: 7.6.3
  • Operating System: win10_x64

It looks like newly added allowInParentheses option of no-sequences rule won't work with arrow functions.

const wat = (op) => (console.log('wat'), op);

What did you expect to happen?
Expect it to pass validation

What actually happened?
Validation error: Unexpected use of comma operator

@bricss bricss added bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels Mar 29, 2021
@eslint-github-bot eslint-github-bot bot added this to Needs Triage in Triage Mar 29, 2021
@mdjermanovic mdjermanovic moved this from Needs Triage to Triaging in Triage Mar 29, 2021
@mdjermanovic
Copy link
Member

Hi @bricss, thanks for the issue!

It looks like newly added allowInParentheses option of no-sequences rule won't work with arrow functions.

const wat = (op) => (console.log('wat'), op);

This works as expected. allowInParentheses: true (default) retains the previous behavior of this rule, which is to allow sequence expressions that are explicitly wrapped in parentheses. For arrow function's body, "explicitly" was considered as being parenthesized twice (ref #6082):

/* eslint no-sequences: ["error", { "allowInParentheses": true } ] */

const wat1 = (op) => (console.log('wat'), op); // error

const wat2 = (op) => ((console.log('wat'), op)); // ok

Online Demo

I've verified that ESLint v7.22.0 with the provided example gives the same result.

Marked as accepted issue to improve documentation. We should add some examples with arrow functions to clarify this.

@mdjermanovic mdjermanovic added accepted There is consensus among the team that this change meets the criteria for inclusion documentation Relates to ESLint's documentation rule Relates to ESLint's core rules and removed bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels Mar 29, 2021
@mdjermanovic mdjermanovic moved this from Triaging to Ready to Implement in Triage Mar 29, 2021
@bricss
Copy link
Author

bricss commented Mar 29, 2021

Isn't it like a buttery butter 🧈 to wrap 🌯 it twice in parentheses?
It's obviously looks already wrapped in first example.
Don't see a reason to do it twice 🤔

Triage automation moved this from Ready to Implement to Complete Apr 12, 2021
@zcqno1
Copy link

zcqno1 commented Oct 9, 2021

It's commonly conflict with the prettier format rule. The extra parentheses would be removed.

image

@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Oct 10, 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 Oct 10, 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 documentation Relates to ESLint's documentation rule Relates to ESLint's core rules
Projects
Archived in project
Triage
Complete
Development

Successfully merging a pull request may close this issue.

3 participants