We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
.filter()[0]
.find()
Honestly, I'm not sure if I should add this here or in unicorn, but here it goes:
A rule to suggest replacing the use of .filter()[0] with .find(), since find breaks the loop as soon as it finds a match.
find
const item = array.filter(x => x === y)[0];
const item = array.find(x => x === y);
For the rule name, may I suggest something like no-filter-zero-index.
no-filter-zero-index
The text was updated successfully, but these errors were encountered:
This needs to be opened on eslint-plugin-unicorn.
eslint-plugin-unicorn
Sorry, something went wrong.
No branches or pull requests
Honestly, I'm not sure if I should add this here or in unicorn, but here it goes:
Rule Proposal
A rule to suggest replacing the use of
.filter()[0]
with.find()
, sincefind
breaks the loop as soon as it finds a match.Fail
Pass
For the rule name, may I suggest something like
no-filter-zero-index
.The text was updated successfully, but these errors were encountered: