Skip to content

False positive for prefer-lodash-chain with _.range? #257

@danvk

Description

@danvk

I have this function to produce nPoints of data on a curve:

const generateData = (nPoints: number) =>
  _.range(0, nPoints).map(i => {
    // Inverse tanh on (-0.9, +0.9); just something to get a distribution.
    const x = (1.9 * i) / nPoints - 0.95;
    const atanh = Math.log1p(x) - Math.log1p(-x);
    return {row: i, atanh};
  });

The prefer-lodash-chain rule flags this because of the _.range followed by the map. It's not clear what I'm supposed to replace this with, though. It would have to be something like _(_.range(0, nPoints)).map(...).value(), which doesn't seem like an improvement.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions