Skip to content
This repository has been archived by the owner on Jun 26, 2024. It is now read-only.

Commit

Permalink
[Fix] Check msg.source before trimming it.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanfitzer committed Jul 13, 2022
1 parent 62b59eb commit 5d57084
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Support/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,14 @@ function composeData( report, SourceCode, TMconfig ) {

msg.source = srcLines[ msg.line - 1 ];

const leadSpace = msg.source.match( /^\s*/ );
const leadSpace = msg.source && msg.source.match( /^\s*/ );
const count = leadSpace ? leadSpace[ 0 ].length : 0;
const pad = msg.column > count ? msg.column - count - 1 : 0;

msg.count = index + 1;
msg.isESLintRule = msg.ruleId && msg.ruleId.search( '/' ) < 0;
msg.pointer = `${Array( pad ).fill( '.' ).join( '' )}^`;
msg.source = msg.source.trim();
msg.source = msg.source ? msg.source.trim() : msg.source;
msg.messageHTML = msg.message.replace( /'(.*?)'/g, ( match, code ) => {
return `<code>${code}</code>`;
});
Expand Down

0 comments on commit 5d57084

Please sign in to comment.