You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/rules/prefer-array-some.md
+18-6
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# Prefer `.some(…)` over `.filter(…).length` check and `.{find,findLast}(…)`
1
+
# Prefer `.some(…)` over `.filter(…).length` check and `.{find,findLast,findIndex,findLastIndex}(…)`
2
2
3
3
💼 This rule is enabled in the ✅ `recommended`[config](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs-eslintconfigjs).
4
4
@@ -17,7 +17,11 @@ We only check `.filter().length > 0` and `.filter().length !== 0`. These two non
17
17
18
18
- Comparing the result of [`Array#find()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find) or [`Array#findLast()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLast) with `undefined`.
19
19
20
-
This rule is fixable for `.filter(…).length` check and has a suggestion for `.{find,findLast}(…)`.
20
+
- Using [`Array#findIndex()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex) or [`Array#findLastIndex()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLastIndex) to ensure at least one element in the array passes a given check.
21
+
22
+
This rule is fixable for `.filter(…).length` checks and `.{findIndex,findLastIndex}(…)`.
23
+
24
+
This rule provides a suggestion for `.{find,findLast}(…)`.
Copy file name to clipboardExpand all lines: readme.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -176,7 +176,7 @@ If you don't use the preset, ensure you use the same `env` and `parserOptions` c
176
176
|[prefer-array-flat](docs/rules/prefer-array-flat.md)| Prefer `Array#flat()` over legacy techniques to flatten arrays. | ✅ | 🔧 ||
177
177
|[prefer-array-flat-map](docs/rules/prefer-array-flat-map.md)| Prefer `.flatMap(…)` over `.map(…).flat()`. | ✅ | 🔧 ||
178
178
|[prefer-array-index-of](docs/rules/prefer-array-index-of.md)| Prefer `Array#{indexOf,lastIndexOf}()` over `Array#{findIndex,findLastIndex}()` when looking for the index of an item. | ✅ | 🔧 | 💡 |
179
-
|[prefer-array-some](docs/rules/prefer-array-some.md)| Prefer `.some(…)` over `.filter(…).length` check and `.{find,findLast}(…)`.| ✅ | 🔧 | 💡 |
179
+
|[prefer-array-some](docs/rules/prefer-array-some.md)| Prefer `.some(…)` over `.filter(…).length` check and `.{find,findLast,findIndex,findLastIndex}(…)`. | ✅ | 🔧 | 💡 |
180
180
|[prefer-at](docs/rules/prefer-at.md)| Prefer `.at()` method for index access and `String#charAt()`. | ✅ | 🔧 | 💡 |
181
181
|[prefer-blob-reading-methods](docs/rules/prefer-blob-reading-methods.md)| Prefer `Blob#arrayBuffer()` over `FileReader#readAsArrayBuffer(…)` and `Blob#text()` over `FileReader#readAsText(…)`. | ✅ |||
182
182
|[prefer-code-point](docs/rules/prefer-code-point.md)| Prefer `String#codePointAt(…)` over `String#charCodeAt(…)` and `String.fromCodePoint(…)` over `String.fromCharCode(…)`. | ✅ || 💡 |
0 commit comments