Skip to content

Functional composition heuristics false positives #4751

@princed

Description

@princed

Prettier 1.13.6
Playground link

Input:

this.compose(d1, d2);

Output:

this.compose(
  d1,
  d2
);

Expected behavior:
Input code is not reformatted.

As discussed in #4431 (comment) functional composition heuristics produce some unexpected false positives, in part because compose, connect, flow terms are too broad and might relate not only to functional context.

Possible solutions:

  • Make sure identifiers are originated from certain packages (probably complex and slow as it requires scope)
  • Use code shape instead of identifiers list for heuristics
  • At least blacklist obvious edge case, i.e. when callee is MemberExpression and not Identifier

cc @suchipi

Metadata

Metadata

Assignees

No one assigned

    Labels

    lang:javascriptIssues affecting JSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions