1+ // temp script to check for missing ".js" extensions in relative local imports
2+ // related oxlint issue: https://github.com/oxc-project/oxc/issues/19431
3+
14import fs from 'node:fs' ;
25import path from 'node:path' ;
36import { styleText } from 'node:util' ;
47
5- // temp script to check for missing ".js" extensions in relative local imports
6- // related oxlint issue: https://github.com/oxc-project/oxc/issues/19431
7-
88const roots = [ 'demos' , 'frameworks' , 'frameworks-plugins' , 'packages' ] ;
99const excludedFolders = [ 'demos/aurelia/test' , 'demos/react/test' , 'demos/vue/test' , 'frameworks/angular-slickgrid' ] ;
1010const allowedExtPattern = / \. ( h t m l | j s | j s o n | m j s | p n g | v u e ) ( \? .* ) ? $ / ;
@@ -49,6 +49,7 @@ function walk(dir, acc) {
4949 }
5050}
5151
52+ const startTime = performance . now ( ) ;
5253const files = [ ] ;
5354for ( const root of roots ) {
5455 walk ( root , files ) ;
@@ -83,6 +84,9 @@ for (const filePath of scopedFiles) {
8384 }
8485}
8586
87+ const endTime = performance . now ( ) ;
88+ const elapsedTime = ( ( endTime - startTime ) / 1000 ) . toFixed ( 1 ) ;
89+
8690if ( errors . length > 0 ) {
8791 console . error ( color ( `Found ${ errors . length } relative imports missing a file extension (.js, .json, .mjs, or .vue).` , [ 'red' , 'bold' ] ) ) ;
8892 console . error ( color ( 'Add the appropriate extension to the import path in the following lines:' , 'yellow' ) ) ;
@@ -96,7 +100,11 @@ if (errors.length > 0) {
96100
97101 console . error ( '' ) ;
98102 console . error ( color ( `Total violations: ${ errors . length } ` , [ 'red' , 'bold' ] ) ) ;
103+ console . error ( `Finished in ${ elapsedTime } s on ${ scopedFiles . length } files.` ) ;
99104 process . exit ( 1 ) ;
105+ } else {
106+ console . log ( 'Found 0 violations.' ) ;
107+ console . log ( `Finished in ${ elapsedTime } s on ${ scopedFiles . length } files.` ) ;
100108}
101109
102110console . log ( color ( 'All relative imports have file extensions.' , 'green' ) ) ;
0 commit comments