eslint-plugin-angular icon indicating copy to clipboard operation
eslint-plugin-angular copied to clipboard

New rules suggestion: angular/di-limit, angular/module-dependency-limit

Open jrencz opened this issue 9 years ago • 4 comments

There should be a way to enforce maximum number of dependencies: both module dependencies and injected services. It may be used to enforce architectural decisions when a module grows.

jrencz avatar Apr 08 '16 10:04 jrencz

Nice idea. Your can already achieve a function param limit with the built-in ESLint rule max-params (http://eslint.org/docs/rules/max-params), but a custom rule for angular would be nice too.

tilmanschweitzer avatar Jul 24 '16 20:07 tilmanschweitzer

Not all functions are handled with angular DI so it would be inprecise to use just max-params. On the other hand it may be fair enough: I can't think of functions that are allowed to have more params than those handled by Angular DI

In fact DI is the reason I don't use max-params: I'd have to allow way more params then I intend to allow for all non-DI functions.

It would be best to allow setting a distinct limit for DI-handled functions and another one for all other functions - I assume one would like to allow more params in DI-handled functions than those that are not handled by DI. The rule I suggested could replace max-params in Angular apps

jrencz avatar Jul 24 '16 21:07 jrencz

Ok, no I understand your use-case. Actually I had the same problem and the max-params were way to high for normal function.

tilmanschweitzer avatar Jul 24 '16 23:07 tilmanschweitzer

@tilmanpotthof have you had any chance of working on this feature suggestion?

jrencz avatar Jan 17 '17 11:01 jrencz