@nodeve/checks 0.5.0 → 1.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.md +19 -1
- package/dist/bin/clones.d.ts +3 -0
- package/dist/bin/clones.d.ts.map +1 -0
- package/dist/bin/clones.js +59 -0
- package/dist/bin/clones.js.map +1 -0
- package/dist/bin/helper-collisions.js +12 -5
- package/dist/bin/helper-collisions.js.map +1 -1
- package/dist/bin/inline-dupes.js +2 -2
- package/dist/bin/inline-dupes.js.map +1 -1
- package/dist/lib/ast.d.ts +4 -0
- package/dist/lib/ast.d.ts.map +1 -0
- package/dist/lib/ast.js +14 -0
- package/dist/lib/ast.js.map +1 -0
- package/dist/lib/config.d.ts +36 -1
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +6 -40
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/defaults.d.ts +79 -0
- package/dist/lib/defaults.d.ts.map +1 -0
- package/dist/lib/defaults.js +79 -0
- package/dist/lib/defaults.js.map +1 -0
- package/dist/lib/manifest-ast.d.ts.map +1 -1
- package/dist/lib/manifest-ast.js +3 -4
- package/dist/lib/manifest-ast.js.map +1 -1
- package/lefthook.checks.yml +7 -0
- package/nodeve.checks.defaults.js +79 -0
- package/package.json +10 -4
- package/nodeve.checks.example.js +0 -50
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ Then activate hooks once per clone with `lefthook install` (familiar/nodeve do t
|
|
|
19
19
|
|
|
20
20
|
## Configure
|
|
21
21
|
|
|
22
|
-
Copy `node_modules/@nodeve/checks/nodeve.checks.
|
|
22
|
+
Copy `node_modules/@nodeve/checks/nodeve.checks.defaults.js` to your repo root as `nodeve.checks.js` and keep ONLY the keys you change. That file is the org defaults verbatim — a valid `nodeve.checks.js` in the exact shape your config takes — so it doubles as the reference for every section and its default value. Omitted keys fall back to those defaults (deep-merged; arrays replace wholesale). It's importable too: `import DEFAULTS from '@nodeve/checks/defaults'`.
|
|
23
23
|
|
|
24
24
|
## Checks
|
|
25
25
|
|
|
@@ -29,6 +29,7 @@ Copy `node_modules/@nodeve/checks/nodeve.checks.example.js` to your repo root as
|
|
|
29
29
|
| `nodeve-check-reshape` | callbacks that reproduce their input shape (no-op / pick / clone) | on (`apps/`, `packages/`) |
|
|
30
30
|
| `nodeve-check-inline-dupes` | non-exported top-level names declared in 2+ files | on (`apps/`, `packages/`) |
|
|
31
31
|
| `nodeve-check-helper-collisions` | local helpers that fuzzily match a dependency export | on (needs lib-names index) |
|
|
32
|
+
| `nodeve-check-clones` | structural copy-paste (duplicated code blocks) via jscpd v5 | on (`apps/`, `packages/`; no-op if the jscpd binary isn't installed) |
|
|
32
33
|
| `nodeve-check-page-size` | files over a per-glob line budget | on (`*+page.svelte` >280; no-op where the glob matches nothing) |
|
|
33
34
|
| `nodeve-check-file-size` | TS sources over a line budget (warn >225, fail >300) | on (`apps/`, `packages/`) |
|
|
34
35
|
| `nodeve-check-catalog` | dependency versions not single-sourced from a workspace catalog | on (a workspace must declare a catalog) |
|
|
@@ -38,6 +39,23 @@ Copy `node_modules/@nodeve/checks/nodeve.checks.example.js` to your repo root as
|
|
|
38
39
|
|
|
39
40
|
`catalog` works with both pnpm (catalog in `pnpm-workspace.yaml`) and Bun (catalog in `package.json#workspaces`) — it auto-detects whichever the repo uses. A workspace is **required** to declare a catalog: a repo with none fails the gate, since the point is keeping versions aligned. Every dependency (deps, devDeps, and peers alike) must reference `catalog:` rather than a literal pin. Opt a repo out deliberately with `catalog: { enforce: false }`.
|
|
40
41
|
|
|
42
|
+
`helper-collisions` compares local helper declarations to dependency function exports in `.nodeve/lib-names.json`. Some libraries expose generic function names whose domain is implied by the package name, such as `date-fns.format`; configure `helperCollisions.libKeywords` to also match each real export with those domain words appended/prepended:
|
|
43
|
+
|
|
44
|
+
```js
|
|
45
|
+
export default {
|
|
46
|
+
helperCollisions: {
|
|
47
|
+
libs: ['remeda', 'date-fns'],
|
|
48
|
+
libKeywords: { 'date-fns': ['Date'] },
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
With that config, `formatDate` reports as a collision with `date-fns.format`, while the recommended function remains the real dependency export.
|
|
54
|
+
|
|
55
|
+
A reinvention often borrows a _different_ library's name, which shares no tokens with the blessed export — lodash's `upperFirst` is remeda's `capitalize`. `helperCollisions.aliases` maps each real export to the other names it's known by, so those still match; the defaults seed the common lodash→remeda renames (`capitalize: ['upperFirst']`, `fromEntries: ['fromPairs']`, …).
|
|
56
|
+
|
|
57
|
+
`clones` is the structural counterpart to the name-based gates: it shells [jscpd v5](https://jscpd.dev) (a fast Rust copy-paste detector) over `clones.paths` and fails on any duplicated block past `clones.minTokens`/`minLines`. It catches reuse hiding in function _bodies_ that `inline-dupes`/`helper-collisions` can't see by name. Tune `minTokens`/`threshold`, narrow with `clones.ignore` globs, or `--warn` to downgrade. jscpd's native binary is an optional dependency, so the gate cleanly no-ops where it isn't installed rather than blocking a commit.
|
|
58
|
+
|
|
41
59
|
All blocking checks accept `--warn` (report-only, exit 0); `doc-tokens` accepts `--report` to list the whole backlog without failing. Pass explicit paths to scope a run (lefthook passes `{staged_files}`).
|
|
42
60
|
|
|
43
61
|
## Fixers
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clones.d.ts","sourceRoot":"","sources":["../../src/bin/clones.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Commit gate: structural copy-paste detector over the repo's own sources,
|
|
4
|
+
* backed by jscpd v5 (the Rust `cpd` binary). It flags duplicated *blocks* — the
|
|
5
|
+
* large clones living in function bodies, which the name-based gates
|
|
6
|
+
* (`inline-dupes`, `helper-collisions`) can't see. A clone is a whole-tree
|
|
7
|
+
* property, so like `inline-dupes` this scans the configured `paths` in full.
|
|
8
|
+
*
|
|
9
|
+
* jscpd does the detection, the reporting, AND the pass/fail (its `--threshold`),
|
|
10
|
+
* so this bin just shells it and surfaces its output — quiet on a clean run,
|
|
11
|
+
* printing jscpd's own clone listing when it fails. Escape hatches are jscpd's
|
|
12
|
+
* own: narrow scope with `clones.ignore` globs, or `--warn` to downgrade the
|
|
13
|
+
* whole gate to report-only.
|
|
14
|
+
*
|
|
15
|
+
* jscpd's platform binary ships as an optionalDependency, so a partial or offline
|
|
16
|
+
* install can leave it absent — then this no-ops (exit 0) rather than blocking the
|
|
17
|
+
* commit, matching `helper-collisions`'s behaviour when its lib index is missing.
|
|
18
|
+
*/
|
|
19
|
+
import { spawnSync } from 'node:child_process';
|
|
20
|
+
import { createRequire } from 'node:module';
|
|
21
|
+
import { loadGate } from '../lib/bin.js';
|
|
22
|
+
const { root, cfg, warn, verbose } = await loadGate('clones');
|
|
23
|
+
let launcher;
|
|
24
|
+
try {
|
|
25
|
+
launcher = createRequire(import.meta.url).resolve('jscpd/run-jscpd.js');
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
if (verbose)
|
|
29
|
+
console.log('clones: jscpd binary not installed — skipping');
|
|
30
|
+
process.exit(0);
|
|
31
|
+
}
|
|
32
|
+
// Missing dirs (e.g. `apps/` in a repo that has none) are tolerated by jscpd, so
|
|
33
|
+
// the configured paths go through as-is. `--absolute` makes the reported paths
|
|
34
|
+
// unambiguous and clickable regardless of which path arg they came from.
|
|
35
|
+
const jscpdRun = spawnSync(process.execPath, [
|
|
36
|
+
launcher,
|
|
37
|
+
...cfg.paths,
|
|
38
|
+
'--absolute',
|
|
39
|
+
'--min-tokens', String(cfg.minTokens),
|
|
40
|
+
'--min-lines', String(cfg.minLines),
|
|
41
|
+
'--mode', cfg.mode,
|
|
42
|
+
'--format', cfg.formats.join(','),
|
|
43
|
+
'--ignore', cfg.ignore.join(','),
|
|
44
|
+
'--reporters', 'console',
|
|
45
|
+
'--threshold', String(cfg.threshold),
|
|
46
|
+
], { cwd: root, encoding: 'utf8' });
|
|
47
|
+
// jscpd exits non-zero only when duplication crosses `--threshold`. Stay silent on
|
|
48
|
+
// a clean run (unless --verbose); on a violation print jscpd's clone listing and
|
|
49
|
+
// fail — `--warn` downgrades that to report-only.
|
|
50
|
+
if (jscpdRun.status === 0) {
|
|
51
|
+
if (verbose)
|
|
52
|
+
process.stdout.write(jscpdRun.stdout ?? '');
|
|
53
|
+
process.exit(0);
|
|
54
|
+
}
|
|
55
|
+
process.stdout.write(jscpdRun.stdout ?? '');
|
|
56
|
+
if (jscpdRun.stderr)
|
|
57
|
+
process.stderr.write(jscpdRun.stderr);
|
|
58
|
+
process.exit(warn ? 0 : (jscpdRun.status ?? 1));
|
|
59
|
+
//# sourceMappingURL=clones.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clones.js","sourceRoot":"","sources":["../../src/bin/clones.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAE9D,IAAI,QAAgB,CAAC;AACrB,IAAI,CAAC;IACJ,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC;AACzE,CAAC;AAAC,MAAM,CAAC;IACR,IAAI,OAAO;QAAE,OAAO,CAAC,GAAG,CAAC,+CAA+C,CAAC,CAAC;IAC1E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACjB,CAAC;AAED,iFAAiF;AACjF,+EAA+E;AAC/E,yEAAyE;AACzE,MAAM,QAAQ,GAAG,SAAS,CACzB,OAAO,CAAC,QAAQ,EAChB;IACC,QAAQ;IACR,GAAG,GAAG,CAAC,KAAK;IACZ,YAAY;IACZ,cAAc,EAAE,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC;IACrC,aAAa,EAAE,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IACnC,QAAQ,EAAE,GAAG,CAAC,IAAI;IAClB,UAAU,EAAE,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC;IACjC,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;IAChC,aAAa,EAAE,SAAS;IACxB,aAAa,EAAE,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC;CACpC,EACD,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,CAC/B,CAAC;AAEF,mFAAmF;AACnF,iFAAiF;AACjF,kDAAkD;AAClD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;IAC3B,IAAI,OAAO;QAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC;IACzD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACjB,CAAC;AACD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC;AAC5C,IAAI,QAAQ,CAAC,MAAM;IAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAC3D,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -14,10 +14,11 @@
|
|
|
14
14
|
* regen with `nodeve-build-lib-names`). The index is committed so the gate has no
|
|
15
15
|
* runtime dependency on the libs being installed.
|
|
16
16
|
*/
|
|
17
|
-
import {
|
|
17
|
+
import { identifierSimilarityMatch } from '@nodeve/text/similarity';
|
|
18
18
|
import { existsSync, readFileSync } from 'node:fs';
|
|
19
19
|
import { join } from 'node:path';
|
|
20
20
|
import ts from 'typescript';
|
|
21
|
+
import { parseSource } from '../lib/ast.js';
|
|
21
22
|
import { loadGate, tsSources } from '../lib/bin.js';
|
|
22
23
|
const { root, cfg, paths, warn, verbose, allowlist } = await loadGate('helperCollisions');
|
|
23
24
|
function loadLibIndex() {
|
|
@@ -31,7 +32,7 @@ function loadLibIndex() {
|
|
|
31
32
|
}
|
|
32
33
|
/** Top-level `function` / arrow-const declaration names in a source file. */
|
|
33
34
|
function declaredFunctionNames(absPath) {
|
|
34
|
-
const src =
|
|
35
|
+
const src = parseSource(absPath);
|
|
35
36
|
const out = [];
|
|
36
37
|
for (const stmt of src.statements) {
|
|
37
38
|
if (ts.isFunctionDeclaration(stmt) && stmt.name)
|
|
@@ -48,9 +49,14 @@ function declaredFunctionNames(absPath) {
|
|
|
48
49
|
function bestMatch(name, libIndex) {
|
|
49
50
|
let best = null;
|
|
50
51
|
for (const lib of libIndex) {
|
|
51
|
-
const
|
|
52
|
+
const match = identifierSimilarityMatch(name, lib.name, {
|
|
53
|
+
keywords: cfg.libKeywords[lib.lib],
|
|
54
|
+
aliases: cfg.aliases[lib.name],
|
|
55
|
+
});
|
|
56
|
+
const matched = match.matchedAs === lib.name ? lib : { ...lib, matchedAs: match.matchedAs };
|
|
57
|
+
const score = match.score;
|
|
52
58
|
if (!best || score > best.score)
|
|
53
|
-
best = { lib, score };
|
|
59
|
+
best = { lib: matched, score };
|
|
54
60
|
}
|
|
55
61
|
return best && best.score >= cfg.threshold ? best : null;
|
|
56
62
|
}
|
|
@@ -79,7 +85,8 @@ if (sorted.length === 0) {
|
|
|
79
85
|
console.log(`helper-collisions: ${sorted.length} local function(s) may reinvent a dependency export.\n` +
|
|
80
86
|
`Resolve per case — delete + import, wrap the lib, rename for specificity, or allowlist:\n`);
|
|
81
87
|
for (const f of sorted) {
|
|
82
|
-
|
|
88
|
+
const matchedAs = f.lib.matchedAs ? ` (matched ${f.lib.matchedAs})` : '';
|
|
89
|
+
console.log(` ${f.score.toFixed(2)} ${f.name} ≈ ${f.lib.lib}.${f.lib.name}${matchedAs}`);
|
|
83
90
|
for (const file of f.files)
|
|
84
91
|
console.log(` ${file}`);
|
|
85
92
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helper-collisions.js","sourceRoot":"","sources":["../../src/bin/helper-collisions.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"helper-collisions.js","sourceRoot":"","sources":["../../src/bin/helper-collisions.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAEpD,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,MAAM,QAAQ,CAAC,kBAAkB,CAAC,CAAC;AAI1F,SAAS,YAAY;IACpB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,YAAY,CAAC,CAAC;IAC1C,qEAAqE;IACrE,gFAAgF;IAChF,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,EAAE,CAAC;IACjC,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAwC,CAAC;IACh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S,EAAE,CAAC,CAAC;IAC7F,KAAK,MAAM,IAAI,IAAI,CAAC,CAAC,KAAK;QAAE,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,EAAE,CAAC,CAAC;AAChE,CAAC;AAED,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
package/dist/bin/inline-dupes.js
CHANGED
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
* scans the full configured scope, not just staged files — a dupe is a
|
|
18
18
|
* relationship between two files, so the second file landing must see the first.
|
|
19
19
|
*/
|
|
20
|
-
import { readFileSync } from 'node:fs';
|
|
21
20
|
import { join } from 'node:path';
|
|
22
21
|
import ts from 'typescript';
|
|
22
|
+
import { parseSource } from '../lib/ast.js';
|
|
23
23
|
import { loadGate, tsSources } from '../lib/bin.js';
|
|
24
24
|
const { root, cfg, warn, verbose, allowlist } = await loadGate('inlineDupes');
|
|
25
25
|
/**
|
|
@@ -28,7 +28,7 @@ const { root, cfg, warn, verbose, allowlist } = await loadGate('inlineDupes');
|
|
|
28
28
|
* HTTP verbs, etc.) are skipped — they're legitimately repeated per route.
|
|
29
29
|
*/
|
|
30
30
|
function topLevelNames(absPath) {
|
|
31
|
-
const src =
|
|
31
|
+
const src = parseSource(absPath);
|
|
32
32
|
const out = [];
|
|
33
33
|
for (const stmt of src.statements) {
|
|
34
34
|
const isExported = ts.canHaveModifiers(stmt) &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inline-dupes.js","sourceRoot":"","sources":["../../src/bin/inline-dupes.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"inline-dupes.js","sourceRoot":"","sources":["../../src/bin/inline-dupes.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;A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ACpE,6EAA6E;IAC7E,sFAAsF,CACvF,CAAC;AACF,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,KAAK,EAAE,CAAC;IACnC,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,MAAM,KAAK,CAAC,IAAI,SAAS,CAAC,CAAC;IAChD,KAAK,MAAM,IAAI,IAAI,KAAK;QAAE,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;AACtD,CAAC;AAED,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../src/lib/ast.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,mGAAmG;AACnG,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,EAAE,CAAC,UAAU,CAE1D"}
|
package/dist/lib/ast.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared TypeScript parsing for the source-scanning checks. Several gates open a
|
|
3
|
+
* file the same way — read it, parse with full position info, then walk the
|
|
4
|
+
* top-level statements — which is itself the kind of cross-file clone the
|
|
5
|
+
* `clones` and `inline-dupes` gates exist to flag. Centralized here so each
|
|
6
|
+
* caller parses once and differs only in what it extracts.
|
|
7
|
+
*/
|
|
8
|
+
import { readFileSync } from 'node:fs';
|
|
9
|
+
import ts from 'typescript';
|
|
10
|
+
/** Parse a source file into a full-AST `SourceFile` (positions kept, so callers can `getText`). */
|
|
11
|
+
export function parseSource(absPath) {
|
|
12
|
+
return ts.createSourceFile(absPath, readFileSync(absPath, 'utf8'), ts.ScriptTarget.Latest, true);
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=ast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast.js","sourceRoot":"","sources":["../../src/lib/ast.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,mGAAmG;AACnG,MAAM,UAAU,WAAW,CAAC,OAAe;IAC1C,OAAO,EAAE,CAAC,gBAAgB,CAAC,OAAO,EAAE,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAClG,CAAC"}
|
package/dist/lib/config.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import DEFAULTS from './defaults.js';
|
|
1
2
|
export type Budget = {
|
|
2
3
|
maxLines: number;
|
|
3
4
|
maxTokens: number;
|
|
@@ -24,12 +25,45 @@ export type HelperCollisionsConfig = {
|
|
|
24
25
|
globs: string[];
|
|
25
26
|
/** Dependency packages whose exports shouldn't be reinvented inline. */
|
|
26
27
|
libs: string[];
|
|
28
|
+
/** Domain words to append/prepend to each lib export during collision matching. */
|
|
29
|
+
libKeywords: Record<string, string[]>;
|
|
30
|
+
/**
|
|
31
|
+
* Alternate names a lib export is known by under *other* libraries, keyed by the
|
|
32
|
+
* real export name. Catches a reinvention that borrows a different library's
|
|
33
|
+
* vocabulary even though the names share no tokens — e.g. lodash's `upperFirst`
|
|
34
|
+
* is remeda's `capitalize`: `{ capitalize: ['upperFirst'] }`.
|
|
35
|
+
*/
|
|
36
|
+
aliases: Record<string, string[]>;
|
|
27
37
|
/** Repo-root-relative path to the committed lib-names index. */
|
|
28
38
|
libNamesPath: string;
|
|
29
39
|
threshold: number;
|
|
30
40
|
/** `relPath::local→lib` entries — confirmed false positives. */
|
|
31
41
|
allowlist: string[];
|
|
32
42
|
};
|
|
43
|
+
/**
|
|
44
|
+
* On by default: a structural copy-paste detector over the repo's own sources,
|
|
45
|
+
* backed by jscpd v5 (the Rust `cpd` binary). Catches duplicated *blocks* —
|
|
46
|
+
* clones living in function bodies that the name-based gates (`inline-dupes`,
|
|
47
|
+
* `helper-collisions`) can't see. A whole-tree property, so it scans `paths` in
|
|
48
|
+
* full rather than just staged files. jscpd itself does the gating via
|
|
49
|
+
* `--threshold`; no-ops if the jscpd binary isn't installed.
|
|
50
|
+
*/
|
|
51
|
+
export type ClonesConfig = {
|
|
52
|
+
/** Repo-root-relative dirs to scan (missing dirs are tolerated). */
|
|
53
|
+
paths: string[];
|
|
54
|
+
/** jscpd formats to tokenize (its `--format`). */
|
|
55
|
+
formats: string[];
|
|
56
|
+
/** Glob patterns jscpd ignores (its `--ignore`) — the file-level escape hatch. */
|
|
57
|
+
ignore: string[];
|
|
58
|
+
/** Minimum duplicated tokens to report a clone (jscpd `--min-tokens`). */
|
|
59
|
+
minTokens: number;
|
|
60
|
+
/** Minimum duplicated lines to report a clone (jscpd `--min-lines`). */
|
|
61
|
+
minLines: number;
|
|
62
|
+
/** jscpd detection mode: `mild` | `weak` | `strict`. */
|
|
63
|
+
mode: string;
|
|
64
|
+
/** Max duplication % jscpd tolerates before failing (its `--threshold`); 0 = any clone fails. */
|
|
65
|
+
threshold: number;
|
|
66
|
+
};
|
|
33
67
|
/** Opt-in: each rule fails when a file matching `glob` exceeds `maxLines`. */
|
|
34
68
|
export type PageSizeConfig = {
|
|
35
69
|
rules: {
|
|
@@ -89,13 +123,14 @@ export type Config = {
|
|
|
89
123
|
reshape: ReshapeConfig;
|
|
90
124
|
inlineDupes: InlineDupesConfig;
|
|
91
125
|
helperCollisions: HelperCollisionsConfig;
|
|
126
|
+
clones: ClonesConfig;
|
|
92
127
|
pageSize: PageSizeConfig;
|
|
93
128
|
fileSize: FileSizeConfig;
|
|
94
129
|
catalog: CatalogConfig;
|
|
95
130
|
requireDeps: RequireDepsConfig;
|
|
96
131
|
helperManifest: HelperManifestConfig;
|
|
97
132
|
};
|
|
98
|
-
export
|
|
133
|
+
export { DEFAULTS };
|
|
99
134
|
/**
|
|
100
135
|
* Load `nodeve.checks.*` from the repo root, deep-merging the user config over
|
|
101
136
|
* DEFAULTS. Nested records (e.g. `docTokens.overrides`) merge key-by-key; arrays
|
package/dist/lib/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAgBA,OAAO,QAAQ,MAAM,eAAe,CAAC;AAErC,MAAM,MAAM,MAAM,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7D,MAAM,MAAM,eAAe,GAAG;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,+EAA+E;IAC/E,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,mEAAmE;IACnE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;CAC3C,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC3B,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,mFAAmF;IACnF,SAAS,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC/B,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,uDAAuD;IACvD,SAAS,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACpC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,wEAAwE;IACxE,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,mFAAmF;IACnF,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACtC;;;;;OAKG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,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GAMG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC/B,4DAA4D;IAC5D,IAAI,EAAE,MAAM,EAAE,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACpB,SAAS,EAAE,eAAe,CAAC;IAC3B,OAAO,EAAE,aAAa,CAAC;IACvB,WAAW,EAAE,iBAAiB,CAAC;IAC/B,gBAAgB,EAAE,sBAAsB,CAAC;IACzC,MAAM,EAAE,YAAY,CAAC;IACrB,QAAQ,EAAE,cAAc,CAAC;IACzB,QAAQ,EAAE,cAAc,CAAC;IACzB,OAAO,EAAE,aAAa,CAAC;IACvB,WAAW,EAAE,iBAAiB,CAAC;IAC/B,cAAc,EAAE,oBAAoB,CAAC;CACrC,CAAC;AAMF,OAAO,EAAE,QAAQ,EAAE,CAAC;AAMpB;;;;;GAKG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAS9D;AAED,wEAAwE;AACxE,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG;IAC1C,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;CACjB,CAOA"}
|
package/dist/lib/config.js
CHANGED
|
@@ -14,46 +14,12 @@ import { existsSync } from 'node:fs';
|
|
|
14
14
|
import { join } from 'node:path';
|
|
15
15
|
import { pathToFileURL } from 'node:url';
|
|
16
16
|
import { mergeDeep } from 'remeda';
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
},
|
|
24
|
-
reshape: {
|
|
25
|
-
globs: ['apps/*.ts', 'packages/*.ts'],
|
|
26
|
-
allowlist: [],
|
|
27
|
-
},
|
|
28
|
-
inlineDupes: {
|
|
29
|
-
globs: ['apps/*.ts', 'packages/*.ts'],
|
|
30
|
-
allowlist: [],
|
|
31
|
-
},
|
|
32
|
-
helperCollisions: {
|
|
33
|
-
globs: ['apps/*.ts', 'packages/*.ts'],
|
|
34
|
-
libs: ['remeda'],
|
|
35
|
-
libNamesPath: '.nodeve/lib-names.json',
|
|
36
|
-
threshold: 0.8,
|
|
37
|
-
allowlist: [],
|
|
38
|
-
},
|
|
39
|
-
// On by default: SvelteKit pages over 280 lines should rip inline components
|
|
40
|
-
// out into their own files. The `*+page.svelte` glob is a no-op in repos with
|
|
41
|
-
// no SvelteKit pages, so this stays harmless org-wide. Override per repo.
|
|
42
|
-
pageSize: { rules: [{ glob: '*+page.svelte', maxLines: 280 }] },
|
|
43
|
-
// On by default: warn past 225 lines, block past 300 (override per repo).
|
|
44
|
-
fileSize: {
|
|
45
|
-
globs: ['apps/*.ts', 'packages/*.ts'],
|
|
46
|
-
warnLines: 225,
|
|
47
|
-
maxLines: 300,
|
|
48
|
-
allowlist: [],
|
|
49
|
-
},
|
|
50
|
-
// On by default: a workspace must declare a catalog (set enforce:false to opt out).
|
|
51
|
-
catalog: { enforce: true, allowlist: [] },
|
|
52
|
-
// On by default: the workspace catalog must define remeda (set deps:[] to opt out).
|
|
53
|
-
requireDeps: { deps: ['remeda'] },
|
|
54
|
-
// Opt-in: no packages → no-op.
|
|
55
|
-
helperManifest: { packages: [], output: '.nodeve/helper-manifest.txt' },
|
|
56
|
-
};
|
|
17
|
+
import DEFAULTS from './defaults.js';
|
|
18
|
+
// The authoritative defaults live in `./defaults.ts`, which is itself a valid
|
|
19
|
+
// `nodeve.checks.js` (a bare `export default {...}`) so it doubles as the copyable
|
|
20
|
+
// reference shipped to consumers. Re-exported here to keep the `@nodeve/checks/config`
|
|
21
|
+
// public surface intact.
|
|
22
|
+
export { DEFAULTS };
|
|
57
23
|
const CONFIG_FILES = ['nodeve.checks.js', 'nodeve.checks.mjs', 'nodeve.checks.config.js'];
|
|
58
24
|
/**
|
|
59
25
|
* Load `nodeve.checks.*` from the repo root, deep-merging the user config over
|
package/dist/lib/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,QAAQ,MAAM,eAAe,CAAC;AA2IrC,8EAA8E;AAC9E,mFAAmF;AACnF,uFAAuF;AACvF,yBAAyB;AACzB,OAAO,EAAE,QAAQ,EAAE,CAAC;AAEpB,MAAM,YAAY,GAAG,CAAC,kBAAkB,EAAE,mBAAmB,EAAE,yBAAyB,CAAC,CAAC;AAI1F;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,IAAY;IAC5C,KAAK,MAAM,IAAI,IAAI,YAAY,EAAE,CAAC;QACjC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC9B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;YAAE,SAAS;QAChC,MAAM,GAAG,GAAG,CAAC,MAAM,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAsC,CAAC;QAC1F,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,IAAK,GAA2B,CAAC;QACzD,OAAO,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAW,CAAC;IAC5C,CAAC;IACD,OAAO,QAAQ,CAAC;AACjB,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,SAAS,CAAC,IAAc;IAMvC,OAAO;QACN,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAC9C,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAC7B,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC;QACjC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;KACnC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The org defaults for @nodeve/checks — the single source of truth.
|
|
3
|
+
*
|
|
4
|
+
* This file IS a valid `nodeve.checks.js`: it's the exact shape a repo drops at
|
|
5
|
+
* its root, default-exporting the config object. To customize, copy it (shipped
|
|
6
|
+
* as `node_modules/@nodeve/checks/nodeve.checks.defaults.js`) to your repo root
|
|
7
|
+
* as `nodeve.checks.js` and keep ONLY the keys you change — everything you omit
|
|
8
|
+
* falls back to the value here.
|
|
9
|
+
*
|
|
10
|
+
* Merge semantics (see `loadConfig`): your config is deep-merged OVER these
|
|
11
|
+
* defaults. Nested records merge key-by-key, but ARRAYS REPLACE wholesale — so
|
|
12
|
+
* if you set an array field (e.g. `docTokens.enforce`) you must restate every
|
|
13
|
+
* entry you want to keep, not just the ones you're adding.
|
|
14
|
+
*/
|
|
15
|
+
declare const _default: {
|
|
16
|
+
docTokens: {
|
|
17
|
+
maxLines: number;
|
|
18
|
+
maxTokens: number;
|
|
19
|
+
enforce: string[];
|
|
20
|
+
overrides: {};
|
|
21
|
+
};
|
|
22
|
+
reshape: {
|
|
23
|
+
globs: string[];
|
|
24
|
+
allowlist: never[];
|
|
25
|
+
};
|
|
26
|
+
inlineDupes: {
|
|
27
|
+
globs: string[];
|
|
28
|
+
allowlist: never[];
|
|
29
|
+
};
|
|
30
|
+
helperCollisions: {
|
|
31
|
+
globs: string[];
|
|
32
|
+
libs: string[];
|
|
33
|
+
libKeywords: {};
|
|
34
|
+
aliases: {
|
|
35
|
+
capitalize: string[];
|
|
36
|
+
uncapitalize: string[];
|
|
37
|
+
first: string[];
|
|
38
|
+
flat: string[];
|
|
39
|
+
fromEntries: string[];
|
|
40
|
+
};
|
|
41
|
+
libNamesPath: string;
|
|
42
|
+
threshold: number;
|
|
43
|
+
allowlist: never[];
|
|
44
|
+
};
|
|
45
|
+
clones: {
|
|
46
|
+
paths: string[];
|
|
47
|
+
formats: string[];
|
|
48
|
+
ignore: string[];
|
|
49
|
+
minTokens: number;
|
|
50
|
+
minLines: number;
|
|
51
|
+
mode: string;
|
|
52
|
+
threshold: number;
|
|
53
|
+
};
|
|
54
|
+
pageSize: {
|
|
55
|
+
rules: {
|
|
56
|
+
glob: string;
|
|
57
|
+
maxLines: number;
|
|
58
|
+
}[];
|
|
59
|
+
};
|
|
60
|
+
fileSize: {
|
|
61
|
+
globs: string[];
|
|
62
|
+
warnLines: number;
|
|
63
|
+
maxLines: number;
|
|
64
|
+
allowlist: never[];
|
|
65
|
+
};
|
|
66
|
+
catalog: {
|
|
67
|
+
enforce: true;
|
|
68
|
+
allowlist: never[];
|
|
69
|
+
};
|
|
70
|
+
requireDeps: {
|
|
71
|
+
deps: string[];
|
|
72
|
+
};
|
|
73
|
+
helperManifest: {
|
|
74
|
+
packages: never[];
|
|
75
|
+
output: string;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
export default _default;
|
|
79
|
+
//# sourceMappingURL=defaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/lib/defaults.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACH,wBA+DmB"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The org defaults for @nodeve/checks — the single source of truth.
|
|
3
|
+
*
|
|
4
|
+
* This file IS a valid `nodeve.checks.js`: it's the exact shape a repo drops at
|
|
5
|
+
* its root, default-exporting the config object. To customize, copy it (shipped
|
|
6
|
+
* as `node_modules/@nodeve/checks/nodeve.checks.defaults.js`) to your repo root
|
|
7
|
+
* as `nodeve.checks.js` and keep ONLY the keys you change — everything you omit
|
|
8
|
+
* falls back to the value here.
|
|
9
|
+
*
|
|
10
|
+
* Merge semantics (see `loadConfig`): your config is deep-merged OVER these
|
|
11
|
+
* defaults. Nested records merge key-by-key, but ARRAYS REPLACE wholesale — so
|
|
12
|
+
* if you set an array field (e.g. `docTokens.enforce`) you must restate every
|
|
13
|
+
* entry you want to keep, not just the ones you're adding.
|
|
14
|
+
*/
|
|
15
|
+
export default {
|
|
16
|
+
docTokens: {
|
|
17
|
+
maxLines: 150,
|
|
18
|
+
maxTokens: 3000,
|
|
19
|
+
// Git pathspecs the gate FAILS on: CLAUDE.md + READMEs + guide/ + docs/.
|
|
20
|
+
enforce: ['CLAUDE.md', 'README.md', '*/README.md', 'guide/*.md', 'docs/*.md'],
|
|
21
|
+
// Per-file budget bumps, keyed by repo-root-relative path.
|
|
22
|
+
overrides: {},
|
|
23
|
+
},
|
|
24
|
+
reshape: {
|
|
25
|
+
globs: ['apps/*.ts', 'packages/*.ts'],
|
|
26
|
+
allowlist: [],
|
|
27
|
+
},
|
|
28
|
+
inlineDupes: {
|
|
29
|
+
globs: ['apps/*.ts', 'packages/*.ts'],
|
|
30
|
+
allowlist: [],
|
|
31
|
+
},
|
|
32
|
+
helperCollisions: {
|
|
33
|
+
globs: ['apps/*.ts', 'packages/*.ts'],
|
|
34
|
+
libs: ['remeda'],
|
|
35
|
+
libKeywords: {},
|
|
36
|
+
// Seeded with the lodash→remeda renames (keyed by the remeda export). The org
|
|
37
|
+
// standardizes on remeda, but reinventions often borrow lodash's names, which
|
|
38
|
+
// share no tokens with remeda's — so without these the fuzzy match misses them.
|
|
39
|
+
aliases: {
|
|
40
|
+
capitalize: ['upperFirst'],
|
|
41
|
+
uncapitalize: ['lowerFirst'],
|
|
42
|
+
first: ['head'],
|
|
43
|
+
flat: ['flatten', 'flattenDeep'],
|
|
44
|
+
fromEntries: ['fromPairs'],
|
|
45
|
+
},
|
|
46
|
+
libNamesPath: '.nodeve/lib-names.json',
|
|
47
|
+
threshold: 0.8,
|
|
48
|
+
allowlist: [],
|
|
49
|
+
},
|
|
50
|
+
// On by default: structural copy-paste detection (jscpd v5). No-ops if the
|
|
51
|
+
// jscpd binary isn't installed. `apps/` is skipped when absent.
|
|
52
|
+
clones: {
|
|
53
|
+
paths: ['apps', 'packages'],
|
|
54
|
+
formats: ['typescript', 'javascript'],
|
|
55
|
+
ignore: ['**/node_modules/**', '**/dist/**', '**/*.d.ts', '**/*.test.ts', '**/*.spec.ts'],
|
|
56
|
+
minTokens: 50,
|
|
57
|
+
minLines: 5,
|
|
58
|
+
mode: 'mild',
|
|
59
|
+
threshold: 0,
|
|
60
|
+
},
|
|
61
|
+
// On by default: SvelteKit pages over 280 lines should rip inline components
|
|
62
|
+
// out into their own files. The `*+page.svelte` glob is a no-op in repos with
|
|
63
|
+
// no SvelteKit pages, so this stays harmless org-wide. Override per repo.
|
|
64
|
+
pageSize: { rules: [{ glob: '*+page.svelte', maxLines: 280 }] },
|
|
65
|
+
// On by default: warn past 225 lines, block past 300 (override per repo).
|
|
66
|
+
fileSize: {
|
|
67
|
+
globs: ['apps/*.ts', 'packages/*.ts'],
|
|
68
|
+
warnLines: 225,
|
|
69
|
+
maxLines: 300,
|
|
70
|
+
allowlist: [],
|
|
71
|
+
},
|
|
72
|
+
// On by default: a workspace must declare a catalog (set enforce:false to opt out).
|
|
73
|
+
catalog: { enforce: true, allowlist: [] },
|
|
74
|
+
// On by default: the workspace catalog must define remeda (set deps:[] to opt out).
|
|
75
|
+
requireDeps: { deps: ['remeda'] },
|
|
76
|
+
// Opt-in: no packages → no-op.
|
|
77
|
+
helperManifest: { packages: [], output: '.nodeve/helper-manifest.txt' },
|
|
78
|
+
};
|
|
79
|
+
//# sourceMappingURL=defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../src/lib/defaults.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,eAAe;IACd,SAAS,EAAE;QACV,QAAQ,EAAE,GAAG;QACb,SAAS,EAAE,IAAI;QACf,yEAAyE;QACzE,OAAO,EAAE,CAAC,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,WAAW,CAAC;QAC7E,2DAA2D;QAC3D,SAAS,EAAE,EAAE;KACb;IACD,OAAO,EAAE;QACR,KAAK,EAAE,CAAC,WAAW,EAAE,eAAe,CAAC;QACrC,SAAS,EAAE,EAAE;KACb;IACD,WAAW,EAAE;QACZ,KAAK,EAAE,CAAC,WAAW,EAAE,eAAe,CAAC;QACrC,SAAS,EAAE,EAAE;KACb;IACD,gBAAgB,EAAE;QACjB,KAAK,EAAE,CAAC,WAAW,EAAE,eAAe,CAAC;QACrC,IAAI,EAAE,CAAC,QAAQ,CAAC;QAChB,WAAW,EAAE,EAAE;QACf,8EAA8E;QAC9E,8EAA8E;QAC9E,gFAAgF;QAChF,OAAO,EAAE;YACR,UAAU,EAAE,CAAC,YAAY,CAAC;YAC1B,YAAY,EAAE,CAAC,YAAY,CAAC;YAC5B,KAAK,EAAE,CAAC,MAAM,CAAC;YACf,IAAI,EAAE,CAAC,SAAS,EAAE,aAAa,CAAC;YAChC,WAAW,EAAE,CAAC,WAAW,CAAC;SAC1B;QACD,YAAY,EAAE,wBAAwB;QACtC,SAAS,EAAE,GAAG;QACd,SAAS,EAAE,EAAE;KACb;IACD,2EAA2E;IAC3E,gEAAgE;IAChE,MAAM,EAAE;QACP,KAAK,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC;QAC3B,OAAO,EAAE,CAAC,YAAY,EAAE,YAAY,CAAC;QACrC,MAAM,EAAE,CAAC,oBAAoB,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,cAAc,CAAC;QACzF,SAAS,EAAE,EAAE;QACb,QAAQ,EAAE,CAAC;QACX,IAAI,EAAE,MAAM;QACZ,SAAS,EAAE,CAAC;KACZ;IACD,6EAA6E;IAC7E,8EAA8E;IAC9E,0EAA0E;IAC1E,QAAQ,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE;IAC/D,0EAA0E;IAC1E,QAAQ,EAAE;QACT,KAAK,EAAE,CAAC,WAAW,EAAE,eAAe,CAAC;QACrC,SAAS,EAAE,GAAG;QACd,QAAQ,EAAE,GAAG;QACb,SAAS,EAAE,EAAE;KACb;IACD,oFAAoF;IACpF,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE;IACzC,oFAAoF;IACpF,WAAW,EAAE,EAAE,IAAI,EAAE,CAAC,QAAQ,CAAC,EAAE;IACjC,+BAA+B;IAC/B,cAAc,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,6BAA6B,EAAE;CACtD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest-ast.d.ts","sourceRoot":"","sources":["../../src/lib/manifest-ast.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"manifest-ast.d.ts","sourceRoot":"","sources":["../../src/lib/manifest-ast.ts"],"names":[],"mappings":"AAaA,MAAM,MAAM,IAAI,GAAG,IAAI,GAAG,OAAO,GAAG,OAAO,GAAG,WAAW,CAAC;AAE1D,qFAAqF;AACrF,MAAM,MAAM,IAAI,GAAG;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtE,MAAM,MAAM,QAAQ,GAAG;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,CAAC;AAEtG,MAAM,MAAM,MAAM,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC;AAahE;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAyBtD;AAaD,wFAAwF;AACxF,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAuCpE;AAED,mEAAmE;AACnE,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAI5E;AAED,sFAAsF;AACtF,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,QAAQ,EAAE,CAoB1D;AAaD,6EAA6E;AAC7E,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAgBlD"}
|
package/dist/lib/manifest-ast.js
CHANGED
|
@@ -9,6 +9,7 @@ import { trimText } from '@nodeve/text/trim';
|
|
|
9
9
|
import { existsSync, readFileSync } from 'node:fs';
|
|
10
10
|
import { join } from 'node:path';
|
|
11
11
|
import ts from 'typescript';
|
|
12
|
+
import { parseSource } from './ast.js';
|
|
12
13
|
/** Leading JSDoc block of a node as a single capped line. */
|
|
13
14
|
function jsDocSummary(node) {
|
|
14
15
|
const docs = node.jsDoc;
|
|
@@ -60,8 +61,7 @@ function fnSignature(name, params, returnType, source) {
|
|
|
60
61
|
/** Map every top-level declared name in a source file to its kind/signature/summary. */
|
|
61
62
|
export function declarationsOf(sourcePath) {
|
|
62
63
|
const out = new Map();
|
|
63
|
-
const
|
|
64
|
-
const source = ts.createSourceFile(sourcePath, text, ts.ScriptTarget.Latest, true);
|
|
64
|
+
const source = parseSource(sourcePath);
|
|
65
65
|
for (const stmt of source.statements) {
|
|
66
66
|
if (ts.isFunctionDeclaration(stmt) && stmt.name) {
|
|
67
67
|
const name = stmt.name.text;
|
|
@@ -111,8 +111,7 @@ export function resolveSource(barrelDir, spec) {
|
|
|
111
111
|
}
|
|
112
112
|
/** Parse a barrel's `export { … } from './…'` declarations into re-export records. */
|
|
113
113
|
export function reExportsOf(barrelPath) {
|
|
114
|
-
const
|
|
115
|
-
const source = ts.createSourceFile(barrelPath, text, ts.ScriptTarget.Latest, true);
|
|
114
|
+
const source = parseSource(barrelPath);
|
|
116
115
|
const out = [];
|
|
117
116
|
for (const stmt of source.statements) {
|
|
118
117
|
if (!ts.isExportDeclaration(stmt) || !stmt.moduleSpecifier)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest-ast.js","sourceRoot":"","sources":["../../src/lib/manifest-ast.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"manifest-ast.js","sourceRoot":"","sources":["../../src/lib/manifest-ast.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE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AC;AACZ,CAAC"}
|
package/lefthook.checks.yml
CHANGED
|
@@ -73,6 +73,13 @@ pre-commit:
|
|
|
73
73
|
glob: "*.ts"
|
|
74
74
|
run: node_modules/.bin/nodeve-check-inline-dupes
|
|
75
75
|
|
|
76
|
+
# Whole-tree property — structural copy-paste (jscpd). A clone is a
|
|
77
|
+
# relationship between two places, so it scans the full configured scope.
|
|
78
|
+
# No-ops if the jscpd binary isn't installed.
|
|
79
|
+
- name: clones
|
|
80
|
+
glob: "*.{ts,js}"
|
|
81
|
+
run: node_modules/.bin/nodeve-check-clones
|
|
82
|
+
|
|
76
83
|
- name: helper-collisions
|
|
77
84
|
glob: "*.ts"
|
|
78
85
|
run: node_modules/.bin/nodeve-check-helper-collisions {staged_files}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The org defaults for @nodeve/checks — the single source of truth.
|
|
3
|
+
*
|
|
4
|
+
* This file IS a valid `nodeve.checks.js`: it's the exact shape a repo drops at
|
|
5
|
+
* its root, default-exporting the config object. To customize, copy it (shipped
|
|
6
|
+
* as `node_modules/@nodeve/checks/nodeve.checks.defaults.js`) to your repo root
|
|
7
|
+
* as `nodeve.checks.js` and keep ONLY the keys you change — everything you omit
|
|
8
|
+
* falls back to the value here.
|
|
9
|
+
*
|
|
10
|
+
* Merge semantics (see `loadConfig`): your config is deep-merged OVER these
|
|
11
|
+
* defaults. Nested records merge key-by-key, but ARRAYS REPLACE wholesale — so
|
|
12
|
+
* if you set an array field (e.g. `docTokens.enforce`) you must restate every
|
|
13
|
+
* entry you want to keep, not just the ones you're adding.
|
|
14
|
+
*/
|
|
15
|
+
export default {
|
|
16
|
+
docTokens: {
|
|
17
|
+
maxLines: 150,
|
|
18
|
+
maxTokens: 3000,
|
|
19
|
+
// Git pathspecs the gate FAILS on: CLAUDE.md + READMEs + guide/ + docs/.
|
|
20
|
+
enforce: ['CLAUDE.md', 'README.md', '*/README.md', 'guide/*.md', 'docs/*.md'],
|
|
21
|
+
// Per-file budget bumps, keyed by repo-root-relative path.
|
|
22
|
+
overrides: {},
|
|
23
|
+
},
|
|
24
|
+
reshape: {
|
|
25
|
+
globs: ['apps/*.ts', 'packages/*.ts'],
|
|
26
|
+
allowlist: [],
|
|
27
|
+
},
|
|
28
|
+
inlineDupes: {
|
|
29
|
+
globs: ['apps/*.ts', 'packages/*.ts'],
|
|
30
|
+
allowlist: [],
|
|
31
|
+
},
|
|
32
|
+
helperCollisions: {
|
|
33
|
+
globs: ['apps/*.ts', 'packages/*.ts'],
|
|
34
|
+
libs: ['remeda'],
|
|
35
|
+
libKeywords: {},
|
|
36
|
+
// Seeded with the lodash→remeda renames (keyed by the remeda export). The org
|
|
37
|
+
// standardizes on remeda, but reinventions often borrow lodash's names, which
|
|
38
|
+
// share no tokens with remeda's — so without these the fuzzy match misses them.
|
|
39
|
+
aliases: {
|
|
40
|
+
capitalize: ['upperFirst'],
|
|
41
|
+
uncapitalize: ['lowerFirst'],
|
|
42
|
+
first: ['head'],
|
|
43
|
+
flat: ['flatten', 'flattenDeep'],
|
|
44
|
+
fromEntries: ['fromPairs'],
|
|
45
|
+
},
|
|
46
|
+
libNamesPath: '.nodeve/lib-names.json',
|
|
47
|
+
threshold: 0.8,
|
|
48
|
+
allowlist: [],
|
|
49
|
+
},
|
|
50
|
+
// On by default: structural copy-paste detection (jscpd v5). No-ops if the
|
|
51
|
+
// jscpd binary isn't installed. `apps/` is skipped when absent.
|
|
52
|
+
clones: {
|
|
53
|
+
paths: ['apps', 'packages'],
|
|
54
|
+
formats: ['typescript', 'javascript'],
|
|
55
|
+
ignore: ['**/node_modules/**', '**/dist/**', '**/*.d.ts', '**/*.test.ts', '**/*.spec.ts'],
|
|
56
|
+
minTokens: 50,
|
|
57
|
+
minLines: 5,
|
|
58
|
+
mode: 'mild',
|
|
59
|
+
threshold: 0,
|
|
60
|
+
},
|
|
61
|
+
// On by default: SvelteKit pages over 280 lines should rip inline components
|
|
62
|
+
// out into their own files. The `*+page.svelte` glob is a no-op in repos with
|
|
63
|
+
// no SvelteKit pages, so this stays harmless org-wide. Override per repo.
|
|
64
|
+
pageSize: { rules: [{ glob: '*+page.svelte', maxLines: 280 }] },
|
|
65
|
+
// On by default: warn past 225 lines, block past 300 (override per repo).
|
|
66
|
+
fileSize: {
|
|
67
|
+
globs: ['apps/*.ts', 'packages/*.ts'],
|
|
68
|
+
warnLines: 225,
|
|
69
|
+
maxLines: 300,
|
|
70
|
+
allowlist: [],
|
|
71
|
+
},
|
|
72
|
+
// On by default: a workspace must declare a catalog (set enforce:false to opt out).
|
|
73
|
+
catalog: { enforce: true, allowlist: [] },
|
|
74
|
+
// On by default: the workspace catalog must define remeda (set deps:[] to opt out).
|
|
75
|
+
requireDeps: { deps: ['remeda'] },
|
|
76
|
+
// Opt-in: no packages → no-op.
|
|
77
|
+
helperManifest: { packages: [], output: '.nodeve/helper-manifest.txt' },
|
|
78
|
+
};
|
|
79
|
+
//# sourceMappingURL=defaults.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nodeve/checks",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Org-wide commit-gate checks (doc budgets, reshape/dup/helper smells, page size) and helper-index generators, driven by a per-repo config file and wired through lefthook.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -15,13 +15,17 @@
|
|
|
15
15
|
"files": [
|
|
16
16
|
"dist",
|
|
17
17
|
"lefthook.checks.yml",
|
|
18
|
-
"nodeve.checks.
|
|
18
|
+
"nodeve.checks.defaults.js"
|
|
19
19
|
],
|
|
20
20
|
"exports": {
|
|
21
21
|
"./config": {
|
|
22
22
|
"types": "./dist/lib/config.d.ts",
|
|
23
23
|
"default": "./dist/lib/config.js"
|
|
24
24
|
},
|
|
25
|
+
"./defaults": {
|
|
26
|
+
"types": "./dist/lib/defaults.d.ts",
|
|
27
|
+
"default": "./dist/lib/defaults.js"
|
|
28
|
+
},
|
|
25
29
|
"./lefthook": "./lefthook.checks.yml"
|
|
26
30
|
},
|
|
27
31
|
"bin": {
|
|
@@ -29,6 +33,7 @@
|
|
|
29
33
|
"nodeve-check-reshape": "./dist/bin/reshape.js",
|
|
30
34
|
"nodeve-check-inline-dupes": "./dist/bin/inline-dupes.js",
|
|
31
35
|
"nodeve-check-helper-collisions": "./dist/bin/helper-collisions.js",
|
|
36
|
+
"nodeve-check-clones": "./dist/bin/clones.js",
|
|
32
37
|
"nodeve-check-page-size": "./dist/bin/page-size.js",
|
|
33
38
|
"nodeve-check-file-size": "./dist/bin/file-size.js",
|
|
34
39
|
"nodeve-check-catalog": "./dist/bin/catalog.js",
|
|
@@ -39,18 +44,19 @@
|
|
|
39
44
|
},
|
|
40
45
|
"dependencies": {
|
|
41
46
|
"js-tiktoken": "^1.0.0",
|
|
47
|
+
"jscpd": "^5.0.0",
|
|
42
48
|
"prettier": "^3.0.0",
|
|
43
49
|
"remeda": "^2.0.0",
|
|
44
50
|
"typescript": "^5.5.0",
|
|
45
51
|
"yaml": "^2.5.0",
|
|
46
|
-
"@nodeve/text": "2.
|
|
52
|
+
"@nodeve/text": "2.1.0"
|
|
47
53
|
},
|
|
48
54
|
"devDependencies": {
|
|
49
55
|
"@types/node": "^22.0.0",
|
|
50
56
|
"@nodeve/config": "0.1.0"
|
|
51
57
|
},
|
|
52
58
|
"scripts": {
|
|
53
|
-
"build": "tsc -p tsconfig.json",
|
|
59
|
+
"build": "tsc -p tsconfig.json && cp dist/lib/defaults.js nodeve.checks.defaults.js",
|
|
54
60
|
"clean": "rm -rf dist",
|
|
55
61
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
56
62
|
}
|
package/nodeve.checks.example.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
// Copy to your repo root as `nodeve.checks.js` and keep ONLY what you change.
|
|
2
|
-
// Every section is optional; omitted keys fall back to the org defaults baked
|
|
3
|
-
// into @nodeve/checks (see the `Config` type / `DEFAULTS` in the package for the
|
|
4
|
-
// authoritative values). The user config is deep-merged over those defaults:
|
|
5
|
-
// nested records merge key-by-key, but ARRAYS REPLACE — so if you set an array
|
|
6
|
-
// field (e.g. `docTokens.enforce`) you must restate the entries you want to keep,
|
|
7
|
-
// not just the ones you're adding.
|
|
8
|
-
//
|
|
9
|
-
// The blocks below are illustrative overrides, not the defaults. Delete any you
|
|
10
|
-
// don't need.
|
|
11
|
-
export default {
|
|
12
|
-
// Widen the enforced doc set (this array REPLACES the default list — the
|
|
13
|
-
// default is CLAUDE.md + READMEs + guide/ + docs/, restated here plus adr/):
|
|
14
|
-
docTokens: {
|
|
15
|
-
enforce: ['CLAUDE.md', 'README.md', '*/README.md', 'guide/*.md', 'docs/*.md', 'adr/*.md'],
|
|
16
|
-
// Per-file budget bumps, keyed by repo-root-relative path (merges with defaults):
|
|
17
|
-
overrides: {
|
|
18
|
-
'CLAUDE.md': { maxTokens: 3500 },
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
|
|
22
|
-
// Per-glob page-size budget (default ON: `*+page.svelte` >280 lines → rip
|
|
23
|
-
// inline components out into their own files). This array REPLACES the
|
|
24
|
-
// default, so restate the SvelteKit rule if you only mean to add others:
|
|
25
|
-
pageSize: {
|
|
26
|
-
rules: [
|
|
27
|
-
{ glob: '*+page.svelte', maxLines: 280 },
|
|
28
|
-
{ glob: '*+layout.svelte', maxLines: 200 },
|
|
29
|
-
],
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
// TS line budget (default ON: warn >225, fail >300 across apps/ + packages/).
|
|
33
|
-
// Override the thresholds, or allowlist files that are one responsibility but
|
|
34
|
-
// legitimately long (the allowlist array REPLACES the default — restate all):
|
|
35
|
-
fileSize: {
|
|
36
|
-
maxLines: 350,
|
|
37
|
-
allowlist: ['packages/foo/src/schema.ts'], // WHY: single zod schema
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
// Deliberately opt a repo out of the (default-on) catalog gate:
|
|
41
|
-
catalog: { enforce: false },
|
|
42
|
-
|
|
43
|
-
// Change the org-required catalog deps (default: ['remeda']; [] to opt out):
|
|
44
|
-
requireDeps: { deps: ['remeda'] },
|
|
45
|
-
|
|
46
|
-
// Opt in to the helper-manifest index by listing package dirs to scan:
|
|
47
|
-
helperManifest: {
|
|
48
|
-
packages: ['packages/utils'],
|
|
49
|
-
},
|
|
50
|
-
};
|