diff --git a/.babelrc b/.babelrc deleted file mode 100644 index c13c5f6..0000000 --- a/.babelrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "presets": ["es2015"] -} diff --git a/.travis.yml b/.travis.yml index dd43cd3..f441e71 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,17 +1,8 @@ -sudo: false language: node_js node_js: - - "0.10" - - "0.11" - - "0.12" - - "iojs-1" - - "iojs-2" - - "iojs-3" - - "4" -matrix: - allow_failures: - - node_js: - - "0.11" - - "iojs-1" - - "iojs-2" - - "iojs-3" + - "4" + - "5" + - "6" + - "7" +sudo: false +script: "npm test" \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index 19cbd71..0a19fd7 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -26,7 +26,6 @@ var gulp = require('gulp'), mocha = require('gulp-mocha'), - babel = require('gulp-babel'), git = require('gulp-git'), bump = require('gulp-bump'), filter = require('gulp-filter'), @@ -38,10 +37,6 @@ var gulp = require('gulp'), eslint = require('gulp-eslint'), fs = require('fs'); -require('babel-register')({ - only: /eslint-scope\/(src|test)\// -}); - var TEST = [ 'test/*.js' ]; var SOURCE = [ 'src/**/*.js' ]; @@ -68,23 +63,7 @@ var ESLINT_OPTION = { } }; -var BABEL_OPTIONS = JSON.parse(fs.readFileSync('.babelrc', { encoding: 'utf8' })); - -var build = lazypipe() - .pipe(sourcemaps.init) - .pipe(babel, BABEL_OPTIONS) - .pipe(sourcemaps.write) - .pipe(gulp.dest, 'lib'); - -gulp.task('build-for-watch', function () { - return gulp.src(SOURCE).pipe(plumber()).pipe(build()); -}); - -gulp.task('build', function () { - return gulp.src(SOURCE).pipe(build()); -}); - -gulp.task('test', [ 'lint', 'build' ], function () { +gulp.task('test', function () { return gulp.src(TEST) .pipe(mocha({ reporter: 'spec', @@ -92,10 +71,6 @@ gulp.task('test', [ 'lint', 'build' ], function () { })); }); -gulp.task('watch', [ 'build-for-watch' ], function () { - gulp.watch(SOURCE, [ 'build-for-watch' ]); -}); - // Currently, not works for ES6. gulp.task('lint', function () { return gulp.src(SOURCE) @@ -135,9 +110,9 @@ function inc(importance) { })); } -gulp.task('patch', [ 'build' ], function () { return inc('patch'); }) -gulp.task('minor', [ 'build' ], function () { return inc('minor'); }) -gulp.task('major', [ 'build' ], function () { return inc('major'); }) +gulp.task('patch', function () { return inc('patch'); }) +gulp.task('minor', function () { return inc('minor'); }) +gulp.task('major', function () { return inc('major'); }) gulp.task('travis', [ 'test' ]); -gulp.task('default', [ 'travis' ]); +gulp.task('default', [ 'travis' ]); \ No newline at end of file diff --git a/package.json b/package.json index fe019d1..b2772e1 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "eslint-scope", "description": "ECMAScript scope analyzer for ESLint", "homepage": "http://github.com/eslint/eslint-scope", - "main": "lib/index.js", + "main": "src/index.js", "version": "3.6.0", "engines": { "node": ">=0.4.0" @@ -29,15 +29,11 @@ "estraverse": "^4.1.1" }, "devDependencies": { - "babel": "^6.3.26", - "babel-preset-es2015": "^6.3.13", - "babel-register": "^6.3.13", "chai": "^3.4.1", "eslint-release": "^0.10.1", "espree": "^3.1.1", "esprima": "^2.7.1", "gulp": "^3.9.0", - "gulp-babel": "^6.1.1", "gulp-bump": "^1.0.0", "gulp-eslint": "^1.1.1", "gulp-espower": "^1.0.2", diff --git a/src/definition.js b/src/definition.js index faef938..54ee3c6 100644 --- a/src/definition.js +++ b/src/definition.js @@ -21,13 +21,14 @@ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +"use strict"; -import Variable from './variable'; +const Variable = require('./variable'); /** * @class Definition */ -export default class Definition { +class Definition { constructor(type, name, node, parent, index, kind) { /** * @member {String} Definition#type - type of the occurrence (e.g. "Parameter", "Variable", ...). @@ -70,9 +71,9 @@ class ParameterDefinition extends Definition { } } -export { +module.exports = { ParameterDefinition, Definition -} +}; /* vim: set sw=4 ts=4 et tw=80 : */ diff --git a/src/index.js b/src/index.js index a345e1c..320dfd8 100644 --- a/src/index.js +++ b/src/index.js @@ -45,17 +45,18 @@ * The main interface is the {@link analyze} function. * @module escope */ +"use strict"; /*jslint bitwise:true */ -import assert from 'assert'; +const assert = require('assert'); -import ScopeManager from './scope-manager'; -import Referencer from './referencer'; -import Reference from './reference'; -import Variable from './variable'; -import Scope from './scope'; -import { version } from '../package.json'; +const ScopeManager = require('./scope-manager'); +const Referencer = require('./referencer'); +const Reference = require('./reference'); +const Variable = require('./variable'); +const Scope = require('./scope'); +const version = require('../package.json').version; function defaultOptions() { return { @@ -114,7 +115,7 @@ function updateDeeply(target, override) { * @param {string} [providedOptions.fallback='iteration'] - A kind of the fallback in order to encounter with unknown node. See [esrecurse](https://github.com/estools/esrecurse)'s the `fallback` option. * @return {ScopeManager} */ -export function analyze(tree, providedOptions) { +function analyze(tree, providedOptions) { var scopeManager, referencer, options; options = updateDeeply(defaultOptions(), providedOptions); @@ -129,7 +130,7 @@ export function analyze(tree, providedOptions) { return scopeManager; } -export { +module.exports = { /** @name module:escope.version */ version, /** @name module:escope.Reference */ @@ -139,7 +140,8 @@ export { /** @name module:escope.Scope */ Scope, /** @name module:escope.ScopeManager */ - ScopeManager + ScopeManager, + analyze }; diff --git a/src/pattern-visitor.js b/src/pattern-visitor.js index b98e98a..bd4bcb7 100644 --- a/src/pattern-visitor.js +++ b/src/pattern-visitor.js @@ -21,15 +21,16 @@ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +"use strict"; -import { Syntax } from 'estraverse'; -import esrecurse from 'esrecurse'; +const Syntax = require('estraverse').Syntax; +const esrecurse = require('esrecurse'); function getLast(xs) { return xs[xs.length - 1] || null; } -export default class PatternVisitor extends esrecurse.Visitor { +class PatternVisitor extends esrecurse.Visitor { static isPattern(node) { var nodeType = node.type; return ( @@ -131,4 +132,6 @@ export default class PatternVisitor extends esrecurse.Visitor { } } +module.exports = PatternVisitor; + /* vim: set sw=4 ts=4 et tw=80 : */ diff --git a/src/reference.js b/src/reference.js index 7f273a3..8775440 100644 --- a/src/reference.js +++ b/src/reference.js @@ -21,6 +21,7 @@ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +"use strict"; const READ = 0x1; const WRITE = 0x2; @@ -30,7 +31,7 @@ const RW = READ | WRITE; * A Reference represents a single occurrence of an identifier in code. * @class Reference */ -export default class Reference { +class Reference { constructor(ident, scope, flag, writeExpr, maybeImplicitGlobal, partial, init) { /** * Identifier syntax node. @@ -151,4 +152,6 @@ Reference.WRITE = WRITE; */ Reference.RW = RW; +module.exports = Reference; + /* vim: set sw=4 ts=4 et tw=80 : */ diff --git a/src/referencer.js b/src/referencer.js index bd81080..3cbf6d4 100644 --- a/src/referencer.js +++ b/src/referencer.js @@ -21,13 +21,18 @@ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import { Syntax } from 'estraverse'; -import esrecurse from 'esrecurse'; -import Reference from './reference'; -import Variable from './variable'; -import PatternVisitor from './pattern-visitor'; -import { ParameterDefinition, Definition } from './definition'; -import assert from 'assert'; +"use strict"; + +const Syntax = require('estraverse').Syntax; +const esrecurse = require('esrecurse'); +const Reference = require('./reference'); +const Variable = require('./variable'); +const PatternVisitor = require('./pattern-visitor'); +const definition = require('./definition'); +const assert = require('assert'); + +const ParameterDefinition = definition.ParameterDefinition; +const Definition = definition.Definition; function traverseIdentifierInPattern(options, rootPattern, referencer, callback) { // Call the callback at left hand identifier nodes, and Collect right hand nodes. @@ -90,7 +95,7 @@ class Importer extends esrecurse.Visitor { } // Referencing variables and creating bindings. -export default class Referencer extends esrecurse.Visitor { +class Referencer extends esrecurse.Visitor { constructor(options, scopeManager) { super(null, options); this.options = options; @@ -581,4 +586,6 @@ export default class Referencer extends esrecurse.Visitor { } } +module.exports = Referencer; + /* vim: set sw=4 ts=4 et tw=80 : */ diff --git a/src/scope-manager.js b/src/scope-manager.js index 024535d..90578f4 100644 --- a/src/scope-manager.js +++ b/src/scope-manager.js @@ -21,29 +21,28 @@ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -import WeakMap from 'es6-weak-map'; -import Scope from './scope'; -import assert from 'assert'; - -import { - GlobalScope, - CatchScope, - WithScope, - ModuleScope, - ClassScope, - SwitchScope, - FunctionScope, - ForScope, - TDZScope, - FunctionExpressionNameScope, - BlockScope -} from './scope'; +"use strict"; + +const WeakMap = require('es6-weak-map'); +const Scope = require('./scope'); +const assert = require('assert'); + +const GlobalScope = Scope.GlobalScope; +const CatchScope = Scope.CatchScope; +const WithScope = Scope.WithScope; +const ModuleScope = Scope.ModuleScope; +const ClassScope = Scope.ClassScope; +const SwitchScope = Scope.SwitchScope; +const FunctionScope = Scope.FunctionScope; +const ForScope = Scope.ForScope; +const TDZScope = Scope.TDZScope; +const FunctionExpressionNameScope = Scope.FunctionExpressionNameScope; +const BlockScope = Scope.BlockScope; /** * @class ScopeManager */ -export default class ScopeManager { +class ScopeManager { constructor(options) { this.scopes = []; this.globalScope = null; @@ -242,4 +241,6 @@ export default class ScopeManager { } } +module.exports = ScopeManager; + /* vim: set sw=4 ts=4 et tw=80 : */ diff --git a/src/scope.js b/src/scope.js index 0e4d8c2..988b2d4 100644 --- a/src/scope.js +++ b/src/scope.js @@ -21,14 +21,15 @@ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +"use strict"; -import { Syntax } from 'estraverse'; -import Map from 'es6-map'; +const Syntax = require('estraverse').Syntax; +const Map = require('es6-map'); -import Reference from './reference'; -import Variable from './variable'; -import Definition from './definition'; -import assert from 'assert'; +const Reference = require('./reference'); +const Variable = require('./variable'); +const Definition = require('./definition').Definition; +const assert = require('assert'); function isStrictScope(scope, block, isMethodDefinition, useDirective) { var body, i, iz, stmt, expr; @@ -125,7 +126,7 @@ function shouldBeStatically(def) { /** * @class Scope */ -export default class Scope { +class Scope { constructor(scopeManager, type, upperScope, block, isMethodDefinition) { /** * One of 'TDZ', 'module', 'block', 'switch', 'function', 'catch', 'with', 'function', 'class', 'global'. @@ -458,7 +459,7 @@ export default class Scope { } } -export class GlobalScope extends Scope { +class GlobalScope extends Scope { constructor(scopeManager, block) { super(scopeManager, 'global', null, block, false); this.implicit = { @@ -514,13 +515,13 @@ export class GlobalScope extends Scope { } } -export class ModuleScope extends Scope { +class ModuleScope extends Scope { constructor(scopeManager, upperScope, block) { super(scopeManager, 'module', upperScope, block, false); } } -export class FunctionExpressionNameScope extends Scope { +class FunctionExpressionNameScope extends Scope { constructor(scopeManager, upperScope, block) { super(scopeManager, 'function-expression-name', upperScope, block, false); this.__define(block.id, @@ -536,13 +537,13 @@ export class FunctionExpressionNameScope extends Scope { } } -export class CatchScope extends Scope { +class CatchScope extends Scope { constructor(scopeManager, upperScope, block) { super(scopeManager, 'catch', upperScope, block, false); } } -export class WithScope extends Scope { +class WithScope extends Scope { constructor(scopeManager, upperScope, block) { super(scopeManager, 'with', upperScope, block, false); } @@ -563,25 +564,25 @@ export class WithScope extends Scope { } } -export class TDZScope extends Scope { +class TDZScope extends Scope { constructor(scopeManager, upperScope, block) { super(scopeManager, 'TDZ', upperScope, block, false); } } -export class BlockScope extends Scope { +class BlockScope extends Scope { constructor(scopeManager, upperScope, block) { super(scopeManager, 'block', upperScope, block, false); } } -export class SwitchScope extends Scope { +class SwitchScope extends Scope { constructor(scopeManager, upperScope, block) { super(scopeManager, 'switch', upperScope, block, false); } } -export class FunctionScope extends Scope { +class FunctionScope extends Scope { constructor(scopeManager, upperScope, block, isMethodDefinition) { super(scopeManager, 'function', upperScope, block, isMethodDefinition); @@ -632,16 +633,31 @@ export class FunctionScope extends Scope { } } -export class ForScope extends Scope { + class ForScope extends Scope { constructor(scopeManager, upperScope, block) { super(scopeManager, 'for', upperScope, block, false); } } -export class ClassScope extends Scope { +class ClassScope extends Scope { constructor(scopeManager, upperScope, block) { super(scopeManager, 'class', upperScope, block, false); } } +module.exports = { + Scope, + GlobalScope, + ModuleScope, + FunctionExpressionNameScope, + CatchScope, + WithScope, + TDZScope, + BlockScope, + SwitchScope, + FunctionScope, + ForScope, + ClassScope +}; + /* vim: set sw=4 ts=4 et tw=80 : */ diff --git a/src/variable.js b/src/variable.js index 3945b38..40435e6 100644 --- a/src/variable.js +++ b/src/variable.js @@ -21,13 +21,14 @@ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +"use strict"; /** * A Variable represents a locally scoped identifier. These include arguments to * functions. * @class Variable */ -export default class Variable { +class Variable { constructor(name, scope) { /** * The variable name, as given in the source code. @@ -78,4 +79,6 @@ Variable.ImportBinding = 'ImportBinding'; Variable.TDZ = 'TDZ'; Variable.ImplicitGlobalVariable = 'ImplicitGlobalVariable'; +module.exports = Variable; + /* vim: set sw=4 ts=4 et tw=80 : */ diff --git a/test/arguments.js b/test/arguments.js index 2e32a43..73c2d95 100644 --- a/test/arguments.js +++ b/test/arguments.js @@ -20,10 +20,11 @@ // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +"use strict"; -import { expect } from 'chai'; -import esprima from 'esprima'; -import { analyze } from '..'; +const expect = require('chai').expect; +const esprima = require('esprima'); +const analyze = require('..').analyze; describe('arguments', function() { it('arguments are correctly materialized', function() { diff --git a/test/catch-scope.js b/test/catch-scope.js index 0e05e3c..cd4f58c 100644 --- a/test/catch-scope.js +++ b/test/catch-scope.js @@ -20,10 +20,11 @@ // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +"use strict"; -import { expect } from 'chai'; -import esprima from 'esprima'; -import { analyze } from '..'; +const expect = require('chai').expect; +const esprima = require('esprima'); +const analyze = require('..').analyze; describe('catch', function() { it('creates scope', function() { diff --git a/test/child-visitor-keys.js b/test/child-visitor-keys.js index c8d7095..49d39ad 100644 --- a/test/child-visitor-keys.js +++ b/test/child-visitor-keys.js @@ -20,10 +20,11 @@ // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +"use strict"; -import { expect } from 'chai'; -import esprima from 'esprima'; -import { analyze } from '..'; +const expect = require('chai').expect; +const esprima = require('esprima'); +const analyze = require('..').analyze; describe('childVisitorKeys option', function() { it('should handle as a known node if the childVisitorKeys option was given.', function() { diff --git a/test/es6-arrow-function-expression.js b/test/es6-arrow-function-expression.js index af0a687..5f99f89 100644 --- a/test/es6-arrow-function-expression.js +++ b/test/es6-arrow-function-expression.js @@ -20,10 +20,11 @@ // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +"use strict"; -import { expect } from 'chai'; -import { parse } from '../third_party/esprima'; -import { analyze } from '..'; +const expect = require('chai').expect; +const parse = require('../third_party/esprima').parse; +const analyze = require('..').analyze; describe('ES6 arrow function expression', function() { it('materialize scope for arrow function expression', function() { diff --git a/test/es6-block-scope.js b/test/es6-block-scope.js index 861cee8..79c4971 100644 --- a/test/es6-block-scope.js +++ b/test/es6-block-scope.js @@ -20,10 +20,11 @@ // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +"use strict"; -import { expect } from 'chai'; -import { parse } from '../third_party/esprima'; -import { analyze } from '..'; +const expect = require('chai').expect; +const parse = require('../third_party/esprima').parse; +const analyze = require('..').analyze; describe('ES6 block scope', function() { it('let is materialized in ES6 block scope#1', function() { diff --git a/test/es6-catch.js b/test/es6-catch.js index f05a4a6..c7bf5a5 100644 --- a/test/es6-catch.js +++ b/test/es6-catch.js @@ -20,9 +20,11 @@ // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -import { expect } from 'chai'; -import { parse } from '../third_party/esprima'; -import { analyze } from '..'; +"use strict"; + +const expect = require('chai').expect; +const parse = require('../third_party/esprima').parse; +const analyze = require('..').analyze; describe('ES6 catch', function() { it('takes binding pattern', function() { diff --git a/test/es6-class.js b/test/es6-class.js index 8c6ffac..78d5029 100644 --- a/test/es6-class.js +++ b/test/es6-class.js @@ -20,10 +20,11 @@ // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +"use strict"; -import { expect } from 'chai'; -import { parse } from '../third_party/esprima'; -import { analyze } from '..'; +const expect = require('chai').expect; +const parse = require('../third_party/esprima').parse; +const analyze = require('..').analyze; describe('ES6 class', function() { it('declaration name creates class scope', function() { diff --git a/test/es6-default-parameters.js b/test/es6-default-parameters.js index 96f1765..18339a4 100644 --- a/test/es6-default-parameters.js +++ b/test/es6-default-parameters.js @@ -20,10 +20,11 @@ // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +"use strict"; -import { expect } from 'chai'; -import espree from '../third_party/espree'; -import { analyze } from '..'; +const expect = require('chai').expect; +const espree = require('../third_party/espree'); +const analyze = require('..').analyze; describe('ES6 default parameters:', function() { describe('a default parameter creates a writable reference for its initialization:', function() { diff --git a/test/es6-destructuring-assignments.js b/test/es6-destructuring-assignments.js index 0d894c7..dcdbb92 100644 --- a/test/es6-destructuring-assignments.js +++ b/test/es6-destructuring-assignments.js @@ -20,11 +20,12 @@ // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +"use strict"; -import { expect } from 'chai'; -import harmony from '../third_party/esprima'; -import espree from '../third_party/espree'; -import { analyze } from '..'; +const expect = require('chai').expect; +const harmony = require('../third_party/esprima'); +const espree = require('../third_party/espree'); +const analyze = require('..').analyze; describe('ES6 destructuring assignments', function() { it('Pattern in var in ForInStatement', function() { @@ -713,7 +714,7 @@ describe('ES6 destructuring assignments', function() { expect(scope.variables).to.have.length(0); expect(scope.references).to.have.length(0); expect(scope.implicit.left).to.have.length(4); - expect(scope.implicit.left.map(({ identifier }) => identifier.name)).to.deep.equal([ + expect(scope.implicit.left.map((left) => left.identifier.name)).to.deep.equal([ 'a', 'b', 'c', @@ -797,7 +798,7 @@ describe('ES6 destructuring assignments', function() { expect(scope.variables).to.have.length(0); expect(scope.references).to.have.length(0); expect(scope.implicit.left).to.have.length(4); - expect(scope.implicit.left.map(({ identifier }) => identifier.name)).to.deep.equal([ + expect(scope.implicit.left.map((left) => left.identifier.name)).to.deep.equal([ 'a', 'b', 'rest', @@ -838,7 +839,7 @@ describe('ES6 destructuring assignments', function() { expect(scope.variables).to.have.length(0); expect(scope.references).to.have.length(0); expect(scope.implicit.left).to.have.length(6); - expect(scope.implicit.left.map(({ identifier }) => identifier.name)).to.deep.equal([ + expect(scope.implicit.left.map((left) => left.identifier.name)).to.deep.equal([ 'a', 'b', 'c', @@ -886,7 +887,7 @@ describe('ES6 destructuring assignments', function() { expect(scope.variables).to.have.length(0); expect(scope.references).to.have.length(0); expect(scope.implicit.left).to.have.length(4); - expect(scope.implicit.left.map(({ identifier }) => identifier.name)).to.deep.equal([ + expect(scope.implicit.left.map((left) => left.identifier.name)).to.deep.equal([ 'a', 'b', 'obj', @@ -933,7 +934,7 @@ describe('ES6 destructuring assignments', function() { expect(scope.variables).to.have.length(0); expect(scope.references).to.have.length(0); expect(scope.implicit.left).to.have.length(4); - expect(scope.implicit.left.map(({ identifier }) => identifier.name)).to.deep.equal([ + expect(scope.implicit.left.map((left) => left.identifier.name)).to.deep.equal([ 'shorthand', 'value', 'world', @@ -982,7 +983,7 @@ describe('ES6 destructuring assignments', function() { expect(scope.variables).to.have.length(0); expect(scope.references).to.have.length(0); expect(scope.implicit.left).to.have.length(8); - expect(scope.implicit.left.map(({ identifier }) => identifier.name)).to.deep.equal([ + expect(scope.implicit.left.map((left) => left.identifier.name)).to.deep.equal([ 'shorthand', 'a', 'b', diff --git a/test/es6-export.js b/test/es6-export.js index 018e7ec..6e7edca 100644 --- a/test/es6-export.js +++ b/test/es6-export.js @@ -20,10 +20,11 @@ // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +"use strict"; -import { expect } from 'chai'; -import espree from '../third_party/espree'; -import { analyze } from '..'; +const expect = require('chai').expect; +const espree = require('../third_party/espree'); +const analyze = require('..').analyze; describe('export declaration', function() { // http://people.mozilla.org/~jorendorff/es6-draft.html#sec-static-and-runtme-semantics-module-records diff --git a/test/es6-import.js b/test/es6-import.js index 48e996b..9b15e02 100644 --- a/test/es6-import.js +++ b/test/es6-import.js @@ -20,10 +20,11 @@ // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +"use strict"; -import { expect } from 'chai'; -import espree from '../third_party/espree'; -import { analyze } from '..'; +const expect = require('chai').expect; +const espree = require('../third_party/espree'); +const analyze = require('..').analyze; describe('import declaration', function() { // http://people.mozilla.org/~jorendorff/es6-draft.html#sec-static-and-runtme-semantics-module-records diff --git a/test/es6-iteration-scope.js b/test/es6-iteration-scope.js index d1957e7..123eb7d 100644 --- a/test/es6-iteration-scope.js +++ b/test/es6-iteration-scope.js @@ -20,10 +20,11 @@ // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +"use strict"; -import { expect } from 'chai'; -import { parse } from '../third_party/esprima'; -import { analyze } from '..'; +const expect = require('chai').expect; +const parse = require('../third_party/esprima').parse; +const analyze = require('..').analyze; describe('ES6 iteration scope', function() { it('let materialize iteration scope for ForInStatement#1', function() { diff --git a/test/es6-new-target.js b/test/es6-new-target.js index 029a31f..a31d5a1 100644 --- a/test/es6-new-target.js +++ b/test/es6-new-target.js @@ -20,9 +20,10 @@ // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +"use strict"; -import { expect } from 'chai'; -import { analyze } from '..'; +const expect = require('chai').expect; +const analyze = require('..').analyze; const parse = require('../third_party/espree'); diff --git a/test/es6-object.js b/test/es6-object.js index 0fd7623..12dfc68 100644 --- a/test/es6-object.js +++ b/test/es6-object.js @@ -20,10 +20,11 @@ // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +"use strict"; -import { expect } from 'chai'; -import { parse } from '../third_party/esprima'; -import { analyze } from '..'; +const expect = require('chai').expect; +const parse = require('../third_party/esprima').parse; +const analyze = require('..').analyze; describe('ES6 object', function() { it('method definition', function() { diff --git a/test/es6-rest-args.js b/test/es6-rest-args.js index 89ff2da..3a6165a 100644 --- a/test/es6-rest-args.js +++ b/test/es6-rest-args.js @@ -20,11 +20,12 @@ // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +"use strict"; -import { expect } from 'chai'; -import { parse as esprima } from '../third_party/esprima'; -import espree from '../third_party/espree'; -import { analyze } from '..'; +const expect = require('chai').expect; +const esprima = require('../third_party/esprima').parse; +const espree = require('../third_party/espree'); +const analyze = require('..').analyze; describe('ES6 rest arguments', function() { it('materialize rest argument in scope (esprima: rest property of FunctionDeclaration)', function() { diff --git a/test/es6-super.js b/test/es6-super.js index 4da988d..0ff5221 100644 --- a/test/es6-super.js +++ b/test/es6-super.js @@ -20,10 +20,11 @@ // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +"use strict"; -import { expect } from 'chai'; -import { parse } from '../third_party/esprima'; -import { analyze } from '..'; +const expect = require('chai').expect; +const parse = require('../third_party/esprima').parse; +const analyze = require('..').analyze; describe('ES6 super', function() { it('is not handled as reference', function() { diff --git a/test/es6-switch.js b/test/es6-switch.js index e32061a..217d214 100644 --- a/test/es6-switch.js +++ b/test/es6-switch.js @@ -20,10 +20,11 @@ // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +"use strict"; -import { expect } from 'chai'; -import { parse } from '../third_party/esprima'; -import { analyze } from '..'; +const expect = require('chai').expect; +const parse = require('../third_party/esprima').parse; +const analyze = require('..').analyze; describe('ES6 switch', function() { it('materialize scope', function() { diff --git a/test/es6-template-literal.js b/test/es6-template-literal.js index 113f795..a5127f4 100644 --- a/test/es6-template-literal.js +++ b/test/es6-template-literal.js @@ -20,10 +20,11 @@ // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +"use strict"; -import { expect } from 'chai'; -import { parse } from '../third_party/esprima'; -import { analyze } from '..'; +const expect = require('chai').expect; +const parse = require('../third_party/esprima').parse; +const analyze = require('..').analyze; describe('ES6 template literal', function() { it('refer variables', function() { diff --git a/test/fallback.js b/test/fallback.js index 0cd001c..574c813 100644 --- a/test/fallback.js +++ b/test/fallback.js @@ -20,10 +20,12 @@ // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +"use strict"; + +const expect = require('chai').expect; +const esprima = require('../third_party/esprima'); +const analyze = require('..').analyze; -import { expect } from 'chai'; -import esprima from 'esprima'; -import { analyze } from '..'; describe('fallback option', function() { it('should raise an error when it encountered an unknown node if no fallback.', function() { diff --git a/test/function-expression-name.js b/test/function-expression-name.js index e488b83..e720c44 100644 --- a/test/function-expression-name.js +++ b/test/function-expression-name.js @@ -20,10 +20,11 @@ // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +"use strict"; -import { expect } from 'chai'; -import { parse as parse } from 'esprima'; -import { analyze } from '..'; +const expect = require('chai').expect; +const parse = require('../third_party/esprima').parse; +const analyze = require('..').analyze; describe('function name', function() { it('should create its special scope', function() { diff --git a/test/get-declared-variables.js b/test/get-declared-variables.js index ef0e227..004b315 100644 --- a/test/get-declared-variables.js +++ b/test/get-declared-variables.js @@ -20,11 +20,12 @@ // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +"use strict"; -import { expect } from 'chai'; -import { visit } from 'esrecurse'; -import espree from '../third_party/espree'; -import { analyze } from '..'; +const expect = require('chai').expect; +const visit = require('esrecurse').visit; +const espree = require('../third_party/espree'); +const analyze = require('..').analyze; describe('ScopeManager.prototype.getDeclaredVariables', function() { const verify = (ast, type, expectedNamesList) => { diff --git a/test/global-increment.js b/test/global-increment.js index b613473..83f77b3 100644 --- a/test/global-increment.js +++ b/test/global-increment.js @@ -20,10 +20,11 @@ // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +"use strict"; -import { expect } from 'chai'; -import { parse } from 'esprima'; -import { analyze } from '..'; +const expect = require('chai').expect; +const parse = require('../third_party/esprima').parse; +const analyze = require('..').analyze; describe('global increment', function() { it('becomes read/write', function() { diff --git a/test/implicit-global-reference.js b/test/implicit-global-reference.js index 291560b..a9e04bf 100644 --- a/test/implicit-global-reference.js +++ b/test/implicit-global-reference.js @@ -19,11 +19,11 @@ // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +"use strict"; - -import { expect } from 'chai'; -import { analyze } from '..'; -import { parse } from 'esprima'; +const expect = require('chai').expect; +const parse = require('../third_party/esprima').parse; +const analyze = require('..').analyze; describe('implicit global reference', function() { it('assignments global scope', function() { @@ -32,7 +32,7 @@ describe('implicit global reference', function() { x = 300; `); - const { scopes } = analyze(ast); + const scopes = analyze(ast).scopes; expect(scopes.map(scope => scope.variables.map(variable => variable.defs.map(def => def.type)))).to.be.eql( [ @@ -53,7 +53,7 @@ describe('implicit global reference', function() { x = 300; `); - const { scopes } = analyze(ast); + const scopes = analyze(ast).scopes; expect(scopes.map(scope => scope.variables.map(variable => variable.defs.map(def => def.type)))).to.be.eql( [ @@ -77,7 +77,7 @@ describe('implicit global reference', function() { } `); - const { scopes } = analyze(ast); + const scopes = analyze(ast).scopes; expect(scopes.map(scope => scope.variables.map(variable => variable.defs.map(def => def.type)))).to.be.eql( [ @@ -103,7 +103,7 @@ describe('implicit global reference', function() { } `); - const { scopes } = analyze(ast); + const scopes = analyze(ast).scopes; expect(scopes.map(scope => scope.variables.map(variable => variable.name))).to.be.eql( [ @@ -133,7 +133,7 @@ describe('implicit global reference', function() { } `); - const { scopes } = analyze(ast); + const scopes = analyze(ast).scopes; expect(scopes.map(scope => scope.variables.map(variable => variable.name))).to.be.eql( [ @@ -161,7 +161,7 @@ describe('implicit global reference', function() { for (x in y) { } }`); - const { scopes } = analyze(ast); + const scopes = analyze(ast).scopes; expect(scopes.map(scope => scope.variables.map(variable => variable.name))).to.be.eql( [ @@ -191,7 +191,7 @@ describe('implicit global reference', function() { } `); - const { scopes } = analyze(ast); + const scopes = analyze(ast).scopes; expect(scopes.map(scope => scope.variables.map(variable => variable.name))).to.be.eql( [ diff --git a/test/implied-strict.js b/test/implied-strict.js index f415e15..148241b 100644 --- a/test/implied-strict.js +++ b/test/implied-strict.js @@ -20,10 +20,11 @@ // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +"use strict"; -import { expect } from 'chai'; -import { parse } from '../third_party/esprima'; -import { analyze } from '..'; +const expect = require('chai').expect; +const parse = require('../third_party/esprima').parse; +const analyze = require('..').analyze; describe('impliedStrict option', function() { it('ensures all user scopes are strict if ecmaVersion >= 5', function() { diff --git a/test/label.js b/test/label.js index 6b67f89..95e6b30 100644 --- a/test/label.js +++ b/test/label.js @@ -20,10 +20,11 @@ // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +"use strict"; -import { expect } from 'chai'; -import { parse } from 'esprima'; -import { analyze } from '..'; +const expect = require('chai').expect; +const parse = require('../third_party/esprima').parse; +const analyze = require('..').analyze; describe('label', function() { it('should not create variables', function() { diff --git a/test/nodejs-scope.js b/test/nodejs-scope.js index 2ea861e..dff2c11 100644 --- a/test/nodejs-scope.js +++ b/test/nodejs-scope.js @@ -20,10 +20,11 @@ // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +"use strict"; -import { expect } from 'chai'; -import { parse } from '../third_party/esprima'; -import { analyze } from '..'; +const expect = require('chai').expect; +const parse = require('../third_party/esprima').parse; +const analyze = require('..').analyze; describe('nodejsScope option', function() { it('creates a function scope following the global scope immediately', function() { diff --git a/test/object-expression.js b/test/object-expression.js index f36e28c..d8ad451 100644 --- a/test/object-expression.js +++ b/test/object-expression.js @@ -1,5 +1,7 @@ -import { expect } from 'chai'; -import { analyze } from '..'; +"use strict"; + +const expect = require('chai').expect; +const analyze = require('..').analyze; describe('object expression', function() { it('doesn\'t require property type', function() { diff --git a/test/optimistic.js b/test/optimistic.js index 4144d04..450dabb 100644 --- a/test/optimistic.js +++ b/test/optimistic.js @@ -19,11 +19,11 @@ // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +"use strict"; - -import { expect } from 'chai'; -import { analyze } from '..'; -import { parse } from 'esprima'; +const expect = require('chai').expect; +const parse = require('../third_party/esprima').parse; +const analyze = require('..').analyze; describe('optimistic', function() { it('direct call to eval', function() { @@ -37,7 +37,7 @@ describe('optimistic', function() { } `); - const { scopes } = analyze(ast, {optimistic: true}); + const scopes = analyze(ast, {optimistic: true}).scopes; expect(scopes.map(scope => scope.variables.map(variable => variable.name))).to.be.eql( [ @@ -67,7 +67,7 @@ describe('optimistic', function() { } `); - const { scopes } = analyze(ast, {optimistic: true}); + const scopes = analyze(ast, {optimistic: true}).scopes; expect(scopes.map(scope => scope.variables.map(variable => variable.name))).to.be.eql( [ diff --git a/test/references.js b/test/references.js index 5de08f7..2972d9a 100644 --- a/test/references.js +++ b/test/references.js @@ -20,10 +20,11 @@ // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +"use strict"; -import { expect } from 'chai'; -import espree from '../third_party/espree'; -import { analyze } from '..'; +const expect = require('chai').expect; +const espree = require('../third_party/espree'); +const analyze = require('..').analyze; describe('References:', function() { describe('When there is a `let` declaration on global,', function() { @@ -554,7 +555,7 @@ describe('References:', function() { expect(scope.variables).to.have.length.of.at.least(1); expect(scope.variables[0].name).to.equal('a'); - const { references } = scope.variables[0]; + const references = scope.variables[0].references; expect(references).to.have.length.of.at.least(1); references.forEach(reference => { diff --git a/test/with-scope.js b/test/with-scope.js index 5dc93f2..d526c01 100644 --- a/test/with-scope.js +++ b/test/with-scope.js @@ -20,10 +20,11 @@ // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +"use strict"; -import { expect } from 'chai'; -import { parse } from 'esprima'; -import { analyze } from '..'; +const expect = require('chai').expect; +const parse = require('../third_party/esprima').parse; +const analyze = require('..').analyze; describe('with', function() { it('creates scope', function() {