@@ -2,20 +2,25 @@ import path from 'node:path'
22
33import { exec } from 'tinyexec'
44
5- import { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript'
5+ import {
6+ createTypeScriptImportResolver ,
7+ TSCONFIG_NOT_FOUND_REGEXP ,
8+ } from 'eslint-import-resolver-typescript'
69
710describe ( 'createTypeScriptImportResolver' , async ( ) => {
8- const pnpDir = path . resolve ( import . meta. dirname , 'pnp' )
11+ const { dirname } = import . meta
12+
13+ const pnpDir = path . resolve ( dirname , 'pnp' )
914
1015 await exec ( 'yarn' , [ ] , {
1116 nodeOptions : {
1217 cwd : pnpDir ,
1318 } ,
1419 } )
1520
16- const resolver = createTypeScriptImportResolver ( )
17-
1821 it ( 'should work with pnp' , async ( ) => {
22+ const resolver = createTypeScriptImportResolver ( )
23+
1924 const testfile = path . resolve ( pnpDir , '__test__.js' )
2025
2126 expect ( resolver . resolve ( 'pnpapi' , testfile ) ) . toMatchInlineSnapshot ( `
@@ -32,4 +37,16 @@ describe('createTypeScriptImportResolver', async () => {
3237 }
3338 ` )
3439 } )
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+ } )
3552} )
0 commit comments