Skip to content

Commit de7bae3

Browse files
JounQinbenmccannSukkaW
authored
docs: add why section on the top to clarify (#323)
Co-authored-by: Ben McCann <[email protected]> Co-authored-by: Sukka <[email protected]>
1 parent 8b2d6d3 commit de7bae3

File tree

4 files changed

+56
-17
lines changed

4 files changed

+56
-17
lines changed

.nano-staged.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { default } from '@1stg/lint-staged/tsc'
1+
export { default } from '@1stg/nano-staged/tsc'

README.md

+39
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,16 @@
1414

1515
This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, and prevent issues with misspelling of file paths and import names. All the goodness that the ES2015+ static module syntax intends to provide, marked up in your editor.
1616

17+
It started as a fork of [`eslint-plugin-import`] using [`get-tsconfig`] to replace [`tsconfig-paths`] and heavy [`typescript`] under the hood, making it faster, through less [heavy dependency on Typescript](https://github.com/import-js/eslint-plugin-import/blob/da5f6ec13160cb288338db0c2a00c34b2d932f0d/src/exportMap/typescript.js#L16), and cleaner dependencies altogether.
18+
1719
[`eslint-plugin-i` is now `eslint-plugin-import-x`](https://github.com/un-ts/eslint-plugin-import-x/issues/24#issuecomment-1991605123)
1820

1921
**IF YOU ARE USING THIS WITH SUBLIME**: see the [bottom section](#sublimelinter-eslint) for important info.
2022

2123
## TOC <!-- omit in toc -->
2224

25+
- [Why](#why)
26+
- [Differences](#differences)
2327
- [Installation](#installation)
2428
- [Configuration (legacy: `.eslintrc*`)](#configuration-legacy-eslintrc)
2529
- [TypeScript](#typescript)
@@ -50,6 +54,35 @@ This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, a
5054
- [Changelog](#changelog)
5155
- [License](#license)
5256

57+
## Why
58+
59+
Many issues cannot be fixed easily without API changes. For example, see:
60+
61+
- <https://github.com/import-js/eslint-plugin-import/issues/1479>
62+
- <https://github.com/import-js/eslint-plugin-import/issues/2108>
63+
- <https://github.com/import-js/eslint-plugin-import/issues/2111>
64+
65+
[`eslint-plugin-import`] refused to accept BREAKING CHANGES for these issues, so we had to fork it.
66+
67+
[`eslint-plugin-import`] now claims in <https://github.com/un-ts/eslint-plugin-import-x/issues/170> that it will accept BREAKING CHANGES. However, still nothing is happening: <https://github.com/import-js/eslint-plugin-import/pull/3091>.
68+
69+
[`eslint-plugin-import`] refuses to support the `exports` feature, and the maintainer even locked the feature request issue <https://github.com/import-js/eslint-plugin-import/issues/1810> to prevent future discussion. In the meantime, `eslint-plugin-import-x` now provides first-party support for the `exports` feature <https://github.com/un-ts/eslint-plugin-import-x/pull/209>, which will become the default in the next major version (v5).
70+
71+
We haven't resolved all the issues yet, but we are working on them, which could happen in the next major version (v5): <https://github.com/un-ts/eslint-plugin-import-x/issues/235>.
72+
73+
## Differences
74+
75+
So what are the differences from `eslint-plugin-import` exactly?
76+
77+
- we target [Node `^18.18.0 || ^20.9.0 || >=21.1.0`](https://github.com/un-ts/eslint-plugin-import-x/blob/8b2d6d3b612eb57fb68c3fddec25b02fc622df7c/package.json#L12) + [ESLint `^8.57.0 || ^9.0.0`](https://github.com/un-ts/eslint-plugin-import-x/blob/8b2d6d3b612eb57fb68c3fddec25b02fc622df7c/package.json#L71), while `eslint-plugin-import` targets [Node `>=4`](https://github.com/import-js/eslint-plugin-import/blob/da5f6ec13160cb288338db0c2a00c34b2d932f0d/package.json#L6) and [ESLint `^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8 || ^9`](https://github.com/import-js/eslint-plugin-import/blob/da5f6ec13160cb288338db0c2a00c34b2d932f0d/package.json#L115C16-L115C64)
78+
- we don't depend on old and outdated dependencies, so [we have 49 dependencies](https://npmgraph.js.org/?q=eslint-plugin-import-x) compared to [117 dependencies for `eslint-plugin-import`](https://npmgraph.js.org/?q=eslint-plugin-import)
79+
- `eslint-plugin-import` uses `tsconfig-paths` + `typescript` itself to load `tsconfig`s while we use the single `get-tsconfig` instead, which is much faster and cleaner
80+
- `eslint-plugin-import` uses [`resolve`] which doesn't support the `exports` field in `package.json` while we build our own rust-based resolver [`unrs-resolver`] instead, which is feature-rich and way more performant.
81+
- Our [v3 resolver](./resolvers/README.md#v3) interface shares a single `resolver` instance by default which is used all across resolving chains so it would benefit from caching and memoization out-of-the-box
82+
- ...
83+
84+
The list could be longer in the future, but we don't want to make it too long here. Hope you enjoy and let's get started.
85+
5386
## Installation
5487

5588
```sh
@@ -662,9 +695,15 @@ Detailed changes for each release are documented in [CHANGELOG.md](./CHANGELOG.m
662695
[MIT][] © [JounQin][]@[1stG.me][]
663696

664697
[`@typescript-eslint/parser`]: https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser
698+
[`eslint-plugin-import`]: https://github.com/import-js/eslint-plugin-import
665699
[`eslint-import-resolver-typescript`]: https://github.com/import-js/eslint-import-resolver-typescript
666700
[`eslint_d`]: https://www.npmjs.com/package/eslint_d
667701
[`eslint-loader`]: https://www.npmjs.com/package/eslint-loader
702+
[`get-tsconfig`]: https://github.com/privatenumber/get-tsconfig
703+
[`napi-rs`]: https://github.com/napi-rs/napi-rs
704+
[`tsconfig-paths`]: https://github.com/dividab/tsconfig-paths
705+
[`typescript`]: https://github.com/microsoft/TypeScript
706+
[`unrs-resolver`]: https://github.com/unrs/unrs-resolver
668707
[`resolve`]: https://www.npmjs.com/package/resolve
669708
[`externals`]: https://webpack.github.io/docs/library-and-externals.html
670709
[1stG.me]: https://www.1stG.me

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
},
8686
"devDependencies": {
8787
"@1stg/commitlint-config": "^5.0.6",
88-
"@1stg/lint-staged": "^4.0.9",
88+
"@1stg/nano-staged": "^0.1.1",
8989
"@1stg/prettier-config": "^5.1.4",
9090
"@1stg/remark-preset": "^3.1.1",
9191
"@1stg/simple-git-hooks": "^2.0.1",

yarn.lock

+15-15
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,31 @@ __metadata:
1616
languageName: node
1717
linkType: hard
1818

19-
"@1stg/config@npm:^1.0.4, @1stg/config@npm:^1.0.5":
19+
"@1stg/config@npm:^1.0.5":
2020
version: 1.0.5
2121
resolution: "@1stg/config@npm:1.0.5"
2222
checksum: 10c0/f7e4d638f45ea458fc80763ad26402f4606fd2cf37edb282777ab804b1c8abea866185e8287328754675261dc0bcd741d55a88338844bbf79ddc476dbe9b9503
2323
languageName: node
2424
linkType: hard
2525

26-
"@1stg/lint-staged@npm:^4.0.9":
27-
version: 4.0.9
28-
resolution: "@1stg/lint-staged@npm:4.0.9"
26+
"@1stg/nano-staged@npm:^0.1.1":
27+
version: 0.1.1
28+
resolution: "@1stg/nano-staged@npm:0.1.1"
2929
dependencies:
30-
"@1stg/config": "npm:^1.0.4"
31-
"@1stg/prettier-config": "npm:^5.0.1"
32-
"@1stg/tsconfig": "npm:^3.0.2"
30+
"@1stg/config": "npm:^1.0.5"
31+
"@1stg/prettier-config": "npm:^5.1.1"
32+
"@1stg/tsconfig": "npm:^3.0.3"
3333
"@pkgr/core": "npm:^0.2.2"
3434
prettier: "npm:^3.5.3"
3535
peerDependencies:
36-
lint-staged: ">=12.1.0"
37-
checksum: 10c0/bc576e1b9e8f0fe260f9b3d00b631baa3e74088c41f03936be7028e549fcc57f0210fc8bdd69e574935653e4315fbc91e3e579776ccd0af95448b7ab15780b87
36+
nano-staged: ">=0.8.0"
37+
checksum: 10c0/3e0652c36c06e5c14836bf2329eb0da9d8cf6e9bb1a59ef4bc27fb85672eea685936d1b9d997ec56c3673e5458ee8cfaf34a79be701798c29b48b542bb0b0dc0
3838
languageName: node
3939
linkType: hard
4040

41-
"@1stg/prettier-config@npm:^5.0.1, @1stg/prettier-config@npm:^5.1.4":
42-
version: 5.1.4
43-
resolution: "@1stg/prettier-config@npm:5.1.4"
41+
"@1stg/prettier-config@npm:^5.1.1, @1stg/prettier-config@npm:^5.1.4":
42+
version: 5.2.0
43+
resolution: "@1stg/prettier-config@npm:5.2.0"
4444
dependencies:
4545
"@1stg/config": "npm:^1.0.5"
4646
"@prettier/plugin-pug": "npm:^3.3.0"
@@ -57,7 +57,7 @@ __metadata:
5757
prettier-plugin-toml: "npm:^2.0.4"
5858
peerDependencies:
5959
prettier: ^3.0.0
60-
checksum: 10c0/7950dca3881be0604eff57191b34a0f7efc0377b756225ba7ec969c81ef5cf5db2183d574679c4a1d9224e5597e110d5e78f476aab768e15d434b1c5509bbc3b
60+
checksum: 10c0/a9879a9a0a84aac41d6896009f109ca03f2544e836bc388df3c581a45c4b47e2369b2104eaf35f3bff9d22fef6f2c6bb0f9941f1381b89f5ad0388e805cec028
6161
languageName: node
6262
linkType: hard
6363

@@ -94,7 +94,7 @@ __metadata:
9494
languageName: node
9595
linkType: hard
9696

97-
"@1stg/tsconfig@npm:^3.0.2, @1stg/tsconfig@npm:^3.0.3":
97+
"@1stg/tsconfig@npm:^3.0.3":
9898
version: 3.0.3
9999
resolution: "@1stg/tsconfig@npm:3.0.3"
100100
peerDependencies:
@@ -6346,7 +6346,7 @@ __metadata:
63466346
resolution: "eslint-plugin-import-x@workspace:."
63476347
dependencies:
63486348
"@1stg/commitlint-config": "npm:^5.0.6"
6349-
"@1stg/lint-staged": "npm:^4.0.9"
6349+
"@1stg/nano-staged": "npm:^0.1.1"
63506350
"@1stg/prettier-config": "npm:^5.1.4"
63516351
"@1stg/remark-preset": "npm:^3.1.1"
63526352
"@1stg/simple-git-hooks": "npm:^2.0.1"

0 commit comments

Comments
 (0)