Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rule to recommend spread arguments over Function.prototype.apply #546

Open
ajafff opened this issue Feb 2, 2019 · 0 comments · May be fixed by #710
Open

Add rule to recommend spread arguments over Function.prototype.apply #546

ajafff opened this issue Feb 2, 2019 · 0 comments · May be fixed by #710

Comments

@ajafff
Copy link
Member

ajafff commented Feb 2, 2019

foo.apply(undefined, args);
foo.apply(null, args);
// becomes
foo(...args);

obj.foo.apply(obj, args);
// becomes
obj.foo(...args);

// allows passing a different 'this' reference
foo.apply(other, args);
obj.foo.apply(other, args);
obj.foo.apply(undefined, args);

// detects unrelated methods named 'apply'
const myObj = {apply(a: any, b: any[]) {}};
myObj.apply(undefined, args); // no error here

This rule should probably only do its job if strictBindCallApply is active. Otherwise autofixing might cause type errors.

Suggested name: prefer-spread-arguments

The same rule is available in ESLint as prefer-spread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant