Skip to content

Syntactically invalid fix for function that’s an operand of an operator #37

@andersk

Description

@andersk

This rule auto-fixes f || function () {} to f || () => {}, which is syntactically invalid. Since an arrow function has lower precedence than a function expression, the auto-fix needs to parenthesize it when it’s an operand of most operators: f || (() => {}).

The exceptions are that an unparenthesized arrow function is allowed on the right side of an assignment =, augmenting assignment +=, -=, …, another arrow =>, yield, yield*, spread ..., the middle or right side of a ternary ? :, or either side of a comma ,.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions