Skip to content

Commit 4aad9af

Browse files
committed
MDLSITE-6745 mustachelint: Ensure that fatal errors include a source line
1 parent c22e501 commit 4aad9af

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

mustache_lint/js_helper.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,23 @@ public function run_eslint() {
8181
}
8282

8383
// We should only have problem messages for the one file passed.
84-
return $problems[0]->messages;
84+
$messages = $problems[0]->messages;
85+
86+
foreach ($messages as $problem) {
87+
$problem->linesource = '';
88+
if ($problem->line) {
89+
$lines = explode("\n", $this->js, $problem->line);
90+
if ($lines && count($lines) === $problem->line) {
91+
$problem->linesource = array_pop($lines);
92+
}
93+
}
94+
if (!property_exists($problem, 'source')) {
95+
// Fatal errors do not include a source.
96+
// Fill the entire source line.
97+
$problem->source = $problem->linesource;
98+
}
99+
}
100+
101+
return $messages;
85102
}
86103
}

0 commit comments

Comments
 (0)