[Pkg-javascript-commits] [node-syntax-error] 24/47: updates for acorn

Bastien Roucariès rouca at moszumanska.debian.org
Fri Aug 25 19:29:59 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-syntax-error.

commit e5e5770cf9dc5c3cd3b700de0c5266d52397bb9f
Author: James Halliday <mail at substack.net>
Date:   Sat Jul 26 15:33:31 2014 -0700

    updates for acorn
---
 index.js      | 15 +++++++--------
 test/check.js |  2 +-
 test/html.js  |  2 +-
 3 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/index.js b/index.js
index 9acae6b..ed8acae 100644
--- a/index.js
+++ b/index.js
@@ -1,4 +1,5 @@
-var esprima = require('esprima-fb');
+var aparse = require('acorn').parse;
+function parse (src) { return aparse(src, { ecmaVersion: 6 }) }
 
 module.exports = function (src, file) {
     if (typeof src !== 'string') src = String(src);
@@ -15,22 +16,20 @@ module.exports = function (src, file) {
 };
 
 function errorInfo (src, file) {
-    try {
-        esprima.parse(src);
-        return;
-    }
+    try { parse(src) }
     catch (err) {
         return new ParseError(err, src, file);
     }
+    return undefined;
 }
 
 function ParseError (err, src, file) {
     SyntaxError.call(this);
     
-    this.message = err.message.replace(/^Line \d+: /, '');
+    this.message = err.message.replace(/\s+\(\d+:\d+\)$/, '');
     
-    this.line = err.lineNumber;
-    this.column = err.column;
+    this.line = err.loc.line;
+    this.column = err.loc.column + 1;
     
     this.annotated = '\n'
         + (file || '(anonymous file)')
diff --git a/test/check.js b/test/check.js
index 50ae3d9..f820477 100644
--- a/test/check.js
+++ b/test/check.js
@@ -11,7 +11,7 @@ test('check', function (t) {
     t.ok(err);
     t.equal(err.line, 5);
     t.equal(err.column, 30);
-    t.equal(err.message, 'Unexpected identifier');
+    t.equal(err.message, 'Unexpected token');
     t.ok(String(err).indexOf(file + ':5'));
     t.end();
 });
diff --git a/test/html.js b/test/html.js
index 2fc0fdb..2af4376 100644
--- a/test/html.js
+++ b/test/html.js
@@ -10,7 +10,7 @@ test('html', function (t) {
     t.ok(err);
     t.equal(err.line, 1);
     t.equal(err.column, 1);
-    t.equal(err.message, 'Unexpected token <');
+    t.equal(err.message, 'Unexpected token');
     t.ok(/foo.js:1/.test(err), 'foo.js:1');
     t.end();
 });

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-syntax-error.git



More information about the Pkg-javascript-commits mailing list