Skip to content

Commit c06392f

Browse files
docs: improve the documentation (#464)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent ff0445f commit c06392f

File tree

1 file changed

+39
-33
lines changed

1 file changed

+39
-33
lines changed

README.md

Lines changed: 39 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
[![Code Style: Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
1313
[![changesets](https://img.shields.io/badge/maintained%20with-changesets-176de3.svg)](https://github.com/changesets/changesets)
1414

15-
This is a resolver for `eslint-plugin-import(-x)` plugin, not an ESLint plugin itself, it adds [`TypeScript`][] support to [`eslint-plugin-import`][] (Or maybe you want to try [`eslint-plugin-import-x`][] for faster speed)
15+
This is a resolver for `eslint-plugin-import(-x)` plugin, not an ESLint plugin itself, it adds [`TypeScript`][] support to [`eslint-plugin-import`][]. (Or maybe you want to try [`eslint-plugin-import-x`][] for faster speed)
1616

1717
This means you can:
1818

1919
- `import`/`require` files with extension `.cts`/`.mts`/`.ts`/`.tsx`/`.d.cts`/`.d.mts`/`.d.ts`
2020
- Use [`paths`](https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping) defined in `tsconfig.json`
2121
- Prefer resolving `@types/*` definitions over plain `.js`/`.jsx`
22-
- Multiple tsconfigs support just like normal
22+
- Multiple tsconfigs support, just like normal
2323
- `imports/exports` fields support in `package.json`
2424

2525
## TOC <!-- omit in toc -->
@@ -50,9 +50,9 @@ This means you can:
5050

5151
## Notice
5252

53-
After version 2.0.0, `.d.ts` will take higher priority then normal `.js`/`.jsx` files on resolving `node_modules` packages in favor of `@types/*` definitions or its own definition.
53+
After version 2.0.0, `.d.ts` will take higher priority than normal `.js`/`.jsx` files on resolving `node_modules` packages in favor of `@types/*` definitions or its own definition.
5454

55-
If you're facing some problems on rules `import/default` or `import/named` from [`eslint-plugin-import`][], do not post any issue here, because they are just working exactly as [expected](https://github.com/import-js/eslint-import-resolver-typescript/issues/31#issuecomment-539751607) on our sides, take [import-js/eslint-plugin-import#1525](https://github.com/import-js/eslint-plugin-import/issues/1525) as reference or post a new issue to [`eslint-plugin-import`][] instead.
55+
If you're facing some problems with rules `import/default` or `import/named` from [`eslint-plugin-import`][], do not post any issue here, because they are working exactly as [expected](https://github.com/import-js/eslint-import-resolver-typescript/issues/31#issuecomment-539751607) on our side. Take [import-js/eslint-plugin-import#1525](https://github.com/import-js/eslint-plugin-import/issues/1525) as reference or post a new issue on [`eslint-plugin-import`][] instead.
5656

5757
## Installation
5858

@@ -67,6 +67,9 @@ pnpm i -D eslint-plugin-import-x eslint-import-resolver-typescript
6767

6868
# yarn
6969
yarn add -D eslint-plugin-import-x eslint-import-resolver-typescript
70+
71+
# bun
72+
bun add -d eslint-plugin-import-x eslint-import-resolver-typescript
7073
```
7174

7275
### `eslint-plugin-import`
@@ -80,44 +83,47 @@ pnpm i -D eslint-plugin-import eslint-import-resolver-typescript
8083

8184
# yarn
8285
yarn add -D eslint-plugin-import eslint-import-resolver-typescript
86+
87+
# bun
88+
bun add -d eslint-plugin-import eslint-import-resolver-typescript
8389
```
8490

8591
## Configuration
8692

8793
### `eslint.config.js`
8894

89-
If you are using `eslint-plugin-import-x@>=4.5.0`, you can use import/require to reference `eslint-import-resolver-typescript` directly in your ESLint flat config:
95+
If you are using `eslint-plugin-import-x@>=4.5.0`, you can use `import`/`require` to reference `eslint-import-resolver-typescript` directly in your ESLint flat config:
9096

9197
```js
92-
// eslint.config.js, CommonJS is also supported
98+
// eslint.config.js (CommonJS is also supported)
9399
import { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript'
94100

95101
export default [
96102
{
97103
settings: {
98104
'import-x/resolver-next': [
99105
createTypeScriptImportResolver({
100-
alwaysTryTypes: true, // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
106+
alwaysTryTypes: true, // Always try to resolve types under `<root>@types` directory even if it doesn't contain any source code, like `@types/unist`
101107

102-
bun: true, // resolve Bun modules https://github.com/import-js/eslint-import-resolver-typescript#bun
108+
bun: true, // Resolve Bun modules (https://github.com/import-js/eslint-import-resolver-typescript#bun)
103109

104110
// Choose from one of the "project" configs below or omit to use <root>/tsconfig.json or <root>/jsconfig.json by default
105111

106-
// use <root>/path/to/folder/tsconfig.json or <root>/path/to/folder/jsconfig.json
112+
// Use <root>/path/to/folder/tsconfig.json or <root>/path/to/folder/jsconfig.json
107113
project: 'path/to/folder',
108114

109115
// Multiple tsconfigs/jsconfigs (Useful for monorepos, but discouraged in favor of `references` supported)
110116

111-
// use a glob pattern
117+
// Use a glob pattern
112118
project: 'packages/*/{ts,js}config.json',
113119

114-
// use an array
120+
// Use an array
115121
project: [
116122
'packages/module-a/tsconfig.json',
117123
'packages/module-b/jsconfig.json',
118124
],
119125

120-
// use an array of glob patterns
126+
// Use an array of glob patterns
121127
project: [
122128
'packages/*/tsconfig.json',
123129
'other-packages/*/jsconfig.json',
@@ -129,36 +135,36 @@ export default [
129135
]
130136
```
131137

132-
But if you are using `eslint-plugin-import` or the older version of `eslint-plugin-import-x`, you can't use require/import:
138+
But if you are using `eslint-plugin-import` or the older version of `eslint-plugin-import-x`, you can't use `require`/`import`:
133139

134140
```js
135-
// eslint.config.js, CommonJS is also supported
141+
// eslint.config.js (CommonJS is also supported)
136142
export default [
137143
{
138144
settings: {
139145
'import/resolver': {
140146
typescript: {
141-
alwaysTryTypes: true, // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
147+
alwaysTryTypes: true, // Always try to resolve types under `<root>@types` directory even if it doesn't contain any source code, like `@types/unist`
142148

143-
bun: true, // resolve Bun modules https://github.com/import-js/eslint-import-resolver-typescript#bun
149+
bun: true, // Resolve Bun modules (https://github.com/import-js/eslint-import-resolver-typescript#bun)
144150

145151
// Choose from one of the "project" configs below or omit to use <root>/tsconfig.json or <root>/jsconfig.json by default
146152

147-
// use <root>/path/to/folder/tsconfig.json or <root>/path/to/folder/jsconfig.json
153+
// Use <root>/path/to/folder/tsconfig.json or <root>/path/to/folder/jsconfig.json
148154
project: 'path/to/folder',
149155

150156
// Multiple tsconfigs/jsconfigs (Useful for monorepos, but discouraged in favor of `references` supported)
151157

152-
// use a glob pattern
158+
// Use a glob pattern
153159
project: 'packages/*/{ts,js}config.json',
154160

155-
// use an array
161+
// Use an array
156162
project: [
157163
'packages/module-a/tsconfig.json',
158164
'packages/module-b/jsconfig.json',
159165
],
160166

161-
// use an array of glob patterns
167+
// Use an array of glob patterns
162168
project: [
163169
'packages/*/tsconfig.json',
164170
'other-packages/*/jsconfig.json',
@@ -178,7 +184,7 @@ Add the following to your `.eslintrc` config:
178184
{
179185
"plugins": ["import"],
180186
"rules": {
181-
// turn on errors for missing imports
187+
// Turn on errors for missing imports
182188
"import/no-unresolved": "error",
183189
},
184190
"settings": {
@@ -187,27 +193,27 @@ Add the following to your `.eslintrc` config:
187193
},
188194
"import/resolver": {
189195
"typescript": {
190-
"alwaysTryTypes": true, // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
196+
"alwaysTryTypes": true, // Always try to resolve types under `<root>@types` directory even if it doesn't contain any source code, like `@types/unist`
191197

192-
"bun": true, // resolve Bun modules https://github.com/import-js/eslint-import-resolver-typescript#bun
198+
"bun": true, // Resolve Bun modules (https://github.com/import-js/eslint-import-resolver-typescript#bun)
193199

194200
// Choose from one of the "project" configs below or omit to use <root>/tsconfig.json or <root>/jsconfig.json by default
195201

196-
// use <root>/path/to/folder/tsconfig.json or <root>/path/to/folder/jsconfig.json
202+
// Use <root>/path/to/folder/tsconfig.json or <root>/path/to/folder/jsconfig.json
197203
"project": "path/to/folder",
198204

199205
// Multiple tsconfigs (Useful for monorepos, but discouraged in favor of `references` supported)
200206

201-
// use a glob pattern
207+
// Use a glob pattern
202208
"project": "packages/*/{ts,js}config.json",
203209

204-
// use an array
210+
// Use an array
205211
"project": [
206212
"packages/module-a/tsconfig.json",
207213
"packages/module-b/jsconfig.json",
208214
],
209215

210-
// use an array of glob patterns
216+
// Use an array of glob patterns
211217
"project": [
212218
"packages/*/tsconfig.json",
213219
"other-packages/*/jsconfig.json",
@@ -226,9 +232,9 @@ Add the following to your `.eslintrc` config:
226232

227233
Enable Bun built-in module resolution by choosing 1 out of these 3 options:
228234

229-
- Set the `bun: true` option, as shown in [Configuration](#configuration) above
230-
- Run ESLint with `bun --bun eslint`
231-
- [Configure `run.bun` in `bunfig.toml`](https://bun.sh/docs/runtime/bunfig#run-bun-auto-alias-node-to-bun)
235+
- Set the `bun: true` option, as shown in [Configuration](#configuration) above.
236+
- Run ESLint with `bun --bun eslint`.
237+
- [Configure `run.bun` in `bunfig.toml`](https://bun.sh/docs/runtime/bunfig#run-bun-auto-alias-node-to-bun).
232238

233239
## Options from [`unrs-resolver`][]
234240

@@ -324,11 +330,11 @@ Default:
324330

325331
### Other options
326332

327-
You can pass through other options of [`unrs-resolver`][] directly
333+
You can pass through other options of [`unrs-resolver`][] directly.
328334

329335
### Default options
330336

331-
You can reuse `defaultConditionNames`, `defaultExtensions`, `defaultExtensionAlias` and `defaultMainFields` by `require/import` them directly
337+
You can reuse `defaultConditionNames`, `defaultExtensions`, `defaultExtensionAlias`, and `defaultMainFields` by directly using `require`/`import`.
332338

333339
## Contributing
334340

@@ -337,7 +343,7 @@ You can reuse `defaultConditionNames`, `defaultExtensions`, `defaultExtensionAli
337343
- Make sure that `yarn lint` passes without conflicts.
338344
- Make sure your code changes match our [type-coverage](https://github.com/plantain-00/type-coverage) settings: `yarn type-coverage`.
339345

340-
We have [GitHub Actions](https://github.com/import-js/eslint-import-resolver-typescript/actions) which will run the above commands on your PRs.
346+
We have [GitHub Actions](https://github.com/import-js/eslint-import-resolver-typescript/actions), which will run the above commands on your PRs.
341347

342348
If either fails, we won't be able to merge your PR until it's fixed.
343349

0 commit comments

Comments
 (0)