@@ -382,7 +382,7 @@ configSuspicious["OTHER_FILES.txt"] = contents =>
382
382
: undefined ;
383
383
configSuspicious [ "package.json" ] = makeJsonCheckerFromCore (
384
384
{ private : true } ,
385
- [ "dependencies" , "types" , "typesVersions" ]
385
+ [ "/ dependencies" , "/ types" , "/ typesVersions" ]
386
386
) ;
387
387
configSuspicious [ "tslint.json" ] = makeJsonCheckerFromCore (
388
388
{ extends : "dtslint/dt.json" } ,
@@ -402,20 +402,17 @@ configSuspicious["tsconfig.json"] = makeJsonCheckerFromCore(
402
402
forceConsistentCasingInFileNames : true
403
403
}
404
404
} ,
405
- [ "files" , "compilerOptions. paths" , "compilerOptions. baseUrl" , "compilerOptions. typeRoots" ]
405
+ [ "/ files" , "/ compilerOptions/ paths" , "/ compilerOptions/ baseUrl" , "/ compilerOptions/ typeRoots" ]
406
406
) ;
407
407
408
408
// helper for json file testers: allow either a given "requiredForm", or any edits that get closer
409
- // to it, ignoring some keys (sub-values can be specified using dots ). The ignored properties are
410
- // in most cases checked elsewhere (dtslint), and in some cases they are irrelevant.
409
+ // to it, ignoring some keys (JSON Patch paths ). The ignored properties are in most cases checked
410
+ // elsewhere (dtslint), and in some cases they are irrelevant.
411
411
function makeJsonCheckerFromCore ( requiredForm : any , ignoredKeys : string [ ] ) {
412
412
const diffFromReq = ( text : string ) => {
413
413
let json : any ;
414
414
try { json = JSON . parse ( text ) ; } catch ( e ) { return "couldn't parse json" ; }
415
- // allow dotted keys in ignoredKeys
416
- ignoredKeys . map ( k => k . split ( "." ) ) . forEach ( keys =>
417
- delete keys . slice ( 0 , - 1 ) . reduce ( ( a , b ) => a ?. [ b ] , json )
418
- ?. [ keys [ keys . length - 1 ] ] ) ;
415
+ jsonDiff . applyPatch ( json , ignoredKeys . map ( path => ( { op : "remove" , path } ) ) ) ;
419
416
try { return jsonDiff . compare ( requiredForm , json ) ; } catch ( e ) { return "couldn't diff json" } ;
420
417
} ;
421
418
return ( contents : string , oldText ?: string ) => {
0 commit comments