New Rule: prefer using `.at()`
See original GitHub issueRule details
prefer using .at()
to all the basic indexable classes (Array, String, TypedArray)
Related ECMAScript feature
https://github.com/tc39/proposal-relative-indexing-method
What type of rule is this?
Suggests an alternate way of doing something
Example code
incorrect examples:
var arr = [....];
var last = arr[arr.length - 1];
correct examples:
var arr = [....];
var last = arr.at(-1);
Why should this rule be in the core instead of a plugin?
it’s not platform-specific.
Participation
- I am willing to submit a pull request to implement this rule.
Additional comments
it has been stage-4.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
prefer-arrow-callback - ESLint - Pluggable JavaScript Linter
This rule locates function expressions used as callbacks or function arguments. An error will be produced for any that could be replaced by...
Read more >Only arrow functions in eslint? - javascript - Stack Overflow
You can use this ESLint prefer-arrow-callback rule which would flag with error/warning anywhere you could use an arrow function instead of a ...
Read more >eslint-plugin-unicorn/prefer-object-from-entries.md at main
When transforming a list of key-value pairs into an object, Object.fromEntries(…) should be preferred. This rule is fixable for simple cases. Fail. const ......
Read more >Linter rules - Dart programming language
This page lists all the linter rules, with details such as when you might want ... Implementations of createState() should return a new...
Read more >prefer-arrow-callback - ESLint Config
This rule locates function expressions used as callbacks or function arguments. An error will be produced for any that could be replaced by...
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
Unicorn rule for reference: unicorn/prefer-at
I agree. In general, instance method related rules are problematic because type information is required to be safe.
Given that there’s already a plugin rule filling this gap, I think we should decline.