@@ -2,20 +2,25 @@ import path from 'node:path'
2
2
3
3
import { exec } from 'tinyexec'
4
4
5
- import { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript'
5
+ import {
6
+ createTypeScriptImportResolver ,
7
+ TSCONFIG_NOT_FOUND_REGEXP ,
8
+ } from 'eslint-import-resolver-typescript'
6
9
7
10
describe ( 'createTypeScriptImportResolver' , async ( ) => {
8
- const pnpDir = path . resolve ( import . meta. dirname , 'pnp' )
11
+ const { dirname } = import . meta
12
+
13
+ const pnpDir = path . resolve ( dirname , 'pnp' )
9
14
10
15
await exec ( 'yarn' , [ ] , {
11
16
nodeOptions : {
12
17
cwd : pnpDir ,
13
18
} ,
14
19
} )
15
20
16
- const resolver = createTypeScriptImportResolver ( )
17
-
18
21
it ( 'should work with pnp' , async ( ) => {
22
+ const resolver = createTypeScriptImportResolver ( )
23
+
19
24
const testfile = path . resolve ( pnpDir , '__test__.js' )
20
25
21
26
expect ( resolver . resolve ( 'pnpapi' , testfile ) ) . toMatchInlineSnapshot ( `
@@ -32,4 +37,16 @@ describe('createTypeScriptImportResolver', async () => {
32
37
}
33
38
` )
34
39
} )
40
+
41
+ it ( 'should error on malformed tsconfig reference' , ( ) => {
42
+ const project = path . resolve ( dirname , 'malformed-reference' )
43
+
44
+ const resolver = createTypeScriptImportResolver ( { project } )
45
+
46
+ const testfile = path . resolve ( project , '__test__.js' )
47
+
48
+ expect ( ( ) => resolver . resolve ( 'index.js' , testfile ) ) . toThrowError (
49
+ TSCONFIG_NOT_FOUND_REGEXP ,
50
+ )
51
+ } )
35
52
} )
0 commit comments