Skip to content

Commit 71ca774

Browse files
authored
fix(types): incorrect and unfinished NodeResolverOptions typing (#15)
1 parent ec4b277 commit 71ca774

File tree

4 files changed

+47
-6
lines changed

4 files changed

+47
-6
lines changed

.changeset/swift-carrots-heal.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"eslint-import-context": patch
3+
---
4+
5+
fix(types): incorrect and unfinished `NodeResolverOptions` typing

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
"yarn-berry-deduplicate": "^6.1.3"
101101
},
102102
"resolutions": {
103+
"eslint-import-context": "link:.",
103104
"prettier": "^3.5.3"
104105
},
105106
"typeCoverage": {

src/types.ts

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,45 @@ export type Resolver = LegacyResolver | NewResolver
3737

3838
export type ResolvedResult = ResultFound | ResultNotFound
3939

40-
export interface NodeResolverOptions {
41-
extensions?: readonly string[]
42-
moduleDirectory?: string[]
43-
paths?: string[]
40+
// based on https://github.com/DefinitelyTyped/DefinitelyTyped/blob/157f2565d64cbc03165a2284bf0e5176af18d991/types/resolve/index.d.ts#L93-L122
41+
export interface NodeResolverOptions
42+
extends Omit<NapiResolveOptions, 'extensions'> {
43+
/** Directory to begin resolving from (defaults to __dirname) */
44+
basedir?: string
45+
/** Set to false to exclude node core modules (e.g. fs) from the search */
46+
includeCoreModules?: boolean
47+
/** Array of file extensions to search in order (defaults to ['.js']) */
48+
extensions?: string | readonly string[]
49+
/**
50+
* Require.paths array to use if nothing is found on the normal node_modules
51+
* recursive walk (probably don't use this)
52+
*/
53+
paths?: string | readonly string[]
54+
/**
55+
* Directory (or directories) in which to recursively look for modules.
56+
* (default to 'node_modules')
57+
*/
58+
moduleDirectory?: string | readonly string[]
59+
/**
60+
* If true, doesn't resolve `basedir` to real path before resolving. This is
61+
* the way Node resolves dependencies when executed with the
62+
* --preserve-symlinks flag.
63+
*
64+
* Note: this property is currently true by default but it will be changed to
65+
* false in the next major version because Node's resolution algorithm does
66+
* not preserve symlinks by default.
67+
*/
68+
preserveSymlinks?: boolean
69+
70+
// The following options are not supported anymore, but kept for compatibility
71+
/** @deprecated */
72+
package?: unknown
73+
/** @deprecated */
74+
packageFilter?: unknown
75+
/** @deprecated */
76+
pathFilter?: unknown
77+
/** @deprecated */
78+
packageIterator?: unknown
4479
}
4580

4681
export interface WebpackResolverOptions {
@@ -126,7 +161,7 @@ export interface LegacyResolverRecord {
126161
[resolve: string]: unknown
127162
node?: NodeResolverOptions | boolean
128163
typescript?: TsResolverOptions | boolean
129-
webpack?: WebpackResolverOptions
164+
webpack?: WebpackResolverOptions | boolean
130165
}
131166

132167
export type LegacyImportResolver =

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7323,7 +7323,7 @@ __metadata:
73237323
languageName: node
73247324
linkType: soft
73257325

7326-
"eslint-import-context@npm:^0.1.3, eslint-import-context@npm:^0.1.4, eslint-import-context@workspace:.":
7326+
"eslint-import-context@workspace:.":
73277327
version: 0.0.0-use.local
73287328
resolution: "eslint-import-context@workspace:."
73297329
dependencies:

0 commit comments

Comments
 (0)