@khanacademy/perseus-linter 0.3.1 → 0.3.2

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 (55) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/es/index.js +15 -20
  3. package/dist/es/index.js.map +1 -1
  4. package/dist/index.js +15 -20
  5. package/dist/index.js.map +1 -1
  6. package/dist/tree-transformer.d.ts +1 -1
  7. package/package.json +2 -2
  8. package/src/__tests__/matcher.test.ts +57 -57
  9. package/src/__tests__/rules.test.ts +62 -62
  10. package/src/__tests__/tree-transformer.test.ts +5 -5
  11. package/src/index.ts +4 -4
  12. package/src/rule.ts +2 -2
  13. package/src/tree-transformer.ts +9 -13
  14. package/tsconfig-build.json +11 -0
  15. package/{tsconfig.tsbuildinfo → tsconfig-build.tsbuildinfo} +1 -1
  16. package/dist/index.js.flow +0 -18
  17. package/dist/proptypes.js.flow +0 -17
  18. package/dist/rule.js.flow +0 -86
  19. package/dist/rules/absolute-url.js.flow +0 -9
  20. package/dist/rules/all-rules.js.flow +0 -9
  21. package/dist/rules/blockquoted-math.js.flow +0 -9
  22. package/dist/rules/blockquoted-widget.js.flow +0 -9
  23. package/dist/rules/double-spacing-after-terminal.js.flow +0 -9
  24. package/dist/rules/extra-content-spacing.js.flow +0 -9
  25. package/dist/rules/heading-level-1.js.flow +0 -9
  26. package/dist/rules/heading-level-skip.js.flow +0 -9
  27. package/dist/rules/heading-sentence-case.js.flow +0 -9
  28. package/dist/rules/heading-title-case.js.flow +0 -9
  29. package/dist/rules/image-alt-text.js.flow +0 -9
  30. package/dist/rules/image-in-table.js.flow +0 -9
  31. package/dist/rules/image-spaces-around-urls.js.flow +0 -9
  32. package/dist/rules/image-widget.js.flow +0 -9
  33. package/dist/rules/link-click-here.js.flow +0 -9
  34. package/dist/rules/lint-utils.js.flow +0 -8
  35. package/dist/rules/long-paragraph.js.flow +0 -9
  36. package/dist/rules/math-adjacent.js.flow +0 -9
  37. package/dist/rules/math-align-extra-break.js.flow +0 -9
  38. package/dist/rules/math-align-linebreaks.js.flow +0 -9
  39. package/dist/rules/math-empty.js.flow +0 -9
  40. package/dist/rules/math-font-size.js.flow +0 -9
  41. package/dist/rules/math-frac.js.flow +0 -9
  42. package/dist/rules/math-nested.js.flow +0 -9
  43. package/dist/rules/math-starts-with-space.js.flow +0 -9
  44. package/dist/rules/math-text-empty.js.flow +0 -9
  45. package/dist/rules/math-without-dollars.js.flow +0 -9
  46. package/dist/rules/nested-lists.js.flow +0 -9
  47. package/dist/rules/profanity.js.flow +0 -9
  48. package/dist/rules/table-missing-cells.js.flow +0 -9
  49. package/dist/rules/unbalanced-code-delimiters.js.flow +0 -9
  50. package/dist/rules/unescaped-dollar.js.flow +0 -9
  51. package/dist/rules/widget-in-table.js.flow +0 -9
  52. package/dist/selector.js.flow +0 -31
  53. package/dist/tree-transformer.js.flow +0 -253
  54. package/dist/types.js.flow +0 -12
  55. package/tsconfig.json +0 -12
@@ -47,7 +47,7 @@ describe("Individual lint rules tests", () => {
47
47
  if (TreeTransformer.isTextNode(node)) {
48
48
  let next = state.nextSibling();
49
49
  while (TreeTransformer.isTextNode(next)) {
50
- // @ts-expect-error [FEI-5003] - TS2339 - Property 'content' does not exist on type 'TreeNode'. | TS2533 - Object is possibly 'null' or 'undefined'. | TS2339 - Property 'content' does not exist on type 'TreeNode'.
50
+ // @ts-expect-error - TS2339 - Property 'content' does not exist on type 'TreeNode'. | TS2533 - Object is possibly 'null' or 'undefined'. | TS2339 - Property 'content' does not exist on type 'TreeNode'.
51
51
  node.content += next.content;
52
52
  state.removeNextSibling();
53
53
  next = state.nextSibling();
@@ -66,7 +66,7 @@ describe("Individual lint rules tests", () => {
66
66
  tt.traverse((node, state, content) => {
67
67
  const check = rule.check(node, state, content, context);
68
68
  if (check) {
69
- // @ts-expect-error [FEI-5003] - TS2345 - Argument of type 'any' is not assignable to parameter of type 'never'.
69
+ // @ts-expect-error - TS2345 - Argument of type 'any' is not assignable to parameter of type 'never'.
70
70
  warnings.push(check);
71
71
  }
72
72
  });
@@ -102,62 +102,62 @@ describe("Individual lint rules tests", () => {
102
102
  const sentence = new Array(25).fill("lorem ipsum").join(" ");
103
103
 
104
104
  // long-paragraph rule warns about paragraphs over 500 characters
105
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
105
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
106
106
  expectWarning(longParagraphRule, sentence + sentence);
107
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
107
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
108
108
  expectPass(longParagraphRule, [sentence, sentence + "\n\n" + sentence]);
109
109
 
110
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
110
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
111
111
  expectWarning(headingLevel1Rule, "# Level 1 heading");
112
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
112
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
113
113
  expectPass(headingLevel1Rule, "## Level 1 heading\n\n### Level 3 heading");
114
114
 
115
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
115
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
116
116
  expectWarning(headingLevelSkipRule, "## heading 1\n\n#### heading 2");
117
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
117
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
118
118
  expectPass(headingLevelSkipRule, [
119
119
  "## heading 1\n\n### heading 2\n\n#### heading 3\n\n### heading 4",
120
120
  "## heading 1\n\n##heading 2\n\n##heading3",
121
121
  ]);
122
122
 
123
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
123
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
124
124
  expectWarning(
125
125
  headingTitleCaseRule,
126
126
  "## This Heading is in Title Case and the but nor for Too",
127
127
  );
128
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
128
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
129
129
  expectPass(headingTitleCaseRule, [
130
130
  "## This heading is in sentence case",
131
131
  "## Acronyms: The CIA, NSA, DNI, and FBI",
132
132
  "## The Great War",
133
133
  ]);
134
134
 
135
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
135
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
136
136
  expectWarning(headingSentenceCaseRule, [
137
137
  "## this heading is uncapitalized",
138
138
  "## 'this' heading is uncapitalized",
139
139
  "## this heading is uncapitalized",
140
140
  ]);
141
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
141
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
142
142
  expectPass(headingSentenceCaseRule, [
143
143
  "## This heading is in sentence case",
144
144
  "## 'This heading too'",
145
145
  "## 2 + 2 = 4",
146
146
  ]);
147
147
 
148
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
148
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
149
149
  expectWarning(nestedListsRule, [
150
150
  "1. outer\n * nested\n *nested",
151
151
  " + outer\n\n 1. nested",
152
152
  ]);
153
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
153
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
154
154
  expectPass(nestedListsRule, [
155
155
  "-one\n-two\n-three",
156
156
  "1. one\n 2. two\n3. three",
157
157
  " * one\n\n * two\n\n * three",
158
158
  ]);
159
159
 
160
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
160
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
161
161
  expectWarning(imageAltTextRule, [
162
162
  "![](http://google.com/)",
163
163
  '![](http://google.com/ "title")',
@@ -167,42 +167,42 @@ describe("Individual lint rules tests", () => {
167
167
  "![blah](http://google.com/)", // too short to be meaningful
168
168
  ]);
169
169
 
170
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
170
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
171
171
  expectPass(imageAltTextRule, [
172
172
  "![alt-text](http://google.com)",
173
173
  '![alternative text](http://google.com/ "title")',
174
174
  "![alt alt alt][url-ref]",
175
175
  ]);
176
176
 
177
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
177
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
178
178
  expectWarning(blockquotedMathRule, ["> $1$", "Quote:\n\n> $x$\n\n"]);
179
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
179
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
180
180
  expectPass(blockquotedMathRule, [
181
181
  "$x$",
182
182
  "\n$x$\n $y$\n",
183
183
  "> bq #1\n\n$x+y=1$\n\n> bq #2",
184
184
  ]);
185
185
 
186
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
186
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
187
187
  expectWarning(blockquotedWidgetRule, ["> [[☃ passage 1]]"]);
188
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
188
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
189
189
  expectPass(blockquotedWidgetRule, [
190
190
  "[[☃ passage 1]]",
191
191
  "> bq #1\n\nTesting [[☃ passage 1]] testing\n\n> bq #2",
192
192
  ]);
193
193
 
194
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
194
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
195
195
  expectWarning(linkClickHereRule, [
196
196
  "[click here](http://google.com)",
197
197
  "[Click here, please](http://google.com)",
198
198
  "[For a good time, Click Here](http://google.com)",
199
199
  ]);
200
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
200
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
201
201
  expectPass(linkClickHereRule, [
202
202
  "[click to activate this link here](http://google.com)",
203
203
  ]);
204
204
 
205
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
205
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
206
206
  expectWarning(absoluteUrlRule, [
207
207
  // Warn about absolute khanacademy.org urls
208
208
  "[target](http://khanacademy.org/about)",
@@ -219,7 +219,7 @@ describe("Individual lint rules tests", () => {
219
219
  "![alt text](https://www.khanacademy.org/about)",
220
220
  "![alt text](https://es.khanacademy.org/about)",
221
221
  ]);
222
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
222
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
223
223
  expectPass(absoluteUrlRule, [
224
224
  "[target](/about)", // relative URLs okay
225
225
  "[target](https://kasandbox.org/path)",
@@ -234,25 +234,25 @@ describe("Individual lint rules tests", () => {
234
234
  "![alt text](https://ka-perseus-images.s3.amazonaws.com/path)",
235
235
  ]);
236
236
 
237
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
237
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
238
238
  expectWarning(imageInTableRule, [
239
239
  "|col1|col2|\n|----|----|\n|![alt-text](/link.gif)|cell2|",
240
240
  ]);
241
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
241
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
242
242
  expectPass(imageInTableRule, [
243
243
  "![alt-text](/link.gif)\n|col1|col2|\n|----|----|\n|cell1|cell2|",
244
244
  ]);
245
245
 
246
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
246
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
247
247
  expectWarning(widgetInTableRule, [
248
248
  "|col1|col2|\n|----|----|\n|[[☃ passage 1]]|cell2|",
249
249
  ]);
250
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
250
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
251
251
  expectPass(widgetInTableRule, [
252
252
  "[[☃ passage 1]]\n|col1|col2|\n|----|----|\n|cell1|cell2|",
253
253
  ]);
254
254
 
255
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
255
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
256
256
  expectWarning(tableMissingCellsRule, [
257
257
  "|col1|col2|col3|\n|----|----|----|\n|col1|col2|col3|\n|cell1|cell2|",
258
258
  "|col1|col2|col3|\n|----|----|----|\n|col1|col2|\n|cell1|cell2|",
@@ -260,19 +260,19 @@ describe("Individual lint rules tests", () => {
260
260
  "|col1|\n|----|----|\n|col1|\n|cell1|cell2|",
261
261
  "|col1|col2|\n|----|----|\n|col1|\n|cell1|cell2|",
262
262
  ]);
263
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
263
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
264
264
  expectPass(tableMissingCellsRule, [
265
265
  "|col1|col2|\n|----|----|\n|cell1|cell2|\n|cell1|cell2|",
266
266
  "|cell1|\n|----|\n|cell2|\n|cell3|",
267
267
  ]);
268
268
 
269
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
269
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
270
270
  expectWarning(unescapedDollarRule, ["It costs $10", "It costs $$10$"]);
271
271
 
272
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
272
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
273
273
  expectPass(unescapedDollarRule, ["It costs \\$10", "It costs $10x$"]);
274
274
 
275
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
275
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
276
276
  expectWarning(mathStartsWithSpaceRule, [
277
277
  "foo$~ x$bar",
278
278
  "$\\qquad x$",
@@ -285,7 +285,7 @@ describe("Individual lint rules tests", () => {
285
285
  "$\\enspace x$",
286
286
  "$\\phantom{xyz} x$",
287
287
  ]);
288
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
288
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
289
289
  expectPass(mathStartsWithSpaceRule, [
290
290
  "$a~ x$",
291
291
  "$a\\qquad x$",
@@ -299,51 +299,51 @@ describe("Individual lint rules tests", () => {
299
299
  "$a\\phantom{xyz} x$",
300
300
  ]);
301
301
 
302
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
302
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
303
303
  expectWarning(mathEmptyRule, [
304
304
  "foo $$ bar",
305
305
  "foo\n\n$$\n\nbar",
306
306
  "$$ | $$ | $$\n- | - | -\ndata 1 | data 2 | data 3",
307
307
  ]);
308
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
308
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
309
309
  expectPass(mathEmptyRule, [
310
310
  "foo $x$ bar",
311
311
  "foo\n\n$x$\n\nbar",
312
312
  "$x$ | $y$ | $z$\n- | - | -\ndata 1 | data 2 | data 3",
313
313
  ]);
314
314
 
315
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
315
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
316
316
  expectWarning(mathFracRule, ["$\\frac 12$", "$\\frac{1}{2}$"]);
317
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
317
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
318
318
  expectPass(mathFracRule, [
319
319
  "$\\dfrac 12$",
320
320
  "$\\dfrac{1}{2}$",
321
321
  "$\\fraction 12$",
322
322
  ]);
323
323
 
324
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
324
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
325
325
  expectWarning(mathTextEmptyRule, [
326
326
  "$x\\text{}y$",
327
327
  "$x\\text{ }y$",
328
328
  "$x\\text{\n}y$",
329
329
  "$x\\text{\t}y$",
330
330
  ]);
331
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
331
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
332
332
  expectPass(mathTextEmptyRule, ["$x\\text{z}y$"]);
333
333
 
334
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
334
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
335
335
  expectWarning(mathAdjacentRule, ["$x=b+c$\n\n$x-b=c$"]);
336
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
336
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
337
337
  expectPass(mathAdjacentRule, ["$x=b+c$\n\nnew paragraph\n\n$x-b=c$"]);
338
338
 
339
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
339
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
340
340
  expectWarning(mathAlignLinebreaksRule, [
341
341
  "$\\begin{align}x\\\\y\\end{align}$",
342
342
  "$\\begin{align} x \\\\ y \\end{align}$",
343
343
  "$\\begin{align}x\\\\\\\\\\\\y\\end{align}$",
344
344
  "$\\begin{align}\nx\\\\\n\\\\\\\\\ny\n\\end{align}$",
345
345
  ]);
346
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
346
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
347
347
  expectPass(mathAlignLinebreaksRule, [
348
348
  "$\\begin{align}x\\sqrty\\end{align}$",
349
349
  "$\\begin{align}x\\\\\\\\y\\end{align}$",
@@ -351,26 +351,26 @@ describe("Individual lint rules tests", () => {
351
351
  "$\\begin{align}x \\\\ \\\\ y\\end{align}$",
352
352
  ]);
353
353
 
354
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
354
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
355
355
  expectWarning(mathAlignExtraBreakRule, [
356
356
  "$\\begin{align}x \\\\\\\\ y \\\\ \\end{align}$",
357
357
  "$\\begin{align}x \\\\\\\\ y \\\\\\\\ \\end{align}$",
358
358
  ]);
359
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
359
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
360
360
  expectPass(mathAlignExtraBreakRule, [
361
361
  "$\\begin{align} x \\\\\\\\ y \\end{align}$",
362
362
  ]);
363
363
 
364
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
364
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
365
365
  expectWarning(mathNestedRule, [
366
366
  "$\\text{4$x$}$",
367
367
  "inline $\\text{4$x$}$ math",
368
368
  "$\\text{$$}$",
369
369
  ]);
370
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
370
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
371
371
  expectPass(mathNestedRule, ["$\\text{4}x$", "inline $\\text{4}x$ math"]);
372
372
 
373
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
373
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
374
374
  expectWarning(mathFontSizeRule, [
375
375
  "$\\tiny{x}$",
376
376
  "inline $\\Tiny{x}$ math",
@@ -383,10 +383,10 @@ describe("Individual lint rules tests", () => {
383
383
  "$\\normalsize{x}$",
384
384
  "$\\scriptsize{x}$",
385
385
  ]);
386
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
386
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
387
387
  expectPass(mathFontSizeRule, ["$\\sqrt{x}$", "inline $\\sqrt{x}$ math"]);
388
388
 
389
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
389
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
390
390
  expectWarning(profanityRule, [
391
391
  "Shit",
392
392
  "taking a piss",
@@ -395,17 +395,17 @@ describe("Individual lint rules tests", () => {
395
395
  "cocksucker",
396
396
  "motherfucker",
397
397
  ]);
398
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
398
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
399
399
  expectPass(profanityRule, ["spit", "miss", "duck"]);
400
400
 
401
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
401
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
402
402
  expectWarning(mathWithoutDollarsRule, [
403
403
  "One half: \\frac{1}{2}!",
404
404
  "\\Large{BIG}!",
405
405
  "This looks like someone's ear: {",
406
406
  "Here's the other ear: }. Weird!",
407
407
  ]);
408
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
408
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
409
409
  expectPass(mathWithoutDollarsRule, [
410
410
  "One half: $\\frac{1}{2}$",
411
411
  "$\\Large{BIG}$!",
@@ -417,14 +417,14 @@ describe("Individual lint rules tests", () => {
417
417
  "\n \\frac{1}{2}\n {\n }\n",
418
418
  ]);
419
419
 
420
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
420
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
421
421
  expectWarning(unbalancedCodeDelimitersRule, [
422
422
  "`code``",
423
423
  "``code```",
424
424
  "```code\n",
425
425
  "~~~\ncode\n~~",
426
426
  ]);
427
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
427
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
428
428
  expectPass(unbalancedCodeDelimitersRule, [
429
429
  "`code`",
430
430
  "``code``",
@@ -436,7 +436,7 @@ describe("Individual lint rules tests", () => {
436
436
  "$`~$",
437
437
  ]);
438
438
 
439
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
439
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
440
440
  expectWarning(imageSpacesAroundUrlsRule, [
441
441
  "![alternative]( http://example.com/image.jpg )",
442
442
  "![alternative]( http://example.com/image.jpg)",
@@ -446,7 +446,7 @@ describe("Individual lint rules tests", () => {
446
446
  "![alternative](\nhttp://example.com/image.jpg)",
447
447
  "![alternative](http://example.com/image.jpg\n)",
448
448
  ]);
449
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
449
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
450
450
  expectPass(imageSpacesAroundUrlsRule, [
451
451
  "![alternative](http://example.com/image.jpg)",
452
452
  "![alternative](image.jpg)",
@@ -520,26 +520,26 @@ describe("Individual lint rules tests", () => {
520
520
  },
521
521
  });
522
522
 
523
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
523
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
524
524
  expectWarning(doubleSpacingAfterTerminalRule, [
525
525
  "Good times. Great oldies.",
526
526
  "End of the line! ",
527
527
  "You? Me!",
528
528
  ]);
529
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
529
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
530
530
  expectPass(doubleSpacingAfterTerminalRule, [
531
531
  "This is okay.",
532
532
  "This is definitely okay. Yeah.",
533
533
  "$a == 3. 125$",
534
534
  ]);
535
535
 
536
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
536
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
537
537
  expectWarning(extraContentSpacingRule, [
538
538
  "There's extra spaces here. ",
539
539
  "There's extra spaces here ",
540
540
  " ",
541
541
  ]);
542
- // @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
542
+ // @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
543
543
  expectPass(extraContentSpacingRule, [
544
544
  "This is okay.",
545
545
  "This is definitely okay. Yeah.",
@@ -56,7 +56,7 @@ describe("PerseusLinter tree transformer", () => {
56
56
  function getTraversalOrder(tree: any) {
57
57
  const order: Array<any> = [];
58
58
  new TreeTransformer(tree).traverse((n, state) => {
59
- // @ts-expect-error [FEI-5003] - TS2339 - Property 'id' does not exist on type 'TreeNode'.
59
+ // @ts-expect-error - TS2339 - Property 'id' does not exist on type 'TreeNode'.
60
60
  order.push(n.id);
61
61
  });
62
62
  return order;
@@ -250,7 +250,7 @@ describe("PerseusLinter tree transformer", () => {
250
250
  new TreeTransformer(copy).traverse((n: any, state) => {
251
251
  if (n.id === id) {
252
252
  state.replace({
253
- // @ts-expect-error [FEI-5003] - TS2345 - Argument of type '{ id: number; type: string; }' is not assignable to parameter of type 'TreeNode'.
253
+ // @ts-expect-error - TS2345 - Argument of type '{ id: number; type: string; }' is not assignable to parameter of type 'TreeNode'.
254
254
  id: 99,
255
255
  type: "replacement",
256
256
  });
@@ -288,7 +288,7 @@ describe("PerseusLinter tree transformer", () => {
288
288
  // Ensure that we don't traverse the node more than once
289
289
  expect(++count).toEqual(1);
290
290
  state.replace({
291
- // @ts-expect-error [FEI-5003] - TS2345 - Argument of type '{ id: number; type: string; content: any; }' is not assignable to parameter of type 'TreeNode'.
291
+ // @ts-expect-error - TS2345 - Argument of type '{ id: number; type: string; content: any; }' is not assignable to parameter of type 'TreeNode'.
292
292
  id: 99,
293
293
  type: "reparent",
294
294
  content: n,
@@ -323,7 +323,7 @@ describe("PerseusLinter tree transformer", () => {
323
323
  // Replace the node with two new ones
324
324
  new TreeTransformer(copy).traverse((n: any, state) => {
325
325
  if (n.id === id) {
326
- // @ts-expect-error [FEI-5003] - TS2345 - Argument of type '({ id: number; type: string; } | { id: number; type: string; content: { id: number; type: string; }; })[]' is not assignable to parameter of type 'TreeNode'.
326
+ // @ts-expect-error - TS2345 - Argument of type '({ id: number; type: string; } | { id: number; type: string; content: { id: number; type: string; }; })[]' is not assignable to parameter of type 'TreeNode'.
327
327
  state.replace([
328
328
  {
329
329
  id: 99,
@@ -372,7 +372,7 @@ describe("PerseusLinter tree transformer", () => {
372
372
  if (n.id === id) {
373
373
  state.replace(
374
374
  {
375
- // @ts-expect-error [FEI-5003] - TS2345 - Argument of type '{ id: number; type: string; }' is not assignable to parameter of type 'TreeNode'.
375
+ // @ts-expect-error - TS2345 - Argument of type '{ id: number; type: string; }' is not assignable to parameter of type 'TreeNode'.
376
376
  id: 99,
377
377
  type: "replacement",
378
378
  },
package/src/index.ts CHANGED
@@ -50,7 +50,7 @@ export function runLinter(
50
50
  if (TreeTransformer.isTextNode(node)) {
51
51
  let next = state.nextSibling();
52
52
  while (TreeTransformer.isTextNode(next)) {
53
- // @ts-expect-error [FEI-5003] - TS2339 - Property 'content' does not exist on type 'TreeNode'. | TS2533 - Object is possibly 'null' or 'undefined'. | TS2339 - Property 'content' does not exist on type 'TreeNode'.
53
+ // @ts-expect-error - TS2339 - Property 'content' does not exist on type 'TreeNode'. | TS2533 - Object is possibly 'null' or 'undefined'. | TS2339 - Property 'content' does not exist on type 'TreeNode'.
54
54
  node.content += next.content;
55
55
  state.removeNextSibling();
56
56
  next = state.nextSibling();
@@ -157,7 +157,7 @@ export function runLinter(
157
157
  // this node, then we need to save the warnings for display
158
158
  // on the table itself
159
159
  if (insideTable && nodeWarnings.length) {
160
- // @ts-expect-error [FEI-5003] - TS2345 - Argument of type 'any' is not assignable to parameter of type 'never'.
160
+ // @ts-expect-error - TS2345 - Argument of type 'any' is not assignable to parameter of type 'never'.
161
161
  tableWarnings.push(...nodeWarnings);
162
162
  }
163
163
 
@@ -185,7 +185,7 @@ export function runLinter(
185
185
  // node under a new lint node and put the warnings there.
186
186
  state.replace({
187
187
  type: "lint",
188
- // @ts-expect-error [FEI-5003] - TS2345 - Argument of type '{ type: string; content: TreeNode; message: string; ruleName: any; blockHighlight: any; insideTable: boolean; severity: any; }' is not assignable to parameter of type 'TreeNode'.
188
+ // @ts-expect-error - TS2345 - Argument of type '{ type: string; content: TreeNode; message: string; ruleName: any; blockHighlight: any; insideTable: boolean; severity: any; }' is not assignable to parameter of type 'TreeNode'.
189
189
  content: node,
190
190
  message: nodeWarnings.map((w) => w.message).join("\n\n"),
191
191
  ruleName: nodeWarnings[0].rule,
@@ -219,7 +219,7 @@ export function runLinter(
219
219
  // single line, so keeping them combined in that case might
220
220
  // be the best thing, anyway.
221
221
  //
222
- // @ts-expect-error [FEI-5003] - TS2339 - Property 'content' does not exist on type 'TreeNode'.
222
+ // @ts-expect-error - TS2339 - Property 'content' does not exist on type 'TreeNode'.
223
223
  const content = node.content; // Text nodes have content
224
224
  const warning = nodeWarnings[0]; // There is only one warning.
225
225
  // These are the lint boundaries within the content
package/src/rule.ts CHANGED
@@ -129,7 +129,7 @@ import type {TraversalState, TreeNode} from "./tree-transformer";
129
129
 
130
130
  // This represents the type returned by String.match(). It is an
131
131
  // array of strings, but also has index:number and input:string properties.
132
- // Flow doesn't handle it well, so we punt and just use any.
132
+ // TypeScript doesn't handle it well, so we punt and just use any.
133
133
  export type PatternMatchType = any;
134
134
 
135
135
  // This is the return type of the check() method of a Rule object
@@ -382,7 +382,7 @@ ${e.stack}`,
382
382
  const lastSlash = pattern.lastIndexOf("/");
383
383
  const expression = pattern.substring(1, lastSlash);
384
384
  const flags = pattern.substring(lastSlash + 1);
385
- // @ts-expect-error [FEI-5003] - TS2713 - Cannot access 'RegExp.flags' because 'RegExp' is a type, but not a namespace. Did you mean to retrieve the type of the property 'flags' in 'RegExp' with 'RegExp["flags"]'?
385
+ // @ts-expect-error - TS2713 - Cannot access 'RegExp.flags' because 'RegExp' is a type, but not a namespace. Did you mean to retrieve the type of the property 'flags' in 'RegExp' with 'RegExp["flags"]'?
386
386
  return new RegExp(expression, flags as RegExp.flags);
387
387
  }
388
388
  return new RegExp(pattern);
@@ -135,11 +135,9 @@ export default class TreeTransformer {
135
135
  // Record the node's text content if it has any.
136
136
  // Usually this is for nodes with a type property of "text",
137
137
  // but other nodes types like "math" may also have content.
138
- // TODO(mdr): We found a new Flow error when upgrading:
139
- // "node.content (property `content` is missing in `TreeNode` [1].)"
140
- // @ts-expect-error [FEI-5003] - TS2339 - Property 'content' does not exist on type 'TreeNode'.
138
+ // @ts-expect-error - TS2339 - Property 'content' does not exist on type 'TreeNode'.
141
139
  if (typeof node.content === "string") {
142
- // @ts-expect-error [FEI-5003] - TS2339 - Property 'content' does not exist on type 'TreeNode'.
140
+ // @ts-expect-error - TS2339 - Property 'content' does not exist on type 'TreeNode'.
143
141
  content = node.content;
144
142
  }
145
143
 
@@ -204,7 +202,7 @@ export default class TreeTransformer {
204
202
  while (index < nodes.length) {
205
203
  state._indexes.push(index);
206
204
  content += this._traverse(nodes[index], state, f);
207
- // Casting to convince Flow that this is a number
205
+ // Casting to convince TypeScript that this is a number
208
206
  index = (state._indexes.pop() as number) + 1;
209
207
  }
210
208
 
@@ -231,7 +229,7 @@ export default class TreeTransformer {
231
229
  * for that traversal, and the instance is passed to the traversal callback
232
230
  * function for each node that is traversed. This class is not intended to be
233
231
  * instantiated directly, but is exported so that its type can be used for
234
- * Flow annotaions.
232
+ * type annotaions.
235
233
  **/
236
234
  export class TraversalState {
237
235
  // The root node of the tree being traversed
@@ -241,8 +239,8 @@ export class TraversalState {
241
239
  // below instead of using these properties directly. Note that the
242
240
  // _containers and _indexes stacks can have two different types of
243
241
  // elements, depending on whether we just recursed on an array or on a
244
- // node. This is hard for Flow to deal with, so you'll see a number of
245
- // Flow casts through the any type when working with these two properties.
242
+ // node. This is hard for TypeScript to deal with, so you'll see a number of
243
+ // type casts through the any type when working with these two properties.
246
244
  _currentNode: TreeNode | null | undefined;
247
245
  _containers: Stack<TreeNode | Array<TreeNode>>;
248
246
  _indexes: Stack<string | number>;
@@ -383,7 +381,7 @@ export class TraversalState {
383
381
 
384
382
  // The top of the container stack is either an array or an object
385
383
  // and the top of the indexes stack is a corresponding array index
386
- // or object property. This is hard for Flow, so we have to do some
384
+ // or object property. This is hard for TypeScript, so we have to do some
387
385
  // unsafe casting and be careful when we use which cast version
388
386
  if (Array.isArray(parent)) {
389
387
  const index = this._indexes.top() as number;
@@ -440,7 +438,7 @@ export class TraversalState {
440
438
  this._currentNode = this.previousSibling();
441
439
  // Since we know that we have a previous sibling, we know that
442
440
  // the value on top of the stack is a number, but we have to do
443
- // this unsafe cast because Flow doesn't know that.
441
+ // this unsafe cast because TypeScript doesn't know that.
444
442
  const index = this._indexes.pop() as number;
445
443
  this._indexes.push(index - 1);
446
444
  }
@@ -479,8 +477,6 @@ export class TraversalState {
479
477
  //
480
478
  while (
481
479
  this._containers.size() &&
482
- // This is safe, but easier to just disable flow than do casts
483
- // $FlowFixMe[incompatible-use]
484
480
  this._containers.top()[this._indexes.top()] !== this._currentNode
485
481
  ) {
486
482
  this._containers.pop();
@@ -540,7 +536,7 @@ class Stack<T> {
540
536
 
541
537
  /** Pop a value off of the stack. */
542
538
  pop(): T {
543
- // @ts-expect-error [FEI-5003] - TS2322 - Type 'T | undefined' is not assignable to type 'T'.
539
+ // @ts-expect-error - TS2322 - Type 'T | undefined' is not assignable to type 'T'.
544
540
  return this.stack.pop();
545
541
  }
546
542
 
@@ -0,0 +1,11 @@
1
+ {
2
+ "extends": "../tsconfig-shared.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist",
5
+ "rootDir": "src",
6
+ },
7
+ "references": [
8
+ {"path": "../perseus-error/tsconfig-build.json"},
9
+ {"path": "../pure-markdown/tsconfig-build.json"},
10
+ ]
11
+ }