-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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: max-imports #486
Comments
Can be an interesting rule. I'm guessing this would count both imports and requires. Would you count the number of modules, or functions imported. Like if you import the default and 2 named functions of a module, does that count as 1 or 3? I'd say its better to count it as 1. |
I'd be up for this. I agree with @jfmengels that it should count imported modules, not names. (though I could imagine having a parameter that limits names imported per-module, which would coerce you to import a namespace instead if you need more than X...) |
name options:
(something longer is fine, but I want to avoid restating |
Great! Yes agreed a shorter name probably makes more sense. I personally like |
I'd go for import/max-dependencies or import/max-imports or something, as max could be applied to many things (like max number of named imports for instance). |
@jfmengels but wouldn't that be under the purview of this rule, though? |
To me, this should only limit the number of modules/dependencies your file uses, not how you import it. If you want to use destructuring to use 10 lodash methods, that should still be counted as 1 dependency |
PR #489 ready for review. |
Curious what you would think about a max-imports rule. Usually if a module has, say, more than 10 imports or so, that is code smell and the module should be split up into smaller pieces.
Would you accept such a rule as a PR, or should such a rule live somewhere separately? Or does it already exist and I'm not aware? :)
The text was updated successfully, but these errors were encountered: