Skip to content

[no-sequences] Add option to disable the "in-parentheses" exception #14197

@danielrentz

Description

@danielrentz

Follow-up for bug report #14184

What rule do you want to change?
no-sequences

Does this change cause the rule to produce more or fewer warnings?
more warnings

How will the change be implemented? (New option, new default behavior, etc.)?

  • New option that disables (or enables) the exception that sequences are allowed in parentheses.

Please provide some example code that this change will affect:

if ((x1 === x2) && (y1, y2)) {

Intended was

if ((x1 === x2) && (y1 === y2)) {

This real-life bug sneaked in after replacing a comparison function with the comparison operator

- if (isEqual(x1, x2) && isEqual(y1, y2)) {
+ if ((x1 === x2) && (y1, y2)) {

It was hard to find because the sequence expression was hidden in a short-circuiting AND operator.

What does the rule currently do for this code?
Lets it pass.

What will the rule do after it's changed?
Warns for the sequence.

Are you willing to submit a pull request to implement this change?
No. Yes.

Metadata

Metadata

Assignees

Labels

acceptedThere is consensus among the team that this change meets the criteria for inclusionenhancementThis change enhances an existing feature of ESLintruleRelates to ESLint's core rules

Type

No type

Projects

Status

Complete

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions