@hailstails/hone 1.1.0 → 1.3.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/ADOPTING.md +4 -4
- package/CHANGELOG.md +22 -0
- package/MIGRATING.md +5 -5
- package/README.md +14 -8
- package/api/audit.d.ts +1 -1
- package/api/testing.js +4 -4
- package/chunks/{chunk-BLGGM7AV.js → chunk-H4V72FCW.js} +1 -1
- package/chunks/{chunk-PVCA3ISA.js → chunk-PL2PNPAR.js} +1 -1
- package/chunks/{chunk-CBWWAKQY.js → chunk-T32FOWZA.js} +1 -1
- package/chunks/{chunk-MZTLH4EU.js → chunk-Y2KPZDDV.js} +21 -1
- package/chunks/{chunk-63SJV5ZY.js → chunk-YSN46EB3.js} +41 -22
- package/core/check/tool-command.js +47 -30
- package/docs/adding-a-discipline-or-mechanism.md +1 -1
- package/docs/extending.md +5 -6
- package/docs/output-contract.md +8 -4
- package/mechanisms/audit/CD-3/compiler-overrides.js +193 -29
- package/mechanisms/audit/CD-3/piece.json +35 -7
- package/mechanisms/audit/runner/README.md +3 -2
- package/mechanisms/audit/runner/runner.js +42 -6
- package/mechanisms/audit/runner/walker-piece.d.ts +12 -0
- package/mechanisms/eslint/runner/README.md +1 -1
- package/mechanisms/eslint/runner/runner.js +60 -23
- package/package.json +1 -1
- package/rules/CD-10/CHECKS.md +2 -2
- package/rules/CD-14/CHECKS.md +2 -2
- package/rules/CD-15/CHECKS.md +2 -2
- package/rules/CD-17/CHECKS.md +2 -2
- package/rules/CD-19/CHECKS.md +2 -2
- package/rules/CD-2/CHECKS.md +2 -2
- package/rules/CD-23/CHECKS.md +2 -2
- package/rules/CD-25/CHECKS.md +2 -2
- package/rules/CD-26/CHECKS.md +2 -2
- package/rules/CD-27/CHECKS.md +2 -2
- package/rules/CD-3/CHECKS.md +35 -11
- package/rules/CD-3/discipline.json +278 -0
- package/rules/CD-40/CHECKS.md +2 -2
- package/rules/CD-41/CHECKS.md +2 -2
- package/rules/CD-42/CHECKS.md +2 -2
- package/rules/CD-43/CHECKS.md +2 -2
- package/rules/CD-44/CHECKS.md +2 -2
- package/rules/CD-47/CHECKS.md +2 -2
- package/rules/CD-5/CHECKS.md +2 -2
- package/rules/CD-6/CHECKS.md +2 -2
- package/rules/CD-7/CHECKS.md +2 -2
- package/rules/CD-7a/CHECKS.md +2 -2
- package/rules/CD-8/CHECKS.md +2 -2
|
@@ -6,16 +6,17 @@ import {
|
|
|
6
6
|
import {
|
|
7
7
|
hitSchema,
|
|
8
8
|
runnerResultSchema
|
|
9
|
-
} from "../../../chunks/chunk-
|
|
9
|
+
} from "../../../chunks/chunk-H4V72FCW.js";
|
|
10
10
|
import {
|
|
11
11
|
createDefaultPackageLocationPort,
|
|
12
12
|
installRootOfRunnerEntry,
|
|
13
13
|
toolchainBoundStandaloneRunner
|
|
14
|
-
} from "../../../chunks/chunk-
|
|
14
|
+
} from "../../../chunks/chunk-T32FOWZA.js";
|
|
15
15
|
import {
|
|
16
16
|
gatheredOutcomes
|
|
17
17
|
} from "../../../chunks/chunk-LDQUT742.js";
|
|
18
18
|
import {
|
|
19
|
+
createDefaultEntryKindPort,
|
|
19
20
|
createDefaultFileTextPort,
|
|
20
21
|
createDefaultModuleLoaderPort,
|
|
21
22
|
createDefaultPathPort,
|
|
@@ -24,7 +25,7 @@ import {
|
|
|
24
25
|
loadedPeer,
|
|
25
26
|
moduleExtensionOf,
|
|
26
27
|
moduleFileForm
|
|
27
|
-
} from "../../../chunks/chunk-
|
|
28
|
+
} from "../../../chunks/chunk-Y2KPZDDV.js";
|
|
28
29
|
import {
|
|
29
30
|
sameClauseAddress
|
|
30
31
|
} from "../../../chunks/chunk-FR4FASVM.js";
|
|
@@ -388,6 +389,38 @@ var walkerPieceSettingsSchema = z3.object({
|
|
|
388
389
|
escapingDirectives: z3.array(z3.enum(TYPE_DIRECTIVES)).readonly().optional()
|
|
389
390
|
}).readonly();
|
|
390
391
|
|
|
392
|
+
// mechanisms/audit/runner/walker-disk.ts
|
|
393
|
+
var CASE_ROOT = "/repository";
|
|
394
|
+
var portsDisk = (request) => ({
|
|
395
|
+
root: request.root,
|
|
396
|
+
kindAt: ({ path }) => request.entryKind.kindOf({ path }),
|
|
397
|
+
textAt: ({ path }) => {
|
|
398
|
+
const text = request.fileText.read({ path });
|
|
399
|
+
return text.outcome === "failed" ? { outcome: "failed", error: { detail: text.error.detail } } : text;
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
var foldersHolding = (request) => {
|
|
403
|
+
const segments = request.path.split("/");
|
|
404
|
+
return segments.slice(1, -1).map((_, depth) => segments.slice(0, depth + 2).join("/"));
|
|
405
|
+
};
|
|
406
|
+
var textsDisk = (request) => {
|
|
407
|
+
const files = new Map(Object.entries(request.texts).map(([file, text]) => [`${request.root}/${file}`, text]));
|
|
408
|
+
const folders = /* @__PURE__ */ new Set([request.root, ...[...files.keys()].flatMap((path) => foldersHolding({ path }))]);
|
|
409
|
+
return {
|
|
410
|
+
root: request.root,
|
|
411
|
+
kindAt: ({ path }) => {
|
|
412
|
+
if (files.has(path)) {
|
|
413
|
+
return "file";
|
|
414
|
+
}
|
|
415
|
+
return folders.has(path) ? "directory" : "absent";
|
|
416
|
+
},
|
|
417
|
+
textAt: ({ path }) => {
|
|
418
|
+
const text = files.get(path);
|
|
419
|
+
return text === void 0 ? { outcome: "failed", error: { detail: `${path} is not a file` } } : { outcome: "ok", value: text };
|
|
420
|
+
}
|
|
421
|
+
};
|
|
422
|
+
};
|
|
423
|
+
|
|
391
424
|
// mechanisms/audit/runner/create-walker-runner.ts
|
|
392
425
|
var finishedHitsSchema = runnerResultSchema({ value: z4.array(hitSchema).readonly() });
|
|
393
426
|
var pieceInvalid3 = (request) => ({
|
|
@@ -508,7 +541,8 @@ var runOverRepository = (request) => {
|
|
|
508
541
|
files: request.run.trackedPaths,
|
|
509
542
|
exists: ({ file }) => request.ports.fileText.exists({
|
|
510
543
|
path: request.ports.path.join({ segments: [request.run.repoRoot, file] })
|
|
511
|
-
})
|
|
544
|
+
}),
|
|
545
|
+
disk: portsDisk({ root: request.run.repoRoot, entryKind: request.ports.entryKind, fileText: request.ports.fileText })
|
|
512
546
|
};
|
|
513
547
|
return preparedPieces({ ports: request.ports, clauses: request.run.clauses, repository }).then((prepared) => {
|
|
514
548
|
if (prepared.outcome === "failed") return prepared;
|
|
@@ -529,7 +563,8 @@ var caseFile = (request) => ({
|
|
|
529
563
|
var caseVerdict = (request) => {
|
|
530
564
|
const repository = {
|
|
531
565
|
files: [request.sourceCase.fileName],
|
|
532
|
-
exists: ({ file }) => file === request.sourceCase.fileName ? "present" : "absent"
|
|
566
|
+
exists: ({ file }) => file === request.sourceCase.fileName ? "present" : "absent",
|
|
567
|
+
disk: textsDisk({ root: CASE_ROOT, texts: { [request.sourceCase.fileName]: request.sourceCase.source } })
|
|
533
568
|
};
|
|
534
569
|
return preparedPieces({ ports: request.ports, clauses: [request.clause], repository }).then((prepared) => {
|
|
535
570
|
if (prepared.outcome === "failed") return prepared;
|
|
@@ -611,7 +646,8 @@ var runner = toolchainBoundStandaloneRunner({
|
|
|
611
646
|
fileText: createDefaultFileTextPort({}),
|
|
612
647
|
modules: createDefaultModuleLoaderPort({}),
|
|
613
648
|
path: createDefaultPathPort({}),
|
|
614
|
-
parse
|
|
649
|
+
parse,
|
|
650
|
+
entryKind: createDefaultEntryKindPort({})
|
|
615
651
|
})
|
|
616
652
|
});
|
|
617
653
|
export {
|
|
@@ -45,11 +45,23 @@ export type PreparedWalkerCheck = {
|
|
|
45
45
|
readonly prepareFile: (request: WalkerFile) => Result<PreparedFileCheck, PieceFailure>;
|
|
46
46
|
readonly finish: () => Result<readonly Hit[], PieceFailure>;
|
|
47
47
|
};
|
|
48
|
+
export type WalkerDisk = {
|
|
49
|
+
readonly root: string;
|
|
50
|
+
readonly kindAt: (request: {
|
|
51
|
+
readonly path: string;
|
|
52
|
+
}) => "file" | "directory" | "absent";
|
|
53
|
+
readonly textAt: (request: {
|
|
54
|
+
readonly path: string;
|
|
55
|
+
}) => Result<string, {
|
|
56
|
+
readonly detail: string;
|
|
57
|
+
}>;
|
|
58
|
+
};
|
|
48
59
|
export type WalkerRepository = {
|
|
49
60
|
readonly files: readonly RepoPath[];
|
|
50
61
|
readonly exists: (request: {
|
|
51
62
|
readonly file: RepoPath;
|
|
52
63
|
}) => "present" | "absent";
|
|
64
|
+
readonly disk: WalkerDisk;
|
|
53
65
|
};
|
|
54
66
|
export type WalkerPiece = {
|
|
55
67
|
readonly prepare: (request: {
|
|
@@ -6,7 +6,7 @@ The native channels, the exception kind each maps to, and how the projection is
|
|
|
6
6
|
|
|
7
7
|
The check compares the committed projection byte for byte with what the runner would write now. Built core is the installed package: the runner reads the package's `package.json` for its name, and the projection imports each piece inside it by package name, `<name>/mechanisms/eslint/...`, which resolves wherever the package is installed. A `package.json` that cannot be read or names no package is a `tool-failed` failure. Core run from source, as in its own tests, imports each piece by its path relative to the folder the slice is written in. A piece outside the install, in the repository's own rule set, is always imported by relative path, and a piece on another drive from a slice's folder fails as `piece-invalid`.
|
|
8
8
|
|
|
9
|
-
The config roots are the repository root, every folder holding a tracked `eslint.config.*` when the team's lookup is nearest-to-file, and every folder core passes as a declared config root, less any folder at or under a folder with a tracked `disciplines.json`, because nested Hone configurations are not supported yet ([#72](https://github.com/HailsTails/hone/issues/72)). Under the nearest-to-file lookup,
|
|
9
|
+
The config roots are the repository root, every folder holding a tracked `eslint.config.*` when the team's lookup is nearest-to-file, and every folder core passes as a declared config root, less any folder at or under a folder with a tracked `disciplines.json`, because nested Hone configurations are not supported yet ([#72](https://github.com/HailsTails/hone/issues/72)). Under the nearest-to-file lookup, `run` returns as `unprojectedFolders` each outermost folder, at or under such a folder and holding a file under check, that holds its own tracked `eslint.config.*`, with the outermost folder holding a `disciplines.json` that holds it as `selectionFolder`: a file there loads that config, which gets no slice, so `hone record-debt` writes no record for it. A folder holding its own `disciplines.json` but no config of its own is not one, since its files load the config above it. When the projection is not in effect, `run` also names each outermost such folder holding files under check whose own config leaves a record of this repository out of effect, or the selected rule off, as a `nested-configuration` slice; core names the folder on the `mechanism-not-run` entry it explains, not as a projection problem. Core reads and validates `eslintConfigRoots` from `disciplines.json` and passes the folders in the request as `declaredConfigRoots`; the runner never reads them itself. Each root's slice is `disciplines.eslint.mjs` in that folder. The root slice holds every record; a package slice holds the records for files under its folder, re-pathed relative to it and glob-escaped as in the root, and every clause-wide carve-out. A file belongs to the deepest root containing it. `project` writes every slice, then, for each tracked `disciplines.eslint.mjs` in a folder that is no longer a root, regenerates the slice that folder would get and removes the file only when its bytes match that text, so it never deletes a file it did not write; otherwise it reports `left-in-place`. `project` renders and reads every slice and orphan before it writes or removes anything, so a failure part-way changes nothing. `run` reports each package slice that is `missing` or `out-of-date`, each declared root with no `eslint.config.*` on disk as `unconfigured`, and, under the nearest-to-file lookup when the projection is not in effect, each package root whose own recorded files under check are not excepted as `not-applied`, grouping the checked files by their governing root once. Every config root gets and keeps its slice whatever a config above it ignores: a lint run from that folder loads its own config and never reads the ignores of the configs above it, so `project` writes the same slices from the same inputs every time. `not-applied` judges each recorded file through the same per-file query as every other judgement, which resolves the file from its nearest config, the one a lint run from its package loads. A root-only repository's projection is unchanged.
|
|
10
10
|
|
|
11
11
|
## Runtime
|
|
12
12
|
|
|
@@ -2,14 +2,14 @@ import "../../../chunks/chunk-YLZ73C7O.js";
|
|
|
2
2
|
import {
|
|
3
3
|
eslintConfigLookupSchema,
|
|
4
4
|
parsedJson
|
|
5
|
-
} from "../../../chunks/chunk-
|
|
5
|
+
} from "../../../chunks/chunk-PL2PNPAR.js";
|
|
6
6
|
import "../../../chunks/chunk-RWQ4UNKY.js";
|
|
7
7
|
import "../../../chunks/chunk-NA5L6PUE.js";
|
|
8
8
|
import {
|
|
9
9
|
createDefaultPackageLocationPort,
|
|
10
10
|
installRootOfRunnerEntry,
|
|
11
11
|
toolchainBoundEmbeddedRunner
|
|
12
|
-
} from "../../../chunks/chunk-
|
|
12
|
+
} from "../../../chunks/chunk-T32FOWZA.js";
|
|
13
13
|
import {
|
|
14
14
|
gatheredOutcomes,
|
|
15
15
|
listedOutcome
|
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
moduleFileForm,
|
|
32
32
|
repoPathSchema,
|
|
33
33
|
versionSupport
|
|
34
|
-
} from "../../../chunks/chunk-
|
|
34
|
+
} from "../../../chunks/chunk-Y2KPZDDV.js";
|
|
35
35
|
import {
|
|
36
36
|
TOOL_IDENTITY,
|
|
37
37
|
clauseAddressText,
|
|
@@ -598,6 +598,7 @@ var selectionLookupSchema = z6.looseObject({ eslintConfigLookup: eslintConfigLoo
|
|
|
598
598
|
import { z as z7 } from "zod";
|
|
599
599
|
var SCRIPT_PIECES = /(?<single>'[^']*')|(?<double>"[^"]*")|(?<operator>&&|\|\||[;|])|(?<space>\s+)|(?<text>[^'"\s;|&]+|&)|(?<stray>['"])/g;
|
|
600
600
|
var ESLINT_TOKEN = "eslint";
|
|
601
|
+
var UNREADABLE_SCRIPT_BREAKS = /[\s'";|&()]+/;
|
|
601
602
|
var ESLINT_VERSIONED_PREFIX = "eslint@";
|
|
602
603
|
var ESLINT_PATH_SUFFIXES = ["/eslint", "/eslint.js"];
|
|
603
604
|
var FORWARDED_OPTIONS_SEPARATOR = "--";
|
|
@@ -901,7 +902,7 @@ var locatedScan = (request) => {
|
|
|
901
902
|
return {
|
|
902
903
|
outcome: "ok",
|
|
903
904
|
value: {
|
|
904
|
-
|
|
905
|
+
...request.scan.value,
|
|
905
906
|
suppressionsLocations: [
|
|
906
907
|
...request.scan.value.suppressionsLocations,
|
|
907
908
|
{ location: location.value, script: request.script }
|
|
@@ -909,16 +910,34 @@ var locatedScan = (request) => {
|
|
|
909
910
|
}
|
|
910
911
|
};
|
|
911
912
|
};
|
|
913
|
+
var EMPTY_SCAN = { scriptOptions: [], suppressionsLocations: [], unreadableScripts: [] };
|
|
914
|
+
var unreadableScan = (request) => {
|
|
915
|
+
const command = request.scriptText.split(UNREADABLE_SCRIPT_BREAKS).find((piece) => eslintNamingOf({ token: piece }) === "names-eslint");
|
|
916
|
+
if (command === void 0) {
|
|
917
|
+
return EMPTY_SCAN;
|
|
918
|
+
}
|
|
919
|
+
return {
|
|
920
|
+
...EMPTY_SCAN,
|
|
921
|
+
unreadableScripts: [
|
|
922
|
+
{
|
|
923
|
+
command,
|
|
924
|
+
exceptions: request.selectedRules.map(
|
|
925
|
+
(rule) => ({
|
|
926
|
+
kind: "command-line-option",
|
|
927
|
+
clause: rule.clause,
|
|
928
|
+
location: request.path,
|
|
929
|
+
script: request.script,
|
|
930
|
+
option: request.scriptText
|
|
931
|
+
})
|
|
932
|
+
)
|
|
933
|
+
}
|
|
934
|
+
]
|
|
935
|
+
};
|
|
936
|
+
};
|
|
912
937
|
var scriptScan = (request) => {
|
|
913
938
|
const commands = shellCommandsOf({ script: request.scriptText });
|
|
914
939
|
if (commands.outcome === "failed") {
|
|
915
|
-
return {
|
|
916
|
-
outcome: "failed",
|
|
917
|
-
error: {
|
|
918
|
-
kind: "tool-failed",
|
|
919
|
-
detail: `script "${request.script}" in ${request.path} has an unterminated quote`
|
|
920
|
-
}
|
|
921
|
-
};
|
|
940
|
+
return { outcome: "ok", value: unreadableScan(request) };
|
|
922
941
|
}
|
|
923
942
|
const invocations = settledInvocationsOf({ commands: commands.value });
|
|
924
943
|
const baseSegments = request.path.split("/").slice(0, -1);
|
|
@@ -926,10 +945,7 @@ var scriptScan = (request) => {
|
|
|
926
945
|
(scan, locationText) => locatedScan({ scan, locationText, baseSegments, path: request.path, script: request.script }),
|
|
927
946
|
{
|
|
928
947
|
outcome: "ok",
|
|
929
|
-
value: {
|
|
930
|
-
scriptOptions: scriptOptionsOf({ ...request, invocations }),
|
|
931
|
-
suppressionsLocations: []
|
|
932
|
-
}
|
|
948
|
+
value: { ...EMPTY_SCAN, scriptOptions: scriptOptionsOf({ ...request, invocations }) }
|
|
933
949
|
}
|
|
934
950
|
);
|
|
935
951
|
};
|
|
@@ -953,7 +969,8 @@ var mergedScriptScan = (request) => {
|
|
|
953
969
|
suppressionsLocations: [
|
|
954
970
|
...request.scan.value.suppressionsLocations,
|
|
955
971
|
...scanned.value.suppressionsLocations
|
|
956
|
-
]
|
|
972
|
+
],
|
|
973
|
+
unreadableScripts: [...request.scan.value.unreadableScripts, ...scanned.value.unreadableScripts]
|
|
957
974
|
}
|
|
958
975
|
};
|
|
959
976
|
};
|
|
@@ -971,7 +988,7 @@ var scanPackageJson = (request) => {
|
|
|
971
988
|
}
|
|
972
989
|
return Object.entries(packageJson.data.scripts ?? {}).reduce(
|
|
973
990
|
(scan, [script, scriptText]) => mergedScriptScan({ scan, script, scriptText, path: request.path, selectedRules: request.selectedRules }),
|
|
974
|
-
{ outcome: "ok", value:
|
|
991
|
+
{ outcome: "ok", value: EMPTY_SCAN }
|
|
975
992
|
);
|
|
976
993
|
};
|
|
977
994
|
|
|
@@ -1313,6 +1330,17 @@ var outermostOf = (request) => request.nested.filter(
|
|
|
1313
1330
|
);
|
|
1314
1331
|
var holdingOf = (request) => request.paths.some((path) => within({ path, directory: request.folder }) === "within") ? "holds" : "holds-none";
|
|
1315
1332
|
var nestedConfigurationFoldersOf = (request) => outermostOf({ nested: nestedRepositories(request) }).filter((folder) => holdingOf({ paths: request.files, folder }) === "holds").sort(codeUnitOrder2).map((folder) => repoPathSchema.parse(folder));
|
|
1333
|
+
var unprojectedFoldersOf = (request) => {
|
|
1334
|
+
const nested = nestedRepositories(request);
|
|
1335
|
+
const outermostNested = outermostOf({ nested });
|
|
1336
|
+
const ownConfigured = configuredDirectories({ ...request, declared: [] }).filter(
|
|
1337
|
+
(directory) => directory !== "" && insideNestedRepository({ directory, nested }) === "nested"
|
|
1338
|
+
);
|
|
1339
|
+
return outermostOf({ nested: ownConfigured }).filter((folder) => holdingOf({ paths: request.files, folder }) === "holds").sort(codeUnitOrder2).flatMap((folder) => {
|
|
1340
|
+
const selectionFolder = outermostNested.find((candidate) => within({ path: folder, directory: candidate }) === "within");
|
|
1341
|
+
return selectionFolder === void 0 ? [] : [{ folder: repoPathSchema.parse(folder), selectionFolder: repoPathSchema.parse(selectionFolder) }];
|
|
1342
|
+
});
|
|
1343
|
+
};
|
|
1316
1344
|
var orphanedSliceDirectoriesOf = (request) => {
|
|
1317
1345
|
const nested = nestedRepositories(request);
|
|
1318
1346
|
const rooted = new Set(request.roots.flatMap((root) => root.placement === "package" ? [root.directory] : []));
|
|
@@ -2044,10 +2072,14 @@ var weakeningExceptions = (request) => request.judge({ option: request.option })
|
|
|
2044
2072
|
var judgedScriptExceptions = (request) => Promise.all(request.scan.scriptOptions.map((option) => weakeningExceptions({ option, judge: request.judge }))).then(
|
|
2045
2073
|
(outcomes) => gatheredOutcomes({ outcomes })
|
|
2046
2074
|
);
|
|
2075
|
+
var unreadableScriptExceptions = (request) => request.scan.unreadableScripts.flatMap(
|
|
2076
|
+
(unreadable) => unreadable.exceptions.map((exception) => ({ ...exception, cause: { kind: "unreadable", command: unreadable.command } }))
|
|
2077
|
+
);
|
|
2047
2078
|
var scannedPackageExceptions = (request) => judgedScriptExceptions(request).then(
|
|
2048
2079
|
(scriptExceptions) => gatheredOutcomes({
|
|
2049
2080
|
outcomes: [
|
|
2050
2081
|
scriptExceptions,
|
|
2082
|
+
{ outcome: "ok", value: unreadableScriptExceptions({ scan: request.scan }) },
|
|
2051
2083
|
...request.scan.suppressionsLocations.map(
|
|
2052
2084
|
(scripted) => scriptSuppressionEntries({
|
|
2053
2085
|
fileText: request.fileText,
|
|
@@ -2288,18 +2320,23 @@ var selectedRun = (request) => {
|
|
|
2288
2320
|
roots,
|
|
2289
2321
|
fileText: request.ports.fileText
|
|
2290
2322
|
});
|
|
2291
|
-
|
|
2323
|
+
if (status.outcome === "failed") {
|
|
2324
|
+
return Promise.resolve(status);
|
|
2325
|
+
}
|
|
2326
|
+
const unprojectedFolders = unprojectedFoldersOf({
|
|
2327
|
+
trackedPaths: request.run.trackedPaths,
|
|
2328
|
+
files: request.run.files,
|
|
2329
|
+
lookup: lookup.value.kind
|
|
2330
|
+
});
|
|
2331
|
+
return governedRun({
|
|
2292
2332
|
...request,
|
|
2293
2333
|
status: {
|
|
2294
2334
|
...status.value,
|
|
2295
|
-
slices: [
|
|
2296
|
-
...status.value.slices,
|
|
2297
|
-
...unconfiguredSlicesOf({ ports: request.ports, run: request.run, roots })
|
|
2298
|
-
]
|
|
2335
|
+
slices: [...status.value.slices, ...unconfiguredSlicesOf({ ports: request.ports, run: request.run, roots })]
|
|
2299
2336
|
},
|
|
2300
2337
|
roots,
|
|
2301
2338
|
lookup: lookup.value
|
|
2302
|
-
});
|
|
2339
|
+
}).then((report) => report.outcome === "failed" ? report : { outcome: "ok", value: { ...report.value, unprojectedFolders } });
|
|
2303
2340
|
};
|
|
2304
2341
|
var lintedSourceCases = (request) => {
|
|
2305
2342
|
if (request.selected.outcome === "failed") {
|
package/package.json
CHANGED
package/rules/CD-10/CHECKS.md
CHANGED
|
@@ -38,7 +38,7 @@ it("loads the account", () => {
|
|
|
38
38
|
Assert on the whole result. Branching in tests is also reported by CD-27.
|
|
39
39
|
|
|
40
40
|
## Exceptions
|
|
41
|
-
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` when a test file legitimately needs a throw, such as a shared test harness. Use `file-carve-out` for debt in one file: it is forfeited once the file is touched, and needs
|
|
41
|
+
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` when a test file legitimately needs a throw, such as a shared test harness. Use `file-carve-out` for debt in one file: it is forfeited once the file is touched, and needs no `whyChain`. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
|
|
42
42
|
|
|
43
43
|
```json
|
|
44
44
|
{ "version": 1, "exceptions": [
|
|
@@ -46,4 +46,4 @@ Add an entry to `discipline-exceptions.json` at the repository root. Use `author
|
|
|
46
46
|
] }
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
An `authorised-location` or `clause-wide-carve-out` also needs a `whyChain` that follows the [why-chain contract](../../docs/why-chain-contract.md): five whys chained cause to cause, a `rootCause`, its `rootCheck`, a `readback` and an `owner`. A record imported from an earlier system carries `provenance` instead. A `file-carve-out` is debt and needs only its `kind`, `clause` and `file`; its `reason` is an optional note, and a `whyChain` or `provenance` it gives anyway is still judged. With `"fileExceptionWhyChains": "optional"` in `disciplines.json`, an `authorised-location` may give only its `reason`, which will be refused in the next major release. [The exceptions format](../../README.md#discipline-exceptionsjson) gives each shape.
|
package/rules/CD-14/CHECKS.md
CHANGED
|
@@ -38,7 +38,7 @@ export const createCounter = () => {
|
|
|
38
38
|
Return an object of functions from a factory that closes over its state.
|
|
39
39
|
|
|
40
40
|
## Exceptions
|
|
41
|
-
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` when a class is required, such as an adapter extending a library base class. Use `file-carve-out` for debt in one file: it is forfeited once the file is touched, and needs
|
|
41
|
+
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` when a class is required, such as an adapter extending a library base class. Use `file-carve-out` for debt in one file: it is forfeited once the file is touched, and needs no `whyChain`. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
|
|
42
42
|
|
|
43
43
|
```json
|
|
44
44
|
{ "version": 1, "exceptions": [
|
|
@@ -46,4 +46,4 @@ Add an entry to `discipline-exceptions.json` at the repository root. Use `author
|
|
|
46
46
|
] }
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
An `authorised-location` or `clause-wide-carve-out` also needs a `whyChain` that follows the [why-chain contract](../../docs/why-chain-contract.md): five whys chained cause to cause, a `rootCause`, its `rootCheck`, a `readback` and an `owner`. A record imported from an earlier system carries `provenance` instead. A `file-carve-out` is debt and needs only its `kind`, `clause` and `file`; its `reason` is an optional note, and a `whyChain` or `provenance` it gives anyway is still judged. With `"fileExceptionWhyChains": "optional"` in `disciplines.json`, an `authorised-location` may give only its `reason`, which will be refused in the next major release. [The exceptions format](../../README.md#discipline-exceptionsjson) gives each shape.
|
package/rules/CD-15/CHECKS.md
CHANGED
|
@@ -29,7 +29,7 @@ const totals = orders.map((order) => order.total);
|
|
|
29
29
|
Replace a counted loop with `Array.from({ length }, (_, position) => ...)`.
|
|
30
30
|
|
|
31
31
|
## Exceptions
|
|
32
|
-
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` when a file drains an async stream and cannot use a functional form. Use `file-carve-out` for debt in one file: it is forfeited once the file is touched, and needs
|
|
32
|
+
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` when a file drains an async stream and cannot use a functional form. Use `file-carve-out` for debt in one file: it is forfeited once the file is touched, and needs no `whyChain`. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
|
|
33
33
|
|
|
34
34
|
```json
|
|
35
35
|
{ "version": 1, "exceptions": [
|
|
@@ -37,4 +37,4 @@ Add an entry to `discipline-exceptions.json` at the repository root. Use `author
|
|
|
37
37
|
] }
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
An `authorised-location` or `clause-wide-carve-out` also needs a `whyChain` that follows the [why-chain contract](../../docs/why-chain-contract.md): five whys chained cause to cause, a `rootCause`, its `rootCheck`, a `readback` and an `owner`. A record imported from an earlier system carries `provenance` instead. A `file-carve-out` is debt and needs only its `kind`, `clause` and `file`; its `reason` is an optional note, and a `whyChain` or `provenance` it gives anyway is still judged. With `"fileExceptionWhyChains": "optional"` in `disciplines.json`, an `authorised-location` may give only its `reason`, which will be refused in the next major release. [The exceptions format](../../README.md#discipline-exceptionsjson) gives each shape.
|
package/rules/CD-17/CHECKS.md
CHANGED
|
@@ -26,7 +26,7 @@ const startedAt = clock.now();
|
|
|
26
26
|
Accept a clock as a dependency and read time only through it. The one real implementation lives in an adapter.
|
|
27
27
|
|
|
28
28
|
## Exceptions
|
|
29
|
-
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` for the file that is the single real clock implementation. Use `file-carve-out` for debt in one file: it is forfeited once the file is touched, and needs
|
|
29
|
+
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` for the file that is the single real clock implementation. Use `file-carve-out` for debt in one file: it is forfeited once the file is touched, and needs no `whyChain`. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
|
|
30
30
|
|
|
31
31
|
```json
|
|
32
32
|
{ "version": 1, "exceptions": [
|
|
@@ -34,4 +34,4 @@ Add an entry to `discipline-exceptions.json` at the repository root. Use `author
|
|
|
34
34
|
] }
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
An `authorised-location` or `clause-wide-carve-out` also needs a `whyChain` that follows the [why-chain contract](../../docs/why-chain-contract.md): five whys chained cause to cause, a `rootCause`, its `rootCheck`, a `readback` and an `owner`. A record imported from an earlier system carries `provenance` instead. A `file-carve-out` is debt and needs only its `kind`, `clause` and `file`; its `reason` is an optional note, and a `whyChain` or `provenance` it gives anyway is still judged. With `"fileExceptionWhyChains": "optional"` in `disciplines.json`, an `authorised-location` may give only its `reason`, which will be refused in the next major release. [The exceptions format](../../README.md#discipline-exceptionsjson) gives each shape.
|
package/rules/CD-19/CHECKS.md
CHANGED
|
@@ -38,7 +38,7 @@ import { createIdGenerator } from "./id-generator.ts";
|
|
|
38
38
|
Import your own port. Only the wrapping file imports the library.
|
|
39
39
|
|
|
40
40
|
## Exceptions
|
|
41
|
-
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` for the file that is the wrapping boundary for that dependency. Use `file-carve-out` for debt in one file: it is forfeited once the file is touched, and needs
|
|
41
|
+
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` for the file that is the wrapping boundary for that dependency. Use `file-carve-out` for debt in one file: it is forfeited once the file is touched, and needs no `whyChain`. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
|
|
42
42
|
|
|
43
43
|
```json
|
|
44
44
|
{ "version": 1, "exceptions": [
|
|
@@ -46,4 +46,4 @@ Add an entry to `discipline-exceptions.json` at the repository root. Use `author
|
|
|
46
46
|
] }
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
An `authorised-location` or `clause-wide-carve-out` also needs a `whyChain` that follows the [why-chain contract](../../docs/why-chain-contract.md): five whys chained cause to cause, a `rootCause`, its `rootCheck`, a `readback` and an `owner`. A record imported from an earlier system carries `provenance` instead. A `file-carve-out` is debt and needs only its `kind`, `clause` and `file`; its `reason` is an optional note, and a `whyChain` or `provenance` it gives anyway is still judged. With `"fileExceptionWhyChains": "optional"` in `disciplines.json`, an `authorised-location` may give only its `reason`, which will be refused in the next major release. [The exceptions format](../../README.md#discipline-exceptionsjson) gives each shape.
|
package/rules/CD-2/CHECKS.md
CHANGED
|
@@ -43,7 +43,7 @@ Parse or narrow the value so the type follows from a check rather than from an a
|
|
|
43
43
|
When handing a value across a boundary truly forces a cast, such as a library that types its schemas loosely or a database driver that returns unparsed rows, put the cast in the one adapter file at that boundary and record that file as an `authorised-location` with a why-chain. With clean boundaries that is one file and one record; casts scattered across many files are the sign the boundary is missing.
|
|
44
44
|
|
|
45
45
|
## Exceptions
|
|
46
|
-
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` when a file sits on an external boundary that forces an assertion, such as an adapter. Use `file-carve-out` for debt in one file: it is forfeited once the file is touched, and needs
|
|
46
|
+
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` when a file sits on an external boundary that forces an assertion, such as an adapter. Use `file-carve-out` for debt in one file: it is forfeited once the file is touched, and needs no `whyChain`. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
|
|
47
47
|
|
|
48
48
|
```json
|
|
49
49
|
{ "version": 1, "exceptions": [
|
|
@@ -53,4 +53,4 @@ Add an entry to `discipline-exceptions.json` at the repository root. Use `author
|
|
|
53
53
|
|
|
54
54
|
Records on `CD-2#non-null-assertions` take the same kinds. Existing `!` debt is usually a `file-carve-out` per file, or one `clause-wide-carve-out` while an assessment's steps pay it down. An `eslint-disable` naming `hone-cd2/no-restricted-syntax`, or naming no rule, is held only by an `authorised-location` or `file-carve-out` on this clause and its file; a `clause-wide-carve-out` does not hold it. The projection carries every record for it, so run `hone project` after recording one.
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
An `authorised-location` or `clause-wide-carve-out` also needs a `whyChain` that follows the [why-chain contract](../../docs/why-chain-contract.md): five whys chained cause to cause, a `rootCause`, its `rootCheck`, a `readback` and an `owner`. A record imported from an earlier system carries `provenance` instead. A `file-carve-out` is debt and needs only its `kind`, `clause` and `file`; its `reason` is an optional note, and a `whyChain` or `provenance` it gives anyway is still judged. With `"fileExceptionWhyChains": "optional"` in `disciplines.json`, an `authorised-location` may give only its `reason`, which will be refused in the next major release. [The exceptions format](../../README.md#discipline-exceptionsjson) gives each shape.
|
package/rules/CD-23/CHECKS.md
CHANGED
|
@@ -24,7 +24,7 @@ This is `src/price.ts` with no `src/price.test.ts` beside it.
|
|
|
24
24
|
Add `src/price.test.ts` next to the file, with at least one test of its behaviour.
|
|
25
25
|
|
|
26
26
|
## Exceptions
|
|
27
|
-
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` when a file only wires exports together and has no behaviour of its own to test. Use `file-carve-out` for debt in one file: it is forfeited once the file is touched, and needs
|
|
27
|
+
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` when a file only wires exports together and has no behaviour of its own to test. Use `file-carve-out` for debt in one file: it is forfeited once the file is touched, and needs no `whyChain`. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
|
|
28
28
|
|
|
29
29
|
```json
|
|
30
30
|
{ "version": 1, "exceptions": [
|
|
@@ -32,4 +32,4 @@ Add an entry to `discipline-exceptions.json` at the repository root. Use `author
|
|
|
32
32
|
] }
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
An `authorised-location` or `clause-wide-carve-out` also needs a `whyChain` that follows the [why-chain contract](../../docs/why-chain-contract.md): five whys chained cause to cause, a `rootCause`, its `rootCheck`, a `readback` and an `owner`. A record imported from an earlier system carries `provenance` instead. A `file-carve-out` is debt and needs only its `kind`, `clause` and `file`; its `reason` is an optional note, and a `whyChain` or `provenance` it gives anyway is still judged. With `"fileExceptionWhyChains": "optional"` in `disciplines.json`, an `authorised-location` may give only its `reason`, which will be refused in the next major release. [The exceptions format](../../README.md#discipline-exceptionsjson) gives each shape.
|
package/rules/CD-25/CHECKS.md
CHANGED
|
@@ -27,7 +27,7 @@ const clock = { now: vi.fn().mockReturnValue(1) };
|
|
|
27
27
|
Return a canned value: that double is a stub. If the double needs logic, the seam is probably too wide, or the double is a fake that belongs in a shared in-memory implementation of the port with its own tests.
|
|
28
28
|
|
|
29
29
|
## Exceptions
|
|
30
|
-
A double that legitimately needs behaviour is a fake: write it once as an in-memory implementation of the port, in its own module with its own tests, and pass it in. That is the home for the behaviour, not an exception for a test file. For debt in one file, add a `file-carve-out` entry to `discipline-exceptions.json` at the repository root: it is forfeited once the file is touched, and needs
|
|
30
|
+
A double that legitimately needs behaviour is a fake: write it once as an in-memory implementation of the port, in its own module with its own tests, and pass it in. That is the home for the behaviour, not an exception for a test file. For debt in one file, add a `file-carve-out` entry to `discipline-exceptions.json` at the repository root: it is forfeited once the file is touched, and needs no `whyChain`. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
|
|
31
31
|
|
|
32
32
|
```json
|
|
33
33
|
{ "version": 1, "exceptions": [
|
|
@@ -35,4 +35,4 @@ A double that legitimately needs behaviour is a fake: write it once as an in-mem
|
|
|
35
35
|
] }
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
An `authorised-location` or `clause-wide-carve-out` also needs a `whyChain` that follows the [why-chain contract](../../docs/why-chain-contract.md): five whys chained cause to cause, a `rootCause`, its `rootCheck`, a `readback` and an `owner`. A record imported from an earlier system carries `provenance` instead. A `file-carve-out` is debt and needs only its `kind`, `clause` and `file`; its `reason` is an optional note, and a `whyChain` or `provenance` it gives anyway is still judged. With `"fileExceptionWhyChains": "optional"` in `disciplines.json`, an `authorised-location` may give only its `reason`, which will be refused in the next major release. [The exceptions format](../../README.md#discipline-exceptionsjson) gives each shape.
|
package/rules/CD-26/CHECKS.md
CHANGED
|
@@ -25,7 +25,7 @@ const subject = createSubject({ store: storeStub });
|
|
|
25
25
|
Pass the collaborator in as a dependency and hand the test a stub.
|
|
26
26
|
|
|
27
27
|
## Exceptions
|
|
28
|
-
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` when a test file legitimately needs to intercept a module. Use `file-carve-out` for debt in one file: it is forfeited once the file is touched, and needs
|
|
28
|
+
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` when a test file legitimately needs to intercept a module. Use `file-carve-out` for debt in one file: it is forfeited once the file is touched, and needs no `whyChain`. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
|
|
29
29
|
|
|
30
30
|
```json
|
|
31
31
|
{ "version": 1, "exceptions": [
|
|
@@ -33,4 +33,4 @@ Add an entry to `discipline-exceptions.json` at the repository root. Use `author
|
|
|
33
33
|
] }
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
An `authorised-location` or `clause-wide-carve-out` also needs a `whyChain` that follows the [why-chain contract](../../docs/why-chain-contract.md): five whys chained cause to cause, a `rootCause`, its `rootCheck`, a `readback` and an `owner`. A record imported from an earlier system carries `provenance` instead. A `file-carve-out` is debt and needs only its `kind`, `clause` and `file`; its `reason` is an optional note, and a `whyChain` or `provenance` it gives anyway is still judged. With `"fileExceptionWhyChains": "optional"` in `disciplines.json`, an `authorised-location` may give only its `reason`, which will be refused in the next major release. [The exceptions format](../../README.md#discipline-exceptionsjson) gives each shape.
|
package/rules/CD-27/CHECKS.md
CHANGED
|
@@ -64,7 +64,7 @@ expect(given).toBe(1);
|
|
|
64
64
|
```
|
|
65
65
|
|
|
66
66
|
## Exceptions
|
|
67
|
-
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` when a test file legitimately needs logic. Use `file-carve-out` for debt in one file: it is forfeited once the file is touched, and needs
|
|
67
|
+
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` when a test file legitimately needs logic. Use `file-carve-out` for debt in one file: it is forfeited once the file is touched, and needs no `whyChain`. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
|
|
68
68
|
|
|
69
69
|
```json
|
|
70
70
|
{ "version": 1, "exceptions": [
|
|
@@ -72,4 +72,4 @@ Add an entry to `discipline-exceptions.json` at the repository root. Use `author
|
|
|
72
72
|
] }
|
|
73
73
|
```
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
An `authorised-location` or `clause-wide-carve-out` also needs a `whyChain` that follows the [why-chain contract](../../docs/why-chain-contract.md): five whys chained cause to cause, a `rootCause`, its `rootCheck`, a `readback` and an `owner`. A record imported from an earlier system carries `provenance` instead. A `file-carve-out` is debt and needs only its `kind`, `clause` and `file`; its `reason` is an optional note, and a `whyChain` or `provenance` it gives anyway is still judged. With `"fileExceptionWhyChains": "optional"` in `disciplines.json`, an `authorised-location` may give only its `reason`, which will be refused in the next major release. [The exceptions format](../../README.md#discipline-exceptionsjson) gives each shape.
|
package/rules/CD-3/CHECKS.md
CHANGED
|
@@ -6,19 +6,30 @@ Read [the rule and its spirit](README.md) first. This page is the mechanics: how
|
|
|
6
6
|
|
|
7
7
|
| Clause | Mechanism | Checks |
|
|
8
8
|
| --- | --- | --- |
|
|
9
|
-
| `CD-3#strict` | audit | `strict` is set in a `tsconfig.json
|
|
10
|
-
| `CD-3#no-unchecked-indexed-access` | audit | `noUncheckedIndexedAccess` is set |
|
|
11
|
-
| `CD-3#exact-optional-property-types` | audit | `exactOptionalPropertyTypes` is set |
|
|
12
|
-
| `CD-3#no-implicit-override` | audit | `noImplicitOverride` is set |
|
|
13
|
-
| `CD-3#no-fallthrough-cases-in-switch` | audit | `noFallthroughCasesInSwitch` is set |
|
|
14
|
-
| `CD-3#no-property-access-from-index-signature` | audit | `noPropertyAccessFromIndexSignature` is set |
|
|
15
|
-
| `CD-3#use-unknown-in-catch-variables` | audit | `useUnknownInCatchVariables` is set |
|
|
9
|
+
| `CD-3#strict` | audit | `strict` is set in a `tsconfig.json`; edition 2 adds that it resolves to on |
|
|
10
|
+
| `CD-3#no-unchecked-indexed-access` | audit | `noUncheckedIndexedAccess` is set; edition 2 adds that it resolves to on |
|
|
11
|
+
| `CD-3#exact-optional-property-types` | audit | `exactOptionalPropertyTypes` is set; edition 2 adds that it resolves to on |
|
|
12
|
+
| `CD-3#no-implicit-override` | audit | `noImplicitOverride` is set; edition 2 adds that it resolves to on |
|
|
13
|
+
| `CD-3#no-fallthrough-cases-in-switch` | audit | `noFallthroughCasesInSwitch` is set; edition 2 adds that it resolves to on |
|
|
14
|
+
| `CD-3#no-property-access-from-index-signature` | audit | `noPropertyAccessFromIndexSignature` is set; edition 2 adds that it resolves to on |
|
|
15
|
+
| `CD-3#use-unknown-in-catch-variables` | audit | `useUnknownInCatchVariables` is set; edition 2 adds that it resolves to on |
|
|
16
16
|
|
|
17
17
|
## What the check flags
|
|
18
|
+
Each CD-3 clause has two editions. Edition 1 runs by default. Edition 2 also judges what each `tsconfig.json` inherits, and becomes the default in the next major release; see [Settings](#settings) to run it now.
|
|
19
|
+
|
|
20
|
+
Edition 1:
|
|
18
21
|
- `tsconfig.json` files, named exactly, at any depth. `tsconfig.base.json` and other names are not read. Generated folders such as `node_modules`, `dist`, `build` and `coverage` are skipped.
|
|
19
|
-
- For each selected clause, the matching option present in that file's `compilerOptions`. Presence is enough: `true` is flagged as well as `false
|
|
22
|
+
- For each selected clause, the matching option present in that file's `compilerOptions`. Presence is enough: `true` is flagged as well as `false`.
|
|
20
23
|
- Options in `extends`-ed files are not seen. A file that cannot be parsed, or whose root or `compilerOptions` is not an object, fails the run.
|
|
21
24
|
|
|
25
|
+
Edition 2 also flags, for each selected option a `tsconfig.json` does not set itself, an option its resolved configuration leaves off:
|
|
26
|
+
- The configuration is resolved by the repository's installed TypeScript, as `tsc` would resolve it: every file in the `extends` chain, a relative path, a package such as `@tsconfig/strictest` or a workspace package under `node_modules`, and an array of bases on TypeScript 5.0 or later, later bases winning. An option a base turns on and a later file turns off is off.
|
|
27
|
+
- `strict` and `useUnknownInCatchVariables` take TypeScript's defaults: TypeScript 6 treats `strict` as on when nothing sets it, and `useUnknownInCatchVariables` follows `strict` unless it is set.
|
|
28
|
+
- The finding names the file to edit. `= false, inherited from <base>` names each base that turns the option off. `= false, turned off in <file>` names this `tsconfig.json` when its own `"strict": false` turns `useUnknownInCatchVariables` off. `unset here and in <bases>` lists every file in the chain, none of which sets the option; `unset, and this file extends no base` says there is no chain.
|
|
29
|
+
- A configuration TypeScript cannot resolve, such as a base file that is missing, a package that is not installed, or bases that extend each other, is flagged for each selected option the file does not set as `unknown`, followed by TypeScript's own diagnostic. An `extends` holding `${configDir}` resolves however the installed TypeScript resolves it, and is flagged the same way when TypeScript cannot find it. Fix the chain, and the options are judged.
|
|
30
|
+
- The base files are judged through the `tsconfig.json` files that extend them, not on their own.
|
|
31
|
+
- A `tsconfig.json` from which TypeScript would compile no file is not judged on what it resolves to, since its options apply to no file. After resolving the chain, TypeScript has no `files` entry, and no `include` entry that names a path outright or a folder or pattern it would search. Examples: an empty `files` list, its own or inherited, with no `include`, such as the solution-style root with only `references` that `npm create vite` writes; an empty `include`; an `exclude` of every file. Any non-empty `include` that names a file or a folder is still judged, such as `"include": ["vite.config.ts"]` or `["src"]`, and so is a config that sets neither `files` nor `include`, since TypeScript then includes every file. An option a skipped file sets itself is still flagged, as in edition 1. The configs it references are not judged through it; only files named `tsconfig.json` are read.
|
|
32
|
+
|
|
22
33
|
## Example violation
|
|
23
34
|
```json
|
|
24
35
|
{ "compilerOptions": { "strict": false } }
|
|
@@ -28,10 +39,23 @@ Read [the rule and its spirit](README.md) first. This page is the mechanics: how
|
|
|
28
39
|
```json
|
|
29
40
|
{ "extends": "../../tsconfig.base.json", "compilerOptions": { "outDir": "dist" } }
|
|
30
41
|
```
|
|
31
|
-
Put the flags in a shared base file that is not named `tsconfig.json`, and leave them out of every `tsconfig.json`.
|
|
42
|
+
Put the flags in a shared base file that is not named `tsconfig.json`, and leave them out of every `tsconfig.json`. Under edition 1, that the base file turns them on is left to review. Under edition 2 the check reads the base: turn every selected flag on in it.
|
|
43
|
+
|
|
44
|
+
```json
|
|
45
|
+
{ "compilerOptions": { "strict": true, "noUncheckedIndexedAccess": true, "exactOptionalPropertyTypes": true, "noImplicitOverride": true, "noFallthroughCasesInSwitch": true, "noPropertyAccessFromIndexSignature": true, "useUnknownInCatchVariables": true } }
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Settings
|
|
49
|
+
- `edition`: the edition this clause runs, `"1"` or `"2"`. Without it, the clause runs edition 1, or the latest edition when `checkEditions` in `disciplines.json` is `"latest"`.
|
|
50
|
+
|
|
51
|
+
```json
|
|
52
|
+
"clauseSettings": {
|
|
53
|
+
"CD-3#no-unchecked-indexed-access": { "edition": "2" }
|
|
54
|
+
}
|
|
55
|
+
```
|
|
32
56
|
|
|
33
57
|
## Exceptions
|
|
34
|
-
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` when a package must set the flag itself. Use `file-carve-out` for debt in one file: it is forfeited once the file is touched, and needs
|
|
58
|
+
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` when a package must set the flag itself. Use `file-carve-out` for debt in one file: it is forfeited once the file is touched, and needs no `whyChain`. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
|
|
35
59
|
|
|
36
60
|
```json
|
|
37
61
|
{ "version": 1, "exceptions": [
|
|
@@ -39,4 +63,4 @@ Add an entry to `discipline-exceptions.json` at the repository root. Use `author
|
|
|
39
63
|
] }
|
|
40
64
|
```
|
|
41
65
|
|
|
42
|
-
|
|
66
|
+
An `authorised-location` or `clause-wide-carve-out` also needs a `whyChain` that follows the [why-chain contract](../../docs/why-chain-contract.md): five whys chained cause to cause, a `rootCause`, its `rootCheck`, a `readback` and an `owner`. A record imported from an earlier system carries `provenance` instead. A `file-carve-out` is debt and needs only its `kind`, `clause` and `file`; its `reason` is an optional note, and a `whyChain` or `provenance` it gives anyway is still judged. With `"fileExceptionWhyChains": "optional"` in `disciplines.json`, an `authorised-location` may give only its `reason`, which will be refused in the next major release. [The exceptions format](../../README.md#discipline-exceptionsjson) gives each shape.
|