@mark1russell7/ste-lint 0.0.0-stage → 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 +225 -2
  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 +46 -3
  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
@@ -0,0 +1,35 @@
1
+ import { type InlineText, type Placeholder } from "../source/inline.js";
2
+ export type TokenKind = "word" | "code" | "punct";
3
+ export type Token = {
4
+ readonly kind: TokenKind;
5
+ /** The surface text. For a placeholder, the text in the code span, link tag or quote. */
6
+ readonly text: string;
7
+ /** The text in lower case, with typographic apostrophes changed to `'`. */
8
+ readonly lower: string;
9
+ /** The file offset of the first character. */
10
+ readonly start: number;
11
+ /** The file offset after the last character. */
12
+ readonly end: number;
13
+ /** True when white space comes before the token in the clean text. */
14
+ readonly spaceBefore: boolean;
15
+ readonly placeholder: Placeholder | null;
16
+ };
17
+ /** This function divides clean text into word, code and punctuation tokens. */
18
+ export declare function tokenize(inline: InlineText): Token[];
19
+ /** The lower-case form of a word, with typographic apostrophes changed to `'`. */
20
+ export declare function normalizeWord(text: string): string;
21
+ export declare function isWord(token: Token | undefined): token is Token;
22
+ /** True for a word or a placeholder. Both count in the STE word count. */
23
+ export declare function isCounted(token: Token | undefined): boolean;
24
+ export declare function isNumber(token: Token | undefined): boolean;
25
+ /** True for an abbreviation in capital letters, for example `API`, `CPUs` or `HTTP2`. */
26
+ export declare function isAbbreviation(token: Token | undefined): boolean;
27
+ /** True when the first character is a capital letter. */
28
+ export declare function isCapitalized(token: Token | undefined): boolean;
29
+ /**
30
+ * True for a word that looks like code although it is not in code font.
31
+ * Examples are a camelCase or snake_case name, a path with dots or slashes,
32
+ * a flag, a word with digits, and a name with `()`.
33
+ */
34
+ export declare function isIdentifierLike(token: Token | undefined):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AAgB,aAAa,CAAC,KAAK,EAAG,KAAK,GAAG,SAAS,GAAI,OAAO,CAEjE;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAG,KAAK,GAAG,SAAS,GAAI,OAAO,CAUpE"}
@@ -0,0 +1,113 @@
1
+ import { PLACEHOLDER } from "../source/inline.js";
2
+ import { NUMBER_WORDS } from "./words.js";
3
+ /**
4
+ * One word: letters and digits, with hyphens, dots, slashes, underscores,
5
+ * colons and apostrophes inside it. Thus `main-thread`, `I/O`, `e.g`,
6
+ * `v1.2.3`, `snake_case`, `don't`, `1,000` and `packages/lag` are each one word. A
7
+ * word can start with `--`, `-`, `@`, `#` or `$` (flags, scoped packages,
8
+ * issue numbers, variables), and it can end with `()`.
9
+ */
10
+ const WORD = /(?:--?|[@#$])?[\p{L}\p{N}][\p{L}\p{N}\p{M}]*(?:(?:['’](?=\p{L})|[-_./:+@#\\](?=[\p{L}\p{N}])|(?<=\p{N})–(?=\p{N})|(?<=\p{N}),(?=\p{N}{3}(?!\p{N})))[\p{L}\p{N}\p{M}]*)*(?:\(\))?/uy;
11
+ const CHAR = /./suy;
12
+ /** This function divides clean text into word, code and punctuation tokens. */
13
+ export function tokenize(inline) {
14
+ const { clean, offsets, placeholders } = inline;
15
+ const tokens = [];
16
+ let i = 0;
17
+ let space = true;
18
+ while (i < clean.length) {
19
+ const char = clean[i];
20
+ if (/\s/.test(char)) {
21
+ space = true;
22
+ i++;
23
+ continue;
24
+ }
25
+ if (char === PLACEHOLDER) {
26
+ const placeholder = placeholders.get(i);
27
+ if (placeholder !== undefined) {
28
+ tokens.push({
29
+ kind: "code",
30
+ text: placeholder.text,
31
+ lower: normalizeWord(placeholder.text),
32
+ start: placeholder.start,
33
+ end: placeholder.end,
34
+ spaceBefore: space,
35
+ placeholder,
36
+ });
37
+ space = false;
38
+ i++;
39
+ continue;
40
+ }
41
+ }
42
+ WORD.lastIndex = i;
43
+ const word = WORD.exec(clean);
44
+ let text;
45
+ let kind;
46
+ if (word !== null) {
47
+ text = word[0];
48
+ kind = "word";
49
+ }
50
+ else if (clean.startsWith("...", i)) {
51
+ text = "...";
52
+ kind = "punct";
53
+ }
54
+ else {
55
+ CHAR.lastIndex = i;
56
+ text = CHAR.exec(clean)[0];
57
+ kind = "punct";
58
+ }
59
+ tokens.push({
60
+ kind,
61
+ text,
62
+ lower: normalizeWord(text),
63
+ start: offsets[i],
64
+ end: offsets[i + text.length - 1] + 1,
65
+ spaceBefore: space,
66
+ placeholder: null,
67
+ });
68
+ space = false;
69
+ i += text.length;
70
+ }
71
+ return tokens;
72
+ }
73
+ /** The lower-case form of a word, with typographic apostrophes changed to `'`. */
74
+ export function normalizeWord(text) {
75
+ return text.toLowerCase().replace(/[’‘]/g, "'");
76
+ }
77
+ export function isWord(token) {
78
+ return token !== undefined && token.kind === "word";
79
+ }
80
+ /** True for a word or a placeholder. Both count in the STE word count. */
81
+ export function isCounted(token) {
82
+ return token !== undefined && token.kind !== "punct";
83
+ }
84
+ export function isNumber(token) {
85
+ return isWord(token) && (/^[-+]?\d[\d,.–-]*%?$/.test(token.text) || NUMBER_WORDS.has(token.lower));
86
+ }
87
+ /** True for an abbreviation in capital letters, for example `API`, `CPUs` or `HTTP2`. */
88
+ export function isAbbreviation(token) {
89
+ return isWord(token) && /^[A-Z][A-Z0-9]+s?$/.test(token.text) && /[A-Z].*[A-Z]|^[A-Z][0-9]/.test(token.text);
90
+ }
91
+ /** True when the first character is a capital letter. */
92
+ export function isCapitalized(token) {
93
+ return isWord(token) && /^\p{Lu}/u.test(token.text);
94
+ }
95
+ /**
96
+ * True for a word that looks like code although it is not in code font.
97
+ * Examples are a camelCase or snake_case name, a path with dots or slashes,
98
+ * a flag, a word with digits, and a name with `()`.
99
+ */
100
+ export function isIdentifierLike(token) {
101
+ if (!isWord(token))
102
+ return false;
103
+ const text = token.text;
104
+ if (/^(?:e\.g|i\.e|u\.s|a\.m|p\.m)$/i.test(text))
105
+ return false;
106
+ return /\p{Ll}\p{Lu}/u.test(text)
107
+ || /\p{Lu}{2,}\p{Ll}/u.test(text)
108
+ || /[_./\\:@#$]/.test(text)
109
+ || /^--?/.test(text)
110
+ || text.endsWith("()")
111
+ || (/\d/.test(text) && /\p{L}/u.test(text));
112
+ }
113
+ //# sourceMappingURL=tokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../src/text/tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAqC,MAAM,qBAAqB,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAmB1C;;;;;;GAMG;AACH,MAAM,IAAI,GAAG,oLAAoL,CAAC;AAElM,MAAM,IAAI,GAAG,MAAM,CAAC;AAEpB,+EAA+E;AAC/E,MAAM,UAAU,QAAQ,CAAC,MAAmB;IACxC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,MAAM,CAAC;IAChD,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,IAAI,KAAK,GAAG,IAAI,CAAC;IACjB,OAAO,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;QACtB,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAE,CAAC;QACvB,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAClB,KAAK,GAAG,IAAI,CAAC;YACb,CAAC,EAAE,CAAC;YACJ,SAAS;QACb,CAAC;QACD,IAAI,IAAI,KAAK,WAAW,EAAE,CAAC;YACvB,MAAM,WAAW,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACxC,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;gBAC5B,MAAM,CAAC,IAAI,CAAC;oBACR,IAAI,EAAG,MAAM;oBACb,IAAI,EAAG,WAAW,CAAC,IAAI;oBACvB,KAAK,EAAG,aAAa,CAAC,WAAW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,CAAC;QAAE,OAAO,KAAK,CAAC;IAC/D,OAAO,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC;WAC1B,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC;WAC9B,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC;WACxB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;WACjB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;WACnB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AACpD,CAAC"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Closed word classes and short word lists for the grammar heuristics.
3
+ *
4
+ * These lists are general English grammar. They do not come from the
5
+ * ASD-STE100 dictionary. The linter cannot tag parts of speech, so the
6
+ * heuristics look at the words near a word to guess how the text uses it.
7
+ */
8
+ export declare const DETERMINERS: ReadonlySet<string>;
9
+ export declare const SUBJECT_PRONOUNS: ReadonlySet<string>;
10
+ export declare const OBJECT_PRONOUNS: ReadonlySet<string>;
11
+ /** Forms of "be", with the contractions that contain "is", "are" or "am". */
12
+ export declare const BE_FORMS: ReadonlySet<string>;
13
+ /** Words before a past participle that make a passive: forms of "be" and "get". */
14
+ export declare const PASSIVE_AUXILIARIES: ReadonlySet<string>;
15
+ export declare const HAVE_FORMS: ReadonlySet<string>;
16
+ export declare const DO_FORMS: ReadonlySet<string>;
17
+ export declare const MODALS: ReadonlySet<string>;
18
+ export declare const PREPOSITIONS: ReadonlySet<string>;
19
+ export declare const CONJUNCTIONS: ReadonlySet<string>;
20
+ /** Words that start a condition or purpose clause before the main clause. */
21
+ export declare const CLAUSE_STARTERS: ReadonlySet<string>;
22
+ /** Words that can come before the verb of an imperative sentence. */
23
+ export declare const LEADING_ADVERBS: ReadonlySet<string>;
24
+ /** Adverbs that can come between an auxiliary verb and a participle. */
25
+ export declare const MIDDLE_ADVERBS: ReadonlySet<string>;
26
+ /** Words that tell the reader that a clause is a condition, so a participle after "be" is a state. */
27
+ export declare const CONDITION_MARKERS: ReadonlySet<string>;
28
+ export declare const PARTICLES: ReadonlySet<string>;
29
+ export declare const NUMBER_WORDS: ReadonlySet<string>;
30
+ /** Units of measurement. A number and its unit count as one word (STE Rule 8.6). */
31
+ export declare const UNITS: ReadonlySet<string>;
32
+ /**
33
+ * Words that end in "-ing" but are usually not verb forms: nouns, adjectives,
34
+ * prepositions, and base forms, for example "bring".
35
+ */
36
+ export declare const NON_VERB_ING: ReadonlySet<string>;
37
+ /** Irregular past participles. A participle after "be" makes a passive. */
38
+ export declare const IRREGULAR_PARTICIPLES: ReadonlySet<string>;
39
+ /** Words that end in "-ed" but are not past participles. */
40
+ export declare const NOT_PARTICIPLE_ED: ReadonlySet<string>;
41
+ /**
42
+ * Common verbs in their base form. The imperative heuristic and the
43
+ * missing-subject heuristic use this list. The project glossary adds
44
+ * technical verbs to it.
45
+ */
46
+ export declare const COMMON_VERBS: ReadonlySet<string>;
47
+ /**
48
+ * Nouns that software text often uses before another noun. The noun-cluster
49
+ * heuristic counts only these words, technical nouns, proper nouns,
50
+ * abbreviations and code. Words that are frequently verbs are not in this
51
+ * list, so the heuristic does not count a verb as a noun.
52
+ */
53
+ export declare const COMMON_NOUNS: ReadonlySet<string>;
54
+ /** Abbreviations after which a period does not end a sentence. */
55
+ export declare const NO_BREAK_ABBREVIATIONS: ReadonlySet<string>;
56
+ /** Abbreviations that do not end a sentence when a number comes after them, for example "Fig. 3". */
57
+ export declare const NUMBER_ABBREVIATIONS: ReadonlySet<string>;
58
+ //# sourceMappingURL=words.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"words.d.ts","sourceRoot":"","sources":["../../src/text/words.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,eAAO,MAAM,WAAW,EAAG,WAAW,CAAC,MAAM,CAG3C,CAAC;AAEH,eAAO,MAAM,gBAAgB,EAAG,WAAW,CAAC,MAAM,CAA4D,CAAC;AAE/G,eA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AW,CAAC,MAAM,CAGjD,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAG,WAAW,CAAC,MAAM,CAuB5C,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAG,WAAW,CAAC,MAAM,CAmB5C,CAAC;AAEH,kEAAkE;AAClE,eAAO,MAAM,sBAAsB,EAAG,WAAW,CAAC,MAAM,CAEtD,CAAC;AAEH,qGAAqG;AACrG,eAAO,MAAM,oBAAoB,EAAG,WAAW,CAAC,MAAM,CAA0D,CAAC"}
@@ -0,0 +1,159 @@
1
+ /**
2
+ * Closed word classes and short word lists for the grammar heuristics.
3
+ *
4
+ * These lists are general English grammar. They do not come from the
5
+ * ASD-STE100 dictionary. The linter cannot tag parts of speech, so the
6
+ * heuristics look at the words near a word to guess how the text uses it.
7
+ */
8
+ const set = (words) => new Set(words.trim().split(/\s+/));
9
+ export const DETERMINERS = set(`
10
+ a an the this that these those each every all any some no its their your our my his her
11
+ another other either neither both many much more most few several such which whose what one
12
+ `);
13
+ export const SUBJECT_PRONOUNS = set("i you we they he she it this that which who there");
14
+ export const OBJECT_PRONOUNS = set("me you us them him her it itself themselves this these those");
15
+ /** Forms of "be", with the contractions that contain "is", "are" or "am". */
16
+ export const BE_FORMS = set(`
17
+ am is are was were be been being isn't aren't wasn't weren't it's that's there's here's what's who's
18
+ he's she's they're we're you're i'm
19
+ `);
20
+ /** Words before a past participle that make a passive: forms of "be" and "get". */
21
+ export const PASSIVE_AUXILIARIES = new Set([...BE_FORMS, "get", "gets", "got", "gotten", "getting"]);
22
+ export const HAVE_FORMS = set("have has had having haven't hasn't hadn't");
23
+ export const DO_FORMS = set("do does did don't doesn't didn't");
24
+ export const MODALS = set(`
25
+ can cannot could may might must shall should will would can't couldn't mustn't shouldn't won't wouldn't
26
+ `);
27
+ export const PREPOSITIONS = set(`
28
+ about above across after against along among around as at before behind below beneath beside between
29
+ beyond by despite down during except for from in inside into like near of off on onto out outside over
30
+ past per since through throughout to toward towards under until up upon via with within without
31
+ `);
32
+ export const CONJUNCTIONS = set(`
33
+ and or but nor so yet if when while because although though unless until whether that where once than
34
+ `);
35
+ /** Words that start a condition or purpose clause before the main clause. */
36
+ export const CLAUSE_STARTERS = set(`
37
+ if when whenever before after while until unless once to for in on at during because as since where
38
+ with without by from although though
39
+ `);
40
+ /** Words that can come before the verb of an imperative sentence. */
41
+ export const LEADING_ADVERBS = set(`
42
+ then first next also finally optionally now please second third afterward afterwards alternatively
43
+ instead always only just simply again manually carefully immediately
44
+ `);
45
+ /** Adverbs that can come between an auxiliary verb and a participle. */
46
+ export const MIDDLE_ADVERBS = set(`
47
+ not also always never only then still already often usually automatically immediately sometimes just
48
+ all both each first again correctly currently directly fully later normally now once possibly
49
+ probably quickly rarely really safely silently simply successfully typically
50
+ `);
51
+ /** Words that tell the reader that a clause is a condition, so a participle after "be" is a state. */
52
+ export const CONDITION_MARKERS = set(`
53
+ if when whenever until unless while after before once whether sure that because since
54
+ `);
55
+ export const PARTICLES = set("up out down off back over away");
56
+ export const NUMBER_WORDS = set(`
57
+ zero one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen
58
+ seventeen eighteen nineteen twenty thirty forty fifty sixty seventy eighty ninety hundred hundreds
59
+ thousand thousands million millions billion billions dozen dozens half twice
60
+ `);
61
+ /** Units of measurement. A number and its unit count as one word (STE Rule 8.6). */
62
+ export const UNITS = set(`
63
+ ns µs μs us ms s sec secs second seconds millisecond milliseconds microsecond microseconds nanosecond
64
+ nanoseconds min mins minute minutes h hr hrs hour hours day days week weeks month months year years
65
+ b byte bytes kb mb gb tb kib mib gib tib kilobyte kilobytes megabyte megabytes gigabyte gigabytes
66
+ % percent px pixel pixels hz khz mhz ghz fps °c °f degree degrees kg g mm cm m km kilogram kilograms
67
+ gram grams kilometer kilometers liter liters litre litres inch inches
68
+ `);
69
+ /**
70
+ * Words that end in "-ing" but are usually not verb forms: nouns, adjectives,
71
+ * prepositions, and base forms, for example "bring".
72
+ */
73
+ export const NON_VERB_ING = set(`
74
+ thing things string strings ring rings spring springs king kings wing wings sing bring brings during
75
+ something anything everything nothing morning mornings evening evenings ceiling ceilings sibling
76
+ siblings duckling earring inkling offspring pudding sterling swing swings sling wring cling fling
77
+ sting
78
+ outstanding ongoing upcoming incoming outgoing missing remaining pending interesting confusing
79
+ misleading surprising promising demanding challenging exciting annoying boring willing worrying
80
+ overwhelming existing corresponding underlying trailing preceding notwithstanding
81
+ timing padding heading spacing wording warning beginning opening
82
+ `);
83
+ /** Irregular past participles. A participle after "be" makes a passive. */
84
+ export const IRREGULAR_PARTICIPLES = set(`
85
+ arisen awoken begun bent bitten blown bound broken brought built bought caught chosen cut dealt done
86
+ drawn driven eaten fallen fed felt fought found flown forbidden forgotten forgiven frozen gotten given
87
+ gone grown hung heard hidden hit held hurt kept known laid led left lent let lost made meant met paid
88
+ put quit read rebuilt reset rerun ridden rung risen run said seen sought sold sent set shaken shown
89
+ shut sung sunk slept slid spoken spent spun split spread stood stolen stuck struck sworn swept taken
90
+ taught torn told thought thrown undone understood unset upset withdrawn woken worn won wound written
91
+ overridden rewritten overwritten bitten
92
+ `);
93
+ /** Words that end in "-ed" but are not past participles. */
94
+ export const NOT_PARTICIPLE_ED = set(`
95
+ need needed bed red shed feed seed speed bleed breed deed embed exceed proceed succeed indeed hundred
96
+ kindred sacred naked wicked rugged ragged aged beloved learned
97
+ `);
98
+ /**
99
+ * Common verbs in their base form. The imperative heuristic and the
100
+ * missing-subject heuristic use this list. The project glossary adds
101
+ * technical verbs to it.
102
+ */
103
+ export const COMMON_VERBS = set(`
104
+ accept access activate add adjust allow apply assign attach avoid begin bind block break bring build
105
+ calculate call cancel capture change check choose clean clear click clone close collect combine commit
106
+ compare compile complete compute configure confirm connect consider contain continue control convert
107
+ copy correct count cover create deactivate debug decide declare decrease define delay delete deliver
108
+ depend deploy describe destroy detach detect determine disable disconnect discard dispatch display
109
+ dispose do download drag drop emit enable end enforce enqueue ensure enter estimate examine exclude
110
+ execute exit expand expect explain export expose extend extract fail fetch fill filter find finish fire
111
+ fix flag flush follow force forward freeze generate get give go grant group handle hold ignore implement
112
+ import include increase indicate initialize insert inspect install invoke keep kill launch leave let
113
+ limit link list listen load lock log look make manage map mark match measure merge migrate mock modify
114
+ monitor mount move name navigate need note notify observe obtain omit open operate override parse pass
115
+ paste pause perform pick pin place point poll post prefer prepare press prevent print process produce
116
+ provide publish pull push put queue read rebuild reboot receive record reduce refer refresh register
117
+ reject release reload remember remove rename render repeat replace report request require reschedule
118
+ reset resize resolve respond restart restore resume retry return reuse review revert rotate run sample
119
+ save schedule scroll search select send serve set share show shut sign skip sleep sort specify split
120
+ start stay step stop store submit subscribe substitute supply support swap switch sync take tap tell
121
+ terminate test throttle throw tick toggle touch track transform trigger try turn type uncomment
122
+ uninstall unlock unpin unregister unsubscribe update upgrade upload use validate verify view visit wait
123
+ wake warn watch wrap write yield
124
+ agree appear arrive ask become belong come differ exist happen help know occur overlap reach remain
125
+ seem survive think want
126
+ `);
127
+ /**
128
+ * Nouns that software text often uses before another noun. The noun-cluster
129
+ * heuristic counts only these words, technical nouns, proper nouns,
130
+ * abbreviations and code. Words that are frequently verbs are not in this
131
+ * list, so the heuristic does not count a verb as a noun.
132
+ */
133
+ export const COMMON_NOUNS = set(`
134
+ attribute browser buffer bucket byte cache callback channel chart clock collector column component config
135
+ configuration console constructor container context counter dashboard data database delay dependency
136
+ deployment device dialog directory document domain duration element endpoint entry environment error
137
+ event exception exporter factory field file folder frame framework function gauge handler hardware
138
+ header heap heartbeat histogram history host id identifier index input instance interface interval item
139
+ key keyboard label latency layer layout length level library lifecycle line listener logger loop
140
+ machine memory message meter method metric millisecond mode model module monitor mouse network node
141
+ number object observer offset option origin output owner package page pair parameter parser path
142
+ pattern payload percentile period permission phase pipeline platform plugin pointer policy pool port
143
+ position pressure priority problem procedure processor profile program project promise property protocol
144
+ provider proxy quantity query range rate ratio reader reason receiver recorder reference region registry
145
+ renderer repository resolution resource response router runtime scheduler schema scope screen script
146
+ second section selector sender sequence server service session setting signal size slot snapshot socket
147
+ source span stack stage standard state statement status storage stream string structure style
148
+ subscriber suite summary symbol syntax system tab table target task template terminal text thread
149
+ threshold time timeout timer timestamp title token tool topic trace transaction transport tree tuple
150
+ unit url usage user utility validator value variable vendor version viewport visibility warning window
151
+ worker workspace wrapper
152
+ `);
153
+ /** Abbreviations after which a period does not end a sentence. */
154
+ export const NO_BREAK_ABBREVIATIONS = set(`
155
+ e.g i.e vs viz cf al approx mr mrs dr st jr sr inc ltd corp u.s a.m p.m
156
+ `);
157
+ /** Abbreviations that do not end a sentence when a number comes after them, for example "Fig. 3". */
158
+ export const NUMBER_ABBREVIATIONS = set("fig figs eq eqs no nos ref vol ch pp p sec para");
159
+ //# sourceMappingURL=words.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"words.js","sourceRoot":"","sources":["../../src/text/words.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,GAAG,GAAG,CAAC,KAAc,EAAwB,EAAE,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;AAEzF,MAAM,CAAC,MAAM,WAAW,GAAyB,GAAG,CAAC;;;CAGpD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAyB,GAAG,CAAC,mDAAmD,CAAC,CAAC;AAE/G,MAAM,CAAC,MAAM,eAAe,GAAyB,GAAG,CAAC,8DAA8D,CAAC,CAAC;AAEzH,6EAA6E;AAC7E,MAAM,CAAC,MAAM,QAAQ,GAAyB,GAAG,CAAC;;;CAGjD,CAAC,CAAC;AAEH,mFAAmF;AACnF,MAAM,CAAC,MAAM,mBAAmB,GAAyB,IAAI,GAAG,CAAC,CAAC,GAAG,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;AAE3H,MAAM,CAAC,MAAM,UAAU,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,CAAC;;;;;;;;;;;;;;;;;;;;;;;CAuBrD,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAyB,GAAG,CAAC;;;;;;;;;;;;;;;;;;;CAmBrD,CAAC,CAAC;AAEH,kEAAkE;AAClE,MAAM,CAAC,MAAM,sBAAsB,GAAyB,GAAG,CAAC;;CAE/D,CAAC,CAAC;AAEH,qGAAqG;AACrG,MAAM,CAAC,MAAM,oBAAoB,GAAyB,GAAG,CAAC,iDAAiD,CAAC,CAAC"}
@@ -0,0 +1,18 @@
1
+ export type Severity = "error" | "warning";
2
+ /** The setting of a rule in `ste.config.json`. */
3
+ export type RuleSetting = Severity | "off";
4
+ export declare const RULE_IDS: readonly ["sentence-length", "paragraph-length", "modal-verb", "semicolon", "latin-abbreviation", "about-quantity", "word-list", "gendered-pronoun", "first-person", "passive-instruction", "noun-cluster", "missing-subject", "ing-verb", "unknown-word"];
5
+ export type RuleId = (typeof RULE_IDS)[number];
6
+ /** One problem that the linter found. Lines and columns start at 1. */
7
+ export type Finding = {
8
+ readonly file: string;
9
+ readonly line: number;
10
+ readonly column: number;
11
+ readonly endLine: number;
12
+ readonly endColumn: number;
13
+ readonly ruleId: RuleId;
14
+ readonly severity: Severity;
15
+ readonly message: string;
16
+ };
17
+ export declare function isRuleId(value: string): value is RuleId;
18
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAC;AAE3C,kDAAkD;AAClD,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,KAAK,CAAC;AAE3C,eAAO,MAAM,QAAQ,4PAeX,CAAC;AAEX,MAAM,MAAM,MAAM,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/C,uEAAuE;AACvE,MAAM,MAAM,OAAO,GAAG;IAClB,QAAQ,CAAC,IAAI,EAAG,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAG,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAG,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAG,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAG,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAG,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAG,QAAQ,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAG,MAAM,CAAC;CAC7B,CAAC;AAEF,wBAAgB,QAAQ,CAAC,KAAK,EAAG,MAAM,GAAI,KAAK,IAAI,MAAM,CAEzD"}
package/dist/types.js ADDED
@@ -0,0 +1,20 @@
1
+ export const RULE_IDS = [
2
+ "sentence-length",
3
+ "paragraph-length",
4
+ "modal-verb",
5
+ "semicolon",
6
+ "latin-abbreviation",
7
+ "about-quantity",
8
+ "word-list",
9
+ "gendered-pronoun",
10
+ "first-person",
11
+ "passive-instruction",
12
+ "noun-cluster",
13
+ "missing-subject",
14
+ "ing-verb",
15
+ "unknown-word",
16
+ ];
17
+ export function isRuleId(value) {
18
+ return RULE_IDS.includes(value);
19
+ }
20
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,QAAQ,GAAG;IACpB,iBAAiB;IACjB,kBAAkB;IAClB,YAAY;IACZ,WAAW;IACX,oBAAoB;IACpB,gBAAgB;IAChB,WAAW;IACX,kBAAkB;IAClB,cAAc;IACd,qBAAqB;IACrB,cAAc;IACd,iBAAiB;IACjB,UAAU;IACV,cAAc;CACR,CAAC;AAgBX,MAAM,UAAU,QAAQ,CAAC,KAAc;IACnC,OAAQ,QAA8B,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC3D,CAAC"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Prose units: the blocks of text that the rules examine, with their tokens
3
+ * and sentences.
4
+ */
5
+ import type { Lexicon } from "./lexicon.js";
6
+ import type { ListContext, ProseBlock } from "./source/blocks.js";
7
+ import { type Token } from "./text/tokens.js";
8
+ export type TsdocSection = "summary" | "remarks" | "tag";
9
+ /** Where a block comes from. */
10
+ export type BlockOrigin = {
11
+ readonly source: "markdown" | "mdx" | "tsdoc" | "jsx";
12
+ /** For a doc comment: the summary, the `@remarks` section, or the text of another block tag. */
13
+ readonly tsdocSection: TsdocSection | null;
14
+ /** For a doc comment: the block tag, for example `@param`, or null for the summary. */
15
+ readonly tsdocTag: string | null;
16
+ };
17
+ export type ExtractedBlock = {
18
+ readonly block: ProseBlock;
19
+ readonly origin: BlockOrigin;
20
+ };
21
+ export type Sentence = {
22
+ /** All tokens of the sentence, with the punctuation. */
23
+ readonly tokens: readonly Token[];
24
+ /** The STE word count. */
25
+ readonly words: number;
26
+ /** The tokens in each top-level parenthesis. Each one counts as a separate sentence. */
27
+ readonly parentheticals: readonly (readonly Token[])[];
28
+ /** True when the sentence is an instruction (imperative). */
29
+ readonly instruction: boolean;
30
+ readonly start: number;
31
+ readonly end: number;
32
+ };
33
+ export type UnitKind = ProseBlock["kind"];
34
+ export type ProseUnit = {
35
+ readonly kind: UnitKind;
36
+ readonly origin: BlockOrigin;
37
+ readonly list: ListContext | null;
38
+ readonly tokens: readonly Token[];
39
+ readonly sentences: readonly Sentence[];
40
+ readonly start: number;
41
+ readonly end: number;
42
+ };
43
+ /** This function makes a prose unit from a block. The result is null when the block has no words. */
44
+ export declare function buildUnit(extracted: ExtractedBlock, lexicon: Lexicon): ProseUnit | null;
45
+ /** This function makes a prose unit from the tokens of a block. */
46
+ export declare function unitFromTokens(tokens: readonly Token[], block: Pick<ProseBlock, "kind" | "list">, origin: BlockOrigin, lexicon: Lexicon): ProseUnit | null;
47
+ //# sourceMappingURL=units.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"units.d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AQ,CAAC,IAAI,EAAG,QAAQ,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAG,WAAW,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAG,WAAW,GAAG,IAAI,CAAC;IACnC,QAAQ,CAAC,MAAM,EAAG,SAAS,KAAK,EAAE,CAAC;IACnC,QAAQ,CAAC,SAAS,EAAG,SAAS,QAAQ,EAAE,CAAC;IACzC,QAAQ,CAAC,KAAK,EAAG,MAAM,CAAC;IACxB,QAAQ,CAAC,GAAG,EAAG,MAAM,CAAC;CACzB,CAAC;AAEF,qGAAqG;AACrG,wBAAgB,SAAS,CAAC,SAAS,EAAG,cAAc,EAAE,OAAO,EAAG,OAAO,GAAI,SAAS,GAAG,IAAI,CAI1F;AAED,mEAAmE;AACnE,wBAAgB,cAAc,CAAC,MAAM,EAAG,SAAS,KAAK,EAAE,EAAE,KAAK,EAAG,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC,EAAE,MAAM,EAAG,WAAW,EAAE,OAAO,EAAG,OAAO,GAAI,SAAS,GAAG,IAAI,CAwB/J"}
package/dist/units.js ADDED
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Prose units: the blocks of text that the rules examine, with their tokens
3
+ * and sentences.
4
+ */
5
+ import { normalizeInline } from "./source/inline.js";
6
+ import { isInstruction } from "./text/grammar.js";
7
+ import { countWords, splitSentences } from "./text/sentences.js";
8
+ import { isCounted, tokenize } from "./text/tokens.js";
9
+ /** This function makes a prose unit from a block. The result is null when the block has no words. */
10
+ export function buildUnit(extracted, lexicon) {
11
+ const { block, origin } = extracted;
12
+ const inline = normalizeInline(block.lines, { mdx: origin.source === "mdx" || origin.source === "jsx", tsdoc: origin.source === "tsdoc" });
13
+ return unitFromTokens(tokenize(inline), block, origin, lexicon);
14
+ }
15
+ /** This function makes a prose unit from the tokens of a block. */
16
+ export function unitFromTokens(tokens, block, origin, lexicon) {
17
+ if (!tokens.some(isCounted))
18
+ return null;
19
+ const ranges = block.kind === "paragraph" ? splitSentences(tokens) : [{ from: 0, to: tokens.length }];
20
+ const sentences = ranges.map((range) => {
21
+ const sentenceTokens = tokens.slice(range.from, range.to);
22
+ const count = countWords(sentenceTokens, { properNouns: lexicon.properNounPhrases });
23
+ return {
24
+ tokens: sentenceTokens,
25
+ words: count.words,
26
+ parentheticals: count.parentheticals,
27
+ instruction: block.kind === "paragraph" && isInstruction(sentenceTokens, { verbs: lexicon.verbs }),
28
+ start: sentenceTokens[0].start,
29
+ end: sentenceTokens[sentenceTokens.length - 1].end,
30
+ };
31
+ });
32
+ return {
33
+ kind: block.kind,
34
+ origin,
35
+ list: block.list,
36
+ tokens,
37
+ sentences,
38
+ start: tokens[0].start,
39
+ end: tokens[tokens.length - 1].end,
40
+ };
41
+ }
42
+ //# sourceMappingURL=units.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"units.js","sourceRoot":"","sources":["../src/units.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAc,MAAM,kBAAkB,CAAC;AA2CnE,qGAAqG;AACrG,MAAM,UAAU,SAAS,CAAC,SAA0B,EAAE,OAAiB;IACnE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IACpC,MAAM,MAAM,GAAG,eAAe,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE,GAAG,EAAG,MAAM,CAAC,MAAM,KAAK,KAAK,IAAI,MAAM,CAAC,MAAM,KAAK,KAAK,EAAE,KAAK,EAAG,MAAM,CAAC,MAAM,KAAK,OAAO,EAAE,CAAC,CAAC;IAC7I,OAAO,cAAc,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,MAA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CAAC,CAAE,CAAC,KAAK;QACxB,GAAG,EAAG,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAE,CAAC,GAAG;KACvC,CAAC;AACN,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * The project word list: plain-language substitutions for the documentation
3
+ * of this repository. This list is the style guide of the project, written
4
+ * for it. It is not a copy of the ASD-STE100 dictionary. The local
5
+ * dictionary file (refer to `dictionary.ts`) does that job, and it is not
6
+ * part of the repository at any time.
7
+ *
8
+ * Each entry has the words or phrases to find, the words to write instead,
9
+ * and a severity. `ste.config.json` can add entries, change them, or set an
10
+ * entry to "off".
11
+ */
12
+ import type { Severity } from "./types.js";
13
+ export type WordListEntry = {
14
+ /** A short name of the entry. A configuration entry with the same ID changes this entry. */
15
+ readonly id: string;
16
+ /** The words and phrases to find. The match ignores case. */
17
+ readonly match: readonly string[];
18
+ /** The words to write instead, as the message shows them. Null when the fix is to remove the word. */
19
+ readonly suggest: string | null;
20
+ /** More help for the message, or null. */
21
+ readonly note: string | null;
22
+ readonly severity: Severity;
23
+ /**
24
+ * True when the word can be a noun too. Then the rule reports the word
25
+ * only when the words near it show a verb ("Run the tests", but not "a
26
+ * test run").
27
+ */
28
+ readonly verbOnly: boolean;
29
+ /** A special context: "reference" finds "see" only where it tells the reader to look at other text. */
30
+ readonly context: "reference" | null;
31
+ };
32
+ /** The default word list. */
33
+ export declare const DEFAULT_WORD_LIST: readonly WordListEntry[];
34
+ //# sourceMappingURL=word-list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"word-list.d.ts","sourceRoot":"","sources":["../src/word-list.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,MAAM,aAAa,GAAG;IACxB,4FAA4F;IAC5F,QAAQ,CAAC,EAAE,EAAG,MAAM,CAAC;IACrB,6DAA6D;IAC7D,QAAQ,CAAC,KAAK,EAAG,SAAS,MAAM,EAAE,CAAC;IACnC,sGAAsG;IACtG,QAAQ,CAAC,OAAO,EAAG,MAAM,GAAG,IAAI,CAAC;IACjC,0CAA0C;IAC1C,QAAQ,CAAC,IAAI,EAAG,MAAM,GAAG,IAAI,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAG,QAAQ,CAAC;IAC7B;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,EAAG,OAAO,CAAC;IAC5B,uGAAuG;IACvG,QAAQ,CAAC,OAAO,EAAG,WAAW,GAAG,IAAI,CAAC;CACzC,CAAC;AAwBF,6BAA6B;AAC7B,eAAO,MAAM,iBAAiB,EAAG,SAAS,aAAa,EAsEtD,CAAC"}