@@ -366,6 +366,7 @@ exports.parse = function (code, options) {
366366
367367exports . parseNoPatch = function ( code , options ) {
368368 var opts = {
369+ codeFrame : options . hasOwnProperty ( "codeFrame" ) ? options . codeFrame : true ,
369370 sourceType : options . sourceType ,
370371 allowImportExportEverywhere : options . allowImportExportEverywhere , // consistent with espree
371372 allowReturnOutsideFunction : true ,
@@ -394,14 +395,20 @@ exports.parseNoPatch = function (code, options) {
394395 ast = parse ( code , opts ) ;
395396 } catch ( err ) {
396397 if ( err instanceof SyntaxError ) {
398+
397399 err . lineNumber = err . loc . line ;
398- err . column = err . loc . column + 1 ;
400+ err . column = err . loc . column ;
401+
402+ if ( opts . codeFrame ) {
403+ err . lineNumber = err . loc . line ;
404+ err . column = err . loc . column + 1 ;
399405
400- // remove trailing "(LINE:COLUMN)" acorn message and add in esprima syntax error message start
401- err . message = "Line " + err . lineNumber + ": " + err . message . replace ( / \( ( \d + ) : ( \d + ) \) $ / , "" ) +
402- // add codeframe
403- "\n\n" +
404- codeFrame ( code , err . lineNumber , err . column , { highlightCode : true } ) ;
406+ // remove trailing "(LINE:COLUMN)" acorn message and add in esprima syntax error message start
407+ err . message = "Line " + err . lineNumber + ": " + err . message . replace ( / \( ( \d + ) : ( \d + ) \) $ / , "" ) +
408+ // add codeframe
409+ "\n\n" +
410+ codeFrame ( code , err . lineNumber , err . column , { highlightCode : true } ) ;
411+ }
405412 }
406413
407414 throw err ;
0 commit comments