@@ -67,37 +67,67 @@ export {_void, wrap}
6767// Construct.
6868const mdast = zwitch ( 'type' , {
6969 // Core interface.
70+ // @ts -expect-error: fine.
7071 unknown,
72+ // @ts -expect-error: fine.
7173 invalid : unknown ,
7274 // Per-type handling.
7375 handlers : {
76+ // @ts -expect-error: fine.
7477 root : wrap ( root ) ,
78+ // @ts -expect-error: fine.
7579 paragraph : parent ,
80+ // @ts -expect-error: fine.
7681 blockquote : parent ,
82+ // @ts -expect-error: fine.
7783 tableRow : parent ,
84+ // @ts -expect-error: fine.
7885 tableCell : parent ,
86+ // @ts -expect-error: fine.
7987 strong : parent ,
88+ // @ts -expect-error: fine.
8089 emphasis : parent ,
90+ // @ts -expect-error: fine.
8191 delete : parent ,
92+ // @ts -expect-error: fine.
8293 listItem : wrap ( listItem ) ,
94+ // @ts -expect-error: fine.
8395 footnote : parent ,
96+ // @ts -expect-error: fine.
8497 heading : wrap ( heading ) ,
98+ // @ts -expect-error: fine.
8599 text : literal ,
100+ // @ts -expect-error: fine.
86101 inlineCode : literal ,
102+ // @ts -expect-error: fine.
87103 yaml : literal ,
104+ // @ts -expect-error: fine.
88105 toml : literal ,
106+ // @ts -expect-error: fine.
89107 code : wrap ( code ) ,
108+ // @ts -expect-error: fine.
90109 thematicBreak : _void ,
110+ // @ts -expect-error: fine.
91111 break : _void ,
112+ // @ts -expect-error: fine.
92113 list : wrap ( list ) ,
114+ // @ts -expect-error: fine.
93115 footnoteDefinition : wrap ( footnoteDefinition ) ,
116+ // @ts -expect-error: fine.
94117 definition : wrap ( definition ) ,
118+ // @ts -expect-error: fine.
95119 link : wrap ( link ) ,
120+ // @ts -expect-error: fine.
96121 image : wrap ( image ) ,
122+ // @ts -expect-error: fine.
97123 linkReference : wrap ( linkReference ) ,
124+ // @ts -expect-error: fine.
98125 imageReference : wrap ( imageReference ) ,
126+ // @ts -expect-error: fine.
99127 footnoteReference : wrap ( footnoteReference ) ,
128+ // @ts -expect-error: fine.
100129 table : wrap ( table ) ,
130+ // @ts -expect-error: fine.
101131 html : literal
102132 }
103133} )
@@ -128,9 +158,8 @@ function assertParent(node) {
128158 */
129159function assertLiteral ( node ) {
130160 unistLiteral ( node )
131- nodeAssert . strictEqual (
132- typeof node . value ,
133- 'string' ,
161+ nodeAssert (
162+ typeof node . value === 'string' ,
134163 'literal should have a string `value`'
135164 )
136165}
@@ -143,7 +172,7 @@ function assertLiteral(node) {
143172function root ( node , ancestor ) {
144173 parent ( node )
145174
146- nodeAssert . strictEqual ( ancestor , undefined , '`root` should not have a parent' )
175+ nodeAssert ( ancestor === undefined , '`root` should not have a parent' )
147176}
148177
149178/**
@@ -155,30 +184,21 @@ function list(node) {
155184 indexable ( node )
156185
157186 if ( node . spread != null ) {
158- nodeAssert . strictEqual (
159- typeof node . spread ,
160- 'boolean' ,
161- '`spread` must be `boolean`'
162- )
187+ nodeAssert ( typeof node . spread === 'boolean' , '`spread` must be `boolean`' )
163188 }
164189
165190 if ( node . ordered != null ) {
166- nodeAssert . strictEqual (
167- typeof node . ordered ,
168- 'boolean' ,
169- '`ordered` must be `boolean`'
170- )
191+ nodeAssert ( typeof node . ordered === 'boolean' , '`ordered` must be `boolean`' )
171192 }
172193
173194 if ( ! node . ordered ) {
174- nodeAssert . ok ( node . start == null , 'unordered lists must not have `start`' )
195+ nodeAssert ( node . start == null , 'unordered lists must not have `start`' )
175196 } else if ( node . start != null ) {
176- nodeAssert . strictEqual (
177- typeof node . start ,
178- 'number' ,
197+ nodeAssert (
198+ typeof node . start === 'number' ,
179199 'ordered lists must have `start`'
180200 )
181- nodeAssert . ok ( node . start >= 0 , '`start` must be gte `0`' )
201+ nodeAssert ( node . start >= 0 , '`start` must be gte `0`' )
182202 }
183203}
184204
@@ -191,19 +211,11 @@ function listItem(node) {
191211 indexable ( node )
192212
193213 if ( node . spread != null ) {
194- nodeAssert . strictEqual (
195- typeof node . spread ,
196- 'boolean' ,
197- '`spread` must be `boolean`'
198- )
214+ nodeAssert ( typeof node . spread === 'boolean' , '`spread` must be `boolean`' )
199215 }
200216
201217 if ( node . checked != null ) {
202- nodeAssert . strictEqual (
203- typeof node . checked ,
204- 'boolean' ,
205- '`checked` must be `boolean`'
206- )
218+ nodeAssert ( typeof node . checked === 'boolean' , '`checked` must be `boolean`' )
207219 }
208220}
209221
@@ -215,8 +227,9 @@ function heading(node) {
215227 parent ( node )
216228 indexable ( node )
217229
218- nodeAssert . ok ( node . depth > 0 , '`depth` should be gte `1`' )
219- nodeAssert . ok ( node . depth <= 6 , '`depth` should be lte `6`' )
230+ nodeAssert ( typeof node . depth === 'number' , '`depth` should be a number' )
231+ nodeAssert ( node . depth > 0 , '`depth` should be gte `1`' )
232+ nodeAssert ( node . depth <= 6 , '`depth` should be lte `6`' )
220233}
221234
222235/**
@@ -228,20 +241,12 @@ function code(node) {
228241 indexable ( node )
229242
230243 if ( node . lang != null ) {
231- nodeAssert . strictEqual (
232- typeof node . lang ,
233- 'string' ,
234- '`lang` must be `string`'
235- )
244+ nodeAssert ( typeof node . lang === 'string' , '`lang` must be `string`' )
236245 }
237246
238247 if ( node . meta != null ) {
239- nodeAssert . ok ( node . lang != null , 'code with `meta` must also have `lang`' )
240- nodeAssert . strictEqual (
241- typeof node . meta ,
242- 'string' ,
243- '`meta` must be `string`'
244- )
248+ nodeAssert ( node . lang != null , 'code with `meta` must also have `lang`' )
249+ nodeAssert ( typeof node . meta === 'string' , '`meta` must be `string`' )
245250 }
246251}
247252
@@ -253,18 +258,13 @@ function footnoteDefinition(node) {
253258 parent ( node )
254259 indexable ( node )
255260
256- nodeAssert . strictEqual (
257- typeof node . identifier ,
258- 'string' ,
261+ nodeAssert (
262+ typeof node . identifier === 'string' ,
259263 '`footnoteDefinition` must have `identifier`'
260264 )
261265
262266 if ( node . label != null ) {
263- nodeAssert . strictEqual (
264- typeof node . label ,
265- 'string' ,
266- '`label` must be `string`'
267- )
267+ nodeAssert ( typeof node . label === 'string' , '`label` must be `string`' )
268268 }
269269}
270270
@@ -276,28 +276,19 @@ function definition(node) {
276276 _void ( node )
277277 indexable ( node )
278278
279- nodeAssert . strictEqual (
280- typeof node . identifier ,
281- 'string' ,
279+ nodeAssert (
280+ typeof node . identifier === 'string' ,
282281 '`identifier` must be `string`'
283282 )
284283
285284 if ( node . label != null ) {
286- nodeAssert . strictEqual (
287- typeof node . label ,
288- 'string' ,
289- '`label` must be `string`'
290- )
285+ nodeAssert ( typeof node . label === 'string' , '`label` must be `string`' )
291286 }
292287
293- nodeAssert . strictEqual ( typeof node . url , 'string' , '`url` must be `string`' )
288+ nodeAssert ( typeof node . url === 'string' , '`url` must be `string`' )
294289
295290 if ( node . title != null ) {
296- nodeAssert . strictEqual (
297- typeof node . title ,
298- 'string' ,
299- '`title` must be `string`'
300- )
291+ nodeAssert ( typeof node . title === 'string' , '`title` must be `string`' )
301292 }
302293}
303294
@@ -309,14 +300,10 @@ function link(node) {
309300 parent ( node )
310301 indexable ( node )
311302
312- nodeAssert . strictEqual ( typeof node . url , 'string' , '`url` must be `string`' )
303+ nodeAssert ( typeof node . url === 'string' , '`url` must be `string`' )
313304
314305 if ( node . title != null ) {
315- nodeAssert . strictEqual (
316- typeof node . title ,
317- 'string' ,
318- '`title` must be `string`'
319- )
306+ nodeAssert ( typeof node . title === 'string' , '`title` must be `string`' )
320307 }
321308}
322309
@@ -328,18 +315,14 @@ function image(node) {
328315 _void ( node )
329316 indexable ( node )
330317
331- nodeAssert . strictEqual ( typeof node . url , 'string' , '`url` must be `string`' )
318+ nodeAssert ( typeof node . url === 'string' , '`url` must be `string`' )
332319
333320 if ( node . title != null ) {
334- nodeAssert . strictEqual (
335- typeof node . title ,
336- 'string' ,
337- '`title` must be `string`'
338- )
321+ nodeAssert ( typeof node . title === 'string' , '`title` must be `string`' )
339322 }
340323
341324 if ( node . alt != null ) {
342- nodeAssert . strictEqual ( typeof node . alt , 'string' , '`alt` must be `string`' )
325+ nodeAssert ( typeof node . alt === 'string' , '`alt` must be `string`' )
343326 }
344327}
345328
@@ -351,25 +334,19 @@ function linkReference(node) {
351334 parent ( node )
352335 indexable ( node )
353336
354- nodeAssert . strictEqual (
355- typeof node . identifier ,
356- 'string' ,
337+ nodeAssert (
338+ typeof node . identifier === 'string' ,
357339 '`identifier` must be `string`'
358340 )
359341
360342 if ( node . label != null ) {
361- nodeAssert . strictEqual (
362- typeof node . label ,
363- 'string' ,
364- '`label` must be `string`'
365- )
343+ nodeAssert ( typeof node . label === 'string' , '`label` must be `string`' )
366344 }
367345
368346 if ( node . referenceType != null ) {
369- nodeAssert . notStrictEqual (
347+ nodeAssert (
370348 // @ts -expect-error Check if it’s a string.
371- [ 'shortcut' , 'collapsed' , 'full' ] . indexOf ( node . referenceType ) ,
372- - 1 ,
349+ [ 'shortcut' , 'collapsed' , 'full' ] . includes ( node . referenceType ) ,
373350 '`referenceType` must be `shortcut`, `collapsed`, or `full`'
374351 )
375352 }
@@ -383,29 +360,23 @@ function imageReference(node) {
383360 _void ( node )
384361 indexable ( node )
385362
386- nodeAssert . strictEqual (
387- typeof node . identifier ,
388- 'string' ,
363+ nodeAssert (
364+ typeof node . identifier === 'string' ,
389365 '`identifier` must be `string`'
390366 )
391367
392368 if ( node . label != null ) {
393- nodeAssert . strictEqual (
394- typeof node . label ,
395- 'string' ,
396- '`label` must be `string`'
397- )
369+ nodeAssert ( typeof node . label === 'string' , '`label` must be `string`' )
398370 }
399371
400372 if ( node . alt != null ) {
401- nodeAssert . strictEqual ( typeof node . alt , 'string' , '`alt` must be `string`' )
373+ nodeAssert ( typeof node . alt === 'string' , '`alt` must be `string`' )
402374 }
403375
404376 if ( node . referenceType != null ) {
405- nodeAssert . notStrictEqual (
377+ nodeAssert (
406378 // @ts -expect-error Check if it’s a string.
407- [ 'shortcut' , 'collapsed' , 'full' ] . indexOf ( node . referenceType ) ,
408- - 1 ,
379+ [ 'shortcut' , 'collapsed' , 'full' ] . includes ( node . referenceType ) ,
409380 '`referenceType` must be `shortcut`, `collapsed`, or `full`'
410381 )
411382 }
@@ -419,18 +390,13 @@ function footnoteReference(node) {
419390 _void ( node )
420391 indexable ( node )
421392
422- nodeAssert . strictEqual (
423- typeof node . identifier ,
424- 'string' ,
393+ nodeAssert (
394+ typeof node . identifier === 'string' ,
425395 '`identifier` must be `string`'
426396 )
427397
428398 if ( node . label != null ) {
429- nodeAssert . strictEqual (
430- typeof node . label ,
431- 'string' ,
432- '`label` must be `string`'
433- )
399+ nodeAssert ( typeof node . label === 'string' , '`label` must be `string`' )
434400 }
435401}
436402
@@ -445,18 +411,17 @@ function table(node) {
445411 indexable ( node )
446412
447413 if ( node . align != null ) {
448- nodeAssert . ok ( Array . isArray ( node . align ) , '`align` must be `array`' )
414+ nodeAssert ( Array . isArray ( node . align ) , '`align` must be `array`' )
449415 /** @type {Array.<unknown> } */
450416 const align = node . align // type-coverage:ignore-line
451417
452418 while ( ++ index < align . length ) {
453419 const value = align [ index ]
454420
455421 if ( value != null ) {
456- nodeAssert . notStrictEqual (
422+ nodeAssert (
457423 // @ts -expect-error Check if it’s a string.
458- [ 'left' , 'right' , 'center' ] . indexOf ( value ) ,
459- - 1 ,
424+ [ 'left' , 'right' , 'center' ] . includes ( value ) ,
460425 "each align in table must be `null, 'left', 'right', 'center'`"
461426 )
462427 }
0 commit comments