File tree Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -25,19 +25,21 @@ class Walker extends Lint.RuleWalker {
25
25
}
26
26
27
27
visitClassDeclaration ( node : ts . ClassDeclaration ) {
28
- if ( ! this . hasDirectiveDecorator ( node ) ) {
29
- return ;
30
- }
31
-
32
- // If the class already has an explicit constructor, it's not required
33
- // for base classes to be decorated.
34
- if ( this . hasExplicitConstructor ( node ) ) {
28
+ // If the class isn't decorated or it has an explicit constructor we don't need to check it.
29
+ if ( ! this . hasDirectiveDecorator ( node ) || this . hasExplicitConstructor ( node ) ) {
35
30
return ;
36
31
}
37
32
38
33
const baseClass = this . getConstructorBaseClass ( node ) ;
39
34
if ( baseClass && ! this . hasDirectiveDecorator ( baseClass ) ) {
40
- this . addFailureAtNode ( node , RULE_FAILURE ) ;
35
+ const constructor = baseClass . members . find ( ts . isConstructorDeclaration ) ;
36
+
37
+ // If the base class constructor doesn't have parameters we don't need to flag it, because
38
+ // it can't be using DI. Note that technically we know the constructor exists because of
39
+ // `getConstructorBaseClass`, but we null check it to keep the compiler happy.
40
+ if ( ! constructor || constructor . parameters . length > 0 ) {
41
+ this . addFailureAtNode ( node , RULE_FAILURE ) ;
42
+ }
41
43
}
42
44
}
43
45
You can’t perform that action at this time.
0 commit comments