UseDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/sindresorhus/eslint-plugin-unicorn/llms.txt
Use this file to discover all available pages before exploring further.
Array#find() and Array#findLast() instead of filtering an array and then accessing the first or last element. find() stops iterating as soon as it finds a match and never allocates a new array — making it both clearer in intent and more efficient.
| Recommended | ✅ recommended · ☑️ unopinionated |
| Fixable | 🔧 Auto-fixable |
| Suggestions | 💡 Has suggestions |
This rule is fixable unless default values are used in destructuring. When a default value is present (e.g.,
const [item = fallback] = array.filter(…)), a suggestion is offered instead to choose between ?? or ||.Examples
Options
Type:object
checkFromLast
Type: booleanDefault:
true
Controls whether the rule also checks patterns that can be replaced with findLast(). Set to false to allow .filter(…).at(-1) and .filter(…).pop().