@heyramzi/lint 2.2.1 → 2.3.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/data/slop/patterns/comma-clauses.js +13 -0
- package/package.json +1 -1
- package/slop.js +49 -20
|
@@ -54,6 +54,19 @@ export const patternsCommaClauses = [
|
|
|
54
54
|
rule: 'A name, a comma, then a stock tail with no verb ("end to end", "in one place"), or a mirrored "one X, one Y". It reads as a slogan and says nothing a sentence would not. Ramzi, 28 Sep 2026, on "Editor OS, end to end". Write the sentence, or cut to the name.',
|
|
55
55
|
example: '"Editor OS, end to end" / "one camera, one go" / "No setup, no code"',
|
|
56
56
|
},
|
|
57
|
+
{
|
|
58
|
+
id: "comma-hung-tag",
|
|
59
|
+
// Per LINE: a name of 1 to 4 words, a comma, then a tail with no verb: a preposition and one noun, "by design", or "made"/"done" plus a word.
|
|
60
|
+
|
|
61
|
+
// Open where `comma-hung-phrase` is a closed list, because the list missed "CBAM, in context." on the CBAM news page, 27 Oct 2026.
|
|
62
|
+
|
|
63
|
+
// A sort label ("Checks, in order", "Codes, by sector"), a state ("in review") and a unit ("Price, in EUR", "Cement, in tonnes") stay out.
|
|
64
|
+
test: /^[ \t]*(?:#{1,6}[ \t]+|[-*+][ \t]+|[\w$]+:[ \t]*["'`])?[A-Z][A-Za-zà-ÿ'’-]*(?:[ \t]+[A-Za-zà-ÿ'’-]+){0,3}(?<!\b(?:in|on|at|up|out|off)),[ \t]+(?:in[ \t]+plain[ \t]+[A-Za-zà-ÿ]+|(?:in|at|on)[ \t]+(?:(?:a|an|the|one|real)[ \t]+)?(?!(?:z-)?order\b|(?:review|progress|stock|draft|tonnes?|tons?|kg|grams?|euros?|dollars?|days?|hours?|minutes?|seconds?|weeks?|months?|years?|percent|units?|words?|pages?|total)\b)[a-zà-ÿ][a-zà-ÿ-]*|by[ \t]+(?:design|default)|(?:made|done)[ \t]+[a-zà-ÿ]+)[ \t]*[.!]?(?:["'`][,;]?)?[ \t]*$/m,
|
|
65
|
+
name: "Comma-hung tag",
|
|
66
|
+
rule: 'A short name, a comma, and a verbless tail that sounds like a tagline: "in context", "made simple", "on demand". The tail promises a quality and never says what the page holds. Ramzi, 27 Oct 2026, on the CBAM news heading "CBAM, in context.". Write what the page gives the reader, or cut to the name.',
|
|
67
|
+
example:
|
|
68
|
+
'"CBAM, in context." / "Pricing, made simple." / "Your data, on demand" / "Compliance, by design"',
|
|
69
|
+
},
|
|
57
70
|
{
|
|
58
71
|
id: "guided-tour-promise",
|
|
59
72
|
// A relative clause restating a thing's obvious job as hand-holding.
|
package/package.json
CHANGED
package/slop.js
CHANGED
|
@@ -85,26 +85,55 @@ const bounded = (word) =>
|
|
|
85
85
|
* Entities go before tags. A preheader is deliberately padded with zero-width entities, and decoding those first would turn the padding into real characters and make every length count downstream wrong.
|
|
86
86
|
*/
|
|
87
87
|
export function stripMarkup(raw) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
88
|
+
const text = raw
|
|
89
|
+
.replace(/<(script|style)[\s\S]*?<\/\1>/gi, " ")
|
|
90
|
+
// A markup comment is a note to the next developer, not copy.
|
|
91
|
+
|
|
92
|
+
// It goes with the script block, for the same reason: the CBAM pages rule their sections with `<!-- name -->` wrapped in rows of em dashes, which reported 8 dashes nobody reads.
|
|
93
|
+
.replace(/<!--[\s\S]*?-->/g, " ")
|
|
94
|
+
.replace(/&[a-z]+;|&#\d+;/gi, " ")
|
|
95
|
+
.replace(/<[^>]+>/g, " ");
|
|
96
|
+
// Svelte and Vue control blocks are code that survives tag stripping, and their loop variables read as prose: `{#each items as row,
|
|
97
|
+
|
|
98
|
+
// i (row)}` counted `i` as a first-person pronoun and failed 3 pages on the pronoun ledger.
|
|
99
|
+
|
|
100
|
+
// Only `{#`, `{:`, `{/` and `{@` go; a plain `{value}` interpolation is left alone, because the copy it stands for is audited where it is written.
|
|
101
|
+
return withoutTemplateTags(text)
|
|
102
|
+
.replace(/[ \t]+/g, " ")
|
|
103
|
+
.trim();
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Drops every `{#`, `{:`, `{/` and `{@` block up to its balancing brace, skipping braces inside quotes.
|
|
108
|
+
*/
|
|
109
|
+
|
|
110
|
+
/*
|
|
111
|
+
* A `[^}]*` regex stopped at the first nested brace, so a JSON-LD object inside `{@html}` read as copy and failed `comma-run` on a CBAM news page, 27 Oct 2026.
|
|
112
|
+
*/
|
|
113
|
+
export function withoutTemplateTags(text) {
|
|
114
|
+
let out = "";
|
|
115
|
+
let i = 0;
|
|
116
|
+
while (i < text.length) {
|
|
117
|
+
if (text[i] !== "{" || !"#:/@".includes(text[i + 1] ?? "")) {
|
|
118
|
+
out += text[i++];
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
let depth = 0;
|
|
122
|
+
let quote = "";
|
|
123
|
+
let j = i;
|
|
124
|
+
for (; j < text.length; j++) {
|
|
125
|
+
const c = text[j];
|
|
126
|
+
if (quote) {
|
|
127
|
+
if (c === "\\") j++;
|
|
128
|
+
else if (c === quote) quote = "";
|
|
129
|
+
} else if (c === '"' || c === "'" || c === "`") quote = c;
|
|
130
|
+
else if (c === "{") depth++;
|
|
131
|
+
else if (c === "}" && --depth === 0) break;
|
|
132
|
+
}
|
|
133
|
+
out += " ";
|
|
134
|
+
i = j + 1;
|
|
135
|
+
}
|
|
136
|
+
return out;
|
|
108
137
|
}
|
|
109
138
|
|
|
110
139
|
const isPictographic = (ch) => /\p{Extended_Pictographic}/u.test(ch);
|