File tree Expand file tree Collapse file tree 5 files changed +31
-3
lines changed
Expand file tree Collapse file tree 5 files changed +31
-3
lines changed Original file line number Diff line number Diff line change 1111 }
1212 },
1313 "scripts" : {
14- "build" : " rm -rf dist typings && npm run format && npm test && tsc && node dist/index.js " ,
14+ "build" : " rm -rf dist typings && npm run format && npm test && tsc" ,
1515 "format" : " prettier --write ." ,
1616 "docs" : " rm -rf docs && npm run format && npm test && typedoc" ,
1717 "buildWithDocs" : " rm -rf docs && npm run build && typedoc" ,
Original file line number Diff line number Diff line change 1+ import { readdirSync , readFileSync } from "fs" ;
2+
3+ const isTsFile = ( path : string ) => path . endsWith ( ".ts" ) ;
4+ const isSourceFile = ( path : string ) => isTsFile ( path ) && ! path . endsWith ( ".test.ts" ) && ! path . includes ( "__tests__/" ) ;
5+
6+ function allSourceFilesInDir ( path : string ) {
7+ const files = readdirSync ( path ) . map ( ( filename ) => `${ path } /${ filename } ` ) ;
8+ files . filter ( ( filename ) => ! isTsFile ( filename ) ) . forEach ( ( filename ) => files . push ( ...allSourceFilesInDir ( filename ) ) ) ;
9+
10+ return files . filter ( ( filename ) => isSourceFile ( filename ) ) ;
11+ }
12+
13+ it ( "should include a .js file extension in all source files" , ( ) => {
14+ allSourceFilesInDir ( "src" ) . forEach ( ( filename ) => {
15+ const content = readFileSync ( filename ) . toString ( ) ;
16+ const importStatements = content . split ( "\r\n" ) . filter ( ( line ) => line . match ( / ^ i m p o r t ( \{ ) ? [ \w , ] + ( \} ) ? f r o m " .+ " ; $ / ) ) ;
17+
18+ const allHaveExtension = importStatements . every ( ( line ) => {
19+ if ( line . endsWith ( '.js";' ) ) return true ;
20+
21+ console . log ( line ) ;
22+ return false ;
23+ } ) ;
24+
25+ expect ( allHaveExtension ) . toBe ( true ) ;
26+ } ) ;
27+ } ) ;
Original file line number Diff line number Diff line change 1- import FloatToolkit from "." ;
1+ import FloatToolkit from "./index.js " ;
22
33/**
44 * @internal
Original file line number Diff line number Diff line change 1- import FloatToolkit from "." ;
1+ import FloatToolkit from "./index.js " ;
22
33/**
44 * @internal
Original file line number Diff line number Diff line change 99 "module" : " esnext" ,
1010 "rootDir" : " ./src/" ,
1111 "moduleResolution" : " node" ,
12+ "types" : [],
1213 "resolveJsonModule" : true ,
1314
1415 "declaration" : true ,
You can’t perform that action at this time.
0 commit comments