EmmanuelDemey / eslint-plugin-angular

ESLint plugin for AngularJS applications
https://www.npmjs.com/package/eslint-plugin-angular
618 stars 131 forks source link

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

Open jrencz opened 8 years ago

jrencz commented 8 years ago

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.

tilmanschweitzer commented 8 years ago

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.

jrencz commented 8 years ago

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

tilmanschweitzer commented 8 years ago

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

jrencz commented 7 years ago

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