File tree Expand file tree Collapse file tree 1 file changed +14
-12
lines changed
public/js/lib/editor/markdown-lint Expand file tree Collapse file tree 1 file changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -7,30 +7,32 @@ import './lint.css'
7
7
( function ( mod ) {
8
8
mod ( CodeMirror ) ;
9
9
} ) ( function ( CodeMirror ) {
10
- function validator ( text , options ) {
10
+ function validator ( text ) {
11
11
return lint ( text ) . map ( error => {
12
- const lineNumber = error . lineNumber - 1
12
+ const {
13
+ ruleNames,
14
+ ruleDescription,
15
+ lineNumber : ln ,
16
+ errorRange
17
+ } = error
18
+ const lineNumber = ln - 1
13
19
14
- let start , end
15
- if ( error . errorRange ) {
16
- start = error . errorRange [ 0 ] - 1
17
- end = error . errorRange [ 1 ] - 1
18
- } else {
19
- start = 0
20
- end = - 1
20
+ let start = 0 , end = - 1
21
+ if ( errorRange ) {
22
+ [ start , end ] = errorRange . map ( r => r - 1 )
21
23
}
22
24
23
25
return {
24
- messageHTML : `${ error . ruleNames . join ( '/' ) } : ${ error . ruleDescription } ` ,
26
+ messageHTML : `${ ruleNames . join ( '/' ) } : ${ ruleDescription } ` ,
25
27
severity : 'error' ,
26
28
from : CodeMirror . Pos ( lineNumber , start ) ,
27
29
to : CodeMirror . Pos ( lineNumber , end )
28
30
}
29
31
} )
30
32
}
31
33
32
- CodeMirror . registerHelper ( 'lint' , 'markdown' , validator ) ;
33
- } ) ;
34
+ CodeMirror . registerHelper ( 'lint' , 'markdown' , validator )
35
+ } )
34
36
35
37
function lint ( content ) {
36
38
const { content : errors } = markdownlint . sync ( {
You can’t perform that action at this time.
0 commit comments