glosslint 0.0.1 → 0.1.1

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/dist/index.mjs CHANGED
@@ -1,459 +1,3 @@
1
- import { a as kindOf, c as termKey$1, n as createMatcher, t as check } from "./matcher-Xz4vspsE.mjs";
2
- import { a as toX18nGlossary, c as toJson, i as testCorpus, o as formatFinding, r as printCorpus, s as formatFindings, t as explain } from "./tools-BrdtyK9t.mjs";
3
- import { readFileSync } from "node:fs";
4
- // src/errors.ts
5
- /** A problem in the corpus or the config, with what to change. */
6
- var GlosslintConfigError = class extends Error {
7
- /** A stable code, such as `GLOSSLINT_DUPLICATE_TERM`. */
8
- code;
9
- /** Why the config is wrong. */
10
- why;
11
- /** What to change. */
12
- fix;
13
- /** The term the problem is in, when it is in one. */
14
- term;
15
- constructor(options) {
16
- super(options.term ? `${options.why} (term "${options.term}")` : options.why);
17
- this.name = "GlosslintConfigError";
18
- this.code = options.code;
19
- this.why = options.why;
20
- this.fix = options.fix;
21
- if (options.term !== void 0) this.term = options.term;
22
- }
23
- };
24
- // src/corpus.ts
25
- const INPUT_FIELDS = [
26
- "extends",
27
- "terms",
28
- "allow",
29
- "casing",
30
- "wholeLabel"
31
- ];
32
- const TERM_FIELDS = [
33
- "term",
34
- "description",
35
- "nuance",
36
- "abbr",
37
- "avoid",
38
- "examples",
39
- "links",
40
- "case",
41
- "casing",
42
- "skip",
43
- "forms",
44
- "translations"
45
- ];
46
- const AVOID_FIELDS = ["word", "why"];
47
- const LINK_FIELDS = ["title", "url"];
48
- const EXAMPLE_FIELDS = ["good", "bad"];
49
- const CASE_MODES = [
50
- "exact",
51
- "spelling",
52
- "context"
53
- ];
54
- const SKIPS = ["lower", "upper"];
55
- const CASING_KINDS = [
56
- "label",
57
- "header",
58
- "sentence"
59
- ];
60
- const CASE_STYLES = [
61
- "title",
62
- "sentence",
63
- "lower",
64
- "upper",
65
- "as-written"
66
- ];
67
- /** Stable codes of `GlosslintConfigError`. */
68
- const CONFIG_ERRORS = {
69
- unknownField: "GLOSSLINT_C001",
70
- missingTerm: "GLOSSLINT_C002",
71
- badCase: "GLOSSLINT_C003",
72
- avoidIsTerm: "GLOSSLINT_C004",
73
- duplicateTerm: "GLOSSLINT_C005",
74
- badSkip: "GLOSSLINT_C006",
75
- badType: "GLOSSLINT_C007",
76
- notCorpus: "GLOSSLINT_C008",
77
- badCasing: "GLOSSLINT_C011"
78
- };
79
- function distance(a, b) {
80
- const row = Array.from({ length: b.length + 1 }, (_, index) => index);
81
- for (let i = 1; i <= a.length; i++) {
82
- let diagonal = row[0];
83
- row[0] = i;
84
- for (let j = 1; j <= b.length; j++) {
85
- const above = row[j];
86
- row[j] = Math.min(row[j] + 1, row[j - 1] + 1, diagonal + (a[i - 1] === b[j - 1] ? 0 : 1));
87
- diagonal = above;
88
- }
89
- }
90
- return row[b.length];
91
- }
92
- function nearest(name, fields) {
93
- let best;
94
- let bestDistance = Infinity;
95
- for (const field of fields) {
96
- const d = distance(name.toLowerCase(), field);
97
- if (d < bestDistance) {
98
- best = field;
99
- bestDistance = d;
100
- }
101
- }
102
- return bestDistance <= Math.max(2, Math.floor(name.length / 3)) ? best : void 0;
103
- }
104
- function isRecord(value) {
105
- return typeof value === "object" && value !== null && !Array.isArray(value);
106
- }
107
- function quoteList(values) {
108
- const quoted = values.map((value) => `"${value}"`);
109
- return quoted.length > 1 ? `${quoted.slice(0, -1).join(", ")} or ${quoted.at(-1)}` : quoted[0] ?? "";
110
- }
111
- function checkFields(value, fields, where, fail) {
112
- for (const name of Object.keys(value)) {
113
- if (fields.includes(name)) continue;
114
- const near = nearest(name, fields);
115
- fail(CONFIG_ERRORS.unknownField, `Unknown field "${name}" in ${where}.`, near ? `Rename it to "${near}".` : `Remove it. The fields are ${quoteList(fields)}.`);
116
- }
117
- }
118
- function isStringList(value) {
119
- return Array.isArray(value) && value.every((item) => typeof item === "string" && item.trim() !== "");
120
- }
121
- function checkStringList(value, field, fail) {
122
- if (value !== void 0 && !isStringList(value)) fail(CONFIG_ERRORS.badType, `"${field}" must be a list of non-empty strings.`, `Write it as ["…", "…"].`);
123
- }
124
- function checkLocaleMap(value, field, list, fail) {
125
- if (value === void 0) return;
126
- if (!(isRecord(value) && Object.values(value).every((item) => list ? isStringList(item) : typeof item === "string"))) fail(CONFIG_ERRORS.badType, `"${field}" must map each locale to ${list ? "a list of strings" : "a string"}.`, list ? `Write it as { de: ["…"] }.` : `Write it as { de: "…" }.`);
127
- }
128
- function checkTerm(input, index) {
129
- const name = isRecord(input) && typeof input.term === "string" ? input.term : void 0;
130
- const fail = (code, why, fix) => {
131
- throw new GlosslintConfigError({
132
- code,
133
- why,
134
- fix,
135
- ...name === void 0 ? {} : { term: name }
136
- });
137
- };
138
- if (!isRecord(input)) fail(CONFIG_ERRORS.badType, `Entry ${index + 1} of "terms" is not an object.`, `Write it as { term: "…" }.`);
139
- const term = input;
140
- checkFields(term, TERM_FIELDS, name === void 0 ? `entry ${index + 1} of "terms"` : `term "${name}"`, fail);
141
- if (name === void 0 || termKey$1(name) === "") fail(CONFIG_ERRORS.missingTerm, name === void 0 ? `Entry ${index + 1} of "terms" has no "term".` : `The term "${name}" has no letters or digits.`, `Add the words to use, such as { term: "Dock" }.`);
142
- for (const field of ["description", "nuance"]) if (term[field] !== void 0 && typeof term[field] !== "string") fail(CONFIG_ERRORS.badType, `"${field}" must be a string.`, `Write it as one sentence in quotes.`);
143
- if (term.case !== void 0 && !CASE_MODES.includes(term.case)) fail(CONFIG_ERRORS.badCase, `"case" is ${JSON.stringify(term.case)}.`, `Use ${quoteList(CASE_MODES)}.`);
144
- checkCasing(term.casing, `term "${name}"`, fail);
145
- if (term.skip !== void 0) {
146
- const bad = Array.isArray(term.skip) ? term.skip.find((item) => !SKIPS.includes(item)) : term.skip;
147
- if (!Array.isArray(term.skip) || bad !== void 0) fail(CONFIG_ERRORS.badSkip, `"skip" has ${JSON.stringify(bad)}.`, `Use a list of ${quoteList(SKIPS)}, such as ["lower", "upper"].`);
148
- }
149
- checkStringList(term.abbr, "abbr", fail);
150
- if (term.avoid !== void 0) {
151
- if (!Array.isArray(term.avoid)) fail(CONFIG_ERRORS.badType, `"avoid" must be a list.`, `Write it as ["word", { word: "…", why: "…" }].`);
152
- for (const avoid of term.avoid) {
153
- if (isRecord(avoid)) {
154
- checkFields(avoid, AVOID_FIELDS, `an avoid word of "${name}"`, fail);
155
- if (avoid.why !== void 0 && typeof avoid.why !== "string") fail(CONFIG_ERRORS.badType, `The "why" of an avoid word must be a string.`, `Write the reason in quotes.`);
156
- }
157
- const word = isRecord(avoid) ? avoid.word : avoid;
158
- if (typeof word !== "string" || termKey$1(word) === "") fail(CONFIG_ERRORS.badType, `An avoid word of "${name}" is empty or not a string.`, `Write each one as "word" or { word: "…", why: "…" }.`);
159
- if (word.trim().replace(/\s+/g, " ").toLowerCase() === name.trim().replace(/\s+/g, " ").toLowerCase()) fail(CONFIG_ERRORS.avoidIsTerm, `"${word}" is both the term and one of its avoid words.`, `Remove it from "avoid". To require one casing, set case: "exact".`);
160
- }
161
- }
162
- if (term.examples !== void 0) {
163
- if (!isRecord(term.examples)) fail(CONFIG_ERRORS.badType, `"examples" must be an object.`, `Write it as { good: ["…"], bad: ["…"] }.`);
164
- checkFields(term.examples, EXAMPLE_FIELDS, `the examples of "${name}"`, fail);
165
- checkStringList(term.examples.good, "examples.good", fail);
166
- checkStringList(term.examples.bad, "examples.bad", fail);
167
- }
168
- if (term.links !== void 0) {
169
- if (!Array.isArray(term.links)) fail(CONFIG_ERRORS.badType, `"links" must be a list.`, `Write it as [{ title: "…", url: "https://…" }].`);
170
- for (const link of term.links) {
171
- if (!isRecord(link)) fail(CONFIG_ERRORS.badType, `A link of "${name}" is not an object.`, `Write it as { title: "…", url: "https://…" }.`);
172
- checkFields(link, LINK_FIELDS, `a link of "${name}"`, fail);
173
- if (typeof link.title !== "string" || typeof link.url !== "string") fail(CONFIG_ERRORS.badType, `A link of "${name}" needs a "title" and a "url".`, `Write it as { title: "…", url: "https://…" }.`);
174
- }
175
- }
176
- checkLocaleMap(term.forms, "forms", true, fail);
177
- checkLocaleMap(term.translations, "translations", false, fail);
178
- return term;
179
- }
180
- function checkCasing(value, where, fail) {
181
- if (value === void 0) return;
182
- if (!isRecord(value)) fail(CONFIG_ERRORS.badCasing, `"casing" of ${where} must be an object.`, `Write it as { label: "title", header: "upper", sentence: "sentence" }.`);
183
- for (const [kind, style] of Object.entries(value)) {
184
- if (!CASING_KINDS.includes(kind)) fail(CONFIG_ERRORS.badCasing, `"casing" of ${where} has the kind "${kind}".`, `Use ${quoteList(CASING_KINDS)}.`);
185
- if (!CASE_STYLES.includes(style)) fail(CONFIG_ERRORS.badCasing, `"casing.${kind}" of ${where} is ${JSON.stringify(style)}.`, `Use ${quoteList(CASE_STYLES)}.`);
186
- }
187
- }
188
- function isCorpus(value) {
189
- return isRecord(value) && value.kind === "glosslint.corpus" && Array.isArray(value.terms) && Array.isArray(value.allow);
190
- }
191
- /**
192
- * Sets `key` and moves it to the end, so `terms` lists them from lowest to highest precedence and a term's
193
- * abbreviations and avoid words beat those of the terms before it.
194
- */
195
- function setLast(map, key, term) {
196
- map.delete(key);
197
- map.set(key, term);
198
- }
199
- /** Validates a corpus, merges what it extends, and returns it flat. Throws a `GlosslintConfigError` on a bad term. */
200
- function defineCorpus(input) {
201
- const fail = (code, why, fix) => {
202
- throw new GlosslintConfigError({
203
- code,
204
- why,
205
- fix
206
- });
207
- };
208
- const raw = input;
209
- if (!isRecord(raw)) fail(CONFIG_ERRORS.badType, `defineCorpus takes an object.`, `Pass { extends, terms, allow }.`);
210
- checkFields(raw, INPUT_FIELDS, "the corpus", fail);
211
- if (input.extends !== void 0 && !Array.isArray(input.extends)) fail(CONFIG_ERRORS.badType, `"extends" must be a list of corpora.`, `Write it as [tech, inclusive].`);
212
- if (input.terms !== void 0 && !Array.isArray(input.terms)) fail(CONFIG_ERRORS.badType, `"terms" must be a list.`, `Write it as [{ term: "…" }].`);
213
- checkStringList(input.allow, "allow", fail);
214
- checkCasing(input.casing, "the corpus", fail);
215
- if (input.wholeLabel !== void 0 && typeof input.wholeLabel !== "boolean") fail(CONFIG_ERRORS.badType, `"wholeLabel" must be true or false.`, `Write it as wholeLabel: true.`);
216
- const merged = /* @__PURE__ */ new Map();
217
- const allow = [];
218
- const casing = {};
219
- let wholeLabel;
220
- for (const [index, corpus] of (input.extends ?? []).entries()) {
221
- if (!isCorpus(corpus)) fail(CONFIG_ERRORS.notCorpus, `Entry ${index + 1} of "extends" is not a corpus.`, `Pass a preset, fromGlossaryTable(…) or the result of defineCorpus(…).`);
222
- for (const term of corpus.terms) setLast(merged, termKey$1(term.term), term);
223
- allow.push(...corpus.allow);
224
- Object.assign(casing, corpus.casing);
225
- wholeLabel = corpus.wholeLabel ?? wholeLabel;
226
- }
227
- const own = /* @__PURE__ */ new Map();
228
- for (const [index, raw] of (input.terms ?? []).entries()) {
229
- const term = checkTerm(raw, index);
230
- const key = termKey$1(term.term);
231
- const previous = own.get(key);
232
- if (previous) throw new GlosslintConfigError({
233
- code: CONFIG_ERRORS.duplicateTerm,
234
- why: `"${previous.term}" and "${term.term}" are the same words, so they are one term.`,
235
- fix: `Keep one of them. A spelling to report goes in that term's "avoid" list.`,
236
- term: term.term
237
- });
238
- own.set(key, term);
239
- }
240
- for (const [key, term] of own) setLast(merged, key, term);
241
- allow.push(...input.allow ?? []);
242
- Object.assign(casing, input.casing);
243
- wholeLabel = input.wholeLabel ?? wholeLabel;
244
- return Object.freeze({
245
- kind: "glosslint.corpus",
246
- terms: Object.freeze([...merged.values()]),
247
- allow: Object.freeze(allow),
248
- ...Object.keys(casing).length > 0 ? { casing: Object.freeze(casing) } : {},
249
- ...wholeLabel !== void 0 ? { wholeLabel } : {}
250
- });
251
- }
252
- // src/table.ts
253
- const defaults = {
254
- term: ["use", "term"],
255
- avoid: ["avoid"],
256
- notes: ["notes"],
257
- description: ["description", "meaning"],
258
- links: ["links"]
259
- };
260
- const delimiterRow = /^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)*\|?\s*$/;
261
- const fence = /^\s*(`{3,}|~{3,})/;
262
- const markdownLink = /\[([^\]]*)\]\(\s*<?([^)\s>]+)>?(?:\s+"[^"]*")?\s*\)|<(https?:\/\/[^>\s]+)>/g;
263
- const empty = /^[-–—]?$/;
264
- /**
265
- * Reads the first Markdown table with a `Use` or `Term` column as a corpus.
266
- *
267
- * - `Avoid` becomes the first term's avoid list; `word (reason)` gives the reason.
268
- * - `Notes` becomes `nuance`, and `Description` or `Meaning` becomes `description`.
269
- * - Top-level commas split a cell, and `Term (ABBR, ABBR2)` gives the term and its `abbr`.
270
- * - A term with an inner capital or all capitals, or whose notes say lowercase, is `exact`.
271
- * - Markdown links in any cell, and URLs in a `Links` column, become `links`.
272
- */
273
- function fromGlossaryTable(path, columns = {}) {
274
- const table = findTable(readFileSync(path, "utf8").split(/\r?\n/), columns);
275
- if (!table) throw new GlosslintConfigError({
276
- code: "GLOSSLINT_NO_GLOSSARY_TABLE",
277
- why: `No Markdown table in ${String(path)} has a ${columns.term ?? "Use or Term"} column.`,
278
- fix: "Add a table whose header names the term column, or pass its name in `columns.term`."
279
- });
280
- const terms = /* @__PURE__ */ new Map();
281
- for (const cells of table.rows) {
282
- const cell = (role) => {
283
- const index = table.index[role];
284
- return index === void 0 ? "" : (cells[index] ?? "").trim();
285
- };
286
- const links = [];
287
- const take = (role) => extractLinks(cell(role), links);
288
- for (const url of take("links").match(/https?:\/\/[^\s,<>)]+/g) ?? []) if (!links.some((link) => link.url === url)) links.push({
289
- title: url,
290
- url
291
- });
292
- const termCell = take("term");
293
- const description = clean(take("description"));
294
- const nuance = clean(take("notes"));
295
- const avoid = splitTopLevel(take("avoid")).map(toAvoid);
296
- const exactByNotes = /\blower[\s-]?case\b/i.test(nuance);
297
- splitTopLevel(termCell).forEach((part, i) => {
298
- const { name, abbr, extra } = parseName(part);
299
- if (!name) return;
300
- const term = { term: name };
301
- if (description) term.description = description;
302
- const termNuance = [extra, nuance].filter(Boolean).join(" ");
303
- if (termNuance) term.nuance = termNuance;
304
- if (abbr.length) term.abbr = abbr;
305
- if (i === 0 && avoid.length) term.avoid = avoid;
306
- if (links.length) term.links = dedupeLinks(links);
307
- if (exactByNotes || isExactName(name)) term.case = "exact";
308
- const key = termKey(name);
309
- if (terms.has(key)) throw new GlosslintConfigError({
310
- code: "GLOSSLINT_DUPLICATE_TERM",
311
- why: `The glossary table in ${String(path)} lists the term twice.`,
312
- fix: "Merge the two rows into one.",
313
- term: name
314
- });
315
- terms.set(key, term);
316
- });
317
- }
318
- return {
319
- kind: "glosslint.corpus",
320
- terms: [...terms.values()],
321
- allow: []
322
- };
323
- }
324
- function findTable(lines, columns) {
325
- let inFence;
326
- for (let i = 0; i < lines.length - 1; i++) {
327
- const line = lines[i] ?? "";
328
- const open = fence.exec(line)?.[1];
329
- if (open) {
330
- if (!inFence) inFence = open;
331
- else if (open[0] === inFence[0] && open.length >= inFence.length) inFence = void 0;
332
- continue;
333
- }
334
- if (inFence || !line.includes("|") || !delimiterRow.test(lines[i + 1] ?? "")) continue;
335
- const header = splitRow(line).map((cell) => clean(cell).toLowerCase());
336
- const index = {};
337
- for (const role of Object.keys(defaults)) {
338
- const found = (columns[role] ? [columns[role].toLowerCase()] : defaults[role]).map((name) => header.indexOf(name)).find((at) => at >= 0);
339
- if (found !== void 0) index[role] = found;
340
- }
341
- if (index.term === void 0) continue;
342
- const rows = [];
343
- for (let j = i + 2; j < lines.length; j++) {
344
- const row = lines[j] ?? "";
345
- if (!row.trim() || !row.includes("|")) break;
346
- rows.push(splitRow(row));
347
- }
348
- return {
349
- index,
350
- rows
351
- };
352
- }
353
- }
354
- /** Splits a table row on pipes that are not escaped, and unescapes `\|`. */
355
- function splitRow(line) {
356
- const cells = [];
357
- let current = "";
358
- for (let i = 0; i < line.length; i++) {
359
- const char = line[i];
360
- if (char === "\\" && line[i + 1] === "|") {
361
- current += "|";
362
- i++;
363
- } else if (char === "|") {
364
- cells.push(current);
365
- current = "";
366
- } else current += char;
367
- }
368
- cells.push(current);
369
- if (line.trimStart().startsWith("|")) cells.shift();
370
- if (line.trimEnd().endsWith("|") && !line.trimEnd().endsWith("\\|")) cells.pop();
371
- return cells.map((cell) => cell.trim());
372
- }
373
- /** Splits on commas outside parentheses and inline code. */
374
- function splitTopLevel(text) {
375
- const parts = [];
376
- let depth = 0;
377
- let inCode = false;
378
- let current = "";
379
- for (const char of text) {
380
- if (char === "`") inCode = !inCode;
381
- else if (!inCode && char === "(") depth++;
382
- else if (!inCode && char === ")") depth = Math.max(0, depth - 1);
383
- if (char === "," && depth === 0 && !inCode) {
384
- parts.push(current);
385
- current = "";
386
- } else current += char;
387
- }
388
- parts.push(current);
389
- return parts.map(clean).filter((part) => !empty.test(part));
390
- }
391
- /** Replaces Markdown links with their text, collecting them into `links`. */
392
- function extractLinks(text, links) {
393
- return text.replace(markdownLink, (_, title, url, bare) => {
394
- const href = url ?? bare;
395
- const label = clean(title ?? href);
396
- links.push({
397
- title: label || href,
398
- url: href
399
- });
400
- return title ?? href;
401
- });
402
- }
403
- /** Drops inline-code backticks and bold or italic markers around the whole cell. */
404
- function clean(text) {
405
- let out = text.trim().replace(/`([^`]*)`/g, "$1");
406
- for (const mark of [
407
- "**",
408
- "__",
409
- "*",
410
- "_"
411
- ]) if (out.length > 2 * mark.length && out.startsWith(mark) && out.endsWith(mark)) out = out.slice(mark.length, -mark.length).trim();
412
- return empty.test(out) ? "" : out;
413
- }
414
- /**
415
- * `Day Pass (DP, D)` gives the name and its abbreviations: single words that are one capital or hold a
416
- * capital after their first letter. Other parentheses, such as `(kiosk)` or `(Kiosk)`, are a note that goes to `extra` and from there to `nuance`.
417
- */
418
- function parseName(part) {
419
- const match = /^(.*?)\s*\(([^()]*)\)$/.exec(part);
420
- if (!match) return {
421
- name: part,
422
- abbr: [],
423
- extra: ""
424
- };
425
- const name = clean(match[1] ?? "");
426
- const inner = splitTopLevel(match[2] ?? "");
427
- if (inner.length && inner.every((item) => /^\S+$/.test(item) && /^.+\p{Lu}|^\p{Lu}[^\p{L}\p{N}]*$/u.test(item))) return {
428
- name,
429
- abbr: inner,
430
- extra: ""
431
- };
432
- return {
433
- name,
434
- abbr: [],
435
- extra: sentence(clean(match[2] ?? ""))
436
- };
437
- }
438
- function toAvoid(part) {
439
- const match = /^(.*?)\s*\(([^()]+)\)$/.exec(part);
440
- if (!match?.[1]) return part;
441
- return {
442
- word: clean(match[1]),
443
- why: sentence(clean(match[2] ?? ""))
444
- };
445
- }
446
- function sentence(text) {
447
- return /[.!?]$/.test(text) ? text : `${text}.`;
448
- }
449
- /** A capital right after a letter: an inner capital, like `eBike`, or all capitals, like `SOS`. */
450
- function isExactName(name) {
451
- return /\p{L}\p{Lu}/u.test(name) || name.length > 1 && /\p{Lu}/u.test(name) && !/\p{Ll}/u.test(name);
452
- }
453
- function termKey(name) {
454
- return name.toLowerCase().replace(/[\s._-]+/g, "");
455
- }
456
- function dedupeLinks(links) {
457
- return links.filter((link, i) => links.findIndex((other) => other.url === link.url) === i);
458
- }
459
- export { CONFIG_ERRORS, GlosslintConfigError, check, createMatcher, defineCorpus, explain, formatFinding, formatFindings, fromGlossaryTable, kindOf, printCorpus, testCorpus, toJson, toX18nGlossary };
1
+ import { _ as defineCorpus, a as explain, c as testCorpus, d as createMatcher, g as CONFIG_ERRORS, h as kindOf, i as readGlossary, l as toX18nGlossary, r as fromGlossary, s as printCorpus, u as check, x as GlosslintConfigError } from "./glossary-ztPpmozR.mjs";
2
+ import { n as formatFindings, r as toJson, t as formatFinding } from "./format-E5eFHoQT.mjs";
3
+ export { CONFIG_ERRORS, GlosslintConfigError, check, createMatcher, defineCorpus, explain, formatFinding, formatFindings, fromGlossary, kindOf, printCorpus, readGlossary, testCorpus, toJson, toX18nGlossary };
@@ -0,0 +1,26 @@
1
+ /** `settings.glosslint` in `.oxlintrc.json`. */
2
+ export interface GlosslintOxlintSettings {
3
+ /** The glossary file to read instead of `.agents/glossary.md`, resolved from Oxlint's working folder. */
4
+ glossary?: string;
5
+ /** Callees whose first argument is never checked, added to `t`, `$t`, `te` and `tm`. */
6
+ ignoreCallees?: string[];
7
+ /** Report avoid words in declared names too. */
8
+ identifierAvoid?: boolean;
9
+ }
10
+ interface OxlintRule {
11
+ meta?: object;
12
+ create(context: never): object;
13
+ }
14
+ /** An Oxlint JS plugin, typed without Oxlint or ESLint so neither is needed for the types. */
15
+ export interface GlosslintOxlintPlugin {
16
+ meta: {
17
+ name: "glosslint";
18
+ };
19
+ rules: Record<"term" | "avoid" | "comment" | "identifier", OxlintRule>;
20
+ }
21
+ /**
22
+ * glosslint's rules as an Oxlint JS plugin: `"jsPlugins": ["glosslint/oxlint"]`. The rules read
23
+ * `.agents/glossary.md`, or `settings.glosslint.glossary`, from Oxlint's working folder on the first file.
24
+ */
25
+ declare const plugin: GlosslintOxlintPlugin;
26
+ export { plugin as default };
@@ -0,0 +1,33 @@
1
+ import { n as DEFAULT_IGNORE_CALLEES, t as createRules } from "./rules-D9Jd07u1.mjs";
2
+ import { r as fromGlossary } from "./glossary-ztPpmozR.mjs";
3
+ import { resolve } from "node:path";
4
+ // src/oxlint.ts
5
+ const corpora = /* @__PURE__ */ new Map();
6
+ function corpusAt(file) {
7
+ let corpus = corpora.get(file);
8
+ if (!corpus) {
9
+ corpus = fromGlossary(file);
10
+ corpora.set(file, corpus);
11
+ }
12
+ return corpus;
13
+ }
14
+ function bind(context) {
15
+ const { cwd, settings } = context;
16
+ const options = settings.glosslint ?? {};
17
+ return {
18
+ corpus: corpusAt(resolve(cwd, options.glossary ?? ".agents/glossary.md")),
19
+ settings: {
20
+ ignoreCallees: options.ignoreCallees ?? DEFAULT_IGNORE_CALLEES,
21
+ identifierAvoid: options.identifierAvoid ?? false
22
+ }
23
+ };
24
+ }
25
+ /**
26
+ * glosslint's rules as an Oxlint JS plugin: `"jsPlugins": ["glosslint/oxlint"]`. The rules read
27
+ * `.agents/glossary.md`, or `settings.glosslint.glossary`, from Oxlint's working folder on the first file.
28
+ */
29
+ const plugin = {
30
+ meta: { name: "glosslint" },
31
+ rules: createRules(bind)
32
+ };
33
+ export { plugin as default };
@@ -1,3 +1,3 @@
1
- import { c as Corpus } from "../types-CBQGgzID.mjs";
1
+ import { c as Corpus } from "../types-Bbp_cYfZ.mjs";
2
2
  declare const corpus: Corpus;
3
3
  export { corpus as default };