@antelopejs/tooling-configs 0.5.8 → 0.7.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 +39 -49
- package/dist/{api-CCOiLN3w.mjs → api-BQLrI_S1.mjs} +19 -2
- package/dist/bin/api-diff.mjs +155 -37
- package/dist/bin/body-check.mjs +6 -3
- package/dist/bin/check-size.mjs +1 -1
- package/dist/bin/checks.mjs +1 -1
- package/dist/bin/comment-proof.mjs +3 -5
- package/dist/bin/garden.mjs +86 -34
- package/dist/bin/lease.mjs +314 -26
- package/dist/bin/ratchet.mjs +4 -4
- package/dist/bin/readme-strip.mjs +1 -1
- package/dist/bin/suppressions.mjs +10 -6
- package/dist/bin/sync.mjs +23 -98
- package/dist/bin/triage.mjs +1 -1
- package/dist/bin/verify.mjs +1 -1
- package/dist/{checks-BC-F8bsv.mjs → checks-BefrkjiT.mjs} +729 -25
- package/dist/{docs-compat-Ft1r2sf0.mjs → docs-compat-CSljVi3O.mjs} +13 -8
- package/dist/eslint.d.mts +13 -4
- package/dist/eslint.mjs +48 -6
- package/dist/guardrails-BfGwehVj.mjs +2414 -0
- package/dist/installed-typescript-6MtIWlE4.mjs +84 -0
- package/dist/oxc/anti-slop/index.mjs +541 -34
- package/dist/oxc/guardrails/index.d.mts +1 -1
- package/dist/oxc/guardrails/index.mjs +2 -1854
- package/dist/oxc/lint.d.mts +10 -1
- package/dist/oxc/lint.mjs +13 -5
- package/dist/{oxlint-CCOJqj3d.mjs → oxlint-CkHhK5K_.mjs} +33 -11
- package/dist/{package-DnxZ2CXZ.mjs → package-DDG3YH7W.mjs} +10 -5
- package/dist/{ports-DGP6bPJy.mjs → ports-DAeEJsYh.mjs} +22 -0
- package/dist/{proof-stamp-lyD84zmj.mjs → proof-stamp-BFV7JTZT.mjs} +5 -4
- package/dist/{ratchet-SQ7vTR0i.mjs → ratchet-2FeMs1kh.mjs} +4 -3
- package/dist/{suppression-base-whhvw-IJ.mjs → suppression-base-CYaLZAq7.mjs} +2 -2
- package/dist/{suppression-budget-CtIYSoDO.mjs → suppression-budget-CPDSFg4X.mjs} +1 -1
- package/dist/{suppressions-C79kRvYI.mjs → suppressions-CxPnh4sC.mjs} +2 -2
- package/dist/{templates-Dg188oRC.mjs → templates-HG0fel2S.mjs} +1 -1
- package/dist/{type-aware-rules-DMuN6sHb.mjs → type-aware-rules-Da3769fI.mjs} +9 -1
- package/dist/{typescript--_8og8AM.mjs → typescript-CxfNxyr2.mjs} +59 -98
- package/dist/{workflow-CPcNc8KL.mjs → workflow-C-oBwL2H.mjs} +25 -1
- package/package.json +9 -5
- package/dist/bin/check-interface-ranges.d.mts +0 -1
- package/dist/bin/check-interface-ranges.mjs +0 -44
- package/dist/interface-ranges-CcVSr59f.mjs +0 -116
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import ts from "@typescript/typescript6";
|
|
5
|
+
//#region src/guardrails/installed-typescript.ts
|
|
6
|
+
/** The major version of the `typescript` that `directory` resolves, the compiler its own `tsc` runs; undefined when none resolves. */
|
|
7
|
+
function installedTypeScriptMajor(directory) {
|
|
8
|
+
let manifest;
|
|
9
|
+
try {
|
|
10
|
+
manifest = createRequire(join(directory, "package.json")).resolve("typescript/package.json");
|
|
11
|
+
} catch {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const { version } = JSON.parse(readFileSync(manifest, "utf8"));
|
|
15
|
+
const major = Number.parseInt(version ?? "", 10);
|
|
16
|
+
return Number.isNaN(major) ? void 0 : major;
|
|
17
|
+
}
|
|
18
|
+
/** The first `module` from which TypeScript 5 turns on `esModuleInterop` by default: `node16` through `nodenext`, and `preserve` above them. */
|
|
19
|
+
const FIRST_NODE_MODULE = ts.ModuleKind.Node16;
|
|
20
|
+
/** How TypeScript 5 resolves modules when the config sets no `moduleResolution`, by `module`. */
|
|
21
|
+
function typescript5Resolution(module) {
|
|
22
|
+
if (module === ts.ModuleKind.CommonJS) return "node10";
|
|
23
|
+
if (module === ts.ModuleKind.Preserve) return "bundler";
|
|
24
|
+
if (module === ts.ModuleKind.NodeNext) return "nodenext";
|
|
25
|
+
if (module >= FIRST_NODE_MODULE) return "node16";
|
|
26
|
+
return "classic";
|
|
27
|
+
}
|
|
28
|
+
/** The `target` TypeScript 5 defaults to for a `module`, with its tsconfig spelling: the Node module kinds imply one, every other kind gets ES5. */
|
|
29
|
+
function typescript5Target(module) {
|
|
30
|
+
if (module === ts.ModuleKind.Node16 || module === ts.ModuleKind.Node18) return {
|
|
31
|
+
kind: ts.ScriptTarget.ES2022,
|
|
32
|
+
name: "es2022"
|
|
33
|
+
};
|
|
34
|
+
if (module === ts.ModuleKind.Node20) return {
|
|
35
|
+
kind: ts.ScriptTarget.ES2023,
|
|
36
|
+
name: "es2023"
|
|
37
|
+
};
|
|
38
|
+
if (module === ts.ModuleKind.NodeNext) return {
|
|
39
|
+
kind: ts.ScriptTarget.ESNext,
|
|
40
|
+
name: "esnext"
|
|
41
|
+
};
|
|
42
|
+
return {
|
|
43
|
+
kind: ts.ScriptTarget.ES5,
|
|
44
|
+
name: "es5"
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/** The value TypeScript 5 gives each compiler option whose default TypeScript 6 changed, given the options a config sets. */
|
|
48
|
+
function typescript5Defaults(options) {
|
|
49
|
+
const defaultTarget = typescript5Target(options.module);
|
|
50
|
+
const target = options.target ?? defaultTarget.kind;
|
|
51
|
+
const module = options.module ?? (target >= ts.ScriptTarget.ES2015 ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS);
|
|
52
|
+
const moduleResolution = typescript5Resolution(module);
|
|
53
|
+
const bundler = options.moduleResolution === void 0 ? moduleResolution === "bundler" : options.moduleResolution === ts.ModuleResolutionKind.Bundler;
|
|
54
|
+
const esModuleInterop = options.esModuleInterop ?? module >= FIRST_NODE_MODULE;
|
|
55
|
+
return {
|
|
56
|
+
strict: false,
|
|
57
|
+
alwaysStrict: options.strict ?? false,
|
|
58
|
+
types: ["*"],
|
|
59
|
+
noUncheckedSideEffectImports: false,
|
|
60
|
+
target: defaultTarget.name,
|
|
61
|
+
module: module === ts.ModuleKind.CommonJS ? "commonjs" : "es2015",
|
|
62
|
+
moduleResolution,
|
|
63
|
+
esModuleInterop,
|
|
64
|
+
allowSyntheticDefaultImports: esModuleInterop || module === ts.ModuleKind.System || bundler
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/** The `compilerOptions`, as a tsconfig spells them, that make the pack's TypeScript 6 read a config as the `major` a package installs does: for TypeScript 5, its own default for each option TypeScript 6 changed and the config leaves unset, and `ignoreDeprecations: "6.0"`, so the options TypeScript 6 deprecated still compile as TypeScript 5 accepts them. Empty for TypeScript 6 and 7, which share these defaults, and for an unknown major, read as the newest. */
|
|
68
|
+
function installedCompilerDefaults(options, major) {
|
|
69
|
+
if (major === void 0 || major >= 6) return {};
|
|
70
|
+
const unset = Object.entries(typescript5Defaults(options)).filter(([key]) => options[key] === void 0);
|
|
71
|
+
return {
|
|
72
|
+
...Object.fromEntries(unset),
|
|
73
|
+
ignoreDeprecations: "6.0"
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/** Options parsed by the pack's TypeScript 6 as the `major` a package installs reads them; see `installedCompilerDefaults`. */
|
|
77
|
+
function asInstalledCompilerReads(options, major) {
|
|
78
|
+
return {
|
|
79
|
+
...options,
|
|
80
|
+
...ts.convertCompilerOptionsFromJson(installedCompilerDefaults(options, major), "").options
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
export { installedCompilerDefaults as n, installedTypeScriptMajor as r, asInstalledCompilerReads as t };
|