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 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
Original file line number Diff line number Diff line change @@ -177,7 +177,11 @@ setup () {
177177 # Assert result
178178 assert_failure
179179 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: ^"
181185}
182186
183187@test " mustache_lint: Test eslint handles parsing failures safely" {
@@ -195,7 +199,10 @@ setup () {
195199
196200 # Assert result
197201 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: ^"
199206}
200207
201208@test " mustache_lint: Test eslint runs ok when invoked from any directory" {
You can’t perform that action at this time.
0 commit comments