-
-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test + fixture for updated module resolution
- Loading branch information
Showing
26 changed files
with
136 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"name": "@fixture/exports-in-file-shorthand", | ||
"name": "@fixtures/exports-in-file-shorthand", | ||
"version": "*" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"name": "@fixture/typescript2", | ||
"name": "@fixtures/typescript2", | ||
"workspaces": [ | ||
"packages/*" | ||
] | ||
|
3 changes: 1 addition & 2 deletions
3
packages/knip/fixtures/plugins/typescript2/packages/lib/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/package", | ||
"name": "@fixture/typescript2-lib" | ||
"name": "@fixtures/typescript2-lib" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules | ||
build | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { usedFunction } from "@kp/shared"; | ||
|
||
console.log(usedFunction()); |
9 changes: 9 additions & 0 deletions
9
packages/knip/fixtures/workspaces-dts/apps/app-a/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "@kp/app-a", | ||
"version": "0.0.0", | ||
"private": true, | ||
"type": "module", | ||
"dependencies": { | ||
"@kp/shared": "*" | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/knip/fixtures/workspaces-dts/apps/app-a/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"include": ["**/*.js"], | ||
"exclude": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { usedFunction } from "@kp/shared"; | ||
|
||
console.log(usedFunction()); |
9 changes: 9 additions & 0 deletions
9
packages/knip/fixtures/workspaces-dts/apps/app-b/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "@kp/app-b", | ||
"version": "0.0.0", | ||
"private": true, | ||
"type": "module", | ||
"dependencies": { | ||
"@kp/shared": "*" | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/knip/fixtures/workspaces-dts/apps/app-b/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"include": ["**/*.js"], | ||
"exclude": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** @type {import('knip').KnipConfig} */ | ||
const config = { | ||
workspaces: { | ||
'packages/shared': { | ||
includeEntryExports: true, | ||
}, | ||
}, | ||
}; | ||
|
||
export default config; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "@fixtures/workspaces-dts", | ||
"version": "0.0.0", | ||
"private": true, | ||
"workspaces": [ | ||
"apps/*", | ||
"packages/*" | ||
] | ||
} |
2 changes: 2 additions & 0 deletions
2
packages/knip/fixtures/workspaces-dts/packages/shared/build/index.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { unusedFunction } from "./unused-function.js"; | ||
export { usedFunction } from "./used-function.js"; |
1 change: 1 addition & 0 deletions
1
packages/knip/fixtures/workspaces-dts/packages/shared/build/unused-function.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export function unusedFunction(): string; |
1 change: 1 addition & 0 deletions
1
packages/knip/fixtures/workspaces-dts/packages/shared/build/used-function.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export function usedFunction(): string; |
8 changes: 8 additions & 0 deletions
8
packages/knip/fixtures/workspaces-dts/packages/shared/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "@kp/shared", | ||
"version": "0.0.0", | ||
"private": true, | ||
"main": "src/index.js", | ||
"types": "build/index.d.ts", | ||
"type": "module" | ||
} |
2 changes: 2 additions & 0 deletions
2
packages/knip/fixtures/workspaces-dts/packages/shared/src/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { unusedFunction } from "./unused-function.js"; | ||
export { usedFunction } from "./used-function.js"; |
1 change: 1 addition & 0 deletions
1
packages/knip/fixtures/workspaces-dts/packages/shared/src/unused-function.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const unusedFunction = () => "bar"; |
1 change: 1 addition & 0 deletions
1
packages/knip/fixtures/workspaces-dts/packages/shared/src/used-function.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const usedFunction = () => "bar"; |
11 changes: 11 additions & 0 deletions
11
packages/knip/fixtures/workspaces-dts/packages/shared/tsconfig.build.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"include": ["src"], | ||
"compilerOptions": { | ||
"declaration": true, | ||
"declarationMap": true, | ||
"sourceMap": true, | ||
"emitDeclarationOnly": true, | ||
"outDir": "build" | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/knip/fixtures/workspaces-dts/packages/shared/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"exclude": ["build"], | ||
"include": ["**/*.js"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"include": ["./**/*.js"], | ||
"exclude": ["node_modules", "apps", "packages"], | ||
"compilerOptions": { | ||
"lib": ["DOM", "DOM.Iterable", "ESNext"], | ||
"allowJs": true, | ||
"checkJs": true, | ||
"target": "ESNext", | ||
"module": "ESNext", | ||
"moduleResolution": "Bundler", | ||
"skipLibCheck": true, | ||
"esModuleInterop": true, | ||
"strict": true, | ||
"noUncheckedIndexedAccess": true, | ||
"exactOptionalPropertyTypes": true, | ||
"noPropertyAccessFromIndexSignature": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import assert from 'node:assert/strict'; | ||
import test from 'node:test'; | ||
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/workspaces-dts'); | ||
|
||
test('Find unused un-built exports across workspaces', async () => { | ||
const { issues, counters } = await main({ | ||
...baseArguments, | ||
cwd, | ||
}); | ||
|
||
assert(issues.exports['packages/shared/src/index.js']['unusedFunction']); | ||
|
||
assert.deepEqual(counters, { | ||
...baseCounters, | ||
exports: 1, | ||
processed: 7, | ||
total: 7, | ||
}); | ||
}); |