@yuu1111/knip-config 1.0.0 → 1.0.2

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 ADDED
@@ -0,0 +1,62 @@
1
+ [English](README.md)
2
+
3
+ # @yuu1111/knip-config
4
+
5
+ 共有の [Knip](https://knip.dev/) 設定
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ bun add -D @yuu1111/knip-config knip
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ Knipは `knip.ts` を読むため、Projectに合うpresetをimportしてProject固有のentryを足す
16
+
17
+ ```ts
18
+ import { application } from "@yuu1111/knip-config/application"
19
+
20
+ export default {
21
+ ...application,
22
+ entry: ["src/main.ts"]
23
+ }
24
+ ```
25
+
26
+ ## Presets
27
+
28
+ | Preset | Use case |
29
+ |--------|----------|
30
+ | `base` | 共有の既定値 |
31
+ | `application` | entry pointをframeworkが解決するapplication |
32
+ | `library` | entry pointが公開APIそのものであるlibrary |
33
+
34
+ ### base
35
+
36
+ - `ignoreExportsUsedInFile` は自分のfile内だけで参照されるexportを報告から外す
37
+ - `ignoreFiles` は `quality-check` が実行時に読み込む `quality.config.ts` を報告から外す
38
+
39
+ ### application
40
+
41
+ - applicationのentry pointは公開契約ではないため `includeEntryExports` はoffのままにする
42
+
43
+ ### library
44
+
45
+ - 公開APIから外れたexportを報告するため `includeEntryExports` をonにする
46
+
47
+ ## Notes
48
+
49
+ 動的なentry point、CLI binary、生成物は共有presetがProject構成から推測できないため利用Project側に残す
50
+
51
+ 別Projectを同居させているrepositoryは `ignore` でそのProjectを報告から外し、親のsourceとして読ませない
52
+
53
+ ```ts
54
+ import { application } from "@yuu1111/knip-config/application"
55
+
56
+ export default {
57
+ ...application,
58
+ ignore: ["FFXIVReplayAnalyzer/**"]
59
+ }
60
+ ```
61
+
62
+ そのrepositoryではpresetだけで未使用exportが48件から41件になり、入れ子Projectを外すとrepositoryに本当に残った未使用type 1件まで減った
package/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [日本語](README.ja.md)
2
+
1
3
  # @yuu1111/knip-config
2
4
 
3
5
  Shared [Knip](https://knip.dev/) configuration.
package/application.ts CHANGED
@@ -2,7 +2,9 @@ import type { KnipConfig } from "knip";
2
2
  import { base } from "./base";
3
3
 
4
4
  // frameworkが動的に読み込むentrypointは利用Projectが明示する
5
- /** application向けのknip設定を提供する */
5
+ /**
6
+ * application向けのknip設定を提供する
7
+ */
6
8
  export const application = {
7
9
  ...base,
8
10
  // applicationのentryは公開契約ではないため未使用exportとして報告しない
package/base.ts CHANGED
@@ -1,7 +1,11 @@
1
1
  import type { KnipConfig } from "knip";
2
2
 
3
- /** 各knip設定が共通で継承するbase設定を提供する */
3
+ /**
4
+ * 各knip設定が共通で継承するbase設定を提供する
5
+ */
4
6
  export const base = {
5
7
  // 同一file内で参照しているexportは内部利用とみなす
6
8
  ignoreExportsUsedInFile: true,
9
+ // quality-checkが実行時に読み込むため、Projectのsourceとして報告しない
10
+ ignoreFiles: ["quality.config.ts"],
7
11
  } satisfies KnipConfig;
package/library.ts CHANGED
@@ -2,7 +2,9 @@ import type { KnipConfig } from "knip";
2
2
  import { base } from "./base";
3
3
 
4
4
  // 公開APIのentryから未使用になったexportを報告する
5
- /** 公開APIのentryを持つlibrary向けのknip設定を提供する */
5
+ /**
6
+ * 公開APIのentryを持つlibrary向けのknip設定を提供する
7
+ */
6
8
  export const library = {
7
9
  ...base,
8
10
  includeEntryExports: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuu1111/knip-config",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Shared Knip configuration",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -15,6 +15,7 @@
15
15
  "./library": "./library.ts"
16
16
  },
17
17
  "files": [
18
+ "README.ja.md",
18
19
  "application.ts",
19
20
  "base.ts",
20
21
  "library.ts"