EmmanuelDemey / EmmanuelDemey/eslint-plugin-angular
di-order does not work with DI-enabled ES Class constructors
- Dominant language
- JavaScript
- Stars
- 620
- Forks
- 127
- PR merge metrics
- No merged PRs in 30d
Description
Example (expected outcome: `angular/di-order` error):
```js
/*eslint angular/di-order: [2, false, "case_insensitive]*/
class FooCtrl {
constructor(
c,
b,
a
) {
'ngInject';
this.a = a;
this.b = b;
this.c = c;
}
}
angular.module('foo', []).component('foo', {
controller: FooCtrl
});
```
Class constructor is not matched by the rule although it's matched by [`olov/ng-annotate`](https://github.com/olov/ng-annotate) with `'ngInject'` statement at the beginning.
ng-annotate follows references so I believe it would match this example anyway since after transpilation it's just a function and annotate follows function references. In case class was defined in a distinct ES module (which is a bit more complex example and off course there would be no way to follow a reference) `ng-annotate` would require `'ngInject'` statement. But let's stick to [what annotate README states](https://github.com/olov/ng-annotate#es6-and-typescript-support):
> ng-annotate supports ES5 as input so run it with the output from Babel, Traceur, TypeScript (tsc) and the likes. Use "ngInject" on functions you want annotated.
I suggest `angular/di-order` should apply to all functions having `'ngInject'` statement and assume they are DI-enabled.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.