Skip to content

Rule proposal: No this argument in array methods when using arrow functions #974

@sindresorhus

Description

@sindresorhus

Prevent specifying the this argument to array methods when using an arrow function, since it has no effect.

Applies to the following instance methods:

map
filter
some
find
forEach
findIndex
every

And also Array.from.

Only Array.from can be safely auto-fixed. The others should use suggestions.

Fail

array.filter(x => x === 1, this);

Pass

array.filter(x => x === 1);

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions