@@ -4,23 +4,25 @@ import type {
44 AtValueTokenImporterValue ,
55 CSSModule ,
66 Diagnostic ,
7- ExportBuilder ,
7+ ExportRecord ,
88 Location ,
99 MatchesPattern ,
1010 Resolver ,
1111 TokenImporter ,
1212} from './type.js' ;
1313import { isValidAsJSIdentifier } from './util.js' ;
1414
15- // eslint-disable-next-line max-params, complexity
16- export function checkCSSModule (
17- cssModule : CSSModule ,
18- config : CMKConfig ,
19- exportBuilder : ExportBuilder ,
20- matchesPattern : MatchesPattern ,
21- resolver : Resolver ,
22- getCSSModule : ( path : string ) => CSSModule | undefined ,
23- ) : Diagnostic [ ] {
15+ export interface CheckerArgs {
16+ config : CMKConfig ;
17+ getExportRecord : ( cssModule : CSSModule ) => ExportRecord ;
18+ matchesPattern : MatchesPattern ;
19+ resolver : Resolver ;
20+ getCSSModule : ( path : string ) => CSSModule | undefined ;
21+ }
22+
23+ // eslint-disable-next-line complexity
24+ export function checkCSSModule ( cssModule : CSSModule , args : CheckerArgs ) : Diagnostic [ ] {
25+ const { config } = args ;
2426 const diagnostics : Diagnostic [ ] = [ ] ;
2527
2628 for ( const token of cssModule . localTokens ) {
@@ -37,16 +39,16 @@ export function checkCSSModule(
3739 }
3840
3941 for ( const tokenImporter of cssModule . tokenImporters ) {
40- const from = resolver ( tokenImporter . from , { request : cssModule . fileName } ) ;
41- if ( ! from || ! matchesPattern ( from ) ) continue ;
42- const imported = getCSSModule ( from ) ;
42+ const from = args . resolver ( tokenImporter . from , { request : cssModule . fileName } ) ;
43+ if ( ! from || ! args . matchesPattern ( from ) ) continue ;
44+ const imported = args . getCSSModule ( from ) ;
4345 if ( ! imported ) {
4446 diagnostics . push ( createCannotImportModuleDiagnostic ( cssModule , tokenImporter ) ) ;
4547 continue ;
4648 }
4749
4850 if ( tokenImporter . type === 'value' ) {
49- const exportRecord = exportBuilder . build ( imported ) ;
51+ const exportRecord = args . getExportRecord ( imported ) ;
5052 for ( const value of tokenImporter . values ) {
5153 if ( ! exportRecord . allTokens . includes ( value . name ) ) {
5254 diagnostics . push ( createModuleHasNoExportedTokenDiagnostic ( cssModule , tokenImporter , value ) ) ;
0 commit comments