Rule proposal: `prefer-array-find`
See original GitHub issuePrefer .find()
over .filter()[0]
, since find
breaks the loop as soon as it finds a match.
Fail
const item = array.filter(x => x === '🦄')[0];
Pass
const item = array.find(x => x === '🦄');
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Rule proposal: `prefer-array-some` #736 - Issuehunt
I like the idea of suggesting some . Might help users who don't know any better. BTW, I did a rule to eslint...
Read more >C++ Core Guidelines - GitHub Pages
assignment: regular types – prefer initialization – copy – move – other ... You will find some of the rules contrary to your...
Read more >Medicare Program: Prospective Payment ... - Regulations.gov
This proposed rule would update: Payment rates; forecast error adjustment; ... Follow the search instructions on that website to view public comments.
Read more >Details of the policy definition structure - Azure - Microsoft Learn
This policy rule example uses the resourceGroup resource function to get the name property, combined with the concat array and object function ...
Read more >Proposed Rule: Further Definition of “As a Part of a Regular ...
The Commission has neither approved nor disapproved the content of these staff documents and, like all staff statements, they have no legal ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Fail
Accepted. PR welcome.