@@ -25,6 +25,9 @@ const scanForLinks = async (filenames) => {
2525 return { filename, ...parse ( content ) } ;
2626 } ) ) ;
2727} ;
28+ const showError = ( filename , sourceLocation , code , message ) => {
29+ console . log ( `${ filename } :${ sourceLocation ? `${ sourceLocation . line0 + 1 } :${ sourceLocation . column0 + 1 } ` : "0" } ${ code } ${ message } ` ) ;
30+ } ;
2831const externalLinkPattern = / ^ \w + : / ;
2932const isExternalLink = ( t ) => externalLinkPattern . test ( t ) ;
3033const main = async ( ) => {
@@ -40,7 +43,7 @@ const main = async () => {
4043 const resolved = path . join ( dirname ( parsedFile . filename ) , img . src ) ;
4144 const exists = lowercaseGitFiles . includes ( resolved . toLocaleLowerCase ( ) ) ;
4245 if ( ! exists ) {
43- console . log ( `error BROKEN-INTERNAL-IMAGE ${ parsedFile . filename } :0 Broken internal image reference ${ img . src } `) ;
46+ showError ( parsedFile . filename , img . sourceLocation , "VL002/missing-image-source" , `Image source does not exist ${ img . src } `) ;
4447 ++ errors ;
4548 }
4649 }
@@ -65,7 +68,7 @@ const main = async () => {
6568 : `${ resolved . toLocaleLowerCase ( ) } /` ;
6669 const isDirectory = lowercaseGitFiles . some ( ( s ) => s . startsWith ( resolvedWithTrailingSlash ) ) ;
6770 if ( ! isFile && ! isDirectory ) {
68- console . log ( `error BROKEN-INTERNAL-LINK ${ parsedFile . filename } :0 Link target does not exist: ${ target } `) ;
71+ showError ( parsedFile . filename , link . sourceLocation , "VL001/missing-link-target" , ` Link target does not exist: ${ target } `) ;
6972 ++ errors ;
7073 }
7174 }
0 commit comments