Rule Change: Add onlyOneSimpleParam: boolean
option to no-confusing-arrow
#15548
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
enhancement
This change enhances an existing feature of ESLint
rule
Relates to ESLint's core rules
Projects
What rule do you want to change?
no-confusing-arrow
What change to do you want to make?
Generate fewer warnings
How do you think the change should be implemented?
A new option
Example code
What does the rule currently do for this code?
Warn "Arrow function used ambiguously with a conditional expression."
What will the rule do after it's changed?
I propose a new
onlyOneSimpleParam
option withfalse
default value.When this option is set to
true
, the rule will not report any errors if one of the following is satisfied:The intention of
no-confusing-arrow
is to check whether a BinaryExpression is incorrectly written as an arrow expression. When the arrow contains no argument, the expected BinaryExpression() >= 1
is never valid so we don't have to throw at all. Actually I think this behaviour should be enabled unconditionally.When the arrow contains more than one argument: the expected BinaryExpression
(a, b) >= 1 ? 2 : 3
is rare use case so we don't throwWhen the arrow param is non-simple: the expected BinaryExpression
({ a, b }) >= 1 ? 2 : 3
is even rarer so we don't throw.Note that all the current rule example code gives only an arrow expression with exactly one simple parameter. We could enable this option by default in future majors.
Participation
Additional comments
Context: babel/babel#14201 (comment)
The text was updated successfully, but these errors were encountered: