File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -45,4 +45,38 @@ describe('package', () => {
45
45
}
46
46
}
47
47
} ) ;
48
+
49
+ it ( 'has rules flagged according to their configs' , ( ) => {
50
+ if ( ! plugin . configs ) {
51
+ expect . fail ( 'No configs found.' ) ;
52
+ }
53
+
54
+ const namespace = 'rxjs-x' ;
55
+
56
+ for ( const [ ruleName , rule ] of Object . entries ( plugin . rules ) ) {
57
+ const fullRuleName = `${ namespace } /${ ruleName } ` ;
58
+ const ruleRec = rule . meta . docs ?. recommended ;
59
+
60
+ if ( ! ruleRec ) {
61
+ // Rule is not part of any config.
62
+ expect ( plugin . configs . recommended . rules ) . not . toHaveProperty ( fullRuleName ) ;
63
+ expect ( plugin . configs . strict . rules ) . not . toHaveProperty ( fullRuleName ) ;
64
+ } else if ( typeof ruleRec === 'string' ) {
65
+ // Rule is part of a single config.
66
+ if ( ruleRec === 'recommended' ) {
67
+ expect ( plugin . configs . recommended . rules ) . toHaveProperty ( fullRuleName ) ;
68
+ } else if ( ruleRec === 'strict' ) {
69
+ expect ( plugin . configs . strict . rules ) . toHaveProperty ( fullRuleName ) ;
70
+ } else {
71
+ expect . fail ( `Invalid recommended value for rule ${ fullRuleName } : ${ ruleRec } ` ) ;
72
+ }
73
+ } else {
74
+ // Rule is part of several configs.
75
+ if ( ruleRec . recommended ) {
76
+ expect ( plugin . configs . recommended . rules ) . toHaveProperty ( fullRuleName ) ;
77
+ }
78
+ expect ( plugin . configs . strict . rules ) . toHaveProperty ( fullRuleName ) ;
79
+ }
80
+ }
81
+ } ) ;
48
82
} ) ;
You can’t perform that action at this time.
0 commit comments