@@ -29,12 +29,10 @@ require('script-loader!markdownlint');
29
29
}
30
30
31
31
return {
32
- messageHTML : `${ ruleNames . slice ( 0 , 1 ) } : ${ ruleDescription } ` ,
32
+ messageHTML : `${ ruleNames . join ( '/' ) } : ${ ruleDescription } <small>markdownlint( ${ ruleNames [ 0 ] } )</small> ` ,
33
33
severity : 'error' ,
34
34
from : CodeMirror . Pos ( lineNumber , start ) ,
35
35
to : CodeMirror . Pos ( lineNumber , end ) ,
36
- __ruleNames : ruleNames ,
37
- __ruleDescription : ruleDescription ,
38
36
__error : error
39
37
}
40
38
} )
@@ -47,38 +45,48 @@ export const linterOptions = {
47
45
fixedTooltip : true ,
48
46
contextmenu : annotations => {
49
47
const singleFixMenus = annotations
50
- . filter ( ann => ann . __error . fixInfo )
51
48
. map ( annotation => {
52
49
const error = annotation . __error
53
- return {
54
- content : `Fix ${ error . ruleDescription } ` ,
55
- onClick ( ) {
56
- const doc = window . editor . doc
57
- const fixInfo = normalizeFixInfo ( error . fixInfo , error . lineNumber )
58
- const line = fixInfo . lineNumber - 1
59
- const lineContent = doc . getLine ( line ) || ''
60
- const fixedText = helpers . applyFix ( lineContent , fixInfo , '\n' )
50
+ const ruleNameAlias = error . ruleNames . join ( '/' )
61
51
62
- let from = { line, ch : 0 }
63
- let to = { line, ch : lineContent ? lineContent . length : 0 }
52
+ if ( annotation . __error . fixInfo ) {
53
+ return {
54
+ content : `Click to fix this violoation of ${ ruleNameAlias } ` ,
55
+ onClick ( ) {
56
+ const doc = window . editor . doc
57
+ const fixInfo = normalizeFixInfo ( error . fixInfo , error . lineNumber )
58
+ const line = fixInfo . lineNumber - 1
59
+ const lineContent = doc . getLine ( line ) || ''
60
+ const fixedText = helpers . applyFix ( lineContent , fixInfo , '\n' )
64
61
65
- if ( typeof fixedText === 'string' ) {
66
- doc . replaceRange ( fixedText , from , to )
67
- } else {
68
- if ( fixInfo . lineNumber === 1 ) {
69
- if ( doc . lineCount ( ) > 1 ) {
70
- const nextLineStart = doc . indexFromPos ( {
71
- line : to . line + 1 ,
72
- ch : 0
73
- } )
74
- to = doc . posFromIndex ( nextLineStart )
75
- }
62
+ let from = { line, ch : 0 }
63
+ let to = { line, ch : lineContent ? lineContent . length : 0 }
64
+
65
+ if ( typeof fixedText === 'string' ) {
66
+ doc . replaceRange ( fixedText , from , to )
76
67
} else {
77
- const previousLineEnd = doc . indexFromPos ( from ) - 1
78
- from = doc . posFromIndex ( previousLineEnd )
79
- }
68
+ if ( fixInfo . lineNumber === 1 ) {
69
+ if ( doc . lineCount ( ) > 1 ) {
70
+ const nextLineStart = doc . indexFromPos ( {
71
+ line : to . line + 1 ,
72
+ ch : 0
73
+ } )
74
+ to = doc . posFromIndex ( nextLineStart )
75
+ }
76
+ } else {
77
+ const previousLineEnd = doc . indexFromPos ( from ) - 1
78
+ from = doc . posFromIndex ( previousLineEnd )
79
+ }
80
80
81
- doc . replaceRange ( '' , from , to )
81
+ doc . replaceRange ( '' , from , to )
82
+ }
83
+ }
84
+ }
85
+ } else {
86
+ return {
87
+ content : `Click for more information about ${ ruleNameAlias } ` ,
88
+ onClick ( ) {
89
+ window . open ( error . ruleInformation , '_blank' )
82
90
}
83
91
}
84
92
}
0 commit comments