Skip to content

Commit 1342127

Browse files
authored
docs: add more details about resolvers (#292)
1 parent f67e2b6 commit 1342127

File tree

14 files changed

+1659
-1477
lines changed

14 files changed

+1659
-1477
lines changed

.changeset/lucky-carpets-shine.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"eslint-plugin-import-x": patch
3+
---
4+
5+
refactor: remove unnecessary check for `pnpapi` because `unrs-resolver` already handles it

README.md

Lines changed: 47 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,24 @@ This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, a
2929
- [Configuration (legacy: `.eslintrc*`)](#configuration-legacy-eslintrc)
3030
- [TypeScript](#typescript)
3131
- [Configuration (new: `eslint.config.js`)](#configuration-new-eslintconfigjs)
32+
- [JS example](#js-example)
33+
- [Typescript example](#typescript-example)
3234
- [Resolvers](#resolvers)
35+
- [`import-x/resolver-next`](#import-xresolver-next)
36+
- [`import-x/resolver`](#import-xresolver)
3337
- [Settings](#settings)
3438
- [`import-x/extensions`](#import-xextensions)
3539
- [`import-x/ignore`](#import-xignore)
3640
- [`import-x/core-modules`](#import-xcore-modules)
3741
- [`import-x/external-module-folders`](#import-xexternal-module-folders)
3842
- [`import-x/parsers`](#import-xparsers)
39-
- [`import-x/resolver`](#import-xresolver)
43+
- [`import-x/resolver` and `import-x/resolver-next`](#import-xresolver-and-import-xresolver-next)
4044
- [`import-x/cache`](#import-xcache)
4145
- [`import-x/internal-regex`](#import-xinternal-regex)
4246
- [SublimeLinter-eslint](#sublimelinter-eslint)
43-
- [Sponsors](#sponsors)
44-
- [Backers](#backers)
47+
- [Sponsors and Backers](#sponsors-and-backers)
48+
- [Sponsors](#sponsors)
49+
- [Backers](#backers)
4550
- [Changelog](#changelog)
4651
- [License](#license)
4752

@@ -193,23 +198,16 @@ settings:
193198
From [`v8.21.0`](https://github.com/eslint/eslint/releases/tag/v8.21.0), ESLint announced a new config system.
194199
In the new system, `.eslintrc*` is no longer used. `eslint.config.js` would be the default config file name.
195200

196-
<details>
197-
<summary>JS example</summary>
201+
### JS example
198202

199203
```js
200204
import js from '@eslint/js'
201-
import eslintPluginImportX from 'eslint-plugin-import-x'
205+
import * as pluginImportX from 'eslint-plugin-import-x'
202206
203-
export default [
204-
js.configs.recommended,
205-
eslintPluginImportX.flatConfigs.recommended,
206-
]
207+
export default [js.configs.recommended, pluginImportX.flatConfigs.recommended]
207208
```
208209

209-
</details>
210-
211-
<details>
212-
<summary>Typescript example</summary>
210+
### Typescript example
213211

214212
You have to install `eslint-import-resolver-typescript`:
215213

@@ -219,13 +217,13 @@ npm install eslint-import-resolver-typescript --save-dev
219217

220218
```js
221219
import js from '@eslint/js'
222-
import eslintPluginImportX from 'eslint-plugin-import-x'
220+
import * as pluginImportX from 'eslint-plugin-import-x'
223221
import tsParser from '@typescript-eslint/parser'
224222
225223
export default [
226224
js.configs.recommended,
227-
eslintPluginImportX.flatConfigs.recommended,
228-
eslintPluginImportX.flatConfigs.typescript,
225+
pluginImportX.flatConfigs.recommended,
226+
pluginImportX.flatConfigs.typescript,
229227
{
230228
files: ['**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}'],
231229
ignores: ['eslint.config.js'],
@@ -243,10 +241,6 @@ export default [
243241
]
244242
```
245243

246-
</details>
247-
248-
---
249-
250244
> [!NOTE]
251245
> A complete list of available configuration can be found in [config/flat folders](src/config/flat)
252246

@@ -273,6 +267,32 @@ You can reference resolvers in several ways (in order of precedence):
273267

274268
- as a conventional `eslint-import-resolver` name, like `eslint-import-resolver-foo`:
275269

270+
### `import-x/resolver-next`
271+
272+
> [!warning]
273+
>
274+
> Only available in the new flat config system. If you are using the legacy config system, please use `import-x/resolver` instead.
275+
276+
```js
277+
// eslint.config.js
278+
279+
import { createTypeScriptResolver } from 'eslint-import-resolver-typescript'
280+
import { createNodeResolver } from 'eslint-plugin-import-x'
281+
282+
export default [
283+
{
284+
settings: {
285+
'import/resolver-next': [
286+
createTypeScriptResolver(/* Your override options go here */),
287+
createNodeResolver(/* Your override options go here */),
288+
],
289+
},
290+
},
291+
]
292+
```
293+
294+
### `import-x/resolver`
295+
276296
```yaml
277297
# .eslintrc.yml
278298
settings:
@@ -501,7 +521,7 @@ depending on how far down the rabbit hole goes. Submit an issue if you find stra
501521
behavior beyond here, but steel your heart against the likely outcome of closing
502522
with `wontfix`.
503523

504-
### `import-x/resolver`
524+
### `import-x/resolver` and `import-x/resolver-next`
505525

506526
See [resolvers](#resolvers).
507527

@@ -617,15 +637,17 @@ In Package Settings / SublimeLinter / User Settings:
617637
I believe this defaults to `3`, so you may not need to alter it depending on your
618638
project folder max depth.
619639

620-
[![Sponsors](https://raw.githubusercontent.com/1stG/static/master/sponsors.svg)](https://github.com/sponsors/JounQin)
640+
## Sponsors and Backers
641+
642+
[![Sponsors and Backers](https://raw.githubusercontent.com/1stG/static/master/sponsors.svg)](https://github.com/sponsors/JounQin)
621643

622-
## Sponsors
644+
### Sponsors
623645

624646
| 1stG | RxTS | UnTS |
625647
| ---------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
626648
| [![1stG Open Collective sponsors](https://opencollective.com/1stG/organizations.svg)](https://opencollective.com/1stG) | [![RxTS Open Collective sponsors](https://opencollective.com/rxts/organizations.svg)](https://opencollective.com/rxts) | [![UnTS Open Collective sponsors](https://opencollective.com/unts/organizations.svg)](https://opencollective.com/unts) |
627649

628-
## Backers
650+
### Backers
629651

630652
| 1stG | RxTS | UnTS |
631653
| ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |

package.json

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"description": "Import with sanity.",
66
"repository": "https://github.com/un-ts/eslint-plugin-import-x",
77
"author": "JounQin <[email protected]> (https://www.1stG.me)",
8+
"funding": "https://opencollective.com/eslint-plugin-import-x",
89
"license": "MIT",
910
"packageManager": "[email protected]",
1011
"engines": {
@@ -70,9 +71,9 @@
7071
"eslint": "^8.57.0 || ^9.0.0"
7172
},
7273
"dependencies": {
73-
"@pkgr/core": "^0.2.1",
74+
"@pkgr/core": "^0.2.2",
7475
"@types/doctrine": "^0.0.9",
75-
"@typescript-eslint/utils": "^8.29.0",
76+
"@typescript-eslint/utils": "^8.29.1",
7677
"debug": "^4.4.0",
7778
"doctrine": "^3.0.0",
7879
"eslint-import-resolver-node": "^0.3.9",
@@ -82,7 +83,7 @@
8283
"semver": "^7.7.1",
8384
"stable-hash": "^0.0.5",
8485
"tslib": "^2.8.1",
85-
"unrs-resolver": "^1.4.1"
86+
"unrs-resolver": "^1.5.0"
8687
},
8788
"devDependencies": {
8889
"@1stg/commitlint-config": "^5.0.4",
@@ -108,8 +109,8 @@
108109
"@eslint/js": "^9.24.0",
109110
"@pkgr/rollup": "^6.0.2",
110111
"@swc-node/jest": "^1.8.13",
111-
"@swc/core": "^1.11.16",
112-
"@swc/helpers": "^0.5.15",
112+
"@swc/core": "^1.11.20",
113+
"@swc/helpers": "^0.5.17",
113114
"@test-scope/some-module": "link:./test/fixtures/symlinked-module",
114115
"@total-typescript/ts-reset": "^0.6.1",
115116
"@types/debug": "^4.1.12",
@@ -119,17 +120,17 @@
119120
"@types/jest": "^29.5.14",
120121
"@types/json-schema": "^7.0.15",
121122
"@types/klaw-sync": "^6.0.5",
122-
"@types/node": "^22.14.0",
123+
"@types/node": "^22.14.1",
123124
"@types/pnpapi": "^0.0.5",
124-
"@typescript-eslint/eslint-plugin": "^8.29.0",
125-
"@typescript-eslint/parser": "^8.29.0",
126-
"@typescript-eslint/rule-tester": "^8.29.0",
125+
"@typescript-eslint/eslint-plugin": "^8.29.1",
126+
"@typescript-eslint/parser": "^8.29.1",
127+
"@typescript-eslint/rule-tester": "^8.29.1",
127128
"@unts/patch-package": "^8.1.1",
128129
"clean-pkg-json": "^1.2.1",
129130
"eslint": "^9.24.0",
130-
"eslint-config-prettier": "^10.1.1",
131+
"eslint-config-prettier": "^10.1.2",
131132
"eslint-doc-generator": "^2.1.2",
132-
"eslint-import-resolver-typescript": "^4.3.1",
133+
"eslint-import-resolver-typescript": "^4.3.2",
133134
"eslint-import-resolver-webpack": "^0.13.10",
134135
"eslint-import-test-order-redirect": "link:./test/fixtures/order-redirect",
135136
"eslint-plugin-eslint-plugin": "^6.4.0",
@@ -147,7 +148,7 @@
147148
"hermes-eslint": "^0.28.0",
148149
"jest": "^30.0.0-alpha.7",
149150
"klaw-sync": "^7.0.0",
150-
"lint-staged": "^15.5.0",
151+
"lint-staged": "^15.5.1",
151152
"npm-run-all2": "^7.0.2",
152153
"path-serializer": "^0.3.4",
153154
"prettier": "^3.5.3",
@@ -158,7 +159,7 @@
158159
"ts-node": "^10.9.2",
159160
"type-fest": "^4.39.1",
160161
"typescript": "^5.8.3",
161-
"typescript-eslint": "^8.29.0",
162+
"typescript-eslint": "^8.29.1",
162163
"yarn-berry-deduplicate": "^6.1.1",
163164
"zod": "^3.24.2"
164165
},

0 commit comments

Comments
 (0)