glosslint 0.0.1 → 0.1.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.
@@ -31,6 +31,8 @@ interface Term {
31
31
  description?: string;
32
32
  /** How it differs from near terms and when not to use it. Printed in findings for avoid words. */
33
33
  nuance?: string;
34
+ /** Why the project uses this term. Printed in findings for avoid words that give no reason of their own. */
35
+ why?: string;
34
36
  /** Abbreviations of the term, always checked as `exact`, such as `DP` for `Day Pass`. */
35
37
  abbr?: string[];
36
38
  /** Words to avoid in favour of this term, each a word or `{ word, why }`. */
@@ -120,7 +122,7 @@ interface Finding {
120
122
  text: string;
121
123
  /** The one-line headline, such as `Use "dock" instead of "rack".` */
122
124
  message: string;
123
- /** Why it is reported: the avoid word's reason, or the term's nuance. */
125
+ /** Why it is reported: the avoid word's reason, else the term's `why`, else its nuance. */
124
126
  why?: string;
125
127
  /** The replacement, when there is one. */
126
128
  fix?: Fix;
package/dist/x18n.d.mts CHANGED
@@ -1,9 +1,11 @@
1
- import { c as Corpus, h as KindOf } from "./types-CBQGgzID.mjs";
1
+ import { c as Corpus, h as KindOf } from "./types-Bbp_cYfZ.mjs";
2
2
  import { Plugin } from "@x18n/core";
3
3
  /** Options of the x18n plugin. */
4
4
  export interface GlosslintX18nOptions {
5
- /** The corpus, usually `import corpus from './glosslint.config.ts'`. */
6
- corpus: Corpus;
5
+ /** The glossary file to read instead of `.agents/glossary.md`. A string resolves from the current folder. */
6
+ glossary?: string | URL;
7
+ /** A corpus to use instead of a glossary file, such as `defineCorpus({ extends: [fromGlossary()], … })`. */
8
+ corpus?: Corpus;
7
9
  /** The locale whose messages are checked. Default: the project's source locale. */
8
10
  sourceLocale?: string;
9
11
  /**
@@ -19,5 +21,8 @@ declare module "@x18n/core" {
19
21
  "glosslint-case": true;
20
22
  }
21
23
  }
22
- /** An x18n plugin that checks source-locale messages and hard strings against the corpus. */
23
- export default function glosslint(options: GlosslintX18nOptions): Plugin;
24
+ /**
25
+ * An x18n plugin that checks source-locale messages and hard strings against the corpus. The corpus comes from
26
+ * `corpus`, else from the `glossary` file, else from `.agents/glossary.md`, read once when the plugin is built.
27
+ */
28
+ export default function glosslint(options?: GlosslintX18nOptions): Plugin;
package/dist/x18n.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { i as classify, n as createMatcher, r as caseModeOf } from "./matcher-Xz4vspsE.mjs";
1
+ import { d as createMatcher, f as caseModeOf, h as CONFIG_ERRORS, p as classify, r as fromGlossary, y as GlosslintConfigError } from "./glossary-lk7EwGey.mjs";
2
2
  // src/x18n.ts
3
3
  const CHECKS = [
4
4
  {
@@ -82,9 +82,17 @@ function messageFixes(message, value, finding, autofixes) {
82
82
  ops: set([finding])
83
83
  }];
84
84
  }
85
- /** An x18n plugin that checks source-locale messages and hard strings against the corpus. */
86
- function glosslint(options) {
87
- const matcher = createMatcher(options.corpus);
85
+ /**
86
+ * An x18n plugin that checks source-locale messages and hard strings against the corpus. The corpus comes from
87
+ * `corpus`, else from the `glossary` file, else from `.agents/glossary.md`, read once when the plugin is built.
88
+ */
89
+ function glosslint(options = {}) {
90
+ if (options.corpus && options.glossary !== void 0) throw new GlosslintConfigError({
91
+ code: CONFIG_ERRORS.glossaryAndCorpus,
92
+ why: "glosslint() takes `glossary` or `corpus`, not both.",
93
+ fix: "Pass `glossary` to read a file, or `corpus` with `extends: [fromGlossary(…)]` to add to one."
94
+ });
95
+ const matcher = createMatcher(options.corpus ?? fromGlossary(options.glossary));
88
96
  function* collect(ctx) {
89
97
  const locale = options.sourceLocale ?? ctx.sourceLocale;
90
98
  const paths = new Map(ctx.resources.map((resource) => [resource.id, resource.path]));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glosslint",
3
- "version": "0.0.1",
3
+ "version": "0.1.0",
4
4
  "description": "Lint product terms against a corpus of words to use and avoid, with what each one means, in ESLint, x18n and a CLI",
5
5
  "keywords": [
6
6
  "case-police",
@@ -9,6 +9,8 @@
9
9
  "eslintplugin",
10
10
  "glossary",
11
11
  "lint",
12
+ "oxlint",
13
+ "oxlint-plugin",
12
14
  "terminology",
13
15
  "vocabulary",
14
16
  "writing",
@@ -39,6 +41,9 @@
39
41
  "eslint": [
40
42
  "./dist/eslint.d.mts"
41
43
  ],
44
+ "oxlint": [
45
+ "./dist/oxlint.d.mts"
46
+ ],
42
47
  "x18n": [
43
48
  "./dist/x18n.d.mts"
44
49
  ],
@@ -62,6 +67,10 @@
62
67
  "types": "./dist/eslint.d.mts",
63
68
  "default": "./dist/eslint.mjs"
64
69
  },
70
+ "./oxlint": {
71
+ "types": "./dist/oxlint.d.mts",
72
+ "default": "./dist/oxlint.mjs"
73
+ },
65
74
  "./x18n": {
66
75
  "types": "./dist/x18n.d.mts",
67
76
  "default": "./dist/x18n.mjs"
@@ -92,6 +101,7 @@
92
101
  "case-police": "2.2.1",
93
102
  "eslint": "^10.15.0",
94
103
  "eslint-vitest-rule-tester": "^3.2.0",
104
+ "oxlint": "1.94.0",
95
105
  "publint": "^0.3.25",
96
106
  "tsrs": "7.1.0-beta.tsrs5",
97
107
  "typescript": "npm:@typescript/typescript6@^6.0.2",
@@ -102,7 +112,8 @@
102
112
  },
103
113
  "peerDependencies": {
104
114
  "@x18n/core": ">=0.1.14",
105
- "eslint": ">=9.15.0"
115
+ "eslint": ">=9.15.0",
116
+ "oxlint": ">=1.94.0"
106
117
  },
107
118
  "peerDependenciesMeta": {
108
119
  "@x18n/core": {
@@ -110,6 +121,9 @@
110
121
  },
111
122
  "eslint": {
112
123
  "optional": true
124
+ },
125
+ "oxlint": {
126
+ "optional": true
113
127
  }
114
128
  },
115
129
  "engines": {