@mark1russell7/ste-lint 0.0.0-bootstrap.0 → 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.
Files changed (227) hide show
  1. package/README.md +224 -1
  2. package/dist/.tsbuildinfo +1 -0
  3. package/dist/cli.d.ts +3 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +9 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/config.d.ts +103 -0
  8. package/dist/config.d.ts.map +1 -0
  9. package/dist/config.js +251 -0
  10. package/dist/config.js.map +1 -0
  11. package/dist/dictionary.d.ts +74 -0
  12. package/dist/dictionary.d.ts.map +1 -0
  13. package/dist/dictionary.js +169 -0
  14. package/dist/dictionary.js.map +1 -0
  15. package/dist/files.d.ts +35 -0
  16. package/dist/files.d.ts.map +1 -0
  17. package/dist/files.js +181 -0
  18. package/dist/files.js.map +1 -0
  19. package/dist/format.d.ts +21 -0
  20. package/dist/format.d.ts.map +1 -0
  21. package/dist/format.js +61 -0
  22. package/dist/format.js.map +1 -0
  23. package/dist/index.d.ts +17 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +17 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/lexicon.d.ts +33 -0
  28. package/dist/lexicon.d.ts.map +1 -0
  29. package/dist/lexicon.js +71 -0
  30. package/dist/lexicon.js.map +1 -0
  31. package/dist/lint.d.ts +28 -0
  32. package/dist/lint.d.ts.map +1 -0
  33. package/dist/lint.js +132 -0
  34. package/dist/lint.js.map +1 -0
  35. package/dist/rules/about-quantity.d.ts +3 -0
  36. package/dist/rules/about-quantity.d.ts.map +1 -0
  37. package/dist/rules/about-quantity.js +34 -0
  38. package/dist/rules/about-quantity.js.map +1 -0
  39. package/dist/rules/index.d.ts +8 -0
  40. package/dist/rules/index.d.ts.map +1 -0
  41. package/dist/rules/index.js +35 -0
  42. package/dist/rules/index.js.map +1 -0
  43. package/dist/rules/ing-verb.d.ts +9 -0
  44. package/dist/rules/ing-verb.d.ts.map +1 -0
  45. package/dist/rules/ing-verb.js +60 -0
  46. package/dist/rules/ing-verb.js.map +1 -0
  47. package/dist/rules/latin-abbreviation.d.ts +3 -0
  48. package/dist/rules/latin-abbreviation.d.ts.map +1 -0
  49. package/dist/rules/latin-abbreviation.js +48 -0
  50. package/dist/rules/latin-abbreviation.js.map +1 -0
  51. package/dist/rules/missing-subject.d.ts +16 -0
  52. package/dist/rules/missing-subject.d.ts.map +1 -0
  53. package/dist/rules/missing-subject.js +138 -0
  54. package/dist/rules/missing-subject.js.map +1 -0
  55. package/dist/rules/modal-verb.d.ts +3 -0
  56. package/dist/rules/modal-verb.d.ts.map +1 -0
  57. package/dist/rules/modal-verb.js +72 -0
  58. package/dist/rules/modal-verb.js.map +1 -0
  59. package/dist/rules/noun-cluster.d.ts +17 -0
  60. package/dist/rules/noun-cluster.d.ts.map +1 -0
  61. package/dist/rules/noun-cluster.js +83 -0
  62. package/dist/rules/noun-cluster.js.map +1 -0
  63. package/dist/rules/paragraph-length.d.ts +3 -0
  64. package/dist/rules/paragraph-length.d.ts.map +1 -0
  65. package/dist/rules/paragraph-length.js +19 -0
  66. package/dist/rules/paragraph-length.js.map +1 -0
  67. package/dist/rules/passive-instruction.d.ts +15 -0
  68. package/dist/rules/passive-instruction.d.ts.map +1 -0
  69. package/dist/rules/passive-instruction.js +38 -0
  70. package/dist/rules/passive-instruction.js.map +1 -0
  71. package/dist/rules/pronouns.d.ts +4 -0
  72. package/dist/rules/pronouns.d.ts.map +1 -0
  73. package/dist/rules/pronouns.js +57 -0
  74. package/dist/rules/pronouns.js.map +1 -0
  75. package/dist/rules/rule.d.ts +46 -0
  76. package/dist/rules/rule.d.ts.map +1 -0
  77. package/dist/rules/rule.js +31 -0
  78. package/dist/rules/rule.js.map +1 -0
  79. package/dist/rules/semicolon.d.ts +3 -0
  80. package/dist/rules/semicolon.d.ts.map +1 -0
  81. package/dist/rules/semicolon.js +20 -0
  82. package/dist/rules/semicolon.js.map +1 -0
  83. package/dist/rules/sentence-length.d.ts +3 -0
  84. package/dist/rules/sentence-length.d.ts.map +1 -0
  85. package/dist/rules/sentence-length.js +31 -0
  86. package/dist/rules/sentence-length.js.map +1 -0
  87. package/dist/rules/unknown-word.d.ts +9 -0
  88. package/dist/rules/unknown-word.d.ts.map +1 -0
  89. package/dist/rules/unknown-word.js +49 -0
  90. package/dist/rules/unknown-word.js.map +1 -0
  91. package/dist/rules/word-list-matcher.d.ts +25 -0
  92. package/dist/rules/word-list-matcher.d.ts.map +1 -0
  93. package/dist/rules/word-list-matcher.js +60 -0
  94. package/dist/rules/word-list-matcher.js.map +1 -0
  95. package/dist/rules/word-list.d.ts +3 -0
  96. package/dist/rules/word-list.d.ts.map +1 -0
  97. package/dist/rules/word-list.js +26 -0
  98. package/dist/rules/word-list.js.map +1 -0
  99. package/dist/run-cli.d.ts +27 -0
  100. package/dist/run-cli.d.ts.map +1 -0
  101. package/dist/run-cli.js +176 -0
  102. package/dist/run-cli.js.map +1 -0
  103. package/dist/source/blocks.d.ts +55 -0
  104. package/dist/source/blocks.d.ts.map +1 -0
  105. package/dist/source/blocks.js +464 -0
  106. package/dist/source/blocks.js.map +1 -0
  107. package/dist/source/inline.d.ts +42 -0
  108. package/dist/source/inline.d.ts.map +1 -0
  109. package/dist/source/inline.js +396 -0
  110. package/dist/source/inline.js.map +1 -0
  111. package/dist/source/jsx.d.ts +18 -0
  112. package/dist/source/jsx.d.ts.map +1 -0
  113. package/dist/source/jsx.js +137 -0
  114. package/dist/source/jsx.js.map +1 -0
  115. package/dist/source/lines.d.ts +34 -0
  116. package/dist/source/lines.d.ts.map +1 -0
  117. package/dist/source/lines.js +83 -0
  118. package/dist/source/lines.js.map +1 -0
  119. package/dist/source/markdown.d.ts +23 -0
  120. package/dist/source/markdown.d.ts.map +1 -0
  121. package/dist/source/markdown.js +42 -0
  122. package/dist/source/markdown.js.map +1 -0
  123. package/dist/source/suppressions.d.ts +38 -0
  124. package/dist/source/suppressions.d.ts.map +1 -0
  125. package/dist/source/suppressions.js +69 -0
  126. package/dist/source/suppressions.js.map +1 -0
  127. package/dist/source/tsdoc.d.ts +40 -0
  128. package/dist/source/tsdoc.d.ts.map +1 -0
  129. package/dist/source/tsdoc.js +176 -0
  130. package/dist/source/tsdoc.js.map +1 -0
  131. package/dist/text/grammar.d.ts +91 -0
  132. package/dist/text/grammar.d.ts.map +1 -0
  133. package/dist/text/grammar.js +289 -0
  134. package/dist/text/grammar.js.map +1 -0
  135. package/dist/text/phrases.d.ts +30 -0
  136. package/dist/text/phrases.d.ts.map +1 -0
  137. package/dist/text/phrases.js +65 -0
  138. package/dist/text/phrases.js.map +1 -0
  139. package/dist/text/sentences.d.ts +45 -0
  140. package/dist/text/sentences.d.ts.map +1 -0
  141. package/dist/text/sentences.js +141 -0
  142. package/dist/text/sentences.js.map +1 -0
  143. package/dist/text/tokens.d.ts +35 -0
  144. package/dist/text/tokens.d.ts.map +1 -0
  145. package/dist/text/tokens.js +113 -0
  146. package/dist/text/tokens.js.map +1 -0
  147. package/dist/text/words.d.ts +58 -0
  148. package/dist/text/words.d.ts.map +1 -0
  149. package/dist/text/words.js +159 -0
  150. package/dist/text/words.js.map +1 -0
  151. package/dist/types.d.ts +18 -0
  152. package/dist/types.d.ts.map +1 -0
  153. package/dist/types.js +20 -0
  154. package/dist/types.js.map +1 -0
  155. package/dist/units.d.ts +47 -0
  156. package/dist/units.d.ts.map +1 -0
  157. package/dist/units.js +42 -0
  158. package/dist/units.js.map +1 -0
  159. package/dist/word-list.d.ts +34 -0
  160. package/dist/word-list.d.ts.map +1 -0
  161. package/dist/word-list.js +90 -0
  162. package/dist/word-list.js.map +1 -0
  163. package/package.json +41 -4
  164. package/src/cli.ts +9 -0
  165. package/src/config.test.ts +188 -0
  166. package/src/config.ts +318 -0
  167. package/src/dictionary.test.ts +82 -0
  168. package/src/dictionary.ts +177 -0
  169. package/src/files.test.ts +107 -0
  170. package/src/files.ts +191 -0
  171. package/src/format.ts +78 -0
  172. package/src/index.test.ts +28 -0
  173. package/src/index.ts +34 -0
  174. package/src/lexicon.ts +92 -0
  175. package/src/lint.test.ts +182 -0
  176. package/src/lint.ts +135 -0
  177. package/src/rules/about-quantity.ts +33 -0
  178. package/src/rules/index.ts +40 -0
  179. package/src/rules/ing-verb.test.ts +48 -0
  180. package/src/rules/ing-verb.ts +54 -0
  181. package/src/rules/latin-abbreviation.ts +46 -0
  182. package/src/rules/missing-subject.test.ts +53 -0
  183. package/src/rules/missing-subject.ts +129 -0
  184. package/src/rules/modal-verb.test.ts +45 -0
  185. package/src/rules/modal-verb.ts +72 -0
  186. package/src/rules/noun-cluster.test.ts +49 -0
  187. package/src/rules/noun-cluster.ts +82 -0
  188. package/src/rules/paragraph-length.test.ts +30 -0
  189. package/src/rules/paragraph-length.ts +19 -0
  190. package/src/rules/passive-instruction.test.ts +38 -0
  191. package/src/rules/passive-instruction.ts +37 -0
  192. package/src/rules/pronouns.test.ts +38 -0
  193. package/src/rules/pronouns.ts +54 -0
  194. package/src/rules/punctuation.test.ts +59 -0
  195. package/src/rules/rule.ts +73 -0
  196. package/src/rules/semicolon.ts +19 -0
  197. package/src/rules/sentence-length.test.ts +52 -0
  198. package/src/rules/sentence-length.ts +32 -0
  199. package/src/rules/unknown-word.test.ts +81 -0
  200. package/src/rules/unknown-word.ts +43 -0
  201. package/src/rules/word-list-matcher.ts +68 -0
  202. package/src/rules/word-list.test.ts +110 -0
  203. package/src/rules/word-list.ts +25 -0
  204. package/src/run-cli.test.ts +189 -0
  205. package/src/run-cli.ts +193 -0
  206. package/src/source/blocks.ts +534 -0
  207. package/src/source/inline.test.ts +92 -0
  208. package/src/source/inline.ts +416 -0
  209. package/src/source/jsx.test.ts +46 -0
  210. package/src/source/jsx.ts +147 -0
  211. package/src/source/lines.test.ts +51 -0
  212. package/src/source/lines.ts +91 -0
  213. package/src/source/markdown.test.ts +210 -0
  214. package/src/source/markdown.ts +49 -0
  215. package/src/source/suppressions.ts +79 -0
  216. package/src/source/tsdoc.test.ts +137 -0
  217. package/src/source/tsdoc.ts +189 -0
  218. package/src/text/grammar.ts +304 -0
  219. package/src/text/phrases.ts +72 -0
  220. package/src/text/sentences.ts +148 -0
  221. package/src/text/text.test.ts +262 -0
  222. package/src/text/tokens.ts +135 -0
  223. package/src/text/words.ts +183 -0
  224. package/src/types.ts +39 -0
  225. package/src/units.ts +86 -0
  226. package/src/word-list.ts +128 -0
  227. package/ste.config.schema.json +87 -0
package/dist/config.js ADDED
@@ -0,0 +1,251 @@
1
+ /**
2
+ * The configuration file `ste.config.json`, and the configuration that the
3
+ * linter uses after it reads the file, the environment and the defaults.
4
+ */
5
+ import { existsSync, readFileSync } from "node:fs";
6
+ import { homedir } from "node:os";
7
+ import { dirname, join, resolve } from "node:path";
8
+ import { isRuleId, RULE_IDS } from "./types.js";
9
+ import { DEFAULT_WORD_LIST } from "./word-list.js";
10
+ export const CONFIG_FILE_NAME = "ste.config.json";
11
+ /** The environment variable that gives the path of the local dictionary. It has priority over `dictionaryPath`. */
12
+ export const DICTIONARY_ENV = "STE_DICTIONARY";
13
+ export const DEFAULT_INCLUDE = [
14
+ "README.md",
15
+ "docs/**/*.{md,mdx}",
16
+ "packages/*/README.md",
17
+ "packages/*/src/**/*.{ts,tsx}",
18
+ "packages/*/build/**/*.{ts,tsx}",
19
+ "packages/*/commands/**/*.{ts,tsx}",
20
+ "packages/*/*.config.{ts,mts}",
21
+ ];
22
+ export const DEFAULT_IGNORE = [
23
+ "**/node_modules/**",
24
+ "**/dist/**",
25
+ "**/*.d.ts",
26
+ "**/*.test.ts",
27
+ "**/*.test.tsx",
28
+ "**/*.spec.ts",
29
+ "**/*.spec.tsx",
30
+ ];
31
+ export const DEFAULT_LIMITS = {
32
+ instructionWords: 20,
33
+ descriptionWords: 25,
34
+ paragraphSentences: 6,
35
+ nounClusterNouns: 3,
36
+ };
37
+ /** An error in the configuration. */
38
+ export class ConfigError extends Error {
39
+ name = "ConfigError";
40
+ }
41
+ const SETTINGS = ["error", "warning", "off"];
42
+ const KNOWN_KEYS = new Set([
43
+ "$schema", "include", "ignore", "technicalNouns", "technicalVerbs", "properNouns", "allowedWords",
44
+ "rules", "wordList", "limits", "dictionaryPath",
45
+ ]);
46
+ const WORD_LIST_KEYS = new Set(["id", "match", "suggest", "note", "severity", "verbOnly"]);
47
+ /** This function makes sure that `value` is a valid configuration. It throws a `ConfigError` that lists all problems. */
48
+ export function validateConfig(value, source) {
49
+ const problems = [];
50
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
51
+ throw new ConfigError(`${source}: the configuration must be a JSON object.`);
52
+ }
53
+ const record = value;
54
+ for (const key of Object.keys(record)) {
55
+ if (!KNOWN_KEYS.has(key))
56
+ problems.push(`"${key}" is not a known property. Known properties: ${[...KNOWN_KEYS].join(", ")}.`);
57
+ }
58
+ for (const key of ["include", "ignore", "technicalNouns", "technicalVerbs", "properNouns", "allowedWords"]) {
59
+ const item = record[key];
60
+ if (item !== undefined && !(Array.isArray(item) && item.every((entry) => typeof entry === "string"))) {
61
+ problems.push(`"${key}" must be an array of strings.`);
62
+ }
63
+ }
64
+ const rules = record["rules"];
65
+ if (rules !== undefined) {
66
+ if (typeof rules !== "object" || rules === null || Array.isArray(rules)) {
67
+ problems.push(`"rules" must be an object.`);
68
+ }
69
+ else {
70
+ for (const [id, setting] of Object.entries(rules)) {
71
+ if (!isRuleId(id))
72
+ problems.push(`"rules.${id}" is not a known rule. Known rules: ${RULE_IDS.join(", ")}.`);
73
+ if (typeof setting !== "string" || !SETTINGS.includes(setting))
74
+ problems.push(`"rules.${id}" must be "error", "warning" or "off".`);
75
+ }
76
+ }
77
+ }
78
+ const limits = record["limits"];
79
+ if (limits !== undefined) {
80
+ if (typeof limits !== "object" || limits === null || Array.isArray(limits)) {
81
+ problems.push(`"limits" must be an object.`);
82
+ }
83
+ else {
84
+ for (const [key, limit] of Object.entries(limits)) {
85
+ if (!Object.hasOwn(DEFAULT_LIMITS, key))
86
+ problems.push(`"limits.${key}" is not a known limit. Known limits: ${Object.keys(DEFAULT_LIMITS).join(", ")}.`);
87
+ if (typeof limit !== "number" || !Number.isInteger(limit) || limit < 1)
88
+ problems.push(`"limits.${key}" must be an integer of 1 or more.`);
89
+ }
90
+ }
91
+ }
92
+ const dictionaryPath = record["dictionaryPath"];
93
+ if (dictionaryPath !== undefined && dictionaryPath !== null && typeof dictionaryPath !== "string") {
94
+ problems.push(`"dictionaryPath" must be a string or null.`);
95
+ }
96
+ const wordList = record["wordList"];
97
+ if (wordList !== undefined) {
98
+ if (!Array.isArray(wordList)) {
99
+ problems.push(`"wordList" must be an array.`);
100
+ }
101
+ else {
102
+ wordList.forEach((item, index) => problems.push(...validateWordListEntry(item, `wordList[${index}]`)));
103
+ }
104
+ }
105
+ if (problems.length > 0)
106
+ throw new ConfigError(`${source}:\n - ${problems.join("\n - ")}`);
107
+ return record;
108
+ }
109
+ function validateWordListEntry(item, where) {
110
+ if (typeof item !== "object" || item === null || Array.isArray(item))
111
+ return [`"${where}" must be an object.`];
112
+ const problems = [];
113
+ const entry = item;
114
+ for (const key of Object.keys(entry)) {
115
+ if (!WORD_LIST_KEYS.has(key))
116
+ problems.push(`"${where}.${key}" is not a known property.`);
117
+ }
118
+ const match = entry["match"];
119
+ const matchValid = typeof match === "string" || (Array.isArray(match) && match.length > 0 && match.every((word) => typeof word === "string"));
120
+ if (match !== undefined && !matchValid)
121
+ problems.push(`"${where}.match" must be a string or an array of strings.`);
122
+ if (entry["id"] !== undefined && typeof entry["id"] !== "string")
123
+ problems.push(`"${where}.id" must be a string.`);
124
+ if (entry["id"] === undefined && match === undefined)
125
+ problems.push(`"${where}" must have "id" or "match".`);
126
+ for (const key of ["suggest", "note"]) {
127
+ const text = entry[key];
128
+ if (text !== undefined && text !== null && typeof text !== "string")
129
+ problems.push(`"${where}.${key}" must be a string or null.`);
130
+ }
131
+ const severity = entry["severity"];
132
+ if (severity !== undefined && (typeof severity !== "string" || !SETTINGS.includes(severity)))
133
+ problems.push(`"${where}.severity" must be "error", "warning" or "off".`);
134
+ if (entry["verbOnly"] !== undefined && typeof entry["verbOnly"] !== "boolean")
135
+ problems.push(`"${where}.verbOnly" must be true or false.`);
136
+ return problems;
137
+ }
138
+ /**
139
+ * This function merges the default word list and the entries of the
140
+ * configuration. An entry with the ID (or the first `match` word) of a
141
+ * default entry changes that entry. The severity "off" removes the entry
142
+ * with that ID, and it removes the `match` words from all entries.
143
+ */
144
+ export function mergeWordList(defaults, overrides) {
145
+ const entries = new Map(defaults.map((entry) => [entry.id, entry]));
146
+ for (const override of overrides) {
147
+ const match = override.match === undefined ? undefined : typeof override.match === "string" ? [override.match] : [...override.match];
148
+ const id = override.id ?? match[0];
149
+ const base = entries.get(id) ?? null;
150
+ if (override.severity === "off") {
151
+ entries.set(id, null);
152
+ const removed = new Set((match ?? []).map((word) => word.toLowerCase()));
153
+ for (const [key, entry] of entries) {
154
+ if (entry === null)
155
+ continue;
156
+ const kept = entry.match.filter((word) => !removed.has(word.toLowerCase()));
157
+ entries.set(key, kept.length === 0 ? null : { ...entry, match: kept });
158
+ }
159
+ continue;
160
+ }
161
+ const merged = {
162
+ id,
163
+ match: match ?? base?.match ?? [id],
164
+ suggest: override.suggest !== undefined ? override.suggest : base?.suggest ?? null,
165
+ note: override.note !== undefined ? override.note : base?.note ?? null,
166
+ severity: override.severity ?? base?.severity ?? "error",
167
+ verbOnly: override.verbOnly ?? base?.verbOnly ?? false,
168
+ context: base?.context ?? null,
169
+ };
170
+ entries.set(id, merged);
171
+ }
172
+ return [...entries.values()].filter((entry) => entry !== null);
173
+ }
174
+ /** This function expands a leading `~/` to the home directory, and makes the path absolute. */
175
+ export function resolvePath(path, base) {
176
+ const expanded = path === "~" ? homedir() : path.startsWith("~/") || path.startsWith("~\\") ? join(homedir(), path.slice(2)) : path;
177
+ return resolve(base, expanded);
178
+ }
179
+ /** This function applies the defaults and the environment to a configuration file. */
180
+ export function resolveConfig(file, options) {
181
+ const env = options.env ?? {};
182
+ const cwd = options.cwd ?? options.root;
183
+ const fromEnv = env[DICTIONARY_ENV];
184
+ let dictionaryPath = null;
185
+ let dictionarySource = null;
186
+ if (fromEnv !== undefined && fromEnv.trim().length > 0) {
187
+ dictionaryPath = resolvePath(fromEnv.trim(), cwd);
188
+ dictionarySource = "env";
189
+ }
190
+ else if (typeof file.dictionaryPath === "string" && file.dictionaryPath.trim().length > 0) {
191
+ dictionaryPath = resolvePath(file.dictionaryPath.trim(), options.root);
192
+ dictionarySource = "config";
193
+ }
194
+ const rules = {};
195
+ for (const [id, setting] of Object.entries(file.rules ?? {})) {
196
+ if (isRuleId(id))
197
+ rules[id] = setting;
198
+ }
199
+ return {
200
+ root: options.root,
201
+ configFile: options.configFile ?? null,
202
+ include: file.include ?? DEFAULT_INCLUDE,
203
+ ignore: file.ignore ?? DEFAULT_IGNORE,
204
+ technicalNouns: file.technicalNouns ?? [],
205
+ technicalVerbs: file.technicalVerbs ?? [],
206
+ properNouns: file.properNouns ?? [],
207
+ allowedWords: file.allowedWords ?? [],
208
+ rules,
209
+ wordList: mergeWordList(DEFAULT_WORD_LIST, file.wordList ?? []),
210
+ limits: { ...DEFAULT_LIMITS, ...file.limits },
211
+ dictionaryPath,
212
+ dictionarySource,
213
+ };
214
+ }
215
+ /** The first `ste.config.json` in `cwd` or one of its parent directories, or null. */
216
+ export function findConfigFile(cwd) {
217
+ let directory = resolve(cwd);
218
+ for (;;) {
219
+ const candidate = join(directory, CONFIG_FILE_NAME);
220
+ if (existsSync(candidate))
221
+ return candidate;
222
+ const parent = dirname(directory);
223
+ if (parent === directory)
224
+ return null;
225
+ directory = parent;
226
+ }
227
+ }
228
+ /** This function reads the configuration file, if there is one, and resolves it. */
229
+ export function loadConfig(options) {
230
+ const configFile = options.configPath !== undefined ? resolve(options.cwd, options.configPath) : findConfigFile(options.cwd);
231
+ const env = options.env ?? {};
232
+ if (configFile === null)
233
+ return resolveConfig({}, { root: resolve(options.cwd), cwd: options.cwd, env });
234
+ let text;
235
+ try {
236
+ text = readFileSync(configFile, "utf8");
237
+ }
238
+ catch (error) {
239
+ throw new ConfigError(`Cannot read the configuration file ${configFile}: ${error.message}`);
240
+ }
241
+ let value;
242
+ try {
243
+ value = JSON.parse(text);
244
+ }
245
+ catch (error) {
246
+ throw new ConfigError(`${configFile}: the file is not valid JSON: ${error.message}`);
247
+ }
248
+ const file = validateConfig(value, configFile);
249
+ return resolveConfig(file, { root: dirname(configFile), configFile, cwd: options.cwd, env });
250
+ }
251
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAgD,MAAM,YAAY,CAAC;AAC9F,OAAO,EAAE,iBAAiB,EAAsB,MAAM,gBAAgB,CAAC;AAEvE,MAAM,CAAC,MAAM,gBAAgB,GAAG,iBAAiB,CAAC;AAElD,mHAAmH;AACnH,MAAM,CAAC,MAAM,cAAc,GAAG,gBAAgB,CAAC;AA8D/C,MAAM,CAAC,MAAM,eAAe,GAAuB;IAC/C,WAAW;IACX,oBAAoB;IACpB,sBAAsB;IACtB,8BAA8B;IAC9B,gCAAgC;IAChC,mCAAmC;IACnC,8BAA8B;CACjC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAuB;IAC9C,oBAAoB;IACpB,YAAY;IACZ,WAAW;IACX,cAAc;IACd,eAAe;IACf,cAAc;IACd,eAAe;CAClB,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAY;IACnC,gBAAgB,EAAG,EAAE;IACrB,gBAAgB,EAAG,EAAE;IACrB,kBAAkB,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AE,IAAI,EAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,GAAG,EAAG,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;IAC3G,IAAI,IAAa,CAAC;IAClB,IAAI,CAAC;QACD,IAAI,GAAG,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAC5C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,MAAM,IAAI,WAAW,CAAC,sCAAsC,UAAU,KAAM,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;IAC3G,CAAC;IACD,IAAI,KAAe,CAAC;IACpB,IAAI,CAAC;QACD,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,MAAM,IAAI,WAAW,CAAC,GAAG,UAAU,iCAAkC,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;IACpG,CAAC;IACD,MAAM,IAAI,GAAG,cAAc,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IAC/C,OAAO,aAAa,CAAC,IAAI,EAAE,EAAE,IAAI,EAAG,OAAO,CAAC,UAAU,CAAC,EAAE,UAAU,EAAE,GAAG,EAAG,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;AACnG,CAAC"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * The optional local dictionary of approved words.
3
+ *
4
+ * The ASD-STE100 dictionary is copyrighted. This package does not contain
5
+ * it, and the repository must not contain it. Each user makes a local file
6
+ * from their own copy of the standard. Keep that file outside the
7
+ * repository, or in a git-ignored folder, for example `.ste/`.
8
+ *
9
+ * File format (JSON). The short form is an array of approved words:
10
+ *
11
+ * ```json
12
+ * ["a", "about", "make", "makes", "made"]
13
+ * ```
14
+ *
15
+ * The full form is an object with entries:
16
+ *
17
+ * ```json
18
+ * {
19
+ * "format": "ste-lint-dictionary",
20
+ * "version": 1,
21
+ * "entries": [
22
+ * { "word": "make", "pos": "verb", "forms": ["makes", "made"] },
23
+ * { "word": "valve", "pos": "noun" },
24
+ * { "word": "utilize", "pos": "verb", "approved": false, "alternatives": ["use"] }
25
+ * ]
26
+ * }
27
+ * ```
28
+ *
29
+ * - `word` (necessary): the headword. A phrase, for example "make sure", approves each of its words.
30
+ * - `pos`: the part of speech. A noun also permits its regular plural.
31
+ * - `approved`: `false` for a word that is not approved. The default is `true`.
32
+ * - `forms`: other approved forms, for example the past tense of a verb.
33
+ * - `alternatives`: approved words to use instead of a word that is not approved.
34
+ */
35
+ export type DictionaryEntry = {
36
+ readonly word: string;
37
+ readonly pos?: string;
38
+ readonly approved?: boolean;
39
+ readonly forms?: readonly string[];
40
+ readonly alternatives?: readonly string[];
41
+ };
42
+ export type DictionaryLookup = {
43
+ readonly status: "approved";
44
+ } | {
45
+ readonly status: "not-approved";
46
+ readonly alternatives: readonly string[];
47
+ } | {
48
+ readonly status: "unknown";
49
+ };
50
+ export declare const DICTIONARY_FORMAT = "ste-lint-dictionary";
51
+ /** An error in a dictionary file. */
52
+ export declare class DictionaryError extends Error {
53
+ readonly name: string;
54
+ }
55
+ /** The approved words of a local dictionary. */
56
+ export declare class Dictionary {
57
+ private readonly approved;
58
+ private readonly approvedNouns;
59
+ private readonly notApproved;
60
+ /** The approved nouns. The noun-cluster rule uses them. */
61
+ readonly nouns: Set<string>;
62
+ /** The approved verbs. The imperative and missing-subject heuristics use them. */
63
+ readonly verbs: Set<string>;
64
+ constructor(entries: readonly DictionaryEntry[]);
65
+ /** The number of approved words and forms. */
66
+ get size(): number;
67
+ /** The status of `word` in the dictionary. */
68
+ lookup(word: string): DictionaryLookup;
69
+ }
70
+ /** This function makes a dictionary from parsed JSON. `source` is the file name for error messages. */
71
+ export declare function parseDictionary(value: unknown, source: string): Dictionary;
72
+ /** This function reads a dictionary file. */
73
+ export declare function loadDictionary(path: string): Dictionary;
74
+ //# sourceMappingURL=dictionary.d.ts.map
@@ -0,0 +1 @@
1
+ {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ElB;IAED,8CAA8C;IAC9C,MAAM,CAAC,IAAI,EAAG,MAAM,GAAI,gBAAgB;CAe3C;AAED,uGAAuG;AACvG,wBAAgB,eAAe,CAAC,KAAK,EAAG,OAAO,EAAE,MAAM,EAAG,MAAM,GAAI,UAAU,CAmB7E;AA+BD,6CAA6C;AAC7C,wBAAgB,cAAc,CAAC,IAAI,EAAG,MAAM,GAAI,UAAU,CAczD"}
@@ -0,0 +1,169 @@
1
+ /**
2
+ * The optional local dictionary of approved words.
3
+ *
4
+ * The ASD-STE100 dictionary is copyrighted. This package does not contain
5
+ * it, and the repository must not contain it. Each user makes a local file
6
+ * from their own copy of the standard. Keep that file outside the
7
+ * repository, or in a git-ignored folder, for example `.ste/`.
8
+ *
9
+ * File format (JSON). The short form is an array of approved words:
10
+ *
11
+ * ```json
12
+ * ["a", "about", "make", "makes", "made"]
13
+ * ```
14
+ *
15
+ * The full form is an object with entries:
16
+ *
17
+ * ```json
18
+ * {
19
+ * "format": "ste-lint-dictionary",
20
+ * "version": 1,
21
+ * "entries": [
22
+ * { "word": "make", "pos": "verb", "forms": ["makes", "made"] },
23
+ * { "word": "valve", "pos": "noun" },
24
+ * { "word": "utilize", "pos": "verb", "approved": false, "alternatives": ["use"] }
25
+ * ]
26
+ * }
27
+ * ```
28
+ *
29
+ * - `word` (necessary): the headword. A phrase, for example "make sure", approves each of its words.
30
+ * - `pos`: the part of speech. A noun also permits its regular plural.
31
+ * - `approved`: `false` for a word that is not approved. The default is `true`.
32
+ * - `forms`: other approved forms, for example the past tense of a verb.
33
+ * - `alternatives`: approved words to use instead of a word that is not approved.
34
+ */
35
+ import { readFileSync } from "node:fs";
36
+ export const DICTIONARY_FORMAT = "ste-lint-dictionary";
37
+ /** An error in a dictionary file. */
38
+ export class DictionaryError extends Error {
39
+ name = "DictionaryError";
40
+ }
41
+ const normalize = (word) => word.trim().toLowerCase().replace(/[’‘]/g, "'");
42
+ /** The approved words of a local dictionary. */
43
+ export class Dictionary {
44
+ approved = new Set();
45
+ approvedNouns = new Set();
46
+ notApproved = new Map();
47
+ /** The approved nouns. The noun-cluster rule uses them. */
48
+ nouns = new Set();
49
+ /** The approved verbs. The imperative and missing-subject heuristics use them. */
50
+ verbs = new Set();
51
+ constructor(entries) {
52
+ for (const entry of entries) {
53
+ const words = [entry.word, ...(entry.forms ?? [])].flatMap((form) => normalize(form).split(/\s+/)).filter((form) => form.length > 0);
54
+ if (entry.approved === false) {
55
+ for (const word of words)
56
+ this.notApproved.set(word, entry.alternatives ?? []);
57
+ continue;
58
+ }
59
+ for (const word of words)
60
+ this.approved.add(word);
61
+ const pos = (entry.pos ?? "").toLowerCase();
62
+ const base = normalize(entry.word);
63
+ if (pos === "n" || pos === "noun") {
64
+ this.approvedNouns.add(base);
65
+ this.nouns.add(base);
66
+ }
67
+ if (pos === "v" || pos === "verb")
68
+ this.verbs.add(base);
69
+ }
70
+ }
71
+ /** The number of approved words and forms. */
72
+ get size() {
73
+ return this.approved.size;
74
+ }
75
+ /** The status of `word` in the dictionary. */
76
+ lookup(word) {
77
+ const lower = normalize(word);
78
+ const candidates = [lower];
79
+ if (lower.endsWith("'s"))
80
+ candidates.push(lower.slice(0, -2));
81
+ for (const candidate of candidates) {
82
+ if (this.approved.has(candidate))
83
+ return { status: "approved" };
84
+ const plurals = [candidate.slice(0, -1), candidate.slice(0, -2), candidate.slice(0, -3) + "y"];
85
+ if (candidate.endsWith("s") && plurals.some((singular) => this.approvedNouns.has(singular)))
86
+ return { status: "approved" };
87
+ }
88
+ for (const candidate of candidates) {
89
+ const alternatives = this.notApproved.get(candidate);
90
+ if (alternatives !== undefined)
91
+ return { status: "not-approved", alternatives };
92
+ }
93
+ return { status: "unknown" };
94
+ }
95
+ }
96
+ /** This function makes a dictionary from parsed JSON. `source` is the file name for error messages. */
97
+ export function parseDictionary(value, source) {
98
+ if (Array.isArray(value)) {
99
+ if (!value.every((word) => typeof word === "string")) {
100
+ throw new DictionaryError(`${source}: the array form must contain only strings.`);
101
+ }
102
+ return new Dictionary(value.map((word) => ({ word })));
103
+ }
104
+ if (typeof value !== "object" || value === null) {
105
+ throw new DictionaryError(`${source}: the file must contain an array of words or an object with "entries".`);
106
+ }
107
+ const record = value;
108
+ const format = record["format"];
109
+ if (format !== undefined && format !== DICTIONARY_FORMAT) {
110
+ throw new DictionaryError(`${source}: "format" must be "${DICTIONARY_FORMAT}".`);
111
+ }
112
+ const entries = record["entries"];
113
+ if (!Array.isArray(entries))
114
+ throw new DictionaryError(`${source}: "entries" must be an array.`);
115
+ const parsed = entries.map((entry, index) => parseEntry(entry, `${source}: entries[${index}]`));
116
+ return new Dictionary(parsed);
117
+ }
118
+ function stringArray(value, where) {
119
+ if (value === undefined)
120
+ return undefined;
121
+ if (!Array.isArray(value) || !value.every((item) => typeof item === "string")) {
122
+ throw new DictionaryError(`${where} must be an array of strings.`);
123
+ }
124
+ return value;
125
+ }
126
+ function parseEntry(entry, where) {
127
+ if (typeof entry === "string")
128
+ return { word: entry };
129
+ if (typeof entry !== "object" || entry === null)
130
+ throw new DictionaryError(`${where} must be a string or an object.`);
131
+ const record = entry;
132
+ const word = record["word"];
133
+ if (typeof word !== "string" || word.trim().length === 0)
134
+ throw new DictionaryError(`${where}.word must be a string that is not empty.`);
135
+ const pos = record["pos"];
136
+ if (pos !== undefined && typeof pos !== "string")
137
+ throw new DictionaryError(`${where}.pos must be a string.`);
138
+ const approved = record["approved"];
139
+ if (approved !== undefined && typeof approved !== "boolean")
140
+ throw new DictionaryError(`${where}.approved must be true or false.`);
141
+ const forms = stringArray(record["forms"], `${where}.forms`);
142
+ const alternatives = stringArray(record["alternatives"], `${where}.alternatives`);
143
+ return {
144
+ word,
145
+ ...(pos === undefined ? {} : { pos }),
146
+ ...(approved === undefined ? {} : { approved }),
147
+ ...(forms === undefined ? {} : { forms }),
148
+ ...(alternatives === undefined ? {} : { alternatives }),
149
+ };
150
+ }
151
+ /** This function reads a dictionary file. */
152
+ export function loadDictionary(path) {
153
+ let text;
154
+ try {
155
+ text = readFileSync(path, "utf8");
156
+ }
157
+ catch (error) {
158
+ throw new DictionaryError(`Cannot read the dictionary file ${path}: ${error.message}`);
159
+ }
160
+ let value;
161
+ try {
162
+ value = JSON.parse(text);
163
+ }
164
+ catch (error) {
165
+ throw new DictionaryError(`${path}: the file is not valid JSON: ${error.message}`);
166
+ }
167
+ return parseDictionary(value, path);
168
+ }
169
+ //# sourceMappingURL=dictionary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dictionary.js","sourceRoot":"","sources":["../src/dictionary.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAevC,MAAM,CAAC,MAAM,iBAAiB,GAAG,qBAAqB,CAAC;AAEvD,qCAAqC;AACrC,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACpB,IAAI,GAAY,iBAAiB,CAAC;CACvD;AAED,MAAM,SAAS,GAAG,CAAC,IAAa,EAAW,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;AAE9F,gDAAgD;AAChD,MAAM,OAAO,UAAU;IACF,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;IAC7B,aAAa,GAAG,IAAI,GAAG,EAAU,CAAC;IAClC,WAAW,GAAG,IAAI,GAAG,EAA6B,CAAC;IACpE,2DAA2D;IAClD,KAAK,GAAiB,IAAI,GAAG,EAAU,CAAC;IACjD,kFAAkF;IACzE,KAAK,GAAiB,IAAI,GAAG,EAAU,CAAC;IAEjD,YAAY,OAAoC;QAC5C,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;YAC1B,MAAM,KAAK,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,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K,eAAe,CAAC,CAAC;IAClF,OAAO;QACH,IAAI;QACJ,GAAG,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC;QACrC,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC;QAC/C,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;QACzC,GAAG,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC;KAC1D,CAAC;AACN,CAAC;AAED,6CAA6C;AAC7C,MAAM,UAAU,cAAc,CAAC,IAAa;IACxC,IAAI,IAAa,CAAC;IAClB,IAAI,CAAC;QACD,IAAI,GAAG,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACtC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,MAAM,IAAI,eAAe,CAAC,mCAAmC,IAAI,KAAM,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;IACtG,CAAC;IACD,IAAI,KAAe,CAAC;IACpB,IAAI,CAAC;QACD,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,MAAM,IAAI,eAAe,CAAC,GAAG,IAAI,iCAAkC,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;IAClG,CAAC;IACD,OAAO,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AACxC,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * File discovery: glob patterns to files.
3
+ *
4
+ * The glob syntax:
5
+ *
6
+ * - `*` matches characters in one path segment
7
+ * - `**` matches zero or more segments
8
+ * - `?` matches one character
9
+ * - `{a,b}` matches one of the alternatives
10
+ * - `[abc]` or `[!abc]` matches one character of a set.
11
+ *
12
+ * Patterns use `/` on all platforms. An absolute pattern is also correct.
13
+ */
14
+ /** True when `pattern` has glob characters. */
15
+ export declare function isGlob(pattern: string): boolean;
16
+ /** This function converts a glob pattern to a regular expression that matches a whole relative path. */
17
+ export declare function globToRegExp(glob: string): RegExp;
18
+ /** The part of a pattern before the first segment with glob characters. The walk starts in that directory. */
19
+ export declare function globBase(glob: string): string;
20
+ export type FindOptions = {
21
+ /** The directory that the include patterns are relative to. */
22
+ readonly root: string;
23
+ readonly include: readonly string[];
24
+ readonly ignore: readonly string[];
25
+ /** The directory that the ignore patterns are relative to. The default is `root`. */
26
+ readonly ignoreRoot?: string;
27
+ };
28
+ /**
29
+ * This function finds the files that match the include patterns and no
30
+ * ignore pattern. A pattern without glob characters is a file name, and
31
+ * the ignore patterns do not apply to it. The result has absolute paths,
32
+ * in sorted order, without duplicates.
33
+ */
34
+ export declare function findFiles(options: FindOptions): string[];
35
+ //# sourceMappingURL=files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../src/files.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAOH,+CAA+C;AAC/C,wBAAgB,MAAM,CAAC,OAAO,EAAG,MAAM,GAAI,OAAO,CAEjD;AAuFD,wGAAwG;AACxG,wBAAgB,YAAY,CAAC,IAAI,EAAG,MAAM,GAAI,MAAM,CAGnD;AAED,8GAA8G;AAC9G,wBAAgB,QAAQ,CAAC,IAAI,EAAG,MAAM,GAAI,MAAM,CAQ/C;AAeD,MAAM,MAAM,WAAW,GAAG;IACtB,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAG,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAG,SAAS,MAAM,EAAE,CAAC;IACrC,QAAQ,CAAC,MAAM,EAAG,SAAS,MAAM,EAAE,CAAC;IACpC,qFAAqF;IACrF,QAAQ,CAAC,UAAU,CAAC,EAAG,MAAM,CAAC;CACjC,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAG,WAAW,GAAI,MAAM,EAAE,CAoC1D"}