From 204ba8641841c59f287a8fb2e1a2ef916f5b2499 Mon Sep 17 00:00:00 2001 From: Henry Zhu Date: Fri, 27 Nov 2015 15:42:16 -0500 Subject: [PATCH] Merge pull request babel/babel-eslint#215 from zertosh/master babylon/espree option alignment --- eslint/babel-eslint-parser/index.js | 9 ++++----- eslint/babel-eslint-parser/test/babel-eslint.js | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/eslint/babel-eslint-parser/index.js b/eslint/babel-eslint-parser/index.js index ba3b784ea7..de3cdb0275 100644 --- a/eslint/babel-eslint-parser/index.js +++ b/eslint/babel-eslint-parser/index.js @@ -370,12 +370,11 @@ exports.parse = function (code) { exports.parseNoPatch = function (code) { var opts = { - locations: true, - ranges: true, sourceType: "module", strictMode: true, - allowHashBang: true, - ecmaVersion: Infinity, + allowImportExportEverywhere: false, // consistent with espree + allowReturnOutsideFunction: true, + allowSuperOutsideMethod: true, plugins: [ "flow", "jsx", @@ -391,7 +390,7 @@ exports.parseNoPatch = function (code) { "objectRestSpread", "trailingFunctionCommas" ] -}; + }; var ast; try { diff --git a/eslint/babel-eslint-parser/test/babel-eslint.js b/eslint/babel-eslint-parser/test/babel-eslint.js index c4266de500..b4498042fe 100644 --- a/eslint/babel-eslint-parser/test/babel-eslint.js +++ b/eslint/babel-eslint-parser/test/babel-eslint.js @@ -388,4 +388,18 @@ describe("acorn-to-esprima", function () { "}" ].join("\n")); }); + + it("do not allow import export everywhere", function() { + assert.throws(function () { + parseAndAssertSame("function F() { import a from \"a\"; }"); + }, /Illegal import declaration/) + }); + + it("return outside function", function () { + parseAndAssertSame("return;"); + }); + + it("super outside method", function () { + parseAndAssertSame("function F() { super(); }"); + }); });