@antelopejs/tooling-configs 0.4.1 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +68 -29
- package/dist/bin/api-diff.mjs +235 -37
- package/dist/bin/body-check.mjs +14 -11
- package/dist/bin/capture.mjs +173 -54
- package/dist/bin/check-size.mjs +1 -1
- package/dist/bin/checks.mjs +166 -11
- package/dist/bin/comment-proof.mjs +29 -7
- package/dist/bin/garden.mjs +8 -58
- package/dist/bin/lease.mjs +48 -11
- package/dist/bin/ratchet.mjs +48 -14
- package/dist/bin/suppressions.mjs +3 -3
- package/dist/bin/sync.mjs +199 -80
- package/dist/bin/verify.mjs +1163 -474
- package/dist/capture/index.d.mts +6 -1
- package/dist/capture/index.mjs +1 -1
- package/dist/{ci-workflow-37qJa9LX.mjs → ci-workflow-COJUT12b.mjs} +121 -1
- package/dist/eslint.d.mts +16 -3
- package/dist/eslint.mjs +21 -6
- package/dist/formal/index.d.mts +20 -4
- package/dist/formal/index.mjs +71 -19
- package/dist/{map-B23_WMGE.mjs → map-DRyYz_Fw.mjs} +20 -1
- package/dist/oxc/anti-slop/index.mjs +156 -421
- package/dist/oxc/guardrails/index.d.mts +1 -1
- package/dist/oxc/guardrails/index.mjs +789 -103
- package/dist/oxc/lint.d.mts +13 -15
- package/dist/oxc/lint.mjs +19 -29
- package/dist/{package-CqqBgE8Y.mjs → package-Dn7VTFUW.mjs} +71 -17
- package/dist/{proof-stamp-DDDC0J6l.mjs → proof-stamp-DLWpPwQE.mjs} +72 -10
- package/dist/{ratchet-Q-JXuZIX.mjs → ratchet-ClfblHNJ.mjs} +18 -15
- package/dist/require-safety-comment-for-type-assertion-mnb0CIxa.mjs +181 -0
- package/dist/{scenes-DZVXkcxS.mjs → scenes-d-VQ0LOm.mjs} +4 -1
- package/dist/semver-BDxeEcP_.mjs +57 -0
- package/dist/{suppression-base-9L8dlMQK.mjs → suppression-base-Drnl6Y7F.mjs} +2 -2
- package/dist/{suppression-budget-C0SkPO5R.mjs → suppression-budget-Dvb_IqBo.mjs} +1 -1
- package/dist/{suppressions-DM60NkvL.mjs → suppressions-BroaaGJ_.mjs} +1 -1
- package/dist/{templates-BKZv-BRw.mjs → templates-lJBZFskp.mjs} +8 -3
- package/dist/type-aware-rules-DMuN6sHb.mjs +30 -0
- package/dist/{typescript-DAgQIAAR.mjs → typescript-BBbry7uU.mjs} +123 -27
- package/dist/verify/index.d.mts +60 -15
- package/package.json +3 -1
- package/dist/require-safety-comment-for-type-assertion-BBQ669kj.mjs +0 -83
package/dist/verify/index.d.mts
CHANGED
|
@@ -83,11 +83,23 @@ interface CommandResult {
|
|
|
83
83
|
stdout: string;
|
|
84
84
|
stderr: string;
|
|
85
85
|
}
|
|
86
|
+
/** A journey's HTTP request. `headers` win over the `content-type: application/json` a `body` gets by default. */
|
|
87
|
+
interface HttpInit {
|
|
88
|
+
method?: string;
|
|
89
|
+
body?: string;
|
|
90
|
+
headers?: {
|
|
91
|
+
[name: string]: string;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
86
94
|
/** The answer of an HTTP request, or the network error when nothing answered. */
|
|
87
95
|
interface HttpResult {
|
|
88
96
|
folder: string;
|
|
89
97
|
url: string;
|
|
90
98
|
status: number | null;
|
|
99
|
+
/** The response headers, names lower-cased; empty when nothing answered. */
|
|
100
|
+
headers: {
|
|
101
|
+
[name: string]: string;
|
|
102
|
+
};
|
|
91
103
|
body: string;
|
|
92
104
|
json: JsonValue | undefined;
|
|
93
105
|
error: string | null;
|
|
@@ -97,12 +109,16 @@ interface TreeRecord {
|
|
|
97
109
|
folder: string;
|
|
98
110
|
lines: string[];
|
|
99
111
|
}
|
|
100
|
-
/** Options of `
|
|
112
|
+
/** Options of `context.dev`: extra environment and extra flags such as `--watch`. */
|
|
101
113
|
interface DevOptions {
|
|
102
114
|
env?: {
|
|
103
115
|
[name: string]: string;
|
|
104
116
|
};
|
|
105
117
|
args?: string[];
|
|
118
|
+
/**
|
|
119
|
+
* The program and arguments that start the project in place of `ajs project dev`, for a project that is not an `ajs` project, such as `["node", "ace", "serve"]`. `args` follow it.
|
|
120
|
+
*/
|
|
121
|
+
command?: [program: string, ...args: string[]];
|
|
106
122
|
}
|
|
107
123
|
/** Options of a driven command. */
|
|
108
124
|
interface DriveOptions {
|
|
@@ -116,7 +132,7 @@ interface DriveOptions {
|
|
|
116
132
|
interface CallRequest {
|
|
117
133
|
/** The interface package; defaults to the interface under verification, or the module's only implemented interface. */
|
|
118
134
|
interface?: string;
|
|
119
|
-
/** The export subpath,
|
|
135
|
+
/** The export subpath; defaults to the interface's only entry, else `.`. */
|
|
120
136
|
entry?: string;
|
|
121
137
|
/** The member path inside the entry, for example `["GetClient"]`. */
|
|
122
138
|
path: string[];
|
|
@@ -154,13 +170,12 @@ interface JourneyContext {
|
|
|
154
170
|
readonly work: string;
|
|
155
171
|
/** The journey's own HOME. */
|
|
156
172
|
readonly home: string;
|
|
173
|
+
/** Runs a program. A project whose `.antelope/cache` gains more than one module during it keeps no cache for later journeys; run `ajs` through `ajs` to keep one. */
|
|
157
174
|
command(name: string, program: string, args: string[], options?: DriveOptions): Promise<CommandResult>;
|
|
175
|
+
/** Writes `content` to `file` in a new step and returns the step folder; a file with other hard links gets a new inode, so the write reaches no other path. */
|
|
158
176
|
edit(name: string, file: string, content: string): string;
|
|
159
177
|
tree(name: string, root: string): TreeRecord;
|
|
160
|
-
http(name: string, url: string, init?:
|
|
161
|
-
method?: string;
|
|
162
|
-
body?: string;
|
|
163
|
-
}): Promise<HttpResult>;
|
|
178
|
+
http(name: string, url: string, init?: HttpInit): Promise<HttpResult>;
|
|
164
179
|
/** Records the checks of a step. A failing `critical` step ends the journey. */
|
|
165
180
|
expect(folder: string, checks: Check[], options?: {
|
|
166
181
|
critical?: boolean;
|
|
@@ -182,14 +197,14 @@ interface JourneyContext {
|
|
|
182
197
|
fixture(options?: {
|
|
183
198
|
moduleConfig?: JsonObject;
|
|
184
199
|
}): string;
|
|
185
|
-
/** Starts `ajs project dev` in a project and waits until it is ready. */
|
|
200
|
+
/** Starts `ajs project dev`, or `options.command`, in a project, records its PID for `stop` and `clean`, and waits until it is ready. */
|
|
186
201
|
dev(name: string, project: string, options?: DevOptions): Promise<App>;
|
|
187
202
|
call(name: string, app: App, request: CallRequest): Promise<CallResult>;
|
|
188
203
|
/** Stops an app with SIGINT by recorded PID. */
|
|
189
204
|
stop(name: string, app: App): Promise<StopResult>;
|
|
190
205
|
/**
|
|
191
|
-
* Creates a project from the template under verification with `ajs project init
|
|
192
|
-
* Once init succeeds, the project's `.antelope/cache` starts as a copy of a cache of registry modules an earlier passing journey of the run left exactly as a fresh `ajs` install leaves it, none installed from a lock record.
|
|
206
|
+
* Creates a project from the template under verification with `ajs project init`, or a module with `ajs module init` when `template.module` is set.
|
|
207
|
+
* Once a project init succeeds, the project's `.antelope/cache` starts as a copy of a cache of registry modules an earlier passing journey of the run left exactly as a fresh `ajs` install leaves it, none installed from a lock record.
|
|
193
208
|
*/
|
|
194
209
|
scaffold(name: string, project: string, flags?: string[]): Promise<CommandResult>;
|
|
195
210
|
/**
|
|
@@ -207,12 +222,20 @@ interface JourneyContext {
|
|
|
207
222
|
* that build's evidence under `build/`. A build that is not kept is built
|
|
208
223
|
* again by the next journey. Rerunning the journey that built builds again.
|
|
209
224
|
* In a copy, an absolute symlink into the built folder points to the same
|
|
210
|
-
* path in the copy; every other symlink keeps its target.
|
|
225
|
+
* path in the copy; every other symlink keeps its target. A file with a hard
|
|
226
|
+
* link outside the built folder, such as a package file pnpm links from its
|
|
227
|
+
* store, is linked into each copy rather than copied: `edit` gives it a new
|
|
228
|
+
* inode, and a journey that writes it another way replaces it instead of
|
|
229
|
+
* writing it in place. `build` writes
|
|
211
230
|
* only inside the folder it is given: what it writes elsewhere, such as a
|
|
212
231
|
* sibling in the journey's work folder or the repository, stays with the
|
|
213
232
|
* journey that built. Two journeys that ask for the same key at once, in
|
|
214
233
|
* concurrent `journey` commands, both build, and the first to finish is
|
|
215
|
-
* kept.
|
|
234
|
+
* kept. A project `build` creates with `scaffold` starts each copy as
|
|
235
|
+
* `scaffold` starts one: a copy whose `.antelope/cache` holds no module
|
|
236
|
+
* gets a cache an earlier passing journey kept, and a passing journey keeps
|
|
237
|
+
* the registry modules installed into its copy for later journeys.
|
|
238
|
+
* The commands `build` runs get a HOME of their own, deleted when
|
|
216
239
|
* `build` ends, so what they write there (`ajs config set git`, caches) is
|
|
217
240
|
* never kept and every journey continues with its own HOME. Every journey
|
|
218
241
|
* passes the same `build` for a key. `key` is lowercase letters and digits
|
|
@@ -256,6 +279,25 @@ interface TemplateProbe {
|
|
|
256
279
|
/** How long the process must keep running after `log` matches, 3000 ms by default: core prints nothing once modules start. */
|
|
257
280
|
settleMs?: number;
|
|
258
281
|
}
|
|
282
|
+
/** A module the fixture project loads next to the module under verification: its `antelope.config.ts` source and config. */
|
|
283
|
+
type CompanionModule = {
|
|
284
|
+
source: JsonObject;
|
|
285
|
+
config?: JsonObject;
|
|
286
|
+
};
|
|
287
|
+
/**
|
|
288
|
+
* How `ajs` creates from a template. A project template (`project`) is listed
|
|
289
|
+
* under `projectTemplates` and created with `ajs project init`; a module
|
|
290
|
+
* template (`module`) is listed under `templates` and created with
|
|
291
|
+
* `ajs module init`; any other template is listed under `templates` and
|
|
292
|
+
* created as the app module of a project with `ajs project init`.
|
|
293
|
+
*/
|
|
294
|
+
type TemplateInit = {
|
|
295
|
+
project?: boolean;
|
|
296
|
+
module?: false;
|
|
297
|
+
} | {
|
|
298
|
+
module: true;
|
|
299
|
+
project?: false;
|
|
300
|
+
};
|
|
259
301
|
/** The repo-owned layer of a shared verification skill: `.agents/skills/verify-<kind>/verify.config.ts`. */
|
|
260
302
|
interface VerifyConfig<Api = never> {
|
|
261
303
|
doors: DoorRules;
|
|
@@ -283,13 +325,16 @@ interface VerifyConfig<Api = never> {
|
|
|
283
325
|
};
|
|
284
326
|
/** The module kind's configuration of the module under verification. */
|
|
285
327
|
moduleConfig?(services: ServiceEndpoint[]): JsonObject;
|
|
328
|
+
/** Other modules every fixture project loads, keyed by module name, such as the provider of an interface the module imports that nothing else implements. */
|
|
329
|
+
companions?(services: ServiceEndpoint[]): {
|
|
330
|
+
[name: string]: CompanionModule;
|
|
331
|
+
};
|
|
286
332
|
interface?: InterfaceHooks<Api>;
|
|
287
|
-
/** The template kind: its name in the offline manifest,
|
|
333
|
+
/** The template kind: its name in the offline manifest, how `ajs` creates from it, and its readiness probe. */
|
|
288
334
|
template?: {
|
|
289
335
|
name?: string;
|
|
290
|
-
project?: boolean;
|
|
291
336
|
probe: TemplateProbe;
|
|
292
|
-
};
|
|
337
|
+
} & TemplateInit;
|
|
293
338
|
}
|
|
294
339
|
//#endregion
|
|
295
340
|
//#region src/verify/checks.d.ts
|
|
@@ -320,4 +365,4 @@ declare function answers(result: HttpResult, key: string, expected: JsonValue):
|
|
|
320
365
|
/** Nothing answered the request. */
|
|
321
366
|
declare function refused(result: HttpResult): Check;
|
|
322
367
|
//#endregion
|
|
323
|
-
export { type App, type BehaviourMethod, type CallRequest, type CallResult, type Check, type CommandResult, type DevOptions, type DoorKind, type DoorRule, type DoorRules, type DriveOptions, type FormalCheck, type HttpResult, type InterfaceCall, type InterfaceHooks, type Journey, type JourneyContext, type ServiceDefinition, type ServiceEndpoint, type StopResult, type TemplateProbe, type VerifyConfig, answered, answers, equal, exists, exitIs, fileHas, has, interrupted, lacks, refused };
|
|
368
|
+
export { type App, type BehaviourMethod, type CallRequest, type CallResult, type Check, type CommandResult, type CompanionModule, type DevOptions, type DoorKind, type DoorRule, type DoorRules, type DriveOptions, type FormalCheck, type HttpInit, type HttpResult, type InterfaceCall, type InterfaceHooks, type Journey, type JourneyContext, type ServiceDefinition, type ServiceEndpoint, type StopResult, type TemplateInit, type TemplateProbe, type VerifyConfig, answered, answers, equal, exists, exitIs, fileHas, has, interrupted, lacks, refused };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antelopejs/tooling-configs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Shared tooling presets for AntelopeJS repositories: oxlint (with the vendored anti-slop rules), oxfmt, ESLint for Nuxt layers, Knip, and an interface range check",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"antelopejs",
|
|
@@ -88,6 +88,8 @@
|
|
|
88
88
|
"@nuxt/eslint-config": "^1.17.0",
|
|
89
89
|
"@types/node": "^24.13.3",
|
|
90
90
|
"@types/semver": "^7.8.0",
|
|
91
|
+
"@typescript-eslint/parser": "8.69.0",
|
|
92
|
+
"eslint": "10.9.1",
|
|
91
93
|
"eslint-plugin-perfectionist": "^5.11.0",
|
|
92
94
|
"knip": "^6.34.0",
|
|
93
95
|
"lefthook": "^2.2.2",
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { defineRule } from "@oxlint/plugins";
|
|
2
|
-
//#region src/oxc/anti-slop/rules/require-safety-comment-for-type-assertion.ts
|
|
3
|
-
const DEFAULT_SAFETY_MARKERS = ["SAFETY"];
|
|
4
|
-
const commentOwnerKinds = /* @__PURE__ */ new Set([
|
|
5
|
-
"ExpressionStatement",
|
|
6
|
-
"PropertyDefinition",
|
|
7
|
-
"ReturnStatement",
|
|
8
|
-
"ThrowStatement",
|
|
9
|
-
"VariableDeclaration"
|
|
10
|
-
]);
|
|
11
|
-
function isConstAssertion(node) {
|
|
12
|
-
return node.typeAnnotation.type === "TSTypeReference" && node.typeAnnotation.typeName.type === "Identifier" && node.typeAnnotation.typeName.name === "const";
|
|
13
|
-
}
|
|
14
|
-
function configuredSafetyMarkers(option) {
|
|
15
|
-
if (typeof option !== "object" || option === null || !("markers" in option)) return DEFAULT_SAFETY_MARKERS;
|
|
16
|
-
const configured = option.markers;
|
|
17
|
-
if (!Array.isArray(configured)) return DEFAULT_SAFETY_MARKERS;
|
|
18
|
-
const markers = configured.flatMap((marker) => typeof marker === "string" && marker.trim().length > 0 ? [marker.trim()] : []);
|
|
19
|
-
return markers.length > 0 ? markers : DEFAULT_SAFETY_MARKERS;
|
|
20
|
-
}
|
|
21
|
-
function markerPattern(markers) {
|
|
22
|
-
const alternation = markers.map((marker) => marker.replaceAll(/[.*+?^${}()|[\]\\]/gu, String.raw`\$&`)).join("|");
|
|
23
|
-
return new RegExp(String.raw`(?:^|[^\p{L}\p{N}_])(?:${alternation})\s*:\s*\S`, "u");
|
|
24
|
-
}
|
|
25
|
-
function hasSafetyJustificationBefore(sourceCode, owner, assertion, pattern) {
|
|
26
|
-
return sourceCode.getCommentsBefore(owner).some((comment) => comment.end <= assertion.start && pattern.test(comment.value));
|
|
27
|
-
}
|
|
28
|
-
function hasSafetyComment(sourceCode, node, pattern) {
|
|
29
|
-
let current = node;
|
|
30
|
-
while (true) {
|
|
31
|
-
if (hasSafetyJustificationBefore(sourceCode, current, node, pattern)) return true;
|
|
32
|
-
if (commentOwnerKinds.has(current.type)) {
|
|
33
|
-
const exportDeclaration = current.parent;
|
|
34
|
-
return exportDeclaration.type === "ExportNamedDeclaration" && exportDeclaration.declaration === current && hasSafetyJustificationBefore(sourceCode, exportDeclaration, node, pattern);
|
|
35
|
-
}
|
|
36
|
-
if (current.parent.type === "Program") return false;
|
|
37
|
-
current = current.parent;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
/** Require every non-const type assertion to state the invariant TypeScript cannot express. */
|
|
41
|
-
const requireSafetyCommentForTypeAssertionRule = defineRule({
|
|
42
|
-
meta: {
|
|
43
|
-
type: "problem",
|
|
44
|
-
docs: { description: "Require a nearby SAFETY comment for every TypeScript type assertion except const assertions." },
|
|
45
|
-
messages: { missingSafetyComment: "This type assertion has no `{{marker}}:` justification. State the checked invariant immediately before the assertion or its containing statement." },
|
|
46
|
-
schema: [{
|
|
47
|
-
type: "object",
|
|
48
|
-
properties: { markers: {
|
|
49
|
-
type: "array",
|
|
50
|
-
items: {
|
|
51
|
-
type: "string",
|
|
52
|
-
minLength: 1
|
|
53
|
-
},
|
|
54
|
-
minItems: 1,
|
|
55
|
-
uniqueItems: true
|
|
56
|
-
} },
|
|
57
|
-
additionalProperties: false
|
|
58
|
-
}],
|
|
59
|
-
defaultOptions: [{ markers: ["SAFETY"] }]
|
|
60
|
-
},
|
|
61
|
-
createOnce(context) {
|
|
62
|
-
const patterns = /* @__PURE__ */ new Map();
|
|
63
|
-
const checkAssertion = (node) => {
|
|
64
|
-
if (isConstAssertion(node)) return;
|
|
65
|
-
const markers = configuredSafetyMarkers(context.options?.[0]);
|
|
66
|
-
const patternKey = markers.join("\0");
|
|
67
|
-
const pattern = patterns.get(patternKey) ?? markerPattern(markers);
|
|
68
|
-
patterns.set(patternKey, pattern);
|
|
69
|
-
if (hasSafetyComment(context.sourceCode, node, pattern)) return;
|
|
70
|
-
context.report({
|
|
71
|
-
node,
|
|
72
|
-
messageId: "missingSafetyComment",
|
|
73
|
-
data: { marker: markers[0] ?? DEFAULT_SAFETY_MARKERS[0] }
|
|
74
|
-
});
|
|
75
|
-
};
|
|
76
|
-
return {
|
|
77
|
-
TSAsExpression: checkAssertion,
|
|
78
|
-
TSTypeAssertion: checkAssertion
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
//#endregion
|
|
83
|
-
export { markerPattern as n, requireSafetyCommentForTypeAssertionRule as r, DEFAULT_SAFETY_MARKERS as t };
|