cachelint 0.1.1 → 0.1.2
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/dist/{check-7I5OMP2Q.js → check-DLHCKU7B.js} +3 -3
- package/dist/{chunk-V2DRU4YZ.js → chunk-FP7GIY2E.js} +1 -1
- package/dist/{chunk-WKFGRNYK.js → chunk-LFX7TG3U.js} +19 -7
- package/dist/{chunk-GLL4UN7R.js → chunk-RUWGLM2X.js} +1 -1
- package/dist/cli.js +3 -3
- package/dist/index.js +3 -3
- package/dist/{lint-2AYSH2DO.js → lint-KPVNX5DA.js} +2 -2
- package/dist/{sarif-EQ6VJNGN.js → sarif-N3Z6DPRL.js} +1 -1
- package/package.json +1 -1
|
@@ -2,13 +2,13 @@ import {
|
|
|
2
2
|
check,
|
|
3
3
|
renderCheckHuman,
|
|
4
4
|
renderCheckJson
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-RUWGLM2X.js";
|
|
6
6
|
import "./chunk-UUVSBJ62.js";
|
|
7
|
-
import "./chunk-
|
|
7
|
+
import "./chunk-FP7GIY2E.js";
|
|
8
8
|
import "./chunk-O7ZE6CFI.js";
|
|
9
9
|
import "./chunk-GXASKZ4Z.js";
|
|
10
10
|
import "./chunk-4LB5LF2P.js";
|
|
11
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-LFX7TG3U.js";
|
|
12
12
|
import "./chunk-DYQPXD3G.js";
|
|
13
13
|
import "./chunk-VWE5TDL5.js";
|
|
14
14
|
import "./chunk-SWQJHM3N.js";
|
|
@@ -256,8 +256,8 @@ function tryAst(raw) {
|
|
|
256
256
|
const callee = node["callee"];
|
|
257
257
|
if (callee && callee.type === "MemberExpression" && callee["computed"] === false && callee["object"]?.type === "Identifier" && callee["object"].name === "JSON" && callee["property"]?.type === "Identifier" && callee["property"].name === "stringify") {
|
|
258
258
|
const args = node["arguments"];
|
|
259
|
-
const
|
|
260
|
-
if (
|
|
259
|
+
const argList = Array.isArray(args) ? args : [];
|
|
260
|
+
if (argList.length < 2 || isNonSortingReplacerNode(argList[1])) {
|
|
261
261
|
const loc = node.loc?.start ?? { line: 1, column: 0 };
|
|
262
262
|
out.push({
|
|
263
263
|
line: loc.line,
|
|
@@ -273,17 +273,25 @@ function tryAst(raw) {
|
|
|
273
273
|
});
|
|
274
274
|
return out;
|
|
275
275
|
}
|
|
276
|
+
function isNonSortingReplacerNode(node) {
|
|
277
|
+
if (node.type === "Literal" && node["value"] === null) return true;
|
|
278
|
+
if (node.type === "Identifier" && node["name"] === "undefined") return true;
|
|
279
|
+
return false;
|
|
280
|
+
}
|
|
276
281
|
var CALL_RE = /\bJSON\.stringify\s*\(([^()]*)\)/g;
|
|
277
282
|
function viaRegex(raw) {
|
|
278
283
|
const out = [];
|
|
279
284
|
for (const { match, line, column, sourceLine } of matchesWithLocation(raw, CALL_RE)) {
|
|
280
|
-
const args = match[1] ?? "";
|
|
281
|
-
|
|
285
|
+
const args = splitTopLevel(match[1] ?? "");
|
|
286
|
+
const replacer = args[1]?.trim();
|
|
287
|
+
if (replacer !== void 0 && replacer !== "null" && replacer !== "undefined") continue;
|
|
282
288
|
out.push({ line, column, message: MESSAGE, fixHint: FIX_HINT, snippet: snippetOf(sourceLine) });
|
|
283
289
|
}
|
|
284
290
|
return out;
|
|
285
291
|
}
|
|
286
|
-
function
|
|
292
|
+
function splitTopLevel(s) {
|
|
293
|
+
const parts = [];
|
|
294
|
+
let start = 0;
|
|
287
295
|
let depth = 0;
|
|
288
296
|
let quote = null;
|
|
289
297
|
for (let i = 0; i < s.length; i++) {
|
|
@@ -302,9 +310,13 @@ function hasTopLevelComma(s) {
|
|
|
302
310
|
}
|
|
303
311
|
if (c === "[" || c === "{") depth++;
|
|
304
312
|
else if (c === "]" || c === "}") depth = Math.max(0, depth - 1);
|
|
305
|
-
else if (c === "," && depth === 0)
|
|
313
|
+
else if (c === "," && depth === 0) {
|
|
314
|
+
parts.push(s.slice(start, i));
|
|
315
|
+
start = i + 1;
|
|
316
|
+
}
|
|
306
317
|
}
|
|
307
|
-
|
|
318
|
+
parts.push(s.slice(start));
|
|
319
|
+
return parts;
|
|
308
320
|
}
|
|
309
321
|
|
|
310
322
|
// src/rules/R004-bom-byte.ts
|
package/dist/cli.js
CHANGED
|
@@ -42,7 +42,7 @@ program.command("lint [paths...]").description(
|
|
|
42
42
|
json: opts.json === true,
|
|
43
43
|
cost: costEnabled
|
|
44
44
|
};
|
|
45
|
-
const { lint, renderLintHuman, renderLintJson } = await import("./lint-
|
|
45
|
+
const { lint, renderLintHuman, renderLintJson } = await import("./lint-KPVNX5DA.js");
|
|
46
46
|
const result = lint({
|
|
47
47
|
paths,
|
|
48
48
|
...opts.config !== void 0 ? { config: opts.config } : {},
|
|
@@ -55,7 +55,7 @@ program.command("lint [paths...]").description(
|
|
|
55
55
|
if (opts.sarif !== void 0) {
|
|
56
56
|
const { requirePro } = await import("./gate-63NKQRXL.js");
|
|
57
57
|
requirePro("sarif", "`--sarif` output");
|
|
58
|
-
const { sarifString } = await import("./sarif-
|
|
58
|
+
const { sarifString } = await import("./sarif-N3Z6DPRL.js");
|
|
59
59
|
const { writeFileSync } = await import("fs");
|
|
60
60
|
writeFileSync(opts.sarif, sarifString(result.diagnostics));
|
|
61
61
|
console.error(`cachelint: wrote SARIF to ${opts.sarif}`);
|
|
@@ -94,7 +94,7 @@ program.command("check [paths...]").description(
|
|
|
94
94
|
json: opts.json === true,
|
|
95
95
|
cost: costEnabled
|
|
96
96
|
};
|
|
97
|
-
const { check, renderCheckHuman, renderCheckJson } = await import("./check-
|
|
97
|
+
const { check, renderCheckHuman, renderCheckJson } = await import("./check-DLHCKU7B.js");
|
|
98
98
|
const r = await check({
|
|
99
99
|
paths,
|
|
100
100
|
...opts.config !== void 0 ? { config: opts.config } : {},
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
check,
|
|
3
3
|
renderCheckHuman,
|
|
4
4
|
renderCheckJson
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-RUWGLM2X.js";
|
|
6
6
|
import {
|
|
7
7
|
activate,
|
|
8
8
|
deactivate,
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
renderLintHuman,
|
|
18
18
|
renderLintJson,
|
|
19
19
|
usdPer1kCalls
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-FP7GIY2E.js";
|
|
21
21
|
import {
|
|
22
22
|
PRICING_AS_OF,
|
|
23
23
|
PRICING_TABLE_VERSION,
|
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
allRules,
|
|
39
39
|
getRule,
|
|
40
40
|
ruleDocsUrl
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-LFX7TG3U.js";
|
|
42
42
|
import {
|
|
43
43
|
diffLockfiles,
|
|
44
44
|
isRegression
|
|
@@ -2,11 +2,11 @@ import {
|
|
|
2
2
|
lint,
|
|
3
3
|
renderLintHuman,
|
|
4
4
|
renderLintJson
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-FP7GIY2E.js";
|
|
6
6
|
import "./chunk-O7ZE6CFI.js";
|
|
7
7
|
import "./chunk-GXASKZ4Z.js";
|
|
8
8
|
import "./chunk-4LB5LF2P.js";
|
|
9
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-LFX7TG3U.js";
|
|
10
10
|
import "./chunk-VWE5TDL5.js";
|
|
11
11
|
import "./chunk-52RLK7ML.js";
|
|
12
12
|
import "./chunk-4GHSUBAY.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cachelint",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "A linter + CI gate for LLM prompt-cache regressions. Catches the silent-invalidator class (interpolated timestamps, unsorted JSON, BOM, mixed line endings) and fails PRs when a committed prompt's stable-prefix hash moves.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "cachelint contributors",
|