1+ /* eslint-disable no-undef */
12'use strict' ;
23
34const fs = require ( 'node:fs' ) ;
@@ -32,7 +33,13 @@ function resolveBarrelPath(specifier) {
3233function resolveImportSource ( spec , fromFile ) {
3334 if ( ! spec . startsWith ( '.' ) ) return resolveBarrelPath ( spec ) ;
3435 const base = path . resolve ( path . dirname ( fromFile ) , spec ) ;
35- for ( const c of [ base , base + '.ts' , base + '.js' , path . join ( base , 'index.ts' ) , path . join ( base , 'index.js' ) ] ) {
36+ for ( const c of [
37+ base ,
38+ base + '.ts' ,
39+ base + '.js' ,
40+ path . join ( base , 'index.ts' ) ,
41+ path . join ( base , 'index.js' ) ,
42+ ] ) {
3643 if ( fs . existsSync ( c ) ) return c ;
3744 }
3845 return null ;
@@ -75,9 +82,15 @@ function getModuleExports(filepath, stack = new Set()) {
7582 const exports = new Map ( ) ;
7683 for ( const stmt of ast . body ) {
7784 if ( stmt . type === 'ExportNamedDeclaration' ) collectNamedExports ( stmt , exports , filepath , stack ) ;
78- else if ( stmt . type === 'ExportAllDeclaration' ) collectStarExports ( stmt , exports , filepath , stack ) ;
85+ else if ( stmt . type === 'ExportAllDeclaration' )
86+ collectStarExports ( stmt , exports , filepath , stack ) ;
7987 else if ( stmt . type === 'ExportDefaultDeclaration' ) {
80- exports . set ( 'default' , { source : filepath , localName : 'default' , isType : false , kind : 'local' } ) ;
88+ exports . set ( 'default' , {
89+ source : filepath ,
90+ localName : 'default' ,
91+ isType : false ,
92+ kind : 'local' ,
93+ } ) ;
8194 }
8295 }
8396
@@ -91,7 +104,12 @@ function collectNamedExports(stmt, exports, filepath, stack) {
91104
92105 if ( stmt . declaration ) {
93106 for ( const { name, isType } of declarationNames ( stmt . declaration ) ) {
94- exports . set ( name , { source : filepath , localName : name , isType : isType || stmtIsType , kind : 'local' } ) ;
107+ exports . set ( name , {
108+ source : filepath ,
109+ localName : name ,
110+ isType : isType || stmtIsType ,
111+ kind : 'local' ,
112+ } ) ;
95113 }
96114 return ;
97115 }
@@ -134,7 +152,13 @@ function collectNamedExports(stmt, exports, filepath, stack) {
134152 }
135153 }
136154
137- exports . set ( idOrStr ( spec . exported ) , { source, bareSource, localName : local , isType, kind : 'named' } ) ;
155+ exports . set ( idOrStr ( spec . exported ) , {
156+ source,
157+ bareSource,
158+ localName : local ,
159+ isType,
160+ kind : 'named' ,
161+ } ) ;
138162 }
139163}
140164
@@ -163,14 +187,11 @@ const SCOPE_PREFIXES = [
163187 path . join ( PACKAGES_ROOT , '@ember' ) + path . sep ,
164188 path . join ( PACKAGES_ROOT , '@glimmer' ) + path . sep ,
165189] ;
166- const EXCLUDED_FILE_PREFIXES = [
167- path . join ( PACKAGES_ROOT , '@glimmer/component' ) + path . sep ,
168- ] ;
190+ const EXCLUDED_FILE_PREFIXES = [ path . join ( PACKAGES_ROOT , '@glimmer/component' ) + path . sep ] ;
169191const TEST_DIR_RE = / [ \\ / ] (?: t e s t | t e s t s ) [ \\ / ] / ;
170192
171193const isInScope = ( filename ) => SCOPE_PREFIXES . some ( ( p ) => filename . startsWith ( p ) ) ;
172- const isExcludedFile = ( filename ) =>
173- EXCLUDED_FILE_PREFIXES . some ( ( p ) => filename . startsWith ( p ) ) ;
194+ const isExcludedFile = ( filename ) => EXCLUDED_FILE_PREFIXES . some ( ( p ) => filename . startsWith ( p ) ) ;
174195const isInTestFile = ( filename ) =>
175196 TEST_DIR_RE . test ( filename ) || filename . includes ( `${ path . sep } internal-test-helpers${ path . sep } ` ) ;
176197
@@ -211,9 +232,7 @@ function packageHasWildcardSourceExports(packageRoot) {
211232 const matches = ( v ) => v === './*.ts' ;
212233 allowed =
213234 matches ( wildcard ) ||
214- ( wildcard &&
215- typeof wildcard === 'object' &&
216- Object . values ( wildcard ) . some ( matches ) ) ;
235+ ( wildcard && typeof wildcard === 'object' && Object . values ( wildcard ) . some ( matches ) ) ;
217236 } catch {
218237 /* ignore */
219238 }
@@ -384,8 +403,10 @@ module.exports = {
384403 return ;
385404 }
386405
387- if ( node . type === 'ImportDeclaration' ) return handleImport ( node , moduleExports , spec , barrelPath ) ;
388- if ( node . type === 'ExportNamedDeclaration' ) return handleExportNamed ( node , moduleExports , spec , barrelPath ) ;
406+ if ( node . type === 'ImportDeclaration' )
407+ return handleImport ( node , moduleExports , spec , barrelPath ) ;
408+ if ( node . type === 'ExportNamedDeclaration' )
409+ return handleExportNamed ( node , moduleExports , spec , barrelPath ) ;
389410 if ( node . type === 'ExportAllDeclaration' ) reportUnresolved ( node , spec , [ '*' ] ) ;
390411 }
391412
@@ -404,9 +425,11 @@ module.exports = {
404425 continue ;
405426 }
406427 const importedName =
407- sp . type === 'ImportDefaultSpecifier' ? 'default'
408- : sp . type === 'ImportSpecifier' ? idOrStr ( sp . imported )
409- : null ;
428+ sp . type === 'ImportDefaultSpecifier'
429+ ? 'default'
430+ : sp . type === 'ImportSpecifier'
431+ ? idOrStr ( sp . imported )
432+ : null ;
410433 if ( importedName === null ) continue ;
411434
412435 const local = sp . local . name ;
0 commit comments