-
-
Notifications
You must be signed in to change notification settings - Fork 324
feat: make knip understand yarn pnp #924
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
Changes from 3 commits
de7f35f
3a967e1
f17fe41
35b8e9b
0e9af11
e122144
05b9090
cbd32b5
5e2b43f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| enableGlobalCache: false |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import { dep } from '@sample-package/dep' | ||
|
|
||
| dep; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "ignore": ["**/.pnp.{cjs,mjs,js}", "**/.pnp.loader.{cjs,mjs,js}", "**/sample-packages/**"] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "name": "@fixtures/yarn-pnp-test", | ||
| "version": "1.0.0", | ||
| "main": "index.js", | ||
| "license": "MIT", | ||
| "packageManager": "[email protected]", | ||
| "dependencies": { | ||
| "@sample-package/dep": "./sample-packages/dep", | ||
| "@sample-package/peer": "./sample-packages/peer" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export const dep = 'dep'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "name": "@sample-package/dep", | ||
| "version": "0.0.0", | ||
| "main": "./index.js", | ||
| "peerDependencies": { | ||
| "@sample-package/peer": "*" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export const peer = 'peer'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "name": "@sample-package/peer", | ||
| "version": "0.0.0", | ||
| "main": "./index.js" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # This file is generated by running "yarn install" inside your project. | ||
| # Manual changes might be lost - proceed with caution! | ||
|
|
||
| __metadata: | ||
| version: 8 | ||
| cacheKey: 10c0 | ||
|
|
||
| "@fixtures/yarn-pnp-test@workspace:.": | ||
| version: 0.0.0-use.local | ||
| resolution: "@fixtures/yarn-pnp-test@workspace:." | ||
| dependencies: | ||
| "@sample-package/dep": ./sample-packages/dep | ||
| "@sample-package/peer": ./sample-packages/peer | ||
| languageName: unknown | ||
| linkType: soft | ||
|
|
||
| "@sample-package/dep@file:./sample-packages/dep::locator=%40fixtures%2Fyarn-pnp-test%40workspace%3A.": | ||
| version: 0.0.0 | ||
| resolution: "@sample-package/dep@file:./sample-packages/dep#./sample-packages/dep::hash=537a59&locator=%40fixtures%2Fyarn-pnp-test%40workspace%3A." | ||
| peerDependencies: | ||
| "@sample-package/peer": "*" | ||
| checksum: 10c0/e8bd21d44ae40880d3512bc09edededd1a98716da88727fba4983465d9b452bfebc48257239632ed41d34d75d5fed03183d7422c352e90554e95ebee82c2f83b | ||
| languageName: node | ||
| linkType: hard | ||
|
|
||
| "@sample-package/peer@file:./sample-packages/peer::locator=%40fixtures%2Fyarn-pnp-test%40workspace%3A.": | ||
| version: 0.0.0 | ||
| resolution: "@sample-package/peer@file:./sample-packages/peer#./sample-packages/peer::hash=3bb161&locator=%40fixtures%2Fyarn-pnp-test%40workspace%3A." | ||
| checksum: 10c0/ec625a2dd9ddeeccfb18550e0789ddb92c6b65d7e94514f3eb62a222b500297dc2d50aadc748d5e3067374bdf74e634dfa36cec258e334ca5ea19565f85b44e6 | ||
| languageName: node | ||
| linkType: hard |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import { test } from 'bun:test'; | ||
| import assert from 'node:assert/strict'; | ||
| import { main } from '../src/index.js'; | ||
| import { resolve } from '../src/util/path.js'; | ||
| import baseArguments from './helpers/baseArguments.js'; | ||
| import baseCounters from './helpers/baseCounters.js'; | ||
|
|
||
| const cwd = resolve('fixtures/yarn-pnp'); | ||
|
|
||
| test('Find unused dependencies', async () => { | ||
| const { counters } = await main({ | ||
| ...baseArguments, | ||
| cwd, | ||
| isStrict: true, | ||
| }); | ||
|
|
||
| assert.deepEqual(counters, { | ||
|
Check failure on line 17 in packages/knip/test/yarn-pnp.test.ts
|
||
| ...baseCounters, | ||
| processed: 1, | ||
| total: 4, | ||
| }); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a real yarn workspace to test real pnp api, but it'll be good to see any ideas for this fixture.