From e0fcea48036c9966db7455ea145c9a82486f13b5 Mon Sep 17 00:00:00 2001 From: exbinary Date: Fri, 6 Apr 2018 15:03:56 -0400 Subject: [PATCH] Allow for null message.source Addresses issue #29. Message source can be null when a Parsing error is encountered. --- index.js | 2 +- test/fixtures/fatal/results.json | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index cdfd120..6604a66 100644 --- a/index.js +++ b/index.js @@ -182,7 +182,7 @@ module.exports = function(results) { var column = message.column || 0; var arrow = ''; - var hasSource = message.source !== undefined && message.source.length < 1000; + var hasSource = message.source && message.source.length < 1000; if (hasSource) { for (var i = 0; i < message.column; i++) { if (message.source.charAt(i) === '\t') { diff --git a/test/fixtures/fatal/results.json b/test/fixtures/fatal/results.json index 9ed4d7c..6031bf6 100644 --- a/test/fixtures/fatal/results.json +++ b/test/fixtures/fatal/results.json @@ -5,6 +5,7 @@ { "fatal": true, "severity": 2, + "source": null, "message": "Unexpected token {", "line": 3, "column": 13