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

Commit 1aedb95

Browse files
Standard8hzoo
authored andcommitted
Fix: allow options to be optional when monkey patching escope.analyze (fixes #470). (#484)
1 parent a8003c0 commit 1aedb95

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

index.js

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ function monkeypatch(modules) {
6262

6363
var analyze = escope.analyze;
6464
escope.analyze = function (ast, opts) {
65+
opts = opts || {};
6566
opts.ecmaVersion = eslintOptions.ecmaVersion;
6667
opts.sourceType = eslintOptions.sourceType;
6768
if (eslintOptions.globalReturn !== undefined) {

test/babel-eslint.js

+11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
var assert = require("assert");
22
var babelEslint = require("..");
33
var espree = require("espree");
4+
var escope = require("escope");
45
var util = require("util");
56
var unpad = require("dedent");
67

@@ -85,6 +86,16 @@ function parseAndAssertSame(code) {
8586
}
8687

8788
describe("babylon-to-esprima", () => {
89+
describe("compatibility", () => {
90+
it("should allow ast.analyze to be called without options", function() {
91+
var esAST = babelEslint.parse("`test`");
92+
93+
assert.doesNotThrow(() => {
94+
escope.analyze(esAST);
95+
}, TypeError, "Should allow no options argument.");
96+
});
97+
});
98+
8899
describe("templates", () => {
89100
it("empty template string", () => {
90101
parseAndAssertSame("``");

0 commit comments

Comments
 (0)