Skip to content

chore: bump rspack-resolver for better P'n'P support #397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/gorgeous-wasps-happen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"eslint-import-resolver-typescript": patch
---

chore: bump `rspack-resolver` for better P'n'P support

Now `rspack-resolver` resolves `pnpapi` natively.
3 changes: 3 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ jobs:
with:
languages: ${{ matrix.language }}
queries: +security-and-quality
config: |
paths-ignore:
- tests/pnp/.pnp.*

- name: Autobuild
uses: github/codeql-action/autobuild@v3
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
.yarn/*
!.yarn/plugins
!.yarn/releases
coverage
lib
node_modules
*.log
Expand Down
4 changes: 1 addition & 3 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
.yarn
dist
lib
node_modules
/pnpm-lock.yaml
/tests/pnp/.pnp.*
**/*.svg
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"eslint": "ESLINT_USE_FLAT_CONFIG=false eslint",
"lint": "run-p 'lint:*'",
"lint:es": "eslint . --cache",
"lint:tsc": "tsc --noEmit",
"lint:tsc": "tsc -b --noEmit",
"prepare": "simple-git-hooks && yarn-berry-deduplicate || exit 0",
"release": "clean-pkg-json && changeset publish",
"test": "run-p 'test:*'",
Expand All @@ -54,6 +54,7 @@
"test:multipleEslintrcs": "yarn eslint --ext ts,tsx tests/multipleEslintrcs",
"test:multipleTsconfigs": "yarn eslint --ext ts,tsx tests/multipleTsconfigs",
"test:nearestTsconfig": "yarn eslint --ext ts,tsx tests/nearestTsconfig",
"test:unit": "vitest --run",
"test:withJsExtension": "node tests/withJsExtension/test.js && yarn eslint --ext ts,tsx tests/withJsExtension",
"test:withJsconfig": "yarn eslint --ext js tests/withJsconfig",
"test:withPaths": "yarn eslint --ext ts,tsx tests/withPaths",
Expand Down Expand Up @@ -82,7 +83,7 @@
"dependencies": {
"debug": "^4.4.0",
"get-tsconfig": "^4.10.0",
"rspack-resolver": "^1.2.0",
"rspack-resolver": "^1.2.2",
"stable-hash": "^0.0.5",
"tinyglobby": "^0.2.12"
},
Expand All @@ -98,21 +99,25 @@
"@types/node": "^22.13.10",
"@types/pnpapi": "^0.0.5",
"@types/unist": "^3.0.3",
"@vitest/coverage-v8": "3.0.9",
"clean-pkg-json": "^1.2.1",
"dummy.js": "link:dummy.js",
"eslint": "^9.22.0",
"eslint-import-resolver-typescript": "link:.",
"eslint-plugin-import-x": "^4.8.0",
"eslint-plugin-import-x": "^4.9.0",
"is-bun-module": "^1.3.0",
"lint-staged": "^15.5.0",
"npm-run-all2": "^7.0.2",
"path-serializer": "^0.3.4",
"prettier": "^3.5.3",
"react": "^19.0.0",
"simple-git-hooks": "^2.11.1",
"size-limit": "^11.2.0",
"size-limit-preset-node-lib": "^0.3.0",
"tinyexec": "^1.0.0",
"type-coverage": "^2.29.7",
"typescript": "~5.8.2",
"vitest": "^3.0.9",
"yarn-berry-deduplicate": "^6.1.1"
},
"resolutions": {
Expand Down
13 changes: 2 additions & 11 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import module from 'node:module'
import { isBuiltin } from 'node:module'
import path from 'node:path'

import type { ResolvedResult } from 'eslint-plugin-import-x/types.js'
Expand Down Expand Up @@ -63,20 +63,11 @@ export const resolve = (
options ||= {}

// don't worry about node/bun core modules
if (module.isBuiltin(source) || (options.bun && isBunBuiltin(source))) {
if (isBuiltin(source) || (options.bun && isBunBuiltin(source))) {
log('matched core:', source)
return { found: true, path: null }
}

if (process.versions.pnp && source === 'pnpapi') {
return {
found: true,
path: module
.findPnpApi(file)
.resolveToUnqualified(source, file, { considerBuiltins: false }),
}
}

source = removeQuerystring(source)

if (!resolver) {
Expand Down
8 changes: 8 additions & 0 deletions tests/pnp/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
root=true

[*]
charset=utf-8
end_of_line=lf
indent_size=2
indent_style=space
insert_final_newline=true
4 changes: 4 additions & 0 deletions tests/pnp/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/.yarn/** linguist-vendored
/.yarn/releases/* binary
/.yarn/plugins/**/* binary
/.pnp.* binary linguist-generated
16 changes: 16 additions & 0 deletions tests/pnp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# Whether you use PnP or not, the node_modules folder is often used to store
# build artifacts that should be gitignored
node_modules

# Swap the comments on the following lines if you wish to use zero-installs
# In that case, don't forget to run `yarn config set enableGlobalCache false`!
# Documentation here: https://yarnpkg.com/features/caching#zero-installs

!.yarn/cache
Loading