Skip to content

Commit db3ec78

Browse files
committed
chore: update README
1 parent 92dfc66 commit db3ec78

File tree

1 file changed

+107
-1
lines changed

1 file changed

+107
-1
lines changed

README.md

Lines changed: 107 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,109 @@
11
# eslint-import-resolver-typescript-bun
22

3-
This plugin simply adds workarounds to [eslint-import-resolver-typescript](https://www.npmjs.com/package/eslint-import-resolver-typescript) when resolving [Bun](https://bun.sh/)'s modules.
3+
[![GitHub Actions](https://github.com/opsbr/eslint-import-resolver-typescript-bun/workflows/release/badge.svg)](https://github.com/import-js/eslint-import-resolver-typescript/actions/workflows/ci.yml)
4+
[![npm](https://img.shields.io/npm/v/eslint-import-resolver-typescript-bun.svg)](https://www.npmjs.com/package/eslint-import-resolver-typescript-bun)
5+
[![GitHub Release](https://img.shields.io/github/release/opsbr/eslint-import-resolver-typescript-bun)](https://github.com/opsbr/eslint-import-resolver-typescript-bun/releases)
6+
7+
[![Conventional Commits](https://img.shields.io/badge/conventional%20commits-1.0.0-yellow.svg)](https://conventionalcommits.org)
8+
[![projen](https://img.shields.io/badge/maintained%20with-projen-ED9C50.svg)](https://github.com/projen/projen)
9+
10+
This plugin simply adds workarounds to [`eslint-import-resolver-typescript`](https://www.npmjs.com/package/eslint-import-resolver-typescript) when resolving [Bun](https://bun.sh/)'s modules.
11+
12+
You can use [`eslint-plugin-import`](https://www.npmjs.com/package/eslint-plugin-import) on your Bun project directly with this resolver!
13+
14+
## How it works
15+
16+
This resolver reads [`bun-types`](https://www.npmjs.com/package/bun-types) and list all Bun modules defined there. Currently, we assume all Bun modules start with `bun` e.g. `bun`, `bun:test`, etc.
17+
18+
Then, when resolving, if the requested module is one of the Bun modules detected above, the resolver returns `{ found: true, path: null }`. Otherwise, it delegates to `eslint-import-resolver-typescript`.
19+
20+
## Installation
21+
22+
```shell
23+
# npm
24+
npm i -D eslint-plugin-import eslint-import-resolver-typescript-bun
25+
26+
# pnpm
27+
pnpm i -D eslint-plugin-import eslint-import-resolver-typescript-bun
28+
29+
# yarn
30+
yarn add -D eslint-plugin-import eslint-import-resolver-typescript-bun
31+
```
32+
33+
## Configuration
34+
35+
All configurations are passed to `eslint-import-resolver-typescript`. Simply replace your resolver name from `typescript` to `typescript-bun`!
36+
37+
```javascript
38+
module.exports = {
39+
extends: ["plugin:import/recommended", "plugin:import/typescript"],
40+
parser: "@typescript-eslint/parser",
41+
parserOptions: {
42+
project: true,
43+
},
44+
plugins: ["@typescript-eslint"],
45+
root: true,
46+
settings: {
47+
"import/parsers": {
48+
"@typescript-eslint/parser": [".ts", ".tsx"],
49+
},
50+
"import/resolver": {
51+
"typescript-bun": {
52+
// <= HERE!
53+
project: true,
54+
alwaysTryTypes: true,
55+
},
56+
},
57+
},
58+
rules: {
59+
"import/order": [
60+
"warn",
61+
{
62+
groups: ["builtin", "external"],
63+
alphabetize: {
64+
order: "asc",
65+
caseInsensitive: true,
66+
},
67+
},
68+
],
69+
},
70+
};
71+
```
72+
73+
See `eslint-import-resolver-typescript` configuration [here](https://github.com/import-js/eslint-import-resolver-typescript/tree/master#configuration).
74+
75+
## Debug
76+
77+
Use `DEBUG` environment variable provided by [`debug`](https://www.npmjs.com/package/debug):
78+
79+
```
80+
$ DEBUG=eslint-import-resolver-typescript\* bun x eslint src/index.ts
81+
eslint-import-resolver-typescript looking for: bun-types +0ms
82+
eslint-import-resolver-typescript matched node path: /workspaces/asideline/node_modules/bun-types/types.d.ts +101ms
83+
eslint-import-resolver-typescript-bun found bun modules: Set(5) { 'bun', 'bun:test', 'bun:sqlite', 'bun:jsc', 'bun:ffi' } +0ms
84+
eslint-import-resolver-typescript-bun matched bun modules: bun:test +2ms
85+
```
86+
87+
## Development
88+
89+
This project uses [Projen](https://github.com/projen/projen) and [Yarn 1](https://yarnpkg.com/).
90+
91+
```shell
92+
git clone https://github.com/opsbr/eslint-import-resolver-typescript-bun.git
93+
cd eslint-import-resolver-typescript-bun
94+
yarn install
95+
yarn build
96+
```
97+
98+
## Acknowledgement
99+
100+
- [`eslint-import-resolver-typescript`](https://www.npmjs.com/package/eslint-import-resolver-typescript)
101+
- [`bun-types`](https://www.npmjs.com/package/bun-types)
102+
103+
## Author
104+
105+
[OpsBR Software Technology Inc.](https://opsbr.com/)
106+
107+
## License
108+
109+
[Apache-2.0](https://github.com/opsbr/eslint-import-resolver-typescript-bun/blob/main/LICENSE)

0 commit comments

Comments
 (0)