glosslint 0.1.2 → 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 +2 -2
- package/dist/cli.d.mts +10 -13
- package/dist/cli.mjs +42 -56
- package/dist/eslint.mjs +3 -3
- package/dist/{format-DSSwOlXH.mjs → format-BVGriClu.mjs} +1 -1
- package/dist/{glossary-CWqmN9Bg.mjs → glossary-DvBgwOUw.mjs} +1 -1
- package/dist/{glossary-text-C09ByS5j.mjs → glossary-text-DB0WoR1i.mjs} +21 -7
- package/dist/index.mjs +3 -3
- package/dist/oxlint.mjs +3 -3
- package/dist/{rules-CjMuomuR.mjs → rules-RPbpYGR5.mjs} +1 -1
- package/dist/x18n.mjs +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@ Write your product's terms in `.agents/glossary.md`. This excerpt comes from the
|
|
|
27
27
|
|
|
28
28
|
The words the rider app and the help center use.
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
Presets: tech, inclusive
|
|
31
31
|
Allow: check out our, roof rack
|
|
32
32
|
|
|
33
33
|
## Dock
|
|
@@ -49,7 +49,7 @@ Links:
|
|
|
49
49
|
Case: context
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
-
`eBike` gets `Case: exact` automatically because of its inner capital. `Day Pass (DP)` sets the abbreviation `DP` and enforces Title Case in labels and lowercase in sentences. Every runner reads `.agents/glossary.md` by default
|
|
52
|
+
`eBike` gets `Case: exact` automatically because of its inner capital. `Day Pass (DP)` sets the abbreviation `DP` and enforces Title Case in labels and lowercase in sentences. Every runner reads `.agents/glossary.md` by default. When you need fields such as `skip`, `forms` or `translations`, build a corpus with `defineCorpus` and pass it to the runner: `glosslint({ corpus })` in ESLint or x18n, `--corpus <module>` in the CLI.
|
|
53
53
|
|
|
54
54
|
## Install
|
|
55
55
|
|
package/dist/cli.d.mts
CHANGED
|
@@ -15,7 +15,7 @@ export declare function checkFileText(matcher: Matcher, text: string, file: stri
|
|
|
15
15
|
}): CliFinding[];
|
|
16
16
|
/** Where a command reads and writes, so tests can run commands without a process. */
|
|
17
17
|
export interface CliIo {
|
|
18
|
-
/** The folder paths and the
|
|
18
|
+
/** The folder paths and the corpus module are resolved from. */
|
|
19
19
|
cwd: string;
|
|
20
20
|
stdout: (text: string) => void;
|
|
21
21
|
stderr: (text: string) => void;
|
|
@@ -24,9 +24,9 @@ export interface CliIo {
|
|
|
24
24
|
}
|
|
25
25
|
/** Options every command takes. */
|
|
26
26
|
export interface CommandOptions {
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
/** The glossary file, read when there is no `
|
|
27
|
+
/** A module whose default export is a corpus, such as one that calls `defineCorpus`. */
|
|
28
|
+
corpus?: string;
|
|
29
|
+
/** The glossary file, read when there is no `corpus`. Default: `.agents/glossary.md` in `cwd`. */
|
|
30
30
|
glossary?: string;
|
|
31
31
|
/** Color the output. Default: `io.color`. */
|
|
32
32
|
color?: boolean;
|
|
@@ -71,25 +71,22 @@ export interface DoctorReport {
|
|
|
71
71
|
}
|
|
72
72
|
/** Codes of the errors the CLI prints itself, next to the corpus's `GLOSSLINT_C00x`. */
|
|
73
73
|
export declare const CLI_ERRORS: {
|
|
74
|
-
readonly
|
|
75
|
-
readonly
|
|
74
|
+
readonly noCorpus: "GLOSSLINT_C009";
|
|
75
|
+
readonly loadModule: "GLOSSLINT_C010";
|
|
76
76
|
readonly notCorpus: "GLOSSLINT_C008";
|
|
77
77
|
readonly usage: "GLOSSLINT_USAGE";
|
|
78
78
|
readonly failed: "GLOSSLINT_ERROR";
|
|
79
79
|
};
|
|
80
|
-
/** What `loadCorpus` read: a
|
|
80
|
+
/** What `loadCorpus` read: a corpus module, or a glossary file it then never checks. */
|
|
81
81
|
export interface LoadedCorpus {
|
|
82
82
|
corpus: Corpus;
|
|
83
83
|
/** The absolute path of the file read. */
|
|
84
84
|
file: string;
|
|
85
|
-
from: "
|
|
85
|
+
from: "module" | "glossary";
|
|
86
86
|
}
|
|
87
|
-
/**
|
|
88
|
-
* Finds the corpus: `config`, else `glossary`, else `glosslint.config.{ts,mts,js,mjs}` in `cwd`, else
|
|
89
|
-
* `.agents/glossary.md` in `cwd`.
|
|
90
|
-
*/
|
|
87
|
+
/** Finds the corpus: the `corpus` module, else the `glossary` file, else `.agents/glossary.md` in `cwd`. */
|
|
91
88
|
export declare function loadCorpus(cwd: string, options?: {
|
|
92
|
-
|
|
89
|
+
corpus?: string;
|
|
93
90
|
glossary?: string;
|
|
94
91
|
}): Promise<LoadedCorpus>;
|
|
95
92
|
/** The files `check` reads: named files as they are, folders by extension, and glob patterns. */
|
package/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as readGlossary, b as isCodeShape, c as printCorpus, f as createMatcher, g as kindOf, h as isTextName, l as testCorpus, n as DEFAULT_GLOSSARY, o as explain, r as GLOSSARY_PROBLEMS, s as explainMatches } from "./glossary-text-
|
|
3
|
-
import { i as toJson, r as formatFindings, t as formatDoctor } from "./format-
|
|
2
|
+
import { a as readGlossary, b as isCodeShape, c as printCorpus, f as createMatcher, g as kindOf, h as isTextName, l as testCorpus, n as DEFAULT_GLOSSARY, o as explain, r as GLOSSARY_PROBLEMS, s as explainMatches } from "./glossary-text-DB0WoR1i.mjs";
|
|
3
|
+
import { i as toJson, r as formatFindings, t as formatDoctor } from "./format-BVGriClu.mjs";
|
|
4
4
|
import { existsSync, readFileSync, realpathSync, statSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { extname, relative, resolve, sep } from "node:path";
|
|
6
6
|
import { pathToFileURL } from "node:url";
|
|
@@ -8,7 +8,7 @@ import process from "node:process";
|
|
|
8
8
|
import { cac } from "cac";
|
|
9
9
|
import { escapePath, glob, isDynamicPattern } from "tinyglobby";
|
|
10
10
|
// package.json
|
|
11
|
-
var version = "0.
|
|
11
|
+
var version = "0.2.0";
|
|
12
12
|
// src/comark.ts
|
|
13
13
|
const OPENER = /^[ \t]*(:{2,})[A-Za-z][\w-]*/;
|
|
14
14
|
const BARE = /^[ \t]*:[A-Za-z][\w-]*[ \t]*\r?$/;
|
|
@@ -483,18 +483,12 @@ function toCliFinding(finding, at) {
|
|
|
483
483
|
// src/cli.ts
|
|
484
484
|
/** Codes of the errors the CLI prints itself, next to the corpus's `GLOSSLINT_C00x`. */
|
|
485
485
|
const CLI_ERRORS = {
|
|
486
|
-
|
|
487
|
-
|
|
486
|
+
noCorpus: "GLOSSLINT_C009",
|
|
487
|
+
loadModule: "GLOSSLINT_C010",
|
|
488
488
|
notCorpus: "GLOSSLINT_C008",
|
|
489
489
|
usage: "GLOSSLINT_USAGE",
|
|
490
490
|
failed: "GLOSSLINT_ERROR"
|
|
491
491
|
};
|
|
492
|
-
const CONFIG_FILES = [
|
|
493
|
-
"glosslint.config.ts",
|
|
494
|
-
"glosslint.config.mts",
|
|
495
|
-
"glosslint.config.js",
|
|
496
|
-
"glosslint.config.mjs"
|
|
497
|
-
];
|
|
498
492
|
const DEFAULT_EXTENSIONS = [
|
|
499
493
|
"md",
|
|
500
494
|
"mdx",
|
|
@@ -505,20 +499,20 @@ const MARKDOWN = /* @__PURE__ */ new Set([
|
|
|
505
499
|
".mdx",
|
|
506
500
|
".markdown"
|
|
507
501
|
]);
|
|
508
|
-
/** An error the CLI prints as a tree and exits 2 on: a bad
|
|
502
|
+
/** An error the CLI prints as a tree and exits 2 on: a bad corpus or a bad command line. */
|
|
509
503
|
var CliError = class extends Error {
|
|
510
504
|
code;
|
|
511
505
|
why;
|
|
512
506
|
fix;
|
|
513
507
|
term;
|
|
514
|
-
|
|
508
|
+
corpus;
|
|
515
509
|
constructor(options) {
|
|
516
510
|
super(options.why);
|
|
517
511
|
this.code = options.code;
|
|
518
512
|
this.why = options.why;
|
|
519
513
|
this.fix = options.fix;
|
|
520
514
|
if (options.term !== void 0) this.term = options.term;
|
|
521
|
-
if (options.
|
|
515
|
+
if (options.corpus !== void 0) this.corpus = options.corpus;
|
|
522
516
|
}
|
|
523
517
|
};
|
|
524
518
|
function isConfigError(error) {
|
|
@@ -532,40 +526,31 @@ const toPosix = (path) => path.split(sep).join("/");
|
|
|
532
526
|
function displayPath(cwd, file) {
|
|
533
527
|
return toPosix(relative(cwd, file)) || ".";
|
|
534
528
|
}
|
|
535
|
-
/**
|
|
536
|
-
* Finds the corpus: `config`, else `glossary`, else `glosslint.config.{ts,mts,js,mjs}` in `cwd`, else
|
|
537
|
-
* `.agents/glossary.md` in `cwd`.
|
|
538
|
-
*/
|
|
529
|
+
/** Finds the corpus: the `corpus` module, else the `glossary` file, else `.agents/glossary.md` in `cwd`. */
|
|
539
530
|
async function loadCorpus(cwd, options = {}) {
|
|
540
|
-
const {
|
|
541
|
-
if (
|
|
542
|
-
if (
|
|
543
|
-
|
|
544
|
-
const found = CONFIG_FILES.map((name) => resolve(cwd, name)).find((path) => existsSync(path));
|
|
545
|
-
if (found) return importConfig(cwd, found);
|
|
546
|
-
if (existsSync(resolve(cwd, ".agents/glossary.md"))) return loadGlossary(cwd, DEFAULT_GLOSSARY, false);
|
|
547
|
-
throw new CliError({
|
|
548
|
-
code: CLI_ERRORS.noConfig,
|
|
549
|
-
why: `No ${DEFAULT_GLOSSARY} and no glosslint.config.ts, .mts, .js or .mjs in the current folder.`,
|
|
550
|
-
fix: `Create ${DEFAULT_GLOSSARY} with \`# Glossary\` and a \`## Term\` section per term, or pass --glossary <path> or --config <path>.`
|
|
551
|
-
});
|
|
531
|
+
const { corpus, glossary } = options;
|
|
532
|
+
if (corpus !== void 0 && glossary !== void 0) throw usage("--corpus and --glossary both name the corpus.", "Pass one of them: --glossary for a glossary file, --corpus for a module that exports a corpus.");
|
|
533
|
+
if (corpus !== void 0) return importCorpus(cwd, corpus);
|
|
534
|
+
return loadGlossary(cwd, glossary ?? ".agents/glossary.md", glossary !== void 0);
|
|
552
535
|
}
|
|
553
536
|
/** `G004` to `G008`: the problems only a person can fix, which leave no corpus. */
|
|
554
537
|
function leavesNoCorpus(problem) {
|
|
555
538
|
return !problem.fixable && problem.code !== GLOSSARY_PROBLEMS.failingExample;
|
|
556
539
|
}
|
|
557
|
-
|
|
540
|
+
/** `takesCorpus`: whether the command also takes `--corpus`, which `doctor` does not. */
|
|
541
|
+
function missingGlossary(cwd, file, given, takesCorpus) {
|
|
558
542
|
const shown = displayPath(cwd, file);
|
|
543
|
+
const pass = takesCorpus ? "--glossary <path> or --corpus <module>" : "--glossary <path>";
|
|
559
544
|
return new CliError({
|
|
560
|
-
code: CLI_ERRORS.
|
|
545
|
+
code: CLI_ERRORS.noCorpus,
|
|
561
546
|
why: given ? `The glossary "${shown}" does not exist.` : `No glossary at ${shown}.`,
|
|
562
|
-
fix: given ? "Check the path given to --glossary." : `Create ${shown} with \`# Glossary\` and a \`## Term\` section per term, or pass
|
|
547
|
+
fix: given ? "Check the path given to --glossary." : `Create ${shown} with \`# Glossary\` and a \`## Term\` section per term, or pass ${pass}.`
|
|
563
548
|
});
|
|
564
549
|
}
|
|
565
550
|
/** Reads a glossary file as a corpus, or throws its first problem that leaves no corpus. */
|
|
566
551
|
function loadGlossary(cwd, path, given) {
|
|
567
552
|
const file = resolve(cwd, path);
|
|
568
|
-
if (!existsSync(file)) throw missingGlossary(cwd, file, given);
|
|
553
|
+
if (!existsSync(file)) throw missingGlossary(cwd, file, given, true);
|
|
569
554
|
const { problems, corpus } = readGlossary(readFileSync(file, "utf8"));
|
|
570
555
|
if (corpus) return {
|
|
571
556
|
corpus,
|
|
@@ -583,36 +568,37 @@ function loadGlossary(cwd, path, given) {
|
|
|
583
568
|
...first.term === void 0 ? {} : { term: first.term }
|
|
584
569
|
});
|
|
585
570
|
}
|
|
586
|
-
/** Imports
|
|
587
|
-
async function
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
571
|
+
/** Imports the module given to `--corpus` and returns its default export, which must be a corpus. */
|
|
572
|
+
async function importCorpus(cwd, given) {
|
|
573
|
+
const file = resolve(cwd, given);
|
|
574
|
+
if (!existsSync(file)) throw new CliError({
|
|
575
|
+
code: CLI_ERRORS.noCorpus,
|
|
576
|
+
why: `The corpus module "${given}" does not exist.`,
|
|
577
|
+
fix: "Check the path given to --corpus."
|
|
592
578
|
});
|
|
593
579
|
const shown = displayPath(cwd, file);
|
|
594
580
|
let loaded;
|
|
595
581
|
try {
|
|
596
582
|
loaded = await import(pathToFileURL(file).href);
|
|
597
583
|
} catch (error) {
|
|
598
|
-
if (isConfigError(error)) throw Object.assign(error, {
|
|
584
|
+
if (isConfigError(error)) throw Object.assign(error, { corpus: shown });
|
|
599
585
|
throw new CliError({
|
|
600
|
-
code: CLI_ERRORS.
|
|
586
|
+
code: CLI_ERRORS.loadModule,
|
|
601
587
|
why: `Could not load ${shown}: ${error instanceof Error ? error.message : String(error)}`,
|
|
602
|
-
fix: "Fix the error in the
|
|
603
|
-
|
|
588
|
+
fix: "Fix the error in the module, then run glosslint again.",
|
|
589
|
+
corpus: shown
|
|
604
590
|
});
|
|
605
591
|
}
|
|
606
592
|
if (!isCorpus(loaded.default)) throw new CliError({
|
|
607
593
|
code: CLI_ERRORS.notCorpus,
|
|
608
594
|
why: `${shown} does not export a corpus as its default export.`,
|
|
609
|
-
fix: "End the
|
|
610
|
-
|
|
595
|
+
fix: "End the module with `export default defineCorpus({ … })`.",
|
|
596
|
+
corpus: shown
|
|
611
597
|
});
|
|
612
598
|
return {
|
|
613
599
|
corpus: loaded.default,
|
|
614
600
|
file,
|
|
615
|
-
from: "
|
|
601
|
+
from: "module"
|
|
616
602
|
};
|
|
617
603
|
}
|
|
618
604
|
function usage(why, fix) {
|
|
@@ -755,7 +741,7 @@ async function runDoctor(options, io) {
|
|
|
755
741
|
const format = options.format ?? "text";
|
|
756
742
|
if (format !== "text" && format !== "json") throw usage(`--format is "${format}".`, "Use --format text or --format json.");
|
|
757
743
|
const file = resolve(io.cwd, options.glossary ?? ".agents/glossary.md");
|
|
758
|
-
if (!existsSync(file)) throw missingGlossary(io.cwd, file, options.glossary !== void 0);
|
|
744
|
+
if (!existsSync(file)) throw missingGlossary(io.cwd, file, options.glossary !== void 0, false);
|
|
759
745
|
const shown = displayPath(io.cwd, file);
|
|
760
746
|
let result = readGlossary(readFileSync(file, "utf8"));
|
|
761
747
|
let fixed = 0;
|
|
@@ -794,12 +780,12 @@ async function runDoctor(options, io) {
|
|
|
794
780
|
io.stdout(`${text}\n`);
|
|
795
781
|
return problems.length > 0 ? 1 : 0;
|
|
796
782
|
}
|
|
797
|
-
/** Prints a
|
|
783
|
+
/** Prints a corpus or usage error as a tree on stderr. */
|
|
798
784
|
function printError(error, io, color) {
|
|
799
785
|
const branches = [];
|
|
800
786
|
if (error.term && !error.why.includes(`"${error.term}"`)) branches.push(["term", error.term]);
|
|
801
787
|
branches.push(["fix", error.fix]);
|
|
802
|
-
if (error.
|
|
788
|
+
if (error.corpus) branches.push(["corpus", error.corpus]);
|
|
803
789
|
const lines = branches.map(([label, text], index) => {
|
|
804
790
|
const branch = index === branches.length - 1 ? "╰▶" : "├▶";
|
|
805
791
|
return `${paint(color, "2", branch)} ${paint(color, "1", `${label}:`)} ${text}`;
|
|
@@ -819,19 +805,19 @@ async function main(argv, io = defaultIo()) {
|
|
|
819
805
|
const cli = cac("glosslint");
|
|
820
806
|
let run;
|
|
821
807
|
let color = io.color ?? false;
|
|
822
|
-
const
|
|
823
|
-
const glossaryOption = `Glossary file
|
|
808
|
+
const corpusOption = "Module whose default export is a corpus, instead of a glossary file";
|
|
809
|
+
const glossaryOption = `Glossary file (default: ${DEFAULT_GLOSSARY})`;
|
|
824
810
|
const colorOption = "Color the output (default: when writing to a terminal)";
|
|
825
|
-
cli.command("[...paths]", "Check Markdown and text files against the corpus").alias("check").option("--glossary <path>", glossaryOption).option("--
|
|
811
|
+
cli.command("[...paths]", "Check Markdown and text files against the corpus").alias("check").option("--glossary <path>", glossaryOption).option("--corpus <module>", corpusOption).option("--format <format>", "Output format: text or json", { default: "text" }).option("--ext <list>", "Extensions read in folders, comma-separated (default: md,mdx,txt)").option("--color", colorOption).action((paths, options) => {
|
|
826
812
|
run = () => runCheck(paths, options, io);
|
|
827
813
|
});
|
|
828
|
-
cli.command("test", "Check every term's good and bad examples").option("--glossary <path>", glossaryOption).option("--
|
|
814
|
+
cli.command("test", "Check every term's good and bad examples").option("--glossary <path>", glossaryOption).option("--corpus <module>", corpusOption).option("--color", colorOption).action((options) => {
|
|
829
815
|
run = () => runTest(options, io);
|
|
830
816
|
});
|
|
831
|
-
cli.command("print", "Print the corpus as a Markdown glossary or JSON").option("--glossary <path>", glossaryOption).option("--
|
|
817
|
+
cli.command("print", "Print the corpus as a Markdown glossary or JSON").option("--glossary <path>", glossaryOption).option("--corpus <module>", corpusOption).option("--format <format>", "Output format: md or json", { default: "md" }).action((options) => {
|
|
832
818
|
run = () => runPrint(options, io);
|
|
833
819
|
});
|
|
834
|
-
cli.command("explain <query>", "Show what the corpus says about a word or phrase").option("--glossary <path>", glossaryOption).option("--
|
|
820
|
+
cli.command("explain <query>", "Show what the corpus says about a word or phrase").option("--glossary <path>", glossaryOption).option("--corpus <module>", corpusOption).action((query, options) => {
|
|
835
821
|
run = () => runExplain(String(query), options, io);
|
|
836
822
|
});
|
|
837
823
|
cli.command("doctor", "Report the glossary file's problems, and fix the ones it can with --fix").option("--glossary <path>", `Glossary file (default: ${DEFAULT_GLOSSARY})`).option("--fix", "Rewrite the file in canonical form, unless that would drop text").option("--format <format>", "Output format: text or json", { default: "text" }).option("--color", colorOption).action((options) => {
|
package/dist/eslint.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as GlosslintConfigError, _ as CONFIG_ERRORS } from "./glossary-text-
|
|
2
|
-
import { n as DEFAULT_IGNORE_CALLEES, t as createRules } from "./rules-
|
|
3
|
-
import { t as fromGlossary } from "./glossary-
|
|
1
|
+
import { S as GlosslintConfigError, _ as CONFIG_ERRORS } from "./glossary-text-DB0WoR1i.mjs";
|
|
2
|
+
import { n as DEFAULT_IGNORE_CALLEES, t as createRules } from "./rules-RPbpYGR5.mjs";
|
|
3
|
+
import { t as fromGlossary } from "./glossary-DvBgwOUw.mjs";
|
|
4
4
|
// src/eslint.ts
|
|
5
5
|
/**
|
|
6
6
|
* ESLint flat configs that run glosslint's rules: `...glosslint()`. The corpus comes from `corpus`, else
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as GlosslintConfigError, _ as CONFIG_ERRORS, i as parseGlossary, n as DEFAULT_GLOSSARY, t as BLOCKING } from "./glossary-text-
|
|
1
|
+
import { S as GlosslintConfigError, _ as CONFIG_ERRORS, i as parseGlossary, n as DEFAULT_GLOSSARY, t as BLOCKING } from "./glossary-text-DB0WoR1i.mjs";
|
|
2
2
|
import { existsSync, readFileSync } from "node:fs";
|
|
3
3
|
import { isAbsolute, relative, resolve } from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
@@ -444,6 +444,7 @@ function byName(name, text) {
|
|
|
444
444
|
const words = splitWords(name ?? "").map((word) => HEADING_TAG.test(word) ? "heading" : word.toLowerCase().replace(/\d+$/, ""));
|
|
445
445
|
const last = words.at(-1) ?? "";
|
|
446
446
|
const header = words.some((word) => HEADER_WORD.test(word));
|
|
447
|
+
if (SENTENCE_WORD.test(last)) return "sentence";
|
|
447
448
|
if ((header || words.some((word) => LABEL_WORD.test(word)) || last === "name") && !endsSentence && splitWords(trimmed).length <= 7) return header ? "header" : "label";
|
|
448
449
|
if (words.some((word) => SENTENCE_WORD.test(word)) || endsSentence) return "sentence";
|
|
449
450
|
return "unknown";
|
|
@@ -1248,7 +1249,7 @@ const BLOCKING = /* @__PURE__ */ new Set([
|
|
|
1248
1249
|
const DEFAULT_GLOSSARY = ".agents/glossary.md";
|
|
1249
1250
|
const CORPUS_FIELDS = [
|
|
1250
1251
|
{
|
|
1251
|
-
name: "
|
|
1252
|
+
name: "Presets",
|
|
1252
1253
|
kind: "list",
|
|
1253
1254
|
comma: true
|
|
1254
1255
|
},
|
|
@@ -1296,9 +1297,15 @@ const TERM_FIELDS = [
|
|
|
1296
1297
|
{
|
|
1297
1298
|
name: "Case",
|
|
1298
1299
|
kind: "value"
|
|
1300
|
+
},
|
|
1301
|
+
{
|
|
1302
|
+
name: "Casing",
|
|
1303
|
+
kind: "list",
|
|
1304
|
+
comma: true
|
|
1299
1305
|
}
|
|
1300
1306
|
];
|
|
1301
1307
|
const ALIASES = {
|
|
1308
|
+
extends: "Presets",
|
|
1302
1309
|
description: "What",
|
|
1303
1310
|
meaning: "What",
|
|
1304
1311
|
notes: "How",
|
|
@@ -1703,7 +1710,7 @@ var Reader = class {
|
|
|
1703
1710
|
for (const item of node.items) {
|
|
1704
1711
|
const text = itemText(item);
|
|
1705
1712
|
if (text === "") bad(item.line, `An item of ${name} is empty.`, "Write the item, or remove its line.");
|
|
1706
|
-
else if (name === "
|
|
1713
|
+
else if (name === "Presets" && !Object.hasOwn(PRESETS, text)) bad(item.line, `"${text}" is not a preset.`, `Use ${quoteList(Object.keys(PRESETS))}.`);
|
|
1707
1714
|
else if (name === "Casing" && !CASING.test(text)) bad(item.line, `"${text}" is not a casing.`, "Write a kind (label, header or sentence) and a style (title, sentence, lower, upper or as-written), such as `label sentence`.");
|
|
1708
1715
|
else if (name === "Avoid" && termKey(parseAvoid(text).word) === "") bad(item.line, `"${text}" has no word to avoid.`, "Write it as `word` or `word: reason`.");
|
|
1709
1716
|
else if (name === "Links" && !LINK.test(text)) {
|
|
@@ -1782,21 +1789,28 @@ function buildTerm(node) {
|
|
|
1782
1789
|
}] : [];
|
|
1783
1790
|
});
|
|
1784
1791
|
if (links.length) term.links = links;
|
|
1792
|
+
const casing = parseCasing(items("Casing"));
|
|
1793
|
+
if (Object.keys(casing).length) term.casing = casing;
|
|
1785
1794
|
const mode = field("Case")?.value;
|
|
1786
1795
|
if (mode) term.case = mode;
|
|
1787
|
-
else if (isExactName(node.name)) term.case = "exact";
|
|
1796
|
+
else if (!term.casing && isExactName(node.name)) term.case = "exact";
|
|
1788
1797
|
return term;
|
|
1789
1798
|
}
|
|
1790
|
-
|
|
1791
|
-
|
|
1799
|
+
/** `label sentence, sentence as-written` as a `Casing`. */
|
|
1800
|
+
function parseCasing(pairs) {
|
|
1792
1801
|
const casing = {};
|
|
1793
|
-
for (const pair of
|
|
1802
|
+
for (const pair of pairs) {
|
|
1794
1803
|
const [, kind, style] = CASING.exec(pair);
|
|
1795
1804
|
casing[kind] = style;
|
|
1796
1805
|
}
|
|
1806
|
+
return casing;
|
|
1807
|
+
}
|
|
1808
|
+
function buildCorpus(doc, terms) {
|
|
1809
|
+
const items = (name) => doc.corpus.get(name)?.items.map(itemText).filter(Boolean) ?? [];
|
|
1810
|
+
const casing = parseCasing(items("Casing"));
|
|
1797
1811
|
const allow = items("Allow");
|
|
1798
1812
|
return defineCorpus({
|
|
1799
|
-
extends: items("
|
|
1813
|
+
extends: items("Presets").map((name) => PRESETS[name]),
|
|
1800
1814
|
terms,
|
|
1801
1815
|
...allow.length ? { allow } : {},
|
|
1802
1816
|
...Object.keys(casing).length ? { casing } : {}
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as GlosslintConfigError, _ as CONFIG_ERRORS, a as readGlossary, c as printCorpus, d as check, f as createMatcher, g as kindOf, l as testCorpus, o as explain, u as toX18nGlossary, v as defineCorpus } from "./glossary-text-
|
|
2
|
-
import { i as toJson, n as formatFinding, r as formatFindings } from "./format-
|
|
3
|
-
import { t as fromGlossary } from "./glossary-
|
|
1
|
+
import { S as GlosslintConfigError, _ as CONFIG_ERRORS, a as readGlossary, c as printCorpus, d as check, f as createMatcher, g as kindOf, l as testCorpus, o as explain, u as toX18nGlossary, v as defineCorpus } from "./glossary-text-DB0WoR1i.mjs";
|
|
2
|
+
import { i as toJson, n as formatFinding, r as formatFindings } from "./format-BVGriClu.mjs";
|
|
3
|
+
import { t as fromGlossary } from "./glossary-DvBgwOUw.mjs";
|
|
4
4
|
export { CONFIG_ERRORS, GlosslintConfigError, check, createMatcher, defineCorpus, explain, formatFinding, formatFindings, fromGlossary, kindOf, printCorpus, readGlossary, testCorpus, toJson, toX18nGlossary };
|
package/dist/oxlint.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./glossary-text-
|
|
2
|
-
import { n as DEFAULT_IGNORE_CALLEES, t as createRules } from "./rules-
|
|
3
|
-
import { t as fromGlossary } from "./glossary-
|
|
1
|
+
import "./glossary-text-DB0WoR1i.mjs";
|
|
2
|
+
import { n as DEFAULT_IGNORE_CALLEES, t as createRules } from "./rules-RPbpYGR5.mjs";
|
|
3
|
+
import { t as fromGlossary } from "./glossary-DvBgwOUw.mjs";
|
|
4
4
|
import { resolve } from "node:path";
|
|
5
5
|
// src/oxlint.ts
|
|
6
6
|
const corpora = /* @__PURE__ */ new Map();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as isCodeShape, f as createMatcher, m as classify, p as caseModeOf, x as splitWords } from "./glossary-text-
|
|
1
|
+
import { b as isCodeShape, f as createMatcher, m as classify, p as caseModeOf, x as splitWords } from "./glossary-text-DB0WoR1i.mjs";
|
|
2
2
|
// src/eslint/offsets.ts
|
|
3
3
|
/**
|
|
4
4
|
* Maps from a string's cooked value back to its source text. Each map has one entry per UTF-16 unit of
|
package/dist/x18n.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as GlosslintConfigError, _ as CONFIG_ERRORS, f as createMatcher, m as classify, p as caseModeOf } from "./glossary-text-
|
|
2
|
-
import { t as fromGlossary } from "./glossary-
|
|
1
|
+
import { S as GlosslintConfigError, _ as CONFIG_ERRORS, f as createMatcher, m as classify, p as caseModeOf } from "./glossary-text-DB0WoR1i.mjs";
|
|
2
|
+
import { t as fromGlossary } from "./glossary-DvBgwOUw.mjs";
|
|
3
3
|
// src/x18n/plugin.ts
|
|
4
4
|
const CHECKS = [
|
|
5
5
|
{
|