11import fs from 'node:fs/promises' ;
22import path from 'node:path' ;
33import plugin from '../src' ;
4+ import { RxjsXRuleDocs } from '../src/utils' ;
45
56function isSourceFile ( value : string ) : boolean {
67 const ext = path . extname ( value ) ;
@@ -51,14 +52,16 @@ describe('package', () => {
5152 const namespace = 'rxjs-x' ;
5253 const fullRuleName = `${ namespace } /${ ruleName } ` ;
5354
54- if ( ! rule . meta . docs ?. recommended ) {
55+ const ruleRec = ( rule . meta . docs as RxjsXRuleDocs < unknown [ ] , string > ) ?. recommended ;
56+
57+ if ( ! ruleRec ) {
5558 // Rule is not included in any configuration.
5659 expect ( plugin . configs . recommended . rules ) . not . toHaveProperty ( fullRuleName ) ;
5760 expect ( plugin . configs . strict . rules ) . not . toHaveProperty ( fullRuleName ) ;
58- } else if ( typeof rule . meta . docs . recommended === 'string' ) {
61+ } else if ( typeof ruleRec === 'string' ) {
5962 // Rule specifies only a configuration name.
60- expect ( rule . meta . docs . recommended ) . toMatch ( / ^ ( r e c o m m e n d e d | s t r i c t ) $ / ) ;
61- if ( rule . meta . docs . recommended === 'recommended' ) {
63+ expect ( ruleRec ) . toMatch ( / ^ ( r e c o m m e n d e d | s t r i c t ) $ / ) ;
64+ if ( ruleRec === 'recommended' ) {
6265 expect ( plugin . configs . recommended . rules ) . toHaveProperty ( fullRuleName ) ;
6366 } else {
6467 expect ( plugin . configs . recommended . rules ) . not . toHaveProperty ( fullRuleName ) ;
@@ -69,12 +72,12 @@ describe('package', () => {
6972 expect ( plugin . configs . strict . rules ) . toHaveProperty ( fullRuleName , expect . any ( String ) ) ;
7073 } else {
7174 // Rule specifies non-default options for strict.
72- if ( rule . meta . docs . recommended . recommended ) {
75+ if ( ruleRec . recommended ) {
7376 expect ( plugin . configs . recommended . rules ) . toHaveProperty ( fullRuleName ) ;
7477 } else {
7578 expect ( plugin . configs . recommended . rules ) . not . toHaveProperty ( fullRuleName ) ;
7679 }
77- expect ( plugin . configs . strict . rules ) . toHaveProperty ( fullRuleName , [ expect . any ( String ) , rule . meta . docs . recommended . strict [ 0 ] ] ) ;
80+ expect ( plugin . configs . strict . rules ) . toHaveProperty ( fullRuleName , [ expect . any ( String ) , ruleRec . strict [ 0 ] ] ) ;
7881 }
7982 } ) ;
8083} ) ;
0 commit comments