@v-office/site-checks 0.5.3 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -49
- package/dist/bin.mjs +1 -1
- package/dist/{cli-BZOXjO-z.mjs → cli-CZHXyJcd.mjs} +228 -19
- package/dist/index.d.mts +3 -2
- package/dist/index.mjs +1 -1
- package/instructions/CHANGELOG.md +2 -0
- package/instructions/MIGRATION.md +2 -0
- package/instructions/versions/0.5.4/CHANGELOG.md +37 -0
- package/instructions/versions/0.5.4/MIGRATION.md +49 -0
- package/instructions/versions/0.6.0/CHANGELOG.md +24 -0
- package/instructions/versions/0.6.0/MIGRATION.md +12 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -79,26 +79,26 @@ findings it excludes (below). Severities are fixed by the package. A key of a ch
|
|
|
79
79
|
an earlier version had (`wiring`, `optimizeDepsIgnore`) is noted and ignored; an unknown key stops
|
|
80
80
|
the command.
|
|
81
81
|
|
|
82
|
-
| Key | Used by | What
|
|
83
|
-
| ------------------------- | ---------------------------------- |
|
|
84
|
-
| `donorTerms` | the donor checks | 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.
|
|
85
|
-
| `donorPatterns` | the donor checks | Regular expressions for donor traces a term cannot say (`Brisen(hof\|haus)` also in "Brisenhofer"), matched as written: case-sensitive, in words, whitespace collapsed; no POSIX classes.
|
|
86
|
-
| `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`).
|
|
87
|
-
| `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, `imgproxy.*` hosts, imgproxy base64 paths, `dyn.v-office.com`).
|
|
88
|
-
| `listingPages` | `listing-noindex`, `listing-links` | URL paths of pages that list rentals, in addition to the pages the check recognizes by their markup.
|
|
89
|
-
| `listingClientOnly` | `listing-noindex`, `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.
|
|
90
|
-
| `consentAllowedHosts` | the consent checks | Hosts a `<script src>` or `<iframe src>` may load before consent. The site's own host is always allowed.
|
|
91
|
-
| `hubFilterOptions` | `v9-hub-filters` | v9: the Website SDK options the Hub filter check needs (`rentalScope`, `customAttributeFilterDefinitions`), as the site passes them; `src/data/hub-filters.json` wins over a copy here.
|
|
92
|
-
| `structureIgnore` | `page-structure`, `heading-ratio` | Rules the site declines: `one-h1`, `heading-skip`, `landmark-main`, `img-alt`, `control-label`, `table-headers`; `heading-ratio` turns that check off.
|
|
93
|
-
| `bannedCopy` | `banned-copy`, `banned-copy-src` | Wordings recorded customer corrections ban, as `{ "pattern", "why" }` (a regular expression over the page's
|
|
94
|
-
| `copyExcludePaths` | the copy checks | URL paths (and below) the copy checks skip, legal pages ported verbatim; `/impressum` also covers `/de/impressum`.
|
|
95
|
-
| `bannedCopyExcludePaths` | `banned-copy`
|
|
96
|
-
| `address` | `copy-address` | The one form of address of the site's German texts: `"du"` or `"Sie"`. Unset or `null`, the check waits.
|
|
97
|
-
| `addressAllow` | `copy-address` | German texts the check misreads (a sentence-initial „Sie" meaning she or they), as the text's exact wording.
|
|
98
|
-
| `allowDuplicateSentences` | `duplicate-sentences` | Sentences a page may render twice.
|
|
99
|
-
| `quoteSources` | `quote-sources` | Files or directories holding the text a `<blockquote>` may quote (content captures, the feed's reviews written by the build).
|
|
100
|
-
| `factCheckAccepted` | `rental-facts` | Disagreements the customer confirmed, as the finding prints them: `<slug> <kind> prose=<n> feed=<n>`.
|
|
101
|
-
| `exclude` | every check | The findings the site accepts, by check id: see [Excluding findings](#excluding-findings).
|
|
82
|
+
| Key | Used by | What |
|
|
83
|
+
| ------------------------- | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
84
|
+
| `donorTerms` | the donor checks | 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. |
|
|
85
|
+
| `donorPatterns` | the donor checks | Regular expressions for donor traces a term cannot say (`Brisen(hof\|haus)` also in "Brisenhofer"), matched as written: case-sensitive, in words, whitespace collapsed; no POSIX classes. |
|
|
86
|
+
| `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`). |
|
|
87
|
+
| `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, `imgproxy.*` hosts, imgproxy base64 paths, `dyn.v-office.com`). |
|
|
88
|
+
| `listingPages` | `listing-noindex`, `listing-links` | URL paths of pages that list rentals, in addition to the pages the check recognizes by their markup. |
|
|
89
|
+
| `listingClientOnly` | `listing-noindex`, `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. |
|
|
90
|
+
| `consentAllowedHosts` | the consent checks | Hosts a `<script src>` or `<iframe src>` may load before consent. The site's own host is always allowed. |
|
|
91
|
+
| `hubFilterOptions` | `v9-hub-filters` | v9: the Website SDK options the Hub filter check needs (`rentalScope`, `customAttributeFilterDefinitions`), as the site passes them; `src/data/hub-filters.json` wins over a copy here. |
|
|
92
|
+
| `structureIgnore` | `page-structure`, `heading-ratio` | Rules the site declines: `one-h1`, `heading-skip`, `landmark-main`, `img-alt`, `control-label`, `table-headers`; `heading-ratio` turns that check off. |
|
|
93
|
+
| `bannedCopy` | `banned-copy`, `banned-copy-src` | Wordings recorded customer corrections ban, as `{ "pattern", "why" }` (a regular expression over the page's text and its attribute values; one equal to a built-in empty-state pattern is dropped: `empty-state-copy` reports it). With `"in": "src"` the ban reads the site's own text in `src/` instead (`banned-copy-src`), never the page, which also prints the feed's text; `"srcExclude"` lists path prefixes it skips (`src/data/legal/`). |
|
|
94
|
+
| `copyExcludePaths` | the copy checks | URL paths (and below) the copy checks skip, legal pages ported verbatim; `/impressum` also covers `/de/impressum`. |
|
|
95
|
+
| `bannedCopyExcludePaths` | `banned-copy`, `empty-state-copy` | URL paths only `banned-copy` and `empty-state-copy` skip (an FAQ whose answers port verbatim). |
|
|
96
|
+
| `address` | `copy-address` | The one form of address of the site's German texts: `"du"` or `"Sie"`. Unset or `null`, the check waits. |
|
|
97
|
+
| `addressAllow` | `copy-address` | German texts the check misreads (a sentence-initial „Sie" meaning she or they), as the text's exact wording. |
|
|
98
|
+
| `allowDuplicateSentences` | `duplicate-sentences` | Sentences a page may render twice. |
|
|
99
|
+
| `quoteSources` | `quote-sources` | Files or directories holding the text a `<blockquote>` may quote (content captures, the feed's reviews written by the build). |
|
|
100
|
+
| `factCheckAccepted` | `rental-facts` | Disagreements the customer confirmed, as the finding prints them: `<slug> <kind> prose=<n> feed=<n>`. |
|
|
101
|
+
| `exclude` | every check | The findings the site accepts, by check id: see [Excluding findings](#excluding-findings). |
|
|
102
102
|
|
|
103
103
|
## Excluding findings
|
|
104
104
|
|
|
@@ -187,6 +187,7 @@ unrelated findings, `match` picks one.
|
|
|
187
187
|
| `load-order` | `{ "match": "leaflet" }` | the findings about that library |
|
|
188
188
|
| `first-paint-photos` | `{ "match": "/img/hero.jpg" }` | the findings about that photo |
|
|
189
189
|
| `banned-copy` | `"/faq"` | that page (or `bannedCopyExcludePaths`) |
|
|
190
|
+
| `empty-state-copy` | `{ "path": "/unterkuenfte", "match": "Keine Unterkunft" }` | that wording on those pages (a rental's own text) |
|
|
190
191
|
| `duplicate-sentences` | `{ "match": "Wir freuen uns auf Ihre Anfrage" }` | that sentence on every page (or `allowDuplicateSentences`) |
|
|
191
192
|
| `quote-sources` | `"/bewertungen"` | that page |
|
|
192
193
|
| `rental-facts` | `"/unterkunft/seeblick"` | that rental (`factCheckAccepted` accepts one exact disagreement) |
|
|
@@ -224,35 +225,37 @@ unrelated findings, `match` picks one.
|
|
|
224
225
|
|
|
225
226
|
### `dist`: after the build
|
|
226
227
|
|
|
227
|
-
| id | Severity | What it refuses or reports
|
|
228
|
-
| --------------------- | -------- |
|
|
229
|
-
| `view-source` | error | A developer's note a visitor can read with View Source: an HTML comment in a built page, before or after `<html>` (exact framework markers and wordless ones allowed); a comment in an inline script, style, `style` attribute or handler, or in shipped JS or CSS (`_astro/`, `public/`), whose text is in a project file (not `node_modules`, `dist/`); a source map. Licence banners are allowed, and a library shipped from `public/` as it comes (`*.min.js`/`*.min.css`, a `vendor/` folder, or a licence banner on top) is not read.
|
|
230
|
-
| `donor-terms` | warning | A `donorTerms` term (whole word) or `donorPatterns` match 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. A warning: pages carry the PMS feed's text; the site's own source is `donor-terms-source`. Skipped without terms and patterns.
|
|
231
|
-
| `consent-gate` | error | A third-party `<script src>` or `<iframe src>` outside the consent kit's `ConsentEmbed` frame, loading before consent (needs the site's host); an enabled vendor not `approved` in `consent-registry.snapshot.json`; an `ENABLED_VENDOR_IDS` that is not a literal of quoted ids, or a snapshot that does not parse. Skipped without `src/lib/consent/`.
|
|
232
|
-
| `
|
|
233
|
-
| `
|
|
234
|
-
| `listing-
|
|
235
|
-
| `
|
|
236
|
-
| `sitemap-
|
|
237
|
-
| `
|
|
238
|
-
| `
|
|
239
|
-
| `
|
|
240
|
-
| `
|
|
241
|
-
| `
|
|
242
|
-
| `
|
|
243
|
-
| `
|
|
244
|
-
| `
|
|
245
|
-
| `
|
|
246
|
-
| `
|
|
247
|
-
| `
|
|
248
|
-
| `
|
|
249
|
-
| `
|
|
250
|
-
| `
|
|
251
|
-
| `
|
|
252
|
-
| `
|
|
253
|
-
| `
|
|
254
|
-
| `
|
|
255
|
-
| `
|
|
228
|
+
| id | Severity | What it refuses or reports | How to fix |
|
|
229
|
+
| --------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
230
|
+
| `view-source` | error | A developer's note a visitor can read with View Source: an HTML comment in a built page, before or after `<html>` (exact framework markers and wordless ones allowed); a comment in an inline script, style, `style` attribute or handler, or in shipped JS or CSS (`_astro/`, `public/`), whose text is in a project file (not `node_modules`, `dist/`); a source map. Licence banners are allowed, and a library shipped from `public/` as it comes (`*.min.js`/`*.min.css`, a `vendor/` folder, or a licence banner on top) is not read. | Remove the comment or move it where the build drops it (`//` in frontmatter); turn source maps off. |
|
|
231
|
+
| `donor-terms` | warning | A `donorTerms` term (whole word) or `donorPatterns` match 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. A warning: pages carry the PMS feed's text; the site's own source is `donor-terms-source`. Skipped without terms and patterns. | Replace the term; list the template site's terms in `donorTerms`. |
|
|
232
|
+
| `consent-gate` | error | A third-party `<script src>` or `<iframe src>` outside the consent kit's `ConsentEmbed` frame, loading before consent (needs the site's host); an enabled vendor not `approved` in `consent-registry.snapshot.json`; an `ENABLED_VENDOR_IDS` that is not a literal of quoted ids, or a snapshot that does not parse. 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`. |
|
|
233
|
+
| `consent-manager` | warning | On a site that imports the consent manager from website-components (and has no `src/lib/consent/`): a third-party `<script src>` or `<iframe src>` outside a gate's template or a `ConsentScript` (needs the site's host; `consentAllowedHosts` allowed); a pasted Google Tag Manager or Google tag snippet, and `gtm.js` anywhere, in a gate too; a gate rendered inside an island; a page with gated content but no `ConsentBanner` island; a service id that is not a catalog id. | Gate it with `ConsentGate`, `ConsentScript` or `GoogleTagManager`; put the banner in the layout; name the service by its catalog id. |
|
|
234
|
+
| `feed-image-formats` | warning | A feed photo from the vOffice image hosts requested as JPEG or PNG: in `src`, `srcset` or `poster`, any other attribute (island props, `style`), inline scripts (JSON) and styles (`background-image`); a warning because the photos come from the PMS feed. | Pass feed photos through `webpUrl()`; end an imgproxy URL in `.webp`. |
|
|
235
|
+
| `listing-noindex` | error | A page that lists rentals (the search page's `data-prerendered-results` container, the `SearchResults` island, or `listingPages`) that is noindex. Not a listing: a rental page (`data-rental-stats`), the favourites grid, a `listingClientOnly` page. Waits while no page but the 404 page and redirect stubs is indexable. | Take the page out of the noindex routes. |
|
|
236
|
+
| `listing-links` | warning | A page that lists rentals whose list carries no link to a rental page (a page with `data-rental-stats`) in its HTML, so a crawler without JavaScript sees an empty list. Runs once the build has a rental page; a warning because the links come from the PMS feed. | Render the list server-side, or list the page in `listingClientOnly` with the reason. |
|
|
237
|
+
| `sitemap-noindex` | error | A sitemap entry whose page says noindex (waits while every page is noindex; the 404 and 500 pages and redirect stubs do not count) or is not in the build, in every `sitemap*.xml` of the build and every sitemap an index names; an `llms.txt` link to a page that is not there; an `llms.txt` without the spec's shape (`# ` heading first, a `> ` summary above the first section, `## ` sections). Skipped without a sitemap and `llms.txt`. | Make the sitemap filter and the noindex routes agree; fix the link or the shape. |
|
|
238
|
+
| `sitemap-coverage` | warning | An indexable page the sitemap does not list; a `sitemap-index.xml` without a `/sitemap.xml` beside it. Skipped without a sitemap. | List the page or give it noindex; write a copy of the index as `sitemap.xml`. |
|
|
239
|
+
| `orphan-pages` | warning | An indexable page (not the home page) no other built page links to in its HTML; links an island renders in the browser do not count. | Link it from a page a crawler reaches. |
|
|
240
|
+
| `page-heads` | warning | On indexable pages: a title over 60 characters, a description empty or over 160, a title or description another page repeats (language versions naming each other as `hreflang` alternates do not count), a title naming the site (`og:site_name`) twice. A missing one is `page-metadata`. | Shorten; give each page its own; name the site once. |
|
|
241
|
+
| `canonical-link` | error | On the launched site (a production site URL, some indexable page), an indexable page whose `<link rel="canonical">` is missing, not absolute, on another origin than the site's, with a query or fragment, naming another page while the sitemap lists this one, or in the other URL form than `trailingSlash` (`"never"`: no trailing slash; `"always"`: one). | Build it from the Astro `site` and the page's own path. |
|
|
242
|
+
| `open-graph` | warning | On the launched site: an indexable page without an absolute `og:url` and `og:image`, or whose `og:url` is not its canonical URL. | Add them, absolute; use the canonical URL as `og:url`. |
|
|
243
|
+
| `trailing-slash` | warning | On the launched site: `trailingSlash` is not `"never"`. | Set `trailingSlash: "never"`; write internal links without a trailing slash. |
|
|
244
|
+
| `json-ld` | error | A `<script type="application/ld+json">` block on any page that does not parse. | Build the block from an object with `JSON.stringify`. |
|
|
245
|
+
| `rental-markup` | error | On the launched site: an indexable rental page (the rental blocks' `data-rental-stats` marker) without `VacationRental` JSON-LD (in `@graph`, a type list or nested). | Render the rental's `VacationRental` block from the feed's values, or exclude `rental-markup` with the reason. |
|
|
246
|
+
| `breadcrumbs` | warning | A `BreadcrumbList` item on the site's own origin (or relative) that no page of the build serves. | Point the item at the built page. |
|
|
247
|
+
| `v9-production-hub` | error | v9 only, on the launched site: the build's env does not call the production Hub (`CMS_STAGE=production` or the production Hub URLs); a committed `.env.local`; a `HUB_API_KEY` equal to `.env.local`'s. Waits for a production site URL and an indexable page. | Set the production stage or URLs and the customer's production key; untrack `.env.local`. |
|
|
248
|
+
| `v10-production-api` | error | v10 only (`CMS_BACKEND=v10`, else AI Studio's `PMS_BACKEND=v10`), on the launched site: the build's env does not call the production vOffice API (`CMS_STAGE=production` or the production `VOFFICE_*` endpoints); a committed `.env.local`; a `VOFFICE_LOCAL_DEV_ACCESS_TOKEN` equal to `.env.local`'s. Waits like `v9-production-hub`. | Set the production stage or endpoints and the customer's production token; untrack `.env.local`. |
|
|
249
|
+
| `page-structure` | warning | One `<h1>`, no skipped heading level, a `<main>`, `alt` on every image, a label on every control the keyboard reaches (only `aria-hidden` with `tabindex="-1"` is out of reach), a caption (or `aria-label`/`aria-labelledby`) and scoped `<th>` on every table. | Fix the component where a fault repeats; decline a rule in `structureIgnore`. |
|
|
250
|
+
| `heading-ratio` | warning | Ten or more `<h3>` and more than three times as many as `<h2>` on a page: usually card titles marked up as headings. | Style a `<p>` for a card's name; decline it in `structureIgnore`. |
|
|
251
|
+
| `voffice-credit` | error | A page whose site footer (a `<footer>` outside `main`, `article`, `section`, `aside`, `nav`, `blockquote`, `figure`, `dialog`) has no link to `https://www.v-office.com` (look-alike hosts and `dyn.v-office.com` do not count); a home page (a locale's `de/index.html` too) without a site footer. The wording is not read. | Add `Realisiert mit <a href="https://www.v-office.com">vOffice</a>` to the site footer, worded per language. |
|
|
252
|
+
| `load-order` | warning | At start: an on-demand library (map, chart, 3D) in the start-up code, a start-up chunk over 150 KB compressed, photos after the first in card swipe strips with a URL, a swap face without a `size-adjust` stand-in (preloaded, or apart: not preloaded), a used `font-display: optional` face. Stacks are read from `font-family` and `--font-*`. | `import()` on demand; first slide only; `swap` with a `local()` stand-in. |
|
|
253
|
+
| `first-paint-photos` | error | A first-paint photo (not lazy) or image preload from 100 KB up, a file of the build, in one size only (no width `srcset` / `imagesrcset`); in the `<header>`/`<section>` of the `fetchpriority="high"` photo, a hidden slide (`aria-hidden`, `inert`, `invisible` or `opacity-0`, also at a breakpoint, never a `hover:` state; `hidden` or a closed `<dialog>` when the image is not lazy) whose image carries a URL, an SVG icon aside. | Width variants in a `srcset` with a measured `sizes`; hidden slides get `data-src` and their URL after load. |
|
|
254
|
+
| `banned-copy` | warning | A `bannedCopy` wording (not scoped `"in": "src"`) in a page's text or one of its attribute values (an island's `props`), entities decoded; never inside a `<script>` or `<style>`. Once per wording and place per page. Skipped without configured wordings. | Reword. |
|
|
255
|
+
| `empty-state-copy` | warning | On every site, configured or not: a built-in German or English sentence true in one state only, as the kits word it: the search, map, favourites or offers finding nothing ("Keine Unterkunft gefunden", "An deinen Wunschdaten leider ausgebucht", "No exact matches"), the search failing, a rental not available for the chosen dates, in a page's HTML, read as `banned-copy` reads it: `hidden`, `<noscript>` and `<template>` text and attribute values count, `<script>` contents never. A reader that runs no script (an AI assistant) repeats it as a fact about the agency. Skips `copyExcludePaths` and `bannedCopyExcludePaths`. | Write the sentence in by script only while it applies (a JSON `<script>`, an inline script or the JS chunk), as search-results-kit 5.2.0/5.4.0 does. |
|
|
256
|
+
| `duplicate-sentences` | warning | The same sentence rendered twice on one page. Waits while every page but the 404 page is noindex. | Remove one, or list it in `allowDuplicateSentences`. |
|
|
257
|
+
| `quote-sources` | warning | A `<blockquote>` not word for word in `quoteSources`; a configured source that is missing (when none is there, only that). Skipped without sources. | Quote the source exactly; restore the step that writes the source. |
|
|
258
|
+
| `rental-facts` | warning | On rental pages (the rental blocks' `data-rental-stats` / `data-rental-description` markers, and a site's own `data-rental-facts` chip row): the fact row against the same number in the owner's German description; a perk line of `src/data/perks.ts` a unit's amenities do not back; rental pages on which nothing was compared at all (a description without its marker, or no figure stated). | The customer corrects the PMS; a confirmed one goes into `factCheckAccepted`. |
|
|
256
259
|
|
|
257
260
|
The `dist` stage also runs the platform's dist checks, warnings but for `not-found-beacon` (an
|
|
258
261
|
error: the 404 page's own code never calls `fetch` or `sendBeacon` with `/api/404-log`, in its scripts
|
package/dist/bin.mjs
CHANGED
|
@@ -303,13 +303,13 @@ const blankSourceComments = (raw, extension) => {
|
|
|
303
303
|
// src/checks/consentGate.ts
|
|
304
304
|
/** The consent kit's files in a site: its presence under `src/lib/consent/` is what makes the
|
|
305
305
|
* check apply; the vendors the site enables and the fleet registry's review of them. */
|
|
306
|
-
const KIT_DIR = "src/lib/consent/";
|
|
306
|
+
const KIT_DIR$1 = "src/lib/consent/";
|
|
307
307
|
const ENABLED_FILE = "src/data/consent.ts";
|
|
308
308
|
const REGISTRY_FILE = "src/data/consent-registry.snapshot.json";
|
|
309
309
|
/** The kit's click-to-load frame (`ConsentEmbed.astro`): a third-party frame inside it loads after
|
|
310
310
|
* consent, so it is not a leak. */
|
|
311
311
|
const EMBED_TEMPLATE = "template[data-embed-content]";
|
|
312
|
-
const hostOf = (url) => {
|
|
312
|
+
const hostOf$1 = (url) => {
|
|
313
313
|
try {
|
|
314
314
|
return new URL(url).host;
|
|
315
315
|
} catch {
|
|
@@ -321,7 +321,7 @@ const LEAK_FIX = "Frame it with ConsentEmbed, or register the vendor so the kit
|
|
|
321
321
|
const kitSources = (ctx) => {
|
|
322
322
|
const sources = ctx.sourceFiles(/* @__PURE__ */ new Set([".ts", ".json"]));
|
|
323
323
|
const byRel = new Map(sources.map((file) => [ctx.rel(file), file]));
|
|
324
|
-
return [...byRel.keys()].some((rel) => rel.startsWith(KIT_DIR)) ? byRel : null;
|
|
324
|
+
return [...byRel.keys()].some((rel) => rel.startsWith(KIT_DIR$1)) ? byRel : null;
|
|
325
325
|
};
|
|
326
326
|
/** Each vendor the site enables, against the fleet registry's review. What cannot be read is a
|
|
327
327
|
* finding, never a pass: a list the check cannot read, or a registry that does not parse, would
|
|
@@ -376,7 +376,7 @@ const consentGate = {
|
|
|
376
376
|
begin: (ctx) => {
|
|
377
377
|
const byRel = kitSources(ctx);
|
|
378
378
|
if (!byRel) return null;
|
|
379
|
-
const siteHost = ctx.config.site ? hostOf(ctx.config.site) : void 0;
|
|
379
|
+
const siteHost = ctx.config.site ? hostOf$1(ctx.config.site) : void 0;
|
|
380
380
|
const allowed = new Set(ctx.options.consentAllowedHosts);
|
|
381
381
|
const findings = [];
|
|
382
382
|
return {
|
|
@@ -386,7 +386,7 @@ const consentGate = {
|
|
|
386
386
|
const raw = (el.getAttribute("src") ?? "").trim();
|
|
387
387
|
const src = raw.startsWith("//") ? `https:${raw}` : raw;
|
|
388
388
|
if (!/^https?:\/\//i.test(src)) continue;
|
|
389
|
-
const host = hostOf(src);
|
|
389
|
+
const host = hostOf$1(src);
|
|
390
390
|
if (!host || host === siteHost || allowed.has(host)) continue;
|
|
391
391
|
if (el.closest(EMBED_TEMPLATE)) continue;
|
|
392
392
|
findings.push({
|
|
@@ -410,7 +410,7 @@ const MARKUP = /* @__PURE__ */ new Set([
|
|
|
410
410
|
]);
|
|
411
411
|
/** The consent layer: the kit's components (ConsentEmbed's template frame, the gated loaders) and
|
|
412
412
|
* its library inject vendors after consent. */
|
|
413
|
-
const CONSENT_LAYER = ["src/components/consent/", KIT_DIR];
|
|
413
|
+
const CONSENT_LAYER = ["src/components/consent/", KIT_DIR$1];
|
|
414
414
|
/** ConsentEmbed's click-to-load frame written out in a page: loaded after consent. */
|
|
415
415
|
const EMBED_TEMPLATE_SOURCE = /<template\b[^>]*\bdata-embed-content\b[^>]*>[\s\S]*?<\/template\s*>/gi;
|
|
416
416
|
/** A `<script>` or `<iframe>` whose `src` is an absolute or protocol-relative URL: quoted, or a
|
|
@@ -428,7 +428,7 @@ const consentGateSource = {
|
|
|
428
428
|
severity: "error",
|
|
429
429
|
stage: "src",
|
|
430
430
|
begin: (ctx) => {
|
|
431
|
-
const siteHost = ctx.config.site ? hostOf(ctx.config.site) : void 0;
|
|
431
|
+
const siteHost = ctx.config.site ? hostOf$1(ctx.config.site) : void 0;
|
|
432
432
|
if (!kitSources(ctx) || !siteHost) return null;
|
|
433
433
|
const allowed = new Set(ctx.options.consentAllowedHosts);
|
|
434
434
|
return { finish: () => {
|
|
@@ -441,7 +441,7 @@ const consentGateSource = {
|
|
|
441
441
|
for (const match of text.matchAll(VENDOR_TAG)) {
|
|
442
442
|
const url = match[3];
|
|
443
443
|
const absolute = url.startsWith("//") ? `https:${url}` : url;
|
|
444
|
-
const host = hostOf(absolute) ?? absolute.replace(/^https?:\/\//i, "").split("/")[0];
|
|
444
|
+
const host = hostOf$1(absolute) ?? absolute.replace(/^https?:\/\//i, "").split("/")[0];
|
|
445
445
|
if (host === siteHost || allowed.has(host)) continue;
|
|
446
446
|
const line = text.slice(0, match.index).split("\n").length;
|
|
447
447
|
findings.push({
|
|
@@ -454,6 +454,132 @@ const consentGateSource = {
|
|
|
454
454
|
} };
|
|
455
455
|
}
|
|
456
456
|
};
|
|
457
|
+
// src/checks/consentManager.ts
|
|
458
|
+
/** The consent kit sites copied before the platform's consent manager: `consent-gate` checks a
|
|
459
|
+
* site that still has it. */
|
|
460
|
+
const KIT_DIR = "src/lib/consent/";
|
|
461
|
+
const SOURCES = /* @__PURE__ */ new Set([
|
|
462
|
+
".astro",
|
|
463
|
+
".tsx",
|
|
464
|
+
".jsx",
|
|
465
|
+
".ts",
|
|
466
|
+
".js",
|
|
467
|
+
".mjs",
|
|
468
|
+
".mdx"
|
|
469
|
+
]);
|
|
470
|
+
/** An import of the consent manager's components or hook from website-components, or a local
|
|
471
|
+
* barrel's re-export of them (as site-manifest reads imports): what makes a site one on the new
|
|
472
|
+
* manager. Its own components of the same names (the kit's) do not count. */
|
|
473
|
+
const MANAGER_IMPORT = /(?:import|export)(?:\s+[\w$]+\s*,)?\s*\{[^}]*\b(?:ConsentBanner|ConsentGate|ConsentScript|GoogleTagManager|useServiceConsent|ConsentServiceTable|ConsentSettingsLink)\b[^}]*\}\s*from\s*["']@v-office\/website-components(?:\/consent)?["']/;
|
|
474
|
+
/** A catalog service id, as site-manifest reads it (CONSENT_ID_RE there). */
|
|
475
|
+
const CATALOG_ID = /^(?=.{1,64}$)[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
476
|
+
/** Google's own loaders, written into an inline snippet. */
|
|
477
|
+
const GOOGLE_LOADER = /googletagmanager\.com\/(?:gtm|gtag\/js)/;
|
|
478
|
+
/** The GTM container's loader: only the gate's runtime may load it, behind its lists and policy. A
|
|
479
|
+
* copy anywhere in the HTML, in a gate or a gated script too, loads it around them. */
|
|
480
|
+
const GTM_LOADER = /googletagmanager\.com\/gtm\.js/;
|
|
481
|
+
/** The markers website-components' consent components render (website-headless `CONSENT_MARKERS`). */
|
|
482
|
+
const GATE = "[data-consent-gate]";
|
|
483
|
+
const GATED_SCRIPT = "script[data-consent-service]";
|
|
484
|
+
const GTM_GATE = "template[data-consent-gtm]";
|
|
485
|
+
/** Where the consent runtime defers content: a gate's template. Any other template is put in the
|
|
486
|
+
* page by the site's own code, without asking. */
|
|
487
|
+
const GATE_CONTENT = "template[data-consent-content]";
|
|
488
|
+
const BANNER = "astro-island[component-export=\"ConsentBanner\"]";
|
|
489
|
+
const hostOf = (url) => {
|
|
490
|
+
try {
|
|
491
|
+
return new URL(url).host;
|
|
492
|
+
} catch {
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
};
|
|
496
|
+
const usesManager = (ctx) => {
|
|
497
|
+
const files = ctx.sourceFiles(SOURCES);
|
|
498
|
+
if (files.some((file) => ctx.rel(file).startsWith(KIT_DIR))) return false;
|
|
499
|
+
return files.some((file) => MANAGER_IMPORT.test(blankSourceComments(ctx.readSource(file), file.slice(file.lastIndexOf(".")))));
|
|
500
|
+
};
|
|
501
|
+
/** Every template's content in the page, nested ones too (a query does not reach into a
|
|
502
|
+
* template's content), and whether a gate defers it: its own template, or one around it. */
|
|
503
|
+
const templateContents = (root, deferred = false) => [...root.querySelectorAll("template")].flatMap((template) => {
|
|
504
|
+
const content = template.content;
|
|
505
|
+
const inGate = deferred || template.matches(GATE_CONTENT);
|
|
506
|
+
return [{
|
|
507
|
+
content,
|
|
508
|
+
deferred: inGate
|
|
509
|
+
}, ...templateContents(content, inGate)];
|
|
510
|
+
});
|
|
511
|
+
/** A `<script>` the browser runs: no type, or a JavaScript one. A gated script is `text/plain`. */
|
|
512
|
+
const executable = (script) => {
|
|
513
|
+
const type = (script.getAttribute("type") ?? "").trim().toLowerCase();
|
|
514
|
+
return type === "" || type === "module" || type.includes("javascript");
|
|
515
|
+
};
|
|
516
|
+
/** The service ids a page's consent markup names: gates, gated scripts and the GTM gate's list,
|
|
517
|
+
* nested in a gate's template too. */
|
|
518
|
+
const idsOf = (elements) => [
|
|
519
|
+
...elements(GATE).map(({ el }) => el.getAttribute("data-consent-gate") ?? ""),
|
|
520
|
+
...elements(GATED_SCRIPT).map(({ el }) => el.getAttribute("data-consent-service") ?? ""),
|
|
521
|
+
...elements(GTM_GATE).flatMap(({ el }) => (el.getAttribute("data-consent-services") ?? "").split(/\s+/).filter(Boolean))
|
|
522
|
+
];
|
|
523
|
+
/**
|
|
524
|
+
* For a site on the consent manager (it imports its components from website-components): nothing
|
|
525
|
+
* third-party loads outside a gate, Google's snippet is not pasted, a gate is not rendered inside an
|
|
526
|
+
* island (React would put its content in the page at once), a page with gated content has the
|
|
527
|
+
* banner that grants it, and every service is named by a catalog id. A warning: the platform's
|
|
528
|
+
* decision is that consent findings never fail a build (docs/internal/websites/consent.md). The
|
|
529
|
+
* third-party scan waits while the site's own host is unknown, as `consent-gate` does.
|
|
530
|
+
*/
|
|
531
|
+
const consentManager = {
|
|
532
|
+
id: "consent-manager",
|
|
533
|
+
title: "Third-party content waits for the consent manager",
|
|
534
|
+
severity: "warning",
|
|
535
|
+
stage: "dist",
|
|
536
|
+
begin: (ctx) => {
|
|
537
|
+
if (!usesManager(ctx)) return null;
|
|
538
|
+
const siteHost = ctx.config.site ? hostOf(ctx.config.site) : void 0;
|
|
539
|
+
const allowed = new Set(ctx.options.consentAllowedHosts);
|
|
540
|
+
const findings = [];
|
|
541
|
+
const badIds = /* @__PURE__ */ new Set();
|
|
542
|
+
return {
|
|
543
|
+
visit: (page) => {
|
|
544
|
+
const { document } = page;
|
|
545
|
+
const note = (message) => findings.push({
|
|
546
|
+
path: page.path,
|
|
547
|
+
message
|
|
548
|
+
});
|
|
549
|
+
const templates = templateContents(document);
|
|
550
|
+
const elements = (selector) => [...[...document.querySelectorAll(selector)].map((el) => ({
|
|
551
|
+
el,
|
|
552
|
+
deferred: false
|
|
553
|
+
})), ...templates.flatMap(({ content, deferred }) => [...content.querySelectorAll(selector)].map((el) => ({
|
|
554
|
+
el,
|
|
555
|
+
deferred
|
|
556
|
+
})))];
|
|
557
|
+
for (const { el, deferred } of elements("script[src], iframe[src]")) {
|
|
558
|
+
const raw = (el.getAttribute("src") ?? "").trim();
|
|
559
|
+
if (el.tagName.toLowerCase() === "script" && GTM_LOADER.test(raw)) {
|
|
560
|
+
note("A copy of Google Tag Manager's loader (gtm.js) loads the container around the consent gate's lists and policy. Use <GoogleTagManager containerId services>, listing the services the container runs.");
|
|
561
|
+
continue;
|
|
562
|
+
}
|
|
563
|
+
if (!siteHost || deferred || el.matches(GATED_SCRIPT) && !executable(el)) continue;
|
|
564
|
+
const src = raw.startsWith("//") ? `https:${raw}` : raw;
|
|
565
|
+
if (!/^https?:\/\//i.test(src)) continue;
|
|
566
|
+
const host = hostOf(src);
|
|
567
|
+
if (!host || host === siteHost || allowed.has(host)) continue;
|
|
568
|
+
note(el.tagName.toLowerCase() === "iframe" ? `A third-party <iframe> from ${host} loads before consent. Put it in <ConsentGate service="…">, or list a consent-free host in consentAllowedHosts.` : `A third-party <script> from ${host} loads before consent. Make it <ConsentScript service="…" src="…" />, or list a consent-free host in consentAllowedHosts.`);
|
|
569
|
+
}
|
|
570
|
+
for (const { el: script, deferred } of elements("script:not([src])")) {
|
|
571
|
+
const text = script.textContent ?? "";
|
|
572
|
+
const gated = deferred || script.matches(GATED_SCRIPT) && !executable(script);
|
|
573
|
+
if (GTM_LOADER.test(text) || !gated && executable(script) && GOOGLE_LOADER.test(text)) note("A pasted Google Tag Manager or Google tag snippet loads around the consent gate. Use <GoogleTagManager containerId services>, listing the services the container runs.");
|
|
574
|
+
}
|
|
575
|
+
if (document.querySelector(`astro-island ${GATE}, astro-island ${GATED_SCRIPT}`)) note("A consent gate is rendered inside an island, where React puts its content in the page at once. Render the gate from Astro, or use useServiceConsent in the island.");
|
|
576
|
+
if (document.querySelector(`${GATE}, ${GATED_SCRIPT}, ${GTM_GATE}`) && !document.querySelector(BANNER)) note("The page gates services but has no ConsentBanner island, so visitors cannot grant them. Put <ConsentBanner client:load> in the layout as an island of its own; inside another island it is not found.");
|
|
577
|
+
for (const id of idsOf(elements)) if (!CATALOG_ID.test(id)) badIds.add(id);
|
|
578
|
+
},
|
|
579
|
+
finish: () => [...findings, ...[...badIds].map((id) => ({ message: `"${id}" is not a consent catalog id (lowercase words joined by hyphens, at most 64 characters), so it can never be granted. Name the service by its id in AI Studio's consent catalog.` }))]
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
};
|
|
457
583
|
// src/context.ts
|
|
458
584
|
const SKIPPED_TEXT_TAGS = /* @__PURE__ */ new Set([
|
|
459
585
|
"SCRIPT",
|
|
@@ -634,21 +760,34 @@ const BLOCK_TAGS = new Set("ADDRESS ARTICLE ASIDE BLOCKQUOTE BR DD DETAILS DIV D
|
|
|
634
760
|
/** An element's readable text, whitespace collapsed: a space at every block boundary, so
|
|
635
761
|
* `<p>Schön.</p><p>3 Zimmer.</p>` reads "Schön. 3 Zimmer.", and none inside a word split across
|
|
636
762
|
* inline elements (`<b>Ha</b>us` stays "Haus"). Script, style, noscript and template text is left
|
|
637
|
-
* out. */
|
|
638
|
-
const blockText = (el) => {
|
|
763
|
+
* out, or the elements `skip` names. */
|
|
764
|
+
const blockText = (el, skip = SKIPPED_TEXT_TAGS) => {
|
|
639
765
|
if (!el) return "";
|
|
640
766
|
const walk = (node) => {
|
|
641
767
|
let text = "";
|
|
642
768
|
for (const child of node.childNodes) if (child.nodeType === 3) text += child.textContent ?? "";
|
|
643
769
|
else if (child.nodeType === 1) {
|
|
644
770
|
const inner = child;
|
|
645
|
-
if (
|
|
771
|
+
if (skip.has(inner.tagName)) continue;
|
|
646
772
|
text += BLOCK_TAGS.has(inner.tagName) ? ` ${walk(inner)} ` : walk(inner);
|
|
647
773
|
}
|
|
648
774
|
return text;
|
|
649
775
|
};
|
|
650
776
|
return walk(el).replace(/\s+/g, " ").trim();
|
|
651
777
|
};
|
|
778
|
+
const CODE_TAGS = /* @__PURE__ */ new Set(["SCRIPT", "STYLE"]);
|
|
779
|
+
/** What a reader that runs no script (an AI assistant fetching the page) takes from its HTML: the
|
|
780
|
+
* body's text, `hidden`, `<noscript>` and `<template>` included, and every attribute value,
|
|
781
|
+
* entities decoded (an `astro-island`'s `props` is JSON in an attribute). Never the contents of a
|
|
782
|
+
* `<script>`, of any type, or of a `<style>`: measured against the assistants, a sentence there
|
|
783
|
+
* never reached an answer, one in island props did. */
|
|
784
|
+
const htmlTexts = (page) => [{
|
|
785
|
+
in: "text",
|
|
786
|
+
text: blockText(page.document.body, CODE_TAGS)
|
|
787
|
+
}, ...page.attributeValues().map((value) => ({
|
|
788
|
+
in: "attribute",
|
|
789
|
+
text: value.replace(/\s+/g, " ").trim()
|
|
790
|
+
}))];
|
|
652
791
|
/** Same-site URL references only: no scheme (`https:`, `mailto:`, `tel:`, `data:`, …), not
|
|
653
792
|
* protocol-relative, not a fragment — or an absolute URL on the site's own `origin`. */
|
|
654
793
|
const isSameSiteReference = (value, origin) => {
|
|
@@ -797,17 +936,58 @@ const sentencesOf = (blocks) => blocks.flatMap((block) => {
|
|
|
797
936
|
}).map((s) => s.trim()).filter((s) => /[.!?…]$/.test(s));
|
|
798
937
|
/** A sentence shorter than this is a label ("Mehr erfahren."), not prose. */
|
|
799
938
|
const MIN_SENTENCE = 25;
|
|
800
|
-
/**
|
|
801
|
-
*
|
|
802
|
-
*
|
|
803
|
-
*
|
|
939
|
+
/** Each wording `re` matches in what a reader that runs no script takes from a page
|
|
940
|
+
* (`htmlTexts`), once per place: a title attribute that repeats a heading, or a feed
|
|
941
|
+
* text in both the page and an island's props, is one finding each, not one per copy. Inline
|
|
942
|
+
* formatting does not split a wording ("Jetzt <b>buchen</b>!"), a line break does not hide it. */
|
|
943
|
+
const wordingsIn = (texts, re) => {
|
|
944
|
+
const found = /* @__PURE__ */ new Map();
|
|
945
|
+
for (const { in: where, text } of texts) for (const match of text.matchAll(re)) if (match[0]) found.set(`${where} ${match[0]}`, {
|
|
946
|
+
in: where,
|
|
947
|
+
wording: match[0]
|
|
948
|
+
});
|
|
949
|
+
return [...found.values()];
|
|
950
|
+
};
|
|
951
|
+
const inAttribute = (where) => where === "attribute" ? " (in an attribute value)" : "";
|
|
952
|
+
/** Sentences true in one state only, in German and English, as the kits and the starter word them:
|
|
953
|
+
* the search, the map, the favourites and the offers finding nothing, the search failing, a rental
|
|
954
|
+
* not available for the chosen dates. A reader that runs no script (an AI assistant) ignores
|
|
955
|
+
* `hidden` and repeats such a sentence as a fact about the agency, to a guest asking whether
|
|
956
|
+
* anything is free. Anchored to those phrasings: the pages also print the owners' descriptions
|
|
957
|
+
* ("Über Silvester leider ausgebucht", "No stays under 3 nights"), which must not match. The booking
|
|
958
|
+
* and checkout kits' price messages ("Der Preis konnte gerade nicht geladen werden") are the same
|
|
959
|
+
* kind but left out until those kits write them in by script: they sit in the kits' island props
|
|
960
|
+
* on every rental and booking page, which a site cannot change itself. */
|
|
961
|
+
const EMPTY_STATE_PATTERNS = [
|
|
962
|
+
/Keine Unterkunft gefunden/,
|
|
963
|
+
/[Kk]eine (?:deiner |Ihrer )?(?:gemerkten )?Unterkünfte in diesem Kartenausschnitt|Kartenausschnitt liegt keine/,
|
|
964
|
+
/Keine der gemerkten Unterkünfte passt/,
|
|
965
|
+
/Die Merkliste ist leer/,
|
|
966
|
+
/ist gerade nichts reduziert/,
|
|
967
|
+
/haben wir leider keine passenden Unterkünfte gefunden/,
|
|
968
|
+
/(?:deinen|Ihren) Wunschdaten (?:ist )?leider/,
|
|
969
|
+
/Die Suche ist gerade nicht erreichbar/,
|
|
970
|
+
/ist die Unterkunft leider nicht verfügbar/,
|
|
971
|
+
/\bNo (?:exact )?matches\b/,
|
|
972
|
+
/\bNo stays in this part of the map|\bNone of [^.!?]{0,40}in this part of the map/,
|
|
973
|
+
/\bNone of your saved stays match/,
|
|
974
|
+
/\bNothing saved yet\b/,
|
|
975
|
+
/\bNo deals for these dates\b/,
|
|
976
|
+
/\bNothing is available on your dates|\bbooked on your dates/,
|
|
977
|
+
/\bSearch isn['’]t available right now/,
|
|
978
|
+
/\bisn['’]t available for these dates and guests/
|
|
979
|
+
].map((re) => re.source);
|
|
980
|
+
/** Wordings a recorded customer correction bans, found in what a page's HTML says: its text and
|
|
981
|
+
* its attribute values (`htmlTexts`). A warning: the pages include the feed's descriptions, and an
|
|
982
|
+
* owner's new wording must not stop the nightly builds. A ban scoped `"in": "src"` is the site's
|
|
983
|
+
* own text only: `banned-copy-src` reads it in `src/`, this check never. */
|
|
804
984
|
const bannedCopy = {
|
|
805
985
|
id: "banned-copy",
|
|
806
986
|
title: "Wordings banned by a recorded correction",
|
|
807
987
|
severity: "warning",
|
|
808
988
|
stage: "dist",
|
|
809
989
|
begin: (ctx) => {
|
|
810
|
-
const bans = ctx.options.bannedCopy.filter((ban) => ban.in !== "src").map((ban) => ({
|
|
990
|
+
const bans = ctx.options.bannedCopy.filter((ban) => ban.in !== "src" && !EMPTY_STATE_PATTERNS.includes(ban.pattern)).map((ban) => ({
|
|
811
991
|
...ban,
|
|
812
992
|
re: new RegExp(ban.pattern, "g")
|
|
813
993
|
}));
|
|
@@ -817,10 +997,37 @@ const bannedCopy = {
|
|
|
817
997
|
return {
|
|
818
998
|
visit: (page) => {
|
|
819
999
|
if (excluded(page, skip)) return;
|
|
820
|
-
const
|
|
821
|
-
for (const ban of bans) for (const
|
|
1000
|
+
const texts = htmlTexts(page);
|
|
1001
|
+
for (const ban of bans) for (const { in: where, wording } of wordingsIn(texts, ban.re)) findings.push({
|
|
1002
|
+
path: page.path,
|
|
1003
|
+
message: `"${excerpt$3(wording, 70)}" is a banned wording${inAttribute(where)}: ${ban.why}`
|
|
1004
|
+
});
|
|
1005
|
+
},
|
|
1006
|
+
finish: () => findings
|
|
1007
|
+
};
|
|
1008
|
+
}
|
|
1009
|
+
};
|
|
1010
|
+
/** A sentence of `EMPTY_STATE_PATTERNS` in a page's HTML, on every site, configured or not; the
|
|
1011
|
+
* pages `banned-copy` skips are skipped here too. A warning: the pages and the island props also
|
|
1012
|
+
* carry the feed's descriptions, which no pattern can tell apart from the site's own words for
|
|
1013
|
+
* sure. */
|
|
1014
|
+
const emptyStateCopy = {
|
|
1015
|
+
id: "empty-state-copy",
|
|
1016
|
+
title: "Empty-state and error sentences in the page's HTML",
|
|
1017
|
+
severity: "warning",
|
|
1018
|
+
stage: "dist",
|
|
1019
|
+
begin: (ctx) => {
|
|
1020
|
+
if (!ctx.hasDist) return null;
|
|
1021
|
+
const res = EMPTY_STATE_PATTERNS.map((pattern) => new RegExp(pattern, "g"));
|
|
1022
|
+
const skip = [...ctx.options.copyExcludePaths, ...ctx.options.bannedCopyExcludePaths];
|
|
1023
|
+
const findings = [];
|
|
1024
|
+
return {
|
|
1025
|
+
visit: (page) => {
|
|
1026
|
+
if (excluded(page, skip)) return;
|
|
1027
|
+
const texts = htmlTexts(page);
|
|
1028
|
+
for (const re of res) for (const { in: where, wording } of wordingsIn(texts, re)) findings.push({
|
|
822
1029
|
path: page.path,
|
|
823
|
-
message: `"${excerpt$3(
|
|
1030
|
+
message: `"${excerpt$3(wording, 70)}" is a sentence for one state only (nothing found, not available) in the page's HTML${inAttribute(where)}: a reader that runs no script (an AI assistant) ignores \`hidden\` and repeats it as a fact about the agency, even to a guest asking what is free. Write it in by script only while it applies: from a JSON <script>, an inline script or the component's JS chunk, as search-results-kit 5.2.0 and 5.4.0 do.`
|
|
824
1031
|
});
|
|
825
1032
|
},
|
|
826
1033
|
finish: () => findings
|
|
@@ -3437,6 +3644,7 @@ const checks = [
|
|
|
3437
3644
|
viewSource,
|
|
3438
3645
|
donorTerms,
|
|
3439
3646
|
consentGate,
|
|
3647
|
+
consentManager,
|
|
3440
3648
|
feedImageFormats,
|
|
3441
3649
|
listingNoindex,
|
|
3442
3650
|
listingLinks,
|
|
@@ -3482,6 +3690,7 @@ const checks = [
|
|
|
3482
3690
|
loadOrder,
|
|
3483
3691
|
firstPaintPhotos,
|
|
3484
3692
|
bannedCopy,
|
|
3693
|
+
emptyStateCopy,
|
|
3485
3694
|
duplicateSentences,
|
|
3486
3695
|
quoteSources,
|
|
3487
3696
|
rentalFacts
|
package/dist/index.d.mts
CHANGED
|
@@ -29,8 +29,9 @@ type Exclusion = string | {
|
|
|
29
29
|
type Exclusions = Record<string, true | Exclusion[]>;
|
|
30
30
|
/** A wording a recorded customer correction bans from the rendered pages. */
|
|
31
31
|
interface BannedCopy {
|
|
32
|
-
/** A regular expression (source), matched against each page's
|
|
33
|
-
* collapsed, so a line break cannot hide a match.
|
|
32
|
+
/** A regular expression (source), matched against each page's text and each of its attribute
|
|
33
|
+
* values, whitespace collapsed, so a line break cannot hide a match. A pattern equal to a
|
|
34
|
+
* built-in empty-state pattern is dropped: `empty-state-copy` reports it. */
|
|
34
35
|
pattern: string;
|
|
35
36
|
/** The correction behind it, shown with every finding. */
|
|
36
37
|
why: string;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { g as CONFIG_FILE, d as MAX_FINDINGS_PER_CHECK, f as MAX_MESSAGE_CHARS, p as MAX_PATH_CHARS, o as SITE_CHECKS_FILE, t as USAGE, m as blockingResults, v as checks, y as checksOf, n as cli, i as distChecks, s as findingLine, _ as loadOptions, b as readAstroConfig, c as refusalMessage, a as runDistChecks, h as runSiteChecks, r as runStage, l as summarizeBlocking, u as summaryLines } from "./cli-
|
|
1
|
+
export { g as CONFIG_FILE, d as MAX_FINDINGS_PER_CHECK, f as MAX_MESSAGE_CHARS, p as MAX_PATH_CHARS, o as SITE_CHECKS_FILE, t as USAGE, m as blockingResults, v as checks, y as checksOf, n as cli, i as distChecks, s as findingLine, _ as loadOptions, b as readAstroConfig, c as refusalMessage, a as runDistChecks, h as runSiteChecks, r as runStage, l as summarizeBlocking, u as summaryLines } from "./cli-CZHXyJcd.mjs";
|
|
@@ -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.6.0/CHANGELOG.md`: release notes for 0.6.0
|
|
8
|
+
- `versions/0.5.4/CHANGELOG.md`: release notes for 0.5.4
|
|
7
9
|
- `versions/0.5.3/CHANGELOG.md`: release notes for 0.5.3
|
|
8
10
|
- `versions/0.5.2/CHANGELOG.md`: release notes for 0.5.2
|
|
9
11
|
- `versions/0.5.1/CHANGELOG.md`: release notes for 0.5.1
|
|
@@ -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.6.0/MIGRATION.md`: Migration: 0.5.4 to 0.6.0
|
|
8
|
+
- `versions/0.5.4/MIGRATION.md`: Migration: 0.5.3 to 0.5.4
|
|
7
9
|
- `versions/0.5.3/MIGRATION.md`: Migration: 0.5.2 to 0.5.3
|
|
8
10
|
- `versions/0.5.2/MIGRATION.md`: Migration: 0.5.1 to 0.5.2
|
|
9
11
|
- `versions/0.5.1/MIGRATION.md`: Migration: 0.5.0 to 0.5.1
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Changelog: 0.5.4
|
|
2
|
+
|
|
3
|
+
A new warning, `empty-state-copy`, finds sentences that are true in one state only ("nothing
|
|
4
|
+
found", "not available") in a page's HTML, on every site, and `banned-copy` now also reads attribute
|
|
5
|
+
values. A reader that runs no script (an AI assistant) ignores `hidden` and repeats such a sentence
|
|
6
|
+
as a fact about the agency, even to a guest asking what is free.
|
|
7
|
+
|
|
8
|
+
## Added
|
|
9
|
+
|
|
10
|
+
- `empty-state-copy` (warning, `dist` stage, on every site with no configuration): a sentence that
|
|
11
|
+
is true in one state only, in a page's HTML. Its built-in German and English patterns follow the
|
|
12
|
+
kits' and the starter's wordings: the search, the map, the favourites and the offers finding
|
|
13
|
+
nothing ("Keine Unterkunft gefunden", "Keine Unterkünfte in diesem Kartenausschnitt.", "An
|
|
14
|
+
deinen Wunschdaten leider ausgebucht", "Die Merkliste ist leer.", "No exact matches", "None of
|
|
15
|
+
your saved stays are in this part of the map.", "These stays are booked on your dates."), the
|
|
16
|
+
search failing ("Die Suche ist gerade nicht erreichbar.") and a rental not available for the
|
|
17
|
+
chosen dates ("Für diese Auswahl ist die Unterkunft leider nicht verfügbar."). They are anchored
|
|
18
|
+
to those phrasings, so an owner's "Über Silvester leider ausgebucht" or "No stays under 3 nights"
|
|
19
|
+
does not match. It reads the page's text, `hidden` elements, `<noscript>` and `<template>`
|
|
20
|
+
included, and every attribute value, entities decoded, so a sentence in an `astro-island`'s
|
|
21
|
+
`props` counts; the contents of a `<script>`, of any type, never do. It skips the pages in
|
|
22
|
+
`copyExcludePaths` and `bannedCopyExcludePaths`, as `banned-copy` does. A warning, not an error:
|
|
23
|
+
the pages and the island props also carry the PMS feed's descriptions, which no pattern can tell
|
|
24
|
+
apart from the site's own words for sure. The booking and checkout kits' price messages ("Der
|
|
25
|
+
Preis konnte gerade nicht geladen werden") are not reported yet: they come back once those kits
|
|
26
|
+
write them in by script.
|
|
27
|
+
|
|
28
|
+
## Changed
|
|
29
|
+
|
|
30
|
+
- `banned-copy` reads attribute values as well as the page's text (an island's `props`, `title`,
|
|
31
|
+
`aria-label`, `content`), entities decoded, and the text of `<noscript>` and `<template>`; never
|
|
32
|
+
the contents of a `<script>` or `<style>`. A finding in an attribute says "(in an attribute
|
|
33
|
+
value)". Each wording is reported once per page and place, however often it is printed there.
|
|
34
|
+
- `banned-copy` drops a `bannedCopy` entry whose `pattern` equals one of `empty-state-copy`'s
|
|
35
|
+
built-in patterns, so the same sentence is not reported twice.
|
|
36
|
+
|
|
37
|
+
The levels, the configuration keys, the exit codes and the report's shape stay the same.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Migration: 0.5.3 to 0.5.4
|
|
2
|
+
|
|
3
|
+
## 1. Upgrade
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
pnpm add --save-exact --save-dev @v-office/site-checks@0.5.4
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
No changes required to build. The new `empty-state-copy` is a warning and may report the
|
|
10
|
+
empty-state sentences of the search, the map, the favourites and the offers; `banned-copy` may now
|
|
11
|
+
report a banned wording in an attribute value.
|
|
12
|
+
|
|
13
|
+
## 2. Move an empty-state sentence out of the page's HTML
|
|
14
|
+
|
|
15
|
+
For each page `empty-state-copy` names (usually the search, the map, the favourites, an offers page
|
|
16
|
+
and a theme page that lists rentals):
|
|
17
|
+
|
|
18
|
+
1. Find the component that prints the sentence: a `hidden` element, or a prop of a hydrated island
|
|
19
|
+
(the finding says "(in an attribute value)").
|
|
20
|
+
2. Write the sentence in by script only while it applies: put it in a
|
|
21
|
+
`<script type="application/json">` the component's script reads, pass it to an inline script, or
|
|
22
|
+
keep it in the component's JS chunk. Leave the empty element in the markup without text. This is
|
|
23
|
+
what search-results-kit 5.2.0 and 5.4.0 do; on a site with the kit, update it.
|
|
24
|
+
3. Build and run `site-checks dist`: the finding is gone.
|
|
25
|
+
|
|
26
|
+
A finding the site accepts (an owner's description that happens to use one of the wordings) goes
|
|
27
|
+
into `exclude`:
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"exclude": {
|
|
32
|
+
"empty-state-copy": [
|
|
33
|
+
{
|
|
34
|
+
"path": "/unterkuenfte/haus-seeblick",
|
|
35
|
+
"match": "Keine Unterkunft gefunden",
|
|
36
|
+
"reason": "the owner's text"
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## 3. Delete the starter's two empty-state entries from `bannedCopy`
|
|
44
|
+
|
|
45
|
+
A site built from the starter has two `bannedCopy` entries whose `why` begins "An empty-state
|
|
46
|
+
sentence in the page's HTML". Delete both: `empty-state-copy` now reports those sentences with
|
|
47
|
+
patterns anchored to the kits' wordings. Until they are deleted, their broad patterns still report
|
|
48
|
+
under `banned-copy` (a warning), now in attribute values too, and their bare "leider ausgebucht"
|
|
49
|
+
and "No stays" also match an owner's description. Keep any other pattern of your own.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Changelog: 0.6.0
|
|
2
|
+
|
|
3
|
+
A check for sites on the platform's consent manager (website-components `./consent`): third-party
|
|
4
|
+
content waits for the visitor's consent, and the banner that grants it is on the page.
|
|
5
|
+
|
|
6
|
+
## Added
|
|
7
|
+
|
|
8
|
+
- `consent-manager` (`dist`, warning), for a site that imports the consent manager's components
|
|
9
|
+
from `@v-office/website-components` and has no `src/lib/consent/` (the old kit, which
|
|
10
|
+
`consent-gate` keeps checking). It reports:
|
|
11
|
+
- a third-party `<script src>` or `<iframe src>` outside a `ConsentGate` or a `ConsentScript`,
|
|
12
|
+
which loads before consent (the site's own host and `consentAllowedHosts` are allowed; it
|
|
13
|
+
waits while the site's host is unknown, as `consent-gate` does);
|
|
14
|
+
- a pasted Google Tag Manager or Google tag snippet, and Google Tag Manager's loader (`gtm.js`)
|
|
15
|
+
anywhere in the page, in a gate too: use `GoogleTagManager`;
|
|
16
|
+
- a `ConsentGate` or `ConsentScript` rendered inside an island, where React puts its content in
|
|
17
|
+
the page at once;
|
|
18
|
+
- a page with gated content but no `ConsentBanner` island, where nothing can be granted;
|
|
19
|
+
- a service id that is not a catalog id (lowercase words joined by hyphens, at most 64
|
|
20
|
+
characters).
|
|
21
|
+
|
|
22
|
+
Every finding is a warning: consent findings never fail a build.
|
|
23
|
+
|
|
24
|
+
Every other check, the configuration keys, the exit codes and the report's shape stay the same.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Migration: 0.5.4 to 0.6.0
|
|
2
|
+
|
|
3
|
+
No changes required. A site on the consent manager may see new `consent-manager` warnings: gate
|
|
4
|
+
what each one names with `ConsentGate`, `ConsentScript` or `GoogleTagManager`, put
|
|
5
|
+
`<ConsentBanner client:load locale={locale} />` in the layout, and name every service by its id
|
|
6
|
+
in AI Studio's consent catalog. A consent-free third-party host goes in `consentAllowedHosts`.
|
|
7
|
+
|
|
8
|
+
## 1. Upgrade
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
pnpm add @v-office/site-checks@0.6.0
|
|
12
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@v-office/site-checks",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "The checks over a v-office website in two stages, `site-checks src` before the build and `site-checks dist` after it, which AI Studio's build worker runs on every build from its own pinned copy; the report has the shape of the build worker's dist-check report, and a site excludes the findings it accepts in site-checks.config.json",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|