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

Rule idea: prefer individual per-function modules #163

Closed
jasonkarns opened this issue Oct 17, 2017 · 7 comments
Closed

Rule idea: prefer individual per-function modules #163

jasonkarns opened this issue Oct 17, 2017 · 7 comments

Comments

@jasonkarns
Copy link

Rule suggestion to prefer import uniq from 'lodash.uniq'; over import { uniq } from 'lodash'; to slim bundle sizes and call out explicit uses.

@ganimomer
Copy link
Contributor

Hi, thanks for opening an issue!
This rule is already implemented as import-scope, and its value in the recommended configuration is method, which is what you're describing.

@ganimomer
Copy link
Contributor

However, the plugin currently doesn't handle per-function modules, and can only read imports of files from the lodash modules. (e.g. it recognizes import uniq from 'lodash/uniq' but not import uniq from 'lodash.uniq').
Since it looks like Lodash themselves are going to discontinue per-method packages (second bullet point at the time of writing), I'm not sure the difference is worth implementing.

@jasonkarns
Copy link
Author

jasonkarns commented Oct 17, 2017

rule is already implemented as import-scope

as you later mentioned:

doesn't handle per-function modules

the import-scope rule is not at all what I'm suggesting. The per-function module piece is the crux of the rule. Thanks for pointing out the v5 roadmap; I hadn't seen that.

I can only speak as a user, but I'm not sure the potential deprecation would have any near term impact on me or my desire for this rule. Its presence on the roadmap doesn't guarantee the per-function modules actually get discontinued. Nor is there any timeline as to when that might even happen. (The roadmap currently mentions ~2017 for v5 but that was clearly optimistic.) Even if the per-function modules are discontinued (which isn't a certainty) and even if it happens this year (which is unlikely), a lot of teams will still be using lodash v3 or v4 for quite some time to come (years, most likely). So this rule would still be valuable (at least to me) for quite some time.

Indeed, the discontinuation might even make this rule _more_valuable. If the rule could be implemented in such a way as to be configurable between preferring per-function or rejecting per-function, then the rule would be useful both now in the short term (for current usage) and in the future when migrating to v5.

@ganimomer
Copy link
Contributor

That's a good point.
It would take a small infrastructure change, as well, to include per-method packages in the first place.
Would you like to submit a PR?

@jasonkarns
Copy link
Author

I would like to but it's unlikely I'll have the time in the next few weeks.

@ganimomer
Copy link
Contributor

I went ahead and implemented this. Fixed in v2.5.0.

@jasonkarns
Copy link
Author

sweet, thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants