@antelopejs/tooling-configs 0.6.0 → 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 +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 +9 -2
- 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-BefrkjiT.mjs} +350 -10
- package/dist/eslint.mjs +1 -1
- package/dist/{guardrails-C72rFG8J.mjs → guardrails-BfGwehVj.mjs} +480 -118
- 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/{oxlint-CCOJqj3d.mjs → oxlint-CkHhK5K_.mjs} +33 -11
- package/dist/{ratchet-qu2aLzQU.mjs → ratchet-2FeMs1kh.mjs} +1 -1
- package/package.json +1 -1
|
@@ -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, 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-BfGwehVj.mjs";
|
|
3
3
|
export { ASSERTION_FUNCTION_NAMES, TEST_FILE_GLOBS, guardrailsPlugin as default };
|
|
@@ -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,12 @@ function parseReport(text) {
|
|
|
34
35
|
return report.diagnostics;
|
|
35
36
|
}
|
|
36
37
|
function toDiagnostic(item, root) {
|
|
38
|
+
const rule = ruleId(item.code ?? "");
|
|
39
|
+
if (item.filename === void 0) throw new Error(`oxlint reported ${rule} with no file: ${item.message}`);
|
|
37
40
|
const file = repositoryPath(root, item.filename);
|
|
38
41
|
const span = item.labels?.[0]?.span;
|
|
39
42
|
return {
|
|
40
|
-
rule
|
|
43
|
+
rule,
|
|
41
44
|
file,
|
|
42
45
|
location: span ? `${file}:${span.line}:${span.column}` : file,
|
|
43
46
|
message: item.message,
|
|
@@ -75,6 +78,8 @@ function runOxlint(root, config, files, flags) {
|
|
|
75
78
|
const diagnostics = parseReport(result.stdout);
|
|
76
79
|
if (diagnostics === void 0) throw new Error(`oxlint failed (exit ${result.status}): ${result.stdout}${result.stderr}`.trimEnd());
|
|
77
80
|
if (result.status !== 0 && diagnostics.length === 0 && !foundNoFiles(result.stdout)) throw new Error(`oxlint failed without diagnostics: ${result.stderr || result.stdout}`);
|
|
81
|
+
const crash = diagnostics.find(({ code, message }) => code === void 0 && message.startsWith(PLUGIN_ERROR));
|
|
82
|
+
if (crash) throw new Error(crash.message);
|
|
78
83
|
return diagnostics;
|
|
79
84
|
} finally {
|
|
80
85
|
if (temporary) rmSync(temporary, {
|
|
@@ -90,18 +95,35 @@ function lintDiagnostics(root, config, files, { rejectBrokenProject = false } =
|
|
|
90
95
|
return diagnostics;
|
|
91
96
|
}
|
|
92
97
|
const UNUSED_RULES = /\(no problems were reported from (.+)\)/u;
|
|
98
|
+
function isUnusedDirective(message) {
|
|
99
|
+
return message.startsWith("Unused ") && message.includes("-disable directive");
|
|
100
|
+
}
|
|
93
101
|
/**
|
|
94
102
|
* The disable directives in `files` that suppress nothing, with every ratchet
|
|
95
|
-
* rule enabled as in a measurement
|
|
96
|
-
* lint the whole repository.
|
|
103
|
+
* rule enabled as in a measurement, and the files oxlint could not read.
|
|
104
|
+
* `files` must not be empty, which would lint the whole repository.
|
|
97
105
|
*/
|
|
98
|
-
function
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
106
|
+
function directiveReport(root, files) {
|
|
107
|
+
const report = {
|
|
108
|
+
unused: [],
|
|
109
|
+
unreadable: []
|
|
110
|
+
};
|
|
111
|
+
for (const item of runOxlint(root, void 0, files, ["--report-unused-disable-directives"])) {
|
|
112
|
+
if (item.code !== void 0) continue;
|
|
113
|
+
const file = item.filename === void 0 ? void 0 : repositoryPath(root, item.filename);
|
|
114
|
+
const span = item.labels?.[0]?.span;
|
|
115
|
+
if (file !== void 0 && isUnusedDirective(item.message)) report.unused.push({
|
|
116
|
+
file,
|
|
117
|
+
line: span?.line ?? 0,
|
|
118
|
+
message: item.message,
|
|
119
|
+
rules: UNUSED_RULES.exec(item.message)?.[1].split(/,\s*/u)
|
|
120
|
+
});
|
|
121
|
+
else report.unreadable.push({
|
|
122
|
+
location: file !== void 0 && span ? `${file}:${span.line}:${span.column}` : file,
|
|
123
|
+
message: item.message
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
return report;
|
|
105
127
|
}
|
|
106
128
|
//#endregion
|
|
107
|
-
export {
|
|
129
|
+
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-CkHhK5K_.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";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antelopejs/tooling-configs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
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",
|