1
1
import { expect } from 'chai' ;
2
- import * as fs from 'fs-extra ' ;
2
+ import fs from 'node:fs ' ;
3
3
import MarkdownIt from 'markdown-it' ;
4
- import Token from 'markdown-it/lib/token ' ;
4
+ import { Token } from 'markdown-it' ;
5
5
import * as path from 'path' ;
6
- import toCamelCase = require ( 'lodash.camelcase' ) ;
6
+ import toCamelCase from 'lodash.camelcase' ;
7
7
8
8
import {
9
9
ParsedDocumentation ,
@@ -13,7 +13,7 @@ import {
13
13
ModuleDocumentationContainer ,
14
14
ClassDocumentationContainer ,
15
15
ElementDocumentationContainer ,
16
- } from './ParsedDocumentation' ;
16
+ } from './ParsedDocumentation.js ' ;
17
17
import {
18
18
findNextList ,
19
19
convertListToTypedKeys ,
@@ -28,15 +28,15 @@ import {
28
28
findContentAfterHeadingClose ,
29
29
HeadingContent ,
30
30
getContentBeforeFirstHeadingMatching ,
31
- } from './markdown-helpers' ;
32
- import { WEBSITE_BASE_DOCS_URL , REPO_BASE_DOCS_URL } from './constants' ;
33
- import { extendError } from './helpers' ;
31
+ } from './markdown-helpers.js ' ;
32
+ import { WEBSITE_BASE_DOCS_URL , REPO_BASE_DOCS_URL } from './constants.js ' ;
33
+ import { extendError } from './helpers.js ' ;
34
34
import {
35
35
parseMethodBlocks ,
36
36
_headingToMethodBlock ,
37
37
parsePropertyBlocks ,
38
38
parseEventBlocks ,
39
- } from './block-parsers' ;
39
+ } from './block-parsers.js ' ;
40
40
41
41
export class DocsParser {
42
42
constructor (
@@ -108,7 +108,7 @@ export class DocsParser {
108
108
groups = getContentBeforeConstructor ( tokens ) ;
109
109
} else {
110
110
// FIXME: Make it so that we don't need this magic FIXME for the electron breaking-changes document
111
- groups = getContentBeforeFirstHeadingMatching ( tokens , heading =>
111
+ groups = getContentBeforeFirstHeadingMatching ( tokens , ( heading ) =>
112
112
[ 'Events' , 'Methods' , 'Properties' , '`FIXME` comments' ] . includes ( heading . trim ( ) ) ,
113
113
) ;
114
114
}
@@ -156,7 +156,7 @@ export class DocsParser {
156
156
| ClassDocumentationContainer
157
157
| ElementDocumentationContainer
158
158
) [ ] = [ ] ;
159
- const contents = await fs . readFile ( filePath , 'utf8' ) ;
159
+ const contents = await fs . promises . readFile ( filePath , 'utf8' ) ;
160
160
const md = new MarkdownIt ( { html : true } ) ;
161
161
162
162
const allTokens = md . parse ( contents , { } ) ;
@@ -182,7 +182,7 @@ export class DocsParser {
182
182
if ( isClass ) {
183
183
// Instance name will be taken either from an example in a method declaration or the camel
184
184
// case version of the class name
185
- const levelFourHeader = headingsAndContent ( tokens ) . find ( h => h . level === 4 ) ;
185
+ const levelFourHeader = headingsAndContent ( tokens ) . find ( ( h ) => h . level === 4 ) ;
186
186
const instanceName = levelFourHeader
187
187
? ( levelFourHeader . heading . split ( '`' ) [ 1 ] || '' ) . split ( '.' ) [ 0 ] ||
188
188
toCamelCase ( container . name )
@@ -262,7 +262,7 @@ export class DocsParser {
262
262
}
263
263
264
264
private async parseStructure ( filePath : string ) : Promise < StructureDocumentationContainer > {
265
- const contents = await fs . readFile ( filePath , 'utf8' ) ;
265
+ const contents = await fs . promises . readFile ( filePath , 'utf8' ) ;
266
266
const md = new MarkdownIt ( { html : true } ) ;
267
267
268
268
const tokens = md . parse ( contents , { } ) ;
@@ -279,7 +279,7 @@ export class DocsParser {
279
279
return {
280
280
type : 'Structure' ,
281
281
...baseInfos [ 0 ] . container ,
282
- properties : consumeTypedKeysList ( convertListToTypedKeys ( list ! ) ) . map ( typedKey => ( {
282
+ properties : consumeTypedKeysList ( convertListToTypedKeys ( list ! ) ) . map ( ( typedKey ) => ( {
283
283
name : typedKey . key ,
284
284
description : typedKey . description ,
285
285
required : typedKey . required ,
0 commit comments