@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 CHANGED
@@ -34,7 +34,8 @@ export default {
34
34
  ### base
35
35
 
36
36
  - `ignoreExportsUsedInFile` は自分のfile内だけで参照されるexportを報告から外す
37
- - `ignoreFiles` は `quality-check` が実行時に読み込む `quality.config.ts` を報告から外す
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: ["FFXIVReplayAnalyzer/**"]
68
+ ignore: ["another-project/**"]
59
69
  }
60
70
  ```
61
71
 
62
- そのrepositoryではpresetだけで未使用export48件から41件になり、入れ子Projectを外すとrepositoryに本当に残った未使用type 1件まで減った
72
+ `workspaces` を持つrepositoryで `entry` をtop levelに書くとKnipconfiguration 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: ["FFXIVReplayAnalyzer/**"]
72
+ ignore: ["another-project/**"]
61
73
  }
62
74
  ```
63
75
 
64
- On such a repository the preset alone took the unused exports from 48 to 41,
65
- and the nested project took the report down to the single unused type that the
66
- repository really has left.
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
- * 各knip設定が共通で継承するbase設定を提供する
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
- // quality-checkが実行時に読み込むため、Projectのsourceとして報告しない
10
- ignoreFiles: ["quality.config.ts"],
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuu1111/knip-config",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Shared Knip configuration",
5
5
  "license": "MIT",
6
6
  "repository": {