@@ -27,11 +27,12 @@ function findMarkdownFilesRecursively(dirPath) {
27
27
if (
28
28
entry . isDirectory ( ) &&
29
29
entry . name !== 'api' &&
30
- entry . name !== 'tmp' &&
31
- entry . name !== 'fixtures' &&
32
30
entry . name !== 'changelogs' &&
33
31
entry . name !== 'deps' &&
34
- entry . name !== 'node_modules'
32
+ entry . name !== 'fixtures' &&
33
+ entry . name !== 'node_modules' &&
34
+ entry . name !== 'out' &&
35
+ entry . name !== 'tmp'
35
36
) {
36
37
findMarkdownFilesRecursively ( path ) ;
37
38
} else if ( entry . isFile ( ) && extname ( entry . name ) === '.md' ) {
@@ -46,6 +47,7 @@ function checkFile(path) {
46
47
. parse ( fs . readFileSync ( path ) ) ;
47
48
48
49
const base = pathToFileURL ( path ) ;
50
+ let previousDefinitionLabel ;
49
51
for ( const node of getLinksRecursively ( tree ) ) {
50
52
const targetURL = new URL ( node . url , base ) ;
51
53
if ( targetURL . protocol === 'file:' && ! fs . existsSync ( targetURL ) ) {
@@ -55,5 +57,18 @@ function checkFile(path) {
55
57
`Broken link at ${ path } :${ line } :${ column } (${ node . url } )` ) ;
56
58
process . exitCode = 1 ;
57
59
}
60
+ if ( node . type === 'definition' ) {
61
+ if ( previousDefinitionLabel &&
62
+ previousDefinitionLabel > node . label ) {
63
+ const { line, column } = node . position . start ;
64
+ console . error ( ( process . env . GITHUB_ACTIONS ?
65
+ `::error file=${ path } ,line=${ line } ,col=${ column } ::` : '' ) +
66
+ `Unordered reference at ${ path } :${ line } :${ column } (` +
67
+ `"${ node . label } " should be before "${ previousDefinitionLabel } )"`
68
+ ) ;
69
+ process . exitCode = 1 ;
70
+ }
71
+ previousDefinitionLabel = node . label ;
72
+ }
58
73
}
59
74
}
0 commit comments