Skip to content

Commit

Permalink
Fix: allow options to be optional when monkey patching escope.analyze (
Browse files Browse the repository at this point in the history
…fixes babel#470). (babel#484)
  • Loading branch information
Standard8 authored and hzoo committed Jun 8, 2017
1 parent a8003c0 commit 1aedb95
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ function monkeypatch(modules) {

var analyze = escope.analyze;
escope.analyze = function (ast, opts) {
opts = opts || {};
opts.ecmaVersion = eslintOptions.ecmaVersion;
opts.sourceType = eslintOptions.sourceType;
if (eslintOptions.globalReturn !== undefined) {
Expand Down
11 changes: 11 additions & 0 deletions test/babel-eslint.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var assert = require("assert");
var babelEslint = require("..");
var espree = require("espree");
var escope = require("escope");
var util = require("util");
var unpad = require("dedent");

Expand Down Expand Up @@ -85,6 +86,16 @@ function parseAndAssertSame(code) {
}

describe("babylon-to-esprima", () => {
describe("compatibility", () => {
it("should allow ast.analyze to be called without options", function() {
var esAST = babelEslint.parse("`test`");

assert.doesNotThrow(() => {
escope.analyze(esAST);
}, TypeError, "Should allow no options argument.");
});
});

describe("templates", () => {
it("empty template string", () => {
parseAndAssertSame("``");
Expand Down

0 comments on commit 1aedb95

Please sign in to comment.