sugikit 0.0.1 → 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 +29 -21
- package/README.md +45 -0
- package/dist/api/browser.d.ts +5 -0
- package/dist/api/browser.js +5 -0
- package/dist/api/rules.d.ts +12 -0
- package/dist/api/rules.js +14 -0
- package/dist/auth.d.ts +156 -0
- package/dist/auth.js +547 -0
- package/dist/browser.d.ts +25 -0
- package/dist/browser.js +120 -0
- package/dist/check.d.ts +21 -0
- package/dist/check.js +89 -0
- package/dist/convert-probe.d.ts +21 -0
- package/dist/convert-probe.js +647 -0
- package/dist/fetch.d.ts +6 -0
- package/dist/fetch.js +22 -0
- package/dist/framework.d.ts +2 -0
- package/dist/framework.js +17 -0
- package/dist/gather.d.ts +48 -0
- package/dist/gather.js +211 -0
- package/dist/html.d.ts +17 -0
- package/dist/html.js +43 -0
- package/dist/http.d.ts +36 -0
- package/dist/http.js +57 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +331 -0
- package/dist/links.d.ts +8 -0
- package/dist/links.js +69 -0
- package/dist/polish-run.d.ts +115 -0
- package/dist/polish-run.js +357 -0
- package/dist/probe.d.ts +14 -0
- package/dist/probe.js +457 -0
- package/dist/psi-scores.d.ts +4 -0
- package/dist/psi-scores.js +7 -0
- package/dist/psi.d.ts +56 -0
- package/dist/psi.js +192 -0
- package/dist/release.d.ts +1 -0
- package/dist/release.js +5 -0
- package/dist/render.d.ts +28 -0
- package/dist/render.js +270 -0
- package/dist/report.d.ts +227 -0
- package/dist/report.js +69 -0
- package/dist/rules/convert-render.d.ts +100 -0
- package/dist/rules/convert-render.js +279 -0
- package/dist/rules/convert.d.ts +15 -0
- package/dist/rules/convert.js +322 -0
- package/dist/rules/fixes.d.ts +16 -0
- package/dist/rules/fixes.js +536 -0
- package/dist/rules/geo.d.ts +15 -0
- package/dist/rules/geo.js +112 -0
- package/dist/rules/polish.d.ts +59 -0
- package/dist/rules/polish.js +223 -0
- package/dist/rules/robots.d.ts +14 -0
- package/dist/rules/robots.js +69 -0
- package/dist/rules/seo.d.ts +31 -0
- package/dist/rules/seo.js +208 -0
- package/dist/rules/types.d.ts +55 -0
- package/dist/rules/types.js +78 -0
- package/dist/score.d.ts +6 -0
- package/dist/score.js +23 -0
- package/dist/skills.d.ts +9 -0
- package/dist/skills.js +22 -0
- package/package.json +64 -4
- package/skills/INSTALL_PROMPT.md +9 -0
- package/skills/sugikit/SKILL.md +147 -0
- package/skills/sugikit/references/convert.md +127 -0
- package/skills/sugikit/references/geo.md +97 -0
- package/skills/sugikit/references/next.md +254 -0
- package/skills/sugikit/references/pagespeed.md +94 -0
- package/skills/sugikit/references/polish.md +123 -0
- package/skills/sugikit/references/seo.md +150 -0
- package/skills/sugikit/references/tanstack-start.md +246 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type CheerioAPI } from "cheerio";
|
|
2
|
+
import { type FetchLike } from "../http.js";
|
|
3
|
+
import type { PageType } from "../report.js";
|
|
4
|
+
import { type PageContext, type Rule, type RuleResult } from "./types.js";
|
|
5
|
+
export declare const PRODUCT_NAV_LINKS = 4;
|
|
6
|
+
export declare const MAX_FUNNEL_FIELDS_WARN = 3;
|
|
7
|
+
export declare const MAX_FUNNEL_FIELDS_ERROR = 6;
|
|
8
|
+
export declare function detectPageType($: CheerioAPI): PageType;
|
|
9
|
+
export declare const convertLinkText: Rule;
|
|
10
|
+
export declare const convertPlaceholderText: Rule;
|
|
11
|
+
export declare const convertContactVisible: Rule;
|
|
12
|
+
export declare const convertFormFields: Rule;
|
|
13
|
+
export declare function verifyPricingLink(ctx: Pick<PageContext, "$" | "url">, current: RuleResult, fetcher: FetchLike, renderedPrice?: string): Promise<RuleResult>;
|
|
14
|
+
export declare const convertPriceVisible: (ctx: PageContext) => RuleResult;
|
|
15
|
+
export declare const convertRules: Rule[];
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
// Static conversion checks (cheerio on the server HTML). Each result says which engine measured it, how
|
|
2
|
+
// strong the evidence is and its source; see the conversion checks spec. Render checks live in the browser run.
|
|
3
|
+
import { load } from "cheerio";
|
|
4
|
+
import { INCONCLUSIVE_STATUS, fetchTextWith } from "../http.js";
|
|
5
|
+
import { notApplicable, result } from "./types.js";
|
|
6
|
+
// cheerio does not re-export domhandler's Element type; take it from a typed query.
|
|
7
|
+
const anchors = ($) => $("a").toArray();
|
|
8
|
+
const STATIC = { engine: "static" };
|
|
9
|
+
// The page has a nav with this many links (not same-page anchors) or more: a product homepage.
|
|
10
|
+
export const PRODUCT_NAV_LINKS = 4;
|
|
11
|
+
export const MAX_FUNNEL_FIELDS_WARN = 3;
|
|
12
|
+
export const MAX_FUNNEL_FIELDS_ERROR = 6;
|
|
13
|
+
const VAGUE_LINK_TEXT = new Set(["click here", "learn more", "read more", "here"]);
|
|
14
|
+
const FUNNEL_SUBMIT = /\b(sign ?up|join|wait ?list|subscribe|get started|request)\b/i;
|
|
15
|
+
const EXAMPLE_HOST = /(^|\.)example\.(com|org|net)$/i;
|
|
16
|
+
const PRICE_TEXT = /[$€£]\s?\d[\d.,]*|\d[\d.,]*\s?(USD|EUR|GBP)\b/;
|
|
17
|
+
const PRICING_LINK = /pricing|plans?\b|price/i;
|
|
18
|
+
const CONTACT_LINK = /contact|support|help/i;
|
|
19
|
+
const PLACEHOLDER_TEXT = [
|
|
20
|
+
{ pattern: /lorem ipsum/i, label: "Lorem ipsum", owner: true },
|
|
21
|
+
{ pattern: /\bTODO\b/, label: "TODO", owner: false },
|
|
22
|
+
{ pattern: /\bYour Name\b/, label: "Your Name", owner: true },
|
|
23
|
+
{ pattern: /\bCompany,? Inc\b/, label: "Company Inc", owner: true },
|
|
24
|
+
];
|
|
25
|
+
function squash(text) {
|
|
26
|
+
return text.replace(/\s+/g, " ").trim();
|
|
27
|
+
}
|
|
28
|
+
function isHidden($, el) {
|
|
29
|
+
const node = $(el);
|
|
30
|
+
if (node.closest("[hidden], [aria-hidden='true'], template").length > 0)
|
|
31
|
+
return true;
|
|
32
|
+
return /display\s*:\s*none|visibility\s*:\s*hidden/i.test(node.attr("style") ?? "");
|
|
33
|
+
}
|
|
34
|
+
// Visible body text without scripts, styles and form contents (form labels like "Your name" are fine).
|
|
35
|
+
function visibleText($, { skipForms = false } = {}) {
|
|
36
|
+
const body = $("body").clone();
|
|
37
|
+
body.find(`script, style, noscript, template, [hidden], [aria-hidden='true']${skipForms ? ", form" : ""}`).remove();
|
|
38
|
+
// Join text nodes with spaces: <p>a</p><p>b</p> reads "a b", not "ab".
|
|
39
|
+
const parts = body
|
|
40
|
+
.find("*")
|
|
41
|
+
.addBack()
|
|
42
|
+
.contents()
|
|
43
|
+
.toArray()
|
|
44
|
+
.filter((node) => node.type === "text")
|
|
45
|
+
.map((node) => $(node).text());
|
|
46
|
+
return squash(parts.join(" "));
|
|
47
|
+
}
|
|
48
|
+
function list(items, max = 5) {
|
|
49
|
+
const shown = items.slice(0, max).join("; ");
|
|
50
|
+
return items.length > max ? `${shown}; and ${items.length - max} more` : shown;
|
|
51
|
+
}
|
|
52
|
+
function sameOrigin(href, pageUrl) {
|
|
53
|
+
if (!href)
|
|
54
|
+
return undefined;
|
|
55
|
+
try {
|
|
56
|
+
const target = new URL(href, pageUrl);
|
|
57
|
+
return target.origin === new URL(pageUrl).origin ? target : undefined;
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// Visible fields a visitor fills in: inputs other than hidden and buttons, selects and textareas.
|
|
64
|
+
function formFields($, form) {
|
|
65
|
+
return form
|
|
66
|
+
.find("input, select, textarea")
|
|
67
|
+
.toArray()
|
|
68
|
+
.filter((el) => {
|
|
69
|
+
const type = ($(el).attr("type") ?? "text").toLowerCase();
|
|
70
|
+
return !["hidden", "submit", "button", "reset", "image"].includes(type) && !isHidden($, el);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function isEmailField($, el) {
|
|
74
|
+
const node = $(el);
|
|
75
|
+
const type = (node.attr("type") ?? "").toLowerCase();
|
|
76
|
+
const names = `${node.attr("name") ?? ""} ${node.attr("id") ?? ""} ${node.attr("autocomplete") ?? ""}`;
|
|
77
|
+
return type === "email" || /e-?mail/i.test(names);
|
|
78
|
+
}
|
|
79
|
+
function isPhoneField($, el) {
|
|
80
|
+
const node = $(el);
|
|
81
|
+
const type = (node.attr("type") ?? "").toLowerCase();
|
|
82
|
+
const names = `${node.attr("name") ?? ""} ${node.attr("id") ?? ""} ${node.attr("autocomplete") ?? ""}`;
|
|
83
|
+
return type === "tel" || /phone|\btel\b/i.test(names);
|
|
84
|
+
}
|
|
85
|
+
function submitText($, form) {
|
|
86
|
+
const buttons = form.find("button, input[type='submit' i], input[type='button' i]").toArray();
|
|
87
|
+
return buttons.map((el) => squash($(el).is("input") ? ($(el).attr("value") ?? "") : $(el).text())).join(" ");
|
|
88
|
+
}
|
|
89
|
+
function visibleForms($) {
|
|
90
|
+
return $("form").filter((_, el) => !isHidden($, el));
|
|
91
|
+
}
|
|
92
|
+
// Product: a nav (or header when there is no nav) with PRODUCT_NAV_LINKS or more links that leave the
|
|
93
|
+
// section. Waitlist: the only form is a single email field. Launch: everything else.
|
|
94
|
+
export function detectPageType($) {
|
|
95
|
+
const navs = $("nav").length > 0 ? $("nav") : $("header");
|
|
96
|
+
const navLinks = new Set(navs
|
|
97
|
+
.find("a[href]")
|
|
98
|
+
.toArray()
|
|
99
|
+
.map((el) => $(el).attr("href")?.trim() ?? "")
|
|
100
|
+
.filter((href) => href !== "" && !href.startsWith("#")));
|
|
101
|
+
if (navLinks.size >= PRODUCT_NAV_LINKS)
|
|
102
|
+
return "product";
|
|
103
|
+
const forms = visibleForms($);
|
|
104
|
+
if (forms.length === 1) {
|
|
105
|
+
const fields = formFields($, forms.first());
|
|
106
|
+
if (fields.length === 1 && fields[0] && isEmailField($, fields[0]))
|
|
107
|
+
return "waitlist";
|
|
108
|
+
}
|
|
109
|
+
return "launch";
|
|
110
|
+
}
|
|
111
|
+
function pageTypeOf(ctx) {
|
|
112
|
+
return ctx.pageType ?? detectPageType(ctx.$);
|
|
113
|
+
}
|
|
114
|
+
export const convertLinkText = ({ $ }) => {
|
|
115
|
+
const extra = { ...STATIC, confidence: "high", source: "NN/g F-pattern: descriptive link text" };
|
|
116
|
+
const vague = anchors($)
|
|
117
|
+
.filter((el) => {
|
|
118
|
+
const node = $(el);
|
|
119
|
+
if (node.attr("aria-label")?.trim() || node.attr("aria-labelledby")?.trim())
|
|
120
|
+
return false;
|
|
121
|
+
return VAGUE_LINK_TEXT.has(squash(node.text()).toLowerCase()) && !isHidden($, el);
|
|
122
|
+
})
|
|
123
|
+
.map((el) => `"${squash($(el).text())}" -> ${$(el).attr("href") ?? "(no href)"}`);
|
|
124
|
+
if (vague.length === 0)
|
|
125
|
+
return result("convert/link-text", "warn", true, "No vague link text", extra);
|
|
126
|
+
return result("convert/link-text", "warn", false, `${vague.length} link${vague.length === 1 ? "" : "s"} say${vague.length === 1 ? "s" : ""} only "click here", "learn more", "read more" or "here"`, { ...extra, evidence: list(vague), selector: "a" });
|
|
127
|
+
};
|
|
128
|
+
export const convertPlaceholderText = ({ $, url, linkChecks }) => {
|
|
129
|
+
const extra = { ...STATIC, confidence: "high", source: 'Stanford credibility: "Avoid errors of all types"' };
|
|
130
|
+
const problems = [];
|
|
131
|
+
let owner = false;
|
|
132
|
+
const text = visibleText($, { skipForms: true });
|
|
133
|
+
for (const { pattern, label, owner: needs } of PLACEHOLDER_TEXT) {
|
|
134
|
+
if (!pattern.test(text))
|
|
135
|
+
continue;
|
|
136
|
+
problems.push(`placeholder text "${label}"`);
|
|
137
|
+
owner ||= needs;
|
|
138
|
+
}
|
|
139
|
+
const pageHost = new URL(url).hostname;
|
|
140
|
+
if (!EXAMPLE_HOST.test(pageHost)) {
|
|
141
|
+
const example = $("a[href]")
|
|
142
|
+
.toArray()
|
|
143
|
+
.map((el) => $(el).attr("href") ?? "")
|
|
144
|
+
.filter((href) => {
|
|
145
|
+
try {
|
|
146
|
+
return EXAMPLE_HOST.test(new URL(href, url).hostname);
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
if (example.length > 0) {
|
|
153
|
+
problems.push(`links to example domains: ${list([...new Set(example)], 3)}`);
|
|
154
|
+
owner = true;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
// An anchor with href="#" and role=button or an onclick handler is a same-page JS button, not a dead link.
|
|
158
|
+
const dead = $('a[href="#"]')
|
|
159
|
+
.toArray()
|
|
160
|
+
.filter((el) => !isHidden($, el) && $(el).attr("role") !== "button" && $(el).attr("onclick") === undefined)
|
|
161
|
+
.map((el) => `"${squash($(el).text()) || "(no text)"}"`);
|
|
162
|
+
if (dead.length > 0)
|
|
163
|
+
problems.push(`${dead.length} link${dead.length === 1 ? "" : "s"} to "#": ${list(dead, 3)}`);
|
|
164
|
+
// 401, 403, 429 and 503 come from logins, bot protection and rate limits: those links are not checked.
|
|
165
|
+
const unchecked = (linkChecks ?? []).filter((link) => INCONCLUSIVE_STATUS.has(link.status));
|
|
166
|
+
const broken = (linkChecks ?? []).filter((link) => link.status >= 400 && link.status < 500 && !INCONCLUSIVE_STATUS.has(link.status));
|
|
167
|
+
if (broken.length > 0) {
|
|
168
|
+
problems.push(`broken internal link${broken.length === 1 ? "" : "s"}: ${list(broken.map((l) => `${l.url} (${l.status})`), 3)}`);
|
|
169
|
+
}
|
|
170
|
+
const note = unchecked.length > 0
|
|
171
|
+
? `${unchecked.length} link${unchecked.length === 1 ? "" : "s"} not checked (status ${[...new Set(unchecked.map((l) => l.status))].join(", ")})`
|
|
172
|
+
: undefined;
|
|
173
|
+
if (problems.length === 0) {
|
|
174
|
+
const checked = linkChecks ? `; ${linkChecks.length - unchecked.length} internal link${linkChecks.length - unchecked.length === 1 ? "" : "s"} checked` : "";
|
|
175
|
+
return result("convert/placeholder-text", "error", true, `No placeholder text or dead links${checked}`, {
|
|
176
|
+
...extra,
|
|
177
|
+
...(note ? { evidence: note } : {}),
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
return result("convert/placeholder-text", "error", false, `The page has leftovers: ${problems.join("; ")}`, {
|
|
181
|
+
...extra,
|
|
182
|
+
evidence: [...problems, ...(note ? [note] : [])].join("\n"),
|
|
183
|
+
...(owner ? { needsOwner: true } : {}),
|
|
184
|
+
});
|
|
185
|
+
};
|
|
186
|
+
export const convertContactVisible = ({ $ }) => {
|
|
187
|
+
const extra = { ...STATIC, confidence: "high", source: 'Stanford credibility: "Make it easy to contact you"' };
|
|
188
|
+
const landmarks = $("header, footer, nav, [role='banner'], [role='contentinfo']");
|
|
189
|
+
// A page with no header, footer or nav is searched whole.
|
|
190
|
+
const scope = landmarks.length > 0 ? landmarks.find("a[href]") : $("a[href]");
|
|
191
|
+
const contact = scope.toArray().find((el) => {
|
|
192
|
+
const href = $(el).attr("href") ?? "";
|
|
193
|
+
return /^mailto:/i.test(href) || CONTACT_LINK.test(href) || CONTACT_LINK.test(squash($(el).text()));
|
|
194
|
+
});
|
|
195
|
+
if (contact) {
|
|
196
|
+
return result("convert/contact-visible", "warn", true, "The page links to a way to contact a human", {
|
|
197
|
+
...extra,
|
|
198
|
+
evidence: `"${squash($(contact).text())}" -> ${$(contact).attr("href") ?? ""}`,
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
const where = landmarks.length > 0 ? "The header, footer and nav have" : "The page has";
|
|
202
|
+
return result("convert/contact-visible", "warn", false, `${where} no contact email, contact page or support link`, {
|
|
203
|
+
...extra,
|
|
204
|
+
needsOwner: true,
|
|
205
|
+
});
|
|
206
|
+
};
|
|
207
|
+
export const convertFormFields = ({ $ }) => {
|
|
208
|
+
const extra = { ...STATIC, confidence: "high", source: "Baymard checkout fields; Marketing Examples: ask for the email only" };
|
|
209
|
+
let worst;
|
|
210
|
+
visibleForms($).each((index, el) => {
|
|
211
|
+
const form = $(el);
|
|
212
|
+
const fields = formFields($, form);
|
|
213
|
+
const submit = submitText($, form);
|
|
214
|
+
const funnel = fields.some((field) => isEmailField($, field)) || FUNNEL_SUBMIT.test(submit);
|
|
215
|
+
if (!funnel)
|
|
216
|
+
return;
|
|
217
|
+
const phone = fields.some((field) => isPhoneField($, field));
|
|
218
|
+
const label = `form ${index + 1}${submit ? ` ("${submit}")` : ""}: ${fields.length} field${fields.length === 1 ? "" : "s"}${phone ? " incl. a phone field" : ""}`;
|
|
219
|
+
const rank = (f) => f.fields * 2 + (f.phone ? 1 : 0);
|
|
220
|
+
if (!worst || rank({ fields: fields.length, phone }) > rank(worst))
|
|
221
|
+
worst = { fields: fields.length, phone, label };
|
|
222
|
+
});
|
|
223
|
+
if (!worst)
|
|
224
|
+
return notApplicable("convert/form-fields", "No sign-up or lead form to check", extra);
|
|
225
|
+
if (worst.fields > MAX_FUNNEL_FIELDS_ERROR) {
|
|
226
|
+
return result("convert/form-fields", "error", false, `A sign-up form asks for ${worst.fields} fields (more than ${MAX_FUNNEL_FIELDS_ERROR})`, {
|
|
227
|
+
...extra,
|
|
228
|
+
evidence: worst.label,
|
|
229
|
+
selector: "form",
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
if (worst.fields > MAX_FUNNEL_FIELDS_WARN || worst.phone) {
|
|
233
|
+
const why = worst.fields > MAX_FUNNEL_FIELDS_WARN ? `${worst.fields} fields (more than ${MAX_FUNNEL_FIELDS_WARN})` : "a phone number";
|
|
234
|
+
return result("convert/form-fields", "warn", false, `A sign-up form asks for ${why}`, { ...extra, evidence: worst.label, selector: "form" });
|
|
235
|
+
}
|
|
236
|
+
return result("convert/form-fields", "warn", true, `Sign-up forms ask for ${MAX_FUNNEL_FIELDS_WARN} fields or fewer`, {
|
|
237
|
+
...extra,
|
|
238
|
+
evidence: worst.label,
|
|
239
|
+
});
|
|
240
|
+
};
|
|
241
|
+
function pricingLink($, url) {
|
|
242
|
+
return $("a[href]")
|
|
243
|
+
.toArray()
|
|
244
|
+
.find((el) => {
|
|
245
|
+
const target = sameOrigin($(el).attr("href"), url);
|
|
246
|
+
if (!target)
|
|
247
|
+
return false;
|
|
248
|
+
return PRICING_LINK.test(`${target.pathname} ${target.hash}`) || PRICING_LINK.test(squash($(el).text()));
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
// Render part of convert/price-visible: when the static check passed only through a pricing link, load the
|
|
252
|
+
// link target once and look for a currency amount there (static parse). A link to a section of this page uses
|
|
253
|
+
// the price the browser saw in the rendered page (renderedPrice). Returns the result unchanged otherwise.
|
|
254
|
+
export async function verifyPricingLink(ctx, current, fetcher, renderedPrice) {
|
|
255
|
+
if (current.id !== "convert/price-visible" || !current.pass || !current.evidence?.startsWith("pricing link:"))
|
|
256
|
+
return current;
|
|
257
|
+
const link = pricingLink(ctx.$, ctx.url);
|
|
258
|
+
const target = link ? sameOrigin(ctx.$(link).attr("href"), ctx.url) : undefined;
|
|
259
|
+
if (!link || !target)
|
|
260
|
+
return current;
|
|
261
|
+
const extra = { engine: "render", confidence: "medium", source: current.source ?? "NN/g: show prices, hidden prices read as evasive" };
|
|
262
|
+
const label = `pricing link "${squash(ctx.$(link).text())}" -> ${ctx.$(link).attr("href") ?? ""}`;
|
|
263
|
+
const page = new URL(ctx.url);
|
|
264
|
+
if (target.pathname === page.pathname && target.search === page.search) {
|
|
265
|
+
if (renderedPrice)
|
|
266
|
+
return result("convert/price-visible", "warn", true, "The pricing section shows a price", { ...extra, evidence: `${label} shows ${renderedPrice}` });
|
|
267
|
+
return result("convert/price-visible", "warn", false, "The pricing link points at this page, which shows no price", {
|
|
268
|
+
...extra,
|
|
269
|
+
evidence: `${label}: no currency amount in the rendered page`,
|
|
270
|
+
needsOwner: true,
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
try {
|
|
274
|
+
const fetched = await fetchTextWith(fetcher, target.href);
|
|
275
|
+
if (fetched.status < 200 || fetched.status >= 300) {
|
|
276
|
+
return result("convert/price-visible", "warn", false, `The pricing link answers HTTP ${fetched.status}`, { ...extra, evidence: label, url: target.href });
|
|
277
|
+
}
|
|
278
|
+
const price = PRICE_TEXT.exec(visibleText(load(fetched.body)));
|
|
279
|
+
if (price) {
|
|
280
|
+
return result("convert/price-visible", "warn", true, "The pricing page shows a price", {
|
|
281
|
+
...extra,
|
|
282
|
+
evidence: `${label} shows ${price[0].replace(/[.,]$/, "")}`,
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
return result("convert/price-visible", "warn", false, "The pricing page shows no price", {
|
|
286
|
+
...extra,
|
|
287
|
+
evidence: `${label}: no currency amount in its HTML`,
|
|
288
|
+
url: target.href,
|
|
289
|
+
needsOwner: true,
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
catch {
|
|
293
|
+
return { ...current, evidence: `${current.evidence}; could not load the pricing page to confirm a price` };
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
// Static part: a price on the page or a pricing link. The render check verifies the link shows a price.
|
|
297
|
+
export const convertPriceVisible = (ctx) => {
|
|
298
|
+
const { $, url } = ctx;
|
|
299
|
+
const extra = { ...STATIC, confidence: "medium", source: "NN/g: show prices, hidden prices read as evasive" };
|
|
300
|
+
if (pageTypeOf(ctx) === "waitlist") {
|
|
301
|
+
return result("convert/price-visible", "info", true, "Skipped on a waitlist page", { ...extra, evidence: "page type waitlist" });
|
|
302
|
+
}
|
|
303
|
+
const price = PRICE_TEXT.exec(visibleText($));
|
|
304
|
+
if (price) {
|
|
305
|
+
return result("convert/price-visible", "warn", true, "The page shows a price", { ...extra, evidence: price[0].replace(/[.,]$/, "") });
|
|
306
|
+
}
|
|
307
|
+
const link = pricingLink($, url);
|
|
308
|
+
if (link) {
|
|
309
|
+
return result("convert/price-visible", "warn", true, "The page links to pricing", {
|
|
310
|
+
...extra,
|
|
311
|
+
evidence: `pricing link: "${squash($(link).text())}" -> ${$(link).attr("href") ?? ""}`,
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
return result("convert/price-visible", "warn", false, "The page shows no price and no link to pricing", { ...extra, needsOwner: true });
|
|
315
|
+
};
|
|
316
|
+
export const convertRules = [
|
|
317
|
+
convertLinkText,
|
|
318
|
+
convertPlaceholderText,
|
|
319
|
+
convertContactVisible,
|
|
320
|
+
convertFormFields,
|
|
321
|
+
convertPriceVisible,
|
|
322
|
+
];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Fix, Framework } from "../report.js";
|
|
2
|
+
interface FrameworkFix {
|
|
3
|
+
summary: string;
|
|
4
|
+
files: string[];
|
|
5
|
+
}
|
|
6
|
+
interface FixEntry {
|
|
7
|
+
summary: string;
|
|
8
|
+
next?: FrameworkFix;
|
|
9
|
+
"tanstack-start"?: FrameworkFix;
|
|
10
|
+
}
|
|
11
|
+
export declare const FIXES: Record<string, FixEntry>;
|
|
12
|
+
export declare const AUDIT_HINTS: Record<string, Omit<FixEntry, "summary">>;
|
|
13
|
+
export declare function plainDescription(description: string): string;
|
|
14
|
+
export declare function auditFix(auditId: string, description: string, framework: Framework): Fix;
|
|
15
|
+
export declare function fixFor(id: string, framework: Framework): Fix;
|
|
16
|
+
export {};
|