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 +41 -32
- package/dist/cli.js +3 -3
- package/dist/{config-CxVMn19f.js → config-D--RITk2.js} +76 -14
- package/dist/config-D--RITk2.js.map +1 -0
- package/dist/{config-CF7HziDa.d.ts → config-_4HfnJQu.d.ts} +25 -6
- package/dist/config-_4HfnJQu.d.ts.map +1 -0
- package/dist/config.d.ts +1 -1
- package/dist/config.js +1 -1
- package/dist/{sarif-PkPvsB07.js → sarif-CI8HOokm.js} +3 -3
- package/dist/{sarif-PkPvsB07.js.map → sarif-CI8HOokm.js.map} +1 -1
- package/dist/{scan-B0tZ7y-D.js → scan-Ch2BfIUD.js} +178 -64
- package/dist/scan-Ch2BfIUD.js.map +1 -0
- package/dist/tools.d.ts +28 -2
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +4 -4
- package/dist/vite.d.ts +13 -4
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +47 -21
- package/dist/vite.js.map +1 -1
- package/package.json +1 -1
- package/src/tools/compile.ts +14 -3
- package/src/tools/config.ts +19 -3
- package/src/tools/generate.ts +30 -32
- package/src/tools/icu.ts +30 -1
- package/src/tools/index.ts +14 -1
- package/src/tools/lint.ts +49 -12
- package/src/tools/scan.ts +134 -4
- package/src/vite.ts +62 -18
- package/dist/config-CF7HziDa.d.ts.map +0 -1
- package/dist/config-CxVMn19f.js.map +0 -1
- package/dist/scan-B0tZ7y-D.js.map +0 -1
package/src/tools/scan.ts
CHANGED
|
@@ -81,10 +81,8 @@ export function looksLikeCode(text: string): boolean {
|
|
|
81
81
|
const NON_PROSE_ELEMENTS = new Set(['code', 'pre', 'kbd', 'samp', 'script', 'style', 'svg', 'path']);
|
|
82
82
|
const LETTER = /\p{L}/u;
|
|
83
83
|
|
|
84
|
-
/**
|
|
85
|
-
|
|
86
|
-
const { program } = parseSync(file, code);
|
|
87
|
-
const found: Hardcoded[] = [];
|
|
84
|
+
/** Offsets in `code` as lines and columns, and whether a line is marked `prosebook-ignore`, on it or the line above. */
|
|
85
|
+
function lineIndex(code: string) {
|
|
88
86
|
const lines = code.split('\n');
|
|
89
87
|
const lineStarts: number[] = [];
|
|
90
88
|
let offset = 0;
|
|
@@ -104,6 +102,14 @@ export function hardcodedText(file: string, code: string, attributes: string[]):
|
|
|
104
102
|
};
|
|
105
103
|
const ignored = (line: number) =>
|
|
106
104
|
(lines[line - 1] ?? '').includes('prosebook-ignore') || (lines[line - 2] ?? '').includes('prosebook-ignore');
|
|
105
|
+
return { position, ignored };
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** Literal text in JSX that a person reads, where it should be a catalog entry. */
|
|
109
|
+
export function hardcodedText(file: string, code: string, attributes: string[]): Hardcoded[] {
|
|
110
|
+
const { program } = parseSync(file, code);
|
|
111
|
+
const found: Hardcoded[] = [];
|
|
112
|
+
const { position, ignored } = lineIndex(code);
|
|
107
113
|
const report = (node: Node, text: string, where: string) => {
|
|
108
114
|
const trimmed = text.replace(/\s+/g, ' ').trim();
|
|
109
115
|
if (!LETTER.test(trimmed) || looksLikeCode(trimmed)) return;
|
|
@@ -171,3 +177,127 @@ export function scan(dirs: string[], extensions: string[], attributes: string[],
|
|
|
171
177
|
}
|
|
172
178
|
return { hardcoded, refs, files: files.length };
|
|
173
179
|
}
|
|
180
|
+
|
|
181
|
+
/** A copy's methods that take a key first. */
|
|
182
|
+
export const READERS = new Set(['t', 'rich']);
|
|
183
|
+
|
|
184
|
+
export interface UnseenRead {
|
|
185
|
+
file: string;
|
|
186
|
+
line: number;
|
|
187
|
+
column: number;
|
|
188
|
+
/** The read as written, on one line. */
|
|
189
|
+
code: string;
|
|
190
|
+
/** What it calls: a reader, the name it was imported by, or `Text`. */
|
|
191
|
+
name: string;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export interface Reads {
|
|
195
|
+
/** Reads whose key a build can't see, in calls that may be to a copy's `t` or `rich`. */
|
|
196
|
+
unseen: UnseenRead[];
|
|
197
|
+
/** Names a copy's readers are bound to here, as in `const { rich: tRich } = copy`. */
|
|
198
|
+
aliases: Set<string>;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const PREFIX = /^[a-z0-9][\w-]*(?:\.[\w-]+)*\.$/;
|
|
202
|
+
const WRAPPERS = new Set(['ParenthesizedExpression', 'TSAsExpression', 'TSSatisfiesExpression', 'TSNonNullExpression', 'TSTypeAssertion']);
|
|
203
|
+
|
|
204
|
+
/** Whether `keyRefs` finds every key an expression can be: a literal, or a template or sum after a key prefix. */
|
|
205
|
+
function keySeen(node: Node | undefined): boolean {
|
|
206
|
+
if (node === undefined) return false;
|
|
207
|
+
if (WRAPPERS.has(node.type)) return keySeen(node.expression as Node);
|
|
208
|
+
switch (node.type) {
|
|
209
|
+
case 'Literal':
|
|
210
|
+
return typeof node.value === 'string';
|
|
211
|
+
case 'TemplateLiteral': {
|
|
212
|
+
const [head] = node.quasis as { value: { cooked: string | null } }[];
|
|
213
|
+
return (node.expressions as Node[]).length === 0 || PREFIX.test(head?.value.cooked ?? '');
|
|
214
|
+
}
|
|
215
|
+
case 'BinaryExpression': {
|
|
216
|
+
const left = node.left as Node;
|
|
217
|
+
return node.operator === '+' && left.type === 'Literal' && typeof left.value === 'string' && PREFIX.test(left.value);
|
|
218
|
+
}
|
|
219
|
+
case 'ConditionalExpression':
|
|
220
|
+
return keySeen(node.consequent as Node) && keySeen(node.alternate as Node);
|
|
221
|
+
case 'LogicalExpression':
|
|
222
|
+
return keySeen(node.left as Node) && keySeen(node.right as Node);
|
|
223
|
+
default:
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
const nameOf = (node: Node | undefined): string | undefined =>
|
|
229
|
+
node?.type === 'Identifier' || node?.type === 'JSXIdentifier'
|
|
230
|
+
? (node.name as string)
|
|
231
|
+
: node?.type === 'Literal'
|
|
232
|
+
? String(node.value)
|
|
233
|
+
: undefined;
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* The reads in a module whose key a pruned build can't see, as in `t(item.key)` or `<Text id={id} />`:
|
|
237
|
+
* the build would leave the message out, and the key would show in its place. A build has no types,
|
|
238
|
+
* so readers are known by name: `t` and `rich` called alone or as methods, and any name imported here,
|
|
239
|
+
* which may be bound to one elsewhere (`aliases`); the caller keeps those whose name turns out to be a
|
|
240
|
+
* reader. `<Text>` counts where it is imported from `prosebook/react`. Lines marked `prosebook-ignore`
|
|
241
|
+
* are skipped.
|
|
242
|
+
*/
|
|
243
|
+
export function unseenReads(file: string, code: string): Reads {
|
|
244
|
+
const { program } = parseSync(file, code);
|
|
245
|
+
const { position, ignored } = lineIndex(code);
|
|
246
|
+
const unseen: UnseenRead[] = [];
|
|
247
|
+
const aliases = new Set<string>();
|
|
248
|
+
/** Local name to the name it was imported by. */
|
|
249
|
+
const imported = new Map<string, string>();
|
|
250
|
+
const texts = new Set<string>();
|
|
251
|
+
for (const statement of (program as unknown as Node).body as Node[]) {
|
|
252
|
+
if (statement.type !== 'ImportDeclaration') continue;
|
|
253
|
+
for (const s of statement.specifiers as Node[]) {
|
|
254
|
+
const name = s.type === 'ImportSpecifier' ? nameOf(s.imported as Node) : undefined;
|
|
255
|
+
const local = nameOf(s.local as Node);
|
|
256
|
+
if (name === undefined || local === undefined) continue;
|
|
257
|
+
if (name === 'Text' && (statement.source as Node).value === 'prosebook/react') texts.add(local);
|
|
258
|
+
else imported.set(local, name);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
const report = (node: Node, name: string) => {
|
|
262
|
+
const at = position(node.start);
|
|
263
|
+
if (ignored(at.line)) return;
|
|
264
|
+
const text = code.slice(node.start, node.end).replace(/\s+/g, ' ');
|
|
265
|
+
unseen.push({ file, ...at, name, code: text.length > 80 ? `${text.slice(0, 77)}...` : text });
|
|
266
|
+
};
|
|
267
|
+
// Calls by a plain name, kept until every alias in the module is known.
|
|
268
|
+
const calls: [Node, string][] = [];
|
|
269
|
+
const visit = (node: Node) => {
|
|
270
|
+
if (node.type === 'ObjectPattern') {
|
|
271
|
+
for (const p of node.properties as Node[]) {
|
|
272
|
+
if (p.type === 'Property' && READERS.has(nameOf(p.key as Node) ?? '') && (p.value as Node).type === 'Identifier')
|
|
273
|
+
aliases.add(nameOf(p.value as Node)!);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
if (node.type === 'CallExpression' && !keySeen((node.arguments as Node[])[0])) {
|
|
277
|
+
const callee = node.callee as Node;
|
|
278
|
+
if (callee.type === 'Identifier') calls.push([node, callee.name as string]);
|
|
279
|
+
else if (callee.type === 'MemberExpression' && !callee.computed && READERS.has(nameOf(callee.property as Node) ?? ''))
|
|
280
|
+
report(node, nameOf(callee.property as Node)!);
|
|
281
|
+
}
|
|
282
|
+
if (node.type === 'JSXOpeningElement' && texts.has(nameOf(node.name as Node) ?? '')) {
|
|
283
|
+
const id = (node.attributes as Node[]).find((a) => a.type === 'JSXAttribute' && nameOf(a.name as Node) === 'id');
|
|
284
|
+
const value = id?.value as Node | null | undefined;
|
|
285
|
+
if (value !== null && value !== undefined && !keySeen(value.type === 'JSXExpressionContainer' ? (value.expression as Node) : value))
|
|
286
|
+
report(node, 'Text');
|
|
287
|
+
}
|
|
288
|
+
for (const value of Object.values(node)) {
|
|
289
|
+
if (Array.isArray(value)) {
|
|
290
|
+
for (const child of value) if (isNode(child)) visit(child);
|
|
291
|
+
} else if (isNode(value)) {
|
|
292
|
+
visit(value);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
visit(program as unknown as Node);
|
|
297
|
+
for (const [node, local] of calls) {
|
|
298
|
+
if (READERS.has(local) || aliases.has(local)) report(node, local);
|
|
299
|
+
else if (imported.has(local)) report(node, imported.get(local)!);
|
|
300
|
+
}
|
|
301
|
+
unseen.sort((a, b) => (a.line === b.line ? a.column - b.column : a.line - b.line));
|
|
302
|
+
return { unseen, aliases };
|
|
303
|
+
}
|
package/src/vite.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* the server opens the entry it asks for through Vite's own `/__open-in-editor`, so the editor is
|
|
14
14
|
* whichever Vite already launches.
|
|
15
15
|
*/
|
|
16
|
-
import { resolve } from 'node:path';
|
|
16
|
+
import { relative, resolve } from 'node:path';
|
|
17
17
|
import { fileURLToPath } from 'node:url';
|
|
18
18
|
|
|
19
19
|
import type { Plugin } from 'vite';
|
|
@@ -23,13 +23,22 @@ import { compileLocale, localeExpression } from './tools/compile.ts';
|
|
|
23
23
|
import { loadConfig, type ProsebookConfig, type ResolvedConfig } from './tools/config.ts';
|
|
24
24
|
import { editEntry, readEntry, type EntryEdit } from './tools/entry.ts';
|
|
25
25
|
import { generate, type Generated } from './tools/generate.ts';
|
|
26
|
-
import { isReferenced, keyRefs, type KeyRefs } from './tools/scan.ts';
|
|
26
|
+
import { isReferenced, keyRefs, READERS, unseenReads, type KeyRefs, type Reads } from './tools/scan.ts';
|
|
27
27
|
|
|
28
28
|
export interface ProsebookPluginOptions {
|
|
29
|
-
/** The config, inline. Without it, `prosebook.config.*` at
|
|
29
|
+
/** The config, inline. Without it, `prosebook.config.*` at `root` is read. */
|
|
30
30
|
config?: ProsebookConfig;
|
|
31
|
-
/**
|
|
32
|
-
|
|
31
|
+
/**
|
|
32
|
+
* The folder the config's paths resolve from, and where its file is found: the Vite root when
|
|
33
|
+
* unset. Apps that share one catalog name its folder, so each build generates the same files.
|
|
34
|
+
*/
|
|
35
|
+
root?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Ship only the messages the code names. `strict`, the default, also fails the build on a read
|
|
38
|
+
* whose key it can't see, such as `t(item.key)`, which would show the key where its message was
|
|
39
|
+
* pruned. `loose` prunes without that check; `false` ships every message.
|
|
40
|
+
*/
|
|
41
|
+
prune?: 'strict' | 'loose' | false;
|
|
33
42
|
/** Keys a build always keeps, exactly or as `prefix.*`: for keys built at runtime from data. */
|
|
34
43
|
keep?: string[];
|
|
35
44
|
/** In dev, Alt-click a string on the page to open its entry in the editor. On by default. */
|
|
@@ -37,6 +46,7 @@ export interface ProsebookPluginOptions {
|
|
|
37
46
|
}
|
|
38
47
|
|
|
39
48
|
const PLACEHOLDER = /__PROSEBOOK_LOCALE_(\d+)__/g;
|
|
49
|
+
const SCRIPT = /\.[cm]?[jt]sx?$/;
|
|
40
50
|
const DEV_ID = '\0prosebook/dev';
|
|
41
51
|
|
|
42
52
|
const hotLocale = (locale: string) => `
|
|
@@ -61,13 +71,18 @@ const normalize = (path: string) => resolve(path).replaceAll('\\', '/');
|
|
|
61
71
|
|
|
62
72
|
// Beside this module: the source when run from source, the built file in dist.
|
|
63
73
|
const inspectorPath = normalize(fileURLToPath(new URL(`./inspector${import.meta.url.endsWith('.ts') ? '.ts' : '.js'}`, import.meta.url)));
|
|
74
|
+
// prosebook's own modules, which read keys handed to them: `<Text>` calls `rich(props.id)`.
|
|
75
|
+
const ownDir = normalize(fileURLToPath(new URL('.', import.meta.url)));
|
|
64
76
|
|
|
65
77
|
export function prosebook(options: ProsebookPluginOptions = {}): Plugin {
|
|
66
78
|
let config: ResolvedConfig;
|
|
67
79
|
let generated: Generated | undefined;
|
|
68
80
|
let building = false;
|
|
69
81
|
let base = '/';
|
|
82
|
+
let viteRoot = '';
|
|
70
83
|
let refs: KeyRefs = { exact: new Set(), prefixes: new Set() };
|
|
84
|
+
const reads = new Map<string, Reads>();
|
|
85
|
+
const prune = options.prune ?? 'strict';
|
|
71
86
|
const placeholders: string[] = [];
|
|
72
87
|
const shipped = { total: 0, kept: 0 };
|
|
73
88
|
|
|
@@ -96,7 +111,8 @@ export function prosebook(options: ProsebookPluginOptions = {}): Plugin {
|
|
|
96
111
|
async configResolved(resolved) {
|
|
97
112
|
building = resolved.command === 'build';
|
|
98
113
|
base = resolved.base;
|
|
99
|
-
|
|
114
|
+
viteRoot = resolved.root;
|
|
115
|
+
config = await loadConfig(options.root === undefined ? resolved.root : resolve(resolved.root, options.root), options.config);
|
|
100
116
|
},
|
|
101
117
|
|
|
102
118
|
// First in <head>, so the hot hooks are there before any copy is created.
|
|
@@ -116,6 +132,7 @@ export function prosebook(options: ProsebookPluginOptions = {}): Plugin {
|
|
|
116
132
|
this.error(describe(e));
|
|
117
133
|
}
|
|
118
134
|
refs = { exact: new Set(), prefixes: new Set() };
|
|
135
|
+
reads.clear();
|
|
119
136
|
placeholders.length = 0;
|
|
120
137
|
shipped.total = shipped.kept = 0;
|
|
121
138
|
},
|
|
@@ -128,7 +145,9 @@ export function prosebook(options: ProsebookPluginOptions = {}): Plugin {
|
|
|
128
145
|
if (!path.endsWith('.yaml') || !dirs.some((d) => path.startsWith(`${d}/`))) return;
|
|
129
146
|
try {
|
|
130
147
|
generated = generate(config);
|
|
131
|
-
server.config.logger.info(`prosebook: regenerated from ${
|
|
148
|
+
server.config.logger.info(`prosebook: regenerated from ${relative(config.root, path).replaceAll('\\', '/')}`, {
|
|
149
|
+
timestamp: true,
|
|
150
|
+
});
|
|
132
151
|
} catch (e) {
|
|
133
152
|
server.config.logger.error(describe(e), { timestamp: true });
|
|
134
153
|
server.ws.send({ type: 'error', err: { message: describe(e), stack: '', plugin: 'prosebook' } });
|
|
@@ -207,23 +226,48 @@ export function prosebook(options: ProsebookPluginOptions = {}): Plugin {
|
|
|
207
226
|
if (options.inspect === false) return hot;
|
|
208
227
|
return `import { install } from ${JSON.stringify(inspectorPath)};\n${hot}install(${JSON.stringify({ base })});\n`;
|
|
209
228
|
}
|
|
210
|
-
if (!building ||
|
|
229
|
+
if (!building || prune === false || generated === undefined) return null;
|
|
211
230
|
const locale = localeOf(id);
|
|
212
231
|
if (locale === undefined) return null;
|
|
213
232
|
placeholders.push(locale);
|
|
214
233
|
return `export default __PROSEBOOK_LOCALE_${placeholders.length - 1}__;\n`;
|
|
215
234
|
},
|
|
216
235
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
236
|
+
// Before other plugins, so a read is found in the source as written: `<Text id>` still JSX, and
|
|
237
|
+
// the line it is reported at, and its `prosebook-ignore`, where the author wrote them.
|
|
238
|
+
transform: {
|
|
239
|
+
order: 'pre',
|
|
240
|
+
handler(code, id) {
|
|
241
|
+
if (!building) {
|
|
242
|
+
const locale = localeOf(id);
|
|
243
|
+
if (locale !== undefined) return { code: code + hotLocale(locale), map: null };
|
|
244
|
+
return isIndex(id) ? { code: code + HOT_INDEX, map: null } : null;
|
|
245
|
+
}
|
|
246
|
+
if (prune === false || id.includes('/node_modules/') || id.startsWith('\0')) return null;
|
|
247
|
+
// The index's `Messages` type names every key, and is read here before its types are stripped.
|
|
248
|
+
if (localeOf(id) !== undefined || isIndex(id)) return null;
|
|
249
|
+
keyRefs(code, refs);
|
|
250
|
+
const path = id.split('?', 1)[0]!;
|
|
251
|
+
if (prune === 'strict' && SCRIPT.test(path) && !normalize(path).startsWith(`${ownDir}/`)) reads.set(id, unseenReads(path, code));
|
|
252
|
+
return null;
|
|
253
|
+
},
|
|
254
|
+
},
|
|
255
|
+
|
|
256
|
+
buildEnd(error) {
|
|
257
|
+
if (error !== undefined || prune !== 'strict') return;
|
|
258
|
+
const live = new Set(this.getModuleIds());
|
|
259
|
+
const all = [...reads].filter(([id]) => live.has(id)).map(([, r]) => r);
|
|
260
|
+
const readers = new Set([...READERS, ...all.flatMap((r) => [...r.aliases])]);
|
|
261
|
+
const unseen = all.flatMap((r) => r.unseen).filter((u) => u.name === 'Text' || readers.has(u.name));
|
|
262
|
+
if (unseen.length === 0) return;
|
|
263
|
+
const at = (file: string) => relative(viteRoot, file).replaceAll('\\', '/');
|
|
264
|
+
this.error(
|
|
265
|
+
[
|
|
266
|
+
`${unseen.length} read(s) whose key the build can't see, so their messages would be pruned and the key shown instead:`,
|
|
267
|
+
...unseen.map((u) => ` ${at(u.file)}:${u.line}:${u.column} ${u.code}`),
|
|
268
|
+
'Write each key at the read, as a literal or `area.${id}`; or, where every key it reads is written elsewhere or listed in `keep`, mark the line `prosebook-ignore`. `prune: "loose"` turns this check off.',
|
|
269
|
+
].join('\n'),
|
|
270
|
+
);
|
|
227
271
|
},
|
|
228
272
|
|
|
229
273
|
renderChunk(code) {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config-CF7HziDa.d.ts","names":[],"sources":["../src/tools/catalog.ts","../src/tools/presets.ts","../src/tools/lint.ts","../src/tools/config.ts"],"mappings":";UAgBiB;EACf;EACA,KAAK;EACL;;UAGe;EACf;;EAEA;EACA;EACA;EACA;;EAEA;;EAEA,SAAS;;EAET;;EAEA,OAAO;;EAEP;;EAEA;;EAEA;EACA,KAAK;;EAEL,MAAM;;EAEN,YAAY;EACZ;;EAEA,cAAc,YAAY;;UAGX;EACf;;EAEA;;EAEA;EACA;;;iBAIc,QAAQ,SAAS;UAIhB;EACf,UAAU;;EAEV;EACA,UAAU;;cAGC,qBAAqB;WACvB,UAAU;EAEnB,YAAY,UAAU;;;;;;cAUX,aAAW;;;;;;iBASR,YAAY,QAAQ,gBAAgB,UAAU,8BAA8B;UAoS3E;;EAEf;;EAEA;;EAEA;;;;;;iBAOc,cAAc,QAAQ,gBAAgB,SAAS,SAAS,kBAAkB;;iBA6C1E,UAAU,SAAS;;;;;;;;KCvbvB;UAEK;;EAEf;;EAEA;;EAEA;EACA,iBAAiB;;EAEjB;;EAEA;;EAEA;;cAGW,eAAe,eAAe;cA2B9B,kBAAkB;;cAkBlB;;;;;EAuFN,UAAA;;;UC9IU;;EAEf,SAAS;;EAET;;EAEA,KAAK;;EAEL,MAAM;;EAEN,MAAM;;EAEN,QAAQ;EACR,QAAQ;;UAGA;;EAER;;EAEA,cAAc;;EAEd,SAAS;;;;;;EAMT;IAAO;IAAiB;IAAoB;;;;UAI7B,kBAAkB;;EAEjC,MAAM,SAAS,wBAAwB;;;UAIxB;EACf;;EAEA;;EAEA;;;UAIe;EACf;EACA;EACA;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e;EACtB,UAAU;EACV;IAAQ,OAAO;MAAiB,MAAM;MAAW,UAAU;;MAAgB,SAAS;EACpF;IAAQ;IAAgB;IAAsB;;;;iBAIhC,aAAa,QAAQ,kBAAkB;cAI1C;;iBASS,WAAW,cAAc,SAAS,kBAAkB,QAAQ;iBAYlE,cAAc,cAAc,QAAQ,kBAAkB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config-CxVMn19f.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 return parse(text, { shouldParseSkeletons: true, requiresOtherClause: true });\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 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, or on these surfaces; an entry that says neither is skipped. Only\n * the source unless `locale` says otherwise, since most writing rules are written for one language:\n * `all` reads every locale, and a list those languages and their regions (`de` covers `de-CH`).\n */\n on?: { kind?: string[]; surface?: 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/** The singular of an English plural noun, or nothing where it doesn't look like one. */\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 (/[^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. Which stop is the arm's own: a\n * question in `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 return text.replaceAll(HOLE, '').trim() === '' ? undefined : 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\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 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, 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 );\n}\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, severity }] of rules) {\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 (rule.severity === '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}\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?: Partial<Record<CoreRule, Severity>> & Record<string, Severity>;\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: { rules: Record<string, { rule: CheckRule; severity: Severity }> } & 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 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: lintRules(lint),\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 },\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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