Skip to content

Commit b8cd1bd

Browse files
docs: improve documentation
Fixed the overall punctuation, the typos, and the structure of a few sentences. Also, added installation commands with Bun.
1 parent ff0445f commit b8cd1bd

File tree

1 file changed

+52
-46
lines changed

1 file changed

+52
-46
lines changed

README.md

Lines changed: 52 additions & 46 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,74 +50,80 @@ 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

5959
### `eslint-plugin-import-x`
6060

6161
```sh
62-
# npm
62+
# NPM
6363
npm i -D eslint-plugin-import-x eslint-import-resolver-typescript
6464

65-
# pnpm
65+
# PNPM
6666
pnpm i -D eslint-plugin-import-x eslint-import-resolver-typescript
6767

68-
# yarn
68+
# 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`
7376

7477
```sh
75-
# npm
78+
# NPM
7679
npm i -D eslint-plugin-import eslint-import-resolver-typescript
7780

78-
# pnpm
81+
# PNPM
7982
pnpm i -D eslint-plugin-import eslint-import-resolver-typescript
8083

81-
# yarn
84+
# 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
93-
import { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript'
98+
// eslint.config.js (CommonJS is also supported.)
99+
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

104-
// Choose from one of the "project" configs below or omit to use <root>/tsconfig.json or <root>/jsconfig.json by default
110+
// 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

145-
// Choose from one of the "project" configs below or omit to use <root>/tsconfig.json or <root>/jsconfig.json by default
151+
// 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

194-
// Choose from one of the "project" configs below or omit to use <root>/tsconfig.json or <root>/jsconfig.json by default
200+
// 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

@@ -260,7 +266,7 @@ Default:
260266

261267
```jsonc
262268
[
263-
// `.mts`, `.cts`, `.d.mts`, `.d.cts`, `.mjs`, `.cjs` are not included because `.cjs` and `.mjs` must be used explicitly
269+
// `.mts`, `.cts`, `.d.mts`, `.d.cts`, `.mjs`, `.cjs` are not included because `.cjs` and `.mjs` must be used explicitly.
264270
".ts",
265271
".tsx",
266272
".d.ts",
@@ -279,7 +285,7 @@ Default:
279285
{
280286
".js": [
281287
".ts",
282-
// `.tsx` can also be compiled as `.js`
288+
// `.tsx` can also be compiled as `.js`.
283289
".tsx",
284290
".d.ts",
285291
".js",
@@ -290,7 +296,7 @@ Default:
290296
".tsx",
291297
".d.ts",
292298
".jsx",
293-
// `.tsx` can also be compiled as `.js`
299+
// `.tsx` can also be compiled as `.js`.
294300
".js",
295301
],
296302
".cjs": [".cts", ".d.cts", ".cjs"],
@@ -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)