@yuu1111/knip-config 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +64 -0
- package/application.ts +9 -0
- package/base.ts +6 -0
- package/library.ts +8 -0
- package/package.json +37 -0
package/README.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# @yuu1111/knip-config
|
|
2
|
+
|
|
3
|
+
Shared [Knip](https://knip.dev/) configuration.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bun add -D @yuu1111/knip-config knip
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
Knip loads `knip.ts`, so import the preset that matches the project and add the
|
|
14
|
+
project specific entries:
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import { application } from "@yuu1111/knip-config/application"
|
|
18
|
+
|
|
19
|
+
export default {
|
|
20
|
+
...application,
|
|
21
|
+
entry: ["src/main.ts"]
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Presets
|
|
26
|
+
|
|
27
|
+
| Preset | Use case |
|
|
28
|
+
|--------|----------|
|
|
29
|
+
| `base` | Shared defaults |
|
|
30
|
+
| `application` | Applications whose entry points are resolved by a framework |
|
|
31
|
+
| `library` | Libraries whose entry points are their public API |
|
|
32
|
+
|
|
33
|
+
### base
|
|
34
|
+
|
|
35
|
+
- `ignoreExportsUsedInFile` keeps exports that are only referenced inside their own file out of the report
|
|
36
|
+
|
|
37
|
+
### application
|
|
38
|
+
|
|
39
|
+
- `includeEntryExports` stays off because the entry points of an application are not a public contract
|
|
40
|
+
|
|
41
|
+
### library
|
|
42
|
+
|
|
43
|
+
- `includeEntryExports` is on so an export that is no longer part of the public API is reported
|
|
44
|
+
|
|
45
|
+
## Notes
|
|
46
|
+
|
|
47
|
+
Dynamic entry points, CLI binaries, and generated files stay in the consuming
|
|
48
|
+
project because a shared preset cannot infer them from the project layout.
|
|
49
|
+
|
|
50
|
+
A repository that also holds another project keeps that project out of the
|
|
51
|
+
report with `ignore`, so its files are not read as source of the parent:
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
import { application } from "@yuu1111/knip-config/application"
|
|
55
|
+
|
|
56
|
+
export default {
|
|
57
|
+
...application,
|
|
58
|
+
ignore: ["FFXIVReplayAnalyzer/**"]
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
On such a repository the preset alone took the unused exports from 48 to 41,
|
|
63
|
+
and the nested project took the report down to the single unused type that the
|
|
64
|
+
repository really has left.
|
package/application.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { KnipConfig } from "knip";
|
|
2
|
+
import { base } from "./base";
|
|
3
|
+
|
|
4
|
+
// frameworkが動的に読み込むentrypointは利用Projectが明示する
|
|
5
|
+
export const application = {
|
|
6
|
+
...base,
|
|
7
|
+
// applicationのentryは公開契約ではないため未使用exportとして報告しない
|
|
8
|
+
includeEntryExports: false,
|
|
9
|
+
} satisfies KnipConfig;
|
package/base.ts
ADDED
package/library.ts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@yuu1111/knip-config",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Shared Knip configuration",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/yuu1111/configs.git",
|
|
9
|
+
"directory": "packages/knip-config"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"exports": {
|
|
13
|
+
"./application": "./application.ts",
|
|
14
|
+
"./base": "./base.ts",
|
|
15
|
+
"./library": "./library.ts"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"application.ts",
|
|
19
|
+
"base.ts",
|
|
20
|
+
"library.ts"
|
|
21
|
+
],
|
|
22
|
+
"keywords": [
|
|
23
|
+
"knip",
|
|
24
|
+
"config"
|
|
25
|
+
],
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"knip": ">=5.0.0"
|
|
28
|
+
},
|
|
29
|
+
"peerDependenciesMeta": {
|
|
30
|
+
"knip": {
|
|
31
|
+
"optional": true
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"knip": "^6.34.0"
|
|
36
|
+
}
|
|
37
|
+
}
|