Skip to content
This repository was archived by the owner on Aug 7, 2023. It is now read-only.

Commit 451ef4f

Browse files
committed
Don't make any assumptions about output
Don't assume the message has a line, column, or rule.
1 parent 8d0d5b3 commit 451ef4f

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

lib/main.coffee

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,21 @@ module.exports =
1919
if lintResult.messages.length < 1
2020
return toReturn
2121
for data in lintResult.messages
22-
if not data.rollup
22+
msg = {}
23+
if not (data.line and data.col)
24+
# Use the file start if location not defined
25+
msg.range = helpers.rangeFromLineNumber(textEditor, 0)
26+
else
2327
line = data.line - 1
2428
col = data.col - 1
25-
else
26-
helpers.rangeFromLineNumber(textEditor, 0)
27-
toReturn.push({
28-
type: data.type.charAt(0).toUpperCase() + data.type.slice(1),
29-
text: data.message,
30-
filePath: filePath
31-
range: [[line, col], [line, col]],
32-
trace: [{
29+
msg.range = [[line, col], [line, col]]
30+
msg.type = data.type.charAt(0).toUpperCase() + data.type.slice(1)
31+
msg.text = data.message
32+
msg.filePath = filePath
33+
if data.rule.id and data.rule.desc
34+
msg.trace = [{
3335
type: "Trace",
3436
text: '[' + data.rule.id + '] ' + data.rule.desc
3537
}]
36-
})
38+
toReturn.push(msg)
3739
return toReturn

0 commit comments

Comments
 (0)