@@ -11,7 +11,9 @@ import isGlob from 'is-glob'
11
11
import { isCore , sync } from 'resolve'
12
12
import debug from 'debug'
13
13
14
- const log = debug ( 'eslint-import-resolver-typescript' )
14
+ const IMPORTER_NAME = 'eslint-import-resolver-typescript'
15
+
16
+ const log = debug ( IMPORTER_NAME )
15
17
16
18
const defaultExtensions = [ '.ts' , '.tsx' , '.d.ts' ] . concat (
17
19
// eslint-disable-next-line node/no-deprecated-api
@@ -23,14 +25,19 @@ export const interfaceVersion = 2
23
25
24
26
export interface TsResolverOptions {
25
27
alwaysTryTypes ?: boolean
28
+ /**
29
+ * @deprecated use `project` instead
30
+ */
26
31
directory ?: string | string [ ]
32
+ project ?: string | string [ ]
27
33
extensions ?: string [ ]
28
34
packageFilter ?: ( pkg : Record < string , string > ) => Record < string , string >
29
35
}
30
36
31
37
/**
32
38
* @param {string } source the module to resolve; i.e './some-module'
33
39
* @param {string } file the importing file's full path; i.e. '/usr/local/bin/file.js'
40
+ * @param {TsResolverOptions } options
34
41
*/
35
42
export function resolve (
36
43
source : string ,
@@ -140,17 +147,24 @@ function initMappers(options: TsResolverOptions) {
140
147
return
141
148
}
142
149
143
- const isArrayOfStrings = ( array ?: string | string [ ] ) =>
144
- Array . isArray ( array ) && array . every ( o => typeof o === 'string' )
150
+ if ( options . directory ) {
151
+ console . warn (
152
+ `[${ IMPORTER_NAME } ]: option \`directory\` is deprecated, please use \`project\` instead` ,
153
+ )
154
+
155
+ if ( ! options . project ) {
156
+ options . project = options . directory
157
+ }
158
+ }
145
159
146
160
const configPaths =
147
- typeof options . directory === 'string'
148
- ? [ options . directory ]
149
- : isArrayOfStrings ( options . directory )
150
- ? options . directory
161
+ typeof options . project === 'string'
162
+ ? [ options . project ]
163
+ : Array . isArray ( options . project )
164
+ ? options . project
151
165
: [ process . cwd ( ) ]
152
166
153
- mappers = configPaths !
167
+ mappers = configPaths
154
168
// turn glob patterns into paths
155
169
. reduce < string [ ] > (
156
170
( paths , path ) => paths . concat ( isGlob ( path ) ? globSync ( path ) : path ) ,
0 commit comments