-
-
Notifications
You must be signed in to change notification settings - Fork 353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rule proposal: Prefer Array.from(arr, mapFn)
over Array.from(arr).map(mapFn)
#2357
Comments
Please fill out the title. |
This rule may conflict with Array.from(foo).map(bar).flat() |
Array.from(arr, mapFn)
over Array.from(arr).map(...)
Done
We first need to figure out what we want to have Array.from(foo, bar).flat() vs Array.from(foo).flatMap(bar) In my opinion the |
Array.from(arr, mapFn)
over Array.from(arr).map(...)
Array.from(arr, mapFn)
over Array.from(arr).map(mapFn)
Already exists in another plugin: https://github.com/freaktechnik/eslint-plugin-array-func#from-map |
Okay cool, thanks 👍 https://www.npmjs.com/package/eslint-plugin-array-func So.. what now? @fisker @sindresorhus I would prefer to stick with eslint-plugin-unicorn only that is well managed and that I trust. Will this feature be added to eslint-plugin-unicorn or should I add an extra eslint-plugin-array-func to my ESLint config? 🤔 |
Description
Prefer
Array.from(arrayLike, mapFn)
overArray.from(arrayLike).map(...)
Prefer directly using
Array.from
mapFn
argument instead of an extramap
.This is supposed to improve performances.
Fail
Pass
Proposed rule name
prefer-array-from-map-fn
Additional Info
This should be automatically fixable by the --fix CLI option.
This looks 🤔 a bit related to:
no-useless-array-method
#2045prefer-array-from
#1714The text was updated successfully, but these errors were encountered: