File tree Expand file tree Collapse file tree 3 files changed +25
-5
lines changed
Expand file tree Collapse file tree 3 files changed +25
-5
lines changed Original file line number Diff line number Diff line change 11# Programme
22
3- > [ !WARNING]
3+ > [ !WARNING]
44> This repository is under construction. If you're looking for the current HYF curriculum, check out [ Curriculum] ( https://github.com/HackYourFuture-CPH/curriculum ) .
55
66Documents the HYF programme, courses and modules.
Original file line number Diff line number Diff line change @@ -17,9 +17,21 @@ export type ParsedImage = {
1717export type ParseResult = {
1818 readonly links : readonly ParsedLink [ ] ;
1919 readonly images : readonly ParsedImage [ ] ;
20+ readonly trailingWhitespace : readonly SourceLocation [ ] ;
2021} ;
2122
2223export const parse = ( content : string ) : ParseResult => {
24+ const trailingWhitespace : SourceLocation [ ] = [ ] ;
25+
26+ content . split ( / \n / ) . forEach ( ( line , index ) => {
27+ if ( line . endsWith ( " " ) ) {
28+ trailingWhitespace . push ( {
29+ line0 : index ,
30+ column0 : line . trimEnd ( ) . length ,
31+ } ) ;
32+ }
33+ } ) ;
34+
2335 const parser = mit ( ) ;
2436 const tokens = parser . parse ( content , { } ) ;
2537
@@ -64,5 +76,6 @@ export const parse = (content: string): ParseResult => {
6476 return {
6577 links : parsedLinks ,
6678 images : parsedImages ,
79+ trailingWhitespace,
6780 } ;
6881} ;
Original file line number Diff line number Diff line change @@ -28,10 +28,7 @@ const findAllFiles = async (): Promise<string[]> => {
2828} ;
2929
3030const findMarkdownFiles = ( files : string [ ] ) : string [ ] => {
31- const ignorePattern = / ^ ( R E A D M E | L I C E N S E | c o n t r i b u t i n g \/ ) / ;
32- return files . filter (
33- ( f ) => f . toLocaleLowerCase ( ) . endsWith ( ".md" ) && ! ignorePattern . test ( f ) ,
34- ) ;
31+ return files . filter ( ( f ) => f . toLocaleLowerCase ( ) . endsWith ( ".md" ) ) ;
3532} ;
3633
3734const scanForLinks = async ( filenames : string [ ] ) : Promise < ParsedFile [ ] > => {
@@ -70,6 +67,16 @@ const main = async () => {
7067 let errors = 0 ;
7168
7269 for ( const parsedFile of parsedFiles ) {
70+ for ( const ws of parsedFile . trailingWhitespace ) {
71+ showError (
72+ parsedFile . filename ,
73+ ws ,
74+ "VL003/trailing-whitespace" ,
75+ "Trailing whitespace" ,
76+ ) ;
77+ ++ errors ;
78+ }
79+
7380 for ( const img of parsedFile . images ) {
7481 if ( ! isExternalLink ( img . src ) ) {
7582 const resolved = path . join ( dirname ( parsedFile . filename ) , img . src ) ;
You can’t perform that action at this time.
0 commit comments