@@ -6,11 +6,13 @@ import { AbstractConfigDependentRule } from '../src/rules';
66
77const ALL_OR_NONE_OPTION = 'all-or-none' ;
88const LEADING_OPTION = 'leading' ;
9+ const TRAILING_OPTION = 'trailing' ;
910const READONLY_OPTION = 'readonly' ;
1011const MEMBER_ACCESS_OPTION = 'member-access' ;
1112
1213const ALL_OR_NONE_FAIL = 'don\'t mix parameter properties with regular parameters' ;
1314const LEADING_FAIL = 'parameter properties must precede regular parameters' ;
15+ const TRAILING_FAIL = 'regular parameters must precede parameter properties' ;
1416const READONLY_FAIL = 'parameter property must be readonly' ;
1517const MEMBER_ACCESS_FAIL = 'parameter property must have access modifier' ;
1618
@@ -26,6 +28,7 @@ const MEMBER_ACCESS_FAIL = 'parameter property must have access modifier';
2628interface IOptions {
2729 allOrNone : boolean ;
2830 leading : boolean ;
31+ trailing : boolean ;
2932 readOnly : boolean ;
3033 memberAccess : boolean ;
3134}
@@ -35,6 +38,7 @@ export class Rule extends AbstractConfigDependentRule {
3538 return this . applyWithWalker ( new ParameterPropertyWalker ( sourceFile , this . ruleName , {
3639 allOrNone : this . ruleArguments . indexOf ( ALL_OR_NONE_OPTION ) !== - 1 ,
3740 leading : this . ruleArguments . indexOf ( LEADING_OPTION ) !== - 1 ,
41+ trailing : this . ruleArguments . indexOf ( TRAILING_OPTION ) !== - 1 ,
3842 readOnly : this . ruleArguments . indexOf ( READONLY_OPTION ) !== - 1 ,
3943 memberAccess : this . ruleArguments . indexOf ( MEMBER_ACCESS_OPTION ) !== - 1 ,
4044 } ) ) ;
@@ -90,6 +94,10 @@ class ParameterPropertyWalker extends Lint.AbstractWalker<IOptions> {
9094 regular = true ;
9195 }
9296 }
97+ } else if ( this . options . trailing ) {
98+ for ( let i = index ; i < length ; ++ i )
99+ if ( ! utils . isParameterProperty ( parameters [ i ] ) )
100+ this . addFailureAtNode ( parameters [ i ] , TRAILING_FAIL ) ;
93101 }
94102
95103 if ( this . options . memberAccess ) {
0 commit comments