Skip to content

[eslint-plugin-vtex] Create rule to prevent assigning the return value of array methods that mutate the array #78

@kaisermann

Description

@kaisermann

Is your feature request related to a problem? Please describe.

As posted on slack:

Jay Phelps @_jayphelps
I feel very strongly that array.sort() in JS should 100% of the time be put on it's own line and return value never used. sort() mutates the original array, and returns that same array again, so when chained with functional methods like map/filter/reduce is very bug prone later https://pbs.twimg.com/media/EJnuzRGXkAIPCvB.png

Describe the solution you'd like

Reference: https://github.com/cartant/eslint-plugin-etc/blob/master/source/rules/no-assign-mutated-array.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions