@antelopejs/tooling-configs 0.6.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 +15 -15
- package/dist/{api-CCOiLN3w.mjs → api-BQLrI_S1.mjs} +19 -2
- package/dist/bin/body-check.mjs +1 -1
- package/dist/bin/checks.mjs +1 -1
- package/dist/bin/garden.mjs +10 -18
- package/dist/bin/ratchet.mjs +2 -2
- package/dist/bin/suppressions.mjs +7 -3
- package/dist/bin/sync.mjs +3 -3
- package/dist/bin/triage.mjs +1 -1
- package/dist/{checks-C_I0jCN4.mjs → checks-DJ_CFEZH.mjs} +446 -23
- package/dist/eslint.mjs +1 -1
- package/dist/{guardrails-C72rFG8J.mjs → guardrails-6i82vsUi.mjs} +839 -124
- package/dist/npm-CIIqL5SG.mjs +18 -0
- package/dist/oxc/anti-slop/index.mjs +5 -4
- 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-CCOJqj3d.mjs → oxlint-CIeonWMB.mjs} +37 -11
- package/dist/{ratchet-qu2aLzQU.mjs → ratchet-DLCfeaPY.mjs} +2 -1
- package/package.json +1 -1
|
@@ -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 };
|
|
@@ -654,11 +654,11 @@ function hasKnownCallArgumentEvidence(sourceCode, expression, environment, visit
|
|
|
654
654
|
visitedVariables.add(variable);
|
|
655
655
|
return hasKnownCallArgumentEvidence(sourceCode, declarator.init, environment, visitedVariables);
|
|
656
656
|
}
|
|
657
|
-
function typePredicateSubjectIndex(sourceCode, owner) {
|
|
657
|
+
function typePredicateSubjectIndex(sourceCode, owner, parameters) {
|
|
658
658
|
const predicate = owner.returnType?.typeAnnotation;
|
|
659
659
|
if (predicate?.type !== "TSTypePredicate" || predicate.parameterName.type !== "Identifier") return null;
|
|
660
660
|
const predicateParameterName = predicate.parameterName.name;
|
|
661
|
-
const index =
|
|
661
|
+
const index = parameters.findIndex((parameter) => functionParameterBindingName(parameter, sourceCode) === predicateParameterName);
|
|
662
662
|
return index === -1 ? null : index;
|
|
663
663
|
}
|
|
664
664
|
function annotationTarget(annotation, environment) {
|
|
@@ -746,9 +746,10 @@ const noKnownValueWideningRule = defineRule({
|
|
|
746
746
|
if (environment === null) return;
|
|
747
747
|
const owner = localFunctionForCall(context.sourceCode, node.callee);
|
|
748
748
|
if (owner === null) return;
|
|
749
|
-
const
|
|
749
|
+
const parameters = argumentParameters(owner);
|
|
750
|
+
const parameterIndex = typePredicateSubjectIndex(context.sourceCode, owner, parameters);
|
|
750
751
|
if (parameterIndex === null) return;
|
|
751
|
-
const parameter =
|
|
752
|
+
const parameter = parameters[parameterIndex];
|
|
752
753
|
const argument = node.arguments[parameterIndex];
|
|
753
754
|
if (parameter === void 0 || argument === void 0 || argument.type === "SpreadElement") return;
|
|
754
755
|
const parameterAnnotation = functionParameterTypeAnnotation(parameter);
|
|
@@ -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, 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"
|
|
@@ -21,6 +21,7 @@ function ruleId(code) {
|
|
|
21
21
|
return `${plugin === "typescript-eslint" ? "typescript" : plugin}/${rule}`;
|
|
22
22
|
}
|
|
23
23
|
const NO_FILES = "No files found to lint.";
|
|
24
|
+
const PLUGIN_ERROR = "Error running JS plugin.";
|
|
24
25
|
/** Whether oxlint matched no file, in which case it prints a notice before its report and exits 1. */
|
|
25
26
|
function foundNoFiles(stdout) {
|
|
26
27
|
return stdout.startsWith(NO_FILES) && stdout.includes("{");
|
|
@@ -34,10 +35,16 @@ function parseReport(text) {
|
|
|
34
35
|
return report.diagnostics;
|
|
35
36
|
}
|
|
36
37
|
function toDiagnostic(item, root) {
|
|
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);
|
|
43
|
+
if (item.filename === void 0) throw new Error(`oxlint reported ${rule} with no file: ${item.message}`);
|
|
37
44
|
const file = repositoryPath(root, item.filename);
|
|
38
45
|
const span = item.labels?.[0]?.span;
|
|
39
46
|
return {
|
|
40
|
-
rule
|
|
47
|
+
rule,
|
|
41
48
|
file,
|
|
42
49
|
location: span ? `${file}:${span.line}:${span.column}` : file,
|
|
43
50
|
message: item.message,
|
|
@@ -75,6 +82,8 @@ function runOxlint(root, config, files, flags) {
|
|
|
75
82
|
const diagnostics = parseReport(result.stdout);
|
|
76
83
|
if (diagnostics === void 0) throw new Error(`oxlint failed (exit ${result.status}): ${result.stdout}${result.stderr}`.trimEnd());
|
|
77
84
|
if (result.status !== 0 && diagnostics.length === 0 && !foundNoFiles(result.stdout)) throw new Error(`oxlint failed without diagnostics: ${result.stderr || result.stdout}`);
|
|
85
|
+
const crash = diagnostics.find(({ code, message }) => code === void 0 && message.startsWith(PLUGIN_ERROR));
|
|
86
|
+
if (crash) throw new Error(crash.message);
|
|
78
87
|
return diagnostics;
|
|
79
88
|
} finally {
|
|
80
89
|
if (temporary) rmSync(temporary, {
|
|
@@ -90,18 +99,35 @@ function lintDiagnostics(root, config, files, { rejectBrokenProject = false } =
|
|
|
90
99
|
return diagnostics;
|
|
91
100
|
}
|
|
92
101
|
const UNUSED_RULES = /\(no problems were reported from (.+)\)/u;
|
|
102
|
+
function isUnusedDirective(message) {
|
|
103
|
+
return message.startsWith("Unused ") && message.includes("-disable directive");
|
|
104
|
+
}
|
|
93
105
|
/**
|
|
94
106
|
* The disable directives in `files` that suppress nothing, with every ratchet
|
|
95
|
-
* rule enabled as in a measurement
|
|
96
|
-
* lint the whole repository.
|
|
107
|
+
* rule enabled as in a measurement, and the files oxlint could not read.
|
|
108
|
+
* `files` must not be empty, which would lint the whole repository.
|
|
97
109
|
*/
|
|
98
|
-
function
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
110
|
+
function directiveReport(root, files) {
|
|
111
|
+
const report = {
|
|
112
|
+
unused: [],
|
|
113
|
+
unreadable: []
|
|
114
|
+
};
|
|
115
|
+
for (const item of runOxlint(root, void 0, files, ["--report-unused-disable-directives"])) {
|
|
116
|
+
if (item.code !== void 0) continue;
|
|
117
|
+
const file = item.filename === void 0 ? void 0 : repositoryPath(root, item.filename);
|
|
118
|
+
const span = item.labels?.[0]?.span;
|
|
119
|
+
if (file !== void 0 && isUnusedDirective(item.message)) report.unused.push({
|
|
120
|
+
file,
|
|
121
|
+
line: span?.line ?? 0,
|
|
122
|
+
message: item.message,
|
|
123
|
+
rules: UNUSED_RULES.exec(item.message)?.[1].split(/,\s*/u)
|
|
124
|
+
});
|
|
125
|
+
else report.unreadable.push({
|
|
126
|
+
location: file !== void 0 && span ? `${file}:${span.line}:${span.column}` : file,
|
|
127
|
+
message: item.message
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
return report;
|
|
105
131
|
}
|
|
106
132
|
//#endregion
|
|
107
|
-
export {
|
|
133
|
+
export { lintDiagnostics as n, directiveReport as t };
|
|
@@ -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 {
|
|
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.
|
|
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",
|