@heyramzi/lint 2.8.0 → 2.11.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.
@@ -43,6 +43,13 @@
43
43
  * `--jev` adds model-scored shapes. They are a report, never a failure: one sentence scored 0.71, then 0.78.
44
44
  */
45
45
 
46
+ /*
47
+ * A repo adds its own bans without touching this package: `--patterns=<module>`, or `"slop": { "patterns": ["<module>"] }`
48
+ * in the nearest package.json above the linted file. Each module default-exports `{ id, test, rule }` entries, and a
49
+ * hit fails as kind `repo-pattern`. Locameuble needed the accounting-monopoly phrasings, which are law for one product and
50
+ * noise for every other repo, so they live there (TSK-2087, 10 Nov 2026).
51
+ */
52
+
46
53
  /*
47
54
  * `--shape-block=0.85` makes a shape at that score or above fail the run. Scores are cached per sentence.
48
55
  */
@@ -56,7 +63,8 @@
56
63
  */
57
64
 
58
65
  import { readdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
59
- import { join } from "node:path";
66
+ import { dirname, join, resolve } from "node:path";
67
+ import { pathToFileURL } from "node:url";
60
68
  import { shapes } from "#lint/data/slop-words.js";
61
69
  import { patterns } from "#lint/data/slop/patterns.js";
62
70
  import { titleTells } from "#lint/data/slop/title-tells.js";
@@ -91,7 +99,7 @@ function expand(path) {
91
99
  .toSorted();
92
100
  }
93
101
 
94
- function gate(file, register) {
102
+ function gate(file, register, repoPatterns) {
95
103
  const raw = file === "-" ? readFileSync(0, "utf8") : readFileSync(file, "utf8");
96
104
  // HTML gets its tags stripped before anything is matched, so an email body audits the same way a post does.
97
105
 
@@ -104,7 +112,45 @@ function gate(file, register) {
104
112
  const text = /\.mdx?$/i.test(file) ? proseOfMarkdown(raw) : raw;
105
113
  // Read from the raw file, because `proseOfMarkdown` blanks the frontmatter that carries `lang`.
106
114
  const language = declaredLanguage(raw, file);
107
- return { raw, result: slopGate(text, { markup, code, register, language }) };
115
+ const result = slopGate(text, { markup, code, register, language });
116
+ // Read on the cleaned text, so a ban split by a tag or an invisible character still matches.
117
+ for (const p of repoPatterns) {
118
+ const m = result.text.match(p.test);
119
+ if (m) result.findings.push({ kind: "repo-pattern", id: p.id, detail: m[0].slice(0, 90) });
120
+ }
121
+ result.ok = result.findings.length === 0;
122
+ return { raw, result };
123
+ }
124
+
125
+ /** The module paths for one file: the flag wins, else the nearest package.json above it with a `slop.patterns` key. */
126
+ function repoPatternPaths(file, flag) {
127
+ if (flag) return [resolve(flag)];
128
+ for (let dir = file === "-" ? process.cwd() : dirname(resolve(file)); ; dir = dirname(dir)) {
129
+ try {
130
+ const declared = JSON.parse(readFileSync(join(dir, "package.json"), "utf8")).slop?.patterns;
131
+ if (declared) return [declared].flat().map((p) => resolve(dir, p));
132
+ } catch {
133
+ // No package.json here, or not JSON: keep climbing.
134
+ }
135
+ if (dirname(dir) === dir) return [];
136
+ }
137
+ }
138
+
139
+ const loadedModules = new Map();
140
+ async function loadRepoPatterns(file, flag) {
141
+ const loaded = [];
142
+ for (const p of repoPatternPaths(file, flag)) {
143
+ if (!loadedModules.has(p)) {
144
+ const list = (await import(pathToFileURL(p).href)).default;
145
+ if (!Array.isArray(list) || !list.every((e) => e?.id && e.test instanceof RegExp)) {
146
+ process.stderr.write(`${p} must default-export an array of { id, test: RegExp }\n`);
147
+ process.exit(2);
148
+ }
149
+ loadedModules.set(p, list);
150
+ }
151
+ loaded.push(...loadedModules.get(p));
152
+ }
153
+ return loaded;
108
154
  }
109
155
 
110
156
  /**
@@ -195,7 +241,7 @@ const paths = args.filter((a) => !a.startsWith("--"));
195
241
 
196
242
  if (paths.length === 0) {
197
243
  process.stderr.write(
198
- "usage: heyramzi-slop <file|dir|-> [more...] [--fix] [--json] [--jev [--shape-block=0.6-1]] [--quiet] [--register=spoken|shorts|written|forum [--thread=post.md]] [--only=kind|id,...]\n",
244
+ "usage: heyramzi-slop <file|dir|-> [more...] [--fix] [--json] [--jev [--shape-block=0.6-1]] [--quiet] [--register=spoken|shorts|written|forum [--thread=post.md]] [--only=kind|id,...] [--patterns=module.mjs]\n",
199
245
  );
200
246
  process.exit(2);
201
247
  }
@@ -247,6 +293,13 @@ if (blockFlag) {
247
293
  }
248
294
  }
249
295
 
296
+ const patternsFlag = args.find((a) => a.startsWith("--patterns"));
297
+ if (patternsFlag && !patternsFlag.includes("=")) {
298
+ process.stderr.write("--patterns takes a module: --patterns=scripts/slop-patterns.mjs\n");
299
+ process.exit(2);
300
+ }
301
+ const patternsPath = patternsFlag?.split("=").slice(1).join("=");
302
+
250
303
  const files = paths.flatMap(expand);
251
304
  const results = [];
252
305
  /** Looked up once, on the first file that needs Jev. */
@@ -255,7 +308,7 @@ let jevKey;
255
308
  let jevDown = "";
256
309
 
257
310
  for (const file of files) {
258
- const { raw, result } = gate(file, register);
311
+ const { raw, result } = gate(file, register, await loadRepoPatterns(file, patternsPath));
259
312
  if (only) {
260
313
  result.findings = result.findings.filter((f) => only.has(f.kind) || only.has(f.id));
261
314
  result.review = [];
@@ -64,4 +64,23 @@ export const patternsSubjectVoice = [
64
64
  example:
65
65
  '"The best automation you own is the one that complains" / "The best client is the one who says no"',
66
66
  },
67
+ {
68
+ id: "the-one-doing",
69
+ name: "You're the one doing updates",
70
+ // 0 of 267 human replies on data/reddit-bench.json, 9 Nov 2026. The lookahead keeps "the one thing" and "the one meeting" out.
71
+ test: /\b(?:is|are|was|were|['’](?:re|s|m))\s+(?:always\s+|usually\s+|still\s+|then\s+)?the\s+ones?\s+(?:who(?:['’]s|\s+(?:is|are|was|were))\s+)?(?:\w+ly\s+)?(?!(?:thing|things|nothing|something|everything|string|king|ring|spring|building|setting|meeting|listing|wing|ending|morning|evening)\b)[a-z]+ing\b/i,
72
+ rule: 'A person or thing cast as "the one" plus an -ing verb: you\'re the one doing updates, it\'s the one having the problem. It sounds like a sentence and isn\'t one anybody says. Give the subject the verb: "you do the updates", "it has the problem". Ramzi, 9 Nov 2026, on a lint-clean Reddit draft: "the grammar is weird".',
73
+ example:
74
+ '"self-hosting means you\'re the one doing updates" / "it\'s the one having the problem" / "you\'re the one who\'s paying for it"',
75
+ },
76
+ {
77
+ id: "passive-voice",
78
+ name: "Every scenario is named by its trigger",
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
+ // 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
+ 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/i,
82
+ 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
+ example:
84
+ '"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"',
85
+ },
67
86
  ];
@@ -11,6 +11,34 @@ export const patternsVagueAndFlourish = [
11
11
  example:
12
12
  '"A quote to sign before anything exists." / "You commit before anything is built." / "They bill you when nothing has happened."',
13
13
  },
14
+ {
15
+ id: "your-way",
16
+ name: "Your way",
17
+ // Ramzi caught "Your ClickUp data, laid out your way" as a newsletter subject the gate passed (TSK-2000, 9 Nov 2026).
18
+
19
+ // Bounded to a shaping verb in front, so "on your way" and "find your way" pass.
20
+ test: /\b(?:laid out|set up|built|made|organi[sz]ed|arranged|tailored|customi[sz]ed|shaped|designed|done|works?|fits?|working)\s+(?:(?:exactly|just)\s+)?(?:your way|the way you (?:work|think|want|like)|how you (?:work|think|want))\b/i,
21
+ rule: "A tailored-to-you promise that fits any product and names nothing. The reader can't picture what changed. Say what the thing does: which view, which columns, what it saves them.",
22
+ example: '"Your ClickUp data, laid out your way" / "a dashboard that works the way you work"',
23
+ },
24
+ {
25
+ id: "grading-their-choice",
26
+ name: "That makes sense",
27
+ // Ramzi, 9 Nov 2026 (TSK-2130). Only a verdict that ends the sentence, so "it only makes sense if" passes.
28
+ test: /\bmakes?\s+(?:(?:total|perfect|complete|a\s+lot\s+of|so\s+much|good)\s+)?sense(?=\s*[.!]|\s*$)|\b(?:smart|good|great|wise|right)\s+(?:move|call|idea|plan|choice)(?=\s*[.!,])|\b(?:totally|completely|very)\s+(?:understandable|fair)\b|\bc'est\s+(?:tout\s+à\s+fait\s+)?(?:logique|compréhensible)\b/i,
29
+ rule: "A line that grades the other person's decision. They didn't ask for your approval, so it reads as filler validation from a bot. Cut the sentence; the reply works without it. Ramzi, 9 Nov 2026, on a client reply: \"sounds like this stupid validation, the evaluator should have cut it.\"",
30
+ example:
31
+ '"Getting your internal onboarding in place first makes sense." / "Totally understandable." / "Smart move." / "Good call, let\'s wait."',
32
+ },
33
+ {
34
+ id: "unnamed-fix",
35
+ name: "Unnamed fix",
36
+ // Ramzi caught "Step 4: fix the prompt part that's missing" on a Claude Start slide the gate passed (TSK-2028, 7 Nov 2026).
37
+ test: /\bfix\s+(?:what(?:(?:'|’)s|\s+is)|whatever(?:(?:'|’)s|\s+is)|the\s+(?:[a-z]+\s+){0,2}(?:part|bit|thing|piece|one)s?\s+that(?:(?:'|’)s|\s+is|\s+are))\s+(?:wrong|missing|off|broken)\b/i,
38
+ rule: "An instruction to fix something it never names. The reader has to work out what is wrong before they can act. Name the fix itself: check every price in offer.md, ask for it shorter, tell it what to forget.",
39
+ example:
40
+ '"Step 4: fix the prompt part that\'s missing" / "Open offer.md and fix what\'s wrong" / "Read the view and fix what is missing."',
41
+ },
14
42
  {
15
43
  id: "recap-opener",
16
44
  name: "Recap opener",
@@ -99,6 +99,10 @@ export const phrasesEnWikipedia = [
99
99
  "i am sorry, but",
100
100
  "you're absolutely right",
101
101
  "you are absolutely right",
102
+ // The same agreement opener without the adverb: "You're right that supplier data from
103
+ // China is where importers get stuck" passed as a 0.80 shape in a LinkedIn DM (Ramzi, 10 Nov 2026).
104
+ "you're right that",
105
+ "you are right that",
102
106
  "great question",
103
107
  "would you like me to",
104
108
  "let me know if you",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heyramzi/lint",
3
- "version": "2.8.0",
3
+ "version": "2.11.1",
4
4
  "description": "Shared oxlint rules, base config and gates for Studio projects",
5
5
  "license": "MIT",
6
6
  "repository": {
package/register.js CHANGED
@@ -291,7 +291,8 @@ REGISTERS.forum = {
291
291
  // The exact-pattern kinds that still count. Every other kind refused 68 of the 157 humans.
292
292
 
293
293
  // `pattern:comma-and-you-can` is one pattern, not its kind: 0 of 265 humans, and Ramzi caught it in a Reddit draft on 5 Nov 2026.
294
- exact: ["dash", "pattern:comma-and-you-can"],
294
+ // `the-one-doing` and `passive-voice` are Ramzi's, 9 Nov 2026, on lint-clean Reddit drafts.
295
+ exact: ["dash", "pattern:comma-and-you-can", "pattern:the-one-doing", "pattern:passive-voice"],
295
296
  };
296
297
 
297
298
  const DIRECTION = {