@@ -7,6 +7,7 @@ const CONTENTS = {
77 foo : 'console.log("foo")' ,
88 bar : 'console.log("bar")' ,
99 'baz/bar' : 'console.log("baz bar")' ,
10+ 'bat/baz/bar' : 'console.log("bat/baz/bar")' ,
1011} ;
1112
1213const tmpDirs = new Set < tmp . DirResult > ( ) ;
@@ -22,7 +23,7 @@ afterEach(() => {
2223function writeTSConfig ( dirName : string , config : Record < string , unknown > ) : void {
2324 fs . writeFileSync ( path . join ( dirName , 'tsconfig.json' ) , JSON . stringify ( config ) ) ;
2425}
25- function writeFile ( dirName : string , file : 'foo' | 'bar' | 'baz/bar' ) : void {
26+ function writeFile ( dirName : string , file : keyof typeof CONTENTS ) : void {
2627 fs . writeFileSync ( path . join ( dirName , 'src' , `${ file } .ts` ) , CONTENTS [ file ] ) ;
2728}
2829function renameFile ( dirName : string , src : 'bar' , dest : 'baz/bar' ) : void {
@@ -53,7 +54,7 @@ function setup(tsconfig: Record<string, unknown>, writeBar = true): string {
5354 return tmpDir . name ;
5455}
5556
56- function parseFile ( filename : 'foo' | 'bar' | 'baz/bar' , tmpDir : string ) : void {
57+ function parseFile ( filename : keyof typeof CONTENTS , tmpDir : string ) : void {
5758 parseAndGenerateServices ( CONTENTS . foo , {
5859 project : './tsconfig.json' ,
5960 tsconfigRootDir : tmpDir ,
@@ -112,6 +113,24 @@ function baseTests(
112113 expect ( ( ) => parseFile ( bazSlashBar , PROJECT_DIR ) ) . not . toThrow ( ) ;
113114 } ) ;
114115
116+ it ( 'allows parsing of deeply nested new files in new folder' , ( ) => {
117+ const PROJECT_DIR = setup ( tsConfigIncludeAll ) ;
118+
119+ expect ( ( ) => parseFile ( 'foo' , PROJECT_DIR ) ) . not . toThrow ( ) ;
120+
121+ // Create deep folder structure after first parse (this is important step)
122+ // context: https://github.com/typescript-eslint/typescript-eslint/issues/1394
123+ fs . mkdirSync ( path . join ( PROJECT_DIR , 'src' , 'bat' ) ) ;
124+ fs . mkdirSync ( path . join ( PROJECT_DIR , 'src' , 'bat' , 'baz' ) ) ;
125+
126+ const bazSlashBar = path . join ( 'bat' , 'baz' , 'bar' ) as 'bat/baz/bar' ;
127+
128+ // write a new file and attempt to parse it
129+ writeFile ( PROJECT_DIR , bazSlashBar ) ;
130+
131+ expect ( ( ) => parseFile ( bazSlashBar , PROJECT_DIR ) ) . not . toThrow ( ) ;
132+ } ) ;
133+
115134 it ( 'allows renaming of files' , ( ) => {
116135 const PROJECT_DIR = setup ( tsConfigIncludeAll , true ) ;
117136 const bazSlashBar = path . join ( 'baz' , 'bar' ) as 'baz/bar' ;
0 commit comments