Skip to content
This repository has been archived by the owner on Aug 18, 2021. It is now read-only.

Commit

Permalink
Merge pull request #3 from researchgate/fix-tests-eslint2
Browse files Browse the repository at this point in the history
Fix remaining eslint2 test failures
  • Loading branch information
hzoo committed Mar 2, 2016
2 parents 07c6059 + 285110e commit 2d0ae9e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
1 change: 0 additions & 1 deletion babylon-to-espree/toAST.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ var source;

module.exports = function (ast, traverse, code) {
source = code;
ast.sourceType = "module";
ast.range = [ast.start, ast.end];
traverse(ast, astTransformVisitor);
};
Expand Down
12 changes: 7 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,20 +380,22 @@ function monkeypatch() {
};
}

exports.parse = function (code) {
exports.parse = function (code, options) {
options = options || {};

try {
monkeypatch();
} catch (err) {
console.error(err.stack);
process.exit(1);
}

return exports.parseNoPatch(code);
return exports.parseNoPatch(code, options);
}

exports.parseNoPatch = function (code) {
exports.parseNoPatch = function (code, options) {
var opts = {
sourceType: "module",
sourceType: options.sourceType || "module",
strictMode: true,
allowImportExportEverywhere: false, // consistent with espree
allowReturnOutsideFunction: true,
Expand Down Expand Up @@ -422,7 +424,7 @@ exports.parseNoPatch = function (code) {
} catch (err) {
if (err instanceof SyntaxError) {
err.lineNumber = err.loc.line;
err.column = err.loc.column;
err.column = err.loc.column + 1;

// remove trailing "(LINE:COLUMN)" acorn message and add in esprima syntax error message start
err.message = "Line " + err.lineNumber + ": " + err.message.replace(/ \((\d+):(\d+)\)$/, "");
Expand Down
3 changes: 3 additions & 0 deletions test/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ var errorLevel = 2;

var baseEslintOpts = {
parser: require.resolve(".."),
parserOptions: {
sourceType: "script"
}
};

/**
Expand Down

0 comments on commit 2d0ae9e

Please sign in to comment.