@hailstails/hone 1.3.0 → 1.4.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 +2 -2
- package/CHANGELOG.md +22 -0
- package/MIGRATING.md +23 -0
- package/README.md +27 -6
- package/api/audit.d.ts +1 -1
- package/api/testing.js +3 -3
- package/chunks/chunk-335ITLPO.js +7 -0
- package/chunks/{chunk-YSN46EB3.js → chunk-6SM3HKWO.js} +270 -624
- package/chunks/{chunk-PL2PNPAR.js → chunk-E6VR3VRV.js} +1 -6
- package/chunks/{chunk-H4V72FCW.js → chunk-FEWCJU7H.js} +9 -1
- package/chunks/chunk-WF3PPYRR.js +27 -0
- package/core/check/tool-command.js +756 -64
- package/core/mechanism-port/runner-result-types.d.ts +6 -0
- package/docs/adding-a-discipline-or-mechanism.md +3 -3
- package/docs/extending.md +1 -0
- package/docs/output-contract.md +52 -10
- package/mechanisms/audit/CD-27/test-body-logic.js +394 -46
- package/mechanisms/audit/runner/runner.js +1 -1
- package/mechanisms/audit/runner/typescript-parse.d.ts +2 -0
- package/mechanisms/audit/runner/walker-piece.d.ts +2 -1
- package/mechanisms/eslint/CD-1/cd1/cd1.eslint-plugin.js +7 -4
- package/mechanisms/eslint/CD-10/cd10/cd10.eslint-plugin.js +21 -11
- package/mechanisms/eslint/CD-14/cd14/cd14.eslint-plugin.js +15 -5
- package/mechanisms/eslint/CD-27/cd27/cd27.eslint-plugin.js +7 -3
- package/mechanisms/eslint/CD-41/README.md +1 -1
- package/mechanisms/eslint/CD-41/cd41/cd41.eslint-plugin.js +100 -28
- package/mechanisms/eslint/CD-42/cd42/cd42.eslint-plugin.js +8 -4
- package/mechanisms/eslint/CD-7/cd7/cd7.eslint-plugin.js +8 -4
- package/mechanisms/eslint/runner/README.md +9 -2
- package/mechanisms/eslint/runner/runner.js +1404 -1382
- package/methods/lenses/di-discipline.md +4 -5
- package/methods/lenses/test-discipline.md +1 -1
- package/package.json +1 -1
- package/rules/CD-1/CHECKS.md +2 -0
- package/rules/CD-12/README.md +1 -1
- package/rules/CD-15/CHECKS.md +2 -0
- package/rules/CD-17/README.md +3 -3
- package/rules/CD-2/CHECKS.md +2 -0
- package/rules/CD-25/CHECKS.md +2 -2
- package/rules/CD-25/README.md +3 -3
- package/rules/CD-27/CHECKS.md +382 -6
- package/rules/CD-27/README.md +1 -1
- package/rules/CD-27/discipline.json +130 -0
- package/rules/CD-41/CHECKS.md +10 -0
- package/rules/CD-41/README.md +2 -0
- package/rules/CD-41/discipline.json +14 -0
- package/chunks/chunk-YLZ73C7O.js +0 -0
|
@@ -99,6 +99,118 @@
|
|
|
99
99
|
2
|
|
100
100
|
],
|
|
101
101
|
"edition": "2"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"name": "join on node:path with several segments",
|
|
105
|
+
"fileName": "node-path.test.ts",
|
|
106
|
+
"source": "import path from \"node:path\";\nexpect(path.join(\"a\", \"b\", \"c\")).toBe(\"a/b/c\");\n",
|
|
107
|
+
"expectedLines": [
|
|
108
|
+
2
|
|
109
|
+
]
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"name": "a library helper given an object",
|
|
113
|
+
"fileName": "library.test.ts",
|
|
114
|
+
"source": "import _ from \"lodash\";\nexpect(_.find([{ id: \"a\" }], { id: \"a\" }, 0, 1)).toEqual({ id: \"a\" });\n",
|
|
115
|
+
"expectedLines": [
|
|
116
|
+
2
|
|
117
|
+
]
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"name": "Object.entries given an object",
|
|
121
|
+
"fileName": "object-entries.test.ts",
|
|
122
|
+
"source": "expect(Object.entries({ a: 1 })).toEqual([[\"a\", 1]]);\n",
|
|
123
|
+
"expectedLines": [
|
|
124
|
+
1
|
|
125
|
+
]
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"name": "join on a dynamic import of node:path",
|
|
129
|
+
"fileName": "dynamic-path.test.ts",
|
|
130
|
+
"source": "const path = await import(\"node:path\");\nexpect(path.join(\"a\", \"b\", \"c\")).toBe(\"a/b/c\");\n",
|
|
131
|
+
"expectedLines": [
|
|
132
|
+
2
|
|
133
|
+
]
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"name": "join on a required node:path",
|
|
137
|
+
"fileName": "required-path.test.ts",
|
|
138
|
+
"source": "const path = require(\"node:path\");\nexpect(path.join(\"a\", \"b\", \"c\")).toBe(\"a/b/c\");\n",
|
|
139
|
+
"expectedLines": [
|
|
140
|
+
2
|
|
141
|
+
]
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"name": "join on an import-equals of node:path",
|
|
145
|
+
"fileName": "import-equals-path.test.ts",
|
|
146
|
+
"source": "import path = require(\"node:path\");\nexpect(path.join(\"a\", \"b\", \"c\")).toBe(\"a/b/c\");\n",
|
|
147
|
+
"expectedLines": [
|
|
148
|
+
2
|
|
149
|
+
]
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"name": "join on a member destructured from node:path",
|
|
153
|
+
"fileName": "posix-path.test.ts",
|
|
154
|
+
"source": "import path from \"node:path\";\nconst { posix } = path;\nexpect(posix.join(\"a\", \"b\", \"c\")).toBe(\"a/b/c\");\n",
|
|
155
|
+
"expectedLines": [
|
|
156
|
+
3
|
|
157
|
+
]
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
"name": "join on node:path held in an object literal",
|
|
161
|
+
"fileName": "held-path.test.ts",
|
|
162
|
+
"source": "import path from \"node:path\";\nconst deps = { path };\nexpect(deps.path.join(\"a\", \"b\", \"c\")).toBe(\"a/b/c\");\n",
|
|
163
|
+
"expectedLines": [
|
|
164
|
+
3
|
|
165
|
+
]
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"name": "entries on an alias of Object",
|
|
169
|
+
"fileName": "object-alias.test.ts",
|
|
170
|
+
"source": "const o = Object;\nexpect(o.entries({ a: 1 })).toEqual([[\"a\", 1]]);\n",
|
|
171
|
+
"expectedLines": [
|
|
172
|
+
2
|
|
173
|
+
]
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
"name": "find given an object as this",
|
|
177
|
+
"fileName": "find-this.test.ts",
|
|
178
|
+
"source": "declare const rows: readonly { readonly id: string }[];\ndeclare const isA: (row: { readonly id: string }) => boolean;\nexpect(rows.find(isA, {})).toEqual({ id: \"a\" });\n",
|
|
179
|
+
"expectedLines": [
|
|
180
|
+
3
|
|
181
|
+
]
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"name": "split given a splitter object",
|
|
185
|
+
"fileName": "split-protocol.test.ts",
|
|
186
|
+
"source": "declare const text: string;\ndeclare const splitter: (text: string) => string[];\nexpect(text.split({ [Symbol.split]: splitter })).toEqual([\"a\"]);\n",
|
|
187
|
+
"expectedLines": [
|
|
188
|
+
3
|
|
189
|
+
]
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"name": "includes given an object",
|
|
193
|
+
"fileName": "includes-object.test.ts",
|
|
194
|
+
"source": "const rows = [{ id: \"a\" }];\nexpect(rows.includes({ id: \"a\" })).toBe(false);\n",
|
|
195
|
+
"expectedLines": [
|
|
196
|
+
2
|
|
197
|
+
]
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
"name": "reduce given an object to start from",
|
|
201
|
+
"fileName": "reduce-object.test.ts",
|
|
202
|
+
"source": "declare const sum: (total: { readonly total: number }, row: number) => { readonly total: number };\nexpect([1].reduce(sum, { total: 0 })).toEqual({ total: 1 });\n",
|
|
203
|
+
"expectedLines": [
|
|
204
|
+
2
|
|
205
|
+
]
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
"name": "a port method given a variable",
|
|
209
|
+
"fileName": "port-variable.test.ts",
|
|
210
|
+
"source": "declare const paths: { readonly join: (request: { readonly segments: readonly string[] }) => string };\nconst request = { segments: [\"a\"] };\nexpect(paths.join(request)).toBe(\"a\");\n",
|
|
211
|
+
"expectedLines": [
|
|
212
|
+
3
|
|
213
|
+
]
|
|
102
214
|
}
|
|
103
215
|
],
|
|
104
216
|
"allow": [
|
|
@@ -139,6 +251,24 @@
|
|
|
139
251
|
"source": "const calls = [[1]];\nexpect(calls[0]).toEqual([1]);\n",
|
|
140
252
|
"expectedLines": [],
|
|
141
253
|
"edition": "2"
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
"name": "the adopter's own port method given an object",
|
|
257
|
+
"fileName": "own-port.test.ts",
|
|
258
|
+
"source": "declare const paths: { readonly join: (request: { readonly segments: readonly string[] }) => string };\nexpect(paths.join({ segments: [\"a\", \"b\"] })).toBe(\"a/b\");\n",
|
|
259
|
+
"expectedLines": []
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
"name": "the adopter's own method given more arguments than any built-in of its name takes",
|
|
263
|
+
"fileName": "own-arity.test.ts",
|
|
264
|
+
"source": "declare const screen: { readonly keys: (text: string, literal: boolean, submit: boolean) => void };\nscreen.keys(\"x\", true, true);\n",
|
|
265
|
+
"expectedLines": []
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
"name": "the adopter's own port imported from a relative module",
|
|
269
|
+
"fileName": "own-import.test.ts",
|
|
270
|
+
"source": "import { paths } from \"./paths.ts\";\nexpect(paths.join({ segments: [\"a\"] })).toBe(\"a\");\n",
|
|
271
|
+
"expectedLines": []
|
|
142
272
|
}
|
|
143
273
|
]
|
|
144
274
|
}
|
package/rules/CD-41/CHECKS.md
CHANGED
|
@@ -19,6 +19,16 @@ Read [the rule and its spirit](README.md) first. This page is the mechanics: wha
|
|
|
19
19
|
- A nested function is scored on its own, starting one level deeper, and its score is not added to its parent.
|
|
20
20
|
- Reported at the function's name.
|
|
21
21
|
- `hone-cd41/function-length`: a function body may span at most 50 lines. Blank and comment lines count; lines holding only `{` or `}` do not. Getters and setters are not checked. Reported at the function.
|
|
22
|
+
- A test suite's body is not checked. A suite body is a function passed as an argument to the call that runs a suite:
|
|
23
|
+
- `describe`, `suite`, `fdescribe`, `xdescribe`, `fsuite` or `xsuite`, alone or followed only by the modifiers `each`, `for`, `only`, `skip`, `todo`, `concurrent`, `sequential`, `shuffle`, `skipIf` and `runIf`, such as `describe.each(table)(name, fn)`, `describe.each` with a template table, `describe.only.each(table)(name, fn)` or `describe.skipIf(condition)(name, fn)`;
|
|
24
|
+
- Playwright's `test.describe`, alone or followed only by `only`, `skip`, `fixme`, `serial` and `parallel`, such as `test.describe.serial.only(name, fn)`.
|
|
25
|
+
- A suite nested in a suite is not checked either.
|
|
26
|
+
- Everything else is checked as any function is:
|
|
27
|
+
- each function inside a suite's body: each `it` and `test` callback, each hook and each helper declared there;
|
|
28
|
+
- a function given to `describe.each` as a table entry;
|
|
29
|
+
- a callback on any other member of those names, such as `test.describe.configure(fn)` or `suite.add(name, fn)` on a benchmark suite;
|
|
30
|
+
- mocha's `context`, and any other suite function not listed above.
|
|
31
|
+
- The check matches names, not bindings, so a local function of the repository's own named `describe` or `suite` is treated as a suite when called that way.
|
|
22
32
|
- `orchestration-only` is a judgement clause. It cannot be selected and is enforced by review.
|
|
23
33
|
|
|
24
34
|
## Example violation
|
package/rules/CD-41/README.md
CHANGED
|
@@ -16,6 +16,8 @@ Review lens: [decomposition](../../methods/lenses/decomposition.md). The lens re
|
|
|
16
16
|
- *Failures checked inline.* Nesting deepens because each failure is handled in place. Return early on failure, or let helpers return results the coordinator only routes.
|
|
17
17
|
- *Shapes that do not meet.* The coordinator reshapes data between calls because its helpers disagree. Align the helpers' inputs and outputs.
|
|
18
18
|
|
|
19
|
+
**What a finding does not point at.** A test suite's `describe` body is a list of cases, not a coordinator, so its length is not a finding. Splitting a suite only to shorten it adds nothing. The tests and helpers inside it are still functions, and each is judged on its own.
|
|
20
|
+
|
|
19
21
|
**Where to go.** Coordinators read as a short list of named steps. Each helper does one thing at one level of detail.
|
|
20
22
|
|
|
21
23
|
**Reactions to distrust.**
|
|
@@ -96,6 +96,14 @@
|
|
|
96
96
|
"expectedLines": [
|
|
97
97
|
1
|
|
98
98
|
]
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"name": "an it callback inside a describe",
|
|
102
|
+
"fileName": "src/steps.test.ts",
|
|
103
|
+
"source": "describe(\"steps\", () => {\n it(\"runs\", () => {\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n });\n});\n",
|
|
104
|
+
"expectedLines": [
|
|
105
|
+
2
|
|
106
|
+
]
|
|
99
107
|
}
|
|
100
108
|
],
|
|
101
109
|
"allow": [
|
|
@@ -110,6 +118,12 @@
|
|
|
110
118
|
"fileName": "src/steps.ts",
|
|
111
119
|
"source": "export function steps(): void {\n step0();\n step1();\n step2();\n step3();\n step4();\n step5();\n step6();\n step7();\n step8();\n step9();\n step10();\n step11();\n step12();\n step13();\n step14();\n step15();\n step16();\n step17();\n step18();\n step19();\n step20();\n step21();\n step22();\n step23();\n step24();\n step25();\n step26();\n step27();\n step28();\n step29();\n step30();\n step31();\n step32();\n step33();\n step34();\n step35();\n step36();\n step37();\n step38();\n step39();\n step40();\n step41();\n step42();\n step43();\n if (ready0) {\n run();\n }\n if (ready1) {\n run();\n }\n if (ready2) {\n run();\n }\n}\n",
|
|
112
120
|
"expectedLines": []
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"name": "a describe callback is not a function to shorten",
|
|
124
|
+
"fileName": "src/steps.test.ts",
|
|
125
|
+
"source": "describe(\"steps\", () => {\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n});\n",
|
|
126
|
+
"expectedLines": []
|
|
113
127
|
}
|
|
114
128
|
]
|
|
115
129
|
}
|
package/chunks/chunk-YLZ73C7O.js
DELETED
|
File without changes
|