@@ -11,7 +11,9 @@ import isGlob from 'is-glob'
1111import { isCore , sync } from 'resolve'
1212import debug from 'debug'
1313
14- const log = debug ( 'eslint-import-resolver-typescript' )
14+ const IMPORTER_NAME = 'eslint-import-resolver-typescript'
15+
16+ const log = debug ( IMPORTER_NAME )
1517
1618const defaultExtensions = [ '.ts' , '.tsx' , '.d.ts' ] . concat (
1719 // eslint-disable-next-line node/no-deprecated-api
@@ -23,14 +25,19 @@ export const interfaceVersion = 2
2325
2426export interface TsResolverOptions {
2527 alwaysTryTypes ?: boolean
28+ /**
29+ * @deprecated use `project` instead
30+ */
2631 directory ?: string | string [ ]
32+ project ?: string | string [ ]
2733 extensions ?: string [ ]
2834 packageFilter ?: ( pkg : Record < string , string > ) => Record < string , string >
2935}
3036
3137/**
3238 * @param {string } source the module to resolve; i.e './some-module'
3339 * @param {string } file the importing file's full path; i.e. '/usr/local/bin/file.js'
40+ * @param {TsResolverOptions } options
3441 */
3542export function resolve (
3643 source : string ,
@@ -140,17 +147,24 @@ function initMappers(options: TsResolverOptions) {
140147 return
141148 }
142149
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+ }
145159
146160 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
151165 : [ process . cwd ( ) ]
152166
153- mappers = configPaths !
167+ mappers = configPaths
154168 // turn glob patterns into paths
155169 . reduce < string [ ] > (
156170 ( paths , path ) => paths . concat ( isGlob ( path ) ? globSync ( path ) : path ) ,
0 commit comments