@@ -586,159 +586,6 @@ test('mergeWithFileConfig: tsx files', async t => {
586586} ) ;
587587} ) ;
588588
589- test ( 'mergeWithFileConfigs: nested configs with prettier' , async t => {
590- const cwd = path . resolve ( 'fixtures' , 'nested-configs' ) ;
591- const paths = [
592- 'no-semicolon.js' ,
593- 'child/semicolon.js' ,
594- 'child-override/two-spaces.js' ,
595- 'child-override/child-prettier-override/semicolon.js' ,
596- ] . map ( file => path . resolve ( cwd , file ) ) ;
597- const result = await manager . mergeWithFileConfigs ( paths , { cwd} , [
598- {
599- filepath : path . resolve ( cwd , 'child-override' , 'child-prettier-override' , 'package.json' ) ,
600- config : { overrides : [ { files : 'semicolon.js' , prettier : true } ] } ,
601- } ,
602- { filepath : path . resolve ( cwd , 'package.json' ) , config : { semicolon : true } } ,
603- {
604- filepath : path . resolve ( cwd , 'child-override' , 'package.json' ) ,
605- config : { overrides : [ { files : 'two-spaces.js' , space : 4 } ] } ,
606- } ,
607- { filepath : path . resolve ( cwd , 'child' , 'package.json' ) , config : { semicolon : false } } ,
608- ] ) ;
609-
610- t . deepEqual ( result , [
611- {
612- files : [ path . resolve ( cwd , 'no-semicolon.js' ) ] ,
613- options : {
614- semicolon : true ,
615- cwd,
616- extensions : DEFAULT_EXTENSION ,
617- ignores : DEFAULT_IGNORES ,
618- } ,
619- prettierOptions : { } ,
620- } ,
621- {
622- files : [ path . resolve ( cwd , 'child/semicolon.js' ) ] ,
623- options : {
624- semicolon : false ,
625- cwd : path . resolve ( cwd , 'child' ) ,
626- extensions : DEFAULT_EXTENSION ,
627- ignores : DEFAULT_IGNORES ,
628- } ,
629- prettierOptions : { } ,
630- } ,
631- {
632- files : [ path . resolve ( cwd , 'child-override/two-spaces.js' ) ] ,
633- options : {
634- space : 4 ,
635- rules : { } ,
636- settings : { } ,
637- globals : [ ] ,
638- envs : [ ] ,
639- plugins : [ ] ,
640- extends : [ ] ,
641- cwd : path . resolve ( cwd , 'child-override' ) ,
642- extensions : DEFAULT_EXTENSION ,
643- ignores : DEFAULT_IGNORES ,
644- } ,
645- prettierOptions : { } ,
646- } ,
647- {
648- files : [ path . resolve ( cwd , 'child-override/child-prettier-override/semicolon.js' ) ] ,
649- options : {
650- prettier : true ,
651- rules : { } ,
652- settings : { } ,
653- globals : [ ] ,
654- envs : [ ] ,
655- plugins : [ ] ,
656- extends : [ ] ,
657- cwd : path . resolve ( cwd , 'child-override' , 'child-prettier-override' ) ,
658- extensions : DEFAULT_EXTENSION ,
659- ignores : DEFAULT_IGNORES ,
660- } ,
661- prettierOptions : { endOfLine : 'lf' , semi : false , useTabs : true } ,
662- } ,
663- ] ) ;
664- } ) ;
665-
666- test ( 'mergeWithFileConfigs: typescript files' , async t => {
667- const cwd = path . resolve ( 'fixtures' , 'typescript' ) ;
668- const paths = [ 'two-spaces.tsx' , 'child/extra-semicolon.ts' , 'child/sub-child/four-spaces.ts' ] . map ( file => path . resolve ( cwd , file ) ) ;
669- const configFiles = [
670- { filepath : path . resolve ( cwd , 'child/sub-child/package.json' ) , config : { space : 2 } } ,
671- { filepath : path . resolve ( cwd , 'package.json' ) , config : { space : 4 } } ,
672- { filepath : path . resolve ( cwd , 'child/package.json' ) , config : { semicolon : false } } ,
673- ] ;
674- const result = await manager . mergeWithFileConfigs ( paths , { cwd} , configFiles ) ;
675-
676- t . deepEqual ( omit ( result [ 0 ] , 'options.tsConfigPath' ) , {
677- files : [ path . resolve ( cwd , 'two-spaces.tsx' ) ] ,
678- options : {
679- space : 4 ,
680- cwd,
681- extensions : DEFAULT_EXTENSION ,
682- ignores : DEFAULT_IGNORES ,
683- ts : true ,
684- } ,
685- prettierOptions : { } ,
686- } ) ;
687- t . deepEqual ( await readJson ( result [ 0 ] . options . tsConfigPath ) , {
688- files : [ path . resolve ( cwd , 'two-spaces.tsx' ) ] ,
689- compilerOptions : {
690- newLine : 'lf' ,
691- noFallthroughCasesInSwitch : true ,
692- noImplicitReturns : true ,
693- noUnusedLocals : true ,
694- noUnusedParameters : true ,
695- strict : true ,
696- target : 'es2018' ,
697- } ,
698- } ) ;
699-
700- t . deepEqual ( omit ( result [ 1 ] , 'options.tsConfigPath' ) , {
701- files : [ path . resolve ( cwd , 'child/extra-semicolon.ts' ) ] ,
702- options : {
703- semicolon : false ,
704- cwd : path . resolve ( cwd , 'child' ) ,
705- extensions : DEFAULT_EXTENSION ,
706- ignores : DEFAULT_IGNORES ,
707- ts : true ,
708- } ,
709- prettierOptions : { } ,
710- } ) ;
711-
712- t . deepEqual ( omit ( result [ 2 ] , 'options.tsConfigPath' ) , {
713- files : [ path . resolve ( cwd , 'child/sub-child/four-spaces.ts' ) ] ,
714- options : {
715- space : 2 ,
716- cwd : path . resolve ( cwd , 'child/sub-child' ) ,
717- extensions : DEFAULT_EXTENSION ,
718- ignores : DEFAULT_IGNORES ,
719- ts : true ,
720- } ,
721- prettierOptions : { } ,
722- } ) ;
723-
724- // Verify that we use the same temporary tsconfig.json for both files group sharing the same original tsconfig.json even if they have different xo config
725- t . is ( result [ 1 ] . options . tsConfigPath , result [ 2 ] . options . tsConfigPath ) ;
726- t . deepEqual ( await readJson ( result [ 1 ] . options . tsConfigPath ) , {
727- extends : path . resolve ( cwd , 'child/tsconfig.json' ) ,
728- files : [ path . resolve ( cwd , 'child/extra-semicolon.ts' ) , path . resolve ( cwd , 'child/sub-child/four-spaces.ts' ) ] ,
729- include : [
730- slash ( path . resolve ( cwd , 'child/**/*.ts' ) ) ,
731- slash ( path . resolve ( cwd , 'child/**/*.tsx' ) ) ,
732- ] ,
733- } ) ;
734-
735- const secondResult = await manager . mergeWithFileConfigs ( paths , { cwd} , configFiles ) ;
736-
737- // Verify that on each run the options.tsConfigPath is consistent to preserve ESLint cache
738- t . is ( result [ 0 ] . options . tsConfigPath , secondResult [ 0 ] . options . tsConfigPath ) ;
739- t . is ( result [ 1 ] . options . tsConfigPath , secondResult [ 1 ] . options . tsConfigPath ) ;
740- } ) ;
741-
742589test ( 'applyOverrides' , t => {
743590t . deepEqual (
744591manager . applyOverrides (
0 commit comments