@antelopejs/tooling-configs 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -26
- 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 +132 -11
- package/dist/bin/comment-proof.mjs +29 -7
- package/dist/bin/garden.mjs +2 -57
- package/dist/bin/ratchet.mjs +48 -14
- package/dist/bin/suppressions.mjs +3 -3
- package/dist/bin/sync.mjs +74 -41
- package/dist/bin/verify.mjs +898 -366
- 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 +50 -55
- package/dist/oxc/guardrails/index.d.mts +1 -1
- package/dist/oxc/guardrails/index.mjs +520 -103
- package/dist/oxc/lint.d.mts +7 -15
- package/dist/oxc/lint.mjs +16 -28
- 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-BTiPMqam.mjs} +17 -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/oxc/lint.d.mts
CHANGED
|
@@ -37,6 +37,8 @@ interface AntelopePresetOptions {
|
|
|
37
37
|
/**
|
|
38
38
|
* Type-aware rules. Defaults to true. Consumers must also set options.typeAware
|
|
39
39
|
* in their root config because oxlint never reads that field from extends.
|
|
40
|
+
* oxlint-tsgolint reads only TypeScript files, so `.vue` script blocks get
|
|
41
|
+
* these rules from `antelopeNuxtConfig({ typeAware })` in ESLint instead.
|
|
40
42
|
*/
|
|
41
43
|
typeAware?: boolean;
|
|
42
44
|
}
|
|
@@ -129,20 +131,7 @@ declare function antelopePreset(options?: AntelopePresetOptions): {
|
|
|
129
131
|
};
|
|
130
132
|
} | {
|
|
131
133
|
rules: {
|
|
132
|
-
|
|
133
|
-
"typescript/no-unsafe-argument": "error";
|
|
134
|
-
"typescript/no-unsafe-assignment": "error";
|
|
135
|
-
"typescript/no-unsafe-return": "error";
|
|
136
|
-
"typescript/use-unknown-in-catch-callback-variable": "error";
|
|
137
|
-
"typescript/no-floating-promises": "error";
|
|
138
|
-
"typescript/await-thenable": "error";
|
|
139
|
-
"typescript/unbound-method": "error";
|
|
140
|
-
"typescript/no-meaningless-void-operator": "error";
|
|
141
|
-
"typescript/no-misused-spread": "error";
|
|
142
|
-
"typescript/no-base-to-string": "error";
|
|
143
|
-
"typescript/no-redundant-type-constituents": "error";
|
|
144
|
-
"typescript/restrict-template-expressions": "error";
|
|
145
|
-
"typescript/require-array-sort-compare": "error";
|
|
134
|
+
[k: string]: "error";
|
|
146
135
|
};
|
|
147
136
|
} | {
|
|
148
137
|
jsPlugins: {
|
|
@@ -195,12 +184,15 @@ declare function antelopePreset(options?: AntelopePresetOptions): {
|
|
|
195
184
|
specifier: string;
|
|
196
185
|
}[];
|
|
197
186
|
rules: {
|
|
187
|
+
"antelopejs/no-unsafe-object-assign": "off" | "error";
|
|
198
188
|
"antelopejs/require-tsconfig-include": "off" | "error";
|
|
189
|
+
"antelopejs/require-tsconfig-types": "off" | "error";
|
|
199
190
|
};
|
|
200
191
|
overrides: {
|
|
201
|
-
files:
|
|
192
|
+
files: string[];
|
|
202
193
|
rules: {
|
|
203
194
|
"antelopejs/require-tsconfig-include": "off";
|
|
195
|
+
"antelopejs/require-tsconfig-types": "off";
|
|
204
196
|
};
|
|
205
197
|
}[];
|
|
206
198
|
} | {
|
package/dist/oxc/lint.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { i as findGitRoot } from "../ceilings-B7KayYIG.mjs";
|
|
2
2
|
import { t as readCarriedCeilings } from "../renames-L2owF5GD.mjs";
|
|
3
|
-
import { t as PRESET_CONFIGS } from "../templates-
|
|
3
|
+
import { t as PRESET_CONFIGS } from "../templates-lJBZFskp.mjs";
|
|
4
|
+
import { t as TYPE_AWARE_RULES } from "../type-aware-rules-DMuN6sHb.mjs";
|
|
4
5
|
import { n as TEST_FILE_GLOBS, t as ASSERTION_FUNCTION_NAMES } from "../shared-WC0z3y9F.mjs";
|
|
5
6
|
import { n as IGNORE_PATTERNS, r as SYNCED_AGENT_PATTERNS } from "../shared-igPpEDpS.mjs";
|
|
6
7
|
import { defineConfig } from "oxlint";
|
|
@@ -131,7 +132,8 @@ function guardrailsRules() {
|
|
|
131
132
|
});
|
|
132
133
|
}
|
|
133
134
|
/**
|
|
134
|
-
* With type-aware lint, a file no tsconfig lists
|
|
135
|
+
* With type-aware lint, a file no tsconfig lists, or whose tsconfig lists no
|
|
136
|
+
* `compilerOptions.types`, is reported. The root configs
|
|
135
137
|
* `antelopejs-sync` writes are exempt: a tsconfig that builds `src` reaches them
|
|
136
138
|
* only through a referenced composite tsconfig, which every repository would need.
|
|
137
139
|
*/
|
|
@@ -142,10 +144,17 @@ function guardrailsPreset(typeAware) {
|
|
|
142
144
|
name: "antelopejs",
|
|
143
145
|
specifier: "@antelopejs/tooling-configs/oxc/guardrails"
|
|
144
146
|
}],
|
|
145
|
-
rules: {
|
|
147
|
+
rules: {
|
|
148
|
+
"antelopejs/no-unsafe-object-assign": typeAware ? "error" : "off",
|
|
149
|
+
"antelopejs/require-tsconfig-include": typeAware ? "error" : "off",
|
|
150
|
+
"antelopejs/require-tsconfig-types": typeAware ? "error" : "off"
|
|
151
|
+
},
|
|
146
152
|
overrides: [{
|
|
147
|
-
files: PRESET_CONFIGS.map(({ path }) => path),
|
|
148
|
-
rules: {
|
|
153
|
+
files: PRESET_CONFIGS.map(({ path }) => `./${path}`),
|
|
154
|
+
rules: {
|
|
155
|
+
"antelopejs/require-tsconfig-include": "off",
|
|
156
|
+
"antelopejs/require-tsconfig-types": "off"
|
|
157
|
+
}
|
|
149
158
|
}]
|
|
150
159
|
});
|
|
151
160
|
}
|
|
@@ -166,30 +175,9 @@ function complexityPreset(thresholds) {
|
|
|
166
175
|
"eslint/complexity": ["error", { max: thresholds.complexity }]
|
|
167
176
|
} });
|
|
168
177
|
}
|
|
169
|
-
/**
|
|
170
|
-
* Besides the base set, five rules reject an `any` or a type parameter that
|
|
171
|
-
* stands in for `unknown`, which the anti-slop `unknown` and assertion rules
|
|
172
|
-
* never see: a once-used type parameter, `any` passed as a typed argument,
|
|
173
|
-
* assigned to a typed binding or returned as a typed result, and an untyped
|
|
174
|
-
* `.catch` callback variable.
|
|
175
|
-
*/
|
|
178
|
+
/** The {@link TYPE_AWARE_RULES} as oxlint names them. */
|
|
176
179
|
function typeAwarePreset() {
|
|
177
|
-
return defineConfig({ rules: {
|
|
178
|
-
"typescript/no-unnecessary-type-parameters": "error",
|
|
179
|
-
"typescript/no-unsafe-argument": "error",
|
|
180
|
-
"typescript/no-unsafe-assignment": "error",
|
|
181
|
-
"typescript/no-unsafe-return": "error",
|
|
182
|
-
"typescript/use-unknown-in-catch-callback-variable": "error",
|
|
183
|
-
"typescript/no-floating-promises": "error",
|
|
184
|
-
"typescript/await-thenable": "error",
|
|
185
|
-
"typescript/unbound-method": "error",
|
|
186
|
-
"typescript/no-meaningless-void-operator": "error",
|
|
187
|
-
"typescript/no-misused-spread": "error",
|
|
188
|
-
"typescript/no-base-to-string": "error",
|
|
189
|
-
"typescript/no-redundant-type-constituents": "error",
|
|
190
|
-
"typescript/restrict-template-expressions": "error",
|
|
191
|
-
"typescript/require-array-sort-compare": "error"
|
|
192
|
-
} });
|
|
180
|
+
return defineConfig({ rules: Object.fromEntries(TYPE_AWARE_RULES.map((rule) => [`typescript/${rule}`, "error"])) });
|
|
193
181
|
}
|
|
194
182
|
/** Side-effect imports register classes, so sorting may never relocate them. */
|
|
195
183
|
function importSortingPreset() {
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
+
import { t as admits } from "./semver-BDxeEcP_.mjs";
|
|
1
2
|
import { existsSync, readFileSync } from "node:fs";
|
|
2
3
|
import { dirname, join } from "node:path";
|
|
3
4
|
import { fileURLToPath } from "node:url";
|
|
4
5
|
//#region src/guardrails/package.ts
|
|
6
|
+
/** The capture tool's optional peers, which a repository with `docs/captures.ts` declares as devDependencies at the ranges the pack tests against. */
|
|
7
|
+
const CAPTURE_PEERS = [
|
|
8
|
+
"mongodb-memory-server",
|
|
9
|
+
"pixelmatch",
|
|
10
|
+
"playwright-core",
|
|
11
|
+
"sharp"
|
|
12
|
+
];
|
|
5
13
|
function parseManifest(text) {
|
|
6
14
|
const manifest = JSON.parse(text);
|
|
7
15
|
if (manifest === null || Array.isArray(manifest)) throw new Error("package.json must contain an object.");
|
|
@@ -33,10 +41,16 @@ function toolingVersions() {
|
|
|
33
41
|
const knip = manifest.devDependencies?.knip;
|
|
34
42
|
const tsgolint = manifest.devDependencies?.["oxlint-tsgolint"];
|
|
35
43
|
if (!lefthook || !knip || !tsgolint || !manifest.version) throw new Error("tooling-configs must declare its version and lefthook, knip and oxlint-tsgolint devDependencies.");
|
|
44
|
+
const tested = manifest.devDependencies ?? {};
|
|
36
45
|
return {
|
|
37
46
|
lefthook,
|
|
38
47
|
knip,
|
|
39
48
|
tsgolint,
|
|
49
|
+
capture: CAPTURE_PEERS.map((name) => {
|
|
50
|
+
const range = tested[name];
|
|
51
|
+
if (!range) throw new Error(`tooling-configs must declare ${name} as a devDependency.`);
|
|
52
|
+
return [name, range];
|
|
53
|
+
}),
|
|
40
54
|
pack: manifest.version
|
|
41
55
|
};
|
|
42
56
|
}
|
|
@@ -95,6 +109,15 @@ const DEFAULT_SCRIPTS = {
|
|
|
95
109
|
"format:check": "oxfmt --check .",
|
|
96
110
|
knip: "knip"
|
|
97
111
|
};
|
|
112
|
+
function defaultScripts(nuxt) {
|
|
113
|
+
return {
|
|
114
|
+
...DEFAULT_SCRIPTS,
|
|
115
|
+
...nuxt && { typecheck: "nuxi typecheck" }
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function sortedEntries(record) {
|
|
119
|
+
return Object.fromEntries(Object.entries(record).sort(([a], [b]) => a.localeCompare(b)));
|
|
120
|
+
}
|
|
98
121
|
/** Stands in for the current install while the script is split on its separators, since the install holds `&&` itself. */
|
|
99
122
|
const INSTALL_TOKEN = "\0prepare-install\0";
|
|
100
123
|
/** Rewrites every earlier synced install to the current one in one pass and keeps a single install, whatever separator joined the copies. */
|
|
@@ -119,6 +142,19 @@ function prepareScript(current = "") {
|
|
|
119
142
|
if (legacy.test(current)) return current.replace(legacy, `$1${PREPARE_INSTALL}`);
|
|
120
143
|
return current ? `${current} && ${PREPARE_INSTALL}` : PREPARE_INSTALL;
|
|
121
144
|
}
|
|
145
|
+
/** Whether `range`'s lowest named version is one the pack's `tested` range admits. A `workspace:` or `catalog:` spec resolves elsewhere and is kept as declared. */
|
|
146
|
+
function withinTested(range, tested) {
|
|
147
|
+
if (range?.startsWith("workspace:") || range?.startsWith("catalog:")) return true;
|
|
148
|
+
const floor = /\d+\.\d+\.\d+/.exec(range ?? "")?.[0];
|
|
149
|
+
return floor !== void 0 && admits(tested, floor);
|
|
150
|
+
}
|
|
151
|
+
/** The devDependencies, with their ranges, that sync writes into `manifest`: tools it lacks, and capture peers it lacks or declares below the pack's tested range. */
|
|
152
|
+
function addedDevDependencies(manifest, versions, options) {
|
|
153
|
+
const declared = manifest.devDependencies ?? {};
|
|
154
|
+
const tools = [["lefthook", versions.lefthook], ["knip", versions.knip]];
|
|
155
|
+
if (options.typeAware) tools.push(["oxlint-tsgolint", versions.tsgolint]);
|
|
156
|
+
return [...tools.filter(([name]) => !declared[name]), ...options.captures ? versions.capture.filter(([name, tested]) => !withinTested(declared[name], tested)) : []];
|
|
157
|
+
}
|
|
122
158
|
function managedPackage(current, versions, options = {}) {
|
|
123
159
|
if (current === void 0) throw new Error("package.json is missing.");
|
|
124
160
|
const manifest = parseManifest(current);
|
|
@@ -134,34 +170,52 @@ function managedPackage(current, versions, options = {}) {
|
|
|
134
170
|
delete scripts.ratchet;
|
|
135
171
|
delete scripts["ratchet:update"];
|
|
136
172
|
}
|
|
137
|
-
for (const [name, command] of Object.entries(
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
manifest.devDependencies = Object.fromEntries(Object.entries(dependencies).sort(([a], [b]) => a.localeCompare(b)));
|
|
173
|
+
for (const [name, command] of Object.entries(defaultScripts(options.nuxt))) scripts[name] ??= command;
|
|
174
|
+
manifest.devDependencies = sortedEntries({
|
|
175
|
+
...manifest.devDependencies,
|
|
176
|
+
...Object.fromEntries(addedDevDependencies(manifest, versions, options))
|
|
177
|
+
});
|
|
143
178
|
return serializeManifest(manifest, current);
|
|
144
179
|
}
|
|
145
180
|
/**
|
|
146
|
-
* The template profile owns
|
|
147
|
-
* the
|
|
148
|
-
*
|
|
181
|
+
* The template profile owns the scripts and devDependencies `antelopejs-checks`
|
|
182
|
+
* runs, without the hooks: the pack's commands are set, and the other steps get
|
|
183
|
+
* a default only where the template has none, so its own `test`, `lint` or
|
|
184
|
+
* `sync` stays. An already complete manifest is returned unchanged, so a
|
|
185
|
+
* template is never reformatted for nothing.
|
|
149
186
|
*/
|
|
150
|
-
function templatePackage(current, options) {
|
|
187
|
+
function templatePackage(current, versions, options) {
|
|
151
188
|
if (current === void 0) throw new Error("package.json is missing.");
|
|
152
189
|
const manifest = parseManifest(current);
|
|
153
|
-
const commands = repositoryTools(manifest)
|
|
154
|
-
const
|
|
190
|
+
const { commands } = repositoryTools(manifest);
|
|
191
|
+
const sync = `${commands.sync} --profile template`;
|
|
192
|
+
const scripts = manifest.scripts ??= {};
|
|
193
|
+
const dependencies = manifest.devDependencies ??= {};
|
|
194
|
+
const set = Object.entries({
|
|
195
|
+
checks: commands.checks,
|
|
196
|
+
size: commands.size,
|
|
155
197
|
suppressions: commands.suppressions,
|
|
156
198
|
"suppressions:update": `${commands.suppressions} --update`,
|
|
157
199
|
...options.ratchet && {
|
|
158
200
|
ratchet: commands.ratchet,
|
|
159
201
|
"ratchet:update": `${commands.ratchet} --update`
|
|
160
202
|
}
|
|
161
|
-
};
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
|
|
203
|
+
}).filter(([name, command]) => scripts[name] !== command);
|
|
204
|
+
const defaults = Object.entries({
|
|
205
|
+
...defaultScripts(options.nuxt),
|
|
206
|
+
sync,
|
|
207
|
+
"sync:check": `${sync} --check`
|
|
208
|
+
}).filter(([name]) => scripts[name] === void 0);
|
|
209
|
+
const missing = Object.entries({
|
|
210
|
+
knip: versions.knip,
|
|
211
|
+
...options.typeAware && { "oxlint-tsgolint": versions.tsgolint }
|
|
212
|
+
}).filter(([name]) => dependencies[name] === void 0);
|
|
213
|
+
if (set.length + defaults.length + missing.length === 0) return current;
|
|
214
|
+
Object.assign(scripts, Object.fromEntries([...defaults, ...set]));
|
|
215
|
+
manifest.devDependencies = sortedEntries({
|
|
216
|
+
...dependencies,
|
|
217
|
+
...Object.fromEntries(missing)
|
|
218
|
+
});
|
|
165
219
|
return serializeManifest(manifest, current);
|
|
166
220
|
}
|
|
167
221
|
function serializeManifest(manifest, current) {
|
|
@@ -170,4 +224,4 @@ function serializeManifest(manifest, current) {
|
|
|
170
224
|
return `${JSON.stringify(manifest, null, indent).replaceAll("\n", newline)}${newline}`;
|
|
171
225
|
}
|
|
172
226
|
//#endregion
|
|
173
|
-
export {
|
|
227
|
+
export { parseManifest as a, toolingVersions as c, packageManager as i, execCommand as n, repositoryTools as o, managedPackage as r, templatePackage as s, addedDevDependencies as t };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { a as parseManifest } from "./package-Dn7VTFUW.mjs";
|
|
1
2
|
import { l as resolveRevision, u as trackedManifests } from "./files-DJ0TeaTU.mjs";
|
|
2
|
-
import { o as revisionSuppressions, r as countSuppressions } from "./suppressions-
|
|
3
|
-
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, symlinkSync } from "node:fs";
|
|
4
|
-
import { dirname, join, matchesGlob } from "node:path";
|
|
3
|
+
import { o as revisionSuppressions, r as countSuppressions } from "./suppressions-BroaaGJ_.mjs";
|
|
4
|
+
import { copyFileSync, existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, symlinkSync } from "node:fs";
|
|
5
|
+
import { dirname, isAbsolute, join, matchesGlob, relative, sep } from "node:path";
|
|
5
6
|
import { execFileSync, spawnSync } from "node:child_process";
|
|
6
7
|
import { createHash } from "node:crypto";
|
|
7
8
|
import { tmpdir } from "node:os";
|
|
@@ -90,16 +91,77 @@ function describeAllowance(policy) {
|
|
|
90
91
|
//#endregion
|
|
91
92
|
//#region src/guardrails/revisions.ts
|
|
92
93
|
const DIRECTORY_LINK = process.platform === "win32" ? "junction" : "dir";
|
|
93
|
-
|
|
94
|
+
/** The parsed manifest of each tracked package of `checkout`, keyed by its directory; an unreadable manifest is left out. */
|
|
95
|
+
function workspaceManifests(checkout) {
|
|
96
|
+
const manifests = /* @__PURE__ */ new Map();
|
|
97
|
+
for (const file of trackedManifests(checkout)) try {
|
|
98
|
+
manifests.set(dirname(file), parseManifest(readFileSync(join(checkout, file), "utf8")));
|
|
99
|
+
} catch {
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
return manifests;
|
|
103
|
+
}
|
|
104
|
+
/** Maps each named package directory of the checkout to its package in `worktree`: the same directory when it holds a package of that name, otherwise the only package of that name. */
|
|
105
|
+
function ownPackages(root, worktree) {
|
|
106
|
+
const atRevision = workspaceManifests(worktree);
|
|
107
|
+
const byName = /* @__PURE__ */ new Map();
|
|
108
|
+
for (const [directory, { name }] of atRevision) if (name !== void 0) byName.set(name, [...byName.get(name) ?? [], directory]);
|
|
109
|
+
const packages = /* @__PURE__ */ new Map();
|
|
110
|
+
for (const [directory, { name }] of workspaceManifests(root)) {
|
|
111
|
+
if (name === void 0) continue;
|
|
112
|
+
const named = byName.get(name) ?? [];
|
|
113
|
+
if (atRevision.get(directory)?.name === name) packages.set(directory, directory);
|
|
114
|
+
else if (named.length === 1) packages.set(directory, named[0]);
|
|
115
|
+
}
|
|
116
|
+
return packages;
|
|
117
|
+
}
|
|
118
|
+
/** The worktree path standing in for `real`, a path relative to the checkout, when it is a workspace package of the checkout or lies inside one other than the root package, and the revision has a package of that name. */
|
|
119
|
+
function ownCopy(real, packages) {
|
|
120
|
+
const posix = real.split(sep).join("/") || ".";
|
|
121
|
+
if (isAbsolute(real) || posix.split("/").some((part) => part === ".." || part === "node_modules")) return void 0;
|
|
122
|
+
const owner = [...packages.keys()].filter((directory) => posix === directory || posix.startsWith(`${directory}/`)).sort((a, b) => b.length - a.length)[0];
|
|
123
|
+
return owner === void 0 ? void 0 : join(packages.get(owner) ?? owner, posix.slice(owner.length));
|
|
124
|
+
}
|
|
125
|
+
/** Mirrors `path`, a `node_modules`, scope or `.bin` directory of the checkout, into the worktree entry by entry: an entry whose real location is a workspace package of the checkout links to the worktree's package of that name, and every other entry to the checkout's installed one. */
|
|
126
|
+
function mirrorInstalled(installed, path) {
|
|
127
|
+
const { root, realRoot, worktree, packages } = installed;
|
|
128
|
+
mkdirSync(join(worktree, path));
|
|
129
|
+
for (const entry of readdirSync(join(root, path))) {
|
|
130
|
+
const source = join(root, path, entry);
|
|
131
|
+
const target = join(worktree, path, entry);
|
|
132
|
+
if (!existsSync(source) || lstatSync(target, { throwIfNoEntry: false }) !== void 0) continue;
|
|
133
|
+
const directory = statSync(source).isDirectory();
|
|
134
|
+
if (directory && (entry === ".bin" || entry.startsWith("@"))) {
|
|
135
|
+
mirrorInstalled(installed, join(path, entry));
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
const real = realpathSync(source);
|
|
139
|
+
const own = ownCopy(relative(realRoot, real), packages);
|
|
140
|
+
const type = directory ? DIRECTORY_LINK : "file";
|
|
141
|
+
if (own !== void 0) symlinkSync(join(worktree, own), target, type);
|
|
142
|
+
else if (directory) symlinkSync(source, target, DIRECTORY_LINK);
|
|
143
|
+
else if (lstatSync(source).isSymbolicLink()) symlinkSync(real, target, type);
|
|
144
|
+
else copyFileSync(source, target);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/** Links the checkout's installed dependencies into `worktree`; with `ownWorkspace`, a dependency on a workspace package resolves to the worktree's own revision of it instead of the checkout's. */
|
|
148
|
+
function linkDependencies(root, worktree, ownWorkspace) {
|
|
94
149
|
const directories = /* @__PURE__ */ new Set([".", ...trackedManifests(root).map(dirname)]);
|
|
150
|
+
const installed = {
|
|
151
|
+
root,
|
|
152
|
+
realRoot: realpathSync(root),
|
|
153
|
+
worktree,
|
|
154
|
+
packages: ownWorkspace ? ownPackages(root, worktree) : /* @__PURE__ */ new Map()
|
|
155
|
+
};
|
|
95
156
|
for (const directory of directories) {
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
if (
|
|
157
|
+
const path = join(directory, "node_modules");
|
|
158
|
+
if (!existsSync(join(root, path)) || !existsSync(join(worktree, directory)) || lstatSync(join(worktree, path), { throwIfNoEntry: false }) !== void 0) continue;
|
|
159
|
+
if (ownWorkspace) mirrorInstalled(installed, path);
|
|
160
|
+
else symlinkSync(join(root, path), join(worktree, path), DIRECTORY_LINK);
|
|
99
161
|
}
|
|
100
162
|
}
|
|
101
163
|
/** Compares isolated committed revisions and removes both worktrees even when compilation fails; a policy lets matching `@internal` additions through. */
|
|
102
|
-
function compareRevisions(root, baseRef, label, emit, policy) {
|
|
164
|
+
function compareRevisions(root, baseRef, label, emit, { policy, ownWorkspace = false } = {}) {
|
|
103
165
|
const temporary = mkdtempSync(join(tmpdir(), "antelope-proof-"));
|
|
104
166
|
const worktrees = [];
|
|
105
167
|
const results = [];
|
|
@@ -136,7 +198,7 @@ function compareRevisions(root, baseRef, label, emit, policy) {
|
|
|
136
198
|
]
|
|
137
199
|
});
|
|
138
200
|
worktrees.push(worktree);
|
|
139
|
-
linkDependencies(root, worktree);
|
|
201
|
+
linkDependencies(root, worktree, ownWorkspace);
|
|
140
202
|
const output = join(temporary, side);
|
|
141
203
|
mkdirSync(output, { recursive: true });
|
|
142
204
|
results.push(emit(worktree, output, join(temporary, "emit", side)));
|
|
@@ -276,4 +338,4 @@ function stampProof(root, command, baseRef, output) {
|
|
|
276
338
|
return `${text}<!-- antelopejs-proof base=${stamp.base} head=${stamp.head} lines=${proofLines(lines).length} digest=${proofDigest(stamp, lines)} command: ${command} -->\n`;
|
|
277
339
|
}
|
|
278
340
|
//#endregion
|
|
279
|
-
export { DIRECTORY_LINK as a, revisionCounts as c,
|
|
341
|
+
export { DIRECTORY_LINK as a, revisionCounts as c, createAddedPolicy as d, describeAllowance as f, stampProof as i, workspaceManifests as l, recordVerdict as m, proofDigest as n, compareRevisions as o, fillStars as p, proofLines as r, revisionCountRows as s, parseProofStamp as t, allowedByGlob as u };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { a as formatCeilings, c as parseCeilings, n as MAX_FILE_BYTES, o as isPackRelease, s as isRetired, t as CEILINGS_FILE } from "./ceilings-B7KayYIG.mjs";
|
|
2
2
|
import { n as renamedPaths, t as readCarriedCeilings } from "./renames-L2owF5GD.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { c as toolingVersions } from "./package-Dn7VTFUW.mjs";
|
|
4
4
|
import { n as authoredSizes, o as isAgentFile, r as changedFiles, t as LINT_CONFIG } from "./files-DJ0TeaTU.mjs";
|
|
5
5
|
import { t as lintDiagnostics } from "./oxlint-DIV-lLSS.mjs";
|
|
6
|
-
import "./suppression-budget-
|
|
6
|
+
import "./suppression-budget-Dvb_IqBo.mjs";
|
|
7
7
|
import { n as sizeFailure } from "./size-DBatLT-F.mjs";
|
|
8
8
|
import { copyFileSync, existsSync, mkdirSync, mkdtempSync, rmSync, symlinkSync, unlinkSync, writeFileSync } from "node:fs";
|
|
9
9
|
import { dirname, join } from "node:path";
|
|
@@ -20,7 +20,9 @@ import { tmpdir } from "node:os";
|
|
|
20
20
|
const PACK_NEW_RULES = /* @__PURE__ */ new Map([
|
|
21
21
|
["antelopejs/no-inherited-key-lookup", "0.2.17"],
|
|
22
22
|
["antelopejs/no-presence-only-type-guard", "0.2.17"],
|
|
23
|
+
["antelopejs/no-unsafe-object-assign", "0.4.2"],
|
|
23
24
|
["antelopejs/require-tsconfig-include", "0.2.18"],
|
|
25
|
+
["antelopejs/require-tsconfig-types", "0.4.2"],
|
|
24
26
|
["typescript/no-unnecessary-type-parameters", "0.2.17"],
|
|
25
27
|
["typescript/no-unsafe-argument", "0.2.17"],
|
|
26
28
|
["typescript/no-unsafe-assignment", "0.2.17"],
|
|
@@ -123,20 +125,20 @@ function revisionEntries(root, revision) {
|
|
|
123
125
|
}
|
|
124
126
|
return entries;
|
|
125
127
|
}
|
|
126
|
-
/** Links
|
|
127
|
-
function
|
|
128
|
-
const
|
|
128
|
+
/** Links each entry a `.gitignore` of the working tree ignores, such as `node_modules` or a generated tsconfig a tracked one extends, into `tree`, so the checkout loads its configuration and resolves dependencies as the real one does, while its own `.gitignore` keeps a whole-tree lint off them. */
|
|
129
|
+
function linkIgnored(root, tree) {
|
|
130
|
+
const entries = git(root, [
|
|
129
131
|
"ls-files",
|
|
130
132
|
"-z",
|
|
131
|
-
"--",
|
|
132
|
-
"
|
|
133
|
-
"
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
const
|
|
138
|
-
const target = join(tree,
|
|
139
|
-
if (existsSync(
|
|
133
|
+
"--others",
|
|
134
|
+
"--ignored",
|
|
135
|
+
"--exclude-per-directory=.gitignore",
|
|
136
|
+
"--directory"
|
|
137
|
+
], {}).split("\0").filter(Boolean);
|
|
138
|
+
for (const entry of entries) {
|
|
139
|
+
const path = entry.replace(/\/$/u, "");
|
|
140
|
+
const target = join(tree, path);
|
|
141
|
+
if (existsSync(dirname(target)) && !existsSync(target)) symlinkSync(join(root, path), target, entry.endsWith("/") ? "dir" : "file");
|
|
140
142
|
}
|
|
141
143
|
}
|
|
142
144
|
/**
|
|
@@ -189,7 +191,7 @@ function withPreviousTree(root, revision, paths, use, { wholeIndex = false } = {
|
|
|
189
191
|
`--prefix=${tree}/`
|
|
190
192
|
], env);
|
|
191
193
|
if (wholeIndex) mkdirSync(join(tree, ".git"), { recursive: true });
|
|
192
|
-
|
|
194
|
+
linkIgnored(root, tree);
|
|
193
195
|
return use(tree);
|
|
194
196
|
} finally {
|
|
195
197
|
rmSync(scratch, {
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { defineRule } from "@oxlint/plugins";
|
|
2
|
+
//#region src/oxc/anti-slop/shared/type-guards.ts
|
|
3
|
+
/** JavaScript files, where TypeScript reads types from JSDoc instead of from syntax. */
|
|
4
|
+
const JSDOC_TYPED_FILE = /\.[cm]?js$/;
|
|
5
|
+
/** A `@returns {x is T}` type, `x` captured: `asserts x is T` does not match. */
|
|
6
|
+
const JSDOC_PREDICATE = /^\s*([A-Za-z_$][\w$]*)\s+is\s+\S/;
|
|
7
|
+
function isRuntimeFunction(node) {
|
|
8
|
+
return node.type === "ArrowFunctionExpression" || node.type === "FunctionDeclaration" || node.type === "FunctionExpression";
|
|
9
|
+
}
|
|
10
|
+
/** Return the statement or member a JSDoc block documenting this function is attached to. */
|
|
11
|
+
function documentedNode(fn) {
|
|
12
|
+
const parent = fn.parent;
|
|
13
|
+
if ((parent.type === "Property" || parent.type === "MethodDefinition") && parent.value === fn) return parent;
|
|
14
|
+
let node = fn;
|
|
15
|
+
if (parent.type === "VariableDeclarator" && parent.init === fn && parent.parent.type === "VariableDeclaration" && parent.parent.declarations.length === 1) node = parent.parent;
|
|
16
|
+
const container = node.parent;
|
|
17
|
+
return container !== null && (container.type === "ExportNamedDeclaration" || container.type === "ExportDefaultDeclaration") ? container : node;
|
|
18
|
+
}
|
|
19
|
+
/** Return the type inside the braces of the first `@<tag> {...}` tag of a JSDoc block. */
|
|
20
|
+
function jsDocTagType(text, tag) {
|
|
21
|
+
const match = new RegExp(String.raw`@${tag}\s*\{`, "u").exec(text);
|
|
22
|
+
if (match === null) return null;
|
|
23
|
+
const start = match.index + match[0].length;
|
|
24
|
+
let depth = 1;
|
|
25
|
+
for (let index = start; index < text.length; index++) if (text[index] === "{") depth++;
|
|
26
|
+
else if (text[index] === "}" && --depth === 0) return text.slice(start, index);
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
/** Return whether the JSDoc block right before the function declares `@returns {param is T}` for one of its parameters. */
|
|
30
|
+
function hasJsDocTypePredicate(fn, sourceCode) {
|
|
31
|
+
const comment = sourceCode.getCommentsBefore(documentedNode(fn)).at(-1);
|
|
32
|
+
if (comment === void 0 || comment.type !== "Block" || !comment.value.startsWith("*")) return false;
|
|
33
|
+
const returnType = jsDocTagType(comment.value, "returns");
|
|
34
|
+
const subject = returnType === null ? void 0 : JSDOC_PREDICATE.exec(returnType)?.[1];
|
|
35
|
+
return subject !== void 0 && fn.params.some((parameter) => parameter.type === "Identifier" && parameter.name === subject);
|
|
36
|
+
}
|
|
37
|
+
/** Return whether a function declares a type predicate or assertion, or a JSDoc `@returns {x is T}` in a `.js`, `.mjs` or `.cjs` file. */
|
|
38
|
+
function isTypeGuard(fn, sourceCode, filename) {
|
|
39
|
+
if (fn.returnType?.typeAnnotation.type === "TSTypePredicate") return true;
|
|
40
|
+
return JSDOC_TYPED_FILE.test(filename) && hasJsDocTypePredicate(fn, sourceCode);
|
|
41
|
+
}
|
|
42
|
+
/** Return the nearest runtime function around a node when that function is a type guard. */
|
|
43
|
+
function enclosingTypeGuard(node, sourceCode, filename) {
|
|
44
|
+
let current = node.parent;
|
|
45
|
+
while (current !== null && current.type !== "Program") {
|
|
46
|
+
if (isRuntimeFunction(current)) return isTypeGuard(current, sourceCode, filename) ? current : null;
|
|
47
|
+
current = current.parent;
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/oxc/anti-slop/rules/require-safety-comment-for-type-assertion.ts
|
|
53
|
+
const DEFAULT_SAFETY_MARKERS = ["SAFETY"];
|
|
54
|
+
const commentOwnerKinds = /* @__PURE__ */ new Set([
|
|
55
|
+
"ExpressionStatement",
|
|
56
|
+
"PropertyDefinition",
|
|
57
|
+
"ReturnStatement",
|
|
58
|
+
"ThrowStatement",
|
|
59
|
+
"VariableDeclaration"
|
|
60
|
+
]);
|
|
61
|
+
function isConstAssertion(node) {
|
|
62
|
+
return node.typeAnnotation.type === "TSTypeReference" && node.typeAnnotation.typeName.type === "Identifier" && node.typeAnnotation.typeName.name === "const";
|
|
63
|
+
}
|
|
64
|
+
function configuredSafetyMarkers(option) {
|
|
65
|
+
if (typeof option !== "object" || option === null || !("markers" in option)) return DEFAULT_SAFETY_MARKERS;
|
|
66
|
+
const configured = option.markers;
|
|
67
|
+
if (!Array.isArray(configured)) return DEFAULT_SAFETY_MARKERS;
|
|
68
|
+
const markers = configured.flatMap((marker) => typeof marker === "string" && marker.trim().length > 0 ? [marker.trim()] : []);
|
|
69
|
+
return markers.length > 0 ? markers : DEFAULT_SAFETY_MARKERS;
|
|
70
|
+
}
|
|
71
|
+
function markerPattern(markers) {
|
|
72
|
+
const alternation = markers.map((marker) => marker.replaceAll(/[.*+?^${}()|[\]\\]/gu, String.raw`\$&`)).join("|");
|
|
73
|
+
return new RegExp(String.raw`(?:^|[^\p{L}\p{N}_])(?:${alternation})\s*:\s*\S`, "u");
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Return the cast a JSDoc `@type {T}` block makes of the parenthesized expression after it,
|
|
77
|
+
* unless `T` is `const` or the `(` opens the parameters of an annotated arrow function.
|
|
78
|
+
*/
|
|
79
|
+
function jsDocCast(sourceCode, comment) {
|
|
80
|
+
if (comment.type !== "Block" || !comment.value.startsWith("*")) return null;
|
|
81
|
+
const type = jsDocTagType(comment.value, "type");
|
|
82
|
+
if (type === null || type.trim() === "const") return null;
|
|
83
|
+
const paren = sourceCode.getTokenAfter(comment);
|
|
84
|
+
if (paren?.type !== "Punctuator" || paren.value !== "(") return null;
|
|
85
|
+
const owner = sourceCode.getNodeByRangeIndex(paren.start);
|
|
86
|
+
if (owner === null) return null;
|
|
87
|
+
return owner.type === "ArrowFunctionExpression" && owner.start === paren.start ? null : {
|
|
88
|
+
paren,
|
|
89
|
+
owner
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Return whether a marker comment ends before `assertion` starts, either right before it
|
|
94
|
+
* or before a node between `owner` and its statement or class property.
|
|
95
|
+
*/
|
|
96
|
+
function hasSafetyComment(sourceCode, assertion, owner, pattern) {
|
|
97
|
+
const justifies = (target) => sourceCode.getCommentsBefore(target).some((comment) => comment.end <= assertion.start && pattern.test(comment.value));
|
|
98
|
+
if (justifies(assertion)) return true;
|
|
99
|
+
let current = owner;
|
|
100
|
+
while (current.type !== "Program") {
|
|
101
|
+
if (justifies(current)) return true;
|
|
102
|
+
if (commentOwnerKinds.has(current.type)) {
|
|
103
|
+
const exportDeclaration = current.parent;
|
|
104
|
+
return exportDeclaration.type === "ExportNamedDeclaration" && exportDeclaration.declaration === current && justifies(exportDeclaration);
|
|
105
|
+
}
|
|
106
|
+
current = current.parent;
|
|
107
|
+
}
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
/** Require every non-const type assertion, JSDoc casts in JavaScript files included, to state the invariant TypeScript cannot express. */
|
|
111
|
+
const requireSafetyCommentForTypeAssertionRule = defineRule({
|
|
112
|
+
meta: {
|
|
113
|
+
type: "problem",
|
|
114
|
+
docs: { description: "Require a nearby SAFETY comment for every type assertion, TypeScript or JSDoc cast, except const assertions." },
|
|
115
|
+
messages: { missingSafetyComment: "This type assertion has no `{{marker}}:` justification. State the checked invariant immediately before the assertion or its containing statement." },
|
|
116
|
+
schema: [{
|
|
117
|
+
type: "object",
|
|
118
|
+
properties: { markers: {
|
|
119
|
+
type: "array",
|
|
120
|
+
items: {
|
|
121
|
+
type: "string",
|
|
122
|
+
minLength: 1
|
|
123
|
+
},
|
|
124
|
+
minItems: 1,
|
|
125
|
+
uniqueItems: true
|
|
126
|
+
} },
|
|
127
|
+
additionalProperties: false
|
|
128
|
+
}],
|
|
129
|
+
defaultOptions: [{ markers: ["SAFETY"] }]
|
|
130
|
+
},
|
|
131
|
+
createOnce(context) {
|
|
132
|
+
const patterns = /* @__PURE__ */ new Map();
|
|
133
|
+
const markerSettings = () => {
|
|
134
|
+
const markers = configuredSafetyMarkers(context.options?.[0]);
|
|
135
|
+
const patternKey = markers.join("\0");
|
|
136
|
+
const pattern = patterns.get(patternKey) ?? markerPattern(markers);
|
|
137
|
+
patterns.set(patternKey, pattern);
|
|
138
|
+
return {
|
|
139
|
+
pattern,
|
|
140
|
+
data: { marker: markers[0] ?? DEFAULT_SAFETY_MARKERS[0] }
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
const checkAssertion = (node) => {
|
|
144
|
+
if (isConstAssertion(node)) return;
|
|
145
|
+
const { pattern, data } = markerSettings();
|
|
146
|
+
if (node.parent === null || hasSafetyComment(context.sourceCode, node, node.parent, pattern)) return;
|
|
147
|
+
context.report({
|
|
148
|
+
node,
|
|
149
|
+
messageId: "missingSafetyComment",
|
|
150
|
+
data
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
const checkJsDocCasts = () => {
|
|
154
|
+
if (!JSDOC_TYPED_FILE.test(context.filename)) return;
|
|
155
|
+
const { sourceCode } = context;
|
|
156
|
+
const { pattern, data } = markerSettings();
|
|
157
|
+
const castParens = /* @__PURE__ */ new Set();
|
|
158
|
+
for (const comment of sourceCode.getAllComments()) {
|
|
159
|
+
const cast = jsDocCast(sourceCode, comment);
|
|
160
|
+
if (cast === null || castParens.has(cast.paren.start)) continue;
|
|
161
|
+
castParens.add(cast.paren.start);
|
|
162
|
+
if (hasSafetyComment(sourceCode, comment, cast.owner, pattern)) continue;
|
|
163
|
+
context.report({
|
|
164
|
+
loc: {
|
|
165
|
+
start: comment.loc.start,
|
|
166
|
+
end: cast.paren.loc.end
|
|
167
|
+
},
|
|
168
|
+
messageId: "missingSafetyComment",
|
|
169
|
+
data
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
return {
|
|
174
|
+
Program: checkJsDocCasts,
|
|
175
|
+
TSAsExpression: checkAssertion,
|
|
176
|
+
TSTypeAssertion: checkAssertion
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
//#endregion
|
|
181
|
+
export { isRuntimeFunction as a, enclosingTypeGuard as i, markerPattern as n, requireSafetyCommentForTypeAssertionRule as r, DEFAULT_SAFETY_MARKERS as t };
|
|
@@ -63,12 +63,15 @@ function parseScene(entry, position) {
|
|
|
63
63
|
const route = optStr(entry, "route");
|
|
64
64
|
if (route === void 0 || !route.startsWith("/")) throw new Error("route must start with \"/\"");
|
|
65
65
|
const setup = entry.setup === true;
|
|
66
|
+
const signedOut = entry.signedOut === true;
|
|
67
|
+
if (setup && signedOut) throw new Error("a setup scene cannot be signed out");
|
|
66
68
|
const scene = {
|
|
67
69
|
id,
|
|
68
70
|
route,
|
|
69
71
|
viewport: parseViewport(entry),
|
|
70
72
|
steps: Object.hasOwn(entry, "steps") ? children(entry, "steps").map(parseStep) : [],
|
|
71
|
-
setup
|
|
73
|
+
setup,
|
|
74
|
+
signedOut
|
|
72
75
|
};
|
|
73
76
|
const crop = optStr(entry, "crop");
|
|
74
77
|
if (crop !== void 0 && crop !== "") scene.crop = crop;
|