@yuu1111/knip-config 1.0.6 → 1.0.7

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
@@ -12,7 +12,7 @@ bun add -D @yuu1111/knip-config knip
12
12
 
13
13
  ## Usage
14
14
 
15
- Knipは `knip.ts` を読むため、Projectに合うpresetをimportしてProject固有のentryを足す
15
+ Knipは `knip.ts` を読むため、Projectに合うpresetをimportし、presetが推測できないentryを足す
16
16
 
17
17
  ```ts
18
18
  import { application } from "@yuu1111/knip-config/application"
@@ -25,31 +25,39 @@ export default {
25
25
 
26
26
  ## Presets
27
27
 
28
- | Preset | Use case |
29
- |--------|----------|
30
- | `base` | 共有の既定値 |
31
- | `application` | entry pointをframeworkが解決するapplication |
32
- | `library` | entry pointが公開APIそのものであるlibrary |
28
+ | Preset | `includeEntryExports` | 用途 |
29
+ |--------|----------------------|------|
30
+ | `base` | — | 共有の既定値 |
31
+ | `application` | `false` | entry pointをframeworkが解決するapplication |
32
+ | `library` | `true` | entry pointが公開APIそのものであるlibrary |
33
33
 
34
34
  ### base
35
35
 
36
- - `ignoreExportsUsedInFile` は自分のfile内だけで参照されるexportを報告から外す
37
- - `entry` は `quality-check` が実行時に読み込む `quality.config.ts` をentry pointとして扱う 未使用fileとして報告せず、このfileがimportするexportも利用中とみなす
38
- - `ignoreIssues` `quality.config.ts` 自身のexportを報告から外す 利用側の入口は `quality-check` のAPIであり、このfileのexportではない
36
+ すべてのpresetが `base` をextendsする
37
+
38
+ | Setting | |
39
+ |---------|-----|
40
+ | `entry` | `["quality.config.ts"]` |
41
+ | `ignoreExportsUsedInFile` | `true` |
42
+ | `ignoreIssues` | `{"quality.config.ts": ["exports"]}` |
43
+
44
+ `quality-check` は `quality.config.ts` を実行時に読み込むため、このfileはentry pointとして扱われ未使用fileとして報告しない
45
+ `ignoreIssues` はこのfileのexportを報告から外す
46
+ 利用側の公開APIは `quality-check` のAPIであり、このfileのexportではない
39
47
 
40
48
  ### application
41
49
 
42
- - applicationのentry pointは公開契約ではないため `includeEntryExports` はoffのままにする
50
+ applicationのentry pointは公開契約ではないため `includeEntryExports: false` を設定する
43
51
 
44
52
  ### library
45
53
 
46
- - 公開APIから外れたexportを報告するため `includeEntryExports` をonにする
54
+ 公開APIから外れたexportを報告するため `includeEntryExports: true` を設定する
47
55
 
48
- ## Notes
56
+ ## Config
49
57
 
50
- 動的なentry point、CLI binary、生成物は共有presetがProject構成から推測できないため利用Project側に残す
58
+ 動的なentry point、CLI binary、生成物は共有presetがProject構成から推測できないため、利用Project側で足す
51
59
 
52
- `base` が足す `entry` は、利用Project `entry` を書くと置き換わる 自分のentryを足すときは `quality.config.ts` も並べる
60
+ `entry` は利用Projectが書くと置き換わるため `quality.config.ts` も並べる
53
61
 
54
62
  ```ts
55
63
  export default {
@@ -58,7 +66,7 @@ export default {
58
66
  }
59
67
  ```
60
68
 
61
- `workspaces` を設定に書くと、`base` が足すtop levelの `entry` はroot workspaceへ届かない root workspace側にも `entry` を書く
69
+ `workspaces` を使う場合、`base` が足すtop levelの `entry` はroot workspaceへ届かないためroot workspace側にも書く
62
70
 
63
71
  ```ts
64
72
  export default {
@@ -70,15 +78,14 @@ export default {
70
78
  }
71
79
  ```
72
80
 
81
+ `workspaces` を持つrepositoryがtop levelにも `entry` を書くとKnipがconfiguration hintを出す
82
+ 報告ではないため終了codeは変わらない
83
+
73
84
  別Projectを同居させているrepositoryは `ignore` でそのProjectを報告から外し、親のsourceとして読ませない
74
85
 
75
86
  ```ts
76
- import { application } from "@yuu1111/knip-config/application"
77
-
78
87
  export default {
79
88
  ...application,
80
89
  ignore: ["another-project/**"]
81
90
  }
82
91
  ```
83
-
84
- `workspaces` を持つrepositoryで `entry` をtop levelに書くとKnipがconfiguration hintを出す 報告ではないため終了codeは変わらない
package/README.md CHANGED
@@ -12,8 +12,7 @@ bun add -D @yuu1111/knip-config knip
12
12
 
13
13
  ## Usage
14
14
 
15
- Knip loads `knip.ts`, so import the preset that matches the project and add the
16
- project specific entries:
15
+ Knip loads `knip.ts`, so import the preset that matches the project and add the entries it cannot infer:
17
16
 
18
17
  ```ts
19
18
  import { application } from "@yuu1111/knip-config/application"
@@ -26,33 +25,38 @@ export default {
26
25
 
27
26
  ## Presets
28
27
 
29
- | Preset | Use case |
30
- |--------|----------|
31
- | `base` | Shared defaults |
32
- | `application` | Applications whose entry points are resolved by a framework |
33
- | `library` | Libraries whose entry points are their public API |
28
+ | Preset | `includeEntryExports` | Use case |
29
+ |--------|----------------------|----------|
30
+ | `base` | — | Shared defaults |
31
+ | `application` | `false` | Applications whose entry points a framework resolves |
32
+ | `library` | `true` | Libraries whose entry points are their public API |
34
33
 
35
34
  ### base
36
35
 
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
36
+ Every preset extends `base`.
37
+
38
+ | Setting | Value |
39
+ |---------|-------|
40
+ | `entry` | `["quality.config.ts"]` |
41
+ | `ignoreExportsUsedInFile` | `true` |
42
+ | `ignoreIssues` | `{"quality.config.ts": ["exports"]}` |
43
+
44
+ `quality-check` loads `quality.config.ts` at run time, so the file counts as an entry point and is not reported as unused.
45
+ `ignoreIssues` keeps its exports out of the report, because the public API of a consuming project is the API of `quality-check` and not the exports of this file.
40
46
 
41
47
  ### application
42
48
 
43
- - `includeEntryExports` stays off because the entry points of an application are not a public contract
49
+ Sets `includeEntryExports: false`, because the entry points of an application are not a public contract.
44
50
 
45
51
  ### library
46
52
 
47
- - `includeEntryExports` is on so an export that is no longer part of the public API is reported
53
+ Sets `includeEntryExports: true`, so an export that is no longer part of the public API is reported.
48
54
 
49
- ## Notes
55
+ ## Config
50
56
 
51
- Dynamic entry points, CLI binaries, and generated files stay in the consuming
52
- project because a shared preset cannot infer them from the project layout.
57
+ A shared preset cannot see dynamic entry points, CLI binaries, or generated files, so the project adds them.
53
58
 
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:
59
+ `entry` is replaced when the project writes its own, so list `quality.config.ts` too:
56
60
 
57
61
  ```ts
58
62
  export default {
@@ -61,8 +65,7 @@ export default {
61
65
  }
62
66
  ```
63
67
 
64
- Writing `workspaces` in the config means the top-level `entry` that `base`
65
- adds does not reach the root workspace, so the root workspace repeats it:
68
+ `workspaces` does not inherit the top-level `entry` in the root workspace, so write it there too:
66
69
 
67
70
  ```ts
68
71
  export default {
@@ -74,18 +77,14 @@ export default {
74
77
  }
75
78
  ```
76
79
 
77
- A repository that also holds another project keeps that project out of the
78
- report with `ignore`, so its files are not read as source of the parent:
80
+ Knip prints a configuration hint when a repository with `workspaces` also writes `entry` at the top level.
81
+ A hint is not a report, so the exit code does not change.
79
82
 
80
- ```ts
81
- import { application } from "@yuu1111/knip-config/application"
83
+ A repository that also holds another project keeps it out of the report with `ignore`, so its files are not read as source of the parent:
82
84
 
85
+ ```ts
83
86
  export default {
84
87
  ...application,
85
88
  ignore: ["another-project/**"]
86
89
  }
87
90
  ```
88
-
89
- Knip prints a configuration hint when a repository with `workspaces` writes
90
- `entry` at the top level. A hint is not a report, so the exit code does not
91
- change.
package/application.ts CHANGED
@@ -6,6 +6,5 @@ import { base } from "./base";
6
6
  */
7
7
  export const application = {
8
8
  ...base,
9
- // applicationのentryは公開契約ではないため未使用exportとして報告しない
10
9
  includeEntryExports: false,
11
10
  } satisfies KnipConfig;
package/base.ts CHANGED
@@ -4,10 +4,7 @@ import type { KnipConfig } from "knip";
4
4
  * 各presetが共通で継承するbase設定を提供する
5
5
  */
6
6
  export const base = {
7
- // quality-checkが実行時に読み込むentrypointとして扱い、未使用fileとして報告しない
8
7
  entry: ["quality.config.ts"],
9
- // 同一file内で参照しているexportは内部利用とみなす
10
8
  ignoreExportsUsedInFile: true,
11
- // config file自身のexportは利用側の入口ではないため報告しない
12
9
  ignoreIssues: { "quality.config.ts": ["exports"] },
13
10
  } satisfies KnipConfig;
package/library.ts CHANGED
@@ -6,6 +6,5 @@ import { base } from "./base";
6
6
  */
7
7
  export const library = {
8
8
  ...base,
9
- // 公開APIから外れたexportを未使用として報告する
10
9
  includeEntryExports: true,
11
10
  } satisfies KnipConfig;
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@yuu1111/knip-config",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "Shared Knip configuration",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/yuu1111/configs.git",
8
- "directory": "packages/knip-config"
8
+ "directory": "packages/config/knip-config"
9
9
  },
10
10
  "type": "module",
11
11
  "exports": {