@yuu1111/knip-config 1.0.2 → 1.0.4
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.ja.md +13 -3
- package/README.md +16 -4
- package/application.ts +1 -2
- package/base.ts +5 -3
- package/library.ts +1 -1
- package/package.json +1 -1
package/README.ja.md
CHANGED
|
@@ -34,7 +34,8 @@ export default {
|
|
|
34
34
|
### base
|
|
35
35
|
|
|
36
36
|
- `ignoreExportsUsedInFile` は自分のfile内だけで参照されるexportを報告から外す
|
|
37
|
-
- `
|
|
37
|
+
- `entry` は `quality-check` が実行時に読み込む `quality.config.ts` をentry pointとして扱う 未使用fileとして報告せず、このfileがimportするexportも利用中とみなす
|
|
38
|
+
- `ignoreIssues` は `quality.config.ts` 自身のexportを報告から外す 利用側の入口は `quality-check` のAPIであり、このfileのexportではない
|
|
38
39
|
|
|
39
40
|
### application
|
|
40
41
|
|
|
@@ -48,6 +49,15 @@ export default {
|
|
|
48
49
|
|
|
49
50
|
動的なentry point、CLI binary、生成物は共有presetがProject構成から推測できないため利用Project側に残す
|
|
50
51
|
|
|
52
|
+
`base` が足す `entry` は、利用Projectが `entry` を書くと置き換わる 自分のentryを足すときは `quality.config.ts` も並べる
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
export default {
|
|
56
|
+
...application,
|
|
57
|
+
entry: ["src/main.ts", "quality.config.ts"]
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
51
61
|
別Projectを同居させているrepositoryは `ignore` でそのProjectを報告から外し、親のsourceとして読ませない
|
|
52
62
|
|
|
53
63
|
```ts
|
|
@@ -55,8 +65,8 @@ import { application } from "@yuu1111/knip-config/application"
|
|
|
55
65
|
|
|
56
66
|
export default {
|
|
57
67
|
...application,
|
|
58
|
-
ignore: ["
|
|
68
|
+
ignore: ["another-project/**"]
|
|
59
69
|
}
|
|
60
70
|
```
|
|
61
71
|
|
|
62
|
-
|
|
72
|
+
`workspaces` を持つrepositoryで `entry` をtop levelに書くとKnipがconfiguration hintを出す 報告ではないため終了codeは変わらない
|
package/README.md
CHANGED
|
@@ -35,6 +35,8 @@ export default {
|
|
|
35
35
|
### base
|
|
36
36
|
|
|
37
37
|
- `ignoreExportsUsedInFile` keeps exports that are only referenced inside their own file out of the report
|
|
38
|
+
- `entry` treats `quality.config.ts`, which `quality-check` loads at run time, as an entry point: it is not reported as an unused file and the exports it imports count as used
|
|
39
|
+
- `ignoreIssues` keeps the exports of `quality.config.ts` itself out of the report, because the entry point of a consuming project is the API of `quality-check` and not the exports of this file
|
|
38
40
|
|
|
39
41
|
### application
|
|
40
42
|
|
|
@@ -49,6 +51,16 @@ export default {
|
|
|
49
51
|
Dynamic entry points, CLI binaries, and generated files stay in the consuming
|
|
50
52
|
project because a shared preset cannot infer them from the project layout.
|
|
51
53
|
|
|
54
|
+
The `entry` that `base` adds is replaced when a project writes its own `entry`,
|
|
55
|
+
so an added entry lists `quality.config.ts` as well:
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
export default {
|
|
59
|
+
...application,
|
|
60
|
+
entry: ["src/main.ts", "quality.config.ts"]
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
52
64
|
A repository that also holds another project keeps that project out of the
|
|
53
65
|
report with `ignore`, so its files are not read as source of the parent:
|
|
54
66
|
|
|
@@ -57,10 +69,10 @@ import { application } from "@yuu1111/knip-config/application"
|
|
|
57
69
|
|
|
58
70
|
export default {
|
|
59
71
|
...application,
|
|
60
|
-
ignore: ["
|
|
72
|
+
ignore: ["another-project/**"]
|
|
61
73
|
}
|
|
62
74
|
```
|
|
63
75
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
76
|
+
Knip prints a configuration hint when a repository with `workspaces` writes
|
|
77
|
+
`entry` at the top level. A hint is not a report, so the exit code does not
|
|
78
|
+
change.
|
package/application.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { KnipConfig } from "knip";
|
|
2
2
|
import { base } from "./base";
|
|
3
3
|
|
|
4
|
-
// frameworkが動的に読み込むentrypointは利用Projectが明示する
|
|
5
4
|
/**
|
|
6
|
-
* application向けのknip設定を提供する
|
|
5
|
+
* frameworkが動的に読み込むentryは利用Projectが明示するapplication向けのknip設定を提供する
|
|
7
6
|
*/
|
|
8
7
|
export const application = {
|
|
9
8
|
...base,
|
package/base.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { KnipConfig } from "knip";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* 各
|
|
4
|
+
* 各presetが共通で継承するbase設定を提供する
|
|
5
5
|
*/
|
|
6
6
|
export const base = {
|
|
7
|
+
// quality-checkが実行時に読み込むentrypointとして扱い、未使用fileとして報告しない
|
|
8
|
+
entry: ["quality.config.ts"],
|
|
7
9
|
// 同一file内で参照しているexportは内部利用とみなす
|
|
8
10
|
ignoreExportsUsedInFile: true,
|
|
9
|
-
//
|
|
10
|
-
|
|
11
|
+
// config file自身のexportは利用側の入口ではないため報告しない
|
|
12
|
+
ignoreIssues: { "quality.config.ts": ["exports"] },
|
|
11
13
|
} satisfies KnipConfig;
|
package/library.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { KnipConfig } from "knip";
|
|
2
2
|
import { base } from "./base";
|
|
3
3
|
|
|
4
|
-
// 公開APIのentryから未使用になったexportを報告する
|
|
5
4
|
/**
|
|
6
5
|
* 公開APIのentryを持つlibrary向けのknip設定を提供する
|
|
7
6
|
*/
|
|
8
7
|
export const library = {
|
|
9
8
|
...base,
|
|
9
|
+
// 公開APIから外れたexportを未使用として報告する
|
|
10
10
|
includeEntryExports: true,
|
|
11
11
|
} satisfies KnipConfig;
|