File tree 5 files changed +20
-2
lines changed
5 files changed +20
-2
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " eslint-import-resolver-typescript " : patch
3
+ ---
4
+
5
+ fix: resolve modules if folder contains a package.json file
Original file line number Diff line number Diff line change @@ -250,6 +250,10 @@ const isFile = (path?: string | undefined): path is string => {
250
250
}
251
251
}
252
252
253
+ const isModule = ( modulePath ?: string | undefined ) : modulePath is string => {
254
+ return ! ! modulePath && isFile ( path . resolve ( modulePath , 'package.json' ) )
255
+ }
256
+
253
257
/**
254
258
* @param {string } source the module to resolve; i.e './some-module'
255
259
* @param {string } file the importing file's full path; i.e. '/usr/local/bin/file.js'
@@ -267,7 +271,7 @@ function getMappedPath(
267
271
const originalExtensions = extensions
268
272
extensions = [ '' , ...extensions ]
269
273
270
- let paths : string [ ] | undefined = [ ]
274
+ let paths : Array < string | undefined > | undefined = [ ]
271
275
272
276
if ( RELATIVE_PATH_PATTERN . test ( source ) ) {
273
277
const resolved = path . resolve ( path . dirname ( file ) , source )
@@ -283,7 +287,7 @@ function getMappedPath(
283
287
] ) ,
284
288
)
285
289
. flat ( 2 )
286
- . filter ( isFile )
290
+ . filter ( mappedPath => isFile ( mappedPath ) || isModule ( mappedPath ) )
287
291
}
288
292
289
293
if ( retry && paths . length === 0 ) {
Original file line number Diff line number Diff line change @@ -10,6 +10,9 @@ import 'folder/tsxImportee'
10
10
import 'folder/subfolder/tsImportee'
11
11
import 'folder/subfolder/tsxImportee'
12
12
13
+ // import module with typings set in package.json
14
+ import 'folder/module'
15
+
13
16
// import from node_module
14
17
import 'typescript'
15
18
import 'dummy.js'
Original file line number Diff line number Diff line change
1
+ export { }
Original file line number Diff line number Diff line change
1
+ {
2
+ "type" : " commonjs" ,
3
+ "typings" : " ./module.d.ts" ,
4
+ "private" : true
5
+ }
You can’t perform that action at this time.
0 commit comments