`no-run-logic`: allow arguments to be nested
Currently it's not possible to use the rule with the following:
angular
.module('foo', [
'config',
'someLogicModule',
])
.run(function (
someLogic,
config
) {
someLogic(config.foo.bar.baz);
})
Rationale:
In my project I have configuration built from many sources in CD. config module is created dynamically. I only allow run blocks to import config constant but the constant itself is nested (it's created from JSON objects). I chose to expose those things to DI under a common name to prevent naming collisions.
I'm striding towards applying this rule, but this really holds me back: I want to keep the architectural decision of NOT injecting config directly to services providing logic. On the other hand the only thing I can do with the rule enabled is:
.run(function (
someLogic,
config
) {
someLogic(config); // and handle `foo.bar.baz` inside
})
which gives someLogic too much power.
I suggest there should be a setting that will optionally allow passing values nested in DI objects.
This rule should also allow logic services to take named params (I mean ES2015 destructuring):
.run(function (
someLogic,
config
) {
someLogic({
foo: 1,
bar: 42
}); // those are still simple arguments but `someLogic` takes them as named arguments
})
John Papa angular-styleguide is for ES5 webapp only. The no-run-logic rule is implementing a John Papa rule so destructuring should not be taken into account.
Anyway, there is the Todd Motto style guide for AngularJS ES6 webapp.
So IMHO, you should write a specific rule for that instead of changing the ES5 behavior, or simply disable this rule.