@yuu1111/knip-config 1.0.7 → 2.1.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.ja.md CHANGED
@@ -37,13 +37,14 @@ export default {
37
37
 
38
38
  | Setting | 値 |
39
39
  |---------|-----|
40
- | `entry` | `["quality.config.ts"]` |
40
+ | `entry` | `["quality.json"]` |
41
41
  | `ignoreExportsUsedInFile` | `true` |
42
- | `ignoreIssues` | `{"quality.config.ts": ["exports"]}` |
43
-
44
- `quality-check` は `quality.config.ts` を実行時に読み込むため、このfileはentry pointとして扱われ未使用fileとして報告しない
45
- `ignoreIssues` はこのfileのexportを報告から外す
42
+ | `treatConfigHintsAsErrors` | `true` |
43
+ | `treatTagHintsAsErrors` | `true` |
44
+ `quality-check` は `quality.json` を実行時に読み込むため、このfileはentry pointとして扱われ未使用fileとして報告しない
46
45
  利用側の公開APIは `quality-check` のAPIであり、このfileのexportではない
46
+ `treatConfigHintsAsErrors` は設定がProjectの実態と合わなくなったときに実行を失敗させる
47
+ `treatTagHintsAsErrors` は抑制しなくなったtagがあるときに実行を失敗させる
47
48
 
48
49
  ### application
49
50
 
@@ -57,30 +58,32 @@ applicationのentry pointは公開契約ではないため `includeEntryExports:
57
58
 
58
59
  動的なentry point、CLI binary、生成物は共有presetがProject構成から推測できないため、利用Project側で足す
59
60
 
60
- `entry` は利用Projectが書くと置き換わるため `quality.config.ts` も並べる
61
+ `entry` は利用Projectが書くと置き換わるため `quality.json` も並べる
61
62
 
62
63
  ```ts
63
64
  export default {
64
65
  ...application,
65
- entry: ["src/main.ts", "quality.config.ts"]
66
+ entry: ["src/main.ts", "quality.json"]
66
67
  }
67
68
  ```
68
69
 
69
- `workspaces` を使う場合、`base` が足すtop levelの `entry` はroot workspaceへ届かないためroot workspace側にも書く
70
+ `workspaces` を使う場合、`base` が足すtop levelの `entry` はroot workspaceへ届かないためroot workspace側へ移す
71
+ top levelの `entry` を残すとKnipがconfiguration hintを出し、`base` はhintをerrorとして扱うため実行が失敗する
70
72
 
71
73
  ```ts
74
+ import { application } from "@yuu1111/knip-config/application"
75
+
76
+ const { entry, ...base } = application
77
+
72
78
  export default {
73
- ...application,
79
+ ...base,
74
80
  workspaces: {
75
- ".": { entry: ["quality.config.ts"] },
81
+ ".": { entry },
76
82
  "packages/app": { entry: ["src/cli.ts"] }
77
83
  }
78
84
  }
79
85
  ```
80
86
 
81
- `workspaces` を持つrepositoryがtop levelにも `entry` を書くとKnipがconfiguration hintを出す
82
- 報告ではないため終了codeは変わらない
83
-
84
87
  別Projectを同居させているrepositoryは `ignore` でそのProjectを報告から外し、親のsourceとして読ませない
85
88
 
86
89
  ```ts
package/README.md CHANGED
@@ -37,12 +37,15 @@ Every preset extends `base`.
37
37
 
38
38
  | Setting | Value |
39
39
  |---------|-------|
40
- | `entry` | `["quality.config.ts"]` |
40
+ | `entry` | `["quality.json"]` |
41
41
  | `ignoreExportsUsedInFile` | `true` |
42
- | `ignoreIssues` | `{"quality.config.ts": ["exports"]}` |
42
+ | `treatConfigHintsAsErrors` | `true` |
43
+ | `treatTagHintsAsErrors` | `true` |
43
44
 
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.
45
+ `quality-check` loads `quality.json` at run time, so the file counts as an entry point and is not reported as unused.
46
+ `ignoreExportsUsedInFile` 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.
47
+ `treatConfigHintsAsErrors` fails the run when a configuration no longer matches the project.
48
+ `treatTagHintsAsErrors` fails the run when a suppression tag no longer suppresses anything.
46
49
 
47
50
  ### application
48
51
 
@@ -56,29 +59,32 @@ Sets `includeEntryExports: true`, so an export that is no longer part of the pub
56
59
 
57
60
  A shared preset cannot see dynamic entry points, CLI binaries, or generated files, so the project adds them.
58
61
 
59
- `entry` is replaced when the project writes its own, so list `quality.config.ts` too:
62
+ `entry` is replaced when the project writes its own, so list `quality.json` too:
60
63
 
61
64
  ```ts
62
65
  export default {
63
66
  ...application,
64
- entry: ["src/main.ts", "quality.config.ts"]
67
+ entry: ["src/main.ts", "quality.json"]
65
68
  }
66
69
  ```
67
70
 
68
- `workspaces` does not inherit the top-level `entry` in the root workspace, so write it there too:
71
+ `workspaces` does not inherit the top-level `entry` in the root workspace, so move `entry` there:
69
72
 
70
73
  ```ts
74
+ import { application } from "@yuu1111/knip-config/application"
75
+
76
+ const { entry, ...base } = application
77
+
71
78
  export default {
72
- ...application,
79
+ ...base,
73
80
  workspaces: {
74
- ".": { entry: ["quality.config.ts"] },
81
+ ".": { entry },
75
82
  "packages/app": { entry: ["src/cli.ts"] }
76
83
  }
77
84
  }
78
85
  ```
79
86
 
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.
87
+ Knip prints a configuration hint when a repository with `workspaces` also writes `entry` at the top level, and `base` fails the run on a hint.
82
88
 
83
89
  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:
84
90
 
package/base.ts CHANGED
@@ -4,7 +4,8 @@ import type { KnipConfig } from "knip";
4
4
  * 各presetが共通で継承するbase設定を提供する
5
5
  */
6
6
  export const base = {
7
- entry: ["quality.config.ts"],
7
+ entry: ["quality.json"],
8
8
  ignoreExportsUsedInFile: true,
9
- ignoreIssues: { "quality.config.ts": ["exports"] },
9
+ treatConfigHintsAsErrors: true,
10
+ treatTagHintsAsErrors: true,
10
11
  } satisfies KnipConfig;
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@yuu1111/knip-config",
3
- "version": "1.0.7",
3
+ "version": "2.1.0",
4
4
  "description": "Shared Knip configuration",
5
+ "homepage": "https://yuu1111.github.io/configs/packages/config/knip-config/",
5
6
  "repository": {
6
7
  "type": "git",
7
8
  "url": "git+https://github.com/yuu1111/configs.git",