@antelopejs/tooling-configs 0.7.0 → 0.7.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 +1 -1
- package/dist/bin/body-check.mjs +1 -1
- package/dist/bin/checks.mjs +1 -1
- package/dist/bin/garden.mjs +1 -16
- package/dist/bin/ratchet.mjs +2 -2
- package/dist/bin/suppressions.mjs +1 -1
- package/dist/bin/sync.mjs +2 -2
- package/dist/{checks-BefrkjiT.mjs → checks-DJ_CFEZH.mjs} +106 -23
- package/dist/eslint.mjs +1 -1
- package/dist/{guardrails-BfGwehVj.mjs → guardrails-6i82vsUi.mjs} +375 -22
- package/dist/npm-CIIqL5SG.mjs +18 -0
- package/dist/oxc/guardrails/index.d.mts +1 -1
- package/dist/oxc/guardrails/index.mjs +1 -1
- package/dist/oxc/lint.d.mts +5 -2
- package/dist/oxc/lint.mjs +1 -0
- package/dist/{oxlint-CkHhK5K_.mjs → oxlint-CIeonWMB.mjs} +5 -1
- package/dist/{ratchet-2FeMs1kh.mjs → ratchet-DLCfeaPY.mjs} +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -234,7 +234,7 @@ pnpm install
|
|
|
234
234
|
|
|
235
235
|
`--profile template` writes only what `antelopejs-checks` runs, for template repositories: the three preset configs, `.gitattributes`, a user-facing `AGENTS.md` block, `guardrails.suppressions.json`, and the `package.json` scripts and devDependencies of the table above without the hooks (no `prepare`, no `lefthook`). It sets `checks`, `size`, `suppressions` and `suppressions:update`, plus `ratchet` and `ratchet:update` once `guardrails.ratchet.json` exists. It adds `typecheck`, `lint`, `format`, `format:check`, `knip`, `sync` and `sync:check` only where the template has none, the sync scripts with `--profile template`. It writes no `guardrails.ratchet.json`. The agent layer, `verify-template` and the writing skills under `.agents/skills/` with their `.claude/skills` links, is synced and checked only in the template source, marked by its `.agents/skills/verify-template/` folder; a project scaffolded from the template ships without it, so the template's `AGENTS.md` block links no skill under `.agents/` or `.claude/skills/`. `antelopejs-sync --check` writes nothing and exits 1 on any drift; `pnpm run checks` runs it.
|
|
236
236
|
|
|
237
|
-
`pnpm run checks` runs `typecheck`, `lint`, `format:check`, `knip`, `test`, `size`, `suppressions` and `sync:check`, plus `ratchet` when `guardrails.ratchet.json` exists. It prints only the output of the steps that failed. Sync adds the ratchet scripts and pre-commit hook only while `guardrails.ratchet.json` exists. When the repository has a verify layer, an `.agents/skills/verify-*` folder holding a `verify.config.ts` or a `tsconfig.json`, it also runs `verify:types` and `verify:lockfiles`, which need no package script. Neither writes a file in the repository, spawns a package manager or fetches anything, so both pass offline after a root install, as CI runs them. When the repository holds a `pnpm-lock.yaml`, outside what `.gitignore` leaves out, it also runs `lockfile:singletons`, which fails when a lockfile resolves an `@antelopejs/interface-*` package at more than one version and names the importers and packages that pull each copy. It reads the lockfiles only. When a tracked `package.json` declares an `@antelopejs/*` package, it also runs `dependency:ranges` (see [Dependency ranges](#dependency-ranges)), which reads the manifests only. In a git checkout it also runs `git:identity`, which fails when the repository's own git config, the `.git/config` every worktree shares or a worktree's `config.worktree`, sets `user.name` or `user.email`, and names the file and value. An identity from the global config or a `git -c` passes. When the `README.md` of the root or of a workspace package holds a config example whose `package` is
|
|
237
|
+
`pnpm run checks` runs `typecheck`, `lint`, `format:check`, `knip`, `test`, `size`, `suppressions` and `sync:check`, plus `ratchet` when `guardrails.ratchet.json` exists. It prints only the output of the steps that failed. Sync adds the ratchet scripts and pre-commit hook only while `guardrails.ratchet.json` exists. When the repository has a verify layer, an `.agents/skills/verify-*` folder holding a `verify.config.ts` or a `tsconfig.json`, it also runs `verify:types` and `verify:lockfiles`, which need no package script. Neither writes a file in the repository, spawns a package manager or fetches anything, so both pass offline after a root install, as CI runs them. When the repository holds a `pnpm-lock.yaml`, outside what `.gitignore` leaves out, it also runs `lockfile:singletons`, which fails when a lockfile resolves an `@antelopejs/interface-*` package at more than one version and names the importers and packages that pull each copy. It reads the lockfiles only. When a tracked `package.json` declares an `@antelopejs/*` package, it also runs `dependency:ranges` (see [Dependency ranges](#dependency-ranges)), which reads the manifests only. In a git checkout it also runs `git:identity`, which fails when the repository's own git config, the `.git/config` every worktree shares or a worktree's `config.worktree`, sets `user.name` or `user.email`, and names the file and value. An identity from the global config or a `git -c` passes. When the `README.md` of the root or of a workspace package holds a config example whose `package` is an `@antelopejs/*` package, such as `source: { type: "package", package: "@antelopejs/brevo", version: ">=0.0.9 <0.1.0" }`, it also runs `readme:version`. It fails when that example's `version` range does not stop below the next minor of the package's newest version and admit it, as [Dependency ranges](#dependency-ranges) reads a range, and names the README line and the range to use. The newest version of a package of the repository is the `version` in its `package.json`. For any other package it is the `latest` dist-tag on the registry npm is configured with, and the step fails when it cannot read it. A value that is not a range, such as `latest`, passes. When the root or a workspace package is not `private` and names declarations through `types`, `typings` or `exports`, it also runs `published:types`, after `test` and alone. It runs each such package's `prepack` through `pnpm run` or `npm run`, then packs it with lifecycle scripts off, so `prepare` and `postpack` do not run. It installs the tarball alone in a scratch folder without install scripts, together with the package's peers (optional ones included), `typescript` and `@types/node`, both at their latest version unless the package names them as peers. A workspace package it depends on comes from that package's own tarball, not from the registry. Then it runs `tsc` with `skipLibCheck: false`, `strict` and `nodenext` resolution over a file that imports each entry the package's `exports` names, a `*` subpath once per shipped file it matches. A package without `exports` gets its bare name and every declaration file it ships instead. The step fails on any error and names each file as `<package>/<path>`. It needs the registry, so it fails offline unless the package manager's store already holds what the install needs.
|
|
238
238
|
|
|
239
239
|
- `verify:types` type-checks each layer's own code with the repository's own TypeScript, run as `node <typescript>/bin/tsc` without a shell. A repository that installs the TypeScript 6 API as `typescript` (`npm:@typescript/typescript6`) for tools that need it, beside TypeScript 7 as `@typescript/native`, runs `@typescript/native`'s `tsc`. The files are those the layer's `tsconfig.json` includes, minus its `playground` folder and any `node_modules` or `dist` folder: verify compiles a playground itself, with the playground's own config, after installing it. The step writes a config to the system temp folder that extends the layer's, lists those files, keeps the layer's type roots, sets `noEmit` and unsets with `null` the `declaration`, `composite`, `incremental`, `tsBuildInfoFile`, `declarationDir`, `declarationMap`, `emitDeclarationOnly` and `isolatedDeclarations` the layer may inherit, then deletes it. No `.tsbuildinfo` is written, no declaration check runs on code that is never emitted, and `skipLibCheck` keeps the layer's value. `antelopejs-sync` writes the `tsconfig.json` of the shared `verify-interface`, `verify-module` and `verify-template` layers; a repository's own layer, such as a `verify-dms-*` one, keeps the one it wrote. A layer with a `verify.config.ts` and no `tsconfig.json` fails, and so does one whose `tsconfig.json` does not include its `verify.config.ts`.
|
|
240
240
|
- `verify:lockfiles` compares, in code, the direct dependencies each lockfile records with the `package.json` files it locks, and fails on a difference in either direction, naming the dependency and the command that regenerates the lockfile. It reads each lockfile in a folder under a layer, `node_modules` and `dist` aside, and in the root `playground`. A `pnpm-lock.yaml` is compared importer by importer, for each importer it lists that has a `package.json` on disk; a `package-lock.json` by its root entry. Only `dependencies`, `devDependencies` and `optionalDependencies` are compared, by name and specifier: a name counts as present whichever of the three fields records it, and a `catalog:` or `workspace:` specifier compares as written, as pnpm stores it. A name the lockfile records that `package.json` declares only in `peerDependencies` passes, whether or not peers are auto-installed. A name an override selector in the `pnpm-lock.yaml` mentions is not compared, nor is a `link:` dependency the lockfile leaves out under `excludeLinksFromLockfile`. A lockfile it cannot parse, or of a version before pnpm's 6 or npm's 2, fails as unreadable. A missing lockfile fails only in a layer's `playground` or the root `playground` whose `package.json` has dependencies, unless a folder above it holds a `pnpm-workspace.yaml` or a `package.json` with `workspaces`; the fix it names is npm's when a `package-lock.json` sits in a folder above, pnpm's otherwise. It does not check workspace membership, `overrides`, lockfile `settings`, catalogs, `.npmrc` or user configuration, resolved versions, integrity hashes, transitive entries, npm workspace members, or `yarn.lock` and `bun.lock`: verify's own frozen install still rejects a lockfile stale there.
|
package/dist/bin/body-check.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { t as runCli } from "../cli-4Tv71vYk.mjs";
|
|
3
3
|
import { c as repositoryRoot, l as resolveRevision } from "../files-C-JJhExM.mjs";
|
|
4
|
-
import { n as lintDiagnostics } from "../oxlint-
|
|
4
|
+
import { n as lintDiagnostics } from "../oxlint-CIeonWMB.mjs";
|
|
5
5
|
import { n as proofDigest, r as proofLines, s as revisionCountRows, t as parseProofStamp } from "../proof-stamp-BFV7JTZT.mjs";
|
|
6
6
|
import { readFileSync } from "node:fs";
|
|
7
7
|
import { spawnSync } from "node:child_process";
|
package/dist/bin/checks.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { n as runCliAsync } from "../cli-4Tv71vYk.mjs";
|
|
3
3
|
import { c as repositoryRoot } from "../files-C-JJhExM.mjs";
|
|
4
|
-
import { r as runChecks, t as CHECKS_SKIP_ENV } from "../checks-
|
|
4
|
+
import { r as runChecks, t as CHECKS_SKIP_ENV } from "../checks-DJ_CFEZH.mjs";
|
|
5
5
|
import { parseArgs } from "node:util";
|
|
6
6
|
//#region src/bin/checks.ts
|
|
7
7
|
const SIGNAL_EXIT = /* @__PURE__ */ new Map([
|
package/dist/bin/garden.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import { t as admits } from "../semver-BDxeEcP_.mjs";
|
|
|
3
3
|
import { a as isString, c as object, d as optTime, f as parseJson, h as time, i as isObject, l as optNum, m as strings, n as children, o as list, p as str, r as flag, s as num, t as child, u as optStr } from "../json-CG2L7YFl.mjs";
|
|
4
4
|
import { n as runCliAsync } from "../cli-4Tv71vYk.mjs";
|
|
5
5
|
import { a as RENOVATE_CONFIGS, c as GITATTRIBUTES, d as enforcesLf, f as CI_CONTEXT, h as CI_RENOVATE_SYNC_REF, m as CI_PATH, n as ciNodeCallers, o as RENOVATE_PRESET, p as CI_NODE_REF, r as ciRenovateSyncCallers, u as LF_ATTRIBUTES } from "../workflow-C-oBwL2H.mjs";
|
|
6
|
+
import { n as tagVersion, r as tooling, t as TOOLING_PACKAGE } from "../npm-CIIqL5SG.mjs";
|
|
6
7
|
import { i as ghToken, n as createApi, t as ApiError } from "../api-BQLrI_S1.mjs";
|
|
7
8
|
import { parseDocument } from "yaml";
|
|
8
9
|
import { parseArgs } from "node:util";
|
|
@@ -753,22 +754,6 @@ async function applyPrunes(api, prunes) {
|
|
|
753
754
|
return failed;
|
|
754
755
|
}
|
|
755
756
|
//#endregion
|
|
756
|
-
//#region src/garden/npm.ts
|
|
757
|
-
const TOOLING_PACKAGE = "@antelopejs/tooling-configs";
|
|
758
|
-
function distTags(packument) {
|
|
759
|
-
return child(object(packument, "packument"), "dist-tags");
|
|
760
|
-
}
|
|
761
|
-
function tagVersion(packument, tag) {
|
|
762
|
-
return optStr(distTags(packument), tag);
|
|
763
|
-
}
|
|
764
|
-
/** The `latest` dist-tag of tooling-configs. */
|
|
765
|
-
async function tooling(context) {
|
|
766
|
-
const packument = await context.packument(TOOLING_PACKAGE);
|
|
767
|
-
const latest = packument === void 0 ? void 0 : tagVersion(packument, "latest");
|
|
768
|
-
if (latest === void 0) throw new Error(`${TOOLING_PACKAGE} has no latest version on npm.`);
|
|
769
|
-
return latest;
|
|
770
|
-
}
|
|
771
|
-
//#endregion
|
|
772
757
|
//#region src/garden/checks/conformance.ts
|
|
773
758
|
const CHECK$1 = "conformance";
|
|
774
759
|
const DAY$2 = 864e5;
|
package/dist/bin/ratchet.mjs
CHANGED
|
@@ -3,8 +3,8 @@ import { c as parseCeilings, l as readCeilings, t as CEILINGS_FILE } from "../ce
|
|
|
3
3
|
import { n as renamedPaths } from "../renames-L2owF5GD.mjs";
|
|
4
4
|
import { t as runCli } from "../cli-4Tv71vYk.mjs";
|
|
5
5
|
import { c as repositoryRoot, l as resolveRevision, t as LINT_CONFIG } from "../files-C-JJhExM.mjs";
|
|
6
|
-
import { n as ratchet, r as withPreviousTree } from "../ratchet-
|
|
7
|
-
import { n as lintDiagnostics } from "../oxlint-
|
|
6
|
+
import { n as ratchet, r as withPreviousTree } from "../ratchet-DLCfeaPY.mjs";
|
|
7
|
+
import { n as lintDiagnostics } from "../oxlint-CIeonWMB.mjs";
|
|
8
8
|
import { d as stagedAdditions, f as stagedChanges, u as previousLine } from "../suppression-budget-CPDSFg4X.mjs";
|
|
9
9
|
import { n as suppressionBase } from "../suppression-base-CYaLZAq7.mjs";
|
|
10
10
|
import { existsSync } from "node:fs";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { t as runCli } from "../cli-4Tv71vYk.mjs";
|
|
3
3
|
import { c as repositoryRoot, r as changedFiles } from "../files-C-JJhExM.mjs";
|
|
4
|
-
import { t as directiveReport } from "../oxlint-
|
|
4
|
+
import { t as directiveReport } from "../oxlint-CIeonWMB.mjs";
|
|
5
5
|
import { c as stagedSuppressions, i as checkSuppressions, l as checkPolicy, s as stagedNames } from "../suppression-budget-CPDSFg4X.mjs";
|
|
6
6
|
import { c as suppressionsIn, i as inWorktree } from "../suppressions-CxPnh4sC.mjs";
|
|
7
7
|
import { n as suppressionBase, t as raisedCeilings } from "../suppression-base-CYaLZAq7.mjs";
|
package/dist/bin/sync.mjs
CHANGED
|
@@ -9,8 +9,8 @@ import { _ as placeholderTestScript, f as CI_CONTEXT, g as ciWorkflow, i as hasC
|
|
|
9
9
|
import { a as gitFiles, c as repositoryRoot } from "../files-C-JJhExM.mjs";
|
|
10
10
|
import { n as workspaceDirectories, r as workspacePatterns, t as planDocs } from "../docs-compat-CSljVi3O.mjs";
|
|
11
11
|
import { n as shimInvocation } from "../run-command-BlFRPORx.mjs";
|
|
12
|
-
import { a as stepsOf, i as matchingScripts, n as droppedChecksSteps, o as moveDependencyRanges, s as runPnpm } from "../checks-
|
|
13
|
-
import { i as recordedRelease, t as measureBaseline } from "../ratchet-
|
|
12
|
+
import { a as stepsOf, i as matchingScripts, n as droppedChecksSteps, o as moveDependencyRanges, s as runPnpm } from "../checks-DJ_CFEZH.mjs";
|
|
13
|
+
import { i as recordedRelease, t as measureBaseline } from "../ratchet-DLCfeaPY.mjs";
|
|
14
14
|
import { n as SUPPRESSIONS_FILE, r as adoptedBudget } from "../suppression-budget-CPDSFg4X.mjs";
|
|
15
15
|
import { u as typescript } from "../suppressions-CxPnh4sC.mjs";
|
|
16
16
|
import { t as DEFAULT_SHARED } from "../map-BYkmnvNw.mjs";
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { t as CEILINGS_FILE } from "./ceilings-B7KayYIG.mjs";
|
|
2
2
|
import { l as serializeManifest, o as packageManager, s as parseManifest } from "./package-DDG3YH7W.mjs";
|
|
3
|
+
import { f as parseJson } from "./json-CG2L7YFl.mjs";
|
|
3
4
|
import { a as gitFiles, u as trackedManifests } from "./files-C-JJhExM.mjs";
|
|
4
5
|
import { n as workspaceDirectories } from "./docs-compat-CSljVi3O.mjs";
|
|
5
6
|
import { n as shimInvocation, t as runCommand } from "./run-command-BlFRPORx.mjs";
|
|
7
|
+
import { n as tagVersion } from "./npm-CIIqL5SG.mjs";
|
|
6
8
|
import { t as accepting } from "./ports-DAeEJsYh.mjs";
|
|
7
9
|
import { existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
8
10
|
import { basename, dirname, join, posix, relative, resolve, sep } from "node:path";
|
|
@@ -12,7 +14,7 @@ import ts from "@typescript/typescript6";
|
|
|
12
14
|
import { createHash } from "node:crypto";
|
|
13
15
|
import { tmpdir } from "node:os";
|
|
14
16
|
import { gunzipSync } from "node:zlib";
|
|
15
|
-
import {
|
|
17
|
+
import { validRange } from "semver";
|
|
16
18
|
import { minimatch } from "minimatch";
|
|
17
19
|
//#region src/guardrails/run-pnpm.ts
|
|
18
20
|
/** Runs pnpm, the only manager the pack's CI installs with, with `args` quietly; returns its output only when it failed. */
|
|
@@ -40,7 +42,7 @@ function runPnpm(root, args) {
|
|
|
40
42
|
* module whose range that copy falls outside, so a pin breaks startup at the
|
|
41
43
|
* next patch release.
|
|
42
44
|
*/
|
|
43
|
-
const ANTELOPEJS_SCOPE = "@antelopejs/";
|
|
45
|
+
const ANTELOPEJS_SCOPE$1 = "@antelopejs/";
|
|
44
46
|
/** A linked folder is the copy the dependent builds against, not a release it resolves. */
|
|
45
47
|
const LINK_SPEC_PREFIXES = ["file:", "link:"];
|
|
46
48
|
/** pnpm replaces a `workspace:` spec with a range on the sibling's version when it publishes the package. */
|
|
@@ -139,6 +141,15 @@ function isCapped(bounds, local) {
|
|
|
139
141
|
if (compareVersions(ceiling, nextMinor(floor)) !== 0) return false;
|
|
140
142
|
return local === void 0 || compareVersions(local, floor) >= 0 && compareVersions(local, ceiling) < 0;
|
|
141
143
|
}
|
|
144
|
+
/**
|
|
145
|
+
* The range to use in place of `spec` on the minor of `newest`, or `undefined` when `spec` already stops below the
|
|
146
|
+
* next minor of its floor and admits `newest`.
|
|
147
|
+
*/
|
|
148
|
+
function cappedReplacement(spec, newest) {
|
|
149
|
+
const version = readFloor(newest);
|
|
150
|
+
if (version === void 0 || isCapped(readBounds(spec.trim()), version)) return void 0;
|
|
151
|
+
return cappedRange(version);
|
|
152
|
+
}
|
|
142
153
|
function isLinkSpec(spec) {
|
|
143
154
|
return LINK_SPEC_PREFIXES.some((prefix) => spec.startsWith(prefix));
|
|
144
155
|
}
|
|
@@ -177,7 +188,7 @@ function checkEntry(manifest, field, [name, spec], local) {
|
|
|
177
188
|
}
|
|
178
189
|
/** Whether `manifest` declares an `@antelopejs/*` package in a field this check reads. */
|
|
179
190
|
function declaresAntelopePackage(manifest) {
|
|
180
|
-
return CHECKED_FIELDS.some((field) => Object.keys(manifest[field] ?? {}).some((name) => name.startsWith(ANTELOPEJS_SCOPE)));
|
|
191
|
+
return CHECKED_FIELDS.some((field) => Object.keys(manifest[field] ?? {}).some((name) => name.startsWith(ANTELOPEJS_SCOPE$1)));
|
|
181
192
|
}
|
|
182
193
|
/**
|
|
183
194
|
* The version of each named package among `manifests`, the packages that sit
|
|
@@ -207,7 +218,7 @@ function checkDependencyRanges(manifest, localVersions = /* @__PURE__ */ new Map
|
|
|
207
218
|
const violations = [];
|
|
208
219
|
for (const field of CHECKED_FIELDS) for (const entry of Object.entries(manifest[field] ?? {})) {
|
|
209
220
|
const [name, spec] = entry;
|
|
210
|
-
if (!name.startsWith(ANTELOPEJS_SCOPE) || isLinkSpec(spec)) continue;
|
|
221
|
+
if (!name.startsWith(ANTELOPEJS_SCOPE$1) || isLinkSpec(spec)) continue;
|
|
211
222
|
const violation = checkEntry(manifest, field, entry, localVersions.get(name));
|
|
212
223
|
if (violation) violations.push(violation);
|
|
213
224
|
}
|
|
@@ -419,6 +430,38 @@ function entrySpecifiers(name, exports, files, consumer) {
|
|
|
419
430
|
};
|
|
420
431
|
}
|
|
421
432
|
//#endregion
|
|
433
|
+
//#region src/guardrails/pack-tarball.ts
|
|
434
|
+
/** The flag that stops `pack` from running lifecycle scripts, by package manager. */
|
|
435
|
+
const IGNORE_SCRIPTS = {
|
|
436
|
+
pnpm: "--config.ignore-scripts=true",
|
|
437
|
+
npm: "--ignore-scripts"
|
|
438
|
+
};
|
|
439
|
+
/**
|
|
440
|
+
* Packs the package in `cwd` into `destination`: runs its `prepack` through `<manager> run`, which uses the configured
|
|
441
|
+
* script shell, then `<manager> pack` with lifecycle scripts off, since `pnpm pack` runs them through cmd.exe on Windows
|
|
442
|
+
* whatever the script shell, so a POSIX `prepare` fails there. Returns the first failed command, else the pack.
|
|
443
|
+
*/
|
|
444
|
+
async function packTarball(manager, cwd, destination, signal) {
|
|
445
|
+
const prepack = await runCommand(manager, [
|
|
446
|
+
"run",
|
|
447
|
+
"--if-present",
|
|
448
|
+
"prepack"
|
|
449
|
+
], {
|
|
450
|
+
cwd,
|
|
451
|
+
signal
|
|
452
|
+
});
|
|
453
|
+
if (prepack.status !== 0) return prepack;
|
|
454
|
+
return runCommand(manager, [
|
|
455
|
+
"pack",
|
|
456
|
+
IGNORE_SCRIPTS[manager],
|
|
457
|
+
"--pack-destination",
|
|
458
|
+
destination
|
|
459
|
+
], {
|
|
460
|
+
cwd,
|
|
461
|
+
signal
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
//#endregion
|
|
422
465
|
//#region src/guardrails/published-types.ts
|
|
423
466
|
const DECLARATION_FILE = /\.d\.[cm]?ts$/;
|
|
424
467
|
/** An `exports` map that names declarations: a `types` condition or a `.d.ts`, `.d.mts` or `.d.cts` target. */
|
|
@@ -498,21 +541,14 @@ function packedManifest(destination) {
|
|
|
498
541
|
manifest: parseManifest(text)
|
|
499
542
|
};
|
|
500
543
|
}
|
|
501
|
-
/** Packs the package `name` once per run
|
|
544
|
+
/** Packs the package `name` once per run through {@link packTarball} and reads the manifest its tarball holds. */
|
|
502
545
|
async function pack(run, name) {
|
|
503
546
|
const cached = run.packs.get(name);
|
|
504
547
|
if (cached) return cached;
|
|
505
548
|
const slot = String(run.packs.size);
|
|
506
549
|
const destination = join(run.scratch, "tarballs", slot);
|
|
507
550
|
mkdirSync(destination, { recursive: true });
|
|
508
|
-
const result = await
|
|
509
|
-
"pack",
|
|
510
|
-
"--pack-destination",
|
|
511
|
-
destination
|
|
512
|
-
], {
|
|
513
|
-
cwd: join(run.root, run.members.get(name) ?? ""),
|
|
514
|
-
signal: run.signal
|
|
515
|
-
});
|
|
551
|
+
const result = await packTarball(run.manager, join(run.root, run.members.get(name) ?? ""), destination, run.signal);
|
|
516
552
|
const packed = result.status === 0 ? packedManifest(destination) : { failure: `Packing ${name} failed:\n${result.output}` };
|
|
517
553
|
run.packs.set(name, packed);
|
|
518
554
|
return packed;
|
|
@@ -663,6 +699,12 @@ async function checkPublishedTypes(root, signal) {
|
|
|
663
699
|
//#region src/guardrails/readme-version.ts
|
|
664
700
|
/** An object literal holding no other, such as a config example's `source: { package, version }`. */
|
|
665
701
|
const FLAT_OBJECT = /\{[^{}]*\}/g;
|
|
702
|
+
const ANTELOPEJS_SCOPE = "@antelopejs/";
|
|
703
|
+
const DEFAULT_REGISTRY = "https://registry.npmjs.org/";
|
|
704
|
+
/** How long one read of a package's dist-tags may take before it counts as failed. */
|
|
705
|
+
const REGISTRY_TIMEOUT_MS = 3e3;
|
|
706
|
+
/** How many times a read that failed or timed out is made before the version counts as unreadable. */
|
|
707
|
+
const REGISTRY_ATTEMPTS = 2;
|
|
666
708
|
function stringField(body, key) {
|
|
667
709
|
return new RegExp(String.raw`(?<![\w$-])["']?${key}["']?\s*:\s*["']([^"'\n]+)["']`).exec(body);
|
|
668
710
|
}
|
|
@@ -688,33 +730,74 @@ function ownPackages(root) {
|
|
|
688
730
|
function examplesIn(readme, text, packages) {
|
|
689
731
|
return [...text.matchAll(FLAT_OBJECT)].flatMap((object) => {
|
|
690
732
|
const name = stringField(object[0], "package")?.[1];
|
|
691
|
-
const owner = name === void 0 ? void 0 : packages.get(name);
|
|
692
733
|
const field = stringField(object[0], "version");
|
|
693
734
|
const range = field?.[1];
|
|
694
|
-
if (!name || !
|
|
735
|
+
if (!name?.startsWith(ANTELOPEJS_SCOPE) || !field || range === void 0) return [];
|
|
695
736
|
return [{
|
|
696
737
|
readme,
|
|
697
738
|
line: text.slice(0, object.index + field.index).split("\n").length,
|
|
698
739
|
name,
|
|
699
740
|
range,
|
|
700
|
-
owner
|
|
741
|
+
owner: packages.get(name)
|
|
701
742
|
}];
|
|
702
743
|
});
|
|
703
744
|
}
|
|
704
|
-
/** The config examples in the `README.md` of the root and of each workspace package that give
|
|
745
|
+
/** The config examples in the `README.md` of the root and of each workspace package that give an `@antelopejs/*` package a `version`. */
|
|
705
746
|
function readmeExamples(root) {
|
|
706
747
|
const readmes = packageDirectories(root).map((directory) => relative$1(directory, "README.md")).filter((readme) => existsSync(join(root, readme)));
|
|
707
748
|
if (!readmes.length) return [];
|
|
708
749
|
const packages = ownPackages(root);
|
|
709
750
|
return readmes.flatMap((readme) => examplesIn(readme, readFileSync(join(root, readme), "utf8"), packages));
|
|
710
751
|
}
|
|
752
|
+
function registry() {
|
|
753
|
+
const configured = process.env.npm_config_registry || process.env.NPM_CONFIG_REGISTRY;
|
|
754
|
+
if (!configured) return DEFAULT_REGISTRY;
|
|
755
|
+
return configured.endsWith("/") ? configured : `${configured}/`;
|
|
756
|
+
}
|
|
757
|
+
/** The `latest` dist-tag of `name` on the registry npm is configured with, or `undefined` when it cannot be read within {@link REGISTRY_ATTEMPTS} reads of {@link REGISTRY_TIMEOUT_MS} each. */
|
|
758
|
+
async function publishedVersion(name) {
|
|
759
|
+
for (let attempt = 0; attempt < REGISTRY_ATTEMPTS; attempt++) try {
|
|
760
|
+
const response = await fetch(new URL(name.replace("/", "%2f"), registry()), {
|
|
761
|
+
headers: { accept: "application/vnd.npm.install-v1+json" },
|
|
762
|
+
signal: AbortSignal.timeout(REGISTRY_TIMEOUT_MS)
|
|
763
|
+
});
|
|
764
|
+
return response.ok ? tagVersion(parseJson(await response.text()), "latest") : void 0;
|
|
765
|
+
} catch {
|
|
766
|
+
continue;
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
async function newestVersions(examples) {
|
|
770
|
+
const names = [...new Set(examples.map(({ name }) => name))];
|
|
771
|
+
const entries = await Promise.all(names.map(async (name) => {
|
|
772
|
+
const owner = examples.find((example) => example.name === name)?.owner;
|
|
773
|
+
if (owner) return [name, {
|
|
774
|
+
version: owner.version,
|
|
775
|
+
source: `the version in ${owner.manifest}`
|
|
776
|
+
}];
|
|
777
|
+
const version = await publishedVersion(name);
|
|
778
|
+
return [name, version === void 0 ? void 0 : {
|
|
779
|
+
version,
|
|
780
|
+
source: "its newest published version"
|
|
781
|
+
}];
|
|
782
|
+
}));
|
|
783
|
+
return new Map(entries);
|
|
784
|
+
}
|
|
785
|
+
function describe({ readme, line, name, range }, newest) {
|
|
786
|
+
if (newest === void 0) return `${readme}:${line} gives ${name} the version range "${range}", but its newest published version could not be read from ${registry()}.\n`;
|
|
787
|
+
const expected = cappedReplacement(range, newest.version);
|
|
788
|
+
if (expected === void 0) return "";
|
|
789
|
+
return `${readme}:${line} gives ${name} the version range "${range}", which does not stop below the next minor of ${newest.version}, ${newest.source}. Use "${expected}".\n`;
|
|
790
|
+
}
|
|
711
791
|
/**
|
|
712
|
-
* Fails for each README config example whose `version` range
|
|
713
|
-
*
|
|
714
|
-
*
|
|
792
|
+
* Fails for each README config example whose `@antelopejs/*` `version` range does not stop below the next minor of the
|
|
793
|
+
* package's newest version and admit it, naming the README line and the range to use. The newest version is the one in
|
|
794
|
+
* the repository's own `package.json` for its own packages, and the registry's `latest` dist-tag for any other. A value
|
|
795
|
+
* that is not a range, such as a dist-tag, passes.
|
|
715
796
|
*/
|
|
716
|
-
function checkReadmeVersion(root) {
|
|
717
|
-
|
|
797
|
+
async function checkReadmeVersion(root) {
|
|
798
|
+
const examples = readmeExamples(root).filter(({ range }) => validRange(range) !== null);
|
|
799
|
+
const newest = await newestVersions(examples);
|
|
800
|
+
return examples.map((example) => describe(example, newest.get(example.name))).join("");
|
|
718
801
|
}
|
|
719
802
|
//#endregion
|
|
720
803
|
//#region src/guardrails/services.ts
|
|
@@ -1621,7 +1704,7 @@ const OWN_STEPS = /* @__PURE__ */ new Map([
|
|
|
1621
1704
|
["lockfile:singletons", (root) => Promise.resolve(checkSingletonPackages(root))],
|
|
1622
1705
|
["dependency:ranges", (root) => Promise.resolve(checkRepositoryRanges(root))],
|
|
1623
1706
|
["git:identity", checkGitIdentity],
|
|
1624
|
-
["readme:version",
|
|
1707
|
+
["readme:version", checkReadmeVersion],
|
|
1625
1708
|
["published:types", checkPublishedTypes]
|
|
1626
1709
|
]);
|
|
1627
1710
|
function hasWork(root, step) {
|
package/dist/eslint.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as typeAwareRuleSetting, t as TYPE_AWARE_RULES } from "./type-aware-rules-Da3769fI.mjs";
|
|
2
|
-
import { t as guardrailsPlugin } from "./guardrails-
|
|
2
|
+
import { t as guardrailsPlugin } from "./guardrails-6i82vsUi.mjs";
|
|
3
3
|
import { createConfigForNuxt } from "@nuxt/eslint-config/flat";
|
|
4
4
|
//#region src/eslint.ts
|
|
5
5
|
/** Whether every rule of `plugin` has the `create` function ESLint calls, which `eslintCompatPlugin` gives each oxlint rule. */
|
|
@@ -414,7 +414,7 @@ function checksOwnKey(node, read) {
|
|
|
414
414
|
}
|
|
415
415
|
const EQUALITY = /* @__PURE__ */ new Set(["==", "==="]);
|
|
416
416
|
const INEQUALITY = /* @__PURE__ */ new Set(["!=", "!=="]);
|
|
417
|
-
const MAX_DEPTH$
|
|
417
|
+
const MAX_DEPTH$3 = 8;
|
|
418
418
|
const ASSERTS = /* @__PURE__ */ new Set([
|
|
419
419
|
"assert",
|
|
420
420
|
"assert.ok",
|
|
@@ -441,7 +441,7 @@ function comparedOutcome(node, outcome) {
|
|
|
441
441
|
}
|
|
442
442
|
/** A value that is `true` or `false`, so comparing it with a boolean literal tests its truth: a call, a `!`, or a `const` of one. */
|
|
443
443
|
function isBooleanValued(node, read, depth) {
|
|
444
|
-
if (depth > MAX_DEPTH$
|
|
444
|
+
if (depth > MAX_DEPTH$3) return false;
|
|
445
445
|
if (node.type === "ParenthesizedExpression") return isBooleanValued(node.expression, read, depth);
|
|
446
446
|
if (node.type === "Identifier") {
|
|
447
447
|
const value = constValue(node, read);
|
|
@@ -478,7 +478,7 @@ function combinedHolds(node, outcome, read, depth) {
|
|
|
478
478
|
* `Object.prototype`'s own value.
|
|
479
479
|
*/
|
|
480
480
|
function holds$1(node, outcome, read, depth = 0) {
|
|
481
|
-
if (depth > MAX_DEPTH$
|
|
481
|
+
if (depth > MAX_DEPTH$3) return false;
|
|
482
482
|
switch (node.type) {
|
|
483
483
|
case "ParenthesizedExpression": return holds$1(node.expression, outcome, read, depth);
|
|
484
484
|
case "CallExpression": return outcome ? checksOwnKey(node, read) : checksOwnKey(node, {
|
|
@@ -1839,6 +1839,29 @@ function scriptView(sfc) {
|
|
|
1839
1839
|
}
|
|
1840
1840
|
return end === 0 ? void 0 : `${view}${blank(sfc.slice(end))}${MODULE}`;
|
|
1841
1841
|
}
|
|
1842
|
+
/**
|
|
1843
|
+
* The text to type for a linted file. A component whose linted text holds no
|
|
1844
|
+
* script block, as oxlint passes a component's script alone, is read whole
|
|
1845
|
+
* from disk, and `offset` is where that script starts inside the block whose
|
|
1846
|
+
* contents it is, which oxlint passes trimmed. Undefined for a component with no such block, or that
|
|
1847
|
+
* declares `generic` type parameters.
|
|
1848
|
+
*/
|
|
1849
|
+
function lintedSource(filename, text) {
|
|
1850
|
+
if (!filename.endsWith(".vue")) return {
|
|
1851
|
+
text,
|
|
1852
|
+
offset: 0
|
|
1853
|
+
};
|
|
1854
|
+
if (scriptView(text) !== void 0) return declaresTypeParameters(text) ? void 0 : {
|
|
1855
|
+
text,
|
|
1856
|
+
offset: 0
|
|
1857
|
+
};
|
|
1858
|
+
const component = readFileSync(filename, "utf8");
|
|
1859
|
+
const block = Array.from(component.matchAll(BLOCK)).find(({ 1: open, 2: content }) => open !== void 0 && content?.trim() === text.trim());
|
|
1860
|
+
return block?.[1] === void 0 || block[2] === void 0 || declaresTypeParameters(component) ? void 0 : {
|
|
1861
|
+
text: component,
|
|
1862
|
+
offset: block.index + block[1].length + block[2].indexOf(text)
|
|
1863
|
+
};
|
|
1864
|
+
}
|
|
1842
1865
|
/** Whether a script block of the component declares type parameters with `generic`, which only Vue's compiler brings into scope, so the view types them as error types. */
|
|
1843
1866
|
function declaresTypeParameters(sfc) {
|
|
1844
1867
|
return Array.from(sfc.matchAll(BLOCK)).some(({ 1: open }) => open !== void 0 && GENERIC.test(open));
|
|
@@ -1963,12 +1986,12 @@ function resultIsAwaited(fn) {
|
|
|
1963
1986
|
const call = fn.parent;
|
|
1964
1987
|
return call?.type === "CallExpression" && call.arguments.some((argument) => argument === fn) && isPromiseCallback(call);
|
|
1965
1988
|
}
|
|
1966
|
-
/** Whether `call` calls the first parameter of a function it sits in, as a `new Promise` executor calls its `resolve`. */
|
|
1989
|
+
/** Whether `call` calls the first parameter after any `this` parameter of a function it sits in, as a `new Promise` executor calls its `resolve`. */
|
|
1967
1990
|
function callsFirstParameter(call) {
|
|
1968
1991
|
const { callee } = call;
|
|
1969
1992
|
if (callee.type !== "Identifier") return false;
|
|
1970
1993
|
for (let fn = enclosingFunction(call); fn !== null; fn = enclosingFunction(fn)) {
|
|
1971
|
-
const
|
|
1994
|
+
const first = fn.params.find((param) => param.type !== "Identifier" || param.name !== "this");
|
|
1972
1995
|
const name = first?.type === "AssignmentPattern" ? first.left : first;
|
|
1973
1996
|
if (name?.type === "Identifier" && name.name === callee.name) return true;
|
|
1974
1997
|
}
|
|
@@ -1986,21 +2009,24 @@ function isQuery(checker, type) {
|
|
|
1986
2009
|
function isTable(checker, type) {
|
|
1987
2010
|
return declaredIn(checker.getPropertyOfType(type, "insert"), INTERFACE_DATABASE);
|
|
1988
2011
|
}
|
|
1989
|
-
/** Whether `type` is an object literal,
|
|
2012
|
+
/** Whether `type` is an object literal, an interface or object type the project declares, a mapped type such as `Readonly<T>` or `Record<K, V>`, or an intersection of those, as opposed to a class instance or a library type. */
|
|
1990
2013
|
function isHolder(type) {
|
|
2014
|
+
if (type.isIntersection()) return type.types.every(isHolder);
|
|
1991
2015
|
const symbol = type.getSymbol();
|
|
2016
|
+
if (symbol?.declarations?.some(ts.isMappedTypeNode) === true) return true;
|
|
1992
2017
|
return symbol !== void 0 && (symbol.flags & HOLDERS) !== 0 && (symbol.flags & ts.SymbolFlags.Class) === 0 && !declaredIn(symbol, "/node_modules/");
|
|
1993
2018
|
}
|
|
1994
2019
|
function members$1(type) {
|
|
1995
2020
|
return type.isUnion() ? type.types : [type];
|
|
1996
2021
|
}
|
|
1997
|
-
/** The values an array, a tuple or a holder keeps, which awaiting it leaves as they are. */
|
|
2022
|
+
/** The values an array, a tuple or a holder keeps in its properties and index signatures, which awaiting it leaves as they are. */
|
|
1998
2023
|
function heldValues(checker, type) {
|
|
1999
2024
|
if (checker.isArrayType(type) || checker.isTupleType(type)) {
|
|
2000
2025
|
const element = checker.getIndexTypeOfType(type, ts.IndexKind.Number);
|
|
2001
2026
|
return element === void 0 ? [] : [element];
|
|
2002
2027
|
}
|
|
2003
|
-
|
|
2028
|
+
if (!isHolder(type)) return [];
|
|
2029
|
+
return [...checker.getPropertiesOfType(type).map((property) => checker.getTypeOfSymbol(property)), ...checker.getIndexInfosOfType(type).map((info) => info.type)];
|
|
2004
2030
|
}
|
|
2005
2031
|
/** Whether an array, a tuple or a holder of `type` keeps a query other than a table at any depth. */
|
|
2006
2032
|
function holdsHeldQuery(checker, type, visited) {
|
|
@@ -2021,12 +2047,40 @@ function callbackResult(checker, callback) {
|
|
|
2021
2047
|
return checker.getTypeAtLocation(callback).getCallSignatures().filter(({ declaration }) => declaration === void 0 || (ts.getCombinedModifierFlags(declaration) & ts.ModifierFlags.Async) === 0).map((signature) => checker.getReturnTypeOfSignature(signature));
|
|
2022
2048
|
}
|
|
2023
2049
|
const executorsByFile = /* @__PURE__ */ new WeakMap();
|
|
2024
|
-
/**
|
|
2025
|
-
function
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2050
|
+
/** `expression` without the parentheses, `as`, `<T>`, `satisfies` and `!` around it. */
|
|
2051
|
+
function unwrapped(expression) {
|
|
2052
|
+
return ts.isParenthesizedExpression(expression) || ts.isAsExpression(expression) || ts.isTypeAssertionExpression(expression) || ts.isSatisfiesExpression(expression) || ts.isNonNullExpression(expression) ? unwrapped(expression.expression) : expression;
|
|
2053
|
+
}
|
|
2054
|
+
/** The function a declaration holds: the initialiser of a variable or property, the value a shorthand property names, or the declaration itself. */
|
|
2055
|
+
function declaredFunctions(checker, declaration) {
|
|
2056
|
+
if (ts.isShorthandPropertyAssignment(declaration)) return (checker.getShorthandAssignmentValueSymbol(declaration)?.declarations ?? []).flatMap((value) => declaredFunctions(checker, value));
|
|
2057
|
+
return (ts.isVariableDeclaration(declaration) || ts.isPropertyDeclaration(declaration) || ts.isPropertyAssignment(declaration)) && declaration.initializer !== void 0 ? [unwrapped(declaration.initializer)] : [declaration];
|
|
2058
|
+
}
|
|
2059
|
+
/** `value` as a member access the source names, or `undefined` for any other expression. */
|
|
2060
|
+
function namedMember(value) {
|
|
2061
|
+
if (ts.isPropertyAccessExpression(value)) return {
|
|
2062
|
+
receiver: value.expression,
|
|
2063
|
+
key: value,
|
|
2064
|
+
name: value.name.text
|
|
2065
|
+
};
|
|
2066
|
+
return ts.isElementAccessExpression(value) && ts.isStringLiteralLike(value.argumentExpression) ? {
|
|
2067
|
+
receiver: value.expression,
|
|
2068
|
+
key: value.argumentExpression,
|
|
2069
|
+
name: value.argumentExpression.text
|
|
2070
|
+
} : void 0;
|
|
2071
|
+
}
|
|
2072
|
+
/** The declarations of `member` on the value its receiver variable is initialised with, past any type annotation that names only a signature. */
|
|
2073
|
+
function initialisedMember(checker, member) {
|
|
2074
|
+
const receiver = ts.isIdentifier(member.receiver) ? checker.getSymbolAtLocation(member.receiver)?.valueDeclaration : void 0;
|
|
2075
|
+
return receiver !== void 0 && ts.isVariableDeclaration(receiver) && receiver.initializer !== void 0 ? checker.getTypeAtLocation(unwrapped(receiver.initializer)).getProperty(member.name)?.declarations ?? [] : [];
|
|
2076
|
+
}
|
|
2077
|
+
/** The functions a `new Promise` argument names: the function written there, or each declaration, overloads included, or initialiser of the variable, property or method its identifier, member access or literal-keyed element access resolves to. */
|
|
2078
|
+
function namedFunctions(checker, argument) {
|
|
2079
|
+
const value = unwrapped(argument);
|
|
2080
|
+
if (ts.isFunctionExpression(value) || ts.isArrowFunction(value)) return [value];
|
|
2081
|
+
const member = namedMember(value);
|
|
2082
|
+
if (!ts.isIdentifier(value) && member === void 0) return [];
|
|
2083
|
+
return [...checker.getSymbolAtLocation(member?.key ?? value)?.declarations ?? [], ...member === void 0 ? [] : initialisedMember(checker, member)].flatMap((declaration) => declaredFunctions(checker, declaration));
|
|
2030
2084
|
}
|
|
2031
2085
|
/** The functions `sourceFile` hands to `new Promise` as its executor, inline or by name. */
|
|
2032
2086
|
function promiseExecutors(checker, sourceFile) {
|
|
@@ -2035,19 +2089,18 @@ function promiseExecutors(checker, sourceFile) {
|
|
|
2035
2089
|
const executors = /* @__PURE__ */ new Set();
|
|
2036
2090
|
const visit = (node) => {
|
|
2037
2091
|
const argument = ts.isNewExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === "Promise" ? node.arguments?.[0] : void 0;
|
|
2038
|
-
const executor
|
|
2039
|
-
if (executor !== void 0) executors.add(executor);
|
|
2092
|
+
for (const executor of argument ? namedFunctions(checker, argument) : []) executors.add(executor);
|
|
2040
2093
|
ts.forEachChild(node, visit);
|
|
2041
2094
|
};
|
|
2042
2095
|
visit(sourceFile);
|
|
2043
2096
|
executorsByFile.set(sourceFile, executors);
|
|
2044
2097
|
return executors;
|
|
2045
2098
|
}
|
|
2046
|
-
/** The value `call` resolves its promise with, when its callee is the first parameter of a function the file hands to `new Promise` as its executor. */
|
|
2099
|
+
/** The value `call` resolves its promise with, when its callee is the first parameter after any `this` parameter of a function the file hands to `new Promise` as its executor. */
|
|
2047
2100
|
function resolvedValue(checker, call) {
|
|
2048
2101
|
const parameter = checker.getSymbolAtLocation(call.expression)?.valueDeclaration;
|
|
2049
2102
|
const executor = parameter?.parent;
|
|
2050
|
-
return parameter !== void 0 && ts.isParameter(parameter) && executor !== void 0 && ts.isFunctionLike(executor) && executor.parameters
|
|
2103
|
+
return parameter !== void 0 && ts.isParameter(parameter) && executor !== void 0 && ts.isFunctionLike(executor) && executor.parameters.find(({ name }) => !ts.isIdentifier(name) || name.text !== "this") === parameter && promiseExecutors(checker, call.getSourceFile()).has(executor) ? call.arguments[0] : void 0;
|
|
2051
2104
|
}
|
|
2052
2105
|
/** Since interface-database 0.4.0 a query is no longer thenable, so an awaited function that returns one, alone or wrapped, resolves to the unrun query and sends nothing. */
|
|
2053
2106
|
const noUnrunQueryRule = defineRule({
|
|
@@ -2095,6 +2148,303 @@ const noUnrunQueryRule = defineRule({
|
|
|
2095
2148
|
}
|
|
2096
2149
|
});
|
|
2097
2150
|
//#endregion
|
|
2151
|
+
//#region src/oxc/guardrails/rules/no-unsafe-any-in-vue.ts
|
|
2152
|
+
const UNTYPED$1 = ts.TypeFlags.Any | ts.TypeFlags.Unknown;
|
|
2153
|
+
const MAX_DEPTH$2 = 4;
|
|
2154
|
+
/** Whether `type` is `any` itself, not an error type from an import the program cannot resolve, such as another component. */
|
|
2155
|
+
function isAnyType(checker, type) {
|
|
2156
|
+
return type === checker.getAnyType();
|
|
2157
|
+
}
|
|
2158
|
+
function isAny(checker, node) {
|
|
2159
|
+
return isAnyType(checker, checker.getTypeAtLocation(node));
|
|
2160
|
+
}
|
|
2161
|
+
function takesAnything(type) {
|
|
2162
|
+
return type === void 0 || (type.flags & UNTYPED$1) !== 0;
|
|
2163
|
+
}
|
|
2164
|
+
function isObjectType(type) {
|
|
2165
|
+
return (type.flags & ts.TypeFlags.Object) !== 0;
|
|
2166
|
+
}
|
|
2167
|
+
function isReference(type) {
|
|
2168
|
+
return (type.objectFlags & ts.ObjectFlags.Reference) !== 0;
|
|
2169
|
+
}
|
|
2170
|
+
/** The array or tuple reference `type` is, for comparing by its generic target as tsgolint does. */
|
|
2171
|
+
function arrayReference(checker, type) {
|
|
2172
|
+
return (checker.isArrayType(type) || checker.isTupleType(type)) && isObjectType(type) && isReference(type) ? type : void 0;
|
|
2173
|
+
}
|
|
2174
|
+
/**
|
|
2175
|
+
* Whether a `sender` value lets `any` into a `receiver` slot as an argument,
|
|
2176
|
+
* a return or a type argument: `any` into a slot that is undeclared or typed
|
|
2177
|
+
* neither `any` nor `unknown`, or an array or tuple holding `any`, as in
|
|
2178
|
+
* `any[]`, into one of the same generic target, such as `string[]`, with
|
|
2179
|
+
* another type in that position. `readonly` and labelled tuples have targets
|
|
2180
|
+
* of their own.
|
|
2181
|
+
*/
|
|
2182
|
+
function leaks(checker, sender, receiver, depth = 0) {
|
|
2183
|
+
if (isAnyType(checker, sender)) return receiver === void 0 || !takesAnything(receiver);
|
|
2184
|
+
if (receiver === void 0 || depth === MAX_DEPTH$2) return false;
|
|
2185
|
+
const from = arrayReference(checker, sender);
|
|
2186
|
+
const to = arrayReference(checker, receiver);
|
|
2187
|
+
if (from === void 0 || to === void 0 || from.target !== to.target) return false;
|
|
2188
|
+
const slots = checker.getTypeArguments(to);
|
|
2189
|
+
return checker.getTypeArguments(from).some((argument, index) => leaks(checker, argument, slots[index], depth + 1));
|
|
2190
|
+
}
|
|
2191
|
+
/** Whether `sender` lets `any` into an assigned `receiver`: `any` into anything but `unknown`, a slot declared `any` included, or what {@link leaks} finds. */
|
|
2192
|
+
function assignmentLeaks(checker, sender, receiver) {
|
|
2193
|
+
return isAnyType(checker, sender) ? receiver === void 0 || (receiver.flags & ts.TypeFlags.Unknown) === 0 : leaks(checker, sender, receiver);
|
|
2194
|
+
}
|
|
2195
|
+
/** Whether `value`, flowing into the slot its context declares, lets `any` in. */
|
|
2196
|
+
function leaksIntoContext(checker, value) {
|
|
2197
|
+
return assignmentLeaks(checker, checker.getTypeAtLocation(value), checker.getContextualType(value));
|
|
2198
|
+
}
|
|
2199
|
+
/** Whether `literal` is the target of a destructuring assignment, as in `({ a } = value)`, whose elements name targets, not values. */
|
|
2200
|
+
function isDestructuringTarget(literal) {
|
|
2201
|
+
let child = literal;
|
|
2202
|
+
let parent = literal.parent;
|
|
2203
|
+
while (ts.isParenthesizedExpression(parent) || ts.isArrayLiteralExpression(parent) || ts.isObjectLiteralExpression(parent) || ts.isPropertyAssignment(parent) || ts.isShorthandPropertyAssignment(parent) || ts.isSpreadElement(parent) || ts.isSpreadAssignment(parent)) {
|
|
2204
|
+
child = parent;
|
|
2205
|
+
parent = parent.parent;
|
|
2206
|
+
}
|
|
2207
|
+
return ts.isBinaryExpression(parent) && parent.operatorToken.kind === ts.SyntaxKind.EqualsToken && parent.left === child || (ts.isForOfStatement(parent) || ts.isForInStatement(parent)) && parent.initializer === child;
|
|
2208
|
+
}
|
|
2209
|
+
function declaredReturn(checker, node) {
|
|
2210
|
+
let owner = node.parent;
|
|
2211
|
+
while (!ts.isFunctionLike(owner)) {
|
|
2212
|
+
if (ts.isSourceFile(owner)) return void 0;
|
|
2213
|
+
owner = owner.parent;
|
|
2214
|
+
}
|
|
2215
|
+
const contextual = ts.isExpression(owner) ? checker.getContextualType(owner) : void 0;
|
|
2216
|
+
const declared = owner.type === void 0 ? contextual && checker.getNonNullableType(contextual).getCallSignatures()[0]?.getReturnType() : checker.getTypeFromTypeNode(owner.type);
|
|
2217
|
+
const isAsync = ts.canHaveModifiers(owner) && ts.getModifiers(owner)?.some((modifier) => modifier.kind === ts.SyntaxKind.AsyncKeyword);
|
|
2218
|
+
return declared && isAsync ? checker.getAwaitedType(declared) : declared;
|
|
2219
|
+
}
|
|
2220
|
+
function argumentFindings(checker, call) {
|
|
2221
|
+
return (call.arguments ?? []).flatMap((argument) => {
|
|
2222
|
+
const parameter = checker.getContextualType(argument);
|
|
2223
|
+
return ts.isSpreadElement(argument) || parameter === void 0 || !leaks(checker, checker.getTypeAtLocation(argument), parameter) ? [] : [{
|
|
2224
|
+
kind: "argument",
|
|
2225
|
+
node: argument
|
|
2226
|
+
}];
|
|
2227
|
+
});
|
|
2228
|
+
}
|
|
2229
|
+
function returned(checker, value) {
|
|
2230
|
+
return leaks(checker, checker.getTypeAtLocation(value), declaredReturn(checker, value)) ? [{
|
|
2231
|
+
kind: "return",
|
|
2232
|
+
node: value
|
|
2233
|
+
}] : [];
|
|
2234
|
+
}
|
|
2235
|
+
/** Whether `type` is `any` or an array of `any`, as a spread or rest holds it. */
|
|
2236
|
+
function isAnyOrAnyArray(checker, type) {
|
|
2237
|
+
const element = checker.isArrayType(type) ? checker.getIndexTypeOfType(type, ts.IndexKind.Number) : void 0;
|
|
2238
|
+
return isAnyType(checker, type) || element !== void 0 && isAnyType(checker, element);
|
|
2239
|
+
}
|
|
2240
|
+
function spreadFindings(checker, spread) {
|
|
2241
|
+
const { parent } = spread;
|
|
2242
|
+
return !((ts.isCallExpression(parent) || ts.isNewExpression(parent)) && isAny(checker, parent.expression)) && !isDestructuringTarget(parent) && isAnyOrAnyArray(checker, checker.getTypeAtLocation(spread.expression)) ? [{
|
|
2243
|
+
kind: ts.isArrayLiteralExpression(spread.parent) ? "assignment" : "argument",
|
|
2244
|
+
node: spread
|
|
2245
|
+
}] : [];
|
|
2246
|
+
}
|
|
2247
|
+
function propertyFindings(checker, property) {
|
|
2248
|
+
if (isDestructuringTarget(property.parent)) {
|
|
2249
|
+
const fallback = ts.isShorthandPropertyAssignment(property) ? property.objectAssignmentInitializer : void 0;
|
|
2250
|
+
return fallback !== void 0 && assignmentLeaks(checker, checker.getTypeAtLocation(fallback), checker.getTypeAtLocation(property.name)) ? [{
|
|
2251
|
+
kind: "assignment",
|
|
2252
|
+
node: property
|
|
2253
|
+
}] : [];
|
|
2254
|
+
}
|
|
2255
|
+
return leaksIntoContext(checker, ts.isPropertyAssignment(property) ? property.initializer : property.name) ? [{
|
|
2256
|
+
kind: "assignment",
|
|
2257
|
+
node: property
|
|
2258
|
+
}] : [];
|
|
2259
|
+
}
|
|
2260
|
+
function isPattern(node) {
|
|
2261
|
+
return ts.isObjectBindingPattern(node) || ts.isArrayBindingPattern(node) || ts.isObjectLiteralExpression(node) || ts.isArrayLiteralExpression(node);
|
|
2262
|
+
}
|
|
2263
|
+
/** The key a property name spells, a computed literal such as `['a']` included. */
|
|
2264
|
+
function literalKey(name) {
|
|
2265
|
+
if (ts.isIdentifier(name)) return name.text;
|
|
2266
|
+
const key = ts.isComputedPropertyName(name) ? name.expression : name;
|
|
2267
|
+
return ts.isStringLiteral(key) || ts.isNumericLiteral(key) || ts.isNoSubstitutionTemplateLiteral(key) ? key.text : void 0;
|
|
2268
|
+
}
|
|
2269
|
+
/** The target and default of an assignment pattern element, as in `a = fallback`. */
|
|
2270
|
+
function withDefault(element) {
|
|
2271
|
+
return ts.isBinaryExpression(element) && element.operatorToken.kind === ts.SyntaxKind.EqualsToken ? {
|
|
2272
|
+
target: element.left,
|
|
2273
|
+
initializer: element.right
|
|
2274
|
+
} : {
|
|
2275
|
+
target: element,
|
|
2276
|
+
initializer: void 0
|
|
2277
|
+
};
|
|
2278
|
+
}
|
|
2279
|
+
function objectElements(pattern) {
|
|
2280
|
+
if (ts.isObjectBindingPattern(pattern)) return pattern.elements.map((element) => ({
|
|
2281
|
+
key: element.dotDotDotToken === void 0 ? literalKey(element.propertyName ?? element.name) : void 0,
|
|
2282
|
+
target: element.name,
|
|
2283
|
+
initializer: element.initializer,
|
|
2284
|
+
node: element
|
|
2285
|
+
}));
|
|
2286
|
+
return pattern.properties.map((property) => {
|
|
2287
|
+
if (ts.isPropertyAssignment(property)) return {
|
|
2288
|
+
key: literalKey(property.name),
|
|
2289
|
+
...withDefault(property.initializer),
|
|
2290
|
+
node: property
|
|
2291
|
+
};
|
|
2292
|
+
if (ts.isShorthandPropertyAssignment(property)) return {
|
|
2293
|
+
key: property.name.text,
|
|
2294
|
+
target: property.name,
|
|
2295
|
+
initializer: property.objectAssignmentInitializer,
|
|
2296
|
+
node: property
|
|
2297
|
+
};
|
|
2298
|
+
return {
|
|
2299
|
+
key: void 0,
|
|
2300
|
+
target: property,
|
|
2301
|
+
initializer: void 0,
|
|
2302
|
+
node: property
|
|
2303
|
+
};
|
|
2304
|
+
});
|
|
2305
|
+
}
|
|
2306
|
+
function arrayElements(pattern) {
|
|
2307
|
+
return pattern.elements.flatMap((element, index) => {
|
|
2308
|
+
if (ts.isOmittedExpression(element)) return [];
|
|
2309
|
+
if (ts.isBindingElement(element)) return [{
|
|
2310
|
+
key: element.dotDotDotToken === void 0 ? String(index) : void 0,
|
|
2311
|
+
target: element.name,
|
|
2312
|
+
initializer: element.initializer,
|
|
2313
|
+
node: element
|
|
2314
|
+
}];
|
|
2315
|
+
if (ts.isSpreadElement(element)) return [{
|
|
2316
|
+
key: void 0,
|
|
2317
|
+
target: element.expression,
|
|
2318
|
+
initializer: void 0,
|
|
2319
|
+
node: element
|
|
2320
|
+
}];
|
|
2321
|
+
return [{
|
|
2322
|
+
key: String(index),
|
|
2323
|
+
...withDefault(element),
|
|
2324
|
+
node: element
|
|
2325
|
+
}];
|
|
2326
|
+
});
|
|
2327
|
+
}
|
|
2328
|
+
/** An element that takes an `any` its source declares, but for one whose default is itself reported, and the elements nested under it. */
|
|
2329
|
+
function elementFindings(checker, element, source) {
|
|
2330
|
+
if (isAnyType(checker, source)) return element.initializer !== void 0 && isAny(checker, element.initializer) ? [] : [{
|
|
2331
|
+
kind: "assignment",
|
|
2332
|
+
node: element.node
|
|
2333
|
+
}];
|
|
2334
|
+
return isPattern(element.target) ? destructuredFindings(checker, element.target, source) : [];
|
|
2335
|
+
}
|
|
2336
|
+
/** The property or tuple slot named `key` that `source` declares, not one an index signature stands for. */
|
|
2337
|
+
function declaredSlot(checker, source, key, at) {
|
|
2338
|
+
const slot = checker.getPropertyOfType(source, key);
|
|
2339
|
+
return slot === void 0 ? void 0 : checker.getTypeOfSymbolAtLocation(slot, at);
|
|
2340
|
+
}
|
|
2341
|
+
function slotFindings(checker, element, source) {
|
|
2342
|
+
const slot = element.key === void 0 ? void 0 : declaredSlot(checker, source, element.key, element.node);
|
|
2343
|
+
return slot === void 0 ? [] : elementFindings(checker, element, slot);
|
|
2344
|
+
}
|
|
2345
|
+
/**
|
|
2346
|
+
* The elements of an untyped destructuring declaration or of a destructuring
|
|
2347
|
+
* assignment that take `any` from what `source` declares: a property or
|
|
2348
|
+
* tuple slot typed `any`, whatever the target's own type, or the whole
|
|
2349
|
+
* pattern once when it reads an `any[]`. An index signature, another iterable
|
|
2350
|
+
* and a rest from an object or a tuple are left alone, as
|
|
2351
|
+
* `typescript/no-unsafe-assignment` leaves them.
|
|
2352
|
+
*/
|
|
2353
|
+
function destructuredFindings(checker, pattern, source) {
|
|
2354
|
+
if (ts.isObjectBindingPattern(pattern) || ts.isObjectLiteralExpression(pattern)) return objectElements(pattern).flatMap((element) => slotFindings(checker, element, source));
|
|
2355
|
+
if (isAnyOrAnyArray(checker, source)) return [{
|
|
2356
|
+
kind: "assignment",
|
|
2357
|
+
node: pattern
|
|
2358
|
+
}];
|
|
2359
|
+
return checker.isTupleType(source) ? arrayElements(pattern).flatMap((element) => slotFindings(checker, element, source)) : [];
|
|
2360
|
+
}
|
|
2361
|
+
function declarationFindings(checker, node, initializer) {
|
|
2362
|
+
if (assignmentLeaks(checker, checker.getTypeAtLocation(initializer), node.type === void 0 ? void 0 : checker.getTypeAtLocation(node.name))) return [{
|
|
2363
|
+
kind: "assignment",
|
|
2364
|
+
node
|
|
2365
|
+
}];
|
|
2366
|
+
return node.type === void 0 && !ts.isIdentifier(node.name) ? destructuredFindings(checker, node.name, checker.getTypeAtLocation(initializer)) : [];
|
|
2367
|
+
}
|
|
2368
|
+
function assignmentFindings(checker, node) {
|
|
2369
|
+
if (ts.isVariableDeclaration(node) && node.initializer !== void 0) return declarationFindings(checker, node, node.initializer);
|
|
2370
|
+
if (ts.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.EqualsToken) {
|
|
2371
|
+
const source = checker.getTypeAtLocation(node.right);
|
|
2372
|
+
if (assignmentLeaks(checker, source, checker.getTypeAtLocation(node.left))) return [{
|
|
2373
|
+
kind: "assignment",
|
|
2374
|
+
node
|
|
2375
|
+
}];
|
|
2376
|
+
return ts.isObjectLiteralExpression(node.left) || ts.isArrayLiteralExpression(node.left) ? destructuredFindings(checker, node.left, source) : [];
|
|
2377
|
+
}
|
|
2378
|
+
if ((ts.isParameter(node) || ts.isBindingElement(node)) && node.initializer !== void 0) return leaksIntoContext(checker, node.initializer) ? [{
|
|
2379
|
+
kind: "assignment",
|
|
2380
|
+
node
|
|
2381
|
+
}] : [];
|
|
2382
|
+
if (ts.isPropertyAssignment(node) || ts.isShorthandPropertyAssignment(node)) return propertyFindings(checker, node);
|
|
2383
|
+
return [];
|
|
2384
|
+
}
|
|
2385
|
+
function nodeFindings(checker, node) {
|
|
2386
|
+
if (ts.isSpreadElement(node)) return spreadFindings(checker, node);
|
|
2387
|
+
if (ts.isCallExpression(node) || ts.isNewExpression(node)) return argumentFindings(checker, node);
|
|
2388
|
+
if (ts.isReturnStatement(node) && node.expression !== void 0) return returned(checker, node.expression);
|
|
2389
|
+
if (ts.isArrowFunction(node) && !ts.isBlock(node.body)) return returned(checker, node.body);
|
|
2390
|
+
return assignmentFindings(checker, node);
|
|
2391
|
+
}
|
|
2392
|
+
function findings({ checker, sourceFile }) {
|
|
2393
|
+
const found = [];
|
|
2394
|
+
function visit(node) {
|
|
2395
|
+
found.push(...nodeFindings(checker, node));
|
|
2396
|
+
ts.forEachChild(node, visit);
|
|
2397
|
+
}
|
|
2398
|
+
visit(sourceFile);
|
|
2399
|
+
return found;
|
|
2400
|
+
}
|
|
2401
|
+
/**
|
|
2402
|
+
* `typescript/no-unsafe-assignment`, `no-unsafe-argument` and
|
|
2403
|
+
* `no-unsafe-return` for the script blocks of a `.vue` file, which
|
|
2404
|
+
* oxlint-tsgolint cannot read: an `any` or `any[]` reaching a declared type
|
|
2405
|
+
* through a declaration, an assignment, an object literal property, a
|
|
2406
|
+
* default value, an argument, a spread, a destructured binding, a
|
|
2407
|
+
* destructuring assignment such as `({ a } = value)` or a return. An `any`
|
|
2408
|
+
* assigned to a slot declared `any` is reported too, as tsgolint reports it.
|
|
2409
|
+
* TypeScript files stay with tsgolint, and a
|
|
2410
|
+
* component with `generic` type parameters is skipped, as only Vue's compiler
|
|
2411
|
+
* brings them into scope.
|
|
2412
|
+
*/
|
|
2413
|
+
const noUnsafeAnyInVueRule = defineRule({
|
|
2414
|
+
meta: {
|
|
2415
|
+
type: "problem",
|
|
2416
|
+
docs: { description: "A Vue component's script assigns, passes and returns no `any` where a type is declared." },
|
|
2417
|
+
messages: {
|
|
2418
|
+
assignment: "Unsafe assignment of an `any` value, which `typescript/no-unsafe-assignment` reports in a TypeScript file. Use a typed value or `unknown`, and narrow it before use.",
|
|
2419
|
+
argument: "Unsafe argument of type `any` to a typed parameter, which `typescript/no-unsafe-argument` reports in a TypeScript file. Pass a typed value.",
|
|
2420
|
+
return: "Unsafe return of an `any` value from a function with a declared return type, which `typescript/no-unsafe-return` reports in a TypeScript file. Return a typed value."
|
|
2421
|
+
}
|
|
2422
|
+
},
|
|
2423
|
+
createOnce(context) {
|
|
2424
|
+
return { Program() {
|
|
2425
|
+
const { filename, sourceCode } = context;
|
|
2426
|
+
if (!filename.endsWith(".vue")) return;
|
|
2427
|
+
const { text } = sourceCode;
|
|
2428
|
+
const linted = lintedSource(filename, text);
|
|
2429
|
+
if (linted === void 0) return;
|
|
2430
|
+
const { offset } = linted;
|
|
2431
|
+
const typed = typedFile(filename, linted.text);
|
|
2432
|
+
if (typed === void 0) return;
|
|
2433
|
+
for (const { kind, node } of findings(typed)) {
|
|
2434
|
+
const start = node.getStart(typed.sourceFile) - offset;
|
|
2435
|
+
const end = node.end - offset;
|
|
2436
|
+
if (start >= 0 && end <= text.length) context.report({
|
|
2437
|
+
messageId: kind,
|
|
2438
|
+
loc: {
|
|
2439
|
+
start: sourceCode.getLocFromIndex(start),
|
|
2440
|
+
end: sourceCode.getLocFromIndex(end)
|
|
2441
|
+
}
|
|
2442
|
+
});
|
|
2443
|
+
}
|
|
2444
|
+
} };
|
|
2445
|
+
}
|
|
2446
|
+
});
|
|
2447
|
+
//#endregion
|
|
2098
2448
|
//#region src/oxc/guardrails/literal-fit.ts
|
|
2099
2449
|
const MAX_DEPTH$1 = 8;
|
|
2100
2450
|
const INDEX = /^\d+$/u;
|
|
@@ -2233,9 +2583,11 @@ const noUnsafeObjectAssignRule = defineRule({
|
|
|
2233
2583
|
},
|
|
2234
2584
|
createOnce(context) {
|
|
2235
2585
|
return { CallExpression(node) {
|
|
2236
|
-
if (callName(node.callee) !== "Object.assign" || node.arguments.length < 2
|
|
2237
|
-
const
|
|
2238
|
-
const
|
|
2586
|
+
if (callName(node.callee) !== "Object.assign" || node.arguments.length < 2) return;
|
|
2587
|
+
const linted = lintedSource(context.filename, context.sourceCode.text);
|
|
2588
|
+
const typed = linted && typedFile(context.filename, linted.text);
|
|
2589
|
+
const [start, end] = node.range;
|
|
2590
|
+
const call = linted && typed && nodeAt(typed.sourceFile, { range: [start + linted.offset, end + linted.offset] }, ts.isCallExpression);
|
|
2239
2591
|
if (typed === void 0 || call === void 0) return;
|
|
2240
2592
|
const declared = typed.checker.getTypeAtLocation(call.arguments[0]);
|
|
2241
2593
|
const target = declared.isTypeParameter() ? typed.checker.getBaseConstraintOfType(declared) ?? declared : declared;
|
|
@@ -2391,7 +2743,7 @@ const requireTsconfigTypesRule = defineRule({
|
|
|
2391
2743
|
});
|
|
2392
2744
|
//#endregion
|
|
2393
2745
|
//#region src/oxc/guardrails/index.ts
|
|
2394
|
-
/** AntelopeJS rules that reject comments, inherited-key lookups, presence-only type guards, inserts that follow a read of the same table or that a called function makes once an awaited read found nothing, unrun interface-database queries an awaited function returns, unchecked Object.assign writes, low-evidence tests, files no tsconfig lists and tsconfigs that list no `types`. */
|
|
2746
|
+
/** AntelopeJS rules that reject comments, inherited-key lookups, presence-only type guards, inserts that follow a read of the same table or that a called function makes once an awaited read found nothing, unrun interface-database queries an awaited function returns, unchecked Object.assign writes, `any` assigned, passed or returned in a Vue script, low-evidence tests, files no tsconfig lists and tsconfigs that list no `types`. */
|
|
2395
2747
|
const guardrailsPlugin = eslintCompatPlugin({
|
|
2396
2748
|
meta: { name: "antelopejs" },
|
|
2397
2749
|
rules: {
|
|
@@ -2404,6 +2756,7 @@ const guardrailsPlugin = eslintCompatPlugin({
|
|
|
2404
2756
|
"no-self-import-in-tests": noSelfImportInTestsRule,
|
|
2405
2757
|
"no-typeof-function-only-test": noTypeofFunctionOnlyTestRule,
|
|
2406
2758
|
"no-unrun-query": noUnrunQueryRule,
|
|
2759
|
+
"no-unsafe-any-in-vue": noUnsafeAnyInVueRule,
|
|
2407
2760
|
"no-unsafe-object-assign": noUnsafeObjectAssignRule,
|
|
2408
2761
|
"require-assertion": requireAssertionRule,
|
|
2409
2762
|
"require-tsconfig-include": requireTsconfigIncludeRule,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { c as object, t as child, u as optStr } from "./json-CG2L7YFl.mjs";
|
|
2
|
+
//#region src/garden/npm.ts
|
|
3
|
+
const TOOLING_PACKAGE = "@antelopejs/tooling-configs";
|
|
4
|
+
function distTags(packument) {
|
|
5
|
+
return child(object(packument, "packument"), "dist-tags");
|
|
6
|
+
}
|
|
7
|
+
function tagVersion(packument, tag) {
|
|
8
|
+
return optStr(distTags(packument), tag);
|
|
9
|
+
}
|
|
10
|
+
/** The `latest` dist-tag of tooling-configs. */
|
|
11
|
+
async function tooling(context) {
|
|
12
|
+
const packument = await context.packument(TOOLING_PACKAGE);
|
|
13
|
+
const latest = packument === void 0 ? void 0 : tagVersion(packument, "latest");
|
|
14
|
+
if (latest === void 0) throw new Error(`${TOOLING_PACKAGE} has no latest version on npm.`);
|
|
15
|
+
return latest;
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { tagVersion as n, tooling as r, TOOLING_PACKAGE as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as TEST_FILE_GLOBS, t as ASSERTION_FUNCTION_NAMES } from "../../shared-BG0Nkzh0.mjs";
|
|
2
2
|
//#region src/oxc/guardrails/index.d.ts
|
|
3
|
-
/** AntelopeJS rules that reject comments, inherited-key lookups, presence-only type guards, inserts that follow a read of the same table or that a called function makes once an awaited read found nothing, unrun interface-database queries an awaited function returns, unchecked Object.assign writes, low-evidence tests, files no tsconfig lists and tsconfigs that list no `types`. */
|
|
3
|
+
/** AntelopeJS rules that reject comments, inherited-key lookups, presence-only type guards, inserts that follow a read of the same table or that a called function makes once an awaited read found nothing, unrun interface-database queries an awaited function returns, unchecked Object.assign writes, `any` assigned, passed or returned in a Vue script, low-evidence tests, files no tsconfig lists and tsconfigs that list no `types`. */
|
|
4
4
|
declare const guardrailsPlugin: import("@oxlint/plugins").Plugin;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { ASSERTION_FUNCTION_NAMES, TEST_FILE_GLOBS, guardrailsPlugin as default };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { n as TEST_FILE_GLOBS, t as ASSERTION_FUNCTION_NAMES } from "../../shared-WC0z3y9F.mjs";
|
|
2
|
-
import { t as guardrailsPlugin } from "../../guardrails-
|
|
2
|
+
import { t as guardrailsPlugin } from "../../guardrails-6i82vsUi.mjs";
|
|
3
3
|
export { ASSERTION_FUNCTION_NAMES, TEST_FILE_GLOBS, guardrailsPlugin as default };
|
package/dist/oxc/lint.d.mts
CHANGED
|
@@ -37,8 +37,10 @@ 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
|
|
41
|
-
*
|
|
40
|
+
* oxlint-tsgolint reads only TypeScript files, so in `.vue` script blocks
|
|
41
|
+
* `antelopejs/no-unsafe-any-in-vue` runs the `typescript/no-unsafe-*`
|
|
42
|
+
* checks, and `antelopeNuxtConfig({ typeAware })` runs every type-aware rule
|
|
43
|
+
* in ESLint.
|
|
42
44
|
*/
|
|
43
45
|
typeAware?: boolean;
|
|
44
46
|
}
|
|
@@ -199,6 +201,7 @@ declare function antelopePreset(options?: AntelopePresetOptions): {
|
|
|
199
201
|
}[];
|
|
200
202
|
rules: {
|
|
201
203
|
"antelopejs/no-unrun-query": "off" | "error";
|
|
204
|
+
"antelopejs/no-unsafe-any-in-vue": "off" | "error";
|
|
202
205
|
"antelopejs/no-unsafe-object-assign": "off" | "error";
|
|
203
206
|
"antelopejs/require-tsconfig-include": "off" | "error";
|
|
204
207
|
"antelopejs/require-tsconfig-types": "off" | "error";
|
package/dist/oxc/lint.mjs
CHANGED
|
@@ -155,6 +155,7 @@ function guardrailsPreset(typeAware) {
|
|
|
155
155
|
}],
|
|
156
156
|
rules: {
|
|
157
157
|
"antelopejs/no-unrun-query": typeAware ? "error" : "off",
|
|
158
|
+
"antelopejs/no-unsafe-any-in-vue": typeAware ? "error" : "off",
|
|
158
159
|
"antelopejs/no-unsafe-object-assign": typeAware ? "error" : "off",
|
|
159
160
|
"antelopejs/require-tsconfig-include": typeAware ? "error" : "off",
|
|
160
161
|
"antelopejs/require-tsconfig-types": typeAware ? "error" : "off"
|
|
@@ -35,7 +35,11 @@ function parseReport(text) {
|
|
|
35
35
|
return report.diagnostics;
|
|
36
36
|
}
|
|
37
37
|
function toDiagnostic(item, root) {
|
|
38
|
-
|
|
38
|
+
if (item.code === void 0 || item.code === "") {
|
|
39
|
+
const where = item.filename === void 0 ? "" : `${repositoryPath(root, item.filename)}: `;
|
|
40
|
+
throw new Error(`${where}${item.message}. Fix this parser or configuration error before measuring.`);
|
|
41
|
+
}
|
|
42
|
+
const rule = ruleId(item.code);
|
|
39
43
|
if (item.filename === void 0) throw new Error(`oxlint reported ${rule} with no file: ${item.message}`);
|
|
40
44
|
const file = repositoryPath(root, item.filename);
|
|
41
45
|
const span = item.labels?.[0]?.span;
|
|
@@ -2,7 +2,7 @@ import { a as formatCeilings, c as parseCeilings, n as MAX_FILE_BYTES, o as isPa
|
|
|
2
2
|
import { n as renamedPaths, t as readCarriedCeilings } from "./renames-L2owF5GD.mjs";
|
|
3
3
|
import { f as toolingVersions } from "./package-DDG3YH7W.mjs";
|
|
4
4
|
import { n as authoredSizes, o as isAgentFile, r as changedFiles, t as LINT_CONFIG } from "./files-C-JJhExM.mjs";
|
|
5
|
-
import { n as lintDiagnostics } from "./oxlint-
|
|
5
|
+
import { n as lintDiagnostics } from "./oxlint-CIeonWMB.mjs";
|
|
6
6
|
import "./suppression-budget-CPDSFg4X.mjs";
|
|
7
7
|
import { n as sizeFailure } from "./size-CCGLY4Ke.mjs";
|
|
8
8
|
import { copyFileSync, existsSync, mkdirSync, mkdtempSync, rmSync, symlinkSync, unlinkSync, writeFileSync } from "node:fs";
|
|
@@ -22,6 +22,7 @@ const PACK_NEW_RULES = /* @__PURE__ */ new Map([
|
|
|
22
22
|
["antelopejs/no-presence-only-type-guard", "0.2.17"],
|
|
23
23
|
["antelopejs/no-read-then-insert", "0.5.1"],
|
|
24
24
|
["antelopejs/no-unrun-query", "0.6.0"],
|
|
25
|
+
["antelopejs/no-unsafe-any-in-vue", "0.7.1"],
|
|
25
26
|
["antelopejs/no-unsafe-object-assign", "0.4.2"],
|
|
26
27
|
["antelopejs/require-tsconfig-include", "0.2.18"],
|
|
27
28
|
["antelopejs/require-tsconfig-types", "0.4.2"],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antelopejs/tooling-configs",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "Shared tooling presets for AntelopeJS repositories: oxlint (with the vendored anti-slop rules), oxfmt, ESLint for Nuxt layers, Knip, and a dependency range check",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"antelopejs",
|