Skip to content
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

[Feature Request] Remeda ESLint Plugin #656

Open
AndreaPontrandolfo opened this issue Apr 28, 2024 · 7 comments
Open

[Feature Request] Remeda ESLint Plugin #656

AndreaPontrandolfo opened this issue Apr 28, 2024 · 7 comments
Labels
feature request New feature or request question Further information is requested

Comments

@AndreaPontrandolfo
Copy link

Hey, i'm following the developments of Remeda and i have to say, this looks to be the most promising Lodash alternative in the wild right now.
Many have been born trough the years but almost all of them got abandoned at some point. Apparently replacing Lodash is no easy task.
There are a few concerns that i want to raise that could be key to the widespread adoption o this lib:

  • a proper ESLint plugin: the main reason why it's difficult to migrate out of Lodash is because Lodash is familiar, other libs are not. If i introduce Remeda in my company projects today, it will not be picked up by my team-mates because it cannot come natural to them to use these utils, simply because they don't know about their existence, even if the library is already installed in the project. This is a discoverability issue. In my experience, the only effective way to overcome this is with a ESLint plugin, just like the one Lodash have. Is there any plan to develop one?
  • runtime performance: i came across ts-belt and it has this benchmark. Apparently Remeda is pretty slow compared to some alternatives. Has this ever been discussed? There is any plan to improve this?
  • a Discussion tab: a saw that there are a few issues like mine that people opened in the Issues tab. These really are Discussions and should stay in the Discussion tab. Please open it so we can keep them there.
@eranhirsch
Copy link
Collaborator

eranhirsch commented Apr 28, 2024

Hello, and thanks for the kind words. I'll jump right in:

  • Being compared to lodash is both a blessing and a curse. One thing that constantly creates strong opinions is how we name stuff: If we choose to name everything like Lodash, we lose out on making the function names better, when possible, e.g., Lodash's toPairs and fromPairs when ECMAScript has chosen entries instead, or Lodash's choice of abbreviating function names instead of calling them by their full name (cond vs conditionally). Looking at the future and wanting to be the next lodash and not just a reimplementation of Lodash we need to make a choice here.
  • As for eslint, I don't know what the lodash lint plugin does (but planning on checking it out!), but it's probably overkill for us to build a Remeda plugin as other eslint plugins already do a great job (we can highly recommend unicorn as a supplement to the typescript plugin, and there is the functional programming one, although it's extremely FP 😉).
  • A note about migration: I think that once you remove lodash from your project your team would more likely adopt the replacement (they don't have a choice), so it's more about getting lodash out. For that, I've considered a "codemod" tool to help people convert existing projects from lodash to remeda, but those sorts of tools are not trivial to get right (but we'd be happy to get help building them!).
  • We don't benchmark remeda against other utilities but never get any feedback about performance issues. On the contrary, our lazy pipes are probably a perf benefit users get "for free" without needing to think about it, and they also help greatly with memory problems which aren't reflected in these sort of benchmark tests. We've introduced a lot of changes over the years and the benchmark from ts-belt doesn't mention what version it was tested against, so it's hard to know if they are reflected in those benchmarks. In v2 we continue to improve our runtime implementations, and we have plans to introduce more "iterator"-style improvements to make almost all functions run lazily where possible. TL;DR - this is not top of mind, but it's also not obviously a problem.
  • I'm totally for the Discussions tab, I don't know though how to structure the project to facilitate it, and the current rate of traffic is such that we can handle it with only issues and PRs. We will consider organizing the project with discussions (and maybe projects) in the near future if we find it useful.

@eranhirsch eranhirsch added feature request New feature or request question Further information is requested labels Apr 28, 2024
@AndreaPontrandolfo
Copy link
Author

AndreaPontrandolfo commented Apr 28, 2024

Thank you for clarifying the perf concerns, it totally makes sense.

About ESLint, let me clarify what i wanted to express.
Unicorn and ts-eslint have nothing to do with it.
The main benefit of eslint-plugin-lodash is the following.
If any of my team-mates write code like this:
const t = x === undefined || x === null;
ESLint will auto-fix it (in-editor) with:
const t = isNil(x);
Another example:
array.length > 0
becomes
!isEmpty(array)
It's very powerful, ESLint will warn your developers whenever they are doing something with Vanilla JS where is could be better expressed with Remeda utils, and then it actually autofix it in-editor!
Then, with time, developers of the team will start to reach for Remeda utils themselves.

A note about migration: I think that once you remove lodash from your project your team would more likely adopt the replacement (they don't have a choice), so it's more about getting lodash out. For that, I've considered a "codemod" tool to help people convert existing projects from lodash to remeda, but those sorts of tools are not trivial to get right (but we'd be happy to get help building them!).

See? Here you would just be reimplementing the ESLint CLI functionality: eslint --fix. Link.
Once the plugin is developed, adopters of Remeda could migrate just by running eslint --fix from their command-line.

@AndreaPontrandolfo
Copy link
Author

Even Ramda has one.
Not a coincidence. Lodash and Ramda are the 2 most popular JS util libs out there.

@eranhirsch
Copy link
Collaborator

Your examples are from vanilla JS to lodash/ramda, not from one library to the other. If your project is already using Lodash, the vanilla -> Remeda is not the main hurdle to adoption, the lint rule wouldn't help in those cases.

@AndreaPontrandolfo
Copy link
Author

The point is not the Lodash > Remeda migration. That's the easy part, because most utils overlap, even by names.
The point is minimum feature parity between Lodash and Remeda.
The Lodash ESLint plugin is fundamental for me, because without that, overtime, my team-mates would turn our codebase in a mess. This is an important code-quality consideration that i'm sure many lead-devs would make.
Without such a feature i cannot see myself comparing Lodash and Remeda on fair grounds. The utils themselves are just a part of the story, the ecosystem is equally important too.

@cjquines
Copy link
Collaborator

i think the eslint plugin is a good idea; is that the only feature request from this issue? if so, let's rename this issue and use it to track this?

@AndreaPontrandolfo
Copy link
Author

Yes, fine by me 👍

@AndreaPontrandolfo AndreaPontrandolfo changed the title A few suggestions and concerns [NEW FEATURE] Remeda ESLint Plugin Apr 28, 2024
@AndreaPontrandolfo AndreaPontrandolfo changed the title [NEW FEATURE] Remeda ESLint Plugin [Feature Request] Remeda ESLint Plugin Apr 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants