1
- 'use strict'
2
-
3
- var fs = require ( 'fs' )
4
- var path = require ( 'path' )
5
- var assert = require ( 'assert' )
6
- var test = require ( 'tape' )
7
- var not = require ( 'not' )
8
- var hidden = require ( 'is-hidden' )
9
- var vfile = require ( 'to-vfile' )
10
- var parse5 = require ( 'parse5' )
11
- var visit = require ( 'unist-util-visit' )
12
- var fromParse5 = require ( '..' )
1
+ import fs from 'fs'
2
+ import path from 'path'
3
+ import assert from 'assert'
4
+ import test from 'tape'
5
+ import { isHidden } from 'is-hidden'
6
+ import parse5 from 'parse5'
7
+ import { visit } from 'unist-util-visit'
8
+ import vfile from 'to-vfile'
9
+ import { fromParse5 } from '../index.js'
13
10
14
11
var join = path . join
15
12
@@ -348,11 +345,13 @@ test('hast-util-from-parse5', function (t) {
348
345
349
346
test ( 'fixtures' , function ( t ) {
350
347
var base = join ( 'test' , 'fixtures' )
351
- var files = fs . readdirSync ( base ) . filter ( not ( hidden ) )
348
+ var files = fs . readdirSync ( base )
352
349
var index = - 1
353
350
354
351
while ( ++ index < files . length ) {
355
- each ( files [ index ] )
352
+ if ( ! isHidden ( files [ index ] ) ) {
353
+ each ( files [ index ] )
354
+ }
356
355
}
357
356
358
357
t . end ( )
@@ -366,14 +365,14 @@ test('fixtures', function (t) {
366
365
367
366
st . plan ( 4 )
368
367
369
- checkYesYes ( st , fixture , options )
370
- checkNoYes ( st , fixture , options )
371
- checkYesNo ( st , fixture , options )
372
- checkNoNo ( st , fixture , options )
368
+ checkYesYes ( st , options )
369
+ checkNoYes ( st , options )
370
+ checkYesNo ( st , options )
371
+ checkNoNo ( st , options )
373
372
} )
374
373
}
375
374
376
- function checkYesYes ( t , fixture , options ) {
375
+ function checkYesYes ( t , options ) {
377
376
var input = parse5 . parse ( String ( options . file ) , {
378
377
sourceCodeLocationInfo : true
379
378
} )
@@ -382,7 +381,7 @@ test('fixtures', function (t) {
382
381
383
382
try {
384
383
expected = JSON . parse ( fs . readFileSync ( options . out ) )
385
- } catch ( _ ) {
384
+ } catch {
386
385
// New fixture.
387
386
fs . writeFileSync ( options . out , JSON . stringify ( actual , 0 , 2 ) + '\n' )
388
387
return
@@ -392,7 +391,7 @@ test('fixtures', function (t) {
392
391
t . deepEqual ( actual , expected , 'p5 w/ position, hast w/ intent of position' )
393
392
}
394
393
395
- function checkNoYes ( t , fixture , options ) {
394
+ function checkNoYes ( t , options ) {
396
395
var input = parse5 . parse ( String ( options . file ) )
397
396
var actual = fromParse5 ( input , { file : options . file , verbose : true } )
398
397
var expected = JSON . parse ( fs . readFileSync ( options . out ) )
@@ -403,7 +402,7 @@ test('fixtures', function (t) {
403
402
t . deepEqual ( actual , expected , 'p5 w/o position, hast w/ intent of position' )
404
403
}
405
404
406
- function checkYesNo ( t , fixture , options ) {
405
+ function checkYesNo ( t , options ) {
407
406
var input = parse5 . parse ( String ( options . file ) , {
408
407
sourceCodeLocationInfo : true
409
408
} )
@@ -416,7 +415,7 @@ test('fixtures', function (t) {
416
415
t . deepEqual ( actual , expected , 'p5 w/ position, hast w/o intent of position' )
417
416
}
418
417
419
- function checkNoNo ( t , fixture , options ) {
418
+ function checkNoNo ( t , options ) {
420
419
var input = parse5 . parse ( String ( options . file ) )
421
420
var actual = fromParse5 ( input )
422
421
var expected = JSON . parse ( fs . readFileSync ( options . out ) )
@@ -452,7 +451,7 @@ function cleaner(node) {
452
451
function log ( label , actual , expected ) {
453
452
try {
454
453
assert . deepStrictEqual ( actual , expected , label )
455
- } catch ( _ ) {
454
+ } catch {
456
455
console . log ( 'actual:%s:' , label )
457
456
console . dir ( actual , { depth : null } )
458
457
console . log ( 'expected:%s:' , label )
0 commit comments