@@ -10,35 +10,35 @@ const path = require('path');
1010 */
1111function extractJsonFromHttpFile ( filePath ) {
1212 const content = fs . readFileSync ( filePath , 'utf8' ) ;
13-
13+
1414 // Split by double newline to separate headers from body
1515 const parts = content . split ( / \n \s * \n / , 2 ) ;
16-
17- if ( parts . length < 2 ) {
16+
17+ if ( parts . length < 2 )
1818 return null ;
19- }
20-
19+
20+
2121 const body = parts [ 1 ] . trim ( ) ;
22- if ( ! body ) {
22+ if ( ! body )
2323 return null ;
24- }
25-
24+
25+
2626 // Check if content-type indicates JSON
2727 const headers = parts [ 0 ] ;
28- const isJsonContentType = headers . includes ( 'Content-Type: application/json' ) ||
28+ const isJsonContentType = headers . includes ( 'Content-Type: application/json' ) ||
2929 headers . includes ( 'content-type: application/json' ) ;
30-
30+
3131 // If no explicit JSON content-type, try to parse as JSON anyway
3232 // (some files might have JSON without proper content-type header)
33- if ( ! isJsonContentType ) {
33+ if ( ! isJsonContentType )
3434 try {
3535 JSON . parse ( body ) ;
3636 return body ;
37- } catch ( e ) {
37+ } catch {
3838 return null ;
3939 }
40- }
41-
40+
41+
4242 return body ;
4343}
4444
@@ -49,22 +49,22 @@ function extractJsonFromHttpFile(filePath) {
4949 */
5050function findHttpFiles ( dir ) {
5151 const files = [ ] ;
52-
52+
5353 function traverse ( currentDir ) {
5454 const items = fs . readdirSync ( currentDir ) ;
55-
55+
5656 for ( const item of items ) {
5757 const fullPath = path . join ( currentDir , item ) ;
5858 const stat = fs . statSync ( fullPath ) ;
59-
60- if ( stat . isDirectory ( ) ) {
59+
60+ if ( stat . isDirectory ( ) )
6161 traverse ( fullPath ) ;
62- } else if ( item . endsWith ( '.http' ) ) {
62+ else if ( item . endsWith ( '.http' ) )
6363 files . push ( fullPath ) ;
64- }
64+
6565 }
6666 }
67-
67+
6868 traverse ( dir ) ;
6969 return files ;
7070}
@@ -77,21 +77,21 @@ function validateJsonInFixtures(fixturesDir) {
7777 const errors = [ ] ;
7878 let filesChecked = 0 ;
7979 let jsonFilesFound = 0 ;
80-
80+
8181 console . log ( `🔍 Scanning for HTTP fixtures in: ${ fixturesDir } ` ) ;
82-
82+
8383 const httpFiles = findHttpFiles ( fixturesDir ) ;
84-
84+
8585 for ( const filePath of httpFiles ) {
8686 filesChecked ++ ;
8787 const jsonContent = extractJsonFromHttpFile ( filePath ) ;
88-
89- if ( ! jsonContent ) {
88+
89+ if ( ! jsonContent )
9090 continue ;
91- }
92-
91+
92+
9393 jsonFilesFound ++ ;
94-
94+
9595 try {
9696 JSON . parse ( jsonContent ) ;
9797 console . log ( `✅ ${ filePath } ` ) ;
@@ -101,12 +101,12 @@ function validateJsonInFixtures(fixturesDir) {
101101 errors . push ( errorMsg ) ;
102102 }
103103 }
104-
104+
105105 console . log ( '\n📊 Summary:' ) ;
106106 console . log ( `Files checked: ${ filesChecked } ` ) ;
107107 console . log ( `JSON files found: ${ jsonFilesFound } ` ) ;
108108 console . log ( `Validation errors: ${ errors . length } ` ) ;
109-
109+
110110 if ( errors . length > 0 ) {
111111 console . log ( '\n❌ Errors found:' ) ;
112112 errors . forEach ( error => console . log ( ` ${ error } ` ) ) ;
0 commit comments