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

Commit

Permalink
Chore: Remove es6-map and es6-weakmap as they are included in node4 (#10
Browse files Browse the repository at this point in the history
) (#13)
  • Loading branch information
corbinu authored and JamesHenry committed Feb 22, 2017
1 parent 12a1ca1 commit 31b0085
Show file tree
Hide file tree
Showing 43 changed files with 162 additions and 5,723 deletions.
1 change: 0 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ npm-debug.log
.DS_Store
.vimrc.local
t.js
esprima.js
.travis.yml
.npmignore
/tmp/
Expand Down
2 changes: 1 addition & 1 deletion Makefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const NODE = "node",
// Files
MAKEFILE = "./Makefile.js",
JS_FILES = "src/**/*.js",
TEST_FILES = "test/**/*.js";
TEST_FILES = "test/*.js";

//------------------------------------------------------------------------------
// Tasks
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ Example:

```js
var eslintScope = require('eslint-scope');
var esprima = require('esprima');
var espree = require('espree');
var estraverse = require('estraverse');

var ast = esprima.parse(code);
var ast = espree.parse(code);
var scopeManager = eslintScope.analyze(ast);

var currentScope = scopeManager.acquire(ast); // global scope

estraverse.traverse(ast, {
enter: function(node, parent) {
// do stuff

if (/Function/.test(node.type)) {
currentScope = scopeManager.acquire(node); // get current function scope
}
Expand All @@ -34,7 +34,7 @@ estraverse.traverse(ast, {
if (/Function/.test(node.type)) {
currentScope = currentScope.upper; // set to parent scope
}

// do stuff
}
});
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"eslint-config-eslint": "^3.0.0",
"eslint-release": "^0.10.1",
"espree": "^3.1.1",
"esprima": "^2.7.1",
"istanbul": "^0.4.5",
"mocha": "^3.2.0",
"npm-license": "^0.3.3",
Expand Down
6 changes: 3 additions & 3 deletions src/definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ class Definition {
*/
this.type = type;
/**
* @member {esprima.Identifier} Definition#name - the identifier AST node of the occurrence.
* @member {espree.Identifier} Definition#name - the identifier AST node of the occurrence.
*/
this.name = name;
/**
* @member {esprima.Node} Definition#node - the enclosing node of the identifier.
* @member {espree.Node} Definition#node - the enclosing node of the identifier.
*/
this.node = node;
/**
* @member {esprima.Node?} Definition#parent - the enclosing statement node of the identifier.
* @member {espree.Node?} Definition#parent - the enclosing statement node of the identifier.
*/
this.parent = parent;
/**
Expand Down
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
* <em>escope</em> works on a syntax tree of the parsed source code which has
* to adhere to the <a
* href="https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API">
* Mozilla Parser API</a>. E.g. <a href="http://esprima.org">esprima</a> is a parser
* Mozilla Parser API</a>. E.g. <a href="https://github.com/eslint/espree">espree</a> is a parser
* that produces such syntax trees.
* <p>
* The main interface is the {@link analyze} function.
Expand Down Expand Up @@ -111,10 +111,10 @@ function updateDeeply(target, override) {
}

/**
* Main interface function. Takes an Esprima syntax tree and returns the
* Main interface function. Takes an Espree syntax tree and returns the
* analyzed scopes.
* @function analyze
* @param {esprima.Tree} tree - Abstract Syntax Tree
* @param {espree.Tree} tree - Abstract Syntax Tree
* @param {Object} providedOptions - Options that tailor the scope analysis
* @param {boolean} [providedOptions.optimistic=false] - the optimistic flag
* @param {boolean} [providedOptions.directive=false]- the directive flag
Expand Down
2 changes: 1 addition & 1 deletion src/pattern-visitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class PatternVisitor extends esrecurse.Visitor {
// ForInStatement.left and AssignmentExpression.left are LeftHandSideExpression.
// By spec, LeftHandSideExpression is Pattern or MemberExpression.
// (see also: https://github.com/estree/estree/pull/20#issuecomment-74584758)
// But espree 2.0 and esprima 2.0 parse to ArrayExpression, ObjectExpression, etc...
// But espree 2.0 parses to ArrayExpression, ObjectExpression, etc...
//

SpreadElement(node) {
Expand Down
4 changes: 2 additions & 2 deletions src/reference.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Reference {
constructor(ident, scope, flag, writeExpr, maybeImplicitGlobal, partial, init) {
/**
* Identifier syntax node.
* @member {esprima#Identifier} Reference#identifier
* @member {espreeIdentifier} Reference#identifier
*/
this.identifier = ident;
/**
Expand Down Expand Up @@ -64,7 +64,7 @@ class Reference {
if (this.isWrite()) {
/**
* If reference is writeable, this is the tree being written to it.
* @member {esprima#Node} Reference#writeExpr
* @member {espreeNode} Reference#writeExpr
*/
this.writeExpr = writeExpr;
/**
Expand Down
8 changes: 4 additions & 4 deletions src/scope-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class ScopeManager {
* If the node declares nothing, this method returns an empty array.
* CAUTION: This API is experimental. See https://github.com/estools/escope/pull/69 for more details.
*
* @param {Esprima.Node} node - a node to get.
* @param {Espree.Node} node - a node to get.
* @returns {Variable[]} variables that declared by the node.
*/
getDeclaredVariables(node) {
Expand All @@ -103,7 +103,7 @@ class ScopeManager {
/**
* acquire scope from node.
* @method ScopeManager#acquire
* @param {Esprima.Node} node - node for the acquired scope.
* @param {Espree.Node} node - node for the acquired scope.
* @param {boolean=} inner - look up the most inner scope, default value is false.
* @returns {Scope?} Scope from node
*/
Expand Down Expand Up @@ -158,7 +158,7 @@ class ScopeManager {
/**
* acquire all scopes from node.
* @method ScopeManager#acquireAll
* @param {Esprima.Node} node - node for the acquired scope.
* @param {Espree.Node} node - node for the acquired scope.
* @returns {Scopes?} Scope array
*/
acquireAll(node) {
Expand All @@ -168,7 +168,7 @@ class ScopeManager {
/**
* release the node.
* @method ScopeManager#release
* @param {Esprima.Node} node - releasing node.
* @param {Espree.Node} node - releasing node.
* @param {boolean=} inner - look up the most inner scope, default value is false.
* @returns {Scope?} upper scope for the node.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class Scope {
this.dynamic = this.type === "global" || this.type === "with";
/**
* A reference to the scope-defining syntax node.
* @member {esprima.Node} Scope#block
* @member {espree.Node} Scope#block
*/
this.block = block;
/**
Expand Down Expand Up @@ -428,7 +428,7 @@ class Scope {
/**
* returns resolved {Reference}
* @method Scope#resolve
* @param {Esprima.Identifier} ident - identifier to be resolved.
* @param {Espree.Identifier} ident - identifier to be resolved.
* @returns {Reference} reference
*/
resolve(ident) {
Expand Down
2 changes: 1 addition & 1 deletion src/variable.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Variable {
/**
* List of defining occurrences of this variable (like in 'var ...'
* statements or as parameter), as AST nodes.
* @member {esprima.Identifier[]} Variable#identifiers
* @member {espree.Identifier[]} Variable#identifiers
*/
this.identifiers = [];
/**
Expand Down
4 changes: 2 additions & 2 deletions test/arguments.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
/* eslint-disable no-unused-expressions */

const expect = require("chai").expect;
const esprima = require("esprima");
const espree = require("./util/espree");
const analyze = require("..").analyze;

describe("arguments", function() {
it("arguments are correctly materialized", function() {
const ast = esprima.parse(`
const ast = espree(`
(function () {
arguments;
}());
Expand Down
4 changes: 2 additions & 2 deletions test/catch-scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
/* eslint-disable no-unused-expressions */

const expect = require("chai").expect;
const esprima = require("esprima");
const espree = require("./util/espree");
const analyze = require("..").analyze;

describe("catch", function() {
it("creates scope", function() {
const ast = esprima.parse(`
const ast = espree(`
(function () {
try {
} catch (e) {
Expand Down
8 changes: 4 additions & 4 deletions test/child-visitor-keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
"use strict";

const expect = require("chai").expect;
const esprima = require("esprima");
const espree = require("./util/espree");
const analyze = require("..").analyze;

describe("childVisitorKeys option", function() {
it("should handle as a known node if the childVisitorKeys option was given.", function() {
const ast = esprima.parse(`
const ast = espree(`
var foo = 0;
`);

Expand All @@ -47,7 +47,7 @@ describe("childVisitorKeys option", function() {
});

it("should not visit to properties which are not given.", function() {
const ast = esprima.parse(`
const ast = espree(`
let foo = bar;
`);

Expand All @@ -73,7 +73,7 @@ describe("childVisitorKeys option", function() {
});

it("should visit to given properties.", function() {
const ast = esprima.parse(`
const ast = espree(`
let foo = bar;
`);

Expand Down
6 changes: 3 additions & 3 deletions test/es6-arrow-function-expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
/* eslint-disable no-unused-expressions */

const expect = require("chai").expect;
const parse = require("../third_party/esprima").parse;
const espree = require("./util/espree");
const analyze = require("..").analyze;

describe("ES6 arrow function expression", function() {
it("materialize scope for arrow function expression", function() {
const ast = parse(`
const ast = espree(`
var arrow = () => {
let i = 0;
var j = 20;
Expand Down Expand Up @@ -58,7 +58,7 @@ describe("ES6 arrow function expression", function() {
});

it("generate bindings for parameters", function() {
const ast = parse("var arrow = (a, b, c, d) => {}");
const ast = espree("var arrow = (a, b, c, d) => {}");

const scopeManager = analyze(ast, {ecmaVersion: 6});
expect(scopeManager.scopes).to.have.length(2);
Expand Down
12 changes: 6 additions & 6 deletions test/es6-block-scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
/* eslint-disable no-unused-expressions */

const expect = require("chai").expect;
const parse = require("../third_party/esprima").parse;
const espree = require("./util/espree");
const analyze = require("..").analyze;

describe("ES6 block scope", function() {
it("let is materialized in ES6 block scope#1", function() {
const ast = parse(`
const ast = espree(`
{
let i = 20;
i;
Expand All @@ -54,7 +54,7 @@ describe("ES6 block scope", function() {
});

it("let is materialized in ES6 block scope#2", function() {
const ast = parse(`
const ast = espree(`
{
let i = 20;
var i = 20;
Expand All @@ -81,7 +81,7 @@ describe("ES6 block scope", function() {
});

it("function delaration is materialized in ES6 block scope", function() {
const ast = parse(`
const ast = espree(`
{
function test() {
}
Expand Down Expand Up @@ -111,7 +111,7 @@ describe("ES6 block scope", function() {
});

it("let is not hoistable#1", function() {
const ast = parse(`
const ast = espree(`
var i = 42; (1)
{
i; // (2) ReferenceError at runtime.
Expand Down Expand Up @@ -140,7 +140,7 @@ describe("ES6 block scope", function() {
});

it("let is not hoistable#2", function() {
const ast = parse(`
const ast = espree(`
(function () {
var i = 42; // (1)
i; // (1)
Expand Down
19 changes: 8 additions & 11 deletions test/es6-catch.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
/* eslint-disable no-unused-expressions */

const expect = require("chai").expect;
const parse = require("../third_party/esprima").parse;
const espree = require("./util/espree");
const analyze = require("..").analyze;

describe("ES6 catch", function() {
it("takes binding pattern", function() {
const ast = parse(`
const ast = espree(`
try {
} catch ({ a, b, c, d }) {
let e = 20;
Expand Down Expand Up @@ -64,15 +64,12 @@ describe("ES6 catch", function() {
expect(scope.block.type).to.be.equal("CatchClause");
expect(scope.isStrict).to.be.false;

// FIXME After Esprima's bug is fixed, I'll add tests #33
// https://github.com/estools/escope/issues/33#issuecomment-64135832
//
// expect(scope.variables).to.have.length(4);
// expect(scope.variables[0].name).to.be.equal('a');
// expect(scope.variables[1].name).to.be.equal('b');
// expect(scope.variables[2].name).to.be.equal('c');
// expect(scope.variables[3].name).to.be.equal('d');
// expect(scope.references).to.have.length(0);
expect(scope.variables).to.have.length(4);
expect(scope.variables[0].name).to.be.equal("a");
expect(scope.variables[1].name).to.be.equal("b");
expect(scope.variables[2].name).to.be.equal("c");
expect(scope.variables[3].name).to.be.equal("d");
expect(scope.references).to.have.length(0);

scope = scopeManager.scopes[3];
expect(scope.type).to.be.equal("block");
Expand Down
Loading

0 comments on commit 31b0085

Please sign in to comment.