1
+ import { existsSync , readFileSync , statSync } from 'node:fs'
2
+ import path , { resolve } from 'node:path'
1
3
import fg from 'fast-glob'
2
- import { readFileSync , existsSync , statSync } from 'node:fs'
3
- // @ts -ignore
4
+ // @ts -ignore Could not find a declaration file for module 'markdown-link-extractor'.
4
5
import markdownLinkExtractor from 'markdown-link-extractor'
5
- import path , { join , dirname , resolve } from 'node:path'
6
-
7
- interface MarkdownLink {
8
- href : string
9
- text : string
10
- }
11
6
12
7
function isRelativeLink ( link : string ) {
13
8
return (
@@ -29,7 +24,7 @@ function normalizePath(p: string): string {
29
24
function fileExistsForLink (
30
25
link : string ,
31
26
markdownFile : string ,
32
- errors : any [ ] ,
27
+ errors : Array < any > ,
33
28
) : boolean {
34
29
// Remove hash if present
35
30
const filePart = link . split ( '#' ) [ 0 ]
@@ -97,12 +92,12 @@ async function findMarkdownLinks() {
97
92
98
93
console . log ( `Found ${ markdownFiles . length } markdown files\n` )
99
94
100
- const errors : any [ ] = [ ]
95
+ const errors : Array < any > = [ ]
101
96
102
97
// Process each file
103
98
for ( const file of markdownFiles ) {
104
99
const content = readFileSync ( file , 'utf-8' )
105
- const links : any [ ] = markdownLinkExtractor ( content )
100
+ const links : Array < any > = markdownLinkExtractor ( content )
106
101
107
102
const filteredLinks = links . filter ( ( link : any ) => {
108
103
if ( typeof link === 'string' ) {
@@ -114,7 +109,7 @@ async function findMarkdownLinks() {
114
109
} )
115
110
116
111
if ( filteredLinks . length > 0 ) {
117
- filteredLinks . forEach ( ( link : any ) => {
112
+ filteredLinks . forEach ( ( link ) => {
118
113
const href = typeof link === 'string' ? link : link . href
119
114
fileExistsForLink ( href , file , errors )
120
115
} )
0 commit comments