@v-office/site-checks 0.2.1 → 0.2.3
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 +21 -21
- package/dist/astro.mjs +1 -1
- package/dist/dist-checks.mjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{report-DI-5w16K.mjs → report-DMjG_lMz.mjs} +82 -28
- package/instructions/CHANGELOG.md +2 -0
- package/instructions/MIGRATION.md +2 -0
- package/instructions/versions/0.2.2/CHANGELOG.md +15 -0
- package/instructions/versions/0.2.2/MIGRATION.md +9 -0
- package/instructions/versions/0.2.3/CHANGELOG.md +18 -0
- package/instructions/versions/0.2.3/MIGRATION.md +15 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -41,32 +41,32 @@ A refused build ends with the failing checks and their first findings:
|
|
|
41
41
|
keys are accepted by `siteChecks({ … })`, and an option given there wins over the file's key.
|
|
42
42
|
Severities are fixed by the package: a site configures data, never whether a check blocks.
|
|
43
43
|
|
|
44
|
-
| Key | Used by | What
|
|
45
|
-
| ------------------------- | ---------------------------------- |
|
|
46
|
-
| `donorTerms` | `donor-terms` | Terms that must not ship: the template site's brand, people, places, phone, email, domain, asset names. Plain strings, matched case-insensitively with whitespace collapsed.
|
|
47
|
-
| `optimizeDepsIgnore` | `optimize-deps` | Packages imported from `src/` that may stay out of `vite.optimizeDeps.include` (only server-side code uses them). Exact specifier or package name.
|
|
48
|
-
| `imageIgnore` | `image-formats` | Raster images under `public/` that ship without an AVIF sibling on purpose, as paths relative to the project root (`public/brand/logo.png`).
|
|
49
|
-
| `feedImagePatterns` | `feed-image-formats` | Regular expressions (case-insensitive) matching a feed photo URL still requested as JPEG or PNG. Defaults to the vOffice image hosts (imgproxy `plain` paths, `dyn.v-office.com`).
|
|
50
|
-
| `listingPages` | `listing-noindex`, `listing-links` | URL paths of pages that list rentals, in addition to the pages the check recognizes by their markup.
|
|
51
|
-
| `listingClientOnly` | `listing-links` | Listing pages whose list stays client-only, as `{ "path", "reason" }`: their list is the rentals free in a window, and a build-time list would show booked-out flats.
|
|
52
|
-
| `consentAllowedHosts` | `consent-gate` | Hosts a `<script src>` or `<iframe src>` may load before consent. The site's own host (`site` in the Astro config) is always allowed.
|
|
53
|
-
| `wiring` | `wiring` | Markup hooks `{ init, marker, scope: "section" \| "global", file? }` and kept texts `{ file, contains, guard }` (the former `scripts/wiring.json` `hooks`).
|
|
54
|
-
| `hubFilterOptions` | `v9-hub-filters` | v9: the Website SDK options the Hub filter check needs (`rentalScope`, `customAttributeFilterDefinitions`), as the site passes them to the SDK.
|
|
55
|
-
| `structureIgnore` | `page-structure` | Rules the site declines: `one-h1`, `heading-skip`, `landmark-main`, `img-alt`, `control-label`, `table-headers`, `heading-ratio`.
|
|
56
|
-
| `bannedCopy` | `banned-copy` | Wordings recorded customer corrections ban, as `{ "pattern", "why" }` (a regular expression over the page's visible text).
|
|
57
|
-
| `copyExcludePaths` | the copy checks | URL paths (and below) the copy checks skip, legal pages ported verbatim; `/impressum` also covers `/de/impressum`.
|
|
58
|
-
| `bannedCopyExcludePaths` | `banned-copy` | URL paths only `banned-copy` skips (an FAQ whose answers port verbatim).
|
|
59
|
-
| `allowDuplicateSentences` | `duplicate-sentences` | Sentences a page may render twice.
|
|
60
|
-
| `quoteSources` | `quote-sources` | Files or directories holding the text a `<blockquote>` may quote (content captures, the feed's reviews written by the build).
|
|
61
|
-
| `factCheckAccepted` | `rental-facts` | Disagreements the customer confirmed, as the finding prints them: `<slug> <kind> prose=<n> feed=<n>`.
|
|
44
|
+
| Key | Used by | What |
|
|
45
|
+
| ------------------------- | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
46
|
+
| `donorTerms` | `donor-terms` | Terms that must not ship: the template site's brand, people, places, phone, email, domain, asset names. Plain strings, matched as whole words, case-insensitively with whitespace collapsed. |
|
|
47
|
+
| `optimizeDepsIgnore` | `optimize-deps` | Packages imported from `src/` that may stay out of `vite.optimizeDeps.include` (only server-side code uses them). Exact specifier or package name. |
|
|
48
|
+
| `imageIgnore` | `image-formats` | Raster images under `public/` that ship without an AVIF sibling on purpose, as paths relative to the project root (`public/brand/logo.png`). |
|
|
49
|
+
| `feedImagePatterns` | `feed-image-formats` | Regular expressions (case-insensitive) matching a feed photo URL still requested as JPEG or PNG. Defaults to the vOffice image hosts (imgproxy `plain` paths, `dyn.v-office.com`). |
|
|
50
|
+
| `listingPages` | `listing-noindex`, `listing-links` | URL paths of pages that list rentals, in addition to the pages the check recognizes by their markup. |
|
|
51
|
+
| `listingClientOnly` | `listing-links` | Listing pages whose list stays client-only, as `{ "path", "reason" }`: their list is the rentals free in a window, and a build-time list would show booked-out flats. |
|
|
52
|
+
| `consentAllowedHosts` | `consent-gate` | Hosts a `<script src>` or `<iframe src>` may load before consent. The site's own host (`site` in the Astro config) is always allowed. |
|
|
53
|
+
| `wiring` | `wiring` | Markup hooks `{ init, marker, scope: "section" \| "global", file? }` and kept texts `{ file, contains, guard }` (the former `scripts/wiring.json` `hooks`). |
|
|
54
|
+
| `hubFilterOptions` | `v9-hub-filters` | v9: the Website SDK options the Hub filter check needs (`rentalScope`, `customAttributeFilterDefinitions`), as the site passes them to the SDK. |
|
|
55
|
+
| `structureIgnore` | `page-structure` | Rules the site declines: `one-h1`, `heading-skip`, `landmark-main`, `img-alt`, `control-label`, `table-headers`, `heading-ratio`. |
|
|
56
|
+
| `bannedCopy` | `banned-copy` | Wordings recorded customer corrections ban, as `{ "pattern", "why" }` (a regular expression over the page's visible text). |
|
|
57
|
+
| `copyExcludePaths` | the copy checks | URL paths (and below) the copy checks skip, legal pages ported verbatim; `/impressum` also covers `/de/impressum`. |
|
|
58
|
+
| `bannedCopyExcludePaths` | `banned-copy` | URL paths only `banned-copy` skips (an FAQ whose answers port verbatim). |
|
|
59
|
+
| `allowDuplicateSentences` | `duplicate-sentences` | Sentences a page may render twice. |
|
|
60
|
+
| `quoteSources` | `quote-sources` | Files or directories holding the text a `<blockquote>` may quote (content captures, the feed's reviews written by the build). |
|
|
61
|
+
| `factCheckAccepted` | `rental-facts` | Disagreements the customer confirmed, as the finding prints them: `<slug> <kind> prose=<n> feed=<n>`. |
|
|
62
62
|
|
|
63
63
|
## The checks
|
|
64
64
|
|
|
65
65
|
| id | Severity | What it refuses or reports | How to fix |
|
|
66
66
|
| --------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
67
67
|
| `html-comments` | error | An HTML comment (`<!-- … -->`) in `src/**/*.{astro,tsx,jsx,md,mdx,html}`: Astro passes it into the built page, readable with View Source. | `{/* … */}` in `.astro` and JSX markup, `//` in frontmatter, remove it from Markdown. |
|
|
68
|
-
| `view-source` | error | A developer's note a visitor can read with View Source: an HTML comment in a built page (
|
|
69
|
-
| `donor-terms` | error | A configured term in the visible text, the title, inline scripts and styles (JSON-LD) or an attribute of a built page, in a built file name, or in the shipped JS and CSS. Skipped without configured terms.
|
|
68
|
+
| `view-source` | error | A developer's note a visitor can read with View Source: an HTML comment in a built page (framework markers are allowed), a comment in an inline `<script>`, `<style>` or event handler that is also in `src/` or `public/`, a comment in CSS or a line comment in JS copied from `public/`, a source map or a reference to one in any shipped file. Bundled JS and CSS are not scanned for comments. | Remove the comment; turn source maps off in the build. |
|
|
69
|
+
| `donor-terms` | error | A configured term in the visible text, the title, inline scripts and styles (JSON-LD) or an attribute of a built page, in a built file name, or in the shipped JS and CSS, as a whole word. Skipped without configured terms. | Replace the term; list the template site's terms in `donorTerms`. |
|
|
70
70
|
| `optimize-deps` | warning | A runtime package (`dependencies`) imported from `src/` that is not listed, with the exact specifier, in `vite.optimizeDeps.include`. Vite discovers it mid-session instead and re-bundles every dependency. | Add the specifier to `vite.optimizeDeps.include` in `astro.config`, or to `optimizeDepsIgnore` when only server-side code uses it. |
|
|
71
71
|
| `sync-once` | warning | An inline content loader in `src/content.config.ts` that fetches the PMS without the `CONTENT_SYNC_TOKEN` reuse idiom: `astro check` and `astro build` each run it, twice per build. | Keep the token in the store's meta (`meta.get`) and reuse the entries (`store.keys()`) when it matches. |
|
|
72
72
|
| `consent-gate` | error | A third-party `<script src>` or `<iframe src>` outside the consent kit's `ConsentEmbed` frame, loading before consent; a vendor in `ENABLED_VENDOR_IDS` that is not `approved` in `consent-registry.snapshot.json`. Skipped without `src/lib/consent/`. | Frame it with `ConsentEmbed`, or register the vendor so the kit injects it after consent; list a consent-free host in `consentAllowedHosts`. |
|
|
@@ -74,7 +74,7 @@ Severities are fixed by the package: a site configures data, never whether a che
|
|
|
74
74
|
| `feed-image-formats` | warning | A feed photo from the vOffice image hosts requested as JPEG or PNG in `src`, `srcset` or `poster`; a warning because the photos come from the PMS feed. | Pass feed photos through `webpUrl()`. |
|
|
75
75
|
| `listing-noindex` | error | A page that lists rentals (the search page's `data-prerendered-results` container, the `SearchResults` island, or `listingPages`) that is noindex. Waits while every page is noindex. | Take the page out of the noindex routes. |
|
|
76
76
|
| `listing-links` | warning | A page that lists rentals that carries no links to rentals in its HTML, so a crawler without JavaScript sees an empty list. Runs once some listing has links or the build has more than ten pages; a warning because the links come from the PMS feed. | Render the list server-side, or list the page in `listingClientOnly` with the reason. |
|
|
77
|
-
| `sitemap-noindex` | error | A sitemap entry whose page says noindex or is not in the build; an `llms.txt` link to a page that is not there. Skipped without a sitemap and `llms.txt`.
|
|
77
|
+
| `sitemap-noindex` | error | A sitemap entry whose page says noindex (waits while every page is noindex) or is not in the build; an `llms.txt` link to a page that is not there. Skipped without a sitemap and `llms.txt`. | Make the sitemap filter and the noindex routes agree; fix the link. |
|
|
78
78
|
| `page-heads` | warning | On indexable pages: a title over 60 characters, a description empty or over 160, a title or description another page repeats. A missing one is the build worker's `page-metadata`. | Shorten; give each page its own. |
|
|
79
79
|
| `wiring` | error | A component carrying a configured hook's marker whose initializer nothing calls (`section`: the component itself; `global`: anything in `src/`), through leaves marked `@bound-by-parent <init>`; a kept text gone from its file. Comments are stripped first. Skipped without `wiring`. | Call the initializer, mark the leaf `@bound-by-parent`, or put the kept text back. |
|
|
80
80
|
| `unused-initializers` | warning | An `init*` exported from `src/scripts/*.ts` that nothing calls. Skipped without `src/scripts/`. | Wire the feature, or delete the leftover. |
|
package/dist/astro.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as writeSiteChecksReport, d as runSiteChecks, i as summaryLines, l as blockingResults, m as checks, n as refusalMessage, p as loadOptions } from "./report-
|
|
1
|
+
import { a as writeSiteChecksReport, d as runSiteChecks, i as summaryLines, l as blockingResults, m as checks, n as refusalMessage, p as loadOptions } from "./report-DMjG_lMz.mjs";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
3
|
//#region src/astro.ts
|
|
4
4
|
/**
|
package/dist/dist-checks.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as referencedUrls, c as MAX_PATH_CHARS, g as loadDistContext, h as isSameSiteReference, l as blockingResults, o as MAX_FINDINGS_PER_CHECK, r as summarizeBlocking, s as MAX_MESSAGE_CHARS, t as SITE_CHECKS_FILE, u as runChecks, v as resolveReference, y as xmlText } from "./report-
|
|
1
|
+
import { _ as referencedUrls, c as MAX_PATH_CHARS, g as loadDistContext, h as isSameSiteReference, l as blockingResults, o as MAX_FINDINGS_PER_CHECK, r as summarizeBlocking, s as MAX_MESSAGE_CHARS, t as SITE_CHECKS_FILE, u as runChecks, v as resolveReference, y as xmlText } from "./report-DMjG_lMz.mjs";
|
|
2
2
|
//#region src/distChecks/insecureResources.ts
|
|
3
3
|
/** `<link>` relations the browser fetches as a subresource; canonical,
|
|
4
4
|
* alternate, preconnect and friends are hints or metadata, not loads. */
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as writeSiteChecksReport, c as MAX_PATH_CHARS, d as runSiteChecks, f as CONFIG_FILE, i as summaryLines, l as blockingResults, m as checks, n as refusalMessage, o as MAX_FINDINGS_PER_CHECK, p as loadOptions, r as summarizeBlocking, s as MAX_MESSAGE_CHARS, t as SITE_CHECKS_FILE } from "./report-
|
|
1
|
+
import { a as writeSiteChecksReport, c as MAX_PATH_CHARS, d as runSiteChecks, f as CONFIG_FILE, i as summaryLines, l as blockingResults, m as checks, n as refusalMessage, o as MAX_FINDINGS_PER_CHECK, p as loadOptions, r as summarizeBlocking, s as MAX_MESSAGE_CHARS, t as SITE_CHECKS_FILE } from "./report-DMjG_lMz.mjs";
|
|
2
2
|
export { CONFIG_FILE, MAX_FINDINGS_PER_CHECK, MAX_MESSAGE_CHARS, MAX_PATH_CHARS, SITE_CHECKS_FILE, blockingResults, checks, loadOptions, refusalMessage, runSiteChecks, summarizeBlocking, summaryLines, writeSiteChecksReport };
|
|
@@ -485,15 +485,25 @@ const quoteSources = {
|
|
|
485
485
|
/** More than this and the point is made; the runner keeps 25 anyway. */
|
|
486
486
|
const MAX_RAW_FINDINGS = 100;
|
|
487
487
|
const normalize$2 = (text) => text.normalize("NFC").toLowerCase().replace(/\s+/g, " ");
|
|
488
|
-
const
|
|
489
|
-
|
|
488
|
+
const escape$1 = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
489
|
+
const WORD = /[\p{L}\p{N}]/u;
|
|
490
|
+
/** A term as a whole word: where it starts or ends with a letter or digit, the text next to it must
|
|
491
|
+
* not continue the word, so "schlei" does not match "wendeschleife" and "emden" not "fremden". A
|
|
492
|
+
* term that starts or ends with other characters (a phone number's "+", a domain's dot) matches
|
|
493
|
+
* there as written. */
|
|
494
|
+
const wholeWord = (term) => {
|
|
495
|
+
const chars = [...term];
|
|
496
|
+
return new RegExp(`${WORD.test(chars[0]) ? "(?<![\\p{L}\\p{N}])" : ""}${escape$1(term)}${WORD.test(chars.at(-1)) ? "(?![\\p{L}\\p{N}])" : ""}`, "u");
|
|
497
|
+
};
|
|
498
|
+
const excerpt$1 = (haystack, at, length) => {
|
|
490
499
|
const start = Math.max(0, at - 30);
|
|
491
|
-
const end = Math.min(haystack.length, at +
|
|
500
|
+
const end = Math.min(haystack.length, at + length + 30);
|
|
492
501
|
return `${start > 0 ? "…" : ""}${haystack.slice(start, end)}${end < haystack.length ? "…" : ""}`;
|
|
493
502
|
};
|
|
494
503
|
/** Every site starts from a template ("donor") site, and nothing of it may ship: its brand, people,
|
|
495
504
|
* places, phone, email, domain, asset names. The site lists the terms in `site-checks.config.json`
|
|
496
|
-
* (`donorTerms`); without them the check skips, which the report shows.
|
|
505
|
+
* (`donorTerms`); without them the check skips, which the report shows. A term matches as a whole
|
|
506
|
+
* word, case-insensitively with whitespace collapsed. Matched in the visible
|
|
497
507
|
* text, the title, the inline scripts and styles (JSON-LD shows in search results) and the
|
|
498
508
|
* attributes of every built page, in the built file names and in the shipped JS and CSS, where an
|
|
499
509
|
* island's copy lives. */
|
|
@@ -502,23 +512,31 @@ const donorTerms = {
|
|
|
502
512
|
title: "Terms of the template site in the built output",
|
|
503
513
|
severity: "error",
|
|
504
514
|
begin: (ctx) => {
|
|
505
|
-
const terms = [...new Set(ctx.options.donorTerms.map(normalize$2).filter(Boolean))]
|
|
515
|
+
const terms = [...new Set(ctx.options.donorTerms.map(normalize$2).map((t) => t.trim()).filter(Boolean))].map((term) => ({
|
|
516
|
+
term,
|
|
517
|
+
re: wholeWord(term)
|
|
518
|
+
}));
|
|
506
519
|
if (terms.length === 0 || !ctx.hasDist) return null;
|
|
507
520
|
const findings = [];
|
|
508
521
|
/** One finding per term and place: the first text of `texts` that contains it. */
|
|
509
522
|
const scan = (texts, path, where) => {
|
|
510
|
-
|
|
523
|
+
const haystacks = texts.map(normalize$2);
|
|
524
|
+
for (const { term, re } of terms) {
|
|
511
525
|
if (findings.length >= MAX_RAW_FINDINGS) return;
|
|
512
|
-
const
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
526
|
+
for (const haystack of haystacks) {
|
|
527
|
+
const match = re.exec(haystack);
|
|
528
|
+
if (!match) continue;
|
|
529
|
+
findings.push({
|
|
530
|
+
path,
|
|
531
|
+
message: `donor term "${term}" in ${where}: "${excerpt$1(haystack, match.index, term.length)}"`
|
|
532
|
+
});
|
|
533
|
+
break;
|
|
534
|
+
}
|
|
517
535
|
}
|
|
518
536
|
};
|
|
519
537
|
return {
|
|
520
538
|
visit: (page) => {
|
|
521
|
-
scan([page.
|
|
539
|
+
scan([blockText(page.document.body ?? page.document.documentElement)], page.path, "the visible text");
|
|
522
540
|
scan(page.attributeValues(), page.path, "an attribute");
|
|
523
541
|
scan([...page.document.querySelectorAll("title, script:not([src]), style")].map((el) => el.textContent ?? ""), page.path, "the title or inline code");
|
|
524
542
|
},
|
|
@@ -536,7 +554,7 @@ const donorTerms = {
|
|
|
536
554
|
//#region src/checks/htmlComments.ts
|
|
537
555
|
/** Astro passes an HTML comment in a template straight into the built page, where a visitor reads
|
|
538
556
|
* it with View Source. Markdown pages too. */
|
|
539
|
-
const SOURCE_EXTENSIONS$
|
|
557
|
+
const SOURCE_EXTENSIONS$2 = /* @__PURE__ */ new Set([
|
|
540
558
|
".astro",
|
|
541
559
|
".tsx",
|
|
542
560
|
".jsx",
|
|
@@ -551,7 +569,7 @@ const htmlComments = {
|
|
|
551
569
|
severity: "error",
|
|
552
570
|
begin: (ctx) => ({ finish: () => {
|
|
553
571
|
const findings = [];
|
|
554
|
-
for (const file of ctx.sourceFiles(SOURCE_EXTENSIONS$
|
|
572
|
+
for (const file of ctx.sourceFiles(SOURCE_EXTENSIONS$2)) {
|
|
555
573
|
const text = ctx.readSource(file);
|
|
556
574
|
let index = text.indexOf("<!--");
|
|
557
575
|
while (index !== -1) {
|
|
@@ -1025,7 +1043,7 @@ const loadOrder = {
|
|
|
1025
1043
|
};
|
|
1026
1044
|
//#endregion
|
|
1027
1045
|
//#region src/checks/optimizeDeps.ts
|
|
1028
|
-
const SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
1046
|
+
const SOURCE_EXTENSIONS$1 = /* @__PURE__ */ new Set([
|
|
1029
1047
|
".ts",
|
|
1030
1048
|
".tsx",
|
|
1031
1049
|
".js",
|
|
@@ -1059,7 +1077,7 @@ const optimizeDeps = {
|
|
|
1059
1077
|
const ignored = new Set(ctx.options.optimizeDepsIgnore);
|
|
1060
1078
|
const runtime = ctx.packageJson.dependencies;
|
|
1061
1079
|
const importers = /* @__PURE__ */ new Map();
|
|
1062
|
-
for (const file of ctx.sourceFiles(SOURCE_EXTENSIONS)) {
|
|
1080
|
+
for (const file of ctx.sourceFiles(SOURCE_EXTENSIONS$1)) {
|
|
1063
1081
|
const text = ctx.readSource(file);
|
|
1064
1082
|
for (const match of text.matchAll(IMPORT_RE)) {
|
|
1065
1083
|
const [, typeOnly, fromSpecifier, dynamicSpecifier] = match;
|
|
@@ -1497,7 +1515,8 @@ const toPath = (loc) => {
|
|
|
1497
1515
|
const locs = (xml) => [...xml.matchAll(/<loc>\s*([^<]+?)\s*<\/loc>/g)].map((m) => xmlText(m[1]));
|
|
1498
1516
|
/** The URL lists the build publishes agree with the pages it built: no sitemap entry whose own page
|
|
1499
1517
|
* says noindex or is not in the build, no `llms.txt` link to a page that is not there. Skipped when
|
|
1500
|
-
* the build publishes neither (a site before launch
|
|
1518
|
+
* the build publishes neither. While every page is noindex (a site before launch, under its blanket
|
|
1519
|
+
* robots meta), a sitemap listing them is not refused: that disagreement ends with the launch. */
|
|
1501
1520
|
const sitemapNoindex = {
|
|
1502
1521
|
id: "sitemap-noindex",
|
|
1503
1522
|
title: "Published URL lists match the built pages",
|
|
@@ -1507,9 +1526,12 @@ const sitemapNoindex = {
|
|
|
1507
1526
|
const start = ctx.has(SITEMAP_INDEX) ? [SITEMAP_INDEX] : ctx.files.filter((f) => /^sitemap[^/]*\.xml$/.test(f));
|
|
1508
1527
|
if (start.length === 0 && !ctx.has(LLMS)) return null;
|
|
1509
1528
|
const noindex = /* @__PURE__ */ new Map();
|
|
1529
|
+
let indexable = 0;
|
|
1510
1530
|
return {
|
|
1511
1531
|
visit: (page) => {
|
|
1512
|
-
if (
|
|
1532
|
+
if (page.redirect) return;
|
|
1533
|
+
if (page.noindex) noindex.set(normalize(page.url), page.path);
|
|
1534
|
+
else indexable += 1;
|
|
1513
1535
|
},
|
|
1514
1536
|
finish: () => {
|
|
1515
1537
|
const findings = [];
|
|
@@ -1536,7 +1558,7 @@ const sitemapNoindex = {
|
|
|
1536
1558
|
path: sitemap,
|
|
1537
1559
|
message: `The sitemap lists ${loc}, which is not in the build.`
|
|
1538
1560
|
});
|
|
1539
|
-
else if (noindex.has(urlPath)) findings.push({
|
|
1561
|
+
else if (indexable > 0 && noindex.has(urlPath)) findings.push({
|
|
1540
1562
|
path: sitemap,
|
|
1541
1563
|
message: `The sitemap lists ${loc}, whose page says noindex: the sitemap filter and the noindex routes disagree.`
|
|
1542
1564
|
});
|
|
@@ -1984,7 +2006,8 @@ const FRAMEWORK_COMMENTS = /* @__PURE__ */ new Set([
|
|
|
1984
2006
|
"[",
|
|
1985
2007
|
"]",
|
|
1986
2008
|
"teleport start",
|
|
1987
|
-
"teleport end"
|
|
2009
|
+
"teleport end",
|
|
2010
|
+
"v-if"
|
|
1988
2011
|
]);
|
|
1989
2012
|
const isFrameworkComment = (data) => {
|
|
1990
2013
|
const text = data.trim();
|
|
@@ -2012,12 +2035,39 @@ const lineComments = (text) => findComments(text).filter(({ start, text: comment
|
|
|
2012
2035
|
while (k > 0 && (text[k - 1] === " " || text[k - 1] === " ")) k -= 1;
|
|
2013
2036
|
return k === 0 || LINE_BREAK.has(text[k - 1]);
|
|
2014
2037
|
}).map((comment) => comment.text);
|
|
2038
|
+
/** The site's own text files, where a comment it wrote into an inline script, style or handler
|
|
2039
|
+
* lives. */
|
|
2040
|
+
const SOURCE_EXTENSIONS = new Set(".astro .tsx .jsx .ts .js .mjs .cjs .css .scss .vue .md .mdx .html .json .svg".split(" "));
|
|
2041
|
+
/** Below this length a comment's inner text appears in almost any source by accident; such a
|
|
2042
|
+
* comment is matched whole, with its markers. */
|
|
2043
|
+
const MIN_INNER_TEXT = 8;
|
|
2044
|
+
const collapse = (text) => text.replace(/\s+/g, " ").trim();
|
|
2045
|
+
/** Whether the site wrote a comment found in an inline script, style or handler: its text,
|
|
2046
|
+
* whitespace collapsed, appears in a file under `src/` or `public/`. A comment in none of them
|
|
2047
|
+
* was rendered by a dependency during the build (c15t's theme `<style>` in the consent kit) and
|
|
2048
|
+
* is not the site's to remove. The files are read once, on the first inline comment. */
|
|
2049
|
+
const siteWrote = (ctx) => {
|
|
2050
|
+
let corpus;
|
|
2051
|
+
const seen = /* @__PURE__ */ new Map();
|
|
2052
|
+
return (comment) => {
|
|
2053
|
+
let wrote = seen.get(comment);
|
|
2054
|
+
if (wrote === void 0) {
|
|
2055
|
+
corpus ??= [...filesUnder(ctx.srcDir, SOURCE_EXTENSIONS), ...filesUnder(ctx.publicDir, SOURCE_EXTENSIONS)].map((file) => collapse(ctx.readSource(file))).join("\n");
|
|
2056
|
+
const inner = collapse(comment.startsWith("//") ? comment.slice(2) : comment.slice(2, -2));
|
|
2057
|
+
wrote = corpus.includes(inner.length < MIN_INNER_TEXT ? collapse(comment) : inner);
|
|
2058
|
+
seen.set(comment, wrote);
|
|
2059
|
+
}
|
|
2060
|
+
return wrote;
|
|
2061
|
+
};
|
|
2062
|
+
};
|
|
2015
2063
|
/** What a visitor can read with View Source, and no developer meant for them: comments in the
|
|
2016
|
-
* built pages
|
|
2017
|
-
*
|
|
2018
|
-
*
|
|
2019
|
-
*
|
|
2020
|
-
*
|
|
2064
|
+
* built pages; comments in their inline scripts, styles and event handlers that the site's own
|
|
2065
|
+
* source contains (one a dependency rendered during the build is not the site's); comments in
|
|
2066
|
+
* the JS and CSS copied verbatim from `public/` (line comments at a line start in JS, block
|
|
2067
|
+
* comments in CSS); source maps and references to them in every shipped file. JS and CSS the
|
|
2068
|
+
* bundler produced (`_astro/…`) are not scanned for comments: Vite minifies them and keeps only
|
|
2069
|
+
* licence banners, so what still looks like one is text inside a string (a bundled library's
|
|
2070
|
+
* shader or styles). */
|
|
2021
2071
|
const viewSource = {
|
|
2022
2072
|
id: "view-source",
|
|
2023
2073
|
title: "Developer notes visible in View Source",
|
|
@@ -2029,21 +2079,25 @@ const viewSource = {
|
|
|
2029
2079
|
path,
|
|
2030
2080
|
message: `${what}: "${excerpt(text)}"`
|
|
2031
2081
|
});
|
|
2082
|
+
const wrote = siteWrote(ctx);
|
|
2083
|
+
const reportInline = (path, what, comment) => {
|
|
2084
|
+
if (wrote(comment)) report(path, what, comment);
|
|
2085
|
+
};
|
|
2032
2086
|
const visit = (page) => {
|
|
2033
2087
|
for (const comment of page.comments()) if (!isFrameworkComment(comment)) report(page.path, "HTML comment in the page", comment);
|
|
2034
2088
|
for (const el of page.document.querySelectorAll("*")) for (const name of el.getAttributeNames()) {
|
|
2035
2089
|
if (!name.startsWith("on")) continue;
|
|
2036
2090
|
const code = el.getAttribute(name) ?? "";
|
|
2037
2091
|
const what = `comment in an inline ${name} handler`;
|
|
2038
|
-
for (const comment of jsComments(code)) if (!DIRECTIVE.test(comment) && !LEGAL_BLOCK_COMMENT.test(comment))
|
|
2092
|
+
for (const comment of jsComments(code)) if (!DIRECTIVE.test(comment) && !LEGAL_BLOCK_COMMENT.test(comment)) reportInline(page.path, what, comment);
|
|
2039
2093
|
}
|
|
2040
2094
|
for (const el of page.document.querySelectorAll("script, style")) {
|
|
2041
2095
|
const text = el.textContent ?? "";
|
|
2042
2096
|
const what = `comment in an inline <${el.tagName.toLowerCase()}>`;
|
|
2043
|
-
for (const comment of blockComments(text))
|
|
2097
|
+
for (const comment of blockComments(text)) reportInline(page.path, what, comment);
|
|
2044
2098
|
if (el.tagName === "SCRIPT") {
|
|
2045
2099
|
if (SOURCE_MAP_URL.test(text)) report(page.path, "source map reference in an inline <script>", text);
|
|
2046
|
-
for (const comment of lineComments(text))
|
|
2100
|
+
for (const comment of lineComments(text)) reportInline(page.path, what, comment);
|
|
2047
2101
|
}
|
|
2048
2102
|
}
|
|
2049
2103
|
};
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
Release notes of `@v-office/site-checks`, newest first. Each version has its own directory.
|
|
6
6
|
|
|
7
|
+
- `versions/0.2.3/CHANGELOG.md`: release notes for 0.2.3
|
|
8
|
+
- `versions/0.2.2/CHANGELOG.md`: release notes for 0.2.2
|
|
7
9
|
- `versions/0.2.1/CHANGELOG.md`: release notes for 0.2.1
|
|
8
10
|
- `versions/0.2.0/CHANGELOG.md`: release notes for 0.2.0
|
|
9
11
|
- `versions/0.1.0/CHANGELOG.md`: release notes for 0.1.0
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
Migration guides of `@v-office/site-checks`, newest first. Apply them in order when skipping versions.
|
|
6
6
|
|
|
7
|
+
- `versions/0.2.3/MIGRATION.md`: Migration: 0.2.2 to 0.2.3
|
|
8
|
+
- `versions/0.2.2/MIGRATION.md`: Migration: 0.2.1 to 0.2.2
|
|
7
9
|
- `versions/0.2.1/MIGRATION.md`: Migration: 0.2.0 to 0.2.1
|
|
8
10
|
- `versions/0.2.0/MIGRATION.md`: Migration: 0.1.0 to 0.2.0
|
|
9
11
|
- `versions/0.1.0/MIGRATION.md`: Migration: 0.1.0
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Changelog: 0.2.2
|
|
2
|
+
|
|
3
|
+
A fix for consent-kit sites: `view-source` refused their build over a comment that c15t writes into
|
|
4
|
+
the theme `<style>` it renders on every page, which the site never wrote and cannot remove.
|
|
5
|
+
|
|
6
|
+
## Changed
|
|
7
|
+
|
|
8
|
+
- `view-source` refuses a comment in an inline `<script>`, `<style>` or event handler only when the
|
|
9
|
+
site's own source contains it: its text, whitespace aside, appears in a file under `src/` or
|
|
10
|
+
`public/`. A comment a dependency renders during the build, such as c15t's theme style in the
|
|
11
|
+
consent kit (`/* Utility class to disable transitions during theme switching */`), no longer
|
|
12
|
+
refuses the build. A comment you wrote into an inline script, style or handler is still
|
|
13
|
+
refused; remove it from your source.
|
|
14
|
+
- HTML comments in the built pages, comments in JS and CSS copied from `public/`, and source maps
|
|
15
|
+
are refused as before.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Changelog: 0.2.3
|
|
2
|
+
|
|
3
|
+
Three fixes for false refusals found while rolling site-checks out to the sites: a site before
|
|
4
|
+
launch, a donor term inside a longer word, and Vue's own placeholder comment.
|
|
5
|
+
|
|
6
|
+
## Fixed
|
|
7
|
+
|
|
8
|
+
- `sitemap-noindex` waits while every page is noindex (a site before launch, under its blanket
|
|
9
|
+
robots meta): a sitemap that lists those pages is no longer refused then. Once any page is
|
|
10
|
+
indexable it applies as before. A sitemap entry or `llms.txt` link to a page the build does not
|
|
11
|
+
have is still refused, launched or not.
|
|
12
|
+
- `donor-terms` matches a term as a whole word: "Schlei" no longer matches "Wendeschleife", nor
|
|
13
|
+
"Emden" "fremden". Matching stays case-insensitive with whitespace collapsed; a term that starts
|
|
14
|
+
or ends with something other than a letter or digit (a phone number's "+", a domain) matches
|
|
15
|
+
there as written. The visible text is read as a visitor sees it, so a word split by inline
|
|
16
|
+
markup (`Wende<em>schlei</em>fe`) is one word.
|
|
17
|
+
- `view-source` allows the HTML comment `v-if`, the placeholder Vue renders for a false `v-if` (for example
|
|
18
|
+
a closed reka-ui or shadcn-vue dialog portal). No developer writes it.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Migration: 0.2.2 to 0.2.3
|
|
2
|
+
|
|
3
|
+
No changes required.
|
|
4
|
+
|
|
5
|
+
## 1. Upgrade
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
pnpm add --save-exact --save-dev @v-office/site-checks@0.2.3
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## What changes for the site
|
|
12
|
+
|
|
13
|
+
- Before launch, a sitemap listing the site's noindex pages no longer refuses the build.
|
|
14
|
+
- `donorTerms` entries match whole words. A term that relied on matching inside a longer word (a
|
|
15
|
+
prefix such as "brisen" meant to catch "Brisenhof") now needs the full word; list every spelling.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@v-office/site-checks",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Build-time checks for the sites: runs inside `astro build`, writes dist/site-checks.json in the shape of the build worker's dist-check report, and refuses the build when a check with severity error finds something. The site-shipping guards of the commit gate, pinned and run where the site is built",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|