File tree Expand file tree Collapse file tree 2 files changed +22
-4
lines changed Expand file tree Collapse file tree 2 files changed +22
-4
lines changed Original file line number Diff line number Diff line change 140
140
// When we have no example context, parse errors are common because
141
141
// there are missing variables in the js, thus we ignore them.
142
142
$ ignoreparseerrors = empty ($ example ) ? true : false ;
143
+ print_message ('INFO ' , 'ESLint reported JavaScript errors ' );
143
144
print_eslint_problems ($ eslintproblems , $ ignoreparseerrors );
144
145
}
145
146
@@ -260,8 +261,18 @@ function print_eslint_problems($problems, $ignoreparseerrors) {
260
261
} else {
261
262
$ severity = 'warning ' ;
262
263
}
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
+ }
265
276
}
266
277
}
267
278
Original file line number Diff line number Diff line change @@ -177,7 +177,11 @@ setup () {
177
177
# Assert result
178
178
assert_failure
179
179
assert_output --partial " lib/templates/js_test.mustache - WARNING: ESLint warning [camelcase]: Identifier 'my_message' is not in camel case"
180
- assert_output --partial " lib/templates/js_test.mustache - WARNING: ESLint warning [no-alert]: Unexpected alert. ( alert(my_message); )"
180
+ assert_output --partial " lib/templates/js_test.mustache - WARNING: var my_message = 'Hello World!';"
181
+ assert_output --partial " lib/templates/js_test.mustache - WARNING: ^"
182
+ assert_output --partial " lib/templates/js_test.mustache - WARNING: ESLint warning [no-alert]: Unexpected alert."
183
+ assert_output --partial " lib/templates/js_test.mustache - WARNING: alert(my_message);"
184
+ assert_output --partial " lib/templates/js_test.mustache - WARNING: ^"
181
185
}
182
186
183
187
@test " mustache_lint: Test eslint handles parsing failures safely" {
@@ -195,7 +199,10 @@ setup () {
195
199
196
200
# Assert result
197
201
assert_failure
198
- assert_output --partial " lib/templates/js_token_test.mustache - WARNING: ESLint error []: Parsing error: Unexpected token bar ( var foo bar baz = 'bum'; )"
202
+ assert_output --partial " lib/templates/js_token_test.mustache - INFO: ESLint reported JavaScript errors"
203
+ assert_output --partial " lib/templates/js_token_test.mustache - WARNING: ESLint error []: Parsing error: Unexpected token bar, Line: 2 Column: 13"
204
+ assert_output --partial " lib/templates/js_token_test.mustache - WARNING: var foo bar baz = 'bum';"
205
+ assert_output --partial " lib/templates/js_token_test.mustache - WARNING: ^"
199
206
}
200
207
201
208
@test " mustache_lint: Test eslint runs ok when invoked from any directory" {
You can’t perform that action at this time.
0 commit comments