prosebook 0.1.0 → 0.2.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 CHANGED
@@ -32,15 +32,14 @@ const { t } = useCopy();
32
32
  2.5 KB gzipped.
33
33
  - **Checked.** Placeholders that drift between the source and a translation fail the build. A
34
34
  translation whose source has changed since is marked stale, automatically.
35
- - **Pruned.** A Vite build ships only the messages the code names.
35
+ - **Pruned.** A Vite build ships only the messages the code names, and fails on a read whose key
36
+ it can't see rather than show a key where a message was.
36
37
  - **Written well.** An optional lint holds the words to a writing guide: word budgets per kind of
37
38
  string, periods, sentence case, banned filler, and `{count} files` outside a plural. Plugins add your
38
39
  own rules, scoped by kind, surface and locale, and translations are held to their source.
39
40
 
40
41
  ## Quick start
41
42
 
42
- Not on npm yet: build it here (`bun run build`) and add it by path.
43
-
44
43
  ```bash
45
44
  bun add prosebook
46
45
  ```
@@ -66,6 +65,9 @@ import { prosebook } from 'prosebook/vite';
66
65
  export default defineConfig({ plugins: [react(), prosebook()] });
67
66
  ```
68
67
 
68
+ Several apps that share one catalog each point the plugin at it: `prosebook({ root: '../../packages/copy' })`
69
+ reads the config there and resolves its paths from there, so every app generates the same files.
70
+
69
71
  ### In React
70
72
 
71
73
  ```tsx
@@ -126,7 +128,8 @@ One file per area, `copy/catalog/<area>.yaml`. A key's first segment names its f
126
128
  | `comment` | A change asked of whoever edits the entry next. A warning until it is made and the comment deleted. |
127
129
  | `remove` | `true` asks for the entry to go, with its translations and the code that reads it. A warning until then. |
128
130
 
129
- `key: message` is the shorthand for an entry with nothing to say about itself (set `require: []`).
131
+ `key: message` is the shorthand for an entry with nothing to say about itself (set `require: []`;
132
+ the schema offers it only then).
130
133
  Kinds and surfaces are configurable; `prosebook generate` writes `catalog.schema.json` beside the
131
134
  catalog, so an editor with the YAML language server completes and explains every field:
132
135
 
@@ -146,12 +149,14 @@ en: '{mode, select, dark {Dark} other {Light}}' # mode: 'dark' | (string & {})
146
149
  en: '{size, number, ::.0 unit/megabyte}' # 1.4 MB
147
150
  en: '{total, number, ::currency/EUR}' # €9.00
148
151
  en: '{when, date, medium} at {when, time, short}' # Oct 28, 2026 at 2:05 PM
152
+ en: '{when, date, ::yMMMdjmm}' # Oct 28, 2026, 2:05 PM; 28. Okt. 2026, 14:05 in German
149
153
  en: 'By checking out you agree to our <link>terms</link>.' # a tag: an element inside the sentence
150
154
  ```
151
155
 
152
156
  A placeholder holds a number, a name or something a person typed, never a translated fragment: a
153
- word that changes with the sentence belongs in a `plural` or `select` arm. A skeleton the formatter
154
- would silently drop (`::compact-shortt`) fails the build instead of reaching the screen unformatted.
157
+ word that changes with the sentence belongs in a `plural` or `select` arm. A skeleton's `j` is the
158
+ hour as each locale writes it, 12 or 24. A skeleton the formatter would silently drop
159
+ (`::compact-shortt`, a date's `J`) fails the build instead of reaching the screen unformatted.
155
160
 
156
161
  **Tags** keep a sentence with a link or bold run inside it as one entry, so a translator can move the
157
162
  element. `t()` renders a tag as its text; `rich()` and `<Text>` render it through a function. Tags
@@ -290,8 +295,9 @@ writes them, in the case of the words they replace, wherever in the message they
290
295
  checked as the whole catalog first, and nothing is written if any would break it. Only the message
291
296
  changes: a `key: message` entry stays one, and quoting and comments elsewhere stay as they were.
292
297
 
293
- `strict` adds sentence case, contractions, em-dashes, `…`, American spelling and a list of filler
294
- and marketing words. Add your own `banned`, `spelling` and `concepts` (one word per concept:
298
+ `strict` adds sentence case, contractions, em-dashes, `…`, American spelling, paths written with one
299
+ separator (`Settings › General`, not `→` or `>`; set `pathSeparator`) and a list of filler and
300
+ marketing words. Add your own `banned`, `spelling` and `concepts` (one word per concept:
295
301
  `{ tablet: 'device' }`), and `properNouns` for sentence case. Where a rule is wrong about an
296
302
  entry, say why:
297
303
 
@@ -307,10 +313,16 @@ legal.privacy:
307
313
  A reason that is a shrug (`Intentional.`) fails, and so does an exemption the entry no longer needs.
308
314
  An exemption covers the entry in every locale, and is needed while any of them needs it.
309
315
 
316
+ Where a rule is wrong about a whole area, set its severity there. A key's first segment is its area:
317
+
318
+ ```ts
319
+ lint: { areas: { native: { 'sentence-case': 'off' } } }, // menu bars and trays write Title Case
320
+ ```
321
+
310
322
  **Lint plugins.** A plugin's rules are named `<plugin>/<rule>` in `lint.rules` and `allow`. A rule
311
323
  is given the entry and its readings: `primary` takes every `other` arm, `variants` holds one reading
312
324
  per plural or select arm, and `skeleton` only the words every arm carries. Placeholders and verbatim
313
- tags (`code`, `kbd`, ...) read as `HOLE`. `on` limits a rule to kinds or surfaces, and says which
325
+ tags (`code`, `kbd`, ...) read as `HOLE`. `on` limits a rule to kinds, surfaces or areas, and says which
314
326
  locales it reads: the source when unset, `'all'`, or a list of languages (`['de']` covers `de-CH`).
315
327
  A rule is then given the `locale`, that locale's `ast` and `text`, and the `source` readings to
316
328
  compare with. `recommended` is its severity under that preset (off when unset), `strict` under
@@ -488,6 +500,13 @@ references. A reference is any string literal equal to a key, so keys kept in ar
488
500
  ``t(`status.${state}`)`` and `t('status.' + state)` keep every key under `status.`. For keys built
489
501
  some other way, list them: `prosebook({ keep: ['plan.*'] })`.
490
502
 
503
+ A message the build leaves out shows as its key, so by default a build fails on any read whose key
504
+ it can't see: `t(item.key)`, ``rich(`${area}.title`)``, `<Text id={id} />`. Write the key at the read,
505
+ or, where every key it reads is written elsewhere (in an array, say) or listed in `keep`, mark the
506
+ line with `prosebook-ignore`. Reads are known by name: `t` and `rich` alone or as methods, the names
507
+ they're destructured to (`const { rich: tRich } = copy`) in any module, and `<Text>` from
508
+ `prosebook/react`. `prune: 'loose'` prunes without the check, and `prune: false` ships everything.
509
+
491
510
  ## Finding a string's entry
492
511
 
493
512
  In dev, hold Alt (Option on a Mac) and point at text on the page: the Vite plugin outlines the
@@ -546,7 +565,17 @@ export default defineConfig({
546
565
  require: ['context'],
547
566
  kinds: {/* name, action, description, state */},
548
567
  surfaces: {/* label, heading, tooltip, ... */},
549
- lint: { extends: 'recommended', plugins: [], rules: {}, banned: [], spelling: {}, concepts: {}, properNouns: [] },
568
+ lint: {
569
+ extends: 'recommended',
570
+ plugins: [],
571
+ rules: {},
572
+ areas: {}, // severities per area: { native: { 'sentence-case': 'off' } }
573
+ banned: [],
574
+ spelling: {},
575
+ concepts: {},
576
+ properNouns: [],
577
+ pathSeparator: '›',
578
+ },
550
579
  scan: { dirs: ['src'] },
551
580
  });
552
581
  ```
@@ -560,26 +589,6 @@ Turkish and the pseudo-locale.
560
589
  bun run example
561
590
  ```
562
591
 
563
- ## Where it came from
564
-
565
- prosebook generalizes `@drasyn/text`, the catalog behind Drasyn's UI. It keeps that design: YAML
566
- entries with `kind`, `surface` and `context`, ICU checked at build time, generated types, tags for
567
- elements inside a sentence, a lint for the writing guide with reasoned exemptions, build-time
568
- pruning, and the YAML 1.1/1.2 divergence check. What changed:
569
-
570
- | Drasyn's text package | prosebook |
571
- | ----------------------------------------------------------- | --------------------------------------------------------------------------- |
572
- | Parses ICU at runtime with `intl-messageformat` | Compiles messages to functions; no parser ships |
573
- | One global language; components don't re-render on a switch | `createCopy` instances; `useCopy()` re-renders; one per request on a server |
574
- | Falls back to English only | Negotiates the locale and falls back key by key through parents |
575
- | No way to know a translation is out of date | The lock marks stale translations; `status`, `todo`, `accept` |
576
- | Kinds, surfaces and word lists are Drasyn's | All configurable; `recommended` and `strict` presets |
577
- | A rich message needs `rich: true` and a `RichText` wrapper | Tags are detected; React output is keyed; default tags in the provider |
578
- | Pruning fails the build on a key it can't read | Pruning reads string literals and prefixes, so keys in data still work |
579
- | Bun scripts inside one repo | A CLI, a Vite plugin and `prosebook/tools` for other bundlers |
580
- | — | Hardcoded-text `scan` and `extract`, pseudo-locale, translator `todo` |
581
- | — | Alt-click a string in dev to open its entry |
582
-
583
592
  ## Further
584
593
 
585
594
  Ideas not built yet, roughly in order of value:
@@ -589,7 +598,7 @@ Ideas not built yet, roughly in order of value:
589
598
  2. **Exchange formats**: XLIFF 2 and JSON export and import for translation tools.
590
599
  3. **Per-area splitting**: one chunk per area and locale, so a lazy route loads only its own messages.
591
600
  4. **Server rendering helpers**: `Accept-Language` negotiation and a React Server Components reader.
592
- 5. **Native targets**: generate Rust, Swift or Kotlin from the same catalog, as Drasyn generates
593
- Rust for its tray and menus.
601
+ 5. **Native targets**: generate Rust, Swift or Kotlin from the same catalog, for the parts of an app
602
+ outside the browser, such as a tray or native menus.
594
603
  6. **Variable MF2 options**: `{$price :currency currency=$code}`, compiled to a formatter cached per
595
604
  value.
package/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import { E as CatalogError, M as whereOf, N as SYNTAX_NAME, a as scan, b as applyFixes, c as generate, d as render, k as entryLocator, n as isReferenced, o as sourceFiles } from "./scan-B0tZ7y-D.js";
3
- import { p as lint, r as loadConfig, t as CONFIG_FILES } from "./config-CxVMn19f.js";
4
- import { a as wordDiff, i as formatDiff, l as planExtract, n as applyMigrate, o as applyExtract, r as planMigrate, t as SarifReport } from "./sarif-PkPvsB07.js";
2
+ import { F as SYNTAX_NAME, O as CatalogError, P as whereOf, S as applyFixes, j as entryLocator, o as scan, p as render, r as isReferenced, s as sourceFiles, u as generate } from "./scan-Ch2BfIUD.js";
3
+ import { p as lint, r as loadConfig, t as CONFIG_FILES } from "./config-D--RITk2.js";
4
+ import { a as wordDiff, i as formatDiff, l as planExtract, n as applyMigrate, o as applyExtract, r as planMigrate, t as SarifReport } from "./sarif-CI8HOokm.js";
5
5
  import { join, relative, resolve } from "node:path";
6
6
  import { existsSync, mkdirSync, readFileSync, watch, writeFileSync } from "node:fs";
7
7
  import { stringify } from "yaml";
@@ -8,10 +8,36 @@ import { TYPE as TYPE$1, isDateElement, isNumberElement, isTimeElement, parse }
8
8
  * date style is one the formatter honors. Shared by the loader, the compiler and the lint.
9
9
  */
10
10
  function parseMessage(text) {
11
- return parse(text, {
11
+ const ast = parse(text, {
12
12
  shouldParseSkeletons: true,
13
13
  requiresOtherClause: true
14
14
  });
15
+ walk(ast, (el) => {
16
+ if ((isDateElement(el) || isTimeElement(el)) && typeof el.style === "object" && el.style !== null && el.style.pattern.includes("j")) el.style.parsedOptions = localHour(el.style.pattern);
17
+ });
18
+ return ast;
19
+ }
20
+ /**
21
+ * A skeleton's `j` is the hour as the locale writes it, 12 or 24. The parser resolves it only when
22
+ * given a locale and drops it otherwise, so `::yMMMdjmm` showed the minute alone. Read here as an
23
+ * hour with no cycle, which `Intl` gives the cycle of whatever locale formats it: "2:05 PM", "14:05".
24
+ */
25
+ function localHour(pattern) {
26
+ const run = /j+/.exec(pattern)[0];
27
+ const rest = pattern.replaceAll("j", "");
28
+ return {
29
+ ...rest === "" ? {} : dateFields(rest),
30
+ hour: run.length % 2 === 0 ? "2-digit" : "numeric"
31
+ };
32
+ }
33
+ /** What the parser reads from a date skeleton on its own; nothing where it can't parse it. */
34
+ function dateFields(skeleton) {
35
+ try {
36
+ const el = parse(`{d, date, ::${skeleton}}`, { shouldParseSkeletons: true })[0];
37
+ return el !== void 0 && isDateElement(el) && typeof el.style === "object" && el.style !== null ? el.style.parsedOptions : {};
38
+ } catch {
39
+ return {};
40
+ }
15
41
  }
16
42
  /**
17
43
  * ICU argument types, as TypeScript. A bare `{x}` is a string: a number spliced in raw is printed by
@@ -108,6 +134,8 @@ function dateOptions(el) {
108
134
  }
109
135
  return { [field]: style };
110
136
  }
137
+ const dropped = (style.pattern.match(/([A-Za-z])*/g) ?? []).filter((f) => !f.startsWith("j") && Object.keys(dateFields(f)).length === 0);
138
+ if (dropped.length > 0) throw new Error(`{${el.value}} has date fields the formatter drops without a word: ${dropped.join(", ")}`);
111
139
  if (Object.keys(style.parsedOptions).length === 0) throw new Error(`{${el.value}} has a date skeleton the formatter reads nothing from: "${style.pattern}"`);
112
140
  try {
113
141
  new Intl.DateTimeFormat("en", style.parsedOptions).resolvedOptions();
@@ -264,10 +292,14 @@ const NOT_PLURAL = /* @__PURE__ */ new Set([
264
292
  "news",
265
293
  "series"
266
294
  ]);
267
- /** The singular of an English plural noun, or nothing where it doesn't look like one. */
295
+ /**
296
+ * The singular of an English plural noun, or nothing where it doesn't look like one. A word with no
297
+ * vowel is a unit or an abbreviation (`kbps`, `fps`, `hrs`), which reads the same after 1.
298
+ */
268
299
  function singularOf(word) {
269
300
  const lower = word.toLowerCase();
270
301
  if (word.length < 3 || !lower.endsWith("s") || lower.endsWith("ss") || NOT_PLURAL.has(lower)) return void 0;
302
+ if (!/[aeiouy]/.test(lower)) return void 0;
271
303
  if (/[^aeiou]ies$/.test(lower)) return `${word.slice(0, -3)}y`;
272
304
  if (/(?:s|x|z|ch|sh)es$/.test(lower)) return word.slice(0, -2);
273
305
  return word.slice(0, -1);
@@ -300,16 +332,25 @@ function eachRun(elements, visit, counted = /* @__PURE__ */ new Set()) {
300
332
  /** A plain placeholder named as a count. A number placeholder is one whatever its name. */
301
333
  const COUNT_NAME = /^(?:n|num|count|total|amount|quantity)$|(?:count|total)$/i;
302
334
  /**
303
- * Whether an arm ends with a stop; nothing for an arm with no words. Which stop is the arm's own: a
304
- * question in `one` and a second sentence after it in `other` both end well.
335
+ * Whether an arm ends with a stop; nothing for an arm with no words, or one that trails off in an
336
+ * ellipsis (`Saving…`, `Save as…`), which is neither. Which stop is the arm's own: a question in
337
+ * `one` and a second sentence after it in `other` both end well.
305
338
  */
306
339
  function endsWithStop(arm) {
307
340
  const text = prose(renderAs(arm, "other")).trim();
308
- return text.replaceAll("⁣", "").trim() === "" ? void 0 : hasStop(text);
341
+ if (text.replaceAll("⁣", "").trim() === "" || /(?:…|\.{3})["')”»」』]*$/u.test(text)) return void 0;
342
+ return hasStop(text);
309
343
  }
310
344
  /** Ends with a stop in any script (`。`, `؟`, `;` as Greek writes `?`), though not a comma. */
311
345
  const hasStop = (text) => /(?![,,、،])[\p{Terminal_Punctuation}…]["')”»」』]*$/u.test(prose(text).trim());
312
346
  const CURRENCY_BEFORE = /[$€£¥₹]\s?$/;
347
+ /**
348
+ * The ways a path through menus is written, the separator in a group: an arrow or `›` however
349
+ * spaced, and `>` or `/` only spaced between words or placeholders, with a capital after a slash,
350
+ * since "2 > 1" and "and / or" are no paths. The match takes the spaces around, so the fix spaces
351
+ * the separator.
352
+ */
353
+ const PATH_SEPARATORS = new RegExp(String.raw`\s*(→|->|›)\s*|(?<=[\p{L}${"⁣"}])\s+(>)\s+(?=[\p{L}${"⁣"}])|(?<=\p{L})\s+(\/)\s+(?=\p{Lu})`, "gu");
313
354
  const OFF_SCREEN = /* @__PURE__ */ new Set(["aria"]);
314
355
  const an = (word = "string") => `${/^[aeiou]/i.test(word) ? "an" : "a"} ${word}`;
315
356
  const CORE_RULES = {
@@ -412,6 +453,21 @@ const CORE_RULES = {
412
453
  }];
413
454
  }
414
455
  },
456
+ path: {
457
+ description: "A path through menus or settings is written with `lint.pathSeparator`, spaced: Settings › General.",
458
+ check: ({ text, config }) => {
459
+ const use = config.lint.pathSeparator;
460
+ for (const v of text.variants) for (const m of v.matchAll(PATH_SEPARATORS)) {
461
+ if ((m[1] ?? m[2] ?? m[3]) === use) continue;
462
+ return [{
463
+ message: `a path is written with a spaced ${use}`,
464
+ match: m[0],
465
+ fix: ` ${use} `
466
+ }];
467
+ }
468
+ return [];
469
+ }
470
+ },
415
471
  contractions: {
416
472
  description: "`could not`, `is not` and `cannot` are written as contractions.",
417
473
  check: ({ text }) => CONTRACTIONS.flatMap(([pattern, short]) => {
@@ -661,9 +717,11 @@ function reasonProblem(why) {
661
717
  /** A locale is one a rule reads when it names its language, or the locale and a region of it. */
662
718
  const readsLocale = (locales, locale, sourceLocale) => locales === void 0 ? locale === sourceLocale : locales === "all" || locales.some((l) => locale.toLowerCase() === l.toLowerCase() || locale.toLowerCase().startsWith(`${l.toLowerCase()}-`));
663
719
  function applies(rule, message, locale, sourceLocale) {
664
- const { kind, surface, locale: locales } = rule.on ?? {};
665
- return readsLocale(locales, locale, sourceLocale) && (kind === void 0 || message.kind !== void 0 && kind.includes(message.kind)) && (surface === void 0 || message.surface !== void 0 && surface.includes(message.surface));
720
+ const { kind, surface, area, locale: locales } = rule.on ?? {};
721
+ return readsLocale(locales, locale, sourceLocale) && (kind === void 0 || message.kind !== void 0 && kind.includes(message.kind)) && (surface === void 0 || message.surface !== void 0 && surface.includes(message.surface)) && (area === void 0 || area.includes(message.area));
666
722
  }
723
+ /** A rule's severity for an entry: its area's, where `lint.areas` sets one. */
724
+ const severityOf = (config, name, message) => config.lint.areas[message.area]?.[name] ?? config.lint.rules[name]?.severity;
667
725
  /**
668
726
  * Where the message's literals are written in its text, each looked for after the one before. A
669
727
  * literal escaped in the text (`''`, `\{`) isn't written as read, so it has no place, and nor does a
@@ -740,7 +798,8 @@ function lint(messages, config) {
740
798
  config
741
799
  };
742
800
  let literals;
743
- for (const [name, { rule, severity }] of rules) {
801
+ for (const [name, { rule }] of rules) {
802
+ const severity = severityOf(config, name, message);
744
803
  if (severity === "off" || !applies(rule, message, locale, config.source)) continue;
745
804
  let said;
746
805
  try {
@@ -782,12 +841,11 @@ function lint(messages, config) {
782
841
  rule: "allow",
783
842
  severity: "error"
784
843
  };
785
- const rule = config.lint.rules[name];
786
- if (rule === void 0) findings.push({
844
+ if (config.lint.rules[name] === void 0) findings.push({
787
845
  ...at,
788
846
  message: `allow.${name} is not a rule: ${rules.map(([n]) => n).join(", ")}`
789
847
  });
790
- else if (rule.severity === "off") continue;
848
+ else if (severityOf(config, name, message) === "off") continue;
791
849
  else if (!fired.has(name)) findings.push({
792
850
  ...at,
793
851
  message: `allow.${name} exempts the entry from a rule it passes: remove it`
@@ -1072,6 +1130,8 @@ function resolveConfig(root, config) {
1072
1130
  const at = (path) => isAbsolute(path) ? path : resolve(root, path);
1073
1131
  const lint = config.lint ?? {};
1074
1132
  const strict = (lint.extends ?? "recommended") === "strict";
1133
+ const rules = lintRules(lint);
1134
+ for (const [area, severities] of Object.entries(lint.areas ?? {})) for (const name of Object.keys(severities)) if (!(name in rules)) throw new Error(`lint.areas.${area}.${name} is not a rule: name one of ${Object.keys(rules).join(", ")}`);
1075
1135
  return {
1076
1136
  root,
1077
1137
  catalog: at(config.catalog ?? "copy/catalog"),
@@ -1089,14 +1149,16 @@ function resolveConfig(root, config) {
1089
1149
  kinds: config.kinds ?? DEFAULT_KINDS,
1090
1150
  surfaces: config.surfaces ?? DEFAULT_SURFACES,
1091
1151
  lint: {
1092
- rules: lintRules(lint),
1152
+ rules,
1153
+ areas: lint.areas ?? {},
1093
1154
  banned: [...strict ? STRICT_LISTS.banned : [], ...lint.banned ?? []],
1094
1155
  spelling: {
1095
1156
  ...strict ? STRICT_LISTS.spelling : {},
1096
1157
  ...lint.spelling
1097
1158
  },
1098
1159
  concepts: { ...lint.concepts },
1099
- properNouns: lint.properNouns ?? []
1160
+ properNouns: lint.properNouns ?? [],
1161
+ pathSeparator: lint.pathSeparator ?? "›"
1100
1162
  },
1101
1163
  scan: {
1102
1164
  dirs: (config.scan?.dirs ?? ["src"]).map(at),
@@ -1143,4 +1205,4 @@ function lintRules(lint) {
1143
1205
  }
1144
1206
  export { numberOptions as C, walk as D, tagsOf as E, formatsOf as S, staticLiteral as T, words as _, DEFAULT_KINDS as a, dateOptions as b, CORE_RULES as c, compileRule as d, definePlugin as f, singularOf as g, sentences as h, resolveConfig as i, HOLE as l, phrase as m, defineConfig as n, DEFAULT_SURFACES as o, lint as p, loadConfig as r, STRICT_LISTS as s, CONFIG_FILES as t, applyEdits as u, TYPE$1 as v, parseMessage as w, formatProblems as x, argsOf as y };
1145
1207
 
1146
- //# sourceMappingURL=config-CxVMn19f.js.map
1208
+ //# sourceMappingURL=config-D--RITk2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-D--RITk2.js","names":["TYPE","TYPE"],"sources":["../src/tools/icu.ts","../src/tools/lint.ts","../src/tools/presets.ts","../src/tools/config.ts"],"sourcesContent":["/**\n * What an ICU message declares, read off its AST: argument types, tags, and whether each number and\n * date style is one the formatter honors. Shared by the loader, the compiler and the lint.\n */\nimport { isDateElement, isNumberElement, isTimeElement, parse, TYPE } from '@formatjs/icu-messageformat-parser';\nimport type { DateElement, MessageFormatElement, NumberElement, TimeElement } from '@formatjs/icu-messageformat-parser';\n\nexport type { MessageFormatElement };\nexport { TYPE };\n\nexport function parseMessage(text: string): MessageFormatElement[] {\n const ast = parse(text, { shouldParseSkeletons: true, requiresOtherClause: true });\n walk(ast, (el) => {\n if ((isDateElement(el) || isTimeElement(el)) && typeof el.style === 'object' && el.style !== null && el.style.pattern.includes('j'))\n el.style.parsedOptions = localHour(el.style.pattern);\n });\n return ast;\n}\n\n/**\n * A skeleton's `j` is the hour as the locale writes it, 12 or 24. The parser resolves it only when\n * given a locale and drops it otherwise, so `::yMMMdjmm` showed the minute alone. Read here as an\n * hour with no cycle, which `Intl` gives the cycle of whatever locale formats it: \"2:05 PM\", \"14:05\".\n */\nfunction localHour(pattern: string): Intl.DateTimeFormatOptions {\n const run = /j+/.exec(pattern)![0];\n const rest = pattern.replaceAll('j', '');\n return { ...(rest === '' ? {} : dateFields(rest)), hour: run.length % 2 === 0 ? '2-digit' : 'numeric' };\n}\n\n/** What the parser reads from a date skeleton on its own; nothing where it can't parse it. */\nfunction dateFields(skeleton: string): Intl.DateTimeFormatOptions {\n try {\n const el = parse(`{d, date, ::${skeleton}}`, { shouldParseSkeletons: true })[0];\n return el !== undefined && isDateElement(el) && typeof el.style === 'object' && el.style !== null ? el.style.parsedOptions : {};\n } catch {\n return {};\n }\n}\n\n/**\n * ICU argument types, as TypeScript. A bare `{x}` is a string: a number spliced in raw is printed by\n * `String()`, which knows no locale, so a quantity says `{x, number}` and the type is what asks for it.\n * A `select` narrows to the arms it names, and still takes any string, since `other` catches the rest.\n */\nfunction argType(el: MessageFormatElement): string | undefined {\n switch (el.type) {\n case TYPE.argument:\n return 'string';\n case TYPE.number:\n case TYPE.plural:\n return 'number';\n case TYPE.date:\n case TYPE.time:\n return 'Date | number';\n case TYPE.select: {\n const named = Object.keys(el.options).filter((o) => o !== 'other');\n return named.length > 0 ? `${named.map((o) => JSON.stringify(o)).join(' | ')} | (string & {})` : 'string';\n }\n case TYPE.literal:\n case TYPE.pound:\n case TYPE.tag:\n default:\n return undefined;\n }\n}\n\n/** Calls `visit` on every element, inside plural and select arms and tags too. */\nexport function walk(elements: MessageFormatElement[], visit: (el: MessageFormatElement) => void): void {\n for (const el of elements) {\n visit(el);\n if (el.type === TYPE.select || el.type === TYPE.plural) for (const option of Object.values(el.options)) walk(option.value, visit);\n if (el.type === TYPE.tag) walk(el.children, visit);\n }\n}\n\nexport function argsOf(elements: MessageFormatElement[], clash: (name: string) => void = () => {}): Map<string, string> {\n const args = new Map<string, string>();\n walk(elements, (el) => {\n const type = argType(el);\n if (type === undefined || !('value' in el) || typeof el.value !== 'string') return;\n const seen = args.get(el.value);\n if (seen !== undefined && seen !== type) clash(el.value);\n else args.set(el.value, type);\n });\n return args;\n}\n\nexport function tagsOf(elements: MessageFormatElement[]): string[] {\n const tags = new Set<string>();\n walk(elements, (el) => {\n if (el.type === TYPE.tag) tags.add(el.value);\n });\n return [...tags].sort();\n}\n\n/** A message with no placeholders and no tags renders to one literal, which ships as a plain string. */\nexport function staticLiteral(ast: MessageFormatElement[]): string | undefined {\n if (ast.length === 0) return '';\n if (ast.length === 1 && ast[0]!.type === TYPE.literal) return ast[0]!.value;\n return undefined;\n}\n\nconst NUMBER_STYLES: Record<string, Intl.NumberFormatOptions> = {\n integer: { maximumFractionDigits: 0 },\n percent: { style: 'percent' },\n};\n\nconst DATE_STYLES = ['short', 'medium', 'long', 'full'] as const;\n\n/** The `Intl` options a number element formats with. Throws, with the fix, where the style is wrong. */\nexport function numberOptions(el: NumberElement): Intl.NumberFormatOptions | undefined {\n const style = el.style;\n if (style === null || style === undefined) return undefined;\n if (typeof style === 'string') {\n if (style === 'currency') throw new Error(`{${el.value}} needs its currency named: {${el.value}, number, ::currency/EUR}`);\n const named = NUMBER_STYLES[style];\n if (named === undefined) throw new Error(`{${el.value}} asks for number style \"${style}\": integer, percent, or a ::skeleton`);\n return named;\n }\n const unknown = style.tokens.filter((t) => !stemIsKnown(t.stem, t.options)).map((t) => t.stem);\n if (unknown.length > 0) throw new Error(`{${el.value}} has skeleton stems the formatter drops without a word: ${unknown.join(', ')}`);\n const options = style.parsedOptions as Intl.NumberFormatOptions;\n try {\n new Intl.NumberFormat('en', options).resolvedOptions();\n } catch (e) {\n throw new Error(`{${el.value}} has a skeleton Intl refuses: ${(e as Error).message}`, { cause: e });\n }\n return options;\n}\n\n/** The `Intl` options a date or time element formats with. Throws, with the fix, where the style is wrong. */\nexport function dateOptions(el: DateElement | TimeElement): Intl.DateTimeFormatOptions | undefined {\n const style = el.style;\n const field = el.type === TYPE.time ? 'timeStyle' : 'dateStyle';\n if (style === null || style === undefined) return el.type === TYPE.time ? { timeStyle: 'short' } : undefined;\n if (typeof style === 'string') {\n if (!(DATE_STYLES as readonly string[]).includes(style)) {\n const kind = el.type === TYPE.time ? 'time' : 'date';\n throw new Error(`{${el.value}} asks for ${kind} style \"${style}\": ${DATE_STYLES.join(', ')}, or a ::skeleton`);\n }\n return { [field]: style };\n }\n // Every field the parser understands sets an option, and one it doesn't is dropped without a word.\n const dropped = (style.pattern.match(/([A-Za-z])\u0001*/g) ?? []).filter((f) => !f.startsWith('j') && Object.keys(dateFields(f)).length === 0);\n if (dropped.length > 0) throw new Error(`{${el.value}} has date fields the formatter drops without a word: ${dropped.join(', ')}`);\n if (Object.keys(style.parsedOptions).length === 0)\n throw new Error(`{${el.value}} has a date skeleton the formatter reads nothing from: \"${style.pattern}\"`);\n try {\n new Intl.DateTimeFormat('en', style.parsedOptions).resolvedOptions();\n } catch (e) {\n throw new Error(`{${el.value}} has a skeleton Intl refuses: ${(e as Error).message}`, { cause: e });\n }\n return style.parsedOptions;\n}\n\n/**\n * Whether the formatter understands a skeleton stem. One it does not is dropped without a word, so\n * `::compact-shortt` reaches the screen as `5` where `5K` was written. Every stem it understands sets\n * at least one option, so an empty result is the answer.\n */\nfunction stemIsKnown(stem: string, options: readonly string[]): boolean {\n try {\n const el = parse(`{n, number, ::${[stem, ...options].join('/')}}`, { shouldParseSkeletons: true })[0];\n if (el === undefined || !isNumberElement(el) || typeof el.style !== 'object' || el.style === null) return false;\n return Object.keys(el.style.parsedOptions).length > 0;\n } catch {\n return false;\n }\n}\n\n/** Every format problem in a message, as sentences. */\nexport function formatProblems(ast: MessageFormatElement[]): string[] {\n const found: string[] = [];\n walk(ast, (el) => {\n try {\n if (isNumberElement(el)) numberOptions(el);\n if (isDateElement(el) || isTimeElement(el)) dateOptions(el);\n } catch (e) {\n found.push((e as Error).message);\n }\n });\n return found;\n}\n\n/** How each number or date argument is formatted, for the generated doc comment: `date medium, time short`. */\nexport function formatsOf(ast: MessageFormatElement[]): Map<string, string> {\n const formats = new Map<string, string[]>();\n walk(ast, (el) => {\n if (!isNumberElement(el) && !isDateElement(el) && !isTimeElement(el)) return;\n const style = el.style;\n if (style === null || style === undefined) return;\n const kind = el.type === TYPE.number ? 'number' : el.type === TYPE.date ? 'date' : 'time';\n let said: string;\n if (typeof style === 'string') {\n said = `${kind} \\`${style}\\``;\n } else if ('mf2' in style) {\n // Read from MF2: the function as written.\n const { name, options } = (style as { mf2: { name: string; options: Record<string, string> } }).mf2;\n said = `\\`${[`:${name}`, ...Object.entries(options).map(([k, v]) => `${k}=${v}`)].join(' ')}\\``;\n } else if ('tokens' in style) {\n said = `${kind} \\`::${style.tokens.map((t) => [t.stem, ...t.options].join('/')).join(' ')}\\``;\n } else {\n said = `${kind} \\`::${style.pattern}\\``;\n }\n const list = formats.get(el.value) ?? [];\n if (!list.includes(said)) list.push(said);\n formats.set(el.value, list);\n });\n return new Map([...formats].map(([name, list]) => [name, list.join(', ')]));\n}\n","/**\n * Holds every source message to the mechanical half of a writing guide: budgets, periods, case,\n * dashes, spelling, contractions, the product's one word per concept, and banned words. What needs\n * judgment stays with review. An entry a rule is wrong about says so under `allow`, with the reason,\n * and an exemption that no longer matches anything fails too, so none outlive the words they excused.\n *\n * The core rules are written as a plugin's are: a project adds its own through `lint.plugins`, as\n * code or as data, and they read the same readings of a message and are exempted the same way.\n */\nimport type { Message } from './catalog.ts';\nimport type { ResolvedConfig } from './config.ts';\nimport { staticLiteral, TYPE, walk, type MessageFormatElement } from './icu.ts';\nimport type { KindRule, Severity } from './presets.ts';\n\n/** What a rule is given about one message in one locale. */\nexport interface RuleContext {\n /** The entry, as the source catalog has it. */\n message: Message;\n /** The locale read: the source, or a translation's. */\n locale: string;\n /** The message in that locale. */\n ast: MessageFormatElement[];\n /** The shape the message's kind is held to, when it names a kind the config defines. */\n kind: KindRule | undefined;\n /** The message in that locale, as prose. */\n text: Readings;\n /** The source message as prose, to hold a translation to it: `text` itself in the source locale. */\n source: Readings;\n config: ResolvedConfig;\n}\n\ninterface RuleBase {\n /** One sentence: what the rule holds a string to. */\n description: string;\n /** Its severity under `extends: 'recommended'`; off when unset. */\n recommended?: Severity;\n /** Its severity under `extends: 'strict'`; `error` when unset. */\n strict?: Severity;\n /**\n * Only entries of these kinds, on these surfaces, or in these areas (a key's first segment); an\n * entry that says no kind or surface is skipped by a rule that names some. Only the source unless\n * `locale` says otherwise, since most writing rules are written for one language: `all` reads\n * every locale, and a list those languages and their regions (`de` covers `de-CH`).\n */\n on?: { kind?: string[]; surface?: string[]; area?: string[]; locale?: 'all' | string[] };\n}\n\n/** A rule written as code. */\nexport interface CheckRule extends RuleBase {\n /** What is wrong with the message, a sentence each that states the fix; none when it passes. */\n check(context: RuleContext): (string | Report)[];\n}\n\n/** A finding that can say where it is, and what to write instead. */\nexport interface Report {\n message: string;\n /** The words the finding is about, as a reading has them: found in the message's text, in any case. */\n match?: string;\n /** What `prosebook lint --fix` writes in place of `match`, wherever it stands; its case follows the text's. */\n fix?: string;\n}\n\n/** A replacement in a message's text, by offset. */\nexport interface Edit {\n start: number;\n end: number;\n text: string;\n}\n\n/*\n * Rules written as data, after Vale's, so a JSON config can carry them. Words and patterns are looked\n * for in every reading, so one in a `one` arm is found; counts and case read the `other` arms. A\n * pattern is a regular expression with the `u` flag, and sees a placeholder as `HOLE`. A message\n * names what was found with `{match}`, and the other fields its rule lists.\n */\n\n/** Words or patterns a string never uses. */\nexport interface ExistenceRule extends RuleBase {\n type: 'existence';\n /** Words or phrases, matched whole and in any case. `{match}` is the one listed. */\n words?: string[];\n /** `{match}` is the text matched. */\n patterns?: string[];\n ignoreCase?: boolean;\n message: string;\n}\n\n/** A word or phrase the product writes another way. */\nexport interface SubstitutionRule extends RuleBase {\n type: 'substitution';\n /** A word or phrase, matched whole and in any case, and the one written instead. */\n swap: Record<string, string>;\n /** `{match}` and `{use}`; `\"{match}\" is written \"{use}\"` when unset. */\n message?: string;\n}\n\n/** A budget, beside the one a kind sets: per surface, say, or in characters. */\nexport interface OccurrenceRule extends RuleBase {\n type: 'occurrence';\n /** Every word, placeholders included; sentences; or characters, placeholders not included. */\n count: 'words' | 'sentences' | 'characters';\n max?: number;\n min?: number;\n /** `max` and `min` are multiples of the source's count: `max: 1.4` is 40% longer than the source at most. */\n relative?: boolean;\n /** `{count}`, `{max}`, `{min}`, and with `relative`, `{source}` (the source's count) and `{limit}`. */\n message?: string;\n}\n\nexport interface CapitalizationRule extends RuleBase {\n type: 'capitalization';\n /** `sentence` capitalizes only the first word and proper nouns, `title` every word but short function words. */\n case: 'sentence' | 'title' | 'lower' | 'upper';\n /** Words that keep their case, beside `lint.properNouns`. */\n exceptions?: string[];\n /** `{match}` is the first word out of case. */\n message?: string;\n}\n\n/** A string that matches `when` (every string, when unset) matches `require` too. */\nexport interface ConditionalRule extends RuleBase {\n type: 'conditional';\n when?: string;\n require: string;\n ignoreCase?: boolean;\n /** `{match}` is the text `when` matched. */\n message: string;\n}\n\nexport type Rule = CheckRule | ExistenceRule | SubstitutionRule | OccurrenceRule | CapitalizationRule | ConditionalRule;\n\n/** A set of rules, named `<name>/<rule>` in `lint.rules` and in an entry's `allow`. */\nexport interface Plugin {\n name: string;\n rules: Record<string, Rule>;\n}\n\n/** Typed plugin, for `lint.plugins`. */\nexport function definePlugin(plugin: Plugin): Plugin {\n return plugin;\n}\n\nexport interface Finding {\n key: string;\n /** The catalog file, or for a translation, the locale's file. */\n file: string;\n /** The locale whose text the finding is about; the source for an `allow` finding. */\n locale: string;\n /** The rule's name, or `allow` for an exemption that is itself wrong. */\n rule: string;\n severity: Exclude<Severity, 'off'>;\n message: string;\n /** Where in the locale's message text, when the rule named a match and it is written there as read. */\n at?: { start: number; end: number };\n /** The edits that fix it, at every place the match stands. */\n fix?: Edit[];\n}\n\n/** Stands in for a placeholder in a reading, which no prose rule reads. */\nexport const HOLE = '\\u2063';\n/** Tags whose content is code or a literal the reader types, not prose. */\nconst VERBATIM_TAGS = new Set(['code', 'mono', 'kbd', 'keycap', 'nums']);\n\nfunction renderAs(elements: MessageFormatElement[], arm: string | null): string {\n let out = '';\n for (const el of elements) {\n if (el.type === TYPE.literal) {\n out += el.value;\n } else if (el.type === TYPE.tag) {\n out += VERBATIM_TAGS.has(el.value) ? HOLE : renderAs(el.children, arm);\n } else if (el.type === TYPE.plural || el.type === TYPE.select) {\n const option = arm === null ? undefined : (el.options[arm] ?? el.options['other']);\n out += option === undefined ? HOLE : renderAs(option.value, arm);\n } else {\n out += HOLE;\n }\n }\n return out;\n}\n\n/** The message as prose: placeholders and verbatim tags read as `HOLE`, and `’` as `'` in `variants`. */\nexport interface Readings {\n /** Every `other` arm taken: what a budget is measured on. */\n primary: string;\n /** One reading per arm, so a word hidden in `one` is still found. */\n variants: string[];\n /** Only the words the message always carries. */\n skeleton: string;\n}\n\nfunction readings(message: MessageFormatElement[]): Readings {\n const literal = staticLiteral(message);\n const ast = literal === undefined ? message : ([{ type: TYPE.literal, value: literal }] as MessageFormatElement[]);\n const arms = new Set<string>();\n const collect = (els: MessageFormatElement[]) => {\n for (const el of els) {\n if (el.type === TYPE.plural || el.type === TYPE.select) {\n for (const [name, option] of Object.entries(el.options)) {\n arms.add(name);\n collect(option.value);\n }\n }\n if (el.type === TYPE.tag) collect(el.children);\n }\n };\n collect(ast);\n const primary = renderAs(ast, 'other');\n const variants = new Set([primary, ...[...arms].map((arm) => renderAs(ast, arm))]);\n return { primary, variants: [...variants].map((v) => v.replace(/\\u2019/g, \"'\")), skeleton: renderAs(ast, null) };\n}\n\n/** What a reader sees end to end, less a placeholder appended at the very end. */\nconst prose = (text: string) => text.replace(new RegExp(`[\\\\s${HOLE}]+$`), '');\n\nconst FREE = new Set('a an the this that these those it its them your and or to of for by in on at from with'.split(' '));\n\nconst tokens = (text: string) => text.split(/\\s+/).filter((w) => /[\\p{L}\\p{N}]/u.test(w) || w.includes(HOLE));\n\n/** The words a budget counts: articles, short prepositions and asides in parentheses are free. */\nexport function words(text: string): string[] {\n return tokens(text.replace(/\\s*\\([^)]*\\)/g, '')).filter((w) => !FREE.has(w.toLowerCase().replace(/[^\\p{L}]/gu, '')));\n}\n\nconst ABBREVIATIONS = /\\b(?:e\\.g|i\\.e|vs|etc)\\.$/i;\n\nexport function sentences(text: string): number {\n let count = 1;\n const boundary = /[.!?…]+[\"')\\]]*\\s+(?=\\S)/g;\n for (let m = boundary.exec(text); m !== null; m = boundary.exec(text))\n if (!ABBREVIATIONS.test(text.slice(0, m.index + m[0].trimEnd().length))) count += 1;\n\n return count;\n}\n\n/** A word or phrase on its own, not inside a longer word or a hyphenated compound. */\nexport function phrase(p: string): RegExp {\n const escaped = p.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&').replace(/ /g, '\\\\s+');\n return new RegExp(`(?<![\\\\p{L}\\\\p{N}'-])${escaped}(?![\\\\p{L}\\\\p{N}'-])`, 'iu');\n}\n\n/** The words and phrases of `list` that some reading carries. */\nconst listed = (variants: string[], list: string[]) => list.filter((w) => variants.some((v) => phrase(w).test(v)));\n\nconst unquoted = (token: string) => token.replace(/^[(\"'“‘]+|[)\"'”’.,:;!?]+$/g, '');\n\nfunction capitalizedWord(text: string, proper: Set<string>): string | undefined {\n const parts = text.split(/\\s+/).filter(Boolean);\n for (let i = 1; i < parts.length; i++) {\n const word = unquoted(parts[i]!);\n if (!/^\\p{Lu}\\p{Ll}/u.test(word) || proper.has(word)) continue;\n if (/[.:?!][\"')]*$/.test(parts[i - 1]!)) continue;\n return word;\n }\n return undefined;\n}\n\n/** Words a count is followed by that are not plural nouns, though they end in s. */\nconst NOT_PLURAL = new Set([\n 'is',\n 'was',\n 'has',\n 'does',\n 'this',\n 'its',\n 'plus',\n 'minus',\n 'less',\n 'yes',\n 'us',\n 'as',\n 'bus',\n 'gas',\n 'news',\n 'series',\n]);\n\n/**\n * The singular of an English plural noun, or nothing where it doesn't look like one. A word with no\n * vowel is a unit or an abbreviation (`kbps`, `fps`, `hrs`), which reads the same after 1.\n */\nexport function singularOf(word: string): string | undefined {\n const lower = word.toLowerCase();\n if (word.length < 3 || !lower.endsWith('s') || lower.endsWith('ss') || NOT_PLURAL.has(lower)) return undefined;\n if (!/[aeiouy]/.test(lower)) return undefined;\n if (/[^aeiou]ies$/.test(lower)) return `${word.slice(0, -3)}y`;\n if (/(?:s|x|z|ch|sh)es$/.test(lower)) return word.slice(0, -2);\n return word.slice(0, -1);\n}\n\nconst MINOR = new Set('a an the and but or nor for so yet as at by in of off on per to up via with'.split(' '));\n\n/** The first word out of `style` case, less those in `keep`. */\nfunction outOfCase(text: string, style: CapitalizationRule['case'], keep: Set<string>): string | undefined {\n if (style === 'sentence') return capitalizedWord(text, keep);\n const list = text\n .split(/\\s+/)\n .map(unquoted)\n .filter((w) => /\\p{L}/u.test(w) && !keep.has(w));\n return list.find((w, i) => {\n if (style === 'lower') return /\\p{Lu}/u.test(w);\n if (style === 'upper') return /\\p{Ll}/u.test(w);\n return /^\\p{Ll}/u.test(w) && (i === 0 || !MINOR.has(w));\n });\n}\n\nconst CONTRACTIONS: [RegExp, string][] = [\n [/\\bcannot\\b/i, \"can't\"],\n [/\\bcan not\\b/i, \"can't\"],\n [/\\bwill not\\b/i, \"won't\"],\n [/\\b(could|would|should|is|are|was|were|do|does|did|has|have|had|must|need) not\\b/i, \"n't\"],\n];\n\n/** Calls `visit` on every run of elements that sit side by side, with the arguments a plural around it counts. */\nfunction eachRun(\n elements: MessageFormatElement[],\n visit: (run: MessageFormatElement[], counted: ReadonlySet<string>) => void,\n counted: ReadonlySet<string> = new Set(),\n): void {\n visit(elements, counted);\n for (const el of elements) {\n if (el.type === TYPE.plural) for (const o of Object.values(el.options)) eachRun(o.value, visit, new Set([...counted, el.value]));\n if (el.type === TYPE.select) for (const o of Object.values(el.options)) eachRun(o.value, visit, counted);\n if (el.type === TYPE.tag) eachRun(el.children, visit, counted);\n }\n}\n\n/** A plain placeholder named as a count. A number placeholder is one whatever its name. */\nconst COUNT_NAME = /^(?:n|num|count|total|amount|quantity)$|(?:count|total)$/i;\n\n/**\n * Whether an arm ends with a stop; nothing for an arm with no words, or one that trails off in an\n * ellipsis (`Saving…`, `Save as…`), which is neither. Which stop is the arm's own: a question in\n * `one` and a second sentence after it in `other` both end well.\n */\nfunction endsWithStop(arm: MessageFormatElement[]): boolean | undefined {\n const text = prose(renderAs(arm, 'other')).trim();\n if (text.replaceAll(HOLE, '').trim() === '' || /(?:…|\\.{3})[\"')”»」』]*$/u.test(text)) return undefined;\n return hasStop(text);\n}\n\n/** Ends with a stop in any script (`。`, `؟`, `;` as Greek writes `?`), though not a comma. */\nconst hasStop = (text: string) => /(?![,,、،])[\\p{Terminal_Punctuation}…][\"')”»」』]*$/u.test(prose(text).trim());\n\nconst CURRENCY_BEFORE = /[$€£¥₹]\\s?$/;\n\n/**\n * The ways a path through menus is written, the separator in a group: an arrow or `›` however\n * spaced, and `>` or `/` only spaced between words or placeholders, with a capital after a slash,\n * since \"2 > 1\" and \"and / or\" are no paths. The match takes the spaces around, so the fix spaces\n * the separator.\n */\nconst PATH_SEPARATORS = new RegExp(\n String.raw`\\s*(→|->|›)\\s*|(?<=[\\p{L}${HOLE}])\\s+(>)\\s+(?=[\\p{L}${HOLE}])|(?<=\\p{L})\\s+(\\/)\\s+(?=\\p{Lu})`,\n 'gu',\n);\n\nconst OFF_SCREEN = new Set(['aria']);\n\nconst an = (word = 'string') => `${/^[aeiou]/i.test(word) ? 'an' : 'a'} ${word}`;\n\nexport const CORE_RULES = {\n whitespace: {\n description: 'No leading, trailing or doubled spaces.',\n recommended: 'error',\n on: { locale: 'all' },\n check: ({ text }) => {\n const message = 'no leading, trailing or doubled spaces';\n // As a match, two spaces stand for a run of any length.\n if (text.variants.some((v) => v.includes(' '))) return [{ message, match: ' ', fix: ' ' }];\n return text.variants.some((v) => /^\\s|\\s$/.test(v.replaceAll(HOLE, 'x'))) ? [message] : [];\n },\n },\n 'word-budget': {\n description: \"A kind with `maxWords` stays within it. Articles, short prepositions and asides in parentheses don't count.\",\n recommended: 'warn',\n check: ({ message: m, kind, text }) => {\n if (kind?.maxWords === undefined || OFF_SCREEN.has(m.surface ?? '')) return [];\n const n = words(text.primary).length;\n return n > kind.maxWords ? [`${an(m.kind)} is ${kind.maxWords} words at most, and this is ${n}`] : [];\n },\n },\n 'sentence-budget': {\n description: 'A kind with `maxSentences` stays within it.',\n recommended: 'warn',\n check: ({ message: m, kind, text }) => {\n const most = (m.surface !== undefined ? kind?.maxSentencesOn?.[m.surface] : undefined) ?? kind?.maxSentences;\n if (most === undefined) return [];\n const n = sentences(prose(text.primary));\n return n > most\n ? [\n `${an(m.kind)}${kind?.maxSentencesOn?.[m.surface ?? ''] !== undefined ? ` on ${m.surface}` : ''} is ${most} sentence(s) at most, and this is ${n}`,\n ]\n : [];\n },\n },\n period: {\n description: 'A kind with `period: always` (or on a listed surface) ends with a period, unless the entry is a fragment.',\n recommended: 'warn',\n check: ({ message: m, kind, text }) => {\n const rule = kind?.period;\n const applies = rule === 'always' || (Array.isArray(rule) && rule.includes(m.surface ?? ''));\n return applies && !m.fragment && !/[.?!…:][\"')”]*$/.test(prose(text.primary))\n ? [`${an(m.kind)} ends with a period, or is marked fragment: true`]\n : [];\n },\n },\n 'no-period': {\n description: 'A kind with `period: never` ends without one.',\n recommended: 'warn',\n check: ({ message: m, kind, text }) =>\n kind?.period === 'never' && /[^.]\\.$/.test(prose(text.primary)) ? [`${an(m.kind)} ends without a period`] : [],\n },\n 'bare-name': {\n description: 'A kind with `bare: true` carries no explanation after a dash or a colon.',\n recommended: 'warn',\n // A colon before a value is a readout, as in \"Zoom: 120%\", not an explanation.\n check: ({ message: m, kind, text }) =>\n kind?.bare === true && new RegExp(`\\\\s[—–-]\\\\s|\\\\p{L}:\\\\s(?!${HOLE})`, 'u').test(text.skeleton)\n ? [`${an(m.kind)} carries no explanation after a dash or a colon`]\n : [],\n },\n 'sentence-case': {\n description: 'A kind with `sentenceCase: true` capitalizes only its first word and proper nouns.',\n check: ({ message: m, kind, text, config }) => {\n if (kind?.sentenceCase !== true) return [];\n const word = outOfCase(text.primary, 'sentence', new Set(config.lint.properNouns));\n if (word === undefined) return [];\n return [\n { message: `\"${word}\" is capitalized in a sentence-case ${m.kind}: add it to lint.properNouns if it is a name`, match: word },\n ];\n },\n },\n 'banned-word': {\n description: 'A word or phrase from the banned lists.',\n recommended: 'warn',\n check: ({ text, config }) =>\n config.lint.banned.flatMap(({ words: list, why }) =>\n listed(text.variants, list).map((w) => ({ message: `\"${w}\" ${why}`, match: w })),\n ),\n },\n spelling: {\n description: 'A spelling the product writes another way.',\n recommended: 'warn',\n check: ({ text, config: { lint } }) =>\n listed(text.variants, Object.keys(lint.spelling)).map((w) => ({\n message: `\"${w}\" is spelled \"${lint.spelling[w]}\"`,\n match: w,\n fix: lint.spelling[w],\n })),\n },\n 'one-word': {\n description: 'A near-synonym for a concept the product has one word for.',\n recommended: 'warn',\n check: ({ text, config: { lint } }) =>\n listed(text.variants, Object.keys(lint.concepts)).map((w) => ({\n message: `\"${w}\" is \"${lint.concepts[w]}\" everywhere in the product`,\n match: w,\n fix: lint.concepts[w],\n })),\n },\n 'no-em-dash': {\n description: 'No em-dashes, and no spaced hyphen standing in for one.',\n check: ({ text }) => {\n const match = text.variants.map((v) => /—|\\s[–-]\\s/.exec(v)?.[0]).find((m) => m !== undefined);\n return match === undefined ? [] : [{ message: 'no em-dash: a comma, a period or a colon does the job', match }];\n },\n },\n path: {\n description: 'A path through menus or settings is written with `lint.pathSeparator`, spaced: Settings › General.',\n check: ({ text, config }) => {\n const use = config.lint.pathSeparator;\n for (const v of text.variants) {\n for (const m of v.matchAll(PATH_SEPARATORS)) {\n if ((m[1] ?? m[2] ?? m[3]) === use) continue;\n return [{ message: `a path is written with a spaced ${use}`, match: m[0], fix: ` ${use} ` }];\n }\n }\n return [];\n },\n },\n contractions: {\n description: '`could not`, `is not` and `cannot` are written as contractions.',\n check: ({ text }) =>\n CONTRACTIONS.flatMap(([pattern, short]) => {\n const found = text.variants.map((v) => pattern.exec(v)).find((f) => f !== null);\n if (found === undefined || found === null) return [];\n const fix = short === \"n't\" ? `${found[1]}n't` : short;\n return [{ message: `\"${found[0]}\" is written as a contraction (${short})`, match: found[0], fix }];\n }),\n },\n ellipsis: {\n description: 'An ellipsis is one character, `…`, not three periods.',\n on: { locale: 'all' },\n check: ({ text }) =>\n text.variants.some((v) => v.includes('...')) ? [{ message: 'an ellipsis is one character: …', match: '...', fix: '…' }] : [],\n },\n 'plural-count': {\n description: 'A count followed by a plural noun, `{count} files`, is a plural, or it reads \"1 files\". English.',\n recommended: 'warn',\n check: ({ ast }) => {\n const said: Report[] = [];\n eachRun(ast, (run, counted) =>\n run.forEach((el, i) => {\n if (el.type !== TYPE.number && el.type !== TYPE.argument) return;\n if (counted.has(el.value) || (el.type === TYPE.argument && !COUNT_NAME.test(el.value))) return;\n const next = run[i + 1];\n const word = next?.type === TYPE.literal ? /^\\s+(\\p{L}+)(?![\\p{L}'])/u.exec(next.value)?.[1] : undefined;\n const one = word === undefined ? undefined : singularOf(word);\n if (word !== undefined && one !== undefined) {\n said.push({\n message: `${el.value} is followed by \"${word}\", which reads \"1 ${word}\": make it a plural with a \"# ${one}\" arm`,\n match: word,\n });\n }\n }),\n );\n return said;\n },\n },\n 'plural-one': {\n description: \"A plural's `one` arm says something other than `other`, and says `#` rather than `1`.\",\n recommended: 'warn',\n on: { locale: 'all' },\n check: ({ ast, locale, config }) => {\n const said: Report[] = [];\n walk(ast, (el) => {\n if (el.type !== TYPE.plural || el.pluralType !== 'cardinal') return;\n const { one, other } = el.options;\n if (one === undefined) return;\n // Turkish says \"# dosya\" for one and other alike, so only the source must tell them apart.\n if (locale === config.source && other !== undefined && renderAs(one.value, 'other') === renderAs(other.value, 'other'))\n said.push({ message: `the one and other arms of ${el.value} say the same: write the singular in one` });\n let literalOne = false;\n walk(one.value, (inner) => {\n if (inner.type === TYPE.literal && /(?<![\\d.,])1(?![\\d.,])/.test(inner.value)) literalOne = true;\n });\n // Russian's `one` is also 21 and 31, so a translator copying a written 1 gets it wrong there.\n if (!literalOne) return;\n const message = `the one arm of ${el.value} writes 1, which one is not in every language: write #, or make the arm =1`;\n said.push({ message, match: '1' });\n });\n return said;\n },\n },\n 'arm-endings': {\n description: 'The arms of a plural or select end alike: all with a stop, or all without one.',\n recommended: 'warn',\n on: { locale: 'all' },\n check: ({ ast }) => {\n const said: string[] = [];\n walk(ast, (el) => {\n if (el.type !== TYPE.plural && el.type !== TYPE.select) return;\n const endings = new Set(Object.values(el.options).flatMap((o) => endsWithStop(o.value) ?? []));\n if (endings.size > 1) said.push(`some arms of ${el.value} end with a stop and some without: end them alike`);\n });\n return said;\n },\n },\n 'formatted-by-hand': {\n description: 'A currency symbol or `%` typed beside a placeholder, or digits grouped by hand, which only suit one locale.',\n recommended: 'warn',\n on: { locale: 'all' },\n check: ({ ast, text }) => {\n const said = new Map<string, Report>();\n const say = (message: string, match: string) => said.set(message, { message, match });\n eachRun(ast, (run) =>\n run.forEach((el, i) => {\n if (el.type !== TYPE.number && el.type !== TYPE.argument) return;\n const before = run[i - 1];\n const after = run[i + 1];\n const symbol = before?.type === TYPE.literal ? CURRENCY_BEFORE.exec(before.value)?.[0].trim() : undefined;\n if (symbol !== undefined)\n say(`\"${symbol}\" is typed before ${el.value}: format it as a currency, which puts the symbol where the locale does`, symbol);\n if (after?.type === TYPE.literal && /^\\s?%/.test(after.value))\n say(`\"%\" is typed after ${el.value}: format it as a percent, which takes the fraction (0.5 for 50%)`, '%');\n }),\n );\n const grouped = text.variants.map((v) => /\\d{1,3}(?:,\\d{3})+(?!\\d)/.exec(v)?.[0]).find((g) => g !== undefined);\n if (grouped !== undefined)\n say(`\"${grouped}\" groups its digits the English way: make it a placeholder formatted as a number`, grouped);\n return [...said.values()];\n },\n },\n 'source-ending': {\n description: 'A translation ends with a stop where its source does, and without one where it does not.',\n recommended: 'warn',\n on: { locale: 'all' },\n check: ({ text, source }) => {\n const ends = hasStop(text.primary);\n if (ends === hasStop(source.primary)) return [];\n return [\n ends\n ? 'ends with a stop, and the source does not: drop it'\n : 'the source ends with a stop, and this does not: end it as the source does',\n ];\n },\n },\n} satisfies Record<string, CheckRule>;\n\nexport type CoreRule = keyof typeof CORE_RULES;\n\nconst fill = (message: string, values: Record<string, string | number | undefined>) =>\n message.replace(/\\{(\\w+)\\}/g, (all, name: string) => (values[name] === undefined ? all : String(values[name])));\n\nconst graphemes = new Intl.Segmenter();\n\nconst COUNTERS: Record<OccurrenceRule['count'], (text: string) => number> = {\n words: (text) => tokens(text).length,\n sentences: (text) => sentences(prose(text)),\n characters: (text) => [...graphemes.segment(text.replaceAll(HOLE, ''))].length,\n};\n\n/** A rule as code, checked once when the config loads: a JSON config is not type-checked. */\nexport function compileRule(name: string, rule: Rule): CheckRule {\n const fail = (problem: string): never => {\n throw new Error(`lint rule ${name} ${problem}`);\n };\n const pattern = (source: unknown, field: string, ignoreCase: boolean | undefined) => {\n if (typeof source !== 'string') return fail(`${field} is not a string: write the pattern as one`);\n try {\n return new RegExp(source, ignoreCase === true ? 'iu' : 'u');\n } catch (e) {\n return fail(`${field} is not a regular expression: ${e instanceof Error ? e.message : String(e)}`);\n }\n };\n const said = (message: unknown) =>\n typeof message === 'string' && message !== '' ? message : fail('has no message: say what to write instead');\n if (typeof rule.description !== 'string' || rule.description === '') fail('has no description: say what it holds a string to');\n if ('check' in rule) return typeof rule.check === 'function' ? rule : fail('has a check that is not a function');\n const { description, recommended, strict, on } = rule;\n const base = { description, recommended, strict, on };\n switch (rule.type) {\n case 'existence': {\n const list = rule.words ?? [];\n const patterns = (rule.patterns ?? []).map((p, i) => pattern(p, `patterns[${i}]`, rule.ignoreCase));\n if (list.length + patterns.length === 0) fail('has no words or patterns: list what a string never says');\n const message = said(rule.message);\n return {\n ...base,\n check: ({ text }) => {\n const matched = patterns.flatMap((p) => text.variants.map((v) => p.exec(v)?.[0]).find((m) => m !== undefined) ?? []);\n return [...new Set([...listed(text.variants, list), ...matched])].map((match) => ({ message: fill(message, { match }), match }));\n },\n };\n }\n case 'substitution': {\n const swap = rule.swap ?? {};\n if (Object.keys(swap).length === 0) fail('has nothing in swap: map a word to the one written instead');\n const message = rule.message === undefined ? '\"{match}\" is written \"{use}\"' : said(rule.message);\n return {\n ...base,\n check: ({ text }) =>\n listed(text.variants, Object.keys(swap)).map((match) => ({\n message: fill(message, { match, use: swap[match] }),\n match,\n fix: swap[match],\n })),\n };\n }\n case 'occurrence': {\n const { count: unit, max, min, relative } = rule;\n const counter = Object.hasOwn(COUNTERS, unit) ? COUNTERS[unit] : fail(`counts ${unit}: count words, sentences or characters`);\n if (max === undefined && min === undefined) fail('has no max or min: give it one');\n if (rule.message !== undefined) said(rule.message);\n return {\n ...base,\n check: ({ text, source }) => {\n const count = counter(text.primary);\n const of = relative === true ? counter(source.primary) : 1;\n const over = max !== undefined && count > max * of;\n const under = min !== undefined && count < min * of;\n if (!over && !under) return [];\n // The limit shown is one the count could meet: 1.5 times 11 characters is 16 at most, 17 at least.\n const limit = over && max !== undefined ? Math.floor(max * of) : Math.ceil((min ?? 0) * of);\n const bound = over ? 'at most' : 'at least';\n const fallback =\n relative === true\n ? `{limit} ${unit} ${bound} ({${over ? 'max' : 'min'}} times the source's {source}), and this is {count}`\n : `{${over ? 'max' : 'min'}} ${unit} ${bound}, and this is {count}`;\n return [fill(rule.message ?? fallback, { count, max, min, source: relative === true ? of : undefined, limit })];\n },\n };\n }\n case 'capitalization': {\n const style = rule.case;\n if (!['sentence', 'title', 'lower', 'upper'].includes(style)) fail(`has case ${style}: use sentence, title, lower or upper`);\n const message =\n rule.message === undefined\n ? `\"{match}\" is out of ${style} case: change it, or add it to exceptions if it is a name`\n : said(rule.message);\n const exceptions = rule.exceptions ?? [];\n return {\n ...base,\n check: ({ text, config }) => {\n const match = outOfCase(text.primary, style, new Set([...config.lint.properNouns, ...exceptions]));\n return match === undefined ? [] : [{ message: fill(message, { match }), match }];\n },\n };\n }\n case 'conditional': {\n const when = rule.when === undefined ? undefined : pattern(rule.when, 'when', rule.ignoreCase);\n const required = pattern(rule.require, 'require', rule.ignoreCase);\n const message = said(rule.message);\n return {\n ...base,\n check: ({ text }) => {\n for (const v of text.variants) {\n const match = when === undefined ? '' : when.exec(v)?.[0];\n if (match !== undefined && !required.test(v)) return [fill(message, { match })];\n }\n return [];\n },\n };\n }\n default:\n return fail(\n `has type ${String((rule as { type?: unknown }).type)}: use existence, substitution, occurrence, capitalization or conditional, or give it a check`,\n );\n }\n}\n\n/** A reason is a sentence a reviewer can check, not a shrug. */\nfunction reasonProblem(why: string): string | undefined {\n if (why.split(/\\s+/).length < 4) return 'is four words at least: say why the rule is wrong here';\n if (/^(?:intentional|needed|required|ok|fine|false positive|by design|legacy|todo)\\b/i.test(why))\n return 'names the reason, not that there is one';\n return undefined;\n}\n\n/** A locale is one a rule reads when it names its language, or the locale and a region of it. */\nconst readsLocale = (locales: 'all' | string[] | undefined, locale: string, sourceLocale: string) =>\n locales === undefined\n ? locale === sourceLocale\n : locales === 'all' ||\n locales.some((l) => locale.toLowerCase() === l.toLowerCase() || locale.toLowerCase().startsWith(`${l.toLowerCase()}-`));\n\nfunction applies(rule: RuleBase, message: Message, locale: string, sourceLocale: string): boolean {\n const { kind, surface, area, locale: locales } = rule.on ?? {};\n return (\n readsLocale(locales, locale, sourceLocale) &&\n (kind === undefined || (message.kind !== undefined && kind.includes(message.kind))) &&\n (surface === undefined || (message.surface !== undefined && surface.includes(message.surface))) &&\n (area === undefined || area.includes(message.area))\n );\n}\n\n/** A rule's severity for an entry: its area's, where `lint.areas` sets one. */\nexport const severityOf = (config: ResolvedConfig, name: string, message: Message): Severity | undefined =>\n config.lint.areas[message.area]?.[name] ?? config.lint.rules[name]?.severity;\n\ninterface Literal {\n start: number;\n value: string;\n}\n\n/**\n * Where the message's literals are written in its text, each looked for after the one before. A\n * literal escaped in the text (`''`, `\\{`) isn't written as read, so it has no place, and nor does a\n * finding in it.\n */\nfunction literalsIn(ast: MessageFormatElement[], text: string): Literal[] {\n const found: Literal[] = [];\n let from = 0;\n walk(ast, (el) => {\n if (el.type !== TYPE.literal || el.value === '') return;\n // MF2's `.match` is read into arms in another order than they are written, so look from the top too.\n const next = text.indexOf(el.value, from);\n const start = next === -1 ? text.indexOf(el.value) : next;\n if (start === -1) return;\n found.push({ start, value: el.value });\n from = start + el.value.length;\n });\n return found;\n}\n\n/** Every place `match` stands in the literals, in any case, whole where it starts or ends with a letter. */\nfunction placesOf(match: string, literals: Literal[]): { start: number; end: number }[] {\n const body = match\n .replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n .replace(/ /g, '\\\\s+')\n .replace(/'/g, \"['’]\");\n const before = /^[\\p{L}\\p{N}]/u.test(match) ? '(?<![\\\\p{L}\\\\p{N}])' : '';\n const after = /[\\p{L}\\p{N}]$/u.test(match) ? '(?![\\\\p{L}\\\\p{N}])' : '';\n const pattern = new RegExp(`${before}${body}${after}`, 'giu');\n const places = new Map<number, number>();\n for (const { start, value } of literals)\n for (const m of value.matchAll(pattern)) places.set(start + m.index, start + m.index + m[0].length);\n return [...places].sort(([a], [b]) => a - b).map(([start, end]) => ({ start, end }));\n}\n\n/** A fix in the case of what it replaces: \"Colour\" becomes \"Color\". */\nconst inCaseOf = (found: string, fix: string) =>\n /^\\p{Lu}/u.test(found) && /^\\p{Ll}/u.test(fix) ? fix.charAt(0).toUpperCase() + fix.slice(1) : fix;\n\n/** `text` with the edits made, leaving out any that overlaps one before it. */\nexport function applyEdits(text: string, edits: Edit[]): string {\n let out = '';\n let at = 0;\n for (const edit of [...edits].sort((a, b) => a.start - b.start)) {\n if (edit.start < at) continue;\n out += text.slice(at, edit.start) + edit.text;\n at = edit.end;\n }\n return out + text.slice(at);\n}\n\nexport function lint(messages: Message[], config: ResolvedConfig): Finding[] {\n const findings: Finding[] = [];\n const rules = Object.entries(config.lint.rules);\n for (const message of messages) {\n const kind = message.kind === undefined ? undefined : config.kinds[message.kind];\n const source = readings(message.ast);\n const locales = [\n { locale: config.source, ast: message.ast, written: message.text, file: message.file },\n ...[...message.translations].map(([locale, t]) => ({ locale, ast: t.ast, written: t.text, file: t.file })),\n ];\n // An exemption is the entry's, so it holds in every locale, and is still needed if any locale needs it.\n const fired = new Set<string>();\n for (const { locale, ast, written, file } of locales) {\n const text = locale === config.source ? source : readings(ast);\n const context: RuleContext = { message, locale, ast, kind, text, source, config };\n let literals: Literal[] | undefined;\n for (const [name, { rule }] of rules) {\n const severity = severityOf(config, name, message)!;\n if (severity === 'off' || !applies(rule, message, locale, config.source)) continue;\n let said: (string | Report)[];\n try {\n said = rule.check(context);\n } catch (cause) {\n throw new Error(`lint rule ${name} failed on ${message.key} in ${locale}: fix or turn off the rule`, { cause });\n }\n if (said.length === 0) continue;\n fired.add(name);\n if (message.allow.has(name)) continue;\n for (const s of said) {\n const { message: text, match, fix } = typeof s === 'string' ? { message: s } : s;\n const finding: Finding = { key: message.key, file, locale, rule: name, severity, message: text };\n if (match !== undefined && match !== '') {\n literals ??= literalsIn(ast, written);\n const places = placesOf(match, literals);\n if (places.length > 0) finding.at = places[0];\n if (places.length > 0 && fix !== undefined)\n finding.fix = places.map((p) => ({ ...p, text: inCaseOf(written.slice(p.start, p.end), fix) }));\n }\n findings.push(finding);\n }\n }\n }\n for (const [name, why] of message.allow) {\n const at = { key: message.key, file: message.file, locale: config.source, rule: 'allow', severity: 'error' as const };\n const rule = config.lint.rules[name];\n if (rule === undefined) {\n findings.push({ ...at, message: `allow.${name} is not a rule: ${rules.map(([n]) => n).join(', ')}` });\n } else if (severityOf(config, name, message) === 'off') {\n continue;\n } else if (!fired.has(name)) {\n findings.push({ ...at, message: `allow.${name} exempts the entry from a rule it passes: remove it` });\n } else {\n const problem = reasonProblem(why);\n if (problem !== undefined) findings.push({ ...at, message: `allow.${name} ${problem}` });\n }\n }\n }\n return findings;\n}\n","/**\n * The defaults: four kinds of string, the surfaces they sit on, and the word lists of the strict lint preset.\n *\n * The kinds are the four any UI writing guide comes down to. A name identifies, an action says what\n * pressing it does, a description adds what the name cannot carry, a state reports what is true.\n * Each carries a budget and a grammar, which is what makes a mechanical check of the words possible.\n */\nexport type Severity = 'error' | 'warn' | 'off';\n\nexport interface KindRule {\n /** What the kind is for, shown when an editor completes it. */\n doc: string;\n /** The most words it may have. Articles, short prepositions and asides in parentheses are free. */\n maxWords?: number;\n /** The most sentences it may have, and per surface where that differs. */\n maxSentences?: number;\n maxSentencesOn?: Record<string, number>;\n /** Whether it ends with a period: always, never, or only on the surfaces listed. */\n period?: 'always' | 'never' | string[];\n /** Capitalizes only its first word and proper nouns. */\n sentenceCase?: boolean;\n /** Carries no explanation after a dash or colon: `Quick capture`, not `Quick capture: choose an area`. */\n bare?: boolean;\n}\n\nexport const DEFAULT_KINDS: Record<string, KindRule> = {\n name: {\n doc: 'Identifies a thing so it can be found again. One to four words, a noun phrase, no period.',\n maxWords: 4,\n period: 'never',\n sentenceCase: true,\n bare: true,\n },\n action: {\n doc: 'Says what pressing it does. One to three words, verb first, no period.',\n maxWords: 3,\n period: 'never',\n sentenceCase: true,\n },\n description: {\n doc: 'Adds only what the name cannot carry. One sentence, two at most, with a period.',\n maxSentences: 2,\n period: 'always',\n },\n state: {\n doc: 'Reports what is true right now. One sentence, present tense; on an error or empty state, one more saying what to do.',\n maxSentences: 1,\n maxSentencesOn: { error: 2, empty: 2, hint: 2, status: 2 },\n period: ['hint', 'status', 'error', 'empty', 'confirm'],\n },\n};\n\nexport const DEFAULT_SURFACES: Record<string, string> = {\n action: 'The text of a button or a menu entry.',\n aria: 'Reached only by a screen reader, so nothing on screen carries it.',\n choice: 'One option among a set offered together.',\n confirm: 'The question of a confirmation, or the verb that answers it.',\n empty: 'Fills a list or a panel that has nothing in it.',\n error: 'Says what failed.',\n heading: 'Heads a section, group, dialog or list.',\n hint: 'A subordinate line under the thing it qualifies.',\n label: 'Names a control, a field, a section or a destination.',\n placeholder: 'Sits inside an empty field, and goes when typing starts.',\n status: 'Reports what is true right now, on a badge or beside a row.',\n title: 'The title of a page, window or document.',\n toast: 'A notification that comes and goes.',\n tooltip: 'Appears on hover.',\n};\n\n/** The word lists of the strict preset: filler, marketing and reassurance, and American spelling. */\nexport const STRICT_LISTS = {\n banned: [\n {\n words: ['seamless', 'seamlessly', 'effortless', 'effortlessly', 'hassle-free', 'frictionless'],\n why: 'promises a feeling rather than saying what happens',\n },\n {\n words: ['leverage', 'leverages', 'leveraging', 'utilize', 'utilizes', 'utilizing', 'harness', 'take advantage of'],\n why: 'is a long way to say use',\n },\n {\n words: [\n 'delve',\n 'dive into',\n 'deep dive',\n 'embark',\n 'journey',\n 'tapestry',\n 'realm',\n 'landscape',\n 'testament',\n 'synergy',\n 'paradigm',\n 'holistic',\n ],\n why: 'is filler, not a thing on the screen',\n },\n {\n words: [\n 'robust',\n 'powerful',\n 'cutting-edge',\n 'state-of-the-art',\n 'best-in-class',\n 'world-class',\n 'next-generation',\n 'revolutionary',\n 'game-changing',\n ],\n why: 'is marketing: say what it does',\n },\n {\n words: ['streamline', 'streamlined', 'empower', 'unlock', 'unleash', 'elevate', 'supercharge', 'boost', 'enhance', 'enhanced'],\n why: 'claims an improvement without naming it',\n },\n { words: ['meticulous', 'crucial', 'pivotal', 'vital', 'paramount'], why: 'tells the reader how to feel instead of what it is' },\n {\n words: ['comprehensive', 'myriad', 'plethora', 'a variety of', 'a wide range of'],\n why: 'is padding: name the things, or say how many',\n },\n {\n words: ['furthermore', 'moreover', 'additionally', 'in order to', 'please note', 'note that', 'keep in mind', 'rest assured'],\n why: 'is a connective a short string has no room for',\n },\n { words: ['intuitive', 'sleek', 'stunning', 'beautiful', 'delightful', 'magical'], why: 'grades the product instead of describing it' },\n { words: ['simply', 'just', 'easily', 'easy', 'quickly'], why: 'says it is easy, which helps nobody it is not easy for' },\n { words: ['so you can', 'allows you to', 'lets you', 'enables you to', \"don't worry\"], why: 'justifies or reassures: state the fact' },\n { words: ['please', 'oops', 'whoops', 'sorry'], why: 'pleads or apologizes: say what failed and what to do' },\n { words: ['etc', 'and more', 'and so on'], why: 'trails off: name the things or stop' },\n ],\n spelling: {\n colour: 'color',\n colours: 'colors',\n behaviour: 'behavior',\n favourite: 'favorite',\n cancelled: 'canceled',\n cancelling: 'canceling',\n labelled: 'labeled',\n centre: 'center',\n licence: 'license',\n grey: 'gray',\n organise: 'organize',\n recognise: 'recognize',\n customise: 'customize',\n optimise: 'optimize',\n minimise: 'minimize',\n maximise: 'maximize',\n synchronise: 'synchronize',\n authorise: 'authorize',\n initialise: 'initialize',\n analyse: 'analyze',\n catalogue: 'catalog',\n dialogue: 'dialog',\n artefact: 'artifact',\n judgement: 'judgment',\n whilst: 'while',\n amongst: 'among',\n } as Record<string, string>,\n};\n","/**\n * `prosebook/config`: where the catalog lives, what an entry may say about itself, and how strictly\n * its words are checked. Written as `prosebook.config.ts` (or `.js`, `.mjs`, `.json`) at the project root.\n */\nimport { existsSync, readFileSync } from 'node:fs';\nimport { isAbsolute, join, resolve } from 'node:path';\nimport { pathToFileURL } from 'node:url';\n\nimport { compileRule, CORE_RULES, type CheckRule, type CoreRule, type Plugin } from './lint.ts';\nimport { DEFAULT_KINDS, DEFAULT_SURFACES, STRICT_LISTS, type KindRule, type Severity } from './presets.ts';\n\nexport type { KindRule, Severity };\nexport {\n definePlugin,\n HOLE,\n phrase,\n sentences,\n words,\n type CapitalizationRule,\n type CheckRule,\n type ConditionalRule,\n type ExistenceRule,\n type OccurrenceRule,\n type Plugin,\n type Readings,\n type Report,\n type Rule,\n type RuleContext,\n type SubstitutionRule,\n} from './lint.ts';\n\nexport interface WordLists {\n /** Words a string never uses, in groups that say why. */\n banned?: { words: string[]; why: string }[];\n /** A spelling, and the one the product uses instead. */\n spelling?: Record<string, string>;\n /** A near-synonym, and the one word the product uses for that concept. */\n concepts?: Record<string, string>;\n /** Words that keep their capital inside a sentence-case string: product names, platforms. */\n properNouns?: string[];\n /** What a path through menus or settings is written with, spaced: `›` by default, as in Settings › General. */\n pathSeparator?: string;\n}\n\ntype RuleSeverities = Partial<Record<CoreRule, Severity>> & Record<string, Severity>;\n\nexport interface LintConfig extends WordLists {\n /** `recommended` (the default) checks shape; `strict` adds the word lists and rules of a house style guide. */\n extends?: 'recommended' | 'strict' | 'none';\n /** Rules of your own, as `<plugin>/<rule>`. Each takes the severity it gives itself under `extends`. */\n plugins?: Plugin[];\n rules?: RuleSeverities;\n /** Severities for one area's entries (a key's first segment) over `rules`: `{ native: { 'sentence-case': 'off' } }`. */\n areas?: Record<string, RuleSeverities>;\n}\n\nexport interface ProsebookConfig {\n /** The source-language catalog: one `<area>.yaml` per area. */\n catalog?: string;\n /** Translations: `<locale>/<area>.yaml` or `<locale>.yaml`, holding `key: message`. */\n locales?: string;\n /** Where the generated modules go. */\n out?: string;\n /** Records which source text each translation was made from, so a changed source marks it stale. */\n lock?: string;\n /** The locale the catalog is written in. Its code is also the field holding the message. */\n source?: string;\n /**\n * The syntax messages are written in: ICU MessageFormat (1) or Unicode MessageFormat 2. Source and\n * translations alike; `prosebook migrate` rewrites a catalog from one to the other.\n */\n messageFormat?: 1 | 2;\n /** Locales that ship in the main bundle beside the source, rather than loading when first used. */\n bundled?: string[];\n /** A pseudo-locale generated from the source (accented and lengthened) to find layout bugs and hardcoded text. */\n pseudo?: string | false;\n /** What a translation whose source changed since does: still show (`use`) or show the source (`fallback`). */\n stale?: 'use' | 'fallback';\n /** Generated modules as TypeScript or as JavaScript with a `.d.ts` beside the index. */\n language?: 'ts' | 'js';\n /** The extension generated imports name: `.js` suits most TypeScript setups, `.ts` suits Node's type stripping. */\n importExtension?: '.js' | '.ts' | '';\n /** The fields every entry must have. A shorthand `key: message` entry satisfies none of them. */\n require?: ('context' | 'kind' | 'surface')[];\n /** The kinds of string an entry may say it is, with the shape each one is held to. */\n kinds?: Record<string, KindRule>;\n /** Where a string may sit, with what each surface means. */\n surfaces?: Record<string, string>;\n lint?: LintConfig;\n /** Where `prosebook scan` looks for hardcoded text and catalog keys. */\n scan?: {\n dirs?: string[];\n extensions?: string[];\n /** JSX attributes whose literal value a person reads. */\n attributes?: string[];\n };\n}\n\nexport interface ResolvedConfig {\n root: string;\n catalog: string;\n locales: string;\n out: string;\n lock: string;\n source: string;\n messageFormat: 1 | 2;\n bundled: string[];\n pseudo: string | false;\n stale: 'use' | 'fallback';\n language: 'ts' | 'js';\n importExtension: '.js' | '.ts' | '';\n require: ('context' | 'kind' | 'surface')[];\n kinds: Record<string, KindRule>;\n surfaces: Record<string, string>;\n lint: {\n rules: Record<string, { rule: CheckRule; severity: Severity }>;\n areas: Record<string, Record<string, Severity>>;\n } & Required<WordLists>;\n scan: { dirs: string[]; extensions: string[]; attributes: string[] };\n}\n\n/** Typed config, for `prosebook.config.ts`. */\nexport function defineConfig(config: ProsebookConfig): ProsebookConfig {\n return config;\n}\n\nexport const CONFIG_FILES = [\n 'prosebook.config.ts',\n 'prosebook.config.mts',\n 'prosebook.config.js',\n 'prosebook.config.mjs',\n 'prosebook.config.json',\n];\n\n/** Finds and reads the config at `root`, or the defaults when there is none. */\nexport async function loadConfig(root: string, inline?: ProsebookConfig): Promise<ResolvedConfig> {\n if (inline) return resolveConfig(root, inline);\n for (const name of CONFIG_FILES) {\n const path = join(root, name);\n if (!existsSync(path)) continue;\n if (name.endsWith('.json')) return resolveConfig(root, JSON.parse(readFileSync(path, 'utf8')) as ProsebookConfig);\n const mod = (await import(pathToFileURL(path).href)) as { default?: ProsebookConfig };\n return resolveConfig(root, mod.default ?? {});\n }\n return resolveConfig(root, {});\n}\n\nexport function resolveConfig(root: string, config: ProsebookConfig): ResolvedConfig {\n const at = (path: string) => (isAbsolute(path) ? path : resolve(root, path));\n const lint = config.lint ?? {};\n const base = lint.extends ?? 'recommended';\n const strict = base === 'strict';\n const rules = lintRules(lint);\n for (const [area, severities] of Object.entries(lint.areas ?? {})) {\n for (const name of Object.keys(severities))\n if (!(name in rules)) throw new Error(`lint.areas.${area}.${name} is not a rule: name one of ${Object.keys(rules).join(', ')}`);\n }\n return {\n root,\n catalog: at(config.catalog ?? 'copy/catalog'),\n locales: at(config.locales ?? 'copy/locales'),\n out: at(config.out ?? 'src/copy'),\n lock: at(config.lock ?? 'copy/lock.json'),\n source: config.source ?? 'en',\n messageFormat: config.messageFormat ?? 1,\n bundled: config.bundled ?? [],\n pseudo: config.pseudo ?? false,\n stale: config.stale ?? 'use',\n language: config.language ?? 'ts',\n importExtension: config.importExtension ?? '.js',\n require: config.require ?? ['context'],\n kinds: config.kinds ?? DEFAULT_KINDS,\n surfaces: config.surfaces ?? DEFAULT_SURFACES,\n lint: {\n rules,\n areas: lint.areas ?? {},\n banned: [...(strict ? STRICT_LISTS.banned : []), ...(lint.banned ?? [])],\n spelling: { ...(strict ? STRICT_LISTS.spelling : {}), ...lint.spelling },\n concepts: { ...lint.concepts },\n properNouns: lint.properNouns ?? [],\n pathSeparator: lint.pathSeparator ?? '›',\n },\n scan: {\n dirs: (config.scan?.dirs ?? ['src']).map(at),\n extensions: config.scan?.extensions ?? ['.ts', '.tsx', '.js', '.jsx', '.mts', '.mjs'],\n attributes: config.scan?.attributes ?? ['alt', 'title', 'placeholder', 'label', 'aria-label', 'aria-description', 'aria-placeholder'],\n },\n };\n}\n\nfunction lintRules(lint: LintConfig): ResolvedConfig['lint']['rules'] {\n const base = lint.extends ?? 'recommended';\n const all: [string, CheckRule][] = Object.entries(CORE_RULES);\n const seen = new Set<string>();\n for (const plugin of lint.plugins ?? []) {\n if (!/^[a-z][a-z0-9-]*$/i.test(plugin.name))\n throw new Error(`lint.plugins: \"${plugin.name}\" is not a plugin name: use letters, digits and dashes`);\n if (seen.has(plugin.name)) throw new Error(`lint.plugins: \"${plugin.name}\" is added twice: remove one`);\n seen.add(plugin.name);\n for (const [name, rule] of Object.entries(plugin.rules)) {\n const full = `${plugin.name}/${name}`;\n all.push([full, compileRule(full, rule)]);\n }\n }\n const preset = (rule: CheckRule): Severity =>\n base === 'none' ? 'off' : base === 'strict' ? (rule.strict ?? 'error') : (rule.recommended ?? 'off');\n const rules = Object.fromEntries(all.map(([name, rule]) => [name, { rule, severity: lint.rules?.[name] ?? preset(rule) }]));\n for (const name of Object.keys(lint.rules ?? {}))\n if (!(name in rules)) throw new Error(`lint.rules.${name} is not a rule: name one of ${Object.keys(rules).join(', ')}`);\n return rules;\n}\n"],"mappings":";;;;;;;;;AAUA,SAAgB,aAAa,MAAsC;CACjE,MAAM,MAAM,MAAM,MAAM;EAAE,sBAAsB;EAAM,qBAAqB;CAAK,CAAC;CACjF,KAAK,MAAM,OAAO;EAChB,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,OAAO,GAAG,UAAU,YAAY,GAAG,UAAU,QAAQ,GAAG,MAAM,QAAQ,SAAS,GAAG,GAChI,GAAG,MAAM,gBAAgB,UAAU,GAAG,MAAM,OAAO;CACvD,CAAC;CACD,OAAO;AACT;;;;;;AAOA,SAAS,UAAU,SAA6C;CAC9D,MAAM,MAAM,KAAK,KAAK,OAAO,CAAC,CAAE;CAChC,MAAM,OAAO,QAAQ,WAAW,KAAK,EAAE;CACvC,OAAO;EAAE,GAAI,SAAS,KAAK,CAAC,IAAI,WAAW,IAAI;EAAI,MAAM,IAAI,SAAS,MAAM,IAAI,YAAY;CAAU;AACxG;;AAGA,SAAS,WAAW,UAA8C;CAChE,IAAI;EACF,MAAM,KAAK,MAAM,eAAe,SAAS,IAAI,EAAE,sBAAsB,KAAK,CAAC,CAAC,CAAC;EAC7E,OAAO,OAAO,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