@syntopica/quality-config 0.11.1 → 0.12.1
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/PUBLIC_API.md +3 -3
- package/README.md +1 -1
- package/bin/baseline-type-coverage.mjs +18 -9
- package/package.json +7 -7
- package/src/knip-framework.ts +7 -6
- package/src/knip.ts +8 -5
package/PUBLIC_API.md
CHANGED
|
@@ -56,9 +56,9 @@ file plus a runner rather than as a factory: the config is read in place, never
|
|
|
56
56
|
copied into the consuming repo.
|
|
57
57
|
|
|
58
58
|
`baseline-type-coverage` takes the directories to search and `--at-least <n>`, a
|
|
59
|
-
repo-local
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
repo-local bar: below the shared threshold for a project still climbing toward
|
|
60
|
+
it, above it to pin a project that has passed it (up to 100). It refuses a value
|
|
61
|
+
equal to the shared threshold, which would only restate it.
|
|
62
62
|
|
|
63
63
|
`--also-ignore <patterns>` adds ignore patterns **on top of** the shared list.
|
|
64
64
|
jscpd's own `--ignore` replaces that list instead, so without this a project
|
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ files/exports/dependencies (knip), module boundaries and dependency cycles
|
|
|
7
7
|
|
|
8
8
|
- **Public API (semver):** see [PUBLIC_API.md](./PUBLIC_API.md).
|
|
9
9
|
- **Platform decisions:**
|
|
10
|
-
[engineering-baseline/docs/platform-decisions.md](https://github.com/
|
|
10
|
+
[engineering-baseline/docs/platform-decisions.md](https://github.com/syntopica/codeality/blob/main/docs/platform-decisions.md).
|
|
11
11
|
|
|
12
12
|
## Requirements
|
|
13
13
|
|
|
@@ -12,12 +12,14 @@
|
|
|
12
12
|
// to `any` is the point. `--strict` is on, so an `any` reached through a
|
|
13
13
|
// generic argument counts as uncovered.
|
|
14
14
|
//
|
|
15
|
-
// `--at-least <n>`
|
|
16
|
-
//
|
|
17
|
-
// so the choice is an unenforced gate or none. Freezing at the
|
|
18
|
-
// makes coverage a ratchet - it cannot fall - and the number in
|
|
19
|
-
// is the debt, visible in every diff that changes it. Raise it as
|
|
20
|
-
// go; never lower it to get green.
|
|
15
|
+
// `--at-least <n>` sets the bar for one repo. Below the shared threshold it
|
|
16
|
+
// exists for adoption: a codebase under it cannot wire this gate at all
|
|
17
|
+
// otherwise, so the choice is an unenforced gate or none. Freezing at the
|
|
18
|
+
// measured value makes coverage a ratchet - it cannot fall - and the number in
|
|
19
|
+
// package.json is the debt, visible in every diff that changes it. Raise it as
|
|
20
|
+
// the `any`s go; never lower it to get green. Above the shared threshold it
|
|
21
|
+
// pins a repo that has already climbed past it (to 100, say), so its coverage
|
|
22
|
+
// cannot slide back to the shared floor unnoticed.
|
|
21
23
|
//
|
|
22
24
|
// `--ignore-files <glob>` adds to the two exclusions above. Repeatable. It is
|
|
23
25
|
// for generated or vendored code the project already excludes elsewhere -
|
|
@@ -27,6 +29,7 @@
|
|
|
27
29
|
// baseline-type-coverage # every workspace under the cwd
|
|
28
30
|
// baseline-type-coverage packages apps # only under these directories
|
|
29
31
|
// baseline-type-coverage --at-least 97 # freeze below the shared bar
|
|
32
|
+
// baseline-type-coverage --at-least 100 # pin above it
|
|
30
33
|
// baseline-type-coverage --ignore-files 'migrations/**'
|
|
31
34
|
import { spawnSync } from 'node:child_process'
|
|
32
35
|
import { existsSync, readdirSync, readFileSync } from 'node:fs'
|
|
@@ -74,10 +77,16 @@ if (atLeastIndex !== -1 && !/^\d+(?:\.\d+)?$/.test(override ?? '')) {
|
|
|
74
77
|
)
|
|
75
78
|
exit(1)
|
|
76
79
|
}
|
|
77
|
-
if (override !== undefined && Number(override) >
|
|
80
|
+
if (override !== undefined && Number(override) > 100) {
|
|
78
81
|
console.error(
|
|
79
|
-
`baseline-type-coverage: --at-least ${override} is above
|
|
80
|
-
|
|
82
|
+
`baseline-type-coverage: --at-least ${override} is above 100 percent.`,
|
|
83
|
+
)
|
|
84
|
+
exit(1)
|
|
85
|
+
}
|
|
86
|
+
if (override !== undefined && Number(override) === Number(declared[1])) {
|
|
87
|
+
console.error(
|
|
88
|
+
`baseline-type-coverage: --at-least ${override} restates the shared ` +
|
|
89
|
+
`threshold. Drop the flag.`,
|
|
81
90
|
)
|
|
82
91
|
exit(1)
|
|
83
92
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@syntopica/quality-config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Shared configuration for cross-file quality gates: knip, dependency-cruiser, type-coverage, jscpd, lefthook",
|
|
@@ -72,13 +72,13 @@
|
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@arethetypeswrong/cli": "^0.18.5",
|
|
75
|
-
"@syntopica/eslint-config": "0.
|
|
76
|
-
"@types/node": "^26.6.
|
|
77
|
-
"dependency-cruiser": "^18.
|
|
78
|
-
"eslint": "^10.
|
|
75
|
+
"@syntopica/eslint-config": "0.9.0",
|
|
76
|
+
"@types/node": "^26.6.4",
|
|
77
|
+
"dependency-cruiser": "^18.5.0",
|
|
78
|
+
"eslint": "^10.12.0",
|
|
79
79
|
"eslint-plugin-regexp": "^3.3.1",
|
|
80
|
-
"knip": "^6.
|
|
81
|
-
"publint": "^0.3.
|
|
80
|
+
"knip": "^6.40.0",
|
|
81
|
+
"publint": "^0.3.25",
|
|
82
82
|
"typescript": "npm:@typescript/typescript6@^6.0.2"
|
|
83
83
|
},
|
|
84
84
|
"scripts": {
|
package/src/knip-framework.ts
CHANGED
|
@@ -46,14 +46,13 @@ export const FRAMEWORK_ENTRIES: Record<
|
|
|
46
46
|
// Every file convention belongs in the one brace alternation rather than in a
|
|
47
47
|
// pattern of its own, including the metadata routes (`sitemap`, `robots`,
|
|
48
48
|
// `manifest`, the image generators): a pattern matching nothing is a hint, and
|
|
49
|
-
// no project uses all of them. `middleware` and `proxy`
|
|
50
|
-
//
|
|
51
|
-
//
|
|
49
|
+
// no project uses all of them. `middleware` and `proxy` are left to knip's
|
|
50
|
+
// Next.js plugin, which registers both: listing them here only produced a
|
|
51
|
+
// "Refine entry pattern (no matches)" hint in a project that has neither.
|
|
52
52
|
nextjs: {
|
|
53
53
|
entry: [
|
|
54
54
|
'{,src/}app/**/{page,layout,loading,error,global-error,not-found,route,template,default,sitemap,robots,manifest,icon,apple-icon,opengraph-image,twitter-image}.{ts,tsx}',
|
|
55
55
|
'next.config.*',
|
|
56
|
-
'{,src/}{middleware,proxy}.ts',
|
|
57
56
|
],
|
|
58
57
|
project: ['{,src/}app/**/*.{ts,tsx}', 'src/**/*.{ts,tsx}'],
|
|
59
58
|
includeEntryExports: false,
|
|
@@ -92,13 +91,15 @@ export const FRAMEWORK_ENTRIES: Record<
|
|
|
92
91
|
project: ['src/**/*.ts'],
|
|
93
92
|
includeEntryExports: true,
|
|
94
93
|
},
|
|
94
|
+
// `src/main.*` is reached through index.html's module script; listing it as
|
|
95
|
+
// well was a "Remove redundant entry pattern" hint in both Vite templates.
|
|
95
96
|
'vite-react': {
|
|
96
|
-
entry: ['
|
|
97
|
+
entry: ['index.html', 'vite.config.*'],
|
|
97
98
|
project: ['src/**/*.{ts,tsx}'],
|
|
98
99
|
includeEntryExports: false,
|
|
99
100
|
},
|
|
100
101
|
'vite-vue': {
|
|
101
|
-
entry: ['
|
|
102
|
+
entry: ['index.html', 'vite.config.*'],
|
|
102
103
|
project: ['src/**/*.{ts,vue}'],
|
|
103
104
|
includeEntryExports: false,
|
|
104
105
|
},
|
package/src/knip.ts
CHANGED
|
@@ -35,7 +35,7 @@ import { FRAMEWORK_ENTRIES, type KnipFramework } from './knip-framework'
|
|
|
35
35
|
// `type-coverage`, `baseline-deps-graph` spawns `depcruise`. A project that
|
|
36
36
|
// wires the runner into its scripts never names the underlying tool anywhere
|
|
37
37
|
// knip can see, so knip reports a real dependency as unused. Found in
|
|
38
|
-
//
|
|
38
|
+
// a consumer the moment its `type-coverage` script became
|
|
39
39
|
// `baseline-type-coverage`.
|
|
40
40
|
//
|
|
41
41
|
// `dependency-cruiser` is on the list even though a project calling
|
|
@@ -70,9 +70,12 @@ const ESLINT_PEER_DEPENDENCIES = [
|
|
|
70
70
|
export const createKnipConfig = (options: {
|
|
71
71
|
framework: KnipFramework
|
|
72
72
|
/**
|
|
73
|
-
* Binaries knip cannot resolve
|
|
74
|
-
*
|
|
75
|
-
*
|
|
73
|
+
* Binaries knip cannot resolve, merged with `gitleaks`. That one is ignored
|
|
74
|
+
* by default because the baseline itself writes `gitleaks detect` into every
|
|
75
|
+
* project's `secrets:check`, and it is a system binary no package provides,
|
|
76
|
+
* so every template reported it as unlisted. Nothing else is: an entry for a
|
|
77
|
+
* binary knip *can* resolve becomes a permanent `Remove from ignoreBinaries`
|
|
78
|
+
* hint the consumer has no way to silence.
|
|
76
79
|
*/
|
|
77
80
|
ignoreBinaries?: string[]
|
|
78
81
|
/** Merged with the built-in lists, never replacing them. */
|
|
@@ -144,7 +147,7 @@ export const createKnipConfig = (options: {
|
|
|
144
147
|
// boolean. It only hides an export that its own file already uses: an
|
|
145
148
|
// export nothing references at all still fails the gate.
|
|
146
149
|
ignoreExportsUsedInFile: true,
|
|
147
|
-
ignoreBinaries: options.ignoreBinaries ?? [],
|
|
150
|
+
ignoreBinaries: ['gitleaks', ...(options.ignoreBinaries ?? [])],
|
|
148
151
|
ignoreDependencies: [
|
|
149
152
|
...BASELINE_RUNNER_DEPENDENCIES,
|
|
150
153
|
...ESLINT_PEER_DEPENDENCIES,
|