@@ -7,6 +7,7 @@ const CONTENTS = {
7
7
foo : 'console.log("foo")' ,
8
8
bar : 'console.log("bar")' ,
9
9
'baz/bar' : 'console.log("baz bar")' ,
10
+ 'bat/baz/bar' : 'console.log("bat/baz/bar")' ,
10
11
} ;
11
12
12
13
const tmpDirs = new Set < tmp . DirResult > ( ) ;
@@ -22,7 +23,7 @@ afterEach(() => {
22
23
function writeTSConfig ( dirName : string , config : Record < string , unknown > ) : void {
23
24
fs . writeFileSync ( path . join ( dirName , 'tsconfig.json' ) , JSON . stringify ( config ) ) ;
24
25
}
25
- function writeFile ( dirName : string , file : 'foo' | 'bar' | 'baz/bar' ) : void {
26
+ function writeFile ( dirName : string , file : keyof typeof CONTENTS ) : void {
26
27
fs . writeFileSync ( path . join ( dirName , 'src' , `${ file } .ts` ) , CONTENTS [ file ] ) ;
27
28
}
28
29
function renameFile ( dirName : string , src : 'bar' , dest : 'baz/bar' ) : void {
@@ -53,7 +54,7 @@ function setup(tsconfig: Record<string, unknown>, writeBar = true): string {
53
54
return tmpDir . name ;
54
55
}
55
56
56
- function parseFile ( filename : 'foo' | 'bar' | 'baz/bar' , tmpDir : string ) : void {
57
+ function parseFile ( filename : keyof typeof CONTENTS , tmpDir : string ) : void {
57
58
parseAndGenerateServices ( CONTENTS . foo , {
58
59
project : './tsconfig.json' ,
59
60
tsconfigRootDir : tmpDir ,
@@ -112,6 +113,24 @@ function baseTests(
112
113
expect ( ( ) => parseFile ( bazSlashBar , PROJECT_DIR ) ) . not . toThrow ( ) ;
113
114
} ) ;
114
115
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
+
115
134
it ( 'allows renaming of files' , ( ) => {
116
135
const PROJECT_DIR = setup ( tsConfigIncludeAll , true ) ;
117
136
const bazSlashBar = path . join ( 'baz' , 'bar' ) as 'baz/bar' ;
0 commit comments