From 35a00870ff33630497b63b8e653153f577de523a Mon Sep 17 00:00:00 2001 From: JounQin Date: Wed, 14 May 2025 23:57:20 +0800 Subject: [PATCH 1/6] docs: add `why` section on the top to clarify close #196 --- .nano-staged.js | 2 +- README.md | 38 ++++++++++++++++++++++++++++++++++++++ package.json | 2 +- yarn.lock | 30 +++++++++++++++--------------- 4 files changed, 55 insertions(+), 17 deletions(-) diff --git a/.nano-staged.js b/.nano-staged.js index d996fafa..958df410 100644 --- a/.nano-staged.js +++ b/.nano-staged.js @@ -1 +1 @@ -export { default } from '@1stg/lint-staged/tsc' +export { default } from '@1stg/nano-staged/tsc' diff --git a/README.md b/README.md index a70a34dc..30bc4dc4 100644 --- a/README.md +++ b/README.md @@ -14,12 +14,16 @@ 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. +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, and cleaner dependencies altogether. + [`eslint-plugin-i` is now `eslint-plugin-import-x`](https://github.com/un-ts/eslint-plugin-import-x/issues/24#issuecomment-1991605123) **IF YOU ARE USING THIS WITH SUBLIME**: see the [bottom section](#sublimelinter-eslint) for important info. ## TOC +- [Why](#why) +- [Differences](#differences) - [Installation](#installation) - [Configuration (legacy: `.eslintrc*`)](#configuration-legacy-eslintrc) - [TypeScript](#typescript) @@ -50,6 +54,34 @@ This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, a - [Changelog](#changelog) - [License](#license) +## Why + +Because a lot of issues can not be fixed easily without API changes, see + +- +- +- + +But [`eslint-plugin-import`] refused to accept BREAKING CHANGES for these issues, so we have to fork it. + +And then [`eslint-plugin-import`] claimed to be allowed to update with BREAKING CHANGES at , +but it still doesn't happen or even seems to happen: . + +We haven't resolved all the issues yet, but we are working on it which could happen in the next major version (v5): . + +## Differences + +So what's the differences from `eslint-plugin-import` exactly? + +- 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) +- we don't depend on old and outdated dependencies, so we have short dependency depths, see also +- `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 +- `eslint-plugin-import` uses [`resolve`] which doesn't support `exports` field in `package.json` while we use [`unrs-resolver`] instead, which is a [napi-rs] project so it's much faster +- 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 box +- ... + +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. + ## Installation ```sh @@ -662,13 +694,19 @@ Detailed changes for each release are documented in [CHANGELOG.md](./CHANGELOG.m [MIT][] © [JounQin][]@[1stG.me][] [`@typescript-eslint/parser`]: https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser +[`eslint-plugin-import`]: https://github.com/import-js/eslint-plugin-import [`eslint-import-resolver-typescript`]: https://github.com/import-js/eslint-import-resolver-typescript [`eslint_d`]: https://www.npmjs.com/package/eslint_d [`eslint-loader`]: https://www.npmjs.com/package/eslint-loader +[`get-tsconfig`]: https://github.com/privatenumber/get-tsconfig +[`tsconfig-paths`]: https://github.com/dividab/tsconfig-paths +[`typescript`]: https://github.com/microsoft/TypeScript +[`unrs-resolver`]: https://github.com/unrs/unrs-resolver [`resolve`]: https://www.npmjs.com/package/resolve [`externals`]: https://webpack.github.io/docs/library-and-externals.html [1stG.me]: https://www.1stG.me [JounQin]: https://github.com/JounQin [MIT]: http://opensource.org/licenses/MIT +[napi-rs]: https://github.com/napi-rs/napi-rs [node]: https://www.npmjs.com/package/eslint-import-resolver-node [webpack]: https://www.npmjs.com/package/eslint-import-resolver-webpack diff --git a/package.json b/package.json index 5bf87385..7347befe 100644 --- a/package.json +++ b/package.json @@ -85,7 +85,7 @@ }, "devDependencies": { "@1stg/commitlint-config": "^5.0.6", - "@1stg/lint-staged": "^4.0.9", + "@1stg/nano-staged": "^0.1.1", "@1stg/prettier-config": "^5.1.4", "@1stg/remark-preset": "^3.1.1", "@1stg/simple-git-hooks": "^2.0.1", diff --git a/yarn.lock b/yarn.lock index 46163320..61473b6f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -16,31 +16,31 @@ __metadata: languageName: node linkType: hard -"@1stg/config@npm:^1.0.4, @1stg/config@npm:^1.0.5": +"@1stg/config@npm:^1.0.5": version: 1.0.5 resolution: "@1stg/config@npm:1.0.5" checksum: 10c0/f7e4d638f45ea458fc80763ad26402f4606fd2cf37edb282777ab804b1c8abea866185e8287328754675261dc0bcd741d55a88338844bbf79ddc476dbe9b9503 languageName: node linkType: hard -"@1stg/lint-staged@npm:^4.0.9": - version: 4.0.9 - resolution: "@1stg/lint-staged@npm:4.0.9" +"@1stg/nano-staged@npm:^0.1.1": + version: 0.1.1 + resolution: "@1stg/nano-staged@npm:0.1.1" dependencies: - "@1stg/config": "npm:^1.0.4" - "@1stg/prettier-config": "npm:^5.0.1" - "@1stg/tsconfig": "npm:^3.0.2" + "@1stg/config": "npm:^1.0.5" + "@1stg/prettier-config": "npm:^5.1.1" + "@1stg/tsconfig": "npm:^3.0.3" "@pkgr/core": "npm:^0.2.2" prettier: "npm:^3.5.3" peerDependencies: - lint-staged: ">=12.1.0" - checksum: 10c0/bc576e1b9e8f0fe260f9b3d00b631baa3e74088c41f03936be7028e549fcc57f0210fc8bdd69e574935653e4315fbc91e3e579776ccd0af95448b7ab15780b87 + nano-staged: ">=0.8.0" + checksum: 10c0/3e0652c36c06e5c14836bf2329eb0da9d8cf6e9bb1a59ef4bc27fb85672eea685936d1b9d997ec56c3673e5458ee8cfaf34a79be701798c29b48b542bb0b0dc0 languageName: node linkType: hard -"@1stg/prettier-config@npm:^5.0.1, @1stg/prettier-config@npm:^5.1.4": - version: 5.1.4 - resolution: "@1stg/prettier-config@npm:5.1.4" +"@1stg/prettier-config@npm:^5.1.1, @1stg/prettier-config@npm:^5.1.4": + version: 5.2.0 + resolution: "@1stg/prettier-config@npm:5.2.0" dependencies: "@1stg/config": "npm:^1.0.5" "@prettier/plugin-pug": "npm:^3.3.0" @@ -57,7 +57,7 @@ __metadata: prettier-plugin-toml: "npm:^2.0.4" peerDependencies: prettier: ^3.0.0 - checksum: 10c0/7950dca3881be0604eff57191b34a0f7efc0377b756225ba7ec969c81ef5cf5db2183d574679c4a1d9224e5597e110d5e78f476aab768e15d434b1c5509bbc3b + checksum: 10c0/a9879a9a0a84aac41d6896009f109ca03f2544e836bc388df3c581a45c4b47e2369b2104eaf35f3bff9d22fef6f2c6bb0f9941f1381b89f5ad0388e805cec028 languageName: node linkType: hard @@ -94,7 +94,7 @@ __metadata: languageName: node linkType: hard -"@1stg/tsconfig@npm:^3.0.2, @1stg/tsconfig@npm:^3.0.3": +"@1stg/tsconfig@npm:^3.0.3": version: 3.0.3 resolution: "@1stg/tsconfig@npm:3.0.3" peerDependencies: @@ -6346,7 +6346,7 @@ __metadata: resolution: "eslint-plugin-import-x@workspace:." dependencies: "@1stg/commitlint-config": "npm:^5.0.6" - "@1stg/lint-staged": "npm:^4.0.9" + "@1stg/nano-staged": "npm:^0.1.1" "@1stg/prettier-config": "npm:^5.1.4" "@1stg/remark-preset": "npm:^3.1.1" "@1stg/simple-git-hooks": "npm:^2.0.1" From 0d2833ac98f380de138b7ac9d687201e07a1e43f Mon Sep 17 00:00:00 2001 From: JounQin Date: Thu, 15 May 2025 08:16:27 +0800 Subject: [PATCH 2/6] docs: add the proof link of `heavy dependency on Typescript` --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 30bc4dc4..c6d4b5ab 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ 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. -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, and cleaner dependencies altogether. +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. [`eslint-plugin-i` is now `eslint-plugin-import-x`](https://github.com/un-ts/eslint-plugin-import-x/issues/24#issuecomment-1991605123) From ae2c47304c1be24bb37c3470179b75e3bab25ebf Mon Sep 17 00:00:00 2001 From: JounQin Date: Thu, 15 May 2025 11:14:38 +0800 Subject: [PATCH 3/6] Apply suggestions from code review Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> --- README.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index c6d4b5ab..39afdde8 100644 --- a/README.md +++ b/README.md @@ -56,22 +56,21 @@ It started as a fork of [`eslint-plugin-import`] using [`get-tsconfig`] to repla ## Why -Because a lot of issues can not be fixed easily without API changes, see +A lot of issues can not be fixed easily without API changes. E.g. see: - - - -But [`eslint-plugin-import`] refused to accept BREAKING CHANGES for these issues, so we have to fork it. +[`eslint-plugin-import`] refused to accept BREAKING CHANGES for these issues, so we had to fork it. -And then [`eslint-plugin-import`] claimed to be allowed to update with BREAKING CHANGES at , -but it still doesn't happen or even seems to happen: . +[`eslint-plugin-import`] now claims in that it will accept BREAKING CHANGES. However, still nothing is happening: . We haven't resolved all the issues yet, but we are working on it which could happen in the next major version (v5): . ## Differences -So what's the differences from `eslint-plugin-import` exactly? +So what are the differences from `eslint-plugin-import` exactly? - 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) - we don't depend on old and outdated dependencies, so we have short dependency depths, see also From 2db56e5a66324138ed988ecb76f9bb871fddd127 Mon Sep 17 00:00:00 2001 From: JounQin Date: Thu, 15 May 2025 11:38:05 +0800 Subject: [PATCH 4/6] Apply suggestions from code review Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 39afdde8..67dcd926 100644 --- a/README.md +++ b/README.md @@ -73,13 +73,13 @@ We haven't resolved all the issues yet, but we are working on it which could hap So what are the differences from `eslint-plugin-import` exactly? - 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) -- we don't depend on old and outdated dependencies, so we have short dependency depths, see also +- 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) - `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 -- `eslint-plugin-import` uses [`resolve`] which doesn't support `exports` field in `package.json` while we use [`unrs-resolver`] instead, which is a [napi-rs] project so it's much faster -- 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 box +- `eslint-plugin-import` uses [`resolve`] which doesn't support the `exports` field in `package.json` while we use [`unrs-resolver`] instead, which does support it and is a [`napi-rs`] project so is also much faster +- 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 - ... -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. +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. ## Installation From 360a34bbfc8988af112fd7cf2e6b2ac2c3cbc4e9 Mon Sep 17 00:00:00 2001 From: JounQin Date: Thu, 15 May 2025 11:52:00 +0800 Subject: [PATCH 5/6] chore: let's make AI happy --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 67dcd926..1c24c9dd 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ It started as a fork of [`eslint-plugin-import`] using [`get-tsconfig`] to repla ## Why -A lot of issues can not be fixed easily without API changes. E.g. see: +Many issues cannot be fixed easily without API changes. For example, see: - - @@ -66,7 +66,7 @@ A lot of issues can not be fixed easily without API changes. E.g. see: [`eslint-plugin-import`] now claims in that it will accept BREAKING CHANGES. However, still nothing is happening: . -We haven't resolved all the issues yet, but we are working on it which could happen in the next major version (v5): . +We haven't resolved all the issues yet, but we are working on them, which could happen in the next major version (v5): . ## Differences @@ -698,6 +698,7 @@ Detailed changes for each release are documented in [CHANGELOG.md](./CHANGELOG.m [`eslint_d`]: https://www.npmjs.com/package/eslint_d [`eslint-loader`]: https://www.npmjs.com/package/eslint-loader [`get-tsconfig`]: https://github.com/privatenumber/get-tsconfig +[`napi-rs`]: https://github.com/napi-rs/napi-rs [`tsconfig-paths`]: https://github.com/dividab/tsconfig-paths [`typescript`]: https://github.com/microsoft/TypeScript [`unrs-resolver`]: https://github.com/unrs/unrs-resolver @@ -706,6 +707,5 @@ Detailed changes for each release are documented in [CHANGELOG.md](./CHANGELOG.m [1stG.me]: https://www.1stG.me [JounQin]: https://github.com/JounQin [MIT]: http://opensource.org/licenses/MIT -[napi-rs]: https://github.com/napi-rs/napi-rs [node]: https://www.npmjs.com/package/eslint-import-resolver-node [webpack]: https://www.npmjs.com/package/eslint-import-resolver-webpack From f74abd60b7a35905ea7ffae4b29e1cb8bb22856e Mon Sep 17 00:00:00 2001 From: JounQin Date: Thu, 15 May 2025 16:19:48 +0800 Subject: [PATCH 6/6] Apply suggestions from code review Co-authored-by: Sukka --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1c24c9dd..33a47279 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,8 @@ Many issues cannot be fixed easily without API changes. For example, see: [`eslint-plugin-import`] now claims in that it will accept BREAKING CHANGES. However, still nothing is happening: . +[`eslint-plugin-import`] refuses to support the `exports` feature, and the maintainer even locked the feature request issue to prevent future discussion. In the meantime, `eslint-plugin-import-x` now provides first-party support for the `exports` feature , which will become the default in the next major version (v5). + We haven't resolved all the issues yet, but we are working on them, which could happen in the next major version (v5): . ## Differences @@ -75,7 +77,7 @@ So what are the differences from `eslint-plugin-import` exactly? - 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) - 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) - `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 -- `eslint-plugin-import` uses [`resolve`] which doesn't support the `exports` field in `package.json` while we use [`unrs-resolver`] instead, which does support it and is a [`napi-rs`] project so is also much faster +- `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. - 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 - ...