Skip to content

Commit 13298f0

Browse files
committed
MDLSITE-6748 mustachelint: Add information about eslint failures
1 parent 4aad9af commit 13298f0

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

mustache_lint/mustache_lint.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@
140140
// When we have no example context, parse errors are common because
141141
// there are missing variables in the js, thus we ignore them.
142142
$ignoreparseerrors = empty($example) ? true : false;
143+
print_message('INFO', 'ESLint reported JavaScript errors');
143144
print_eslint_problems($eslintproblems, $ignoreparseerrors);
144145
}
145146

@@ -260,8 +261,18 @@ function print_eslint_problems($problems, $ignoreparseerrors) {
260261
} else {
261262
$severity = 'warning';
262263
}
263-
$message = "ESLint {$severity} [{$problem->ruleId}]: {$problem->message} ( {$problem->source} ), Line: {$problem->line} Column: {$problem->column}";
264-
print_problem('WARNING', $message);
264+
if ($problem->linesource) {
265+
$message = "ESLint {$severity} [{$problem->ruleId}]: {$problem->message}, Line: {$problem->line} Column: {$problem->column}";
266+
print_problem('WARNING', $message);
267+
print_problem('WARNING', rtrim($problem->linesource));
268+
269+
if ($problem->column !== null) {
270+
print_problem('WARNING', str_pad(' ', $problem->column - 1) . '^');
271+
}
272+
} else {
273+
$message = "ESLint {$severity} [{$problem->ruleId}]: {$problem->message} ( {$problem->source} ), Line: {$problem->line} Column: {$problem->column}";
274+
print_problem('WARNING', $message);
275+
}
265276
}
266277
}
267278

0 commit comments

Comments
 (0)