@heyramzi/lint 2.12.0 → 2.14.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 +7 -3
- package/data/slop/patterns/subject-voice.js +2 -1
- package/package.json +1 -1
- package/register.js +3 -1
- package/repo-rules/blueprints.js +98 -0
- package/repo-rules/mock-response.js +22 -0
- package/repo-rules/npx.js +48 -0
- package/repo-rules.js +6 -0
package/README.md
CHANGED
|
@@ -298,7 +298,9 @@ failure says what to do instead. It reads the staged blob, so it judges what the
|
|
|
298
298
|
- **Import maps:** a published `@heyramzi/*` package with `#src` imports maps `"#src/*.js"` to
|
|
299
299
|
`./src/*.ts` when it ships src, or `"#src/*"` to `{ types, default }` when it ships dist.
|
|
300
300
|
- **Credentials:** an `_authToken` line in a committed `.npmrc`, and the dead
|
|
301
|
-
`GITHUB_PRIVATE_PACKAGES_TOKEN` name in an install file.
|
|
301
|
+
`GITHUB_PRIVATE_PACKAGES_TOKEN` name in an install file. A Make blueprint (a JSON file with a
|
|
302
|
+
`flow`) fails on a literal in a header or field named like a secret, key, token, password or
|
|
303
|
+
client id, or inside a body or query string. A `{{mapping}}` or `<PLACEHOLDER>` passes.
|
|
302
304
|
- **Workflows:** a hosted runner, a write to `~/.npmrc`, a `pull_request` trigger, and any Node
|
|
303
305
|
that isn't 24.
|
|
304
306
|
- **Toolchain:** ESLint, knip, Prettier, Biome and Husky (dependency, script or config file),
|
|
@@ -319,8 +321,10 @@ No allowlist, no config.
|
|
|
319
321
|
`heyramzi-slop <file|dir|->` runs the exact patterns, and `--register=<name>` adds the rates of a
|
|
320
322
|
voice. By default each check reports its first hit per file, which settles pass or fail. `--all`
|
|
321
323
|
lists every hit of every check with its line (`line` in `--json`), and the exit code doesn't
|
|
322
|
-
change. A refused push prints that command with this checkout's path: inside a repo, `npx
|
|
323
|
-
heyramzi-slop` runs the repo's installed copy, which can be older than the gate's.
|
|
324
|
+
change. A refused push prints that command with this checkout's path: inside a repo, `npx -y -p
|
|
325
|
+
@heyramzi/lint heyramzi-slop` runs the repo's installed copy, which can be older than the gate's.
|
|
326
|
+
Always name the package with `-p`: the bare npm name `heyramzi-slop` is only a placeholder that prints this command and exits 1, and the
|
|
327
|
+
`npx-bare-bin` repo rule refuses a file that calls it.
|
|
324
328
|
|
|
325
329
|
`--jev` also asks TypeSafe Jev (`jev.js`) to score each sentence and paragraph against the
|
|
326
330
|
humanizer shapes. Those scores are a report unless `--shape-block=<0.6-1>` names a bar. Jev reads
|
|
@@ -78,7 +78,8 @@ export const patternsSubjectVoice = [
|
|
|
78
78
|
name: "Every scenario is named by its trigger",
|
|
79
79
|
// His rule, not a bot tell: 55 of 267 human replies on the Reddit bench use one, against 7 of our 72 bad ones (9 Nov 2026).
|
|
80
80
|
// A state word passes unless "by" names who did it: "Hive is not connected", "what's broken", "when we're done" (15 of upsys's 78, 10 Nov 2026).
|
|
81
|
-
|
|
81
|
+
// So does "you're" or "we're": the person is the subject, nobody's hidden ("what you're paid for", a human r/ClaudeCode comment, 15 Nov 2026).
|
|
82
|
+
test: /\b(?:is|are|was|were|be|been|being|['’]s|['’]re)\s+(?:not\s+|never\s+|already\s+|also\s+|still\s+|just\s+|then\s+|\w+ly\s+)?(?!(?:interested|based|related|supposed|used\s+to|tired|bored|excited|worried|scared|married|located|involved|impressed|devastated|surprised|confused|annoyed|pleased|stuck|qualified|indeed|need|feed|seed|speed|breed|greed|weed)\b|(?:closed|locked|unlocked|connected|disconnected|archived|enabled|disabled|un[a-z]{2,}ed)\b(?!\s+by\b)|broken\b(?!\s+(?:by|into|down|up|out|off)\b)|caught\s+up\b|done\b(?=\s*(?:[.!?,;:)]|$)))(?:[a-z]{3,}ed|built|made|done|given|taken|known|seen|written|shown|sent|kept|put|found|held|told|paid|brought|bought|caught|taught|chosen|driven|forgotten|hidden|broken|spoken|stolen|frozen|drawn|grown|thrown|worn|torn)\b(?:(?<!\b(?:you|we)['’]re\s+(?:\w+\s+)?\w+)|(?=\s+by\b))/i,
|
|
82
83
|
rule: 'A passive: "is named", "was built", "are treated". Nobody does anything in it, so it reads as a report, not a person talking. Name who does it: "we name every scenario by its trigger". Ramzi, 9 Nov 2026, on a Reddit draft: "anything passive tense basically is bad, bad, bad".',
|
|
83
84
|
example:
|
|
84
85
|
'"Every scenario we build is named by its trigger" / "anything that comes through chat is treated as an emergency" / "the report was sent on Monday"',
|
package/package.json
CHANGED
package/register.js
CHANGED
|
@@ -125,7 +125,9 @@ const AI_SIGNALS = {
|
|
|
125
125
|
// 49% of ours, 14% of theirs.
|
|
126
126
|
"no I, hedge or question": (m) => m.speakerMarks === 0,
|
|
127
127
|
// Our median 12.3 words a sentence, theirs 17.
|
|
128
|
-
|
|
128
|
+
// Even is a spread under 0.45, between the bench medians (ours 0.40, theirs 0.51), read from 8 sentences up like the lengthVariation band.
|
|
129
|
+
"short even sentences": (m) =>
|
|
130
|
+
m.meanSentence < 14 && (m.sentences < 8 || m.lengthVariation < 0.45),
|
|
129
131
|
// 35% of ours, 14% of theirs.
|
|
130
132
|
"orders the reader": (m) => m.sentences >= 3 && m.commandShare > 0,
|
|
131
133
|
// The 21 Oct paragraph rule overshot: 3 or more paragraphs under 30 words each.
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/** Literal credentials in a committed Make blueprint. */
|
|
2
|
+
|
|
3
|
+
// WHY client id: a Royal Mail export held X-IBM-Client-Id beside its secret, and the pair is the login.
|
|
4
|
+
const SECRET_NAME =
|
|
5
|
+
/secret|token|passw(or)?d|api[-_]?key|apikey|authorization|client[-_]?id|auth[-_]?id|private[-_]?key|access[-_]?key/i;
|
|
6
|
+
// WHY: Make's sha256(text; encoding; key) is an HMAC, and an Unleashed export typed its live key there.
|
|
7
|
+
const SIGNING_CALL = /\b(sha\d+|md5|hmac|base64)\(/gi;
|
|
8
|
+
const QUOTED_TOKEN = /"([A-Za-z0-9+/=_.~-]{20,})"/g;
|
|
9
|
+
const INLINE_FIELD =
|
|
10
|
+
"(password|passwd|secret|client[_-]?secret|api[_-]?key|apikey|access[_-]?token)";
|
|
11
|
+
const INLINE = [
|
|
12
|
+
new RegExp(`<${INLINE_FIELD}>\\s*([^<\\s][^<]*)</`, "i"),
|
|
13
|
+
new RegExp(`"${INLINE_FIELD}"\\s*:\\s*"([^"]+)"`, "i"),
|
|
14
|
+
new RegExp(`[?&]${INLINE_FIELD}=([^&\\s"]+)`, "i"),
|
|
15
|
+
/\b(bearer|basic)\s+([A-Za-z0-9._~+/=-]{16,})/i,
|
|
16
|
+
];
|
|
17
|
+
const PLACEHOLDER = /^<[A-Z][A-Z0-9_]*>$/;
|
|
18
|
+
|
|
19
|
+
/** A value a person typed, as opposed to a Make mapping or a <PLACEHOLDER>. */
|
|
20
|
+
function isLiteral(value) {
|
|
21
|
+
const trimmed = value.trim();
|
|
22
|
+
return trimmed.length >= 8 && !trimmed.includes("{{") && !PLACEHOLDER.test(trimmed);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** The text between a call's opening parenthesis and the one that closes it. */
|
|
26
|
+
function argumentsFrom(value, start) {
|
|
27
|
+
let depth = 1;
|
|
28
|
+
for (let at = start; at < value.length; at++) {
|
|
29
|
+
if (value[at] === "(") depth++;
|
|
30
|
+
if (value[at] === ")" && --depth === 0) return value.slice(start, at);
|
|
31
|
+
}
|
|
32
|
+
return value.slice(start);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** A key-shaped quoted literal inside a hashing or encoding call of a Make formula. */
|
|
36
|
+
function hasSigningKey(value) {
|
|
37
|
+
return [...value.matchAll(SIGNING_CALL)].some((call) =>
|
|
38
|
+
[...argumentsFrom(value, call.index + call[0].length).matchAll(QUOTED_TOKEN)].some(
|
|
39
|
+
([, token]) => /\d/.test(token) && /[A-Za-z]/.test(token),
|
|
40
|
+
),
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** The scenario object in an export, a `blueprint` wrapper or an API response, or null. */
|
|
45
|
+
function scenarioOf(json) {
|
|
46
|
+
for (const candidate of [json, json?.blueprint, json?.response?.blueprint]) {
|
|
47
|
+
if (candidate && Array.isArray(candidate.flow)) return candidate;
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Every literal credential under node, as a JSON path and the field it sits in. */
|
|
53
|
+
function literals(node, trail, found) {
|
|
54
|
+
if (Array.isArray(node)) {
|
|
55
|
+
node.forEach((child, index) => literals(child, `${trail}[${index}]`, found));
|
|
56
|
+
return found;
|
|
57
|
+
}
|
|
58
|
+
if (node === null || typeof node !== "object") return found;
|
|
59
|
+
const name = typeof node.name === "string" ? node.name : node.key;
|
|
60
|
+
const pairLeaks =
|
|
61
|
+
typeof name === "string" &&
|
|
62
|
+
typeof node.value === "string" &&
|
|
63
|
+
SECRET_NAME.test(name) &&
|
|
64
|
+
isLiteral(node.value);
|
|
65
|
+
if (pairLeaks) found.push({ trail, field: name });
|
|
66
|
+
for (const [key, child] of Object.entries(node)) {
|
|
67
|
+
// WHY: samples are a run's output (mail DKIM headers), while designer orphans are full modules.
|
|
68
|
+
if (key === "samples" || (pairLeaks && key === "value")) continue;
|
|
69
|
+
const at = `${trail}.${key}`;
|
|
70
|
+
if (typeof child === "string") {
|
|
71
|
+
if (SECRET_NAME.test(key) && isLiteral(child)) found.push({ trail: at, field: key });
|
|
72
|
+
if (hasSigningKey(child)) found.push({ trail: at, field: name ?? key });
|
|
73
|
+
for (const pattern of INLINE) {
|
|
74
|
+
const match = pattern.exec(child);
|
|
75
|
+
if (match && isLiteral(match[2])) found.push({ trail: at, field: match[1] });
|
|
76
|
+
}
|
|
77
|
+
} else {
|
|
78
|
+
literals(child, at, found);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return found;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function blueprintSecrets(tree) {
|
|
85
|
+
const found = [];
|
|
86
|
+
for (const file of tree.touchedMatching(/\.json$/)) {
|
|
87
|
+
const scenario = scenarioOf(tree.json(file));
|
|
88
|
+
if (!scenario) continue;
|
|
89
|
+
for (const { trail, field } of literals(scenario, "blueprint", [])) {
|
|
90
|
+
found.push({
|
|
91
|
+
file,
|
|
92
|
+
rule: "blueprint-secret",
|
|
93
|
+
message: `${trail} holds a literal ${field}. A committed blueprint keeps no credential: put a placeholder such as <${field.replace(/[^A-Za-z0-9]+/g, "_").toUpperCase()}> there, or map it from a Make connection or variable. The key was written down, so have its owner rotate it.`,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return found;
|
|
98
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** A fetch mock that hands every call one Response: its body reads once, so the second call throws "Body is unusable" (Seam, 15 Nov 2026). */
|
|
2
|
+
|
|
3
|
+
const TEST = /\.(test|spec)\.[cm]?[jt]sx?$/;
|
|
4
|
+
const SHARED = /mockResolvedValue\(\s*new Response\(/g;
|
|
5
|
+
|
|
6
|
+
export function sharedMockResponses(tree) {
|
|
7
|
+
const found = [];
|
|
8
|
+
for (const file of tree.touched) {
|
|
9
|
+
if (!TEST.test(file)) continue;
|
|
10
|
+
const text = tree.text(file);
|
|
11
|
+
if (!text) continue;
|
|
12
|
+
for (const match of text.matchAll(SHARED)) {
|
|
13
|
+
const line = text.slice(0, match.index).split("\n").length;
|
|
14
|
+
found.push({
|
|
15
|
+
file,
|
|
16
|
+
rule: "shared-mock-response",
|
|
17
|
+
message: `line ${line} gives every call the same Response, and a body reads once, so a second fetch throws "Body is unusable". Write \`mockImplementation(async () => new Response(...))\` for a fresh one per call, or \`mockResolvedValueOnce\` when exactly one call is expected.`,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return found;
|
|
22
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/** A registry runner (npx, dlx, bunx) fetching a bare `heyramzi-*` name, never the linter on npm (`heyramzi-slop` is a placeholder). */
|
|
2
|
+
|
|
3
|
+
const RUNNER = /(?<![\w-])(?:npx|pnpx|bunx|(?:pnpm|yarn)\s+dlx|npm\s+exec)(?![\w-])/g;
|
|
4
|
+
const BARE = /^heyramzi-[\w.-]+(@\S*)?$/;
|
|
5
|
+
const BINARY =
|
|
6
|
+
/\.(png|jpe?g|gif|webp|avif|heic|ico|icns|psd|pdf|zip|gz|tgz|mp3|mp4|m4a|mov|wav|webm|woff2?|ttf|otf|sqlite|db|wasm|bin|car)$/i;
|
|
7
|
+
const EDGE = /^[`'"([{,;]+|[`'")\]},;:.]+$/g;
|
|
8
|
+
|
|
9
|
+
/** The package a runner fetches: the `-p` value when there is one, else the command it runs. */
|
|
10
|
+
function fetched(words) {
|
|
11
|
+
const packages = [];
|
|
12
|
+
for (let index = 0; index < words.length; index += 1) {
|
|
13
|
+
const word = words[index].replace(EDGE, "");
|
|
14
|
+
if (word === "-p" || word === "--package") {
|
|
15
|
+
packages.push(words[index + 1]?.replace(EDGE, "") ?? "");
|
|
16
|
+
index += 1;
|
|
17
|
+
} else if (/^(-p|--package)=/.test(word)) {
|
|
18
|
+
packages.push(word.slice(word.indexOf("=") + 1));
|
|
19
|
+
} else if (word === "" || word === "--" || word.startsWith("-")) {
|
|
20
|
+
continue;
|
|
21
|
+
} else {
|
|
22
|
+
return packages.length ? packages : [word];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return packages;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function npxBareBins(tree) {
|
|
29
|
+
const found = [];
|
|
30
|
+
for (const file of tree.touched) {
|
|
31
|
+
if (BINARY.test(file)) continue;
|
|
32
|
+
const text = tree.text(file);
|
|
33
|
+
if (text.includes("\0")) continue;
|
|
34
|
+
for (const match of text.matchAll(RUNNER)) {
|
|
35
|
+
const after = text.slice(match.index + match[0].length, match.index + match[0].length + 240);
|
|
36
|
+
const name = fetched(after.trim().split(/\s+/).slice(0, 8)).find((word) => BARE.test(word));
|
|
37
|
+
if (!name) continue;
|
|
38
|
+
const line = text.slice(0, match.index).split("\n").length;
|
|
39
|
+
const bin = name.replace(/@.*$/, "");
|
|
40
|
+
found.push({
|
|
41
|
+
file,
|
|
42
|
+
rule: "npx-bare-bin",
|
|
43
|
+
message: `line ${line} has ${match[0]} fetch the bare npm name ${bin}, which isn't the linter: heyramzi-slop is a placeholder that exits 1, and an unregistered name runs whoever claims it on every machine that follows the line. The bin ships in @heyramzi/lint: write \`npx -y -p @heyramzi/lint ${bin}\`.`,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return found;
|
|
48
|
+
}
|
package/repo-rules.js
CHANGED
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
* to live in Markdown. Pure here, git and process in `bin/heyramzi-repo-rules.js`.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import { blueprintSecrets } from "#lint/repo-rules/blueprints.js";
|
|
6
7
|
import { untrackedImports } from "#lint/repo-rules/imports.js";
|
|
8
|
+
import { sharedMockResponses } from "#lint/repo-rules/mock-response.js";
|
|
9
|
+
import { npxBareBins } from "#lint/repo-rules/npx.js";
|
|
7
10
|
import { composeImages, fossilNames } from "#lint/repo-rules/paths.js";
|
|
8
11
|
import {
|
|
9
12
|
heyramziLinks,
|
|
@@ -38,6 +41,9 @@ export const RULES = [
|
|
|
38
41
|
composeImages,
|
|
39
42
|
fossilNames,
|
|
40
43
|
untrackedImports,
|
|
44
|
+
blueprintSecrets,
|
|
45
|
+
npxBareBins,
|
|
46
|
+
sharedMockResponses,
|
|
41
47
|
];
|
|
42
48
|
|
|
43
49
|
/** Every violation in the files the tree says were touched. */
|