Skip to content

Commit 724811b

Browse files
committed
feat: add a new bun?: boolean option
1 parent ca17abb commit 724811b

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

.changeset/cuddly-kiwis-drum.md

-5
This file was deleted.

.changeset/lemon-trains-hang.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"eslint-import-resolver-typescript": minor
3+
---
4+
5+
feat: add a new `bun?: boolean` option for `bun` users - close #386
6+
7+
`process.versions.bun` is unavailable even with `bun eslint` due to its own design,
8+
but checking `bun` modules for non-bun users is incorrect behavior and just wasting time,
9+
so a new option is added for such case, you can still run with `bun --bun eslint` without this option enabled

src/index.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,13 @@ export const resolve = (
6060
resolver?: ResolverFactory | null,
6161
// eslint-disable-next-line sonarjs/cognitive-complexity
6262
): ResolvedResult => {
63+
options ||= {}
64+
6365
// don't worry about core node/bun modules
6466
if (
6567
module.isBuiltin(source) ||
66-
isBunModule(source, process.versions.bun as Version)
68+
((process.versions.bun || options.bun) &&
69+
isBunModule(source, (process.versions.bun ?? 'latest') as Version))
6770
) {
6871
log('matched core:', source)
6972

@@ -84,8 +87,6 @@ export const resolve = (
8487

8588
source = removeQuerystring(source)
8689

87-
options ||= {}
88-
8990
if (!resolver) {
9091
const optionsHash = stableHash(options)
9192
const cwd = process.cwd()

src/types.ts

+4
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,9 @@ export interface TypeScriptResolverOptions extends NapiResolveOptions {
66
* @default true - whether to always try to resolve `@types` packages
77
*/
88
alwaysTryTypes?: boolean
9+
/**
10+
* Whether `bun` core modules should be accounted
11+
*/
12+
bun?: boolean
913
noWarnOnMultipleProjects?: boolean
1014
}

0 commit comments

Comments
 (0)