@lit-pigeon/lint 0.1.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/LICENSE +21 -0
- package/dist/async-rules/concurrency.d.ts +7 -0
- package/dist/async-rules/concurrency.d.ts.map +1 -0
- package/dist/async-rules/concurrency.js +30 -0
- package/dist/async-rules/concurrency.js.map +1 -0
- package/dist/async-rules/image-weight.d.ts +8 -0
- package/dist/async-rules/image-weight.d.ts.map +1 -0
- package/dist/async-rules/image-weight.js +69 -0
- package/dist/async-rules/image-weight.js.map +1 -0
- package/dist/async-rules/link-reachability.d.ts +8 -0
- package/dist/async-rules/link-reachability.d.ts.map +1 -0
- package/dist/async-rules/link-reachability.js +51 -0
- package/dist/async-rules/link-reachability.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/lint.d.ts +16 -0
- package/dist/lint.d.ts.map +1 -0
- package/dist/lint.js +91 -0
- package/dist/lint.js.map +1 -0
- package/dist/rules/alt-text.d.ts +8 -0
- package/dist/rules/alt-text.d.ts.map +1 -0
- package/dist/rules/alt-text.js +45 -0
- package/dist/rules/alt-text.js.map +1 -0
- package/dist/rules/contrast.d.ts +9 -0
- package/dist/rules/contrast.d.ts.map +1 -0
- package/dist/rules/contrast.js +74 -0
- package/dist/rules/contrast.js.map +1 -0
- package/dist/rules/empty-content.d.ts +8 -0
- package/dist/rules/empty-content.d.ts.map +1 -0
- package/dist/rules/empty-content.js +34 -0
- package/dist/rules/empty-content.js.map +1 -0
- package/dist/rules/links.d.ts +7 -0
- package/dist/rules/links.d.ts.map +1 -0
- package/dist/rules/links.js +53 -0
- package/dist/rules/links.js.map +1 -0
- package/dist/rules/merge-tags.d.ts +8 -0
- package/dist/rules/merge-tags.d.ts.map +1 -0
- package/dist/rules/merge-tags.js +57 -0
- package/dist/rules/merge-tags.js.map +1 -0
- package/dist/rules/preview-text.d.ts +8 -0
- package/dist/rules/preview-text.d.ts.map +1 -0
- package/dist/rules/preview-text.js +48 -0
- package/dist/rules/preview-text.js.map +1 -0
- package/dist/rules/spam-score.d.ts +8 -0
- package/dist/rules/spam-score.d.ts.map +1 -0
- package/dist/rules/spam-score.js +114 -0
- package/dist/rules/spam-score.js.map +1 -0
- package/dist/types.d.ts +62 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/walk.d.ts +23 -0
- package/dist/walk.d.ts.map +1 -0
- package/dist/walk.js +33 -0
- package/dist/walk.js.map +1 -0
- package/package.json +42 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Lit Pigeon Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run `worker` against every `item` with at most `limit` in flight at once.
|
|
3
|
+
* Used by the network rules to keep the lint pass from opening hundreds of
|
|
4
|
+
* sockets against the same origin.
|
|
5
|
+
*/
|
|
6
|
+
export declare function mapWithLimit<T, R>(items: T[], limit: number, worker: (item: T, index: number) => Promise<R>): Promise<R[]>;
|
|
7
|
+
//# sourceMappingURL=concurrency.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"concurrency.d.ts","sourceRoot":"","sources":["../../src/async-rules/concurrency.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAAE,CAAC,EACrC,KAAK,EAAE,CAAC,EAAE,EACV,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,GAC7C,OAAO,CAAC,CAAC,EAAE,CAAC,CAuBd"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run `worker` against every `item` with at most `limit` in flight at once.
|
|
3
|
+
* Used by the network rules to keep the lint pass from opening hundreds of
|
|
4
|
+
* sockets against the same origin.
|
|
5
|
+
*/
|
|
6
|
+
export async function mapWithLimit(items, limit, worker) {
|
|
7
|
+
if (items.length === 0)
|
|
8
|
+
return [];
|
|
9
|
+
const results = new Array(items.length);
|
|
10
|
+
const queue = items.map((item, index) => ({ item, index }));
|
|
11
|
+
const active = [];
|
|
12
|
+
while (queue.length > 0 || active.length > 0) {
|
|
13
|
+
while (active.length < limit && queue.length > 0) {
|
|
14
|
+
const { item, index } = queue.shift();
|
|
15
|
+
const promise = worker(item, index)
|
|
16
|
+
.then((value) => {
|
|
17
|
+
results[index] = value;
|
|
18
|
+
})
|
|
19
|
+
.finally(() => {
|
|
20
|
+
active.splice(active.indexOf(promise), 1);
|
|
21
|
+
});
|
|
22
|
+
active.push(promise);
|
|
23
|
+
}
|
|
24
|
+
if (active.length > 0) {
|
|
25
|
+
await Promise.race(active);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return results;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=concurrency.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"concurrency.js","sourceRoot":"","sources":["../../src/async-rules/concurrency.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,KAAU,EACV,KAAa,EACb,MAA8C;IAE9C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAClC,MAAM,OAAO,GAAQ,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC7C,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IAC5D,MAAM,MAAM,GAAoB,EAAE,CAAC;IAEnC,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7C,OAAO,MAAM,CAAC,MAAM,GAAG,KAAK,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACjD,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC,KAAK,EAAG,CAAC;YACvC,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC;iBAChC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;gBACd,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC;YACzB,CAAC,CAAC;iBACD,OAAO,CAAC,GAAG,EAAE;gBACZ,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;YAC5C,CAAC,CAAC,CAAC;YACL,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;QACD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtB,MAAM,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AsyncLintRule } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* HEAD-request every absolute http(s) image URL and warn when the
|
|
4
|
+
* Content-Length is heavy. Big inline images blow past Gmail's 102 kB clip
|
|
5
|
+
* threshold and absolutely tank mobile open performance.
|
|
6
|
+
*/
|
|
7
|
+
export declare const imageWeightRule: AsyncLintRule;
|
|
8
|
+
//# sourceMappingURL=image-weight.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-weight.d.ts","sourceRoot":"","sources":["../../src/async-rules/image-weight.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAa,MAAM,aAAa,CAAC;AAc5D;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,aA+C7B,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { collectBlocks, readString } from '../walk.js';
|
|
2
|
+
import { mapWithLimit } from './concurrency.js';
|
|
3
|
+
const IMAGE_KEYS = ['src', 'posterUrl', 'imageUrl', 'backgroundUrl'];
|
|
4
|
+
const WARN_BYTES = 1_000_000; // 1 MB
|
|
5
|
+
const ERROR_BYTES = 3_000_000; // 3 MB
|
|
6
|
+
/**
|
|
7
|
+
* HEAD-request every absolute http(s) image URL and warn when the
|
|
8
|
+
* Content-Length is heavy. Big inline images blow past Gmail's 102 kB clip
|
|
9
|
+
* threshold and absolutely tank mobile open performance.
|
|
10
|
+
*/
|
|
11
|
+
export const imageWeightRule = {
|
|
12
|
+
id: 'image-weight',
|
|
13
|
+
description: 'Hosted images larger than 1 MB warn; over 3 MB errors.',
|
|
14
|
+
async check(doc, fetcher) {
|
|
15
|
+
const refs = [];
|
|
16
|
+
for (const hit of collectBlocks(doc)) {
|
|
17
|
+
for (const key of IMAGE_KEYS) {
|
|
18
|
+
const url = readString(hit.block, key).trim();
|
|
19
|
+
if (/^https?:\/\//i.test(url)) {
|
|
20
|
+
refs.push({ url, path: `${hit.path}.values.${key}`, blockId: hit.block.id });
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (refs.length === 0)
|
|
25
|
+
return [];
|
|
26
|
+
const results = await mapWithLimit(refs, 8, async (ref) => {
|
|
27
|
+
try {
|
|
28
|
+
const res = await fetcher(ref.url, { method: 'HEAD' });
|
|
29
|
+
if (!res.ok)
|
|
30
|
+
return null; // link-reachability rule reports unreachable links.
|
|
31
|
+
const lenHeader = res.headers.get('content-length');
|
|
32
|
+
const bytes = lenHeader ? Number(lenHeader) : NaN;
|
|
33
|
+
if (!Number.isFinite(bytes) || bytes <= 0)
|
|
34
|
+
return null;
|
|
35
|
+
if (bytes >= ERROR_BYTES) {
|
|
36
|
+
return {
|
|
37
|
+
rule: 'image-weight/oversized',
|
|
38
|
+
severity: 'error',
|
|
39
|
+
message: `Image is ${formatBytes(bytes)} (>3 MB) — likely to be clipped by Gmail and slow on mobile.`,
|
|
40
|
+
path: ref.path,
|
|
41
|
+
blockId: ref.blockId,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
if (bytes >= WARN_BYTES) {
|
|
45
|
+
return {
|
|
46
|
+
rule: 'image-weight/heavy',
|
|
47
|
+
severity: 'warning',
|
|
48
|
+
message: `Image is ${formatBytes(bytes)} — consider compressing under 1 MB.`,
|
|
49
|
+
path: ref.path,
|
|
50
|
+
blockId: ref.blockId,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
return results.filter((entry) => entry !== null);
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
function formatBytes(n) {
|
|
63
|
+
if (n >= 1_000_000)
|
|
64
|
+
return `${(n / 1_000_000).toFixed(1)} MB`;
|
|
65
|
+
if (n >= 1_000)
|
|
66
|
+
return `${(n / 1_000).toFixed(0)} kB`;
|
|
67
|
+
return `${n} B`;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=image-weight.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-weight.js","sourceRoot":"","sources":["../../src/async-rules/image-weight.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,MAAM,UAAU,GAAG,CAAC,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,eAAe,CAAC,CAAC;AACrE,MAAM,UAAU,GAAG,SAAS,CAAC,CAAC,OAAO;AACrC,MAAM,WAAW,GAAG,SAAS,CAAC,CAAC,OAAO;AAQtC;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAkB;IAC5C,EAAE,EAAE,cAAc;IAClB,WAAW,EAAE,wDAAwD;IACrE,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO;QACtB,MAAM,IAAI,GAAe,EAAE,CAAC;QAC5B,KAAK,MAAM,GAAG,IAAI,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC;YACrC,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;gBAC7B,MAAM,GAAG,GAAG,UAAU,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;gBA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AC;oBACxB,OAAO;wBACL,IAAI,EAAE,oBAAoB;wBAC1B,QAAQ,EAAE,SAAS;wBACnB,OAAO,EAAE,YAAY,WAAW,CAAC,KAAK,CAAC,qCAAqC;wBAC5E,IAAI,EAAE,GAAG,CAAC,IAAI;wBACd,OAAO,EAAE,GAAG,CAAC,OAAO;qBACrB,CAAC;gBACJ,CAAC;gBACD,OAAO,IAAI,CAAC;YACd,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC,CAAC,CAAC;QACH,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,EAAsB,EAAE,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC;IACvE,CAAC;CACF,CAAC;AAEF,SAAS,WAAW,CAAC,CAAS;IAC5B,IAAI,CAAC,IAAI,SAAS;QAAE,OAAO,GAAG,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;IAC9D,IAAI,CAAC,IAAI,KAAK;QAAE,OAAO,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;IACtD,OAAO,GAAG,CAAC,IAAI,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AsyncLintRule } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* HEAD-request every http(s) `href` to catch dead destinations. Most servers
|
|
4
|
+
* answer HEAD; those that don't show up as 405 — we treat that as reachable
|
|
5
|
+
* because the server clearly exists.
|
|
6
|
+
*/
|
|
7
|
+
export declare const linkReachabilityRule: AsyncLintRule;
|
|
8
|
+
//# sourceMappingURL=link-reachability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link-reachability.d.ts","sourceRoot":"","sources":["../../src/async-rules/link-reachability.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAa,MAAM,aAAa,CAAC;AAY5D;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,EAAE,aAuClC,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { collectBlocks, readString } from '../walk.js';
|
|
2
|
+
import { mapWithLimit } from './concurrency.js';
|
|
3
|
+
const URL_KEYS = ['href', 'videoUrl'];
|
|
4
|
+
/**
|
|
5
|
+
* HEAD-request every http(s) `href` to catch dead destinations. Most servers
|
|
6
|
+
* answer HEAD; those that don't show up as 405 — we treat that as reachable
|
|
7
|
+
* because the server clearly exists.
|
|
8
|
+
*/
|
|
9
|
+
export const linkReachabilityRule = {
|
|
10
|
+
id: 'link-reachability',
|
|
11
|
+
description: 'Click-through links must return a 2xx/3xx status (or 405 on HEAD).',
|
|
12
|
+
async check(doc, fetcher) {
|
|
13
|
+
const refs = [];
|
|
14
|
+
for (const hit of collectBlocks(doc)) {
|
|
15
|
+
for (const key of URL_KEYS) {
|
|
16
|
+
const url = readString(hit.block, key).trim();
|
|
17
|
+
if (/^https?:\/\//i.test(url)) {
|
|
18
|
+
refs.push({ url, path: `${hit.path}.values.${key}`, blockId: hit.block.id });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if (refs.length === 0)
|
|
23
|
+
return [];
|
|
24
|
+
const results = await mapWithLimit(refs, 8, async (ref) => {
|
|
25
|
+
try {
|
|
26
|
+
const res = await fetcher(ref.url, { method: 'HEAD' });
|
|
27
|
+
if (res.ok || res.status === 405)
|
|
28
|
+
return null;
|
|
29
|
+
return {
|
|
30
|
+
rule: 'link-reachability/broken',
|
|
31
|
+
severity: 'warning',
|
|
32
|
+
message: `URL "${ref.url}" returned ${res.status} on HEAD.`,
|
|
33
|
+
path: ref.path,
|
|
34
|
+
blockId: ref.blockId,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
39
|
+
return {
|
|
40
|
+
rule: 'link-reachability/unreachable',
|
|
41
|
+
severity: 'warning',
|
|
42
|
+
message: `URL "${ref.url}" did not respond: ${message}.`,
|
|
43
|
+
path: ref.path,
|
|
44
|
+
blockId: ref.blockId,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
return results.filter((entry) => entry !== null);
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=link-reachability.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link-reachability.js","sourceRoot":"","sources":["../../src/async-rules/link-reachability.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,MAAM,QAAQ,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAQtC;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAkB;IACjD,EAAE,EAAE,mBAAmB;IACvB,WAAW,EAAE,oEAAoE;IACjF,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO;QACtB,MAAM,IAAI,GAAc,EAAE,CAAC;QAC3B,KAAK,MAAM,GAAG,IAAI,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC;YACrC,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;gBAC3B,MAAM,GAAG,GAAG,UAAU,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;gBAC9C,IAAI,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;oBAC9B,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,GAAG,CAAC,IAAI,WAAW,GAAG,EAAE,EAAE,OAAO,EAAE,GAAG,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;gBAC/E,CAAC;YACH,CAAC;QACH,CAAC;QACD,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aultRules, defaultAsyncRules } from './lint.js';
|
|
2
|
+
export type { AsyncLintOptions, AsyncLintRule, LintFetcher, LintIssue, LintOptions, LintReport, LintRule, LintSeverity, } from './types.js';
|
|
3
|
+
export { altTextRule } from './rules/alt-text.js';
|
|
4
|
+
export { linksRule } from './rules/links.js';
|
|
5
|
+
export { contrastRule } from './rules/contrast.js';
|
|
6
|
+
export { previewTextRule } from './rules/preview-text.js';
|
|
7
|
+
export { spamScoreRule } from './rules/spam-score.js';
|
|
8
|
+
export { mergeTagsRule } from './rules/merge-tags.js';
|
|
9
|
+
export { emptyContentRule } from './rules/empty-content.js';
|
|
10
|
+
export { imageWeightRule } from './async-rules/image-weight.js';
|
|
11
|
+
export { linkReachabilityRule } from './async-rules/link-reachability.js';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC7F,YAAY,EACV,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,SAAS,EACT,WAAW,EACX,UAAU,EACV,QAAQ,EACR,YAAY,GACb,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { lintDocument, lintDocumentAsync, defaultRules, defaultAsyncRules } from './lint.js';
|
|
2
|
+
// Individual rule exports so callers can compose a custom rule set.
|
|
3
|
+
export { altTextRule } from './rules/alt-text.js';
|
|
4
|
+
export { linksRule } from './rules/links.js';
|
|
5
|
+
export { contrastRule } from './rules/contrast.js';
|
|
6
|
+
export { previewTextRule } from './rules/preview-text.js';
|
|
7
|
+
export { spamScoreRule } from './rules/spam-score.js';
|
|
8
|
+
export { mergeTagsRule } from './rules/merge-tags.js';
|
|
9
|
+
export { emptyContentRule } from './rules/empty-content.js';
|
|
10
|
+
export { imageWeightRule } from './async-rules/image-weight.js';
|
|
11
|
+
export { linkReachabilityRule } from './async-rules/link-reachability.js';
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAY7F,oEAAoE;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC"}
|
package/dist/lint.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { PigeonDocument } from '@lit-pigeon/core';
|
|
2
|
+
import type { AsyncLintOptions, AsyncLintRule, LintOptions, LintReport, LintRule } from './types.js';
|
|
3
|
+
export declare const defaultRules: LintRule[];
|
|
4
|
+
export declare const defaultAsyncRules: AsyncLintRule[];
|
|
5
|
+
/**
|
|
6
|
+
* Run every static rule against the document and return a sorted, summarised
|
|
7
|
+
* report. Pure, fast, no network — safe to call on every keystroke if desired.
|
|
8
|
+
*/
|
|
9
|
+
export declare function lintDocument(doc: PigeonDocument, options?: LintOptions): LintReport;
|
|
10
|
+
/**
|
|
11
|
+
* Run every static rule plus the configured async (network) rules. Use this
|
|
12
|
+
* in CI / pre-send hooks where slower checks like HEAD-request image-weight
|
|
13
|
+
* are acceptable.
|
|
14
|
+
*/
|
|
15
|
+
export declare function lintDocumentAsync(doc: PigeonDocument, options?: AsyncLintOptions): Promise<LintReport>;
|
|
16
|
+
//# sourceMappingURL=lint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../src/lint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EACV,gBAAgB,EAChB,aAAa,EAGb,WAAW,EACX,UAAU,EACV,QAAQ,EACT,MAAM,YAAY,CAAC;AAWpB,eAAO,MAAM,YAAY,EAAE,QAAQ,EAQlC,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,aAAa,EAG5C,CAAC;AAEF;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,cAAc,EACnB,OAAO,GAAE,WAAgB,GACxB,UAAU,CAIZ;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,cAAc,EACnB,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,UAAU,CAAC,CA4BrB"}
|
package/dist/lint.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { altTextRule } from './rules/alt-text.js';
|
|
2
|
+
import { linksRule } from './rules/links.js';
|
|
3
|
+
import { contrastRule } from './rules/contrast.js';
|
|
4
|
+
import { previewTextRule } from './rules/preview-text.js';
|
|
5
|
+
import { spamScoreRule } from './rules/spam-score.js';
|
|
6
|
+
import { mergeTagsRule } from './rules/merge-tags.js';
|
|
7
|
+
import { emptyContentRule } from './rules/empty-content.js';
|
|
8
|
+
import { imageWeightRule } from './async-rules/image-weight.js';
|
|
9
|
+
import { linkReachabilityRule } from './async-rules/link-reachability.js';
|
|
10
|
+
export const defaultRules = [
|
|
11
|
+
altTextRule,
|
|
12
|
+
linksRule,
|
|
13
|
+
contrastRule,
|
|
14
|
+
previewTextRule,
|
|
15
|
+
spamScoreRule,
|
|
16
|
+
mergeTagsRule,
|
|
17
|
+
emptyContentRule,
|
|
18
|
+
];
|
|
19
|
+
export const defaultAsyncRules = [
|
|
20
|
+
imageWeightRule,
|
|
21
|
+
linkReachabilityRule,
|
|
22
|
+
];
|
|
23
|
+
/**
|
|
24
|
+
* Run every static rule against the document and return a sorted, summarised
|
|
25
|
+
* report. Pure, fast, no network — safe to call on every keystroke if desired.
|
|
26
|
+
*/
|
|
27
|
+
export function lintDocument(doc, options = {}) {
|
|
28
|
+
const rules = options.rules ?? defaultRules;
|
|
29
|
+
const issues = rules.flatMap((rule) => rule.check(doc));
|
|
30
|
+
return finalise(issues);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Run every static rule plus the configured async (network) rules. Use this
|
|
34
|
+
* in CI / pre-send hooks where slower checks like HEAD-request image-weight
|
|
35
|
+
* are acceptable.
|
|
36
|
+
*/
|
|
37
|
+
export async function lintDocumentAsync(doc, options = {}) {
|
|
38
|
+
const sync = lintDocument(doc, options);
|
|
39
|
+
const asyncRules = options.asyncRules ?? defaultAsyncRules;
|
|
40
|
+
const fetcher = options.fetcher ?? globalThis.fetch;
|
|
41
|
+
if (!fetcher || asyncRules.length === 0) {
|
|
42
|
+
return sync;
|
|
43
|
+
}
|
|
44
|
+
const settled = await Promise.allSettled(asyncRules.map((rule) => rule.check(doc, wrapFetcher(fetcher, options.timeoutMs ?? 5000))));
|
|
45
|
+
const asyncIssues = [];
|
|
46
|
+
settled.forEach((entry, idx) => {
|
|
47
|
+
if (entry.status === 'fulfilled') {
|
|
48
|
+
asyncIssues.push(...entry.value);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
asyncIssues.push({
|
|
52
|
+
rule: `${asyncRules[idx].id}/crashed`,
|
|
53
|
+
severity: 'warning',
|
|
54
|
+
message: `Lint rule "${asyncRules[idx].id}" failed: ${entry.reason instanceof Error ? entry.reason.message : String(entry.reason)}`,
|
|
55
|
+
path: '',
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
return finalise([...sync.issues, ...asyncIssues]);
|
|
60
|
+
}
|
|
61
|
+
function finalise(issues) {
|
|
62
|
+
const sorted = [...issues].sort((a, b) => severityRank(a.severity) - severityRank(b.severity));
|
|
63
|
+
return {
|
|
64
|
+
issues: sorted,
|
|
65
|
+
summary: {
|
|
66
|
+
errors: sorted.filter((i) => i.severity === 'error').length,
|
|
67
|
+
warnings: sorted.filter((i) => i.severity === 'warning').length,
|
|
68
|
+
infos: sorted.filter((i) => i.severity === 'info').length,
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function severityRank(s) {
|
|
73
|
+
return s === 'error' ? 0 : s === 'warning' ? 1 : 2;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Wrap a fetcher with a per-request AbortSignal so a stuck server can't hang
|
|
77
|
+
* the entire lint pass.
|
|
78
|
+
*/
|
|
79
|
+
function wrapFetcher(fetcher, timeoutMs) {
|
|
80
|
+
return async (url, init) => {
|
|
81
|
+
const controller = new AbortController();
|
|
82
|
+
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
83
|
+
try {
|
|
84
|
+
return await fetcher(url, { ...init, signal: controller.signal });
|
|
85
|
+
}
|
|
86
|
+
finally {
|
|
87
|
+
clearTimeout(timeout);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=lint.js.map
|
package/dist/lint.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lint.js","sourceRoot":"","sources":["../src/lint.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE1E,MAAM,CAAC,MAAM,YAAY,GAAe;IACtC,WAAW;IACX,SAAS;IACT,YAAY;IACZ,eAAe;IACf,aAAa;IACb,aAAa;IACb,gBAAgB;CACjB,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAoB;IAChD,eAAe;IACf,oBAAoB;CACrB,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,YAAY,CAC1B,GAAmB,EACnB,UAAuB,EAAE;IAEzB,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,YAAY,CAAC;IAC5C,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,C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AAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;QACzC,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,SAAS,CAAC,CAAC;QAChE,IAAI,CAAC;YACH,OAAO,MAAM,OAAO,CAAC,GAAG,EAAE,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;QACpE,CAAC;gBAAS,CAAC;YACT,YAAY,CAAC,OAAO,CAAC,CAAC;QACxB,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { LintRule } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Every visible image must have non-empty alt text so screen readers and
|
|
4
|
+
* image-blocked email clients can describe the content. Custom blocks
|
|
5
|
+
* with a `src` value are also covered.
|
|
6
|
+
*/
|
|
7
|
+
export declare const altTextRule: LintRule;
|
|
8
|
+
//# sourceMappingURL=alt-text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alt-text.d.ts","sourceRoot":"","sources":["../../src/rules/alt-text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,QAAQ,EAAE,MAAM,aAAa,CAAC;AAKvD;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,QAmCzB,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { collectBlocks, readString } from '../walk.js';
|
|
2
|
+
const IMAGE_LIKE_TYPES = new Set(['image', 'hero', 'video', 'countdown', 'carousel']);
|
|
3
|
+
/**
|
|
4
|
+
* Every visible image must have non-empty alt text so screen readers and
|
|
5
|
+
* image-blocked email clients can describe the content. Custom blocks
|
|
6
|
+
* with a `src` value are also covered.
|
|
7
|
+
*/
|
|
8
|
+
export const altTextRule = {
|
|
9
|
+
id: 'alt-text',
|
|
10
|
+
description: 'Images must carry non-empty alt text.',
|
|
11
|
+
check(doc) {
|
|
12
|
+
const issues = [];
|
|
13
|
+
for (const hit of collectBlocks(doc)) {
|
|
14
|
+
// Only rules out blocks that clearly aren't image-like, so custom blocks
|
|
15
|
+
// with a `src` field are still linted.
|
|
16
|
+
const isImageLike = IMAGE_LIKE_TYPES.has(hit.block.type) ||
|
|
17
|
+
Boolean(readString(hit.block, 'src')) ||
|
|
18
|
+
Boolean(readString(hit.block, 'posterUrl')) ||
|
|
19
|
+
Boolean(readString(hit.block, 'imageUrl'));
|
|
20
|
+
if (!isImageLike)
|
|
21
|
+
continue;
|
|
22
|
+
const alt = readString(hit.block, 'alt').trim();
|
|
23
|
+
if (!alt) {
|
|
24
|
+
issues.push({
|
|
25
|
+
rule: 'alt-text/missing',
|
|
26
|
+
severity: 'error',
|
|
27
|
+
message: `Image block "${hit.block.type}" has no alt text.`,
|
|
28
|
+
path: `${hit.path}.values.alt`,
|
|
29
|
+
blockId: hit.block.id,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
else if (alt.length > 125) {
|
|
33
|
+
issues.push({
|
|
34
|
+
rule: 'alt-text/too-long',
|
|
35
|
+
severity: 'warning',
|
|
36
|
+
message: `Alt text is ${alt.length} chars; keep it under 125 for screen-reader clarity.`,
|
|
37
|
+
path: `${hit.path}.values.alt`,
|
|
38
|
+
blockId: hit.block.id,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return issues;
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=alt-text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alt-text.js","sourceRoot":"","sources":["../../src/rules/alt-text.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEvD,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC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AI,EAAE,GAAG,GAAG,CAAC,IAAI,aAAa;oBAC9B,OAAO,EAAE,GAAG,CAAC,KAAK,CAAC,EAAE;iBACtB,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { LintRule } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* WCAG AA contrast check for button text against its background. Other blocks
|
|
4
|
+
* (text, hero) typically style content via HTML that we can't easily parse;
|
|
5
|
+
* buttons expose clean `textColor` + `backgroundColor` values, so they're the
|
|
6
|
+
* highest-leverage target.
|
|
7
|
+
*/
|
|
8
|
+
export declare const contrastRule: LintRule;
|
|
9
|
+
//# sourceMappingURL=contrast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contrast.d.ts","sourceRoot":"","sources":["../../src/rules/contrast.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvD;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAE,QA6B1B,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { collectBlocks } from '../walk.js';
|
|
2
|
+
/**
|
|
3
|
+
* WCAG AA contrast check for button text against its background. Other blocks
|
|
4
|
+
* (text, hero) typically style content via HTML that we can't easily parse;
|
|
5
|
+
* buttons expose clean `textColor` + `backgroundColor` values, so they're the
|
|
6
|
+
* highest-leverage target.
|
|
7
|
+
*/
|
|
8
|
+
export const contrastRule = {
|
|
9
|
+
id: 'contrast',
|
|
10
|
+
description: 'Button text must meet WCAG AA contrast against its background.',
|
|
11
|
+
check(doc) {
|
|
12
|
+
const issues = [];
|
|
13
|
+
for (const hit of collectBlocks(doc)) {
|
|
14
|
+
if (hit.block.type !== 'button')
|
|
15
|
+
continue;
|
|
16
|
+
const values = hit.block.values;
|
|
17
|
+
const fg = parseColor(values.textColor);
|
|
18
|
+
const bg = parseColor(values.backgroundColor);
|
|
19
|
+
if (!fg || !bg)
|
|
20
|
+
continue;
|
|
21
|
+
const ratio = contrastRatio(fg, bg);
|
|
22
|
+
// Large text (>=18pt, or >=14pt bold) needs only 3:1; everything else 4.5:1.
|
|
23
|
+
const isLarge = (values.fontSize ?? 16) >= 18 ||
|
|
24
|
+
((values.fontSize ?? 16) >= 14 && /^(600|700|800|900|bold|bolder)$/i.test(values.fontWeight ?? ''));
|
|
25
|
+
const threshold = isLarge ? 3 : 4.5;
|
|
26
|
+
if (ratio < threshold) {
|
|
27
|
+
issues.push({
|
|
28
|
+
rule: 'contrast/insufficient',
|
|
29
|
+
severity: 'warning',
|
|
30
|
+
message: `Button contrast ratio is ${ratio.toFixed(2)}:1, below WCAG AA (${threshold}:1).`,
|
|
31
|
+
path: hit.path,
|
|
32
|
+
blockId: hit.block.id,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return issues;
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
function parseColor(input) {
|
|
40
|
+
if (!input)
|
|
41
|
+
return null;
|
|
42
|
+
const value = input.trim();
|
|
43
|
+
// #rgb / #rrggbb
|
|
44
|
+
const hex = value.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i);
|
|
45
|
+
if (hex) {
|
|
46
|
+
const v = hex[1];
|
|
47
|
+
const full = v.length === 3 ? v.split('').map((c) => c + c).join('') : v;
|
|
48
|
+
return {
|
|
49
|
+
r: parseInt(full.slice(0, 2), 16),
|
|
50
|
+
g: parseInt(full.slice(2, 4), 16),
|
|
51
|
+
b: parseInt(full.slice(4, 6), 16),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
// rgb(255, 255, 255) — minimal parser, no rgba/percent support
|
|
55
|
+
const rgb = value.match(/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/i);
|
|
56
|
+
if (rgb) {
|
|
57
|
+
return { r: +rgb[1], g: +rgb[2], b: +rgb[3] };
|
|
58
|
+
}
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
function relativeLuminance({ r, g, b }) {
|
|
62
|
+
const channel = (v) => {
|
|
63
|
+
const c = v / 255;
|
|
64
|
+
return c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
|
|
65
|
+
};
|
|
66
|
+
return 0.2126 * channel(r) + 0.7152 * channel(g) + 0.0722 * channel(b);
|
|
67
|
+
}
|
|
68
|
+
function contrastRatio(fg, bg) {
|
|
69
|
+
const l1 = relativeLuminance(fg);
|
|
70
|
+
const l2 = relativeLuminance(bg);
|
|
71
|
+
const [hi, lo] = l1 > l2 ? [l1, l2] : [l2, l1];
|
|
72
|
+
return (hi + 0.05) / (lo + 0.05);
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=contrast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contrast.js","sourceRoot":"","sources":["../../src/rules/contrast.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAa;IACpC,EAAE,EAAE,UAAU;IACd,WAAW,EAAE,gEAAgE;IAC7E,KAAK,CAAC,GAAG;QACP,MAAM,MAAM,GAAgB,EAAE,CAAC;QAC/B,KAAK,MAAM,GAAG,IAAI,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC;YACrC,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,KAAK,QAAQ;gBAAE,SAAS;YAC1C,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,MAAkG,CAAC;YAC5H,MAAM,EAAE,GAAG,UAAU,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YACxC,MAAM,EAAE,GAAG,UAAU,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;YAC9C,IAAI,CAAC,EAAE,IAAI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,OAAO,CAAC,CAAC,CAAC,CAAC;AACzE,CAAC;AAED,SAAS,aAAa,CAAC,EAAO,EAAE,EAAO;IACrC,MAAM,EAAE,GAAG,iBAAiB,CAAC,EAAE,CAAC,CAAC;IACjC,MAAM,EAAE,GAAG,iBAAiB,CAAC,EAAE,CAAC,CAAC;IACjC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IAC/C,OAAO,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { LintRule } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Flag rows/columns with no blocks (they render as empty space) and the
|
|
4
|
+
* whole-document empty case. Cheap, useful for catching author mistakes
|
|
5
|
+
* (added a row, never dropped a block in).
|
|
6
|
+
*/
|
|
7
|
+
export declare const emptyContentRule: LintRule;
|
|
8
|
+
//# sourceMappingURL=empty-content.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"empty-content.d.ts","sourceRoot":"","sources":["../../src/rules/empty-content.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvD;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,EAAE,QA2B9B,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flag rows/columns with no blocks (they render as empty space) and the
|
|
3
|
+
* whole-document empty case. Cheap, useful for catching author mistakes
|
|
4
|
+
* (added a row, never dropped a block in).
|
|
5
|
+
*/
|
|
6
|
+
export const emptyContentRule = {
|
|
7
|
+
id: 'empty-content',
|
|
8
|
+
description: 'Rows and the document body must contain at least one block.',
|
|
9
|
+
check(doc) {
|
|
10
|
+
const issues = [];
|
|
11
|
+
if (doc.body.rows.length === 0) {
|
|
12
|
+
issues.push({
|
|
13
|
+
rule: 'empty-content/no-rows',
|
|
14
|
+
severity: 'error',
|
|
15
|
+
message: 'Document has no rows — the rendered email will be blank.',
|
|
16
|
+
path: 'body.rows',
|
|
17
|
+
});
|
|
18
|
+
return issues;
|
|
19
|
+
}
|
|
20
|
+
doc.body.rows.forEach((row, rowIndex) => {
|
|
21
|
+
const totalBlocks = row.columns.reduce((sum, col) => sum + col.blocks.length, 0);
|
|
22
|
+
if (totalBlocks === 0) {
|
|
23
|
+
issues.push({
|
|
24
|
+
rule: 'empty-content/empty-row',
|
|
25
|
+
severity: 'warning',
|
|
26
|
+
message: 'Row contains no blocks — it will render as empty vertical space.',
|
|
27
|
+
path: `body.rows[${rowIndex}]`,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
return issues;
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=empty-content.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"empty-content.js","sourceRoot":"","sources":["../../src/rules/empty-content.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAa;IACxC,EAAE,EAAE,eAAe;IACnB,WAAW,EAAE,6DAA6D;IAC1E,KAAK,CAAC,GAAG;QACP,MAAM,MAAM,GAAgB,EAAE,CAAC;QAC/B,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC/B,MAAM,CAAC,IAAI,CAAC;gBACV,IAAI,EAAE,uBAAuB;gBAC7B,QAAQ,EAAE,OAAO;gBACjB,OAAO,EAAE,0DAA0D;gBACnE,IAAI,EAAE,WAAW;aAClB,CAAC,CAAC;YACH,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,QAAQ,EAAE,EAAE;YACtC,MAAM,WAAW,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;YACjF,IAAI,WAAW,KAAK,CAAC,EAAE,CAAC;gBACtB,MAAM,CAAC,IAAI,CAAC;oBACV,IAAI,EAAE,yBAAyB;oBAC/B,QAAQ,EAAE,SAAS;oBACnB,OAAO,EAAE,kEAAkE;oBAC3E,IAAI,EAAE,aAAa,QAAQ,GAAG;iBAC/B,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { LintRule } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Catch hrefs that point nowhere — empty strings, `#`, missing protocol,
|
|
4
|
+
* or `javascript:` (always stripped by email clients and a phishing flag).
|
|
5
|
+
*/
|
|
6
|
+
export declare const linksRule: LintRule;
|
|
7
|
+
//# sourceMappingURL=links.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"links.d.ts","sourceRoot":"","sources":["../../src/rules/links.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,QAAQ,EAAE,MAAM,aAAa,CAAC;AAMvD;;;GAGG;AACH,eAAO,MAAM,SAAS,EAAE,QA8CvB,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { collectBlocks, readString } from '../walk.js';
|
|
2
|
+
const URL_KEYS = ['href', 'videoUrl', 'imageUrl', 'src'];
|
|
3
|
+
const ABSOLUTE_OR_KNOWN_PROTOCOLS = /^(https?:|mailto:|tel:|sms:|#|\/|\{\{)/i;
|
|
4
|
+
/**
|
|
5
|
+
* Catch hrefs that point nowhere — empty strings, `#`, missing protocol,
|
|
6
|
+
* or `javascript:` (always stripped by email clients and a phishing flag).
|
|
7
|
+
*/
|
|
8
|
+
export const linksRule = {
|
|
9
|
+
id: 'links',
|
|
10
|
+
description: 'Every link must use an absolute http(s)/mailto/tel scheme.',
|
|
11
|
+
check(doc) {
|
|
12
|
+
const issues = [];
|
|
13
|
+
for (const hit of collectBlocks(doc)) {
|
|
14
|
+
for (const key of URL_KEYS) {
|
|
15
|
+
const raw = readString(hit.block, key).trim();
|
|
16
|
+
if (!raw)
|
|
17
|
+
continue;
|
|
18
|
+
const lowered = raw.toLowerCase();
|
|
19
|
+
if (lowered.startsWith('javascript:')) {
|
|
20
|
+
issues.push({
|
|
21
|
+
rule: 'links/javascript-protocol',
|
|
22
|
+
severity: 'error',
|
|
23
|
+
message: `"${key}" uses javascript: — email clients strip this and treat it as phishing.`,
|
|
24
|
+
path: `${hit.path}.values.${key}`,
|
|
25
|
+
blockId: hit.block.id,
|
|
26
|
+
});
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
if (raw === '#') {
|
|
30
|
+
issues.push({
|
|
31
|
+
rule: 'links/placeholder',
|
|
32
|
+
severity: 'warning',
|
|
33
|
+
message: `"${key}" is "#" — replace with a real destination before sending.`,
|
|
34
|
+
path: `${hit.path}.values.${key}`,
|
|
35
|
+
blockId: hit.block.id,
|
|
36
|
+
});
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (!ABSOLUTE_OR_KNOWN_PROTOCOLS.test(raw)) {
|
|
40
|
+
issues.push({
|
|
41
|
+
rule: 'links/no-scheme',
|
|
42
|
+
severity: 'error',
|
|
43
|
+
message: `"${key}"="${raw}" is not an absolute URL — most clients won't render relative links.`,
|
|
44
|
+
path: `${hit.path}.values.${key}`,
|
|
45
|
+
blockId: hit.block.id,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return issues;
|
|
51
|
+
},
|
|
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mB;wBACzB,QAAQ,EAAE,SAAS;wBACnB,OAAO,EAAE,IAAI,GAAG,4DAA4D;wBAC5E,IAAI,EAAE,GAAG,GAAG,CAAC,IAAI,WAAW,GAAG,EAAE;wBACjC,OAAO,EAAE,GAAG,CAAC,KAAK,CAAC,EAAE;qBACtB,CAAC,CAAC;oBACH,SAAS;gBACX,CAAC;gBAED,IAAI,CAAC,2BAA2B,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;oBAC3C,MAAM,CAAC,IAAI,CAAC;wBACV,IAAI,EAAE,iBAAiB;wBACvB,QAAQ,EAAE,OAAO;wBACjB,OAAO,EAAE,IAAI,GAAG,MAAM,GAAG,sEAAsE;wBAC/F,IAAI,EAAE,GAAG,GAAG,CAAC,IAAI,WAAW,GAAG,EAAE;wBACjC,OAAO,EAAE,GAAG,CAAC,KAAK,CAAC,EAAE;qBACtB,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { LintRule } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Catch broken merge tags before they reach the inbox. Unbalanced braces,
|
|
4
|
+
* empty placeholders, and characters that some template engines refuse to
|
|
5
|
+
* accept will all trip this rule.
|
|
6
|
+
*/
|
|
7
|
+
export declare const mergeTagsRule: LintRule;
|
|
8
|
+
//# sourceMappingURL=merge-tags.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge-tags.d.ts","sourceRoot":"","sources":["../../src/rules/merge-tags.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,QAAQ,EAAE,MAAM,aAAa,CAAC;AAMvD;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,QA6C3B,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { collectBlocks } from '../walk.js';
|
|
2
|
+
const VALID_TAG = /^\s*[\w.-]+\s*$/;
|
|
3
|
+
const TAG_PATTERN = /\{\{([^}]*)\}\}/g;
|
|
4
|
+
/**
|
|
5
|
+
* Catch broken merge tags before they reach the inbox. Unbalanced braces,
|
|
6
|
+
* empty placeholders, and characters that some template engines refuse to
|
|
7
|
+
* accept will all trip this rule.
|
|
8
|
+
*/
|
|
9
|
+
export const mergeTagsRule = {
|
|
10
|
+
id: 'merge-tags',
|
|
11
|
+
description: 'Merge tags must be well-formed `{{name}}` placeholders.',
|
|
12
|
+
check(doc) {
|
|
13
|
+
const issues = [];
|
|
14
|
+
for (const hit of collectBlocks(doc)) {
|
|
15
|
+
const values = hit.block.values;
|
|
16
|
+
for (const [key, value] of Object.entries(values)) {
|
|
17
|
+
if (typeof value !== 'string')
|
|
18
|
+
continue;
|
|
19
|
+
const opens = (value.match(/\{\{/g) ?? []).length;
|
|
20
|
+
const closes = (value.match(/\}\}/g) ?? []).length;
|
|
21
|
+
if (opens !== closes) {
|
|
22
|
+
issues.push({
|
|
23
|
+
rule: 'merge-tags/unbalanced',
|
|
24
|
+
severity: 'error',
|
|
25
|
+
message: `"${key}" has ${opens} \`{{\` but ${closes} \`}}\`.`,
|
|
26
|
+
path: `${hit.path}.values.${key}`,
|
|
27
|
+
blockId: hit.block.id,
|
|
28
|
+
});
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
for (const match of value.matchAll(TAG_PATTERN)) {
|
|
32
|
+
const inner = match[1];
|
|
33
|
+
if (!inner.trim()) {
|
|
34
|
+
issues.push({
|
|
35
|
+
rule: 'merge-tags/empty',
|
|
36
|
+
severity: 'error',
|
|
37
|
+
message: 'Empty merge-tag placeholder `{{}}`.',
|
|
38
|
+
path: `${hit.path}.values.${key}`,
|
|
39
|
+
blockId: hit.block.id,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
else if (!VALID_TAG.test(inner)) {
|
|
43
|
+
issues.push({
|
|
44
|
+
rule: 'merge-tags/invalid-name',
|
|
45
|
+
severity: 'warning',
|
|
46
|
+
message: `Merge tag "{{${inner}}}" uses characters most template engines reject.`,
|
|
47
|
+
path: `${hit.path}.values.${key}`,
|
|
48
|
+
blockId: hit.block.id,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return issues;
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=merge-tags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge-tags.js","sourceRoot":"","sources":["../../src/rules/merge-tags.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,SAAS,GAAG,iBAAiB,CAAC;AACpC,MAAM,WAAW,GAAG,kBAAkB,CAAC;AAEvC;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAa;IACrC,EAAE,EAAE,YAAY;IAChB,WAAW,EAAE,yDAAyD;IACtE,KAAK,CAAC,GAAG;QACP,MAAM,MAAM,GAAgB,EAAE,CAAC;QAC/B,KAAK,MAAM,GAAG,IAAI,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC;YACrC,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,MAAiC,CAAC;YAC3D,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;gBAClD,IAAI,OAAO,KAAK,KAAK,QAAQ;oBAAE,SAAS;gBACxC,MAAM,KAAK,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;gBAClD,MAAM,MAAM,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;gBACnD,IAAI,KAAK,KAAK,MAAM,EAAE,CAAC;oBACrB,MAAM,CAAC,IAAI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ox preview text (the snippet shown beside the subject line) drives
|
|
4
|
+
* open rates as much as the subject itself. Empty preview text leaks the
|
|
5
|
+
* email's first words instead. Too long means inboxes truncate mid-thought.
|
|
6
|
+
*/
|
|
7
|
+
export declare const previewTextRule: LintRule;
|
|
8
|
+
//# sourceMappingURL=preview-text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview-text.d.ts","sourceRoot":"","sources":["../../src/rules/preview-text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvD;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,QA0C7B,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inbox preview text (the snippet shown beside the subject line) drives
|
|
3
|
+
* open rates as much as the subject itself. Empty preview text leaks the
|
|
4
|
+
* email's first words instead. Too long means inboxes truncate mid-thought.
|
|
5
|
+
*/
|
|
6
|
+
export const previewTextRule = {
|
|
7
|
+
id: 'preview-text',
|
|
8
|
+
description: 'Inbox preview text should be set and between 35 and 90 characters.',
|
|
9
|
+
check(doc) {
|
|
10
|
+
const issues = [];
|
|
11
|
+
const preview = doc.metadata.previewText?.trim() ?? '';
|
|
12
|
+
const path = 'metadata.previewText';
|
|
13
|
+
if (!preview) {
|
|
14
|
+
issues.push({
|
|
15
|
+
rule: 'preview-text/missing',
|
|
16
|
+
severity: 'warning',
|
|
17
|
+
message: 'No previewText set — inboxes will fall back to the first body text.',
|
|
18
|
+
path,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
else if (preview.length < 35) {
|
|
22
|
+
issues.push({
|
|
23
|
+
rule: 'preview-text/too-short',
|
|
24
|
+
severity: 'info',
|
|
25
|
+
message: `previewText is ${preview.length} chars; aim for 35–90 to fill the inbox snippet.`,
|
|
26
|
+
path,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
else if (preview.length > 90) {
|
|
30
|
+
issues.push({
|
|
31
|
+
rule: 'preview-text/too-long',
|
|
32
|
+
severity: 'info',
|
|
33
|
+
message: `previewText is ${preview.length} chars; most inboxes truncate around 90.`,
|
|
34
|
+
path,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
if (!doc.metadata.name?.trim()) {
|
|
38
|
+
issues.push({
|
|
39
|
+
rule: 'preview-text/missing-subject',
|
|
40
|
+
severity: 'error',
|
|
41
|
+
message: 'metadata.name (the email subject) is empty.',
|
|
42
|
+
path: 'metadata.name',
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return issues;
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=preview-text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview-text.js","sourceRoot":"","sources":["../../src/rules/preview-text.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAa;IACvC,EAAE,EAAE,cAAc;IAClB,WAAW,EAAE,oEAAoE;IACjF,KAAK,CAAC,GAAG;QACP,MAAM,MAAM,GAAgB,EAAE,CAAC;QAC/B,MAAM,OAAO,GAAG,GAAG,CAAC,QAAQ,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QACvD,MAAM,IAAI,GAAG,sBAAsB,CAAC;QAEpC,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,CAAC,IAAI,CAAC;gBACV,IAAI,EAAE,sBAAsB;gBAC5B,QAAQ,EAAE,SAAS;gBACnB,OAAO,EAAE,qEAAqE;gBAC9E,IAAI;aACL,CAAC,CAAC;QACL,CAAC;aAAM,IAAI,OAAO,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;YAC/B,MAAM,CAAC,IAAI,CAAC;gBACV,IAAI,EAAE,wBAAwB;gBAC9B,QAAQ,EAAE,MAAM;gBAChB,OAAO,EAAE,kBAAkB,OAAO,CAAC,MAAM,kDAAkD;gBAC3F,IAAI;aACL,CAAC,CAAC;QACL,CAAC;aAAM,IAAI,OAAO,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;YAC/B,MAAM,CAAC,IAAI,CAAC;gBACV,IAAI,EAAE,uBAAuB;gBAC7B,QAAQ,EAAE,MAAM;gBAChB,OAAO,EAAE,kBAAkB,OAAO,CAAC,MAAM,0CAA0C;gBACnF,IAAI;aACL,CAAC,CAAC;QACL,CAAC;QAED,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC;YAC/B,MAAM,CAAC,IAAI,CAAC;gBACV,IAAI,EAAE,8BAA8B;gBACpC,QAAQ,EAAE,OAAO;gBACjB,OAAO,EAAE,6CAA6C;gBACtD,IAAI,EAAE,eAAe;aACtB,CAAC,CAAC;QACL,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { LintRule } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Crude heuristic spam-score for the *subject* (`metadata.name`) and the
|
|
4
|
+
* first text block — no external API, no perfection, just the obvious
|
|
5
|
+
* Bayesian-spam-filter giveaways. Useful as a smoke check before send.
|
|
6
|
+
*/
|
|
7
|
+
export declare const spamScoreRule: LintRule;
|
|
8
|
+
//# sourceMappingURL=spam-score.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spam-score.d.ts","sourceRoot":"","sources":["../../src/rules/spam-score.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,QAAQ,EAAE,MAAM,aAAa,CAAC;AAyBvD;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,QAkB3B,CAAC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { collectBlocks, readString } from '../walk.js';
|
|
2
|
+
const SPAM_PHRASES = [
|
|
3
|
+
'100% free',
|
|
4
|
+
'act now',
|
|
5
|
+
'best price',
|
|
6
|
+
'cash bonus',
|
|
7
|
+
'click here',
|
|
8
|
+
'congratulations',
|
|
9
|
+
'earn extra cash',
|
|
10
|
+
'free gift',
|
|
11
|
+
'limited time',
|
|
12
|
+
'lose weight',
|
|
13
|
+
'no obligation',
|
|
14
|
+
'order now',
|
|
15
|
+
'risk-free',
|
|
16
|
+
'satisfaction guaranteed',
|
|
17
|
+
'urgent',
|
|
18
|
+
'while supplies last',
|
|
19
|
+
'winner',
|
|
20
|
+
'you have been selected',
|
|
21
|
+
'work from home',
|
|
22
|
+
];
|
|
23
|
+
/**
|
|
24
|
+
* Crude heuristic spam-score for the *subject* (`metadata.name`) and the
|
|
25
|
+
* first text block — no external API, no perfection, just the obvious
|
|
26
|
+
* Bayesian-spam-filter giveaways. Useful as a smoke check before send.
|
|
27
|
+
*/
|
|
28
|
+
export const spamScoreRule = {
|
|
29
|
+
id: 'spam-score',
|
|
30
|
+
description: 'Subject + first text block scanned for common spam-filter tells.',
|
|
31
|
+
check(doc) {
|
|
32
|
+
const issues = [];
|
|
33
|
+
const subject = doc.metadata.name ?? '';
|
|
34
|
+
addSubjectIssues(subject, issues);
|
|
35
|
+
// Body text: scan only the first text-bearing block to avoid noise.
|
|
36
|
+
for (const hit of collectBlocks(doc)) {
|
|
37
|
+
const content = readString(hit.block, 'content');
|
|
38
|
+
if (!content)
|
|
39
|
+
continue;
|
|
40
|
+
addBodyIssues(stripTags(content), `${hit.path}.values.content`, hit.block.id, issues);
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
return issues;
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
function addSubjectIssues(subject, issues) {
|
|
47
|
+
if (!subject)
|
|
48
|
+
return;
|
|
49
|
+
const upperRatio = uppercaseRatio(subject);
|
|
50
|
+
if (subject.length >= 4 && upperRatio > 0.7) {
|
|
51
|
+
issues.push({
|
|
52
|
+
rule: 'spam-score/all-caps-subject',
|
|
53
|
+
severity: 'warning',
|
|
54
|
+
message: `Subject is ${Math.round(upperRatio * 100)}% uppercase — major spam-filter signal.`,
|
|
55
|
+
path: 'metadata.name',
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
const bangs = (subject.match(/!/g) ?? []).length;
|
|
59
|
+
if (bangs >= 3) {
|
|
60
|
+
issues.push({
|
|
61
|
+
rule: 'spam-score/excessive-exclamation',
|
|
62
|
+
severity: 'warning',
|
|
63
|
+
message: `Subject has ${bangs} exclamation marks — strong spam signal.`,
|
|
64
|
+
path: 'metadata.name',
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
const dollarRuns = subject.match(/\${2,}/g) ?? [];
|
|
68
|
+
if (dollarRuns.length > 0) {
|
|
69
|
+
issues.push({
|
|
70
|
+
rule: 'spam-score/dollar-runs',
|
|
71
|
+
severity: 'warning',
|
|
72
|
+
message: 'Subject contains runs of "$" — common spam pattern.',
|
|
73
|
+
path: 'metadata.name',
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
for (const phrase of SPAM_PHRASES) {
|
|
77
|
+
if (subject.toLowerCase().includes(phrase)) {
|
|
78
|
+
issues.push({
|
|
79
|
+
rule: 'spam-score/spam-phrase',
|
|
80
|
+
severity: 'info',
|
|
81
|
+
message: `Subject contains the phrase "${phrase}" — frequent in spam-filter blocklists.`,
|
|
82
|
+
path: 'metadata.name',
|
|
83
|
+
});
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function addBodyIssues(text, path, blockId, issues) {
|
|
89
|
+
const matched = [];
|
|
90
|
+
for (const phrase of SPAM_PHRASES) {
|
|
91
|
+
if (text.toLowerCase().includes(phrase))
|
|
92
|
+
matched.push(phrase);
|
|
93
|
+
}
|
|
94
|
+
if (matched.length >= 2) {
|
|
95
|
+
issues.push({
|
|
96
|
+
rule: 'spam-score/spam-phrases-body',
|
|
97
|
+
severity: 'info',
|
|
98
|
+
message: `First text block hits ${matched.length} spam-list phrases (e.g. "${matched[0]}", "${matched[1]}").`,
|
|
99
|
+
path,
|
|
100
|
+
blockId,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function uppercaseRatio(input) {
|
|
105
|
+
const letters = input.replace(/[^A-Za-z]/g, '');
|
|
106
|
+
if (!letters.length)
|
|
107
|
+
return 0;
|
|
108
|
+
const upper = letters.replace(/[^A-Z]/g, '').length;
|
|
109
|
+
return upper / letters.length;
|
|
110
|
+
}
|
|
111
|
+
function stripTags(html) {
|
|
112
|
+
return html.replace(/<[^>]+>/g, ' ');
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=spam-score.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spam-score.js","sourceRoot":"","sources":["../../src/rules/spam-score.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEvD,MAAM,YAAY,GAAG;IACnB,WAAW;IACX,SAAS;IACT,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,iBAAiB;IACjB,iBAAiB;IACjB,WAAW;IACX,cAAc;IACd,aAAa;IACb,eAAe;IACf,WAAW;IACX,WAAW;IACX,yBAAyB;IACzB,QAAQ;IACR,qBAAqB;IACrB,QAAQ;IACR,wBAAwB;IACxB,gBAAgB;CACjB,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAa;IACrC,EAAE,EAAE,YAAY;IAChB,WAAW,EAAE,kEAAkE;IAC/E,KAAK,CAAC,GAAG;QACP,MAAM,MAAM,GAAgB,EAAE,CAAC;QAC/B,MAAM,OAAO,GAAG,GAAG,CAAC,QAAQ,CAAC,IAAI,IAAI,EAAE,CAAC;QACxC,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAElC,oEAAoE;QACpE,KAAK,MAAM,GAAG,IAAI,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC;YACrC,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG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O,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC;IACpD,OAAO,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC;AAChC,CAAC;AAED,SAAS,SAAS,CAAC,IAAY;IAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;AACvC,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { PigeonDocument } from '@lit-pigeon/core';
|
|
2
|
+
export type LintSeverity = 'error' | 'warning' | 'info';
|
|
3
|
+
export interface LintIssue {
|
|
4
|
+
/** Stable rule id (e.g. `alt-text/missing`). */
|
|
5
|
+
rule: string;
|
|
6
|
+
severity: LintSeverity;
|
|
7
|
+
/** Short, human-readable description of the failure. */
|
|
8
|
+
message: string;
|
|
9
|
+
/** Dot-path into the document, e.g. `body.rows[0].columns[1].blocks[2]`. */
|
|
10
|
+
path: string;
|
|
11
|
+
/** Block id when the issue maps to a single block. */
|
|
12
|
+
blockId?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface LintReport {
|
|
15
|
+
issues: LintIssue[];
|
|
16
|
+
summary: {
|
|
17
|
+
errors: number;
|
|
18
|
+
warnings: number;
|
|
19
|
+
infos: number;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export interface LintRule {
|
|
23
|
+
/** Stable id; prefix with the category, e.g. `links/no-href`. */
|
|
24
|
+
id: string;
|
|
25
|
+
/** One-line description of what the rule catches. */
|
|
26
|
+
description: string;
|
|
27
|
+
check(doc: PigeonDocument): LintIssue[];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A `fetch`-like function used by network rules. Production passes `globalThis.fetch`;
|
|
31
|
+
* tests pass a stub. Only the subset of `fetch` we actually use is required.
|
|
32
|
+
*/
|
|
33
|
+
export type LintFetcher = (url: string, init?: {
|
|
34
|
+
method?: string;
|
|
35
|
+
signal?: AbortSignal;
|
|
36
|
+
}) => Promise<{
|
|
37
|
+
ok: boolean;
|
|
38
|
+
status: number;
|
|
39
|
+
headers: {
|
|
40
|
+
get(name: string): string | null;
|
|
41
|
+
};
|
|
42
|
+
}>;
|
|
43
|
+
export interface AsyncLintRule {
|
|
44
|
+
id: string;
|
|
45
|
+
description: string;
|
|
46
|
+
check(doc: PigeonDocument, fetcher: LintFetcher): Promise<LintIssue[]>;
|
|
47
|
+
}
|
|
48
|
+
export interface LintOptions {
|
|
49
|
+
/** Subset of rules to run. Default: every static rule in {@link defaultRules}. */
|
|
50
|
+
rules?: LintRule[];
|
|
51
|
+
}
|
|
52
|
+
export interface AsyncLintOptions extends LintOptions {
|
|
53
|
+
/** Subset of network rules. Default: every async rule in {@link defaultAsyncRules}. */
|
|
54
|
+
asyncRules?: AsyncLintRule[];
|
|
55
|
+
/** Custom fetcher (e.g. for testing). Default: `globalThis.fetch`. */
|
|
56
|
+
fetcher?: LintFetcher;
|
|
57
|
+
/** Per-request timeout in ms. Default 5000. */
|
|
58
|
+
timeoutMs?: number;
|
|
59
|
+
/** Max parallel network requests. Default 8. */
|
|
60
|
+
concurrency?: number;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AAExD,MAAM,WAAW,SAAS;IACxB,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,YAAY,CAAC;IACvB,wDAAwD;IACxD,OAAO,EAAE,MAAM,CAAC;IAChB,4EAA4E;IAC5E,IAAI,EAAE,MAAM,CAAC;IACb,sDAAsD;IACtD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,UAAU;IACzB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|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/dist/walk.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ColumnNode, ContentBlock, PigeonDocument, RowNode } from '@lit-pigeon/core';
|
|
2
|
+
/** A block plus its location, returned by {@link collectBlocks}. */
|
|
3
|
+
export interface BlockHit {
|
|
4
|
+
block: ContentBlock;
|
|
5
|
+
row: RowNode;
|
|
6
|
+
column: ColumnNode;
|
|
7
|
+
rowIndex: number;
|
|
8
|
+
columnIndex: number;
|
|
9
|
+
blockIndex: number;
|
|
10
|
+
path: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Return every block in document order along with its location info.
|
|
14
|
+
* Tiny by definition (one entry per block) so the array allocation is fine.
|
|
15
|
+
*/
|
|
16
|
+
export declare function collectBlocks(doc: PigeonDocument): BlockHit[];
|
|
17
|
+
/**
|
|
18
|
+
* Read a string-valued field from `block.values`, returning `fallback` when
|
|
19
|
+
* absent or of the wrong type. Lets each rule inspect URLs / alt text / etc.
|
|
20
|
+
* without re-narrowing the block's union shape.
|
|
21
|
+
*/
|
|
22
|
+
export declare function readString(block: ContentBlock, key: string, fallback?: string): string;
|
|
23
|
+
//# sourceMappingURL=walk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"walk.d.ts","sourceRoot":"","sources":["../src/walk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,YAAY,EACZ,cAAc,EACd,OAAO,EACR,MAAM,kBAAkB,CAAC;AAE1B,oEAAoE;AACpE,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,YAAY,CAAC;IACpB,GAAG,EAAE,OAAO,CAAC;IACb,MAAM,EAAE,UAAU,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,cAAc,GAAG,QAAQ,EAAE,CAkB7D;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,YAAY,EACnB,GAAG,EAAE,MAAM,EACX,QAAQ,SAAK,GACZ,MAAM,CAGR"}
|
package/dist/walk.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return every block in document order along with its location info.
|
|
3
|
+
* Tiny by definition (one entry per block) so the array allocation is fine.
|
|
4
|
+
*/
|
|
5
|
+
export function collectBlocks(doc) {
|
|
6
|
+
const hits = [];
|
|
7
|
+
doc.body.rows.forEach((row, rowIndex) => {
|
|
8
|
+
row.columns.forEach((column, columnIndex) => {
|
|
9
|
+
column.blocks.forEach((block, blockIndex) => {
|
|
10
|
+
hits.push({
|
|
11
|
+
block,
|
|
12
|
+
row,
|
|
13
|
+
column,
|
|
14
|
+
rowIndex,
|
|
15
|
+
columnIndex,
|
|
16
|
+
blockIndex,
|
|
17
|
+
path: `body.rows[${rowIndex}].columns[${columnIndex}].blocks[${blockIndex}]`,
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
return hits;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Read a string-valued field from `block.values`, returning `fallback` when
|
|
26
|
+
* absent or of the wrong type. Lets each rule inspect URLs / alt text / etc.
|
|
27
|
+
* without re-narrowing the block's union shape.
|
|
28
|
+
*/
|
|
29
|
+
export function readString(block, key, fallback = '') {
|
|
30
|
+
const v = block.values?.[key];
|
|
31
|
+
return typeof v === 'string' ? v : fallback;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=walk.js.map
|
package/dist/walk.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"walk.js","sourceRoot":"","sources":["../src/walk.ts"],"names":[],"mappings":"AAkBA;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,GAAmB;IAC/C,MAAM,IAAI,GAAe,EAAE,CAAC;IAC5B,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,QAAQ,EAAE,EAAE;QACtC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE;YAC1C,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE;gBAC1C,IAAI,CAAC,IAAI,CAAC;oBACR,KAAK;oBACL,GAAG;oBACH,MAAM;oBACN,QAAQ;oBACR,WAAW;oBACX,UAAU;oBACV,IAAI,EAAE,aAAa,QAAQ,aAAa,WAAW,YAAY,UAAU,GAAG;iBAC7E,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CACxB,KAAmB,EACnB,GAAW,EACX,QAAQ,GAAG,EAAE;IAEb,MAAM,CAAC,GAAI,KAAwD,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC;IAClF,OAAO,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;AAC9C,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lit-pigeon/lint",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Pre-flight QA for Lit Pigeon documents — alt text, contrast, link, merge-tag, spam-score, image-weight, and link-reachability checks.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@lit-pigeon/core": "0.1.0"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@types/node": "^25.9.1",
|
|
23
|
+
"typescript": "^5.5.0",
|
|
24
|
+
"vitest": "^2.0.0"
|
|
25
|
+
},
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "https://github.com/snxstudio/lit-pigeon.git",
|
|
32
|
+
"directory": "packages/lint"
|
|
33
|
+
},
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "tsc",
|
|
37
|
+
"dev": "tsc -w",
|
|
38
|
+
"test": "vitest run",
|
|
39
|
+
"test:watch": "vitest",
|
|
40
|
+
"clean": "rm -rf dist"
|
|
41
|
+
}
|
|
42
|
+
}
|