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/README.md +56 -36
- package/dist/cli.d.mts +49 -5
- package/dist/cli.mjs +469 -61
- package/dist/eslint.d.mts +10 -6
- package/dist/eslint.mjs +19 -771
- package/dist/format-E5eFHoQT.mjs +66 -0
- package/dist/glossary-DmTK_e1d.d.mts +32 -0
- package/dist/glossary-ztPpmozR.mjs +1905 -0
- package/dist/inclusive-CP6oU8NW.mjs +520 -0
- package/dist/index.d.mts +6 -27
- package/dist/index.mjs +3 -459
- package/dist/oxlint.d.mts +26 -0
- package/dist/oxlint.mjs +33 -0
- package/dist/presets/inclusive.d.mts +1 -1
- package/dist/presets/inclusive.mjs +1 -520
- package/dist/presets/tech.d.mts +1 -1
- package/dist/presets/tech.mjs +1 -2401
- package/dist/rules-D9Jd07u1.mjs +792 -0
- package/dist/tech-D0v3ss45.mjs +2401 -0
- package/dist/{types-CBQGgzID.d.mts → types-Bbp_cYfZ.d.mts} +3 -1
- package/dist/x18n.d.mts +10 -5
- package/dist/x18n.mjs +12 -4
- package/package.json +17 -2
- package/dist/matcher-Xz4vspsE.mjs +0 -715
- package/dist/tools-BrdtyK9t.mjs +0 -275
package/README.md
CHANGED
|
@@ -11,54 +11,64 @@
|
|
|
11
11
|
|
|
12
12
|
[](https://glosslint.onmax.me)
|
|
13
13
|
|
|
14
|
-
glosslint checks
|
|
14
|
+
glosslint checks your product's vocabulary against one Markdown file, `.agents/glossary.md`. People and coding agents read that file directly, while ESLint, Oxlint, x18n and the CLI enforce it on code, translations and docs. Every finding carries the reason and meaning alongside the fix.
|
|
15
15
|
|
|
16
|
-
[Docs](https://glosslint.onmax.me) · [Installation](https://glosslint.onmax.me/guide/installation) · [The
|
|
16
|
+
[Docs](https://glosslint.onmax.me) · [Installation](https://glosslint.onmax.me/guide/installation) · [The glossary file](https://glosslint.onmax.me/guide/glossary) · [ESLint](https://glosslint.onmax.me/integrations/eslint) · [Oxlint](https://glosslint.onmax.me/integrations/oxlint) · [x18n](https://glosslint.onmax.me/integrations/x18n) · [CLI](https://glosslint.onmax.me/integrations/cli) · [For agents](https://glosslint.onmax.me/guide/agents)
|
|
17
17
|
|
|
18
|
-
##
|
|
18
|
+
## The glossary
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
Write your product's terms in `.agents/glossary.md`. This excerpt comes from the bike-share app in [`examples/basic/.agents/glossary.md`](https://github.com/onmax/glosslint/blob/main/examples/basic/.agents/glossary.md):
|
|
21
|
+
|
|
22
|
+
<!-- prettier-ignore -->
|
|
23
|
+
```md
|
|
24
|
+
# Glossary
|
|
23
25
|
|
|
24
|
-
|
|
26
|
+
<!-- Format and checks: https://glosslint.onmax.me/guide/glossary -->
|
|
25
27
|
|
|
26
|
-
|
|
28
|
+
The words the rider app and the help center use.
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
Extends: tech, inclusive
|
|
31
|
+
Allow: check out our, roof rack
|
|
29
32
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
## Dock
|
|
34
|
+
What: A powered stand where one bike is locked.
|
|
35
|
+
How: A station is a group of docks.
|
|
36
|
+
Avoid:
|
|
37
|
+
- rack: Racks are unpowered.
|
|
38
|
+
- bay
|
|
39
|
+
Good:
|
|
40
|
+
- Return the bike to any dock
|
|
41
|
+
Bad:
|
|
42
|
+
- Return the bike to any rack
|
|
43
|
+
Links:
|
|
44
|
+
- [Docks](https://example.com/docs/docks)
|
|
45
|
+
|
|
46
|
+
## eBike
|
|
47
|
+
|
|
48
|
+
## Day Pass (DP)
|
|
49
|
+
Case: context
|
|
34
50
|
```
|
|
35
51
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
terms: [
|
|
43
|
-
{
|
|
44
|
-
term: "Dock",
|
|
45
|
-
description: "A powered stand where one bike is locked.",
|
|
46
|
-
nuance: "A station is a group of docks.",
|
|
47
|
-
avoid: [{ word: "rack", why: "Racks are unpowered." }, "bay"],
|
|
48
|
-
examples: { good: ["Return the bike to any dock"], bad: ["Return the bike to any rack"] },
|
|
49
|
-
links: [{ title: "Docks", url: "https://example.com/docs/docks" }],
|
|
50
|
-
},
|
|
51
|
-
{ term: "eBike", case: "exact" },
|
|
52
|
-
],
|
|
53
|
-
});
|
|
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; `defineCorpus` in `glosslint.config.ts` is available when you need fields such as `skip`, `forms` or `translations`.
|
|
53
|
+
|
|
54
|
+
## Install
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
pnpm add -D glosslint
|
|
54
58
|
```
|
|
55
59
|
|
|
56
|
-
|
|
60
|
+
glosslint requires Node 22.18 or later. ESLint (`>=9.15.0`), Oxlint (`>=1.94.0`) and `@x18n/core` (`>=0.1.14`) are optional peer dependencies. Install only the ones you use.
|
|
61
|
+
|
|
62
|
+
## One finding
|
|
63
|
+
|
|
64
|
+
Run the CLI on Markdown docs:
|
|
57
65
|
|
|
58
66
|
```sh
|
|
59
67
|
npx glosslint check docs/guide
|
|
60
68
|
```
|
|
61
69
|
|
|
70
|
+
Here is one finding from `examples/basic`:
|
|
71
|
+
|
|
62
72
|
```txt
|
|
63
73
|
[GLOSSLINT_AVOID] "rack" in docs/guide/riding.md:3:56
|
|
64
74
|
├▶ why: Racks are unpowered.
|
|
@@ -69,13 +79,23 @@ npx glosslint check docs/guide
|
|
|
69
79
|
|
|
70
80
|
## Where it checks
|
|
71
81
|
|
|
72
|
-
- [ESLint](https://glosslint.onmax.me/integrations/eslint) checks strings, comments and
|
|
73
|
-
- [
|
|
74
|
-
- [
|
|
82
|
+
- [ESLint](https://glosslint.onmax.me/integrations/eslint): `glosslint()` reads `.agents/glossary.md` with no options and checks strings, comments and identifiers in JavaScript, TypeScript and Vue templates, plus YAML and JSON locale values.
|
|
83
|
+
- [Nuxt and vue-i18n](https://glosslint.onmax.me/integrations/nuxt): one spread in the `withNuxt()` config, no module.
|
|
84
|
+
- [Oxlint](https://glosslint.onmax.me/integrations/oxlint): add `"glosslint/oxlint"` to `jsPlugins` in `.oxlintrc.json` to run the four rules on JavaScript, TypeScript and Vue `<script>` blocks (Oxlint JS plugins are alpha).
|
|
85
|
+
- [x18n](https://glosslint.onmax.me/integrations/x18n): check source-locale messages and hard-coded strings, and pass the corpus to `toX18nGlossary` for x18n's glossary.
|
|
86
|
+
- [CLI](https://glosslint.onmax.me/integrations/cli): checks Markdown, MDX and text files, tests term examples, prints corpora and explains words from the terminal.
|
|
87
|
+
|
|
88
|
+
## Doctor
|
|
89
|
+
|
|
90
|
+
`glosslint doctor` checks `.agents/glossary.md` for format mistakes, bad values, duplicate terms and failing `Good`/`Bad` examples. Pass `--fix` to rewrite fixable layout, heading and field-name issues into canonical form without dropping text:
|
|
91
|
+
|
|
92
|
+
```sh
|
|
93
|
+
npx glosslint doctor --fix
|
|
94
|
+
```
|
|
75
95
|
|
|
76
96
|
## For agents
|
|
77
97
|
|
|
78
|
-
|
|
98
|
+
Coding agents read `.agents/glossary.md` directly, so link it from `AGENTS.md`. When an agent is unsure which word to use, `glosslint explain "<word>"` prints the term, its meaning, its usage notes and the words to avoid. [For agents](https://glosslint.onmax.me/guide/agents) covers the editing loop by `fix.kind`.
|
|
79
99
|
|
|
80
100
|
## License
|
|
81
101
|
|
package/dist/cli.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as GlossaryProblem } from "./glossary-DmTK_e1d.mjs";
|
|
2
|
+
import { c as Corpus, o as CliFinding, v as Matcher } from "./types-Bbp_cYfZ.mjs";
|
|
2
3
|
/** Where a command reads and writes, so tests can run commands without a process. */
|
|
3
4
|
export interface CliIo {
|
|
4
5
|
/** The folder paths and the config are resolved from. */
|
|
@@ -12,6 +13,8 @@ export interface CliIo {
|
|
|
12
13
|
export interface CommandOptions {
|
|
13
14
|
/** The config file. Default: `glosslint.config.{ts,mts,js,mjs}` in `cwd`. */
|
|
14
15
|
config?: string;
|
|
16
|
+
/** The glossary file, read when there is no `config`. Default: `.agents/glossary.md` in `cwd`. */
|
|
17
|
+
glossary?: string;
|
|
15
18
|
/** Color the output. Default: `io.color`. */
|
|
16
19
|
color?: boolean;
|
|
17
20
|
}
|
|
@@ -27,6 +30,32 @@ export interface PrintOptions extends CommandOptions {
|
|
|
27
30
|
/** `md` (default) or `json`. */
|
|
28
31
|
format?: string;
|
|
29
32
|
}
|
|
33
|
+
/** Options of `glosslint doctor`. */
|
|
34
|
+
export interface DoctorOptions {
|
|
35
|
+
/** The glossary file. Default: `.agents/glossary.md` in `cwd`. */
|
|
36
|
+
glossary?: string;
|
|
37
|
+
/** Rewrite the file in canonical form when that drops no text. */
|
|
38
|
+
fix?: boolean;
|
|
39
|
+
/** `text` (default) or `json`. */
|
|
40
|
+
format?: string;
|
|
41
|
+
/** Color the output. Default: `io.color`. */
|
|
42
|
+
color?: boolean;
|
|
43
|
+
}
|
|
44
|
+
/** One problem of the glossary, as `glosslint doctor --format json` prints it. */
|
|
45
|
+
export interface DoctorProblem extends GlossaryProblem {
|
|
46
|
+
/** The glossary, relative to `cwd`. */
|
|
47
|
+
file: string;
|
|
48
|
+
}
|
|
49
|
+
/** The JSON `glosslint doctor` prints: the problems left, and how many `--fix` fixed. */
|
|
50
|
+
export interface DoctorReport {
|
|
51
|
+
problems: DoctorProblem[];
|
|
52
|
+
summary: {
|
|
53
|
+
file: string;
|
|
54
|
+
problems: number;
|
|
55
|
+
fixable: number;
|
|
56
|
+
fixed: number;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
30
59
|
/** Codes of the errors the CLI prints itself, next to the corpus's `GLOSSLINT_C00x`. */
|
|
31
60
|
export declare const CLI_ERRORS: {
|
|
32
61
|
readonly noConfig: "GLOSSLINT_C009";
|
|
@@ -35,15 +64,25 @@ export declare const CLI_ERRORS: {
|
|
|
35
64
|
readonly usage: "GLOSSLINT_USAGE";
|
|
36
65
|
readonly failed: "GLOSSLINT_ERROR";
|
|
37
66
|
};
|
|
38
|
-
/**
|
|
39
|
-
export
|
|
67
|
+
/** What `loadCorpus` read: a config, or a glossary file it then never checks. */
|
|
68
|
+
export interface LoadedCorpus {
|
|
40
69
|
corpus: Corpus;
|
|
70
|
+
/** The absolute path of the file read. */
|
|
41
71
|
file: string;
|
|
42
|
-
|
|
72
|
+
from: "config" | "glossary";
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Finds the corpus: `config`, else `glossary`, else `glosslint.config.{ts,mts,js,mjs}` in `cwd`, else
|
|
76
|
+
* `.agents/glossary.md` in `cwd`.
|
|
77
|
+
*/
|
|
78
|
+
export declare function loadCorpus(cwd: string, options?: {
|
|
79
|
+
config?: string;
|
|
80
|
+
glossary?: string;
|
|
81
|
+
}): Promise<LoadedCorpus>;
|
|
43
82
|
/**
|
|
44
83
|
* Blanks what is not prose in Markdown, keeping every offset: frontmatter, fenced code, HTML
|
|
45
84
|
* comments and tags, inline code, link targets and references, and the markers of headings, lists
|
|
46
|
-
* and quotes. In MDX, `import` and `export` lines too.
|
|
85
|
+
* and quotes. In MDX, `import` and `export` lines too; in other Markdown, Comark component markup.
|
|
47
86
|
*/
|
|
48
87
|
export declare function maskMarkdown(text: string, options?: {
|
|
49
88
|
mdx?: boolean;
|
|
@@ -63,5 +102,10 @@ export declare function runTest(options: CommandOptions, io: CliIo): Promise<num
|
|
|
63
102
|
export declare function runPrint(options: PrintOptions, io: CliIo): Promise<number>;
|
|
64
103
|
/** `glosslint explain`: what the corpus says about a word or phrase. Exits 1 when no term matches. */
|
|
65
104
|
export declare function runExplain(query: string, options: CommandOptions, io: CliIo): Promise<number>;
|
|
105
|
+
/**
|
|
106
|
+
* `glosslint doctor`: reports the problems of the glossary file, and with `fix` rewrites it in canonical
|
|
107
|
+
* form when no problem would drop text. Exits 0 with no problems left, 1 with problems, 2 with no file.
|
|
108
|
+
*/
|
|
109
|
+
export declare function runDoctor(options: DoctorOptions, io: CliIo): Promise<number>;
|
|
66
110
|
/** Runs the CLI on `argv` (the arguments after the program name) and resolves to the exit code. */
|
|
67
111
|
export declare function main(argv: readonly string[], io?: CliIo): Promise<number>;
|