@@ -395,8 +395,8 @@ describe('CLI Integration Tests', () => {
395395 try {
396396 await run ( calm ( ) , [ 'validate' , '-p' , patternPath , '-a' , archPath ] ) ;
397397 expect . fail ( 'Expected validation to fail' ) ;
398- } catch ( error ) {
399- const result = JSON . parse ( error . stdout ) ;
398+ } catch ( error : unknown ) {
399+ const result = JSON . parse ( ( error as { stdout : string } ) . stdout ) ;
400400 expect ( result . hasErrors ) . toBe ( true ) ;
401401 expect ( JSON . stringify ( result ) ) . toContain ( 'owner' ) ;
402402 }
@@ -410,8 +410,8 @@ describe('CLI Integration Tests', () => {
410410 try {
411411 await run ( calm ( ) , [ 'validate' , '-p' , patternPath , '-a' , archPath , '-u' , mappingPath ] ) ;
412412 expect . fail ( 'Expected validation to fail' ) ;
413- } catch ( error ) {
414- const result = JSON . parse ( error . stdout ) ;
413+ } catch ( error : unknown ) {
414+ const result = JSON . parse ( ( error as { stdout : string } ) . stdout ) ;
415415 expect ( result . hasErrors ) . toBe ( true ) ;
416416 expect ( JSON . stringify ( result ) ) . toContain ( 'owner' ) ;
417417 }
@@ -452,7 +452,7 @@ describe('CLI Integration Tests', () => {
452452 expect ( res . status ) . toBe ( 200 ) ;
453453 expect ( res . data . status ) . toBe ( 'OK' ) ;
454454 } finally {
455- process . kill ( - serverProcess . pid ) ;
455+ if ( serverProcess . pid ) process . kill ( - serverProcess . pid ) ;
456456 }
457457 } ) ;
458458
@@ -486,7 +486,7 @@ describe('CLI Integration Tests', () => {
486486 expect ( JSON . stringify ( res . data ) ) . toContain ( 'hasErrors' ) ;
487487 expect ( JSON . stringify ( res . data ) ) . toContain ( 'hasWarnings' ) ;
488488 } finally {
489- process . kill ( - serverProcess . pid ) ;
489+ if ( serverProcess . pid ) process . kill ( - serverProcess . pid ) ;
490490 }
491491 } ) ;
492492
@@ -834,18 +834,18 @@ describe('CLI Integration Tests', () => {
834834 fs . writeFileSync ( filePath , JSON . stringify ( obj , null , 2 ) ) ;
835835 }
836836
837- function readJson ( filePath : string ) {
837+ function readJson ( filePath : string ) : Record < string , unknown > {
838838 return JSON . parse ( fs . readFileSync ( filePath , 'utf8' ) ) ;
839839 }
840840
841- function patchJson ( filePath : string , patchFn : ( o : object ) => void ) {
841+ function patchJson ( filePath : string , patchFn : ( o : Record < string , unknown > ) => void ) {
842842 const obj = readJson ( filePath ) ;
843843 patchFn ( obj ) ;
844844 writeJson ( filePath , obj ) ;
845845 }
846846
847847 // Utility to recursively remove specific line/character fields from JSON
848- function removeLineNumbers ( obj : object ) {
848+ function removeLineNumbers ( obj : unknown ) : void {
849849 const fieldsToRemove = [
850850 'line_start' ,
851851 'line_end' ,
@@ -854,12 +854,13 @@ describe('CLI Integration Tests', () => {
854854 ] ;
855855 if ( Array . isArray ( obj ) ) {
856856 obj . forEach ( removeLineNumbers ) ;
857- } else if ( obj && typeof obj === 'object' ) {
858- for ( const key of Object . keys ( obj ) ) {
857+ } else if ( obj !== null && typeof obj === 'object' ) {
858+ const record = obj as Record < string , unknown > ;
859+ for ( const key of Object . keys ( record ) ) {
859860 if ( fieldsToRemove . includes ( key ) ) {
860- delete obj [ key ] ;
861+ delete record [ key ] ;
861862 } else {
862- removeLineNumbers ( obj [ key ] ) ;
863+ removeLineNumbers ( record [ key ] ) ;
863864 }
864865 }
865866 }
0 commit comments