cachelint 0.1.0 → 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-2ONJCYKP.js → check-DLHCKU7B.js} +5 -5
- package/dist/{chunk-MW7BXKPR.js → chunk-52RLK7ML.js} +8 -1
- package/dist/{chunk-SQ4IAMTX.js → chunk-ANH5DBRG.js} +2 -2
- package/dist/{chunk-2JSY5BQA.js → chunk-FP7GIY2E.js} +2 -2
- package/dist/{chunk-WKFGRNYK.js → chunk-LFX7TG3U.js} +19 -7
- package/dist/{chunk-ZSEZQ422.js → chunk-RUWGLM2X.js} +3 -3
- package/dist/{chunk-BUZCVKMZ.js → chunk-SWQJHM3N.js} +1 -1
- package/dist/cli.js +4 -4
- package/dist/{hash-XUTGK6SB.js → hash-VALCF7B4.js} +3 -3
- package/dist/index.js +6 -6
- package/dist/{lint-PQHIDWOY.js → lint-KPVNX5DA.js} +3 -3
- package/dist/{sarif-EQ6VJNGN.js → sarif-N3Z6DPRL.js} +1 -1
- package/package.json +1 -1
|
@@ -2,17 +2,17 @@ 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
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
14
|
+
import "./chunk-SWQJHM3N.js";
|
|
15
|
+
import "./chunk-52RLK7ML.js";
|
|
16
16
|
import "./chunk-4GHSUBAY.js";
|
|
17
17
|
import "./chunk-WPJYUQMU.js";
|
|
18
18
|
import "./chunk-XKRPGMZT.js";
|
|
@@ -343,7 +343,7 @@ var SECRET_FILE_PATTERNS = [
|
|
|
343
343
|
];
|
|
344
344
|
function resolveSources(input) {
|
|
345
345
|
const root = input.projectRoot ?? process.cwd();
|
|
346
|
-
const absRoot = pathResolve2(root);
|
|
346
|
+
const absRoot = realpathOrSelf(pathResolve2(root));
|
|
347
347
|
const maxFileBytes = input.maxFileBytes ?? DEFAULT_MAX_FILE_BYTES;
|
|
348
348
|
const maxTotalBytes = input.maxTotalBytes ?? DEFAULT_MAX_TOTAL_BYTES;
|
|
349
349
|
const extraExclude = input.exclude ?? [];
|
|
@@ -485,6 +485,13 @@ function resolveSources(input) {
|
|
|
485
485
|
}
|
|
486
486
|
return { sources, warnings };
|
|
487
487
|
}
|
|
488
|
+
function realpathOrSelf(p) {
|
|
489
|
+
try {
|
|
490
|
+
return realpathSync(p);
|
|
491
|
+
} catch {
|
|
492
|
+
return p;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
488
495
|
function expandPaths(paths, absRoot) {
|
|
489
496
|
const all = /* @__PURE__ */ new Set();
|
|
490
497
|
for (const p of paths) {
|
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
computeBundles,
|
|
4
4
|
makeLockfile,
|
|
5
5
|
writeLockfileAtomic
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-SWQJHM3N.js";
|
|
7
7
|
import {
|
|
8
8
|
resolveConfigArg,
|
|
9
9
|
toPosixRelative
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-52RLK7ML.js";
|
|
11
11
|
import {
|
|
12
12
|
CACHELINT_VERSION
|
|
13
13
|
} from "./chunk-WPJYUQMU.js";
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from "./chunk-GXASKZ4Z.js";
|
|
11
11
|
import {
|
|
12
12
|
runRules
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-LFX7TG3U.js";
|
|
14
14
|
import {
|
|
15
15
|
COST_LINE_OVERLAPPED,
|
|
16
16
|
costLabel,
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
resolveConfigArg,
|
|
25
25
|
resolveSources,
|
|
26
26
|
toPosixRelative
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-52RLK7ML.js";
|
|
28
28
|
import {
|
|
29
29
|
DEFAULT_RULE_VOLATILITY,
|
|
30
30
|
isRuleId
|
|
@@ -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
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
heuristicTokens,
|
|
8
8
|
lint,
|
|
9
9
|
usdPer1kCalls
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-FP7GIY2E.js";
|
|
11
11
|
import {
|
|
12
12
|
getModelPricing,
|
|
13
13
|
referencePricing
|
|
@@ -36,12 +36,12 @@ import {
|
|
|
36
36
|
computeBundles,
|
|
37
37
|
makeLockfile,
|
|
38
38
|
readLockfileIfExists
|
|
39
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-SWQJHM3N.js";
|
|
40
40
|
import {
|
|
41
41
|
resolveConfigArg,
|
|
42
42
|
resolveSources,
|
|
43
43
|
toPosixRelative
|
|
44
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-52RLK7ML.js";
|
|
45
45
|
import {
|
|
46
46
|
CACHELINT_VERSION
|
|
47
47
|
} from "./chunk-WPJYUQMU.js";
|
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}`);
|
|
@@ -70,7 +70,7 @@ program.command("lint [paths...]").description(
|
|
|
70
70
|
if (result.exitCode !== EXIT_OK) process.exitCode = result.exitCode;
|
|
71
71
|
});
|
|
72
72
|
program.command("hash [paths...]").description("Compute and write cachelint.lock for declared bundles").option("-c, --config <file>", "Path to cachelint.config.{json,yaml,yml}").option("-o, --out <file>", "Output lockfile path (default: cachelint.lock)").option("--json", "Emit the written bundles as JSON on stdout").action(async (paths, opts) => {
|
|
73
|
-
const { hash, renderHashHuman, renderHashJson } = await import("./hash-
|
|
73
|
+
const { hash, renderHashHuman, renderHashJson } = await import("./hash-VALCF7B4.js");
|
|
74
74
|
const r = hash({
|
|
75
75
|
paths,
|
|
76
76
|
...opts.config !== void 0 ? { config: opts.config } : {},
|
|
@@ -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 } : {},
|
|
@@ -2,9 +2,9 @@ import {
|
|
|
2
2
|
hash,
|
|
3
3
|
renderHashHuman,
|
|
4
4
|
renderHashJson
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-ANH5DBRG.js";
|
|
6
|
+
import "./chunk-SWQJHM3N.js";
|
|
7
|
+
import "./chunk-52RLK7ML.js";
|
|
8
8
|
import "./chunk-4GHSUBAY.js";
|
|
9
9
|
import "./chunk-WPJYUQMU.js";
|
|
10
10
|
import "./chunk-XKRPGMZT.js";
|
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
|
|
@@ -63,14 +63,14 @@ import {
|
|
|
63
63
|
hash,
|
|
64
64
|
renderHashHuman,
|
|
65
65
|
renderHashJson
|
|
66
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-ANH5DBRG.js";
|
|
67
67
|
import {
|
|
68
68
|
DEFAULT_LOCKFILE_NAME,
|
|
69
69
|
LOCKFILE_FORMAT_VERSION,
|
|
70
70
|
canonicalJsonStringify,
|
|
71
71
|
parseLockfile,
|
|
72
72
|
serializeLockfile
|
|
73
|
-
} from "./chunk-
|
|
73
|
+
} from "./chunk-SWQJHM3N.js";
|
|
74
74
|
import {
|
|
75
75
|
CONFIG_FILENAMES,
|
|
76
76
|
configJsonSchema,
|
|
@@ -79,7 +79,7 @@ import {
|
|
|
79
79
|
loadConfig,
|
|
80
80
|
parseConfig,
|
|
81
81
|
resolveConfigArg
|
|
82
|
-
} from "./chunk-
|
|
82
|
+
} from "./chunk-52RLK7ML.js";
|
|
83
83
|
import {
|
|
84
84
|
DEFAULT_RULE_SEVERITY,
|
|
85
85
|
DEFAULT_RULE_VOLATILITY,
|
|
@@ -2,13 +2,13 @@ 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
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-52RLK7ML.js";
|
|
12
12
|
import "./chunk-4GHSUBAY.js";
|
|
13
13
|
import "./chunk-WPJYUQMU.js";
|
|
14
14
|
import "./chunk-XKRPGMZT.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",
|