@heyramzi/lint 2.6.1 → 2.8.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 +6 -2
- package/bin/heyramzi-push-diff.js +7 -1
- package/bin/heyramzi-slop.js +9 -2
- package/config/oxlintrc.json +1 -0
- package/data/jev-shapes.js +121 -0
- package/data/slop/patterns/comma-clauses.js +18 -1
- package/data/slop/patterns/headings-and-laws.js +3 -0
- package/data/slop/patterns.js +4 -0
- package/data/slop/phrases-en-core.js +7 -0
- package/index.js +2 -0
- package/jev-core.js +15 -117
- package/package.json +2 -1
- package/register.d.ts +7 -1
- package/register.js +9 -1
- package/rules/no-navigation-in-effect.js +114 -0
- package/slop-language.js +112 -0
- package/slop-views.js +27 -1
- package/slop.d.ts +13 -5
- package/slop.js +39 -84
package/README.md
CHANGED
|
@@ -34,6 +34,7 @@ deleted on 14 Sep 2026.
|
|
|
34
34
|
| `no-em-dash` | Error. Em and en dashes in comments, strings, template text and Svelte text. A spaced hyphen (` - `) fails there too, except where it isn't a dash: a string whose whole value is one em or en dash (an empty-value placeholder), a string or template that is code judged on content (SQL keywords like `SELECT … FROM` or `WHERE`, CSS `calc(` or `var(--`, GLSL `gl_` or `vec2`, JS `function x(`, `=>` or `const x =`), a markdown bullet at the start of a template line or comment line, `<style>`, and `sql`/`css`/`gql`/`html`/`raw` templates. Test and fixture files (`*.test.*`, `*.spec.*`, `__fixtures__/`, `fixtures/`) pass a spaced hyphen because their strings are inputs under test. A real em or en dash fails everywhere except a bare placeholder and a tagged template. |
|
|
35
35
|
| `no-svelte4-syntax` | Error. `export let` and `$:` in a `.svelte` file. Svelte 4 markup is the markup gate's job. |
|
|
36
36
|
| `no-app-stores` | Error. An import from `$app/stores`; read `page` from `$app/state`. |
|
|
37
|
+
| `no-navigation-in-effect` | Error. A shallow `goto`, `pushState` or `replaceState` in an `$effect` that tracks `page.state`, or `invalidate*` in one that tracks `page.data`. The call writes what the effect reads and it reruns forever: getwavenote.com/download?auto fired 13 DMGs and hung (TSK-1648). Read it in `untrack()` or move it to `onMount`. |
|
|
37
38
|
| `no-rune-outside-svelte-file` | Error. A rune in a file Svelte doesn't compile, which throws `rune_outside_svelte` at runtime. Rename it `.svelte.ts`. |
|
|
38
39
|
| `no-rune-shadowing-binding` | Error. A top-level binding named `state`, `derived`, `effect`… in a file that calls that rune, which throws `store_invalid_shape`. |
|
|
39
40
|
| `props-interface` | Error, with `--fix`. `type Props = {...}` in a component; write `interface Props`. A union, conditional or mapped type stays a type. |
|
|
@@ -329,9 +330,12 @@ Reddit bench below, because the humanizer checks refused 151 of 157 human replie
|
|
|
329
330
|
of 25 words or more. `aiSignalNames(text)` lists them.
|
|
330
331
|
- **Menu paths**: a written-out "System Settings > Keyboard > Text Replacements" fails.
|
|
331
332
|
- **Ramzi's two rules**: no em or en dash, and no single block over 95 words.
|
|
333
|
+
- **One exact pattern**: `comma-and-you-can` (", and you can still go custom when a big one shows
|
|
334
|
+
up"). `REGISTERS.forum.exact` names it as `pattern:comma-and-you-can`, so the rest of its kind
|
|
335
|
+
stays off. A caller filtering findings itself uses `keepsExact(register, finding)`.
|
|
332
336
|
- **Jev** asks whole-reply questions in place of the sentence shapes, and refuses at 0.75:
|
|
333
|
-
`FORUM_SHAPES` always, and `FORUM_THREAD_SHAPES` (a looked-up tool the post never mentioned
|
|
334
|
-
|
|
337
|
+
`FORUM_SHAPES` always, and `FORUM_THREAD_SHAPES` (a looked-up tool the post never mentioned)
|
|
338
|
+
when `--thread=<post.md>` passes the post's title and body. The forum
|
|
335
339
|
register always asks Jev, and when Jev can't answer the reply fails with `jev unscored`. A reply
|
|
336
340
|
under 25 words asks Jev nothing.
|
|
337
341
|
|
|
@@ -15,9 +15,15 @@ import { changedStorageValues, hasStorageKeys, report } from "#lint/push-diff.js
|
|
|
15
15
|
const repoRoot = execFileSync("git", ["rev-parse", "--show-toplevel"], { encoding: "utf8" }).trim();
|
|
16
16
|
const git = (args) =>
|
|
17
17
|
execFileSync("git", args, { cwd: repoRoot, encoding: "utf8", maxBuffer: 512 * 1024 * 1024 });
|
|
18
|
+
// Quiet stderr: on a detached HEAD, `merge-base HEAD @{u}` prints a fatal line before the fallback works.
|
|
18
19
|
const tryGit = (args) => {
|
|
19
20
|
try {
|
|
20
|
-
return git
|
|
21
|
+
return execFileSync("git", args, {
|
|
22
|
+
cwd: repoRoot,
|
|
23
|
+
encoding: "utf8",
|
|
24
|
+
maxBuffer: 512 * 1024 * 1024,
|
|
25
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
26
|
+
});
|
|
21
27
|
} catch {
|
|
22
28
|
return "";
|
|
23
29
|
}
|
package/bin/heyramzi-slop.js
CHANGED
|
@@ -48,7 +48,11 @@
|
|
|
48
48
|
*/
|
|
49
49
|
|
|
50
50
|
/*
|
|
51
|
-
* With the model unreachable the exact patterns still run, stderr says the model check didn't, and the exit code is theirs.
|
|
51
|
+
* With the model unreachable the exact patterns still run, stderr says the model check didn't, and the exit code is theirs.
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
/*
|
|
55
|
+
* `--register=forum` is the exception: it always asks Jev and fails when Jev can't answer.
|
|
52
56
|
*/
|
|
53
57
|
|
|
54
58
|
import { readdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
@@ -58,6 +62,7 @@ import { patterns } from "#lint/data/slop/patterns.js";
|
|
|
58
62
|
import { titleTells } from "#lint/data/slop/title-tells.js";
|
|
59
63
|
import { FAIL, REVIEW, isUnavailable, proseOf } from "#lint/jev-core.js";
|
|
60
64
|
import { auditShapes, jevKey as readJevKey } from "#lint/jev.js";
|
|
65
|
+
import { declaredLanguage } from "#lint/slop-language.js";
|
|
61
66
|
import { slopGate } from "#lint/slop.js";
|
|
62
67
|
|
|
63
68
|
// =========================
|
|
@@ -97,7 +102,9 @@ function gate(file, register) {
|
|
|
97
102
|
const code = /\.(m?[jt]sx?|json)$/i.test(file);
|
|
98
103
|
if (/\.board\.json$/i.test(file)) return { raw, result: gateBoard(raw, register) };
|
|
99
104
|
const text = /\.mdx?$/i.test(file) ? proseOfMarkdown(raw) : raw;
|
|
100
|
-
|
|
105
|
+
// Read from the raw file, because `proseOfMarkdown` blanks the frontmatter that carries `lang`.
|
|
106
|
+
const language = declaredLanguage(raw, file);
|
|
107
|
+
return { raw, result: slopGate(text, { markup, code, register, language }) };
|
|
101
108
|
}
|
|
102
109
|
|
|
103
110
|
/**
|
package/config/oxlintrc.json
CHANGED
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"@heyramzi/lint/no-hardcoded-models": "error",
|
|
48
48
|
"@heyramzi/lint/no-redundant-prop-fallback": "error",
|
|
49
49
|
"@heyramzi/lint/no-app-stores": "error",
|
|
50
|
+
"@heyramzi/lint/no-navigation-in-effect": "error",
|
|
50
51
|
"@heyramzi/lint/no-rune-outside-svelte-file": "error",
|
|
51
52
|
"@heyramzi/lint/no-rune-shadowing-binding": "error",
|
|
52
53
|
"@heyramzi/lint/no-svelte4-syntax": "error",
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Jev questions, one per root cause, with no import: `jev-core.js` asks them and re-exports them.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/** One question per root cause, not per pattern: humanizer references/patterns.md maps each pattern to one. */
|
|
6
|
+
export const q = (instructions, yes, no) => ({
|
|
7
|
+
type: "noul",
|
|
8
|
+
instructions,
|
|
9
|
+
criteria: { true: yes, false: no },
|
|
10
|
+
});
|
|
11
|
+
const PLAIN =
|
|
12
|
+
"A plain, literal sentence: a step the reader takes, a named thing, a number, or a fact that carries its own meaning.";
|
|
13
|
+
|
|
14
|
+
/** Asked of every sentence, with its paragraph as `context`. */
|
|
15
|
+
export const SHAPES = {
|
|
16
|
+
inflated: q(
|
|
17
|
+
"Does `sentence` tell the reader that something matters, impresses or feels a certain way, instead of giving the fact, number or mechanism that would show it, or is it generic enough to move unchanged to another company, product or person?",
|
|
18
|
+
"Praise, significance, emotion or quality asserted, not shown, or a line with nothing only this subject could say.",
|
|
19
|
+
`${PLAIN} Or a letter's courtesy to its reader: a thanks, a greeting, an invitation.`,
|
|
20
|
+
),
|
|
21
|
+
aphorism: q(
|
|
22
|
+
"Is `sentence` a slogan or maxim: a quotable general truth stated in abstract terms instead of a concrete step, number or fact?",
|
|
23
|
+
"Could be printed on a poster, often a flip or an 'only', and the next sentence has to explain it.",
|
|
24
|
+
PLAIN,
|
|
25
|
+
),
|
|
26
|
+
law: q(
|
|
27
|
+
"Does `sentence` describe how a tool, setting or system behaves as a general rule, with the thing as the subject and no person acting, where it could tell the reader what to do and what they will see?",
|
|
28
|
+
"The subject is an object or an idea, the verb is a state or a spread, and the reader has no step to copy. Often it ends on 'it' or 'them'.",
|
|
29
|
+
"A person does something, a literal step (where to click, what appears), a measured result of what happened, with its number, or a plain fact or rule about one specific thing said the way a person would ('the back door doesn't lock', 'a cancelled ticket is never refunded').",
|
|
30
|
+
),
|
|
31
|
+
vague: q(
|
|
32
|
+
"Does `sentence` point at content instead of stating it: it announces, promises, sets up or labels a point that the sentence itself does not give?",
|
|
33
|
+
"A teaser, signpost or label: the reader learns that there is a reason, a tip, a rule or a next step, but not what it is.",
|
|
34
|
+
"The sentence gives the content itself, the paragraph gives it right after, or it starts with 'Link:' and names what the reader does when they click.",
|
|
35
|
+
),
|
|
36
|
+
hedge: q(
|
|
37
|
+
"Does `sentence` pad itself with a hedge, a reassurance, a propping adverb (really, basically, actually), an unnamed source, or a line about the conversation instead of the subject?",
|
|
38
|
+
"It contains padding of that kind, or talks about the writing instead of the subject.",
|
|
39
|
+
"No hedge, prop or talk about the conversation. A thanks, a greeting or a question to the reader is not padding.",
|
|
40
|
+
),
|
|
41
|
+
filler: q(
|
|
42
|
+
"Can one word or phrase in `sentence` be deleted, or swapped for a shorter one, and the sentence still say exactly the same thing?",
|
|
43
|
+
"At least one word can go or shrink ('in order to', 'each and every', a word the rest already implies) with no loss of meaning.",
|
|
44
|
+
"Every word carries meaning the sentence would lose. Warmth to the reader in a letter counts as meaning.",
|
|
45
|
+
),
|
|
46
|
+
contrast: q(
|
|
47
|
+
"Does `sentence` stage a contrast to make its point: 'not X, it's Y' denying a claim nobody made, an either-or where one side is a strawman, a 'from X to Y' span with no real range, or one claim said twice in other words?",
|
|
48
|
+
"The denied half, the strawman side, the span or the repeat is there for effect. Delete it and the point stands alone.",
|
|
49
|
+
"A real comparison between two named options, or a single plain claim.",
|
|
50
|
+
),
|
|
51
|
+
stilted: q(
|
|
52
|
+
"Does `sentence` sound awkward or unnatural, like a clumsy translation or a forced rewrite, so a native English speaker would phrase it differently or need to reread it?",
|
|
53
|
+
"Awkward phrasing: a person made the subject of find, meet or get where people would say 'there is' or 'X has'; an odd verb; an unexplained code or label; a clumsy word order.",
|
|
54
|
+
"Natural, clear English a person would say out loud.",
|
|
55
|
+
),
|
|
56
|
+
pitch: q(
|
|
57
|
+
"Is `sentence` an ad line that promises an effortless result: a dramatic command plus an outcome said to be already true, or a lone word used as a verdict, instead of saying what happens when the reader takes an action?",
|
|
58
|
+
"Reads like a tagline: 'Do X, and Y is already done', or a one-word fragment as the punchline.",
|
|
59
|
+
`${PLAIN} Or a literal step with what happens next, in the product's own terms.`,
|
|
60
|
+
),
|
|
61
|
+
personified: q(
|
|
62
|
+
"Does `sentence` use a figure where a literal word exists: a non-human thing doing what only a person does, or an abstract idea dressed as a physical object?",
|
|
63
|
+
"A tool that knows, wants, saves or gives; an idea that is a lever, a ceiling, a moat or a muscle.",
|
|
64
|
+
"The thing does something mechanical and literal, or a person does the acting.",
|
|
65
|
+
),
|
|
66
|
+
thingdoer: q(
|
|
67
|
+
"Does `sentence` make a tool, automation, checklist, script or system the grammatical subject of what a person sets up or does, where a person as the subject ('we', 'you', or an imperative) would be plainer?",
|
|
68
|
+
"A noun leads and acts: 'An automation creates it and assigns it', 'A checklist catches this', 'The script only posts what is approved'. It reads like a description of a machine, with nobody behind it. Ramzi, 30 Sep 2026.",
|
|
69
|
+
"A person is the subject or the sentence is an instruction ('Have an automation create it'), or the thing genuinely is the subject of a literal fact ('The API returns JSON').",
|
|
70
|
+
),
|
|
71
|
+
stagey: q(
|
|
72
|
+
"Does `sentence` describe an action or a rule as a small scene where a plain verb and object would do: 'waits for someone to say go' for 'needs your approval', 'gets you most of the way' for 'covers most of it', 'does its sweep' for 'runs'?",
|
|
73
|
+
"A phrase that acts out the idea (waits, says go, gets you there, takes the wheel) when one plain verb says the same thing. Ramzi, 30 Sep 2026: 'Claude Code on a timer requires you' is simpler and means the same.",
|
|
74
|
+
"The sentence already uses the plain verb and object a person would say out loud.",
|
|
75
|
+
),
|
|
76
|
+
reassurance: q(
|
|
77
|
+
"Does `sentence` vouch for what the reader is shown (a demo, screenshot, photo, number, review or the text itself) when nothing in the text doubted it: insist it is real, genuine, untouched, or the product's or the writer's own, or deny it is fake, staged, mocked up, written by AI, sponsored, cherry-picked or padded?",
|
|
78
|
+
"An unasked claim of authenticity or honesty with no proof beside it. A demo that shows the product, a photo that shows the dish and a review nobody paid for are what any reader already assumes, so saying so only fends off a doubt, and raising the doubt is what plants it. Ramzi, 2 Nov 2026.",
|
|
79
|
+
"A plain fact about the thing or what it does, a disclosure of who the writer is or what they were given ('I'm the developer', 'they sent me a free unit'), or an answer to a doubt someone in the text raised.",
|
|
80
|
+
),
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/** Asked once per paragraph of 3 or more sentences: the shapes no single sentence shows. */
|
|
84
|
+
export const PARAGRAPH_SHAPES = {
|
|
85
|
+
rhythm: q(
|
|
86
|
+
"Does `paragraph` repeat one structure instead of varying it: sentences of one length or one opening, items forced into threes, a punchy closer on every beat, a word reused where no new idea arrived, or a transition that asserts a link the facts do not show?",
|
|
87
|
+
"A reader could predict the shape of the next sentence before reading it.",
|
|
88
|
+
"Sentence lengths and openings vary with the thought, and each link between sentences is shown by what they say.",
|
|
89
|
+
),
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Asked once of a whole forum reply, in place of SHAPES and PARAGRAPH_SHAPES: those refused 151 of
|
|
94
|
+
* 157 human Reddit replies (scripts/reddit-bench.mjs, 2 Nov 2026). Of 10 whole-reply questions tried,
|
|
95
|
+
* this one alone refused a bad comment at FAIL without refusing a human. The rest live in TECHLOG.md.
|
|
96
|
+
*/
|
|
97
|
+
export const FORUM_SHAPES = {
|
|
98
|
+
tutorial: q(
|
|
99
|
+
"`reply` is a comment on a Reddit thread. Does it read as a complete tutorial or help-article answer: the whole procedure laid out step by step from start to finish, each step an instruction, rather than what one person typed from their own experience?",
|
|
100
|
+
"A tidy walkthrough: select this, then open that, pick this, then hit that. Every step covered in order, like documentation or a support bot.",
|
|
101
|
+
"A person talking: a partial answer, a pointer, an opinion, a story about what they did, a question back, or one tip with their reason.",
|
|
102
|
+
),
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Asked of a forum reply beside its thread's title and body, only when the caller passes the thread.
|
|
107
|
+
* Ramzi, 2 Nov 2026, on an Espanso reply that passed 2.6.0: "Who the fuck knows about this app?"
|
|
108
|
+
* At 0.7 it refused 2 more of his 6 flagged replies and 2 of 265 humans; 4 other wordings
|
|
109
|
+
* cost 6 to 26 humans for the same catch (TECHLOG.md). By 5 Nov the same code at 0.7 refused 13
|
|
110
|
+
* humans, and every flagged reply it caught was caught by another check, so its bar is 0.75.
|
|
111
|
+
*/
|
|
112
|
+
export const FORUM_THREAD_SHAPES = {
|
|
113
|
+
lookedup: {
|
|
114
|
+
...q(
|
|
115
|
+
"`reply` answers the Reddit post in `thread`. Does `reply` recommend a specific tool, feature or setting that `thread` never mentions, described with looked-up precision (its exact name, where it lives, how it behaves), while nothing shows the writer has used it themselves?",
|
|
116
|
+
"A researched pointer: names an app, feature or setting the poster never raised, says exactly where it is or what it does, and the writer's own use of it is nowhere in the reply.",
|
|
117
|
+
"The writer works with what the poster named, or says they use the thing ('I use', 'we switched to', 'mine does'), or the names are loose and from memory.",
|
|
118
|
+
),
|
|
119
|
+
bar: 0.75,
|
|
120
|
+
},
|
|
121
|
+
};
|
|
@@ -15,6 +15,23 @@ export const patternsCommaClauses = [
|
|
|
15
15
|
example:
|
|
16
16
|
'"Yes, and the honest answer is that a full reconcile is not available." / "No, but the reason matters more than the number." / "Honestly, and this is the part nobody says, it never worked."',
|
|
17
17
|
},
|
|
18
|
+
{
|
|
19
|
+
id: "comma-and-you-can",
|
|
20
|
+
// A finished clause, then a comma plus "and you can/'ll/will still|always", or "and you can X" plus a deferred "once/after/when" clause.
|
|
21
|
+
|
|
22
|
+
// The modal is required and an obligation ("and you still need a separate app") stays out, because that is a cost, not a reassurance.
|
|
23
|
+
|
|
24
|
+
// The deferred form takes a lowercase conjunction plus a subject and no comma between, so "at once", "After Effects", "later" and a relative clause pass.
|
|
25
|
+
|
|
26
|
+
// A bare ", and you can use local models" is a human's bonus option on the Reddit bench (o4sodph), so the plain form is never matched.
|
|
27
|
+
|
|
28
|
+
// Swept over ~/Studio on 5 Nov 2026: 0 of 265 human bench replies, and the "always" hits left were speech transcripts.
|
|
29
|
+
test: /,\s+and\s+you(?:'ll|’ll|\s+will|\s+can)\s+(?:still|always)\s+(?!(?:need|needs|must)\b|ha(?:ve|s)\s+to\b)[a-z]|,\s+and\s+you\s+can\s+(?!not\b)[a-z]+\b[^.!?\n,]{0,60}?(?<!\bat\s)\b(?:once|after|when|whenever)\s+(?:it|the|they|you|that|this|a|an|things?|everything)\b/,
|
|
30
|
+
name: "Comma-and-you-can tail",
|
|
31
|
+
rule: 'A sentence that already answered, then a comma plus "and you can still", "and you\'ll still" or "and you can always" bolting on a reassurance or a spare option, or "and you can X once Y" deferring a bonus step. The tail heads off a worry nobody raised and closes the reply too neatly. Ramzi, 5 Nov 2026, on a lint-clean Reddit draft: "is AI slop and should have been caught". Cut the tail, or give the option its own sentence with the reason a reader would want it.',
|
|
32
|
+
example:
|
|
33
|
+
'"If they are, 2 or 3 packages would cover most of them, and you can still go custom when a big one shows up." / "Pick the cheaper plan, and you\'ll still have room to upgrade." / "A run that errors waits there with its data, and you can resume it after the fix."',
|
|
34
|
+
},
|
|
18
35
|
{
|
|
19
36
|
id: "comma-and-title",
|
|
20
37
|
name: "The rest of the site, and what each part is for",
|
|
@@ -107,7 +124,7 @@ export const patternsCommaClauses = [
|
|
|
107
124
|
id: "advisory-aside",
|
|
108
125
|
// The announcement, not the advice. Closed set of openers, each one a fixed phrase nobody writes by accident.
|
|
109
126
|
|
|
110
|
-
// "one thing I'd/I'll/I would" added 14 Sep 2026, Ramzi: "this sentence is pure AI slop 'One thing I'd revisit'"
|
|
127
|
+
// "one thing I'd/I'll/I would" added 14 Sep 2026, Ramzi: "this sentence is pure AI slop 'One thing I'd revisit'". It's the same self-assigned-critique announcement as "one thing worth",
|
|
111
128
|
|
|
112
129
|
// one pronoun over.
|
|
113
130
|
test: /\b(?:one thing worth|a quick note before|worth flagging|one last thing that|a small tip before|one thing (?:i'd|i'll|i would|i will))\b/i,
|
|
@@ -11,6 +11,8 @@ export const patternsHeadingsAndLaws = [
|
|
|
11
11
|
|
|
12
12
|
// not in the outline.
|
|
13
13
|
view: "faqless",
|
|
14
|
+
// The `?` is the whole signature, so it reads the same in German as in English.
|
|
15
|
+
anyLanguage: true,
|
|
14
16
|
test: /^#{1,6}\s+[^\n?]{5,90}\?\s*$/m,
|
|
15
17
|
rule: "A section heading written as a question the writer then answers. It buys a beat of suspense the reader did not ask for and it makes the outline unscannable. Name the answer in the heading.",
|
|
16
18
|
example: '"## Why does this matter?" / "## Qu\'est-ce que le pilotage ?"',
|
|
@@ -21,6 +23,7 @@ export const patternsHeadingsAndLaws = [
|
|
|
21
23
|
// WP:AILIST. A bullet or a number, a bold run, then a colon, on either side of the closing stars because a chatbot writes it both ways.
|
|
22
24
|
|
|
23
25
|
// The colon is required: a list of bold link labels with no colon is ordinary markdown.
|
|
26
|
+
anyLanguage: true,
|
|
24
27
|
test: /^[ \t]*(?:[-*+•–—]|\d+[.)])\s+\*\*[^*\n]{2,60}(?:[::]\*\*|\*\*\s*[::])/m,
|
|
25
28
|
rule: "The bullet, bold label, colon, sentence shape a chatbot renders by default. It turns prose into a specification nobody asked for and the bold adds no emphasis because every line has it. Write the paragraph, or drop the bold and the colon.",
|
|
26
29
|
example:
|
package/data/slop/patterns.js
CHANGED
|
@@ -44,6 +44,10 @@ import { patternsDiagramAndScriptTells } from "#lint/data/slop/patterns/diagram-
|
|
|
44
44
|
/*
|
|
45
45
|
* `view` is optional and names which reading of the draft the regex judges: the whole draft by default, or `faqless` for the one check an FAQ is allowed to fail.
|
|
46
46
|
*/
|
|
47
|
+
|
|
48
|
+
/*
|
|
49
|
+
* `anyLanguage` is optional. A pattern runs only on English and French drafts, the languages its words are written in, unless it reads markdown shape alone and says so here.
|
|
50
|
+
*/
|
|
47
51
|
export const patterns = [
|
|
48
52
|
...patternsSubjectVoice,
|
|
49
53
|
...patternsRevealsAndTallies,
|
|
@@ -178,6 +178,13 @@ export const phrasesEnCore = [
|
|
|
178
178
|
// It is his tutorial register pointing at a screen, not reader guidance. patterns.md 48 carries it as a written-copy read.
|
|
179
179
|
"the key point is",
|
|
180
180
|
"this distinction matters",
|
|
181
|
+
// blader/humanizer 3.1.0 §2: the closer that grades a point, and the line that names what an example already showed.
|
|
182
|
+
|
|
183
|
+
// Zero hits for the last three across ~/Studio on 5 Nov 2026; "that distinction matters" hit 2 AI-drafted pages.
|
|
184
|
+
"that distinction matters",
|
|
185
|
+
"this shows the importance of",
|
|
186
|
+
"the message was clear",
|
|
187
|
+
"it was a lesson in",
|
|
181
188
|
"nobody tells you",
|
|
182
189
|
"the part everyone misses",
|
|
183
190
|
"most people get wrong",
|
package/index.js
CHANGED
|
@@ -41,6 +41,7 @@ import svelteSectionOrder from "#lint/rules/svelte-section-order.js";
|
|
|
41
41
|
|
|
42
42
|
// Svelte and SvelteKit house rules
|
|
43
43
|
import noAppStores from "#lint/rules/no-app-stores.js";
|
|
44
|
+
import noNavigationInEffect from "#lint/rules/no-navigation-in-effect.js";
|
|
44
45
|
import noRuneOutsideSvelteFile from "#lint/rules/no-rune-outside-svelte-file.js";
|
|
45
46
|
import noRuneShadowingBinding from "#lint/rules/no-rune-shadowing-binding.js";
|
|
46
47
|
import noSkippedOrFocusedTests from "#lint/rules/no-skipped-or-focused-tests.js";
|
|
@@ -100,6 +101,7 @@ export default {
|
|
|
100
101
|
|
|
101
102
|
// Svelte and SvelteKit
|
|
102
103
|
"no-app-stores": noAppStores,
|
|
104
|
+
"no-navigation-in-effect": noNavigationInEffect,
|
|
103
105
|
"no-rune-outside-svelte-file": noRuneOutsideSvelteFile,
|
|
104
106
|
"no-rune-shadowing-binding": noRuneShadowingBinding,
|
|
105
107
|
"no-skipped-or-focused-tests": noSkippedOrFocusedTests,
|
package/jev-core.js
CHANGED
|
@@ -5,6 +5,21 @@
|
|
|
5
5
|
/*
|
|
6
6
|
* The caller brings `post`: `{ state, questions }` in, Jev's `answers` out. jev.js is the Node one.
|
|
7
7
|
*/
|
|
8
|
+
import {
|
|
9
|
+
FORUM_SHAPES,
|
|
10
|
+
FORUM_THREAD_SHAPES,
|
|
11
|
+
PARAGRAPH_SHAPES,
|
|
12
|
+
SHAPES,
|
|
13
|
+
} from "#lint/data/jev-shapes.js";
|
|
14
|
+
|
|
15
|
+
// The questions live in data/jev-shapes.js; callers keep importing them from here.
|
|
16
|
+
export {
|
|
17
|
+
FORUM_SHAPES,
|
|
18
|
+
FORUM_THREAD_SHAPES,
|
|
19
|
+
PARAGRAPH_SHAPES,
|
|
20
|
+
SHAPES,
|
|
21
|
+
q,
|
|
22
|
+
} from "#lint/data/jev-shapes.js";
|
|
8
23
|
|
|
9
24
|
// =========================
|
|
10
25
|
// CONSTANTS
|
|
@@ -27,123 +42,6 @@ const CONCURRENCY = 8;
|
|
|
27
42
|
/** The Reddit bench holds no human reply under this, so a shorter reply is never asked. */
|
|
28
43
|
export const FORUM_MIN_WORDS = 25;
|
|
29
44
|
|
|
30
|
-
/** One question per root cause, not per pattern: humanizer references/patterns.md maps each pattern to one. */
|
|
31
|
-
export const q = (instructions, yes, no) => ({
|
|
32
|
-
type: "noul",
|
|
33
|
-
instructions,
|
|
34
|
-
criteria: { true: yes, false: no },
|
|
35
|
-
});
|
|
36
|
-
const PLAIN =
|
|
37
|
-
"A plain, literal sentence: a step the reader takes, a named thing, a number, or a fact that carries its own meaning.";
|
|
38
|
-
|
|
39
|
-
/** Asked of every sentence, with its paragraph as `context`. */
|
|
40
|
-
export const SHAPES = {
|
|
41
|
-
inflated: q(
|
|
42
|
-
"Does `sentence` tell the reader that something matters, impresses or feels a certain way, instead of giving the fact, number or mechanism that would show it, or is it generic enough to move unchanged to another company, product or person?",
|
|
43
|
-
"Praise, significance, emotion or quality asserted, not shown, or a line with nothing only this subject could say.",
|
|
44
|
-
`${PLAIN} Or a letter's courtesy to its reader: a thanks, a greeting, an invitation.`,
|
|
45
|
-
),
|
|
46
|
-
aphorism: q(
|
|
47
|
-
"Is `sentence` a slogan or maxim: a quotable general truth stated in abstract terms instead of a concrete step, number or fact?",
|
|
48
|
-
"Could be printed on a poster, often a flip or an 'only', and the next sentence has to explain it.",
|
|
49
|
-
PLAIN,
|
|
50
|
-
),
|
|
51
|
-
law: q(
|
|
52
|
-
"Does `sentence` describe how a tool, setting or system behaves as a general rule, with the thing as the subject and no person acting, where it could tell the reader what to do and what they will see?",
|
|
53
|
-
"The subject is an object or an idea, the verb is a state or a spread, and the reader has no step to copy. Often it ends on 'it' or 'them'.",
|
|
54
|
-
"A person does something, a literal step (where to click, what appears), a measured result of what happened, with its number, or a plain fact or rule about one specific thing said the way a person would ('the back door doesn't lock', 'a cancelled ticket is never refunded').",
|
|
55
|
-
),
|
|
56
|
-
vague: q(
|
|
57
|
-
"Does `sentence` point at content instead of stating it: it announces, promises, sets up or labels a point that the sentence itself does not give?",
|
|
58
|
-
"A teaser, signpost or label: the reader learns that there is a reason, a tip, a rule or a next step, but not what it is.",
|
|
59
|
-
"The sentence gives the content itself, the paragraph gives it right after, or it starts with 'Link:' and names what the reader does when they click.",
|
|
60
|
-
),
|
|
61
|
-
hedge: q(
|
|
62
|
-
"Does `sentence` pad itself with a hedge, a reassurance, a propping adverb (really, basically, actually), an unnamed source, or a line about the conversation instead of the subject?",
|
|
63
|
-
"It contains padding of that kind, or talks about the writing instead of the subject.",
|
|
64
|
-
"No hedge, prop or talk about the conversation. A thanks, a greeting or a question to the reader is not padding.",
|
|
65
|
-
),
|
|
66
|
-
filler: q(
|
|
67
|
-
"Can one word or phrase in `sentence` be deleted, or swapped for a shorter one, and the sentence still say exactly the same thing?",
|
|
68
|
-
"At least one word can go or shrink ('in order to', 'each and every', a word the rest already implies) with no loss of meaning.",
|
|
69
|
-
"Every word carries meaning the sentence would lose. Warmth to the reader in a letter counts as meaning.",
|
|
70
|
-
),
|
|
71
|
-
contrast: q(
|
|
72
|
-
"Does `sentence` stage a contrast to make its point: 'not X, it's Y' denying a claim nobody made, an either-or where one side is a strawman, a 'from X to Y' span with no real range, or one claim said twice in other words?",
|
|
73
|
-
"The denied half, the strawman side, the span or the repeat is there for effect. Delete it and the point stands alone.",
|
|
74
|
-
"A real comparison between two named options, or a single plain claim.",
|
|
75
|
-
),
|
|
76
|
-
stilted: q(
|
|
77
|
-
"Does `sentence` sound awkward or unnatural, like a clumsy translation or a forced rewrite, so a native English speaker would phrase it differently or need to reread it?",
|
|
78
|
-
"Awkward phrasing: a person made the subject of find, meet or get where people would say 'there is' or 'X has'; an odd verb; an unexplained code or label; a clumsy word order.",
|
|
79
|
-
"Natural, clear English a person would say out loud.",
|
|
80
|
-
),
|
|
81
|
-
pitch: q(
|
|
82
|
-
"Is `sentence` an ad line that promises an effortless result: a dramatic command plus an outcome said to be already true, or a lone word used as a verdict, instead of saying what happens when the reader takes an action?",
|
|
83
|
-
"Reads like a tagline: 'Do X, and Y is already done', or a one-word fragment as the punchline.",
|
|
84
|
-
`${PLAIN} Or a literal step with what happens next, in the product's own terms.`,
|
|
85
|
-
),
|
|
86
|
-
personified: q(
|
|
87
|
-
"Does `sentence` use a figure where a literal word exists: a non-human thing doing what only a person does, or an abstract idea dressed as a physical object?",
|
|
88
|
-
"A tool that knows, wants, saves or gives; an idea that is a lever, a ceiling, a moat or a muscle.",
|
|
89
|
-
"The thing does something mechanical and literal, or a person does the acting.",
|
|
90
|
-
),
|
|
91
|
-
thingdoer: q(
|
|
92
|
-
"Does `sentence` make a tool, automation, checklist, script or system the grammatical subject of what a person sets up or does, where a person as the subject ('we', 'you', or an imperative) would be plainer?",
|
|
93
|
-
"A noun leads and acts: 'An automation creates it and assigns it', 'A checklist catches this', 'The script only posts what is approved'. It reads like a description of a machine, with nobody behind it. Ramzi, 30 Sep 2026.",
|
|
94
|
-
"A person is the subject or the sentence is an instruction ('Have an automation create it'), or the thing genuinely is the subject of a literal fact ('The API returns JSON').",
|
|
95
|
-
),
|
|
96
|
-
stagey: q(
|
|
97
|
-
"Does `sentence` describe an action or a rule as a small scene where a plain verb and object would do: 'waits for someone to say go' for 'needs your approval', 'gets you most of the way' for 'covers most of it', 'does its sweep' for 'runs'?",
|
|
98
|
-
"A phrase that acts out the idea (waits, says go, gets you there, takes the wheel) when one plain verb says the same thing. Ramzi, 30 Sep 2026: 'Claude Code on a timer requires you' is simpler and means the same.",
|
|
99
|
-
"The sentence already uses the plain verb and object a person would say out loud.",
|
|
100
|
-
),
|
|
101
|
-
reassurance: q(
|
|
102
|
-
"Does `sentence` vouch for what the reader is shown (a demo, screenshot, photo, number, review or the text itself) when nothing in the text doubted it: insist it is real, genuine, untouched, or the product's or the writer's own, or deny it is fake, staged, mocked up, written by AI, sponsored, cherry-picked or padded?",
|
|
103
|
-
"An unasked claim of authenticity or honesty with no proof beside it. A demo that shows the product, a photo that shows the dish and a review nobody paid for are what any reader already assumes, so saying so only fends off a doubt, and raising the doubt is what plants it. Ramzi, 2 Nov 2026.",
|
|
104
|
-
"A plain fact about the thing or what it does, a disclosure of who the writer is or what they were given ('I'm the developer', 'they sent me a free unit'), or an answer to a doubt someone in the text raised.",
|
|
105
|
-
),
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
/** Asked once per paragraph of 3 or more sentences: the shapes no single sentence shows. */
|
|
109
|
-
export const PARAGRAPH_SHAPES = {
|
|
110
|
-
rhythm: q(
|
|
111
|
-
"Does `paragraph` repeat one structure instead of varying it: sentences of one length or one opening, items forced into threes, a punchy closer on every beat, a word reused where no new idea arrived, or a transition that asserts a link the facts do not show?",
|
|
112
|
-
"A reader could predict the shape of the next sentence before reading it.",
|
|
113
|
-
"Sentence lengths and openings vary with the thought, and each link between sentences is shown by what they say.",
|
|
114
|
-
),
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Asked once of a whole forum reply, in place of SHAPES and PARAGRAPH_SHAPES: those refused 151 of
|
|
119
|
-
* 157 human Reddit replies (scripts/reddit-bench.mjs, 2 Nov 2026). Of 10 whole-reply questions tried,
|
|
120
|
-
* this one alone refused a bad comment at FAIL without refusing a human. The rest live in TECHLOG.md.
|
|
121
|
-
*/
|
|
122
|
-
export const FORUM_SHAPES = {
|
|
123
|
-
tutorial: q(
|
|
124
|
-
"`reply` is a comment on a Reddit thread. Does it read as a complete tutorial or help-article answer: the whole procedure laid out step by step from start to finish, each step an instruction, rather than what one person typed from their own experience?",
|
|
125
|
-
"A tidy walkthrough: select this, then open that, pick this, then hit that. Every step covered in order, like documentation or a support bot.",
|
|
126
|
-
"A person talking: a partial answer, a pointer, an opinion, a story about what they did, a question back, or one tip with their reason.",
|
|
127
|
-
),
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Asked of a forum reply beside its thread's title and body, only when the caller passes the thread.
|
|
132
|
-
* Ramzi, 2 Nov 2026, on an Espanso reply that passed 2.6.0: "Who the fuck knows about this app?"
|
|
133
|
-
* At its 0.7 `bar` it refused 2 more of his 6 flagged replies and 2 of 265 humans; 4 other wordings
|
|
134
|
-
* cost 6 to 26 humans for the same catch (TECHLOG.md).
|
|
135
|
-
*/
|
|
136
|
-
export const FORUM_THREAD_SHAPES = {
|
|
137
|
-
lookedup: {
|
|
138
|
-
...q(
|
|
139
|
-
"`reply` answers the Reddit post in `thread`. Does `reply` recommend a specific tool, feature or setting that `thread` never mentions, described with looked-up precision (its exact name, where it lives, how it behaves), while nothing shows the writer has used it themselves?",
|
|
140
|
-
"A researched pointer: names an app, feature or setting the poster never raised, says exactly where it is or what it does, and the writer's own use of it is nowhere in the reply.",
|
|
141
|
-
"The writer works with what the poster named, or says they use the thing ('I use', 'we switched to', 'mine does'), or the names are loose and from memory.",
|
|
142
|
-
),
|
|
143
|
-
bar: 0.7,
|
|
144
|
-
},
|
|
145
|
-
};
|
|
146
|
-
|
|
147
45
|
// =========================
|
|
148
46
|
// FUNCTIONS
|
|
149
47
|
// =========================
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heyramzi/lint",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
4
4
|
"description": "Shared oxlint rules, base config and gates for Studio projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"push-diff.js",
|
|
44
44
|
"slop.d.ts",
|
|
45
45
|
"slop.js",
|
|
46
|
+
"slop-language.js",
|
|
46
47
|
"slop-views.js",
|
|
47
48
|
"ui-rules.js",
|
|
48
49
|
"ui-rules-css.js",
|
package/register.d.ts
CHANGED
|
@@ -58,11 +58,17 @@ export declare const REGISTERS: Record<
|
|
|
58
58
|
label: string;
|
|
59
59
|
source: string;
|
|
60
60
|
bands: Record<string, { min?: number; max?: number }>;
|
|
61
|
-
/** The `auditSlop` finding kinds `slopGate` keeps for this register. Absent keeps every kind. */
|
|
61
|
+
/** The `auditSlop` finding kinds, or single `kind:id`s, `slopGate` keeps for this register. Absent keeps every kind. */
|
|
62
62
|
exact?: string[];
|
|
63
63
|
}
|
|
64
64
|
>;
|
|
65
65
|
|
|
66
|
+
/** Whether `register` keeps an `auditSlop` finding, by its kind or its `kind:id`. */
|
|
67
|
+
export declare function keepsExact(
|
|
68
|
+
register: RegisterName,
|
|
69
|
+
finding: { kind: string; id: string },
|
|
70
|
+
): boolean;
|
|
71
|
+
|
|
66
72
|
/** The AI signals a reply shows, by name, as the forum band counts them. Empty under 25 words. */
|
|
67
73
|
export declare function aiSignalNames(text: string, measured?: RegisterMeasurement): string[];
|
|
68
74
|
|
package/register.js
CHANGED
|
@@ -289,7 +289,9 @@ REGISTERS.forum = {
|
|
|
289
289
|
unbrokenWords: { max: 95 },
|
|
290
290
|
},
|
|
291
291
|
// The exact-pattern kinds that still count. Every other kind refused 68 of the 157 humans.
|
|
292
|
-
|
|
292
|
+
|
|
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"],
|
|
293
295
|
};
|
|
294
296
|
|
|
295
297
|
const DIRECTION = {
|
|
@@ -314,6 +316,12 @@ const DIRECTION = {
|
|
|
314
316
|
menuPaths: "menu paths written out (A > B)",
|
|
315
317
|
};
|
|
316
318
|
|
|
319
|
+
/** Whether a register keeps an `auditSlop` finding: its kind, or its `kind:id`, is in `exact`. No `exact` keeps all. */
|
|
320
|
+
export function keepsExact(register, finding) {
|
|
321
|
+
const exact = REGISTERS[register]?.exact;
|
|
322
|
+
return !exact || exact.includes(finding.kind) || exact.includes(`${finding.kind}:${finding.id}`);
|
|
323
|
+
}
|
|
324
|
+
|
|
317
325
|
/**
|
|
318
326
|
* Measure, then score against one band set.
|
|
319
327
|
*
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ban a shallow navigation in an `$effect` that tracks `page.state`, and `invalidate*` in one that tracks `page.data`.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* The call writes the field the effect tracks, so it reruns forever: getwavenote.com/download?auto fired 13 DMGs and hung (TSK-1648). `untrack()` the read or run it in `onMount`.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** The `page` field each call writes. A plain `goto` leaves the page instead, so it never loops. */
|
|
10
|
+
const WRITES = {
|
|
11
|
+
goto: "state",
|
|
12
|
+
pushState: "state",
|
|
13
|
+
replaceState: "state",
|
|
14
|
+
invalidate: "data",
|
|
15
|
+
invalidateAll: "data",
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const message =
|
|
19
|
+
"`{{name}}` writes `page.{{field}}`, which this `$effect` tracks, so it reruns forever. Read it in `untrack()` or move the call to `onMount`.";
|
|
20
|
+
|
|
21
|
+
function isEffectCall(node) {
|
|
22
|
+
if (node?.type !== "CallExpression") return false;
|
|
23
|
+
const { callee } = node;
|
|
24
|
+
if (callee.type === "Identifier") return callee.name === "$effect";
|
|
25
|
+
return (
|
|
26
|
+
callee.type === "MemberExpression" &&
|
|
27
|
+
callee.object.type === "Identifier" &&
|
|
28
|
+
callee.object.name === "$effect" &&
|
|
29
|
+
callee.property.type === "Identifier" &&
|
|
30
|
+
callee.property.name === "pre"
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** The `$effect` call whose callback holds `node`, or null when an `untrack()` sits between them. */
|
|
35
|
+
function enclosingEffect(node) {
|
|
36
|
+
for (let child = node, parent = node.parent; parent; child = parent, parent = parent.parent) {
|
|
37
|
+
if (parent.type === "CallExpression" && parent.callee.type === "Identifier") {
|
|
38
|
+
if (parent.callee.name === "untrack" && parent.arguments[0] === child) return null;
|
|
39
|
+
}
|
|
40
|
+
if (isEffectCall(parent) && parent.arguments[0] === child) return parent;
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function isInPlace(name, call) {
|
|
46
|
+
if (name !== "goto") return true;
|
|
47
|
+
const options = call.arguments[1];
|
|
48
|
+
return (
|
|
49
|
+
options?.type === "ObjectExpression" &&
|
|
50
|
+
options.properties.some(
|
|
51
|
+
(prop) =>
|
|
52
|
+
prop.type === "Property" &&
|
|
53
|
+
(prop.key.name ?? prop.key.value) === "shallow" &&
|
|
54
|
+
prop.value.type === "Literal" &&
|
|
55
|
+
prop.value.value === true,
|
|
56
|
+
)
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export default {
|
|
61
|
+
meta: {
|
|
62
|
+
type: "problem",
|
|
63
|
+
docs: { description: "Disallow a navigation that writes the page field its $effect tracks." },
|
|
64
|
+
messages: { navigationInEffect: message },
|
|
65
|
+
schema: [],
|
|
66
|
+
},
|
|
67
|
+
create(context) {
|
|
68
|
+
const local = new Map();
|
|
69
|
+
const pageNames = new Set();
|
|
70
|
+
const pending = [];
|
|
71
|
+
const tracked = new Map();
|
|
72
|
+
return {
|
|
73
|
+
ImportDeclaration(node) {
|
|
74
|
+
if (node.source?.value === "$app/state") {
|
|
75
|
+
for (const specifier of node.specifiers) {
|
|
76
|
+
const imported = specifier.imported?.name ?? specifier.imported?.value;
|
|
77
|
+
if (imported === "page") pageNames.add(specifier.local.name);
|
|
78
|
+
}
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (node.source?.value !== "$app/navigation") return;
|
|
82
|
+
for (const specifier of node.specifiers) {
|
|
83
|
+
if (specifier.type !== "ImportSpecifier") continue;
|
|
84
|
+
const imported = specifier.imported.name ?? specifier.imported.value;
|
|
85
|
+
if (imported in WRITES) local.set(specifier.local.name, imported);
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
CallExpression(node) {
|
|
89
|
+
if (node.callee.type !== "Identifier" || !local.has(node.callee.name)) return;
|
|
90
|
+
if (!isInPlace(local.get(node.callee.name), node)) return;
|
|
91
|
+
const effect = enclosingEffect(node);
|
|
92
|
+
if (effect) pending.push({ node, effect });
|
|
93
|
+
},
|
|
94
|
+
Identifier(node) {
|
|
95
|
+
if (!pageNames.has(node.name)) return;
|
|
96
|
+
const { parent } = node;
|
|
97
|
+
if (parent?.type !== "MemberExpression" || parent.object !== node || parent.computed)
|
|
98
|
+
return;
|
|
99
|
+
const effect = enclosingEffect(node);
|
|
100
|
+
if (!effect) return;
|
|
101
|
+
if (!tracked.has(effect)) tracked.set(effect, new Set());
|
|
102
|
+
tracked.get(effect).add(parent.property.name);
|
|
103
|
+
},
|
|
104
|
+
"Program:exit"() {
|
|
105
|
+
for (const { node, effect } of pending) {
|
|
106
|
+
const field = WRITES[local.get(node.callee.name)];
|
|
107
|
+
if (!tracked.get(effect)?.has(field)) continue;
|
|
108
|
+
const data = { name: node.callee.name, field };
|
|
109
|
+
context.report({ node, messageId: "navigationInEffect", data });
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
},
|
|
114
|
+
};
|
package/slop-language.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which language the draft is in, so the checks that only work in one of them pick the right list.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* Stopword counting, not a library.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/*
|
|
10
|
+
* The two sets share almost nothing, a draft of any length separates them by a wide margin, and the only caller that can be hurt by a wrong answer is
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/*
|
|
14
|
+
* the pronoun ledger, which reports rather than rewrites. English is the default on a tie, including on an empty string.
|
|
15
|
+
*/
|
|
16
|
+
const FR_STOPWORDS =
|
|
17
|
+
/(?<![\p{L}\p{N}_])(?:le|la|les|des|une|un|et|est|dans|pour|que|qui|pas|avec|sur|plus|cette|vous|nous|aux|mais|sont|être|ce|se|son|ses|leur|par|au|du|elle|il)(?![\p{L}\p{N}_])/giu;
|
|
18
|
+
const EN_STOPWORDS =
|
|
19
|
+
/(?<![\p{L}\p{N}_])(?:the|and|is|of|to|in|that|it|for|with|you|this|are|on|but|not|have|from|as|was|they|be|at|by|or|an|its|their)(?![\p{L}\p{N}_])/giu;
|
|
20
|
+
// None of these is an English or French word, so an English draft quoting one German phrase stays English.
|
|
21
|
+
const DE_STOPWORDS =
|
|
22
|
+
/(?<![\p{L}\p{N}_])(?:der|das|und|ist|nicht|mit|ein|eine|einen|einem|für|auf|sich|dem|auch|zu|von|wird|sind|oder|aber|wenn|nur|bei|nach|noch|wie|über|kann|ich|wir|Sie|zum|zur|dass|werden|haben)(?![\p{L}\p{N}_])/giu;
|
|
23
|
+
|
|
24
|
+
export function detectLanguage(text) {
|
|
25
|
+
// Japanese first, and by script rather than by stopword.
|
|
26
|
+
|
|
27
|
+
// A Japanese draft has no English or French stopwords of its own, so the count is decided by whatever it quotes, and every Japanese page on the Wavenote site came
|
|
28
|
+
|
|
29
|
+
// back "en" and was then graded on English pronouns it does not use.
|
|
30
|
+
const cjk = (text.match(/[\u3040-\u30ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff]/g) ?? []).length;
|
|
31
|
+
const letters = (text.match(/[\p{L}]/gu) ?? []).length;
|
|
32
|
+
if (letters > 0 && cjk / letters > 0.2) return "ja";
|
|
33
|
+
const en = (text.match(EN_STOPWORDS) ?? []).length;
|
|
34
|
+
const fr = (text.match(FR_STOPWORDS) ?? []).length;
|
|
35
|
+
const de = (text.match(DE_STOPWORDS) ?? []).length;
|
|
36
|
+
if (fr > en && fr >= de) return "fr";
|
|
37
|
+
if (de > en && de > fr) return "de";
|
|
38
|
+
return "en";
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The language a file declares: frontmatter `lang`, `locale` or `language`, then the nearest folder named for one (`/de/`, `/ja-JP/`). Undefined when neither says.
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
/*
|
|
46
|
+
* Seam's German posts said it only by folder and were graded as English, 3 Nov 2026. `it` is left out: that folder is usually a department.
|
|
47
|
+
*/
|
|
48
|
+
const LANGUAGE_FOLDERS = new Set([
|
|
49
|
+
"en",
|
|
50
|
+
"fr",
|
|
51
|
+
"de",
|
|
52
|
+
"ja",
|
|
53
|
+
"es",
|
|
54
|
+
"pt",
|
|
55
|
+
"nl",
|
|
56
|
+
"zh",
|
|
57
|
+
"ko",
|
|
58
|
+
"pl",
|
|
59
|
+
"sv",
|
|
60
|
+
"da",
|
|
61
|
+
"fi",
|
|
62
|
+
"ru",
|
|
63
|
+
"tr",
|
|
64
|
+
]);
|
|
65
|
+
export function declaredLanguage(source = "", path = "") {
|
|
66
|
+
const front = /^---\r?\n([\s\S]*?)\r?\n---/.exec(source)?.[1] ?? "";
|
|
67
|
+
const tag = /^(?:lang|locale|language)[ \t]*:[ \t]*["']?([A-Za-z]{2})(?![A-Za-z])/m.exec(front);
|
|
68
|
+
if (tag) return tag[1].toLowerCase();
|
|
69
|
+
const folder = path
|
|
70
|
+
.split(/[\\/]/)
|
|
71
|
+
.slice(0, -1)
|
|
72
|
+
.toReversed()
|
|
73
|
+
.find((s) => /^[a-z]{2}(?:[-_][A-Za-z]{2})?$/.test(s) && LANGUAGE_FOLDERS.has(s.slice(0, 2)));
|
|
74
|
+
return folder?.slice(0, 2);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* The word lists, phrases, sentence patterns, title case and pronoun ledger are written for these. German needs a comma before every relative clause, which `comma-run` read as a list.
|
|
79
|
+
*/
|
|
80
|
+
|
|
81
|
+
/*
|
|
82
|
+
* The outline, dashes, emoji, hashtags, chatbot markup and any pattern marked `anyLanguage` still run in every language.
|
|
83
|
+
*/
|
|
84
|
+
export const LISTED_LANGUAGES = new Set(["en", "fr"]);
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* The first person against the second, per language.
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
/*
|
|
91
|
+
* The English-only sets were the whole check until 5 Sep 2026, so every French draft counted 0 against 0 and failed `selfish-framing` by construction.
|
|
92
|
+
*/
|
|
93
|
+
|
|
94
|
+
/*
|
|
95
|
+
* The check now runs on the detected language and only fires when the writer actually used the first person: copy with no pronouns at all is a reference page,
|
|
96
|
+
*/
|
|
97
|
+
|
|
98
|
+
/*
|
|
99
|
+
* not a page about its author.
|
|
100
|
+
*/
|
|
101
|
+
export const PRONOUNS = {
|
|
102
|
+
en: {
|
|
103
|
+
// Case-sensitive: a lone `i` is a loop index, `US` a country, and `Annex I` a numeral.
|
|
104
|
+
first:
|
|
105
|
+
/(?<![\p{L}\p{N}_])(?:(?<!(?:Annex|Article|Title|Chapter|Part|Section|Phase|Tier) )I|[Ww]e|WE|[Mm]y|[Oo]urs?|OUR|[Mm]ine|[Uu]s)(?![\p{L}\p{N}_])/gu,
|
|
106
|
+
second: /(?<![\p{L}\p{N}_])(?:you|your|yours)(?![\p{L}\p{N}_])/giu,
|
|
107
|
+
},
|
|
108
|
+
fr: {
|
|
109
|
+
first: /(?<![\p{L}\p{N}_])(?:je|j'|nous|mon|ma|mes|notre|nos|moi|me)(?![\p{L}\p{N}_])/giu,
|
|
110
|
+
second: /(?<![\p{L}\p{N}_])(?:vous|votre|vos|tu|ton|ta|tes|toi)(?![\p{L}\p{N}_])/giu,
|
|
111
|
+
},
|
|
112
|
+
};
|
package/slop-views.js
CHANGED
|
@@ -79,7 +79,33 @@ export function withStringStarts(text) {
|
|
|
79
79
|
* and it holds its own subheadings by design. `question-heading` and `empty-section` skip it rather than asking a page to hide the question it answers.
|
|
80
80
|
*/
|
|
81
81
|
export const FAQ_TITLE =
|
|
82
|
-
/^(?:FAQ|F\.A\.Q\.?|Frequently asked questions|よくある質問|Questions? fréquentes
|
|
82
|
+
/^(?:FAQ|F\.A\.Q\.?|Frequently asked questions|よくある質問|Questions? fréquentes?|Häufig gestellte Fragen|Häufige Fragen)$/i;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* A link's address is not copy: the `/us/` in an App Store link counted as the English "us" on Seam's German brain-fm page, 3 Nov 2026.
|
|
86
|
+
*/
|
|
87
|
+
|
|
88
|
+
/*
|
|
89
|
+
* Letters and digits become `x` while length and punctuation stay, so every other check reads the same shape. Emptied, it moved 5 English hits.
|
|
90
|
+
*/
|
|
91
|
+
|
|
92
|
+
/*
|
|
93
|
+
* The chatbot `artifacts` read the raw address, because `utm_source=chatgpt.com` is the sign.
|
|
94
|
+
*/
|
|
95
|
+
const WEB_TLD = "(?:com|org|net|io|co|fm|app|dev|ai|eu|uk|de|fr|jp|me|so|gg|tv|ly|sh|xyz)";
|
|
96
|
+
const mask = (address) => address.replace(/[\p{L}\p{N}]/gu, "x");
|
|
97
|
+
export function withoutUrls(text) {
|
|
98
|
+
return text
|
|
99
|
+
.replace(
|
|
100
|
+
/(\]\()((?:[^()\s]|\([^()\s]*\))*)(?=(?:\s+"[^"\n]*")?\))/g,
|
|
101
|
+
(_, open, address) => open + mask(address),
|
|
102
|
+
)
|
|
103
|
+
.replace(/\b(?:https?:\/\/|www\.)[^\s<>"'`)\]]+/gi, mask)
|
|
104
|
+
.replace(
|
|
105
|
+
new RegExp(`(?<![\\p{L}\\p{N}@./-])(?:[a-z0-9-]+\\.)+${WEB_TLD}\\/[^\\s<>"'\`)\\]]*`, "gu"),
|
|
106
|
+
mask,
|
|
107
|
+
);
|
|
108
|
+
}
|
|
83
109
|
|
|
84
110
|
export function withoutFaqSections(text) {
|
|
85
111
|
let depth = 0;
|
package/slop.d.ts
CHANGED
|
@@ -12,8 +12,8 @@ export type SlopAudit = {
|
|
|
12
12
|
findings: SlopFinding[];
|
|
13
13
|
/** Shapes a regex cannot judge. Reported, never failed. */
|
|
14
14
|
review: SlopFinding[];
|
|
15
|
-
/** The language the checks ran in. English on a tie. */
|
|
16
|
-
language:
|
|
15
|
+
/** The language the checks ran in, as a 2-letter code: declared, else counted. English on a tie. */
|
|
16
|
+
language: string;
|
|
17
17
|
/** First-person against second-person word counts, in that language. */
|
|
18
18
|
ledger: { first: number; second: number };
|
|
19
19
|
words: number;
|
|
@@ -40,11 +40,17 @@ export declare function stripInvisibles(
|
|
|
40
40
|
/** True when the text carries nothing invisible. */
|
|
41
41
|
export declare function isClean(text: string): boolean;
|
|
42
42
|
|
|
43
|
-
/** Which language the draft is in, by stopword count. English on a tie. */
|
|
44
|
-
export declare function detectLanguage(text: string): "en" | "fr";
|
|
43
|
+
/** Which language the draft is in: `ja` by script, else `en`, `fr` or `de` by stopword count. English on a tie. */
|
|
44
|
+
export declare function detectLanguage(text: string): "en" | "fr" | "de" | "ja";
|
|
45
|
+
|
|
46
|
+
/** The language a file declares: frontmatter `lang`, `locale` or `language`, then a `/de/`-style folder in its path. */
|
|
47
|
+
export declare function declaredLanguage(source?: string, path?: string): string | undefined;
|
|
45
48
|
|
|
46
49
|
/** The enumerable half of the humanizer, over one string. Never rewrites. */
|
|
47
|
-
export declare function auditSlop(
|
|
50
|
+
export declare function auditSlop(
|
|
51
|
+
text: string,
|
|
52
|
+
options?: { code?: boolean; language?: string },
|
|
53
|
+
): SlopAudit;
|
|
48
54
|
|
|
49
55
|
/** Clean, then audit. The one call a publishing path makes. */
|
|
50
56
|
export declare function slopGate(
|
|
@@ -54,5 +60,7 @@ export declare function slopGate(
|
|
|
54
60
|
code?: boolean;
|
|
55
61
|
normalizeSpaces?: boolean;
|
|
56
62
|
register?: import("./register.js").RegisterName;
|
|
63
|
+
/** A 2-letter code the caller already knows. The word, phrase and sentence lists run only on `en` and `fr`. */
|
|
64
|
+
language?: string;
|
|
57
65
|
},
|
|
58
66
|
): SlopLint;
|
package/slop.js
CHANGED
|
@@ -49,7 +49,13 @@ import {
|
|
|
49
49
|
import { phrases, words } from "#lint/data/slop-words.js";
|
|
50
50
|
import { artifacts } from "#lint/data/slop/artifacts.js";
|
|
51
51
|
import { patterns } from "#lint/data/slop/patterns.js";
|
|
52
|
-
import {
|
|
52
|
+
import { auditRegister, keepsExact } from "#lint/register.js";
|
|
53
|
+
import {
|
|
54
|
+
LISTED_LANGUAGES,
|
|
55
|
+
PRONOUNS,
|
|
56
|
+
declaredLanguage,
|
|
57
|
+
detectLanguage,
|
|
58
|
+
} from "#lint/slop-language.js";
|
|
53
59
|
import {
|
|
54
60
|
FAQ_TITLE,
|
|
55
61
|
copyStrings,
|
|
@@ -58,9 +64,13 @@ import {
|
|
|
58
64
|
withoutCode,
|
|
59
65
|
withoutComments,
|
|
60
66
|
withoutFaqSections,
|
|
67
|
+
withoutUrls,
|
|
61
68
|
} from "#lint/slop-views.js";
|
|
62
69
|
import { auditShorts } from "@heyramzi/social/shorts";
|
|
63
70
|
|
|
71
|
+
// Part of the `@heyramzi/lint/slop` API that `slop.d.ts` declares.
|
|
72
|
+
export { declaredLanguage, detectLanguage };
|
|
73
|
+
|
|
64
74
|
const escapeRe = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
65
75
|
|
|
66
76
|
/**
|
|
@@ -89,7 +99,7 @@ export function stripMarkup(raw) {
|
|
|
89
99
|
.replace(/<(script|style)[\s\S]*?<\/\1>/gi, " ")
|
|
90
100
|
// A markup comment is a note to the next developer, not copy.
|
|
91
101
|
|
|
92
|
-
// It goes with the script block
|
|
102
|
+
// It goes with the script block: the CBAM pages rule their sections with `<!-- name -->` in rows of em dashes, which reported 8 dashes nobody reads.
|
|
93
103
|
.replace(/<!--[\s\S]*?-->/g, " ")
|
|
94
104
|
.replace(/&[a-z]+;|&#\d+;/gi, " ")
|
|
95
105
|
.replace(/<[^>]+>/g, " ");
|
|
@@ -253,68 +263,6 @@ const EMOJI =
|
|
|
253
263
|
*/
|
|
254
264
|
const HASHTAG = /(?<=[^\n#]\s|^\s*\S[^\n]*?\s)#(?![0-9a-fA-F]{3,8}\b)(?!\d+\b)[A-Za-z][\w-]*/g;
|
|
255
265
|
|
|
256
|
-
/**
|
|
257
|
-
* Which language the draft is in, so the checks that only work in one of them pick the right list.
|
|
258
|
-
*/
|
|
259
|
-
|
|
260
|
-
/*
|
|
261
|
-
* Stopword counting, not a library.
|
|
262
|
-
*/
|
|
263
|
-
|
|
264
|
-
/*
|
|
265
|
-
* The two sets share almost nothing, a draft of any length separates them by a wide margin, and the only caller that can be hurt by a wrong answer is
|
|
266
|
-
*/
|
|
267
|
-
|
|
268
|
-
/*
|
|
269
|
-
* the pronoun ledger, which reports rather than rewrites. English is the default on a tie, including on an empty string.
|
|
270
|
-
*/
|
|
271
|
-
const FR_STOPWORDS =
|
|
272
|
-
/(?<![\p{L}\p{N}_])(?:le|la|les|des|une|un|et|est|dans|pour|que|qui|pas|avec|sur|plus|cette|vous|nous|aux|mais|sont|être|ce|se|son|ses|leur|par|au|du|elle|il)(?![\p{L}\p{N}_])/giu;
|
|
273
|
-
const EN_STOPWORDS =
|
|
274
|
-
/(?<![\p{L}\p{N}_])(?:the|and|is|of|to|in|that|it|for|with|you|this|are|on|but|not|have|from|as|was|they|be|at|by|or|an|its|their)(?![\p{L}\p{N}_])/giu;
|
|
275
|
-
|
|
276
|
-
export function detectLanguage(text) {
|
|
277
|
-
// Japanese first, and by script rather than by stopword.
|
|
278
|
-
|
|
279
|
-
// A Japanese draft has no English or French stopwords of its own, so the count is decided by whatever it quotes, and every Japanese page on the Wavenote site came
|
|
280
|
-
|
|
281
|
-
// back "en" and was then graded on English pronouns it does not use.
|
|
282
|
-
const cjk = (text.match(/[\u3040-\u30ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff]/g) ?? []).length;
|
|
283
|
-
const letters = (text.match(/[\p{L}]/gu) ?? []).length;
|
|
284
|
-
if (letters > 0 && cjk / letters > 0.2) return "ja";
|
|
285
|
-
const fr = (text.match(FR_STOPWORDS) ?? []).length;
|
|
286
|
-
const en = (text.match(EN_STOPWORDS) ?? []).length;
|
|
287
|
-
return fr > en ? "fr" : "en";
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* The first person against the second, per language.
|
|
292
|
-
*/
|
|
293
|
-
|
|
294
|
-
/*
|
|
295
|
-
* The English-only sets were the whole check until 5 Sep 2026, so every French draft counted 0 against 0 and failed `selfish-framing` by construction.
|
|
296
|
-
*/
|
|
297
|
-
|
|
298
|
-
/*
|
|
299
|
-
* The check now runs on the detected language and only fires when the writer actually used the first person: copy with no pronouns at all is a reference page,
|
|
300
|
-
*/
|
|
301
|
-
|
|
302
|
-
/*
|
|
303
|
-
* not a page about its author.
|
|
304
|
-
*/
|
|
305
|
-
const PRONOUNS = {
|
|
306
|
-
en: {
|
|
307
|
-
// Case-sensitive: a lone `i` is a loop index, `US` a country, and `Annex I` a numeral.
|
|
308
|
-
first:
|
|
309
|
-
/(?<![\p{L}\p{N}_])(?:(?<!(?:Annex|Article|Title|Chapter|Part|Section|Phase|Tier) )I|[Ww]e|WE|[Mm]y|[Oo]urs?|OUR|[Mm]ine|[Uu]s)(?![\p{L}\p{N}_])/gu,
|
|
310
|
-
second: /(?<![\p{L}\p{N}_])(?:you|your|yours)(?![\p{L}\p{N}_])/giu,
|
|
311
|
-
},
|
|
312
|
-
fr: {
|
|
313
|
-
first: /(?<![\p{L}\p{N}_])(?:je|j'|nous|mon|ma|mes|notre|nos|moi|me)(?![\p{L}\p{N}_])/giu,
|
|
314
|
-
second: /(?<![\p{L}\p{N}_])(?:vous|votre|vos|tu|ton|ta|tes|toi)(?![\p{L}\p{N}_])/giu,
|
|
315
|
-
},
|
|
316
|
-
};
|
|
317
|
-
|
|
318
266
|
/**
|
|
319
267
|
* The signs that are only visible across a whole document, so no regex over one sentence finds them: Wikipedia's title case, heading levels,
|
|
320
268
|
*/
|
|
@@ -326,7 +274,7 @@ const PRONOUNS = {
|
|
|
326
274
|
/*
|
|
327
275
|
* Markdown only. HTML is stripped to prose before it reaches here, so a page audits on its words and an `.md` draft audits on its words and its outline.
|
|
328
276
|
*/
|
|
329
|
-
function auditStructure(text) {
|
|
277
|
+
function auditStructure(text, language) {
|
|
330
278
|
const found = [];
|
|
331
279
|
const hit = (id, detail) => found.push({ kind: "structure", id, detail });
|
|
332
280
|
|
|
@@ -342,7 +290,7 @@ function auditStructure(text) {
|
|
|
342
290
|
|
|
343
291
|
// and 2 of them capitalised is the threshold: "Awards and Recognition" hits, "the ClickUp API" does not.
|
|
344
292
|
const names = properNouns(body);
|
|
345
|
-
for (const heading of headings) {
|
|
293
|
+
for (const heading of LISTED_LANGUAGES.has(language) ? headings : []) {
|
|
346
294
|
const rest = heading.title
|
|
347
295
|
.split(/\s+/)
|
|
348
296
|
.slice(1)
|
|
@@ -423,10 +371,14 @@ function auditStructure(text) {
|
|
|
423
371
|
/*
|
|
424
372
|
* Those are claims about the world, and a string is all this function gets.
|
|
425
373
|
*/
|
|
426
|
-
export function auditSlop(draft, { code = false } = {}) {
|
|
427
|
-
const
|
|
374
|
+
export function auditSlop(draft, { code = false, language: declared } = {}) {
|
|
375
|
+
const source = code ? withoutComments(draft) : draft;
|
|
376
|
+
// Every layer but `artifacts` reads the draft with its link addresses masked: `withoutUrls` carries why.
|
|
377
|
+
const text = withoutUrls(source);
|
|
428
378
|
const findings = [];
|
|
429
379
|
const add = (kind, id, detail) => findings.push({ kind, id, detail });
|
|
380
|
+
const language = declared ?? declaredLanguage(draft) ?? detectLanguage(text);
|
|
381
|
+
const listed = LISTED_LANGUAGES.has(language);
|
|
430
382
|
|
|
431
383
|
// The ban lists read the draft with its code spans removed, because an identifier is not a word somebody chose: `enhance` is a Worker directory and `enable` is an API
|
|
432
384
|
|
|
@@ -434,11 +386,11 @@ export function auditSlop(draft, { code = false } = {}) {
|
|
|
434
386
|
|
|
435
387
|
// The `patterns` below still read the whole text, where the surrounding sentence is what they are judging.
|
|
436
388
|
const prose = withoutCode(text);
|
|
437
|
-
for (const word of words) {
|
|
389
|
+
for (const word of listed ? words : []) {
|
|
438
390
|
const m = prose.match(bounded(word));
|
|
439
391
|
if (m) add("word", word, m[0]);
|
|
440
392
|
}
|
|
441
|
-
for (const phrase of phrases) {
|
|
393
|
+
for (const phrase of listed ? phrases : []) {
|
|
442
394
|
// Bounded like a word, not `includes`. A substring test read "En sommeil" as the banned "en somme" and failed a dormant-status label on the UpSys site, 6 Sep 2026.
|
|
443
395
|
|
|
444
396
|
// Every phrase here is whole words.
|
|
@@ -456,19 +408,24 @@ export function auditSlop(draft, { code = false } = {}) {
|
|
|
456
408
|
prose: code ? copyStrings(text) : prose,
|
|
457
409
|
};
|
|
458
410
|
for (const pattern of patterns) {
|
|
459
|
-
|
|
460
|
-
|
|
411
|
+
if (!listed && !pattern.anyLanguage) continue;
|
|
412
|
+
const view = views[pattern.view ?? "anchored"];
|
|
413
|
+
const m = view.match(pattern.test);
|
|
414
|
+
if (!m) continue;
|
|
415
|
+
// Masking keeps every index, so a hit on the masked text is shown as the writer typed it.
|
|
416
|
+
const hit = view === text ? source.slice(m.index, m.index + m[0].length) : m[0];
|
|
417
|
+
add("pattern", pattern.id, hit.slice(0, 90));
|
|
461
418
|
}
|
|
462
419
|
for (const artifact of artifacts) {
|
|
463
|
-
const m =
|
|
420
|
+
const m = source.match(artifact.test);
|
|
464
421
|
if (m) add("artifact", artifact.id, m[0].slice(0, 90));
|
|
465
422
|
}
|
|
466
|
-
for (const finding of auditStructure(text)) findings.push(finding);
|
|
423
|
+
for (const finding of auditStructure(text, language)) findings.push(finding);
|
|
467
424
|
for (const m of text.matchAll(/[—–]/g)) {
|
|
468
|
-
add("dash", "em-or-en-dash",
|
|
425
|
+
add("dash", "em-or-en-dash", source.slice(Math.max(0, m.index - 30), m.index + 30));
|
|
469
426
|
}
|
|
470
427
|
for (const m of text.matchAll(EMOJI)) {
|
|
471
|
-
add("emoji", "emoji",
|
|
428
|
+
add("emoji", "emoji", source.slice(Math.max(0, m.index - 30), m.index + 30));
|
|
472
429
|
}
|
|
473
430
|
for (const m of withoutCode(text).matchAll(HASHTAG)) {
|
|
474
431
|
add("hashtag", "hashtag", m[0]);
|
|
@@ -476,7 +433,6 @@ export function auditSlop(draft, { code = false } = {}) {
|
|
|
476
433
|
|
|
477
434
|
const ledgerText = code ? copyStrings(text) : text;
|
|
478
435
|
const count = (re) => (ledgerText.match(re) ?? []).length;
|
|
479
|
-
const language = detectLanguage(text);
|
|
480
436
|
// Only the languages with pronoun sets are graded.
|
|
481
437
|
|
|
482
438
|
// Japanese marks the same distinction with particles and by leaving the subject out, so a regex over `we` and `you` says nothing about a Japanese draft.
|
|
@@ -489,13 +445,13 @@ export function auditSlop(draft, { code = false } = {}) {
|
|
|
489
445
|
add("ledger", "selfish-framing", `first ${first}, second ${second}`);
|
|
490
446
|
|
|
491
447
|
const review = [];
|
|
492
|
-
for (const grep of PIVOT_GREPS) {
|
|
448
|
+
for (const grep of listed ? PIVOT_GREPS : []) {
|
|
493
449
|
for (const m of text.matchAll(grep)) {
|
|
494
450
|
const from = Math.max(0, m.index - 45);
|
|
495
451
|
review.push({
|
|
496
452
|
kind: "review-pivot",
|
|
497
453
|
id: m[0].toLowerCase(),
|
|
498
|
-
detail: `...${
|
|
454
|
+
detail: `...${source.slice(from, m.index + 55)}...`,
|
|
499
455
|
});
|
|
500
456
|
}
|
|
501
457
|
}
|
|
@@ -537,21 +493,20 @@ export function auditSlop(draft, { code = false } = {}) {
|
|
|
537
493
|
*/
|
|
538
494
|
export function slopGate(
|
|
539
495
|
raw,
|
|
540
|
-
{ markup = false, code = false, normalizeSpaces = true, register } = {},
|
|
496
|
+
{ markup = false, code = false, normalizeSpaces = true, register, language } = {},
|
|
541
497
|
) {
|
|
542
498
|
const source = markup ? stripMarkup(raw) : raw;
|
|
543
499
|
const cleaned = stripInvisibles(source, { normalizeSpaces });
|
|
544
|
-
const audit = auditSlop(cleaned.text, { code });
|
|
500
|
+
const audit = auditSlop(cleaned.text, { code, language });
|
|
545
501
|
// A ban list cannot see the fault that produced the 9 Sep 2026 Shorts batch: every script passed the words and still read as somebody else,
|
|
546
502
|
|
|
547
503
|
// because the register was written and the delivery was spoken. `register.js` carries why.
|
|
548
504
|
const registerAudit = register ? auditRegister(cleaned.text, register) : null;
|
|
549
505
|
// A Short also owes a hook from the library and a counted, reply-ending skeleton.
|
|
550
506
|
const shortsAudit = register === "shorts" ? auditShorts(cleaned.text) : null;
|
|
551
|
-
// A register may count only some exact kinds: on Reddit the rest refused most human replies.
|
|
552
|
-
const exact = REGISTERS[register]?.exact;
|
|
507
|
+
// A register may count only some exact kinds, or one `kind:id`: on Reddit the rest refused most human replies.
|
|
553
508
|
const findings = [
|
|
554
|
-
...
|
|
509
|
+
...audit.findings.filter((f) => keepsExact(register, f)),
|
|
555
510
|
...(registerAudit?.findings ?? []),
|
|
556
511
|
...(shortsAudit?.findings ?? []),
|
|
557
512
|
];
|