@hailstails/hone 0.0.0-stage → 0.1.0-pre.2
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 +314 -0
- package/LICENSE +17 -0
- package/MIGRATING.md +238 -0
- package/README.md +216 -2
- package/THIRD-PARTY-NOTICES.md +354 -0
- package/chunks/chunk-233U4FBA.js +42 -0
- package/chunks/chunk-7ZJZZBSS.js +14909 -0
- package/chunks/chunk-HBY4ZWSP.js +79 -0
- package/chunks/chunk-HJA4CX7C.js +24 -0
- package/chunks/chunk-NZLE2WMY.js +35 -0
- package/chunks/chunk-QWA6OVLC.js +11 -0
- package/chunks/chunk-TRCB27ET.js +202 -0
- package/core/check/tool-command.js +2305 -0
- package/docs/adding-a-discipline-or-mechanism.md +195 -0
- package/docs/why-chain-contract.md +78 -0
- package/mechanisms/audit/CD-1/any-cast.js +81 -0
- package/mechanisms/audit/CD-1/piece.json +13 -0
- package/mechanisms/audit/CD-10/piece.json +13 -0
- package/mechanisms/audit/CD-10/throws-in-tests.js +49 -0
- package/mechanisms/audit/CD-14/class-syntax.js +70 -0
- package/mechanisms/audit/CD-14/piece.json +13 -0
- package/mechanisms/audit/CD-15/loops.js +40 -0
- package/mechanisms/audit/CD-15/piece.json +13 -0
- package/mechanisms/audit/CD-17/clock-sources.js +29 -0
- package/mechanisms/audit/CD-17/piece.json +13 -0
- package/mechanisms/audit/CD-19/import-boundaries.js +80 -0
- package/mechanisms/audit/CD-19/piece.json +13 -0
- package/mechanisms/audit/CD-2/cast-expressions.js +81 -0
- package/mechanisms/audit/CD-2/piece.json +13 -0
- package/mechanisms/audit/CD-23/export-test-sibling.js +56 -0
- package/mechanisms/audit/CD-23/piece.json +13 -0
- package/mechanisms/audit/CD-25/dependency-isolation.js +53 -0
- package/mechanisms/audit/CD-25/piece.json +13 -0
- package/mechanisms/audit/CD-26/module-mocking.js +51 -0
- package/mechanisms/audit/CD-26/piece.json +13 -0
- package/mechanisms/audit/CD-27/piece.json +13 -0
- package/mechanisms/audit/CD-27/test-body-logic.js +107 -0
- package/mechanisms/audit/CD-3/compiler-overrides.js +955 -0
- package/mechanisms/audit/CD-3/piece.json +49 -0
- package/mechanisms/audit/CD-43/boolean-signatures.js +55 -0
- package/mechanisms/audit/CD-43/piece.json +13 -0
- package/mechanisms/audit/CD-44/parameter-mutation.js +92 -0
- package/mechanisms/audit/CD-44/piece.json +13 -0
- package/mechanisms/audit/CD-47/hermetic-git-spawns.js +44 -0
- package/mechanisms/audit/CD-47/piece.json +13 -0
- package/mechanisms/audit/CD-5/comments-directives.js +73 -0
- package/mechanisms/audit/CD-5/piece.json +13 -0
- package/mechanisms/audit/CD-6/identifier-names.js +132 -0
- package/mechanisms/audit/CD-6/piece.json +13 -0
- package/mechanisms/audit/CD-7/categorical-paths.js +55 -0
- package/mechanisms/audit/CD-7/piece.json +13 -0
- package/mechanisms/audit/CD-7a/factory-return-types.js +42 -0
- package/mechanisms/audit/CD-7a/piece.json +13 -0
- package/mechanisms/audit/CD-8/piece.json +13 -0
- package/mechanisms/audit/CD-8/switch-defaults.js +43 -0
- package/mechanisms/audit/runner/README.md +38 -0
- package/mechanisms/audit/runner/runner.js +546 -0
- package/mechanisms/eslint/CD-1/README.md +12 -0
- package/mechanisms/eslint/CD-1/cd1/cd1.eslint-plugin.js +50 -0
- package/mechanisms/eslint/CD-1/piece.json +23 -0
- package/mechanisms/eslint/CD-10/README.md +9 -0
- package/mechanisms/eslint/CD-10/cd10/cd10.eslint-plugin.js +55 -0
- package/mechanisms/eslint/CD-10/piece.json +15 -0
- package/mechanisms/eslint/CD-14/README.md +11 -0
- package/mechanisms/eslint/CD-14/cd14/cd14.eslint-plugin.js +88 -0
- package/mechanisms/eslint/CD-14/piece.json +31 -0
- package/mechanisms/eslint/CD-27/README.md +12 -0
- package/mechanisms/eslint/CD-27/cd27/cd27.eslint-plugin.js +83 -0
- package/mechanisms/eslint/CD-27/piece.json +23 -0
- package/mechanisms/eslint/CD-40/README.md +7 -0
- package/mechanisms/eslint/CD-40/cd40/cd40.eslint-plugin.js +16 -0
- package/mechanisms/eslint/CD-40/piece.json +21 -0
- package/mechanisms/eslint/CD-41/README.md +12 -0
- package/mechanisms/eslint/CD-41/cd41/cd41.eslint-plugin.js +228 -0
- package/mechanisms/eslint/CD-41/piece.json +23 -0
- package/mechanisms/eslint/CD-42/README.md +9 -0
- package/mechanisms/eslint/CD-42/cd42/cd42.eslint-plugin.js +75 -0
- package/mechanisms/eslint/CD-42/piece.json +15 -0
- package/mechanisms/eslint/CD-44/README.md +7 -0
- package/mechanisms/eslint/CD-44/cd44/cd44.eslint-plugin.js +16 -0
- package/mechanisms/eslint/CD-44/piece.json +20 -0
- package/mechanisms/eslint/CD-6/README.md +9 -0
- package/mechanisms/eslint/CD-6/cd6/cd6.eslint-plugin.js +16 -0
- package/mechanisms/eslint/CD-6/piece.json +217 -0
- package/mechanisms/eslint/CD-7/README.md +9 -0
- package/mechanisms/eslint/CD-7/cd7/cd7.eslint-plugin.js +52 -0
- package/mechanisms/eslint/CD-7/piece.json +15 -0
- package/mechanisms/eslint/runner/README.md +43 -0
- package/mechanisms/eslint/runner/runner.js +4248 -0
- package/methods/README.md +18 -0
- package/methods/lenses/clean-architecture.md +167 -0
- package/methods/lenses/decomposition.md +159 -0
- package/methods/lenses/defended-on-intent.md +178 -0
- package/methods/lenses/di-discipline.md +156 -0
- package/methods/lenses/errors-as-data.md +88 -0
- package/methods/lenses/function-first.md +193 -0
- package/methods/lenses/naming.md +127 -0
- package/methods/lenses/test-discipline.md +166 -0
- package/methods/lenses/type-soundness.md +135 -0
- package/methods/lenses/zod-boundary.md +158 -0
- package/package.json +65 -4
- package/rules/CD-1/README.md +43 -0
- package/rules/CD-1/discipline.json +185 -0
- package/rules/CD-10/README.md +55 -0
- package/rules/CD-10/discipline.json +133 -0
- package/rules/CD-11/README.md +19 -0
- package/rules/CD-11/discipline.json +12 -0
- package/rules/CD-12/README.md +19 -0
- package/rules/CD-12/discipline.json +12 -0
- package/rules/CD-13/README.md +19 -0
- package/rules/CD-13/discipline.json +12 -0
- package/rules/CD-14/README.md +54 -0
- package/rules/CD-14/discipline.json +173 -0
- package/rules/CD-15/README.md +48 -0
- package/rules/CD-15/discipline.json +73 -0
- package/rules/CD-16/README.md +17 -0
- package/rules/CD-17/README.md +42 -0
- package/rules/CD-17/discipline.json +51 -0
- package/rules/CD-18/README.md +19 -0
- package/rules/CD-18/discipline.json +12 -0
- package/rules/CD-19/README.md +45 -0
- package/rules/CD-19/discipline.json +65 -0
- package/rules/CD-2/README.md +43 -0
- package/rules/CD-2/discipline.json +65 -0
- package/rules/CD-20/README.md +17 -0
- package/rules/CD-21/README.md +19 -0
- package/rules/CD-21/discipline.json +12 -0
- package/rules/CD-22/README.md +19 -0
- package/rules/CD-22/discipline.json +12 -0
- package/rules/CD-23/README.md +41 -0
- package/rules/CD-23/discipline.json +57 -0
- package/rules/CD-24/README.md +17 -0
- package/rules/CD-25/README.md +43 -0
- package/rules/CD-25/discipline.json +57 -0
- package/rules/CD-26/README.md +42 -0
- package/rules/CD-26/discipline.json +57 -0
- package/rules/CD-27/README.md +51 -0
- package/rules/CD-27/discipline.json +233 -0
- package/rules/CD-28/README.md +19 -0
- package/rules/CD-28/discipline.json +12 -0
- package/rules/CD-29/README.md +19 -0
- package/rules/CD-29/discipline.json +12 -0
- package/rules/CD-3/README.md +48 -0
- package/rules/CD-3/discipline.json +363 -0
- package/rules/CD-30/README.md +19 -0
- package/rules/CD-30/discipline.json +12 -0
- package/rules/CD-31/README.md +19 -0
- package/rules/CD-31/discipline.json +12 -0
- package/rules/CD-32/README.md +19 -0
- package/rules/CD-32/discipline.json +12 -0
- package/rules/CD-33/README.md +19 -0
- package/rules/CD-33/discipline.json +12 -0
- package/rules/CD-34/README.md +19 -0
- package/rules/CD-34/discipline.json +12 -0
- package/rules/CD-39/README.md +19 -0
- package/rules/CD-39/discipline.json +12 -0
- package/rules/CD-4/README.md +19 -0
- package/rules/CD-4/discipline.json +12 -0
- package/rules/CD-40/README.md +45 -0
- package/rules/CD-40/discipline.json +58 -0
- package/rules/CD-41/README.md +60 -0
- package/rules/CD-41/discipline.json +124 -0
- package/rules/CD-42/README.md +53 -0
- package/rules/CD-42/discipline.json +61 -0
- package/rules/CD-43/README.md +43 -0
- package/rules/CD-43/discipline.json +65 -0
- package/rules/CD-44/README.md +54 -0
- package/rules/CD-44/discipline.json +111 -0
- package/rules/CD-45/README.md +19 -0
- package/rules/CD-45/discipline.json +12 -0
- package/rules/CD-46/README.md +13 -0
- package/rules/CD-47/README.md +47 -0
- package/rules/CD-47/discipline.json +57 -0
- package/rules/CD-5/README.md +46 -0
- package/rules/CD-5/discipline.json +65 -0
- package/rules/CD-6/README.md +57 -0
- package/rules/CD-6/discipline.json +165 -0
- package/rules/CD-7/README.md +52 -0
- package/rules/CD-7/discipline.json +142 -0
- package/rules/CD-7a/README.md +44 -0
- package/rules/CD-7a/discipline.json +57 -0
- package/rules/CD-8/README.md +48 -0
- package/rules/CD-8/discipline.json +57 -0
- package/rules/CD-9/README.md +19 -0
- package/rules/CD-9/discipline.json +12 -0
- package/rules/README.md +52 -0
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import "../../../../chunks/chunk-NZLE2WMY.js";
|
|
2
|
+
|
|
3
|
+
// mechanisms/eslint/CD-41/cd41/cd41.eslint-plugin.ts
|
|
4
|
+
var MAX_COGNITIVE_COMPLEXITY = 15;
|
|
5
|
+
var MAX_FUNCTION_LINES = 50;
|
|
6
|
+
var FUNCTION_TYPES = /* @__PURE__ */ new Set([
|
|
7
|
+
"FunctionDeclaration",
|
|
8
|
+
"FunctionExpression",
|
|
9
|
+
"ArrowFunctionExpression"
|
|
10
|
+
]);
|
|
11
|
+
var LOOP_TYPES = /* @__PURE__ */ new Set([
|
|
12
|
+
"ForStatement",
|
|
13
|
+
"ForInStatement",
|
|
14
|
+
"ForOfStatement",
|
|
15
|
+
"WhileStatement",
|
|
16
|
+
"DoWhileStatement"
|
|
17
|
+
]);
|
|
18
|
+
var LOOP_BODY_KEYS = /* @__PURE__ */ new Set(["body"]);
|
|
19
|
+
var ACCESSOR_KINDS = /* @__PURE__ */ new Set(["get", "set"]);
|
|
20
|
+
var MEMBER_TYPES = /* @__PURE__ */ new Set(["MethodDefinition", "Property", "TSAbstractMethodDefinition"]);
|
|
21
|
+
var BRACES = /* @__PURE__ */ new Set(["{", "}"]);
|
|
22
|
+
var LINE_BREAK = /\r\n|[\r\n]/gu;
|
|
23
|
+
var EMPTY = { own: 0, nested: [] };
|
|
24
|
+
var isNode = (candidate) => typeof candidate === "object" && candidate !== null && "type" in candidate && typeof candidate.type === "string";
|
|
25
|
+
var childNodesOf = (request) => (request.sourceCode.visitorKeys[request.node.type] ?? []).filter((key) => request.keys === void 0 || request.keys.has(key)).flatMap((key) => {
|
|
26
|
+
const field = Reflect.get(request.node, key);
|
|
27
|
+
const fieldEntries = Array.isArray(field) ? field : [field];
|
|
28
|
+
return fieldEntries.filter(isNode).map((child) => ({ key, child }));
|
|
29
|
+
});
|
|
30
|
+
var combined = (request) => request.scores.reduce(
|
|
31
|
+
(total, next) => ({ own: total.own + next.own, nested: [...total.nested, ...next.nested] }),
|
|
32
|
+
EMPTY
|
|
33
|
+
);
|
|
34
|
+
var withOwn = (request) => ({
|
|
35
|
+
own: request.score.own + request.increment,
|
|
36
|
+
nested: request.score.nested
|
|
37
|
+
});
|
|
38
|
+
var walkedChildren = (request) => combined({
|
|
39
|
+
scores: childNodesOf({ node: request.node, sourceCode: request.sourceCode }).map(
|
|
40
|
+
({ key, child }) => walked({
|
|
41
|
+
node: child,
|
|
42
|
+
parent: request.node,
|
|
43
|
+
nesting: request.nestedKeys?.has(key) ? request.nesting + 1 : request.nesting,
|
|
44
|
+
sourceCode: request.sourceCode
|
|
45
|
+
})
|
|
46
|
+
)
|
|
47
|
+
});
|
|
48
|
+
var parenthesisation = (request) => {
|
|
49
|
+
const before = request.sourceCode.getTokenBefore(request.node);
|
|
50
|
+
const after = request.sourceCode.getTokenAfter(request.node);
|
|
51
|
+
return before?.value === "(" && after?.value === ")" && before.range[0] >= (request.parent.range?.[0] ?? 0) ? "parenthesised" : "bare";
|
|
52
|
+
};
|
|
53
|
+
var logicalRun = (request) => {
|
|
54
|
+
const parent = request.parent;
|
|
55
|
+
if (request.node.type !== "LogicalExpression" || parent?.type !== "LogicalExpression" || parent.operator !== request.node.operator || parent.left !== request.node) {
|
|
56
|
+
return "starts-run";
|
|
57
|
+
}
|
|
58
|
+
return parenthesisation({ node: request.node, parent, sourceCode: request.sourceCode }) === "parenthesised" ? "starts-run" : "continues-run";
|
|
59
|
+
};
|
|
60
|
+
var childNamed = (request) => childNodesOf({ node: request.node, sourceCode: request.sourceCode, keys: /* @__PURE__ */ new Set([request.key]) }).at(0)?.child;
|
|
61
|
+
var walkedChild = (request) => {
|
|
62
|
+
const child = childNamed({ node: request.node, key: request.key, sourceCode: request.sourceCode });
|
|
63
|
+
return child === void 0 ? EMPTY : walked({ node: child, parent: request.node, nesting: request.nesting + request.deeper, sourceCode: request.sourceCode });
|
|
64
|
+
};
|
|
65
|
+
var walkedElse = (request) => {
|
|
66
|
+
const alternate = childNamed({ node: request.node, key: "alternate", sourceCode: request.sourceCode });
|
|
67
|
+
if (alternate === void 0) {
|
|
68
|
+
return EMPTY;
|
|
69
|
+
}
|
|
70
|
+
if (alternate.type === "IfStatement") {
|
|
71
|
+
return walkedIf({ ...request, node: alternate, parent: request.node });
|
|
72
|
+
}
|
|
73
|
+
return withOwn({
|
|
74
|
+
score: walked({ node: alternate, parent: request.node, nesting: request.nesting + 1, sourceCode: request.sourceCode }),
|
|
75
|
+
increment: 1
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
var walkedIf = (request) => withOwn({
|
|
79
|
+
score: combined({
|
|
80
|
+
scores: [
|
|
81
|
+
walkedChild({ ...request, key: "test", deeper: 0 }),
|
|
82
|
+
walkedChild({ ...request, key: "consequent", deeper: 1 }),
|
|
83
|
+
walkedElse(request)
|
|
84
|
+
]
|
|
85
|
+
}),
|
|
86
|
+
increment: 1 + request.nesting
|
|
87
|
+
});
|
|
88
|
+
var NESTING_STRUCTURES = {
|
|
89
|
+
SwitchStatement: /* @__PURE__ */ new Set(["cases"]),
|
|
90
|
+
ConditionalExpression: /* @__PURE__ */ new Set(["consequent", "alternate"]),
|
|
91
|
+
CatchClause: /* @__PURE__ */ new Set(["body"])
|
|
92
|
+
};
|
|
93
|
+
var structureIncrement = (request) => {
|
|
94
|
+
const node = request.node;
|
|
95
|
+
if (node.type === "LogicalExpression") {
|
|
96
|
+
return logicalRun(request) === "starts-run" ? 1 : 0;
|
|
97
|
+
}
|
|
98
|
+
if ((node.type === "BreakStatement" || node.type === "ContinueStatement") && (node.label ?? null) !== null) {
|
|
99
|
+
return 1;
|
|
100
|
+
}
|
|
101
|
+
return node.type === "WithStatement" ? 1 : 0;
|
|
102
|
+
};
|
|
103
|
+
var walkedTry = (request) => {
|
|
104
|
+
if (request.node.type !== "TryStatement" || request.node.finalizer === null || request.node.finalizer === void 0) {
|
|
105
|
+
return walkedChildren(request);
|
|
106
|
+
}
|
|
107
|
+
return withOwn({ score: walkedChildren(request), increment: 1 });
|
|
108
|
+
};
|
|
109
|
+
var walked = (request) => {
|
|
110
|
+
const node = request.node;
|
|
111
|
+
if (FUNCTION_TYPES.has(node.type)) {
|
|
112
|
+
const nested = scoredFunction({ node, nesting: request.nesting + 1, sourceCode: request.sourceCode });
|
|
113
|
+
return { own: 0, nested: [{ node, score: nested.own }, ...nested.nested] };
|
|
114
|
+
}
|
|
115
|
+
if (node.type === "IfStatement") {
|
|
116
|
+
return walkedIf(request);
|
|
117
|
+
}
|
|
118
|
+
if (node.type === "TryStatement") {
|
|
119
|
+
return walkedTry(request);
|
|
120
|
+
}
|
|
121
|
+
const nestedKeys = LOOP_TYPES.has(node.type) ? LOOP_BODY_KEYS : NESTING_STRUCTURES[node.type];
|
|
122
|
+
if (nestedKeys !== void 0) {
|
|
123
|
+
return withOwn({ score: walkedChildren({ ...request, nestedKeys }), increment: 1 + request.nesting });
|
|
124
|
+
}
|
|
125
|
+
return withOwn({ score: walkedChildren(request), increment: structureIncrement(request) });
|
|
126
|
+
};
|
|
127
|
+
var scoredFunction = (request) => walkedChildren({ ...request, parent: request.node.parent ?? void 0 });
|
|
128
|
+
var memberKeyOf = (request) => {
|
|
129
|
+
const parent = request.node.parent;
|
|
130
|
+
if (parent === null || !MEMBER_TYPES.has(parent.type) || !("key" in parent) || !isNode(parent.key)) {
|
|
131
|
+
return void 0;
|
|
132
|
+
}
|
|
133
|
+
return parent.value === request.node ? parent.key : void 0;
|
|
134
|
+
};
|
|
135
|
+
var functionNameLoc = (request) => {
|
|
136
|
+
const node = request.node;
|
|
137
|
+
const named = "id" in node && isNode(node.id) ? node.id : memberKeyOf({ node });
|
|
138
|
+
if (named?.loc) {
|
|
139
|
+
return named.loc;
|
|
140
|
+
}
|
|
141
|
+
if (node.type === "ArrowFunctionExpression") {
|
|
142
|
+
return request.sourceCode.getTokenBefore(node.body, { filter: (token) => token.value === "=>" })?.loc;
|
|
143
|
+
}
|
|
144
|
+
return request.sourceCode.getFirstToken(node)?.loc;
|
|
145
|
+
};
|
|
146
|
+
var accessorDisposition = (request) => {
|
|
147
|
+
const parent = request.node.parent;
|
|
148
|
+
return parent !== null && MEMBER_TYPES.has(parent.type) && "kind" in parent && ACCESSOR_KINDS.has(String(parent.kind)) ? "accessor" : "callable";
|
|
149
|
+
};
|
|
150
|
+
var functionLineCount = (request) => request.sourceCode.getTokens(request.body).filter((token) => !(token.type === "Punctuator" && BRACES.has(token.value))).reduce((lines, token) => {
|
|
151
|
+
const previous = request.sourceCode.getTokenBefore(token);
|
|
152
|
+
const triviaStart = previous === null ? token.range[0] : previous.range[1];
|
|
153
|
+
return lines + (request.sourceCode.text.slice(triviaStart, token.range[0]).match(LINE_BREAK)?.length ?? 0);
|
|
154
|
+
}, 0);
|
|
155
|
+
var cognitiveComplexity = {
|
|
156
|
+
meta: {
|
|
157
|
+
type: "suggestion",
|
|
158
|
+
docs: { description: "Limit each function's cognitive complexity to 15 (CD-41)" },
|
|
159
|
+
schema: [],
|
|
160
|
+
messages: {
|
|
161
|
+
cognitiveComplexity: "CD-41: this function's cognitive complexity is {{score}}, above the limit of {{max}}; move the branching into helpers it composes."
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
create: (context) => {
|
|
165
|
+
const reportScored = (scored) => {
|
|
166
|
+
const loc = functionNameLoc({ node: scored.node, sourceCode: context.sourceCode });
|
|
167
|
+
if (loc === void 0) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
context.report({
|
|
171
|
+
loc,
|
|
172
|
+
messageId: "cognitiveComplexity",
|
|
173
|
+
data: { score: String(scored.score), max: String(MAX_COGNITIVE_COMPLEXITY) }
|
|
174
|
+
});
|
|
175
|
+
};
|
|
176
|
+
const scoreOutermost = (node) => {
|
|
177
|
+
if (context.sourceCode.getAncestors(node).some((ancestor) => FUNCTION_TYPES.has(ancestor.type))) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
const scored = scoredFunction({ node, nesting: 0, sourceCode: context.sourceCode });
|
|
181
|
+
[{ node, score: scored.own }, ...scored.nested].filter((entry) => entry.score > MAX_COGNITIVE_COMPLEXITY).forEach(reportScored);
|
|
182
|
+
};
|
|
183
|
+
return {
|
|
184
|
+
FunctionDeclaration: scoreOutermost,
|
|
185
|
+
FunctionExpression: scoreOutermost,
|
|
186
|
+
ArrowFunctionExpression: scoreOutermost
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
var reportLongFunction = (request) => {
|
|
191
|
+
if (accessorDisposition({ node: request.node }) === "accessor" || !("body" in request.node) || !isNode(request.node.body)) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
const lines = functionLineCount({ body: request.node.body, sourceCode: request.context.sourceCode });
|
|
195
|
+
if (lines <= MAX_FUNCTION_LINES) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
request.context.report({
|
|
199
|
+
node: request.node,
|
|
200
|
+
messageId: "functionLength",
|
|
201
|
+
data: { lines: String(lines), max: String(MAX_FUNCTION_LINES) }
|
|
202
|
+
});
|
|
203
|
+
};
|
|
204
|
+
var functionLength = {
|
|
205
|
+
meta: {
|
|
206
|
+
type: "suggestion",
|
|
207
|
+
docs: { description: "Limit each function body to 50 lines (CD-41)" },
|
|
208
|
+
schema: [],
|
|
209
|
+
messages: {
|
|
210
|
+
functionLength: "CD-41: this function body has {{lines}} lines, above the limit of {{max}}; split it into helpers."
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
create: (context) => ({
|
|
214
|
+
FunctionDeclaration: (node) => reportLongFunction({ context, node }),
|
|
215
|
+
FunctionExpression: (node) => reportLongFunction({ context, node }),
|
|
216
|
+
ArrowFunctionExpression: (node) => reportLongFunction({ context, node })
|
|
217
|
+
})
|
|
218
|
+
};
|
|
219
|
+
var cd41_eslint_plugin_default = {
|
|
220
|
+
meta: { name: "hone-cd41", version: "0.0.0-local" },
|
|
221
|
+
rules: {
|
|
222
|
+
"cognitive-complexity": cognitiveComplexity,
|
|
223
|
+
"function-length": functionLength
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
export {
|
|
227
|
+
cd41_eslint_plugin_default as default
|
|
228
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"discipline": "CD-41",
|
|
4
|
+
"mechanism": "eslint",
|
|
5
|
+
"clauses": [
|
|
6
|
+
{
|
|
7
|
+
"clause": "cognitive-complexity",
|
|
8
|
+
"settings": {
|
|
9
|
+
"pluginNamespace": "hone-cd41",
|
|
10
|
+
"pluginModule": "cd41/cd41.eslint-plugin.js",
|
|
11
|
+
"rule": "cognitive-complexity"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"clause": "function-length",
|
|
16
|
+
"settings": {
|
|
17
|
+
"pluginNamespace": "hone-cd41",
|
|
18
|
+
"pluginModule": "cd41/cd41.eslint-plugin.js",
|
|
19
|
+
"rule": "function-length"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# CD-42 ESLint piece
|
|
2
|
+
|
|
3
|
+
This piece enforces CD-42's `useless-else` clause through ESLint. It is one rule, `useless-else`, in the plugin `cd42/cd42.eslint-plugin.ts` under the namespace `hone-cd42`. The rule reports an `else` that follows an `if` branch which always exits, at the `else` keyword.
|
|
4
|
+
|
|
5
|
+
`piece.json` names the clause, the namespace, the plugin module and the rule. It is the only file core reads to find the rule.
|
|
6
|
+
|
|
7
|
+
## Adopting the rule
|
|
8
|
+
|
|
9
|
+
The projection is the only supported way to adopt the rule. Run core's project command for your repository; it writes `disciplines.eslint.mjs` at the repository root, which enables every selected rule and carries your recorded exceptions. Spread its default export last in your flat config. Core's governance run checks that the projection's effect is in force, so enabling the rule some other way is not supported and fails the run as `not-included` once any exception is recorded for it.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import "../../../../chunks/chunk-NZLE2WMY.js";
|
|
2
|
+
|
|
3
|
+
// mechanisms/eslint/CD-42/cd42/cd42.eslint-plugin.ts
|
|
4
|
+
var bothBranchesExit = (request) => {
|
|
5
|
+
if (request.alternate === null || request.alternate === void 0) {
|
|
6
|
+
return "continues";
|
|
7
|
+
}
|
|
8
|
+
return exitDisposition({ statement: request.consequent, reach: request.reach }) === "exits" && exitDisposition({ statement: request.alternate, reach: request.reach }) === "exits" ? "exits" : "continues";
|
|
9
|
+
};
|
|
10
|
+
var everyCaseExits = (request) => {
|
|
11
|
+
const enteredCases = request.cases.filter((switchCase) => switchCase.consequent.length > 0);
|
|
12
|
+
return enteredCases.length > 0 && enteredCases.every(
|
|
13
|
+
(switchCase) => exitDisposition({ statement: switchCase.consequent.at(-1), reach: "break-stays-in-switch" }) === "exits"
|
|
14
|
+
) ? "exits" : "continues";
|
|
15
|
+
};
|
|
16
|
+
var exitDisposition = (request) => {
|
|
17
|
+
const statement = request.statement;
|
|
18
|
+
if (statement === void 0) {
|
|
19
|
+
return "continues";
|
|
20
|
+
}
|
|
21
|
+
if (statement.type === "ReturnStatement" || statement.type === "ThrowStatement" || statement.type === "ContinueStatement") {
|
|
22
|
+
return "exits";
|
|
23
|
+
}
|
|
24
|
+
if (statement.type === "BreakStatement") {
|
|
25
|
+
return request.reach === "break-exits" ? "exits" : "continues";
|
|
26
|
+
}
|
|
27
|
+
if (statement.type === "BlockStatement") {
|
|
28
|
+
return exitDisposition({ statement: statement.body.at(-1), reach: request.reach });
|
|
29
|
+
}
|
|
30
|
+
if (statement.type === "IfStatement") {
|
|
31
|
+
return bothBranchesExit({ consequent: statement.consequent, alternate: statement.alternate, reach: request.reach });
|
|
32
|
+
}
|
|
33
|
+
return statement.type === "SwitchStatement" ? everyCaseExits({ cases: statement.cases }) : "continues";
|
|
34
|
+
};
|
|
35
|
+
var chainPosition = (request) => request.node.parent.type === "IfStatement" && request.node.parent.alternate === request.node ? "else-if" : "chain-head";
|
|
36
|
+
var reportedElses = (request) => {
|
|
37
|
+
if (request.alternate === null || request.alternate === void 0) {
|
|
38
|
+
return [];
|
|
39
|
+
}
|
|
40
|
+
if (exitDisposition({ statement: request.consequent, reach: "break-exits" }) === "continues") {
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
return request.alternate.type === "IfStatement" ? [request.alternate, ...reportedElses({ consequent: request.alternate.consequent, alternate: request.alternate.alternate })] : [request.alternate];
|
|
44
|
+
};
|
|
45
|
+
var uselessElse = {
|
|
46
|
+
meta: {
|
|
47
|
+
type: "suggestion",
|
|
48
|
+
docs: { description: "Disallow else after a branch that always exits (CD-42)" },
|
|
49
|
+
schema: [],
|
|
50
|
+
messages: {
|
|
51
|
+
uselessElse: "CD-42: the branch above always exits, so drop this else and return the happy path last."
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
create: (context) => ({
|
|
55
|
+
IfStatement: (node) => {
|
|
56
|
+
if (chainPosition({ node }) === "else-if") {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
reportedElses({ consequent: node.consequent, alternate: node.alternate }).forEach((alternate) => {
|
|
60
|
+
const elseKeyword = context.sourceCode.getTokenBefore(alternate);
|
|
61
|
+
if (elseKeyword === null) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
context.report({ loc: elseKeyword.loc, messageId: "uselessElse" });
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
};
|
|
69
|
+
var cd42_eslint_plugin_default = {
|
|
70
|
+
meta: { name: "hone-cd42", version: "0.0.0-local" },
|
|
71
|
+
rules: { "useless-else": uselessElse }
|
|
72
|
+
};
|
|
73
|
+
export {
|
|
74
|
+
cd42_eslint_plugin_default as default
|
|
75
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"discipline": "CD-42",
|
|
4
|
+
"mechanism": "eslint",
|
|
5
|
+
"clauses": [
|
|
6
|
+
{
|
|
7
|
+
"clause": "useless-else",
|
|
8
|
+
"settings": {
|
|
9
|
+
"pluginNamespace": "hone-cd42",
|
|
10
|
+
"pluginModule": "cd42/cd42.eslint-plugin.js",
|
|
11
|
+
"rule": "useless-else"
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# CD-44 ESLint piece
|
|
2
|
+
|
|
3
|
+
This piece enforces CD-44's `parameter-reassignment` clause through ESLint. It is one rule, `no-param-reassign`, in the plugin `cd44/cd44.eslint-plugin.ts` under the namespace `hone-cd44`. It reuses ESLint's `no-param-reassign` with the `options` `{ "props": false }` carried in `piece.json`, so it flags reassignment of a parameter itself and leaves its fields to the audit's `parameter-mutation` clause.
|
|
4
|
+
|
|
5
|
+
## Adopting the rule
|
|
6
|
+
|
|
7
|
+
The projection is the only supported way to adopt the rule. Run core's project command for your repository; it writes `disciplines.eslint.mjs` at the repository root, which enables every selected rule and carries your recorded exceptions. Spread its default export last in your flat config. Core's governance run checks that the projection's effect is in force, so enabling the rule some other way is not supported and fails the run as `not-included` once any exception is recorded for it.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defaultNativeRuleSources,
|
|
3
|
+
eslintCoreRules
|
|
4
|
+
} from "../../../../chunks/chunk-HJA4CX7C.js";
|
|
5
|
+
import "../../../../chunks/chunk-NZLE2WMY.js";
|
|
6
|
+
|
|
7
|
+
// mechanisms/eslint/CD-44/cd44/cd44.eslint-plugin.ts
|
|
8
|
+
var createPlugin = (sources) => ({
|
|
9
|
+
meta: { name: "hone-cd44", version: "0.0.0-local" },
|
|
10
|
+
rules: eslintCoreRules({ names: ["no-param-reassign"], sources })
|
|
11
|
+
});
|
|
12
|
+
var cd44_eslint_plugin_default = createPlugin(defaultNativeRuleSources);
|
|
13
|
+
export {
|
|
14
|
+
createPlugin,
|
|
15
|
+
cd44_eslint_plugin_default as default
|
|
16
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"discipline": "CD-44",
|
|
4
|
+
"mechanism": "eslint",
|
|
5
|
+
"clauses": [
|
|
6
|
+
{
|
|
7
|
+
"clause": "parameter-reassignment",
|
|
8
|
+
"settings": {
|
|
9
|
+
"pluginNamespace": "hone-cd44",
|
|
10
|
+
"pluginModule": "cd44/cd44.eslint-plugin.js",
|
|
11
|
+
"rule": "no-param-reassign",
|
|
12
|
+
"options": [
|
|
13
|
+
{
|
|
14
|
+
"props": false
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# CD-6 ESLint piece
|
|
2
|
+
|
|
3
|
+
This piece enforces CD-6's `naming-convention` clause through ESLint. It is one rule, `naming-convention`, in the plugin `cd6/cd6.eslint-plugin.ts` under the namespace `hone-cd6`. It reuses typescript-eslint's `naming-convention` with the option list carried in `piece.json`, which sets the allowed case for each kind of name.
|
|
4
|
+
|
|
5
|
+
`piece.json` names the clause, the namespace, the plugin module, the rule and its `options`. It is the only file core reads to find the rule.
|
|
6
|
+
|
|
7
|
+
## Adopting the rule
|
|
8
|
+
|
|
9
|
+
The projection is the only supported way to adopt the rule. Run core's project command for your repository; it writes `disciplines.eslint.mjs` at the repository root, which enables every selected rule and carries your recorded exceptions. Spread its default export last in your flat config. Core's governance run checks that the projection's effect is in force, so enabling the rule some other way is not supported and fails the run as `not-included` once any exception is recorded for it.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defaultNativeRuleSources,
|
|
3
|
+
typescriptEslintRules
|
|
4
|
+
} from "../../../../chunks/chunk-HJA4CX7C.js";
|
|
5
|
+
import "../../../../chunks/chunk-NZLE2WMY.js";
|
|
6
|
+
|
|
7
|
+
// mechanisms/eslint/CD-6/cd6/cd6.eslint-plugin.ts
|
|
8
|
+
var createPlugin = (sources) => ({
|
|
9
|
+
meta: { name: "hone-cd6", version: "0.0.0-local" },
|
|
10
|
+
rules: typescriptEslintRules({ names: ["naming-convention"], sources })
|
|
11
|
+
});
|
|
12
|
+
var cd6_eslint_plugin_default = createPlugin(defaultNativeRuleSources);
|
|
13
|
+
export {
|
|
14
|
+
createPlugin,
|
|
15
|
+
cd6_eslint_plugin_default as default
|
|
16
|
+
};
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"discipline": "CD-6",
|
|
4
|
+
"mechanism": "eslint",
|
|
5
|
+
"clauses": [
|
|
6
|
+
{
|
|
7
|
+
"clause": "naming-convention",
|
|
8
|
+
"settings": {
|
|
9
|
+
"pluginNamespace": "hone-cd6",
|
|
10
|
+
"pluginModule": "cd6/cd6.eslint-plugin.js",
|
|
11
|
+
"rule": "naming-convention",
|
|
12
|
+
"options": [
|
|
13
|
+
{
|
|
14
|
+
"selector": [
|
|
15
|
+
"objectLiteralProperty",
|
|
16
|
+
"objectLiteralMethod",
|
|
17
|
+
"typeProperty",
|
|
18
|
+
"typeMethod",
|
|
19
|
+
"classProperty",
|
|
20
|
+
"classMethod",
|
|
21
|
+
"accessor",
|
|
22
|
+
"enumMember"
|
|
23
|
+
],
|
|
24
|
+
"modifiers": [
|
|
25
|
+
"requiresQuotes"
|
|
26
|
+
],
|
|
27
|
+
"format": null
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"selector": [
|
|
31
|
+
"variable",
|
|
32
|
+
"function",
|
|
33
|
+
"parameter"
|
|
34
|
+
],
|
|
35
|
+
"modifiers": [
|
|
36
|
+
"unused"
|
|
37
|
+
],
|
|
38
|
+
"format": null,
|
|
39
|
+
"filter": {
|
|
40
|
+
"regex": "^_",
|
|
41
|
+
"match": true
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"selector": [
|
|
46
|
+
"variable",
|
|
47
|
+
"parameter"
|
|
48
|
+
],
|
|
49
|
+
"modifiers": [
|
|
50
|
+
"destructured"
|
|
51
|
+
],
|
|
52
|
+
"format": null
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"selector": "import",
|
|
56
|
+
"format": null
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"selector": [
|
|
60
|
+
"classProperty",
|
|
61
|
+
"classMethod",
|
|
62
|
+
"accessor",
|
|
63
|
+
"parameterProperty"
|
|
64
|
+
],
|
|
65
|
+
"modifiers": [
|
|
66
|
+
"override"
|
|
67
|
+
],
|
|
68
|
+
"format": null
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"selector": "variable",
|
|
72
|
+
"modifiers": [
|
|
73
|
+
"const"
|
|
74
|
+
],
|
|
75
|
+
"format": null,
|
|
76
|
+
"custom": {
|
|
77
|
+
"regex": "^(?:[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*|[a-z0-9][A-Za-z0-9]*|[A-Z](?:[A-Za-z0-9]*[a-z][A-Za-z0-9]*|[0-9]*))$",
|
|
78
|
+
"match": true
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"selector": "variable",
|
|
83
|
+
"format": null,
|
|
84
|
+
"custom": {
|
|
85
|
+
"regex": "^[_$]*(?:[a-z0-9][A-Za-z0-9]*|[A-Z](?:[A-Za-z0-9]*[a-z][A-Za-z0-9]*|[0-9]*))?[_$]*$",
|
|
86
|
+
"match": true
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"selector": "function",
|
|
91
|
+
"format": null,
|
|
92
|
+
"custom": {
|
|
93
|
+
"regex": "^[_$]*(?:[a-z0-9][A-Za-z0-9]*|[A-Z](?:[A-Za-z0-9]*[a-z][A-Za-z0-9]*|[0-9]*))?[_$]*$",
|
|
94
|
+
"match": true
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"selector": "function",
|
|
99
|
+
"modifiers": [
|
|
100
|
+
"global"
|
|
101
|
+
],
|
|
102
|
+
"format": null,
|
|
103
|
+
"custom": {
|
|
104
|
+
"regex": "^[_$]*(?:[a-z0-9][A-Za-z0-9]*|[A-Z](?:[A-Za-z0-9]*[a-z][A-Za-z0-9]*|[0-9]*)|[A-Z][A-Z0-9]*)?[_$]*$",
|
|
105
|
+
"match": true
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"selector": "parameter",
|
|
110
|
+
"format": null,
|
|
111
|
+
"custom": {
|
|
112
|
+
"regex": "^[_$]*(?:[a-z0-9][A-Za-z0-9]*|[A-Z](?:[A-Za-z0-9]*[a-z][A-Za-z0-9]*|[0-9]*))?[_$]*$",
|
|
113
|
+
"match": true
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"selector": "typeLike",
|
|
118
|
+
"format": null,
|
|
119
|
+
"custom": {
|
|
120
|
+
"regex": "^[_$]*(?:[A-Z](?:[A-Za-z0-9]*[a-z][A-Za-z0-9]*|[0-9]*))?[_$]*$",
|
|
121
|
+
"match": true
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"selector": "enumMember",
|
|
126
|
+
"format": null,
|
|
127
|
+
"custom": {
|
|
128
|
+
"regex": "^(?:[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*)$",
|
|
129
|
+
"match": true
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"selector": [
|
|
134
|
+
"classProperty",
|
|
135
|
+
"classMethod",
|
|
136
|
+
"accessor",
|
|
137
|
+
"parameterProperty"
|
|
138
|
+
],
|
|
139
|
+
"format": null,
|
|
140
|
+
"custom": {
|
|
141
|
+
"regex": "^[_$]*(?:[a-z0-9][A-Za-z0-9]*)?[_$]*$",
|
|
142
|
+
"match": true
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"selector": [
|
|
147
|
+
"classProperty",
|
|
148
|
+
"accessor"
|
|
149
|
+
],
|
|
150
|
+
"modifiers": [
|
|
151
|
+
"static"
|
|
152
|
+
],
|
|
153
|
+
"format": null,
|
|
154
|
+
"custom": {
|
|
155
|
+
"regex": "^[_$]*(?:[a-z0-9][A-Za-z0-9]*|[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*)?[_$]*$",
|
|
156
|
+
"match": true
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
"selector": "objectLiteralProperty",
|
|
161
|
+
"format": null,
|
|
162
|
+
"custom": {
|
|
163
|
+
"regex": "^(?:[a-z0-9][A-Za-z0-9]*)$",
|
|
164
|
+
"match": true
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"selector": "objectLiteralMethod",
|
|
169
|
+
"format": null,
|
|
170
|
+
"custom": {
|
|
171
|
+
"regex": "^[_$]*(?:[a-z0-9][A-Za-z0-9]*)?[_$]*$",
|
|
172
|
+
"match": true
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
"selector": "typeProperty",
|
|
177
|
+
"format": null,
|
|
178
|
+
"custom": {
|
|
179
|
+
"regex": "^(?:[a-z0-9][A-Za-z0-9]*|[A-Z](?:[A-Za-z0-9]*[a-z][A-Za-z0-9]*|[0-9]*))$",
|
|
180
|
+
"match": true
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"selector": "typeMethod",
|
|
185
|
+
"format": null,
|
|
186
|
+
"custom": {
|
|
187
|
+
"regex": "^[_$]*(?:[a-z0-9][A-Za-z0-9]*)?[_$]*$",
|
|
188
|
+
"match": true
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"selector": "import",
|
|
193
|
+
"modifiers": [
|
|
194
|
+
"default"
|
|
195
|
+
],
|
|
196
|
+
"format": null,
|
|
197
|
+
"custom": {
|
|
198
|
+
"regex": "^[_$]*(?:[a-z0-9][A-Za-z0-9]*|[A-Z](?:[A-Za-z0-9]*[a-z][A-Za-z0-9]*|[0-9]*)|[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*)?[_$]*$",
|
|
199
|
+
"match": true
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"selector": "import",
|
|
204
|
+
"modifiers": [
|
|
205
|
+
"namespace"
|
|
206
|
+
],
|
|
207
|
+
"format": null,
|
|
208
|
+
"custom": {
|
|
209
|
+
"regex": "^[_$]*(?:[a-z0-9][A-Za-z0-9]*|[A-Z](?:[A-Za-z0-9]*[a-z][A-Za-z0-9]*|[0-9]*))?[_$]*$",
|
|
210
|
+
"match": true
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
]
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
]
|
|
217
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# CD-7 ESLint piece
|
|
2
|
+
|
|
3
|
+
This piece enforces CD-7's `filename-case` clause through ESLint. It is one rule, `filename-case`, in the plugin `cd7/cd7.eslint-plugin.ts` under the namespace `hone-cd7`. The rule reports at line 1 of any file whose name is not kebab-case or PascalCase before its first dot.
|
|
4
|
+
|
|
5
|
+
`piece.json` names the clause, the namespace, the plugin module and the rule. It is the only file core reads to find the rule.
|
|
6
|
+
|
|
7
|
+
## Adopting the rule
|
|
8
|
+
|
|
9
|
+
The projection is the only supported way to adopt the rule. Run core's project command for your repository; it writes `disciplines.eslint.mjs` at the repository root, which enables every selected rule and carries your recorded exceptions. Spread its default export last in your flat config. Core's governance run checks that the projection's effect is in force, so enabling the rule some other way is not supported and fails the run as `not-included` once any exception is recorded for it.
|