Skip to content

Commit 968e042

Browse files
committed
Cleanup
Signed-off-by: Yukai Huang <yukaihuangtw@gmail.com>
1 parent 31765a9 commit 968e042

File tree

1 file changed

+14
-12
lines changed
  • public/js/lib/editor/markdown-lint

1 file changed

+14
-12
lines changed

public/js/lib/editor/markdown-lint/index.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,32 @@ import './lint.css'
77
(function(mod) {
88
mod(CodeMirror);
99
})(function(CodeMirror) {
10-
function validator(text, options) {
10+
function validator(text) {
1111
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
1319

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)
2123
}
2224

2325
return {
24-
messageHTML: `${error.ruleNames.join('/')}: ${error.ruleDescription}`,
26+
messageHTML: `${ruleNames.join('/')}: ${ruleDescription}`,
2527
severity: 'error',
2628
from: CodeMirror.Pos(lineNumber, start),
2729
to: CodeMirror.Pos(lineNumber, end)
2830
}
2931
})
3032
}
3133

32-
CodeMirror.registerHelper('lint', 'markdown', validator);
33-
});
34+
CodeMirror.registerHelper('lint', 'markdown', validator)
35+
})
3436

3537
function lint (content) {
3638
const { content: errors } = markdownlint.sync({

0 commit comments

Comments
 (0)