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#at(), String#at(), and equivalent methods on typed arrays and DOM collections for index access. The .at() method is cleaner for negative indices in particular, removing the need to reference .length manually. It also replaces String#charAt().
| Recommended | ✅ recommended · ☑️ unopinionated |
| Fixable | 🔧 Auto-fixable |
| Suggestions | 💡 Has suggestions |
By default this rule only checks negative index access (e.g.,
array[array.length - 1]). Enable checkAllIndexAccess to also enforce .at() for positive integer indices.Examples
Options
Type:object
checkAllIndexAccess
Type: booleanDefault:
false
When true, the rule also reports positive integer index access that can use .at().
getLastElementFunctions
Type: string[]Default:
[]
Additional function names or paths to treat as “get last element” helpers. _.last(), lodash.last(), and underscore.last() are always included.
The related rule
unicorn/prefer-negative-index enforces using negative indices with .at() as well.