-
-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Report unused members of re-exports (fixes #140)
- Loading branch information
Showing
13 changed files
with
136 additions
and
1 deletion.
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
27 changes: 27 additions & 0 deletions
27
tests/fixtures/include-entry-reexports/node_modules/.package-lock.json
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.
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/include-entry-reexports", | ||
"version": "1.0.0", | ||
"private": true, | ||
"type": "module", | ||
"workspaces": [ | ||
"packages/*" | ||
] | ||
} |
3 changes: 3 additions & 0 deletions
3
tests/fixtures/include-entry-reexports/packages/app/index.mjs
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 { foo } from '@kp/shared' | ||
|
||
console.log(foo()) |
10 changes: 10 additions & 0 deletions
10
tests/fixtures/include-entry-reexports/packages/app/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,10 @@ | ||
{ | ||
"name": "@kp/app", | ||
"version": "0.0.0", | ||
"private": true, | ||
"main": "index.mjs", | ||
"type": "module", | ||
"dependencies": { | ||
"@kp/shared": "*" | ||
} | ||
} |
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 bar = () => 'bar' |
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 foo = () => 'foo' |
2 changes: 2 additions & 0 deletions
2
tests/fixtures/include-entry-reexports/packages/shared/index.mjs
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 * from './foo.mjs' | ||
export * from './bar.mjs' |
7 changes: 7 additions & 0 deletions
7
tests/fixtures/include-entry-reexports/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,7 @@ | ||
{ | ||
"name": "@kp/shared", | ||
"version": "0.0.0", | ||
"private": true, | ||
"main": "index.mjs", | ||
"type": "module" | ||
} |
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,39 @@ | ||
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('tests/fixtures/include-entry-reexports'); | ||
|
||
test('Skip unused nsExports in entry source files', async () => { | ||
const { counters } = await main({ | ||
...baseArguments, | ||
cwd, | ||
isIncludeEntryExports: false, | ||
}); | ||
|
||
assert.deepEqual(counters, { | ||
...baseCounters, | ||
processed: 4, | ||
total: 4, | ||
}); | ||
}); | ||
|
||
test('Report unused nsExports in entry source files', async () => { | ||
const { issues, counters } = await main({ | ||
...baseArguments, | ||
cwd, | ||
isIncludeEntryExports: true, | ||
}); | ||
|
||
assert(issues.nsExports['packages/shared/bar.mjs']['bar']); | ||
|
||
assert.deepEqual(counters, { | ||
...baseCounters, | ||
nsExports: 1, | ||
processed: 4, | ||
total: 4, | ||
}); | ||
}); |