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

Commit 019441e

Browse files
corbinuJamesHenry
authored andcommitted
Chore: Convert to ES6 that is supported on Node 4, commonjs modules and remove Babel (#14)
1 parent c647f65 commit 019441e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+252
-227
lines changed

.babelrc

Lines changed: 0 additions & 3 deletions
This file was deleted.

.travis.yml

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
1-
sudo: false
21
language: node_js
32
node_js:
4-
- "0.10"
5-
- "0.11"
6-
- "0.12"
7-
- "iojs-1"
8-
- "iojs-2"
9-
- "iojs-3"
10-
- "4"
11-
matrix:
12-
allow_failures:
13-
- node_js:
14-
- "0.11"
15-
- "iojs-1"
16-
- "iojs-2"
17-
- "iojs-3"
3+
- "4"
4+
- "5"
5+
- "6"
6+
- "7"
7+
sudo: false
8+
script: "npm test"

gulpfile.js

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
var gulp = require('gulp'),
2828
mocha = require('gulp-mocha'),
29-
babel = require('gulp-babel'),
3029
git = require('gulp-git'),
3130
bump = require('gulp-bump'),
3231
filter = require('gulp-filter'),
@@ -38,10 +37,6 @@ var gulp = require('gulp'),
3837
eslint = require('gulp-eslint'),
3938
fs = require('fs');
4039

41-
require('babel-register')({
42-
only: /eslint-scope\/(src|test)\//
43-
});
44-
4540
var TEST = [ 'test/*.js' ];
4641
var SOURCE = [ 'src/**/*.js' ];
4742

@@ -68,34 +63,14 @@ var ESLINT_OPTION = {
6863
}
6964
};
7065

71-
var BABEL_OPTIONS = JSON.parse(fs.readFileSync('.babelrc', { encoding: 'utf8' }));
72-
73-
var build = lazypipe()
74-
.pipe(sourcemaps.init)
75-
.pipe(babel, BABEL_OPTIONS)
76-
.pipe(sourcemaps.write)
77-
.pipe(gulp.dest, 'lib');
78-
79-
gulp.task('build-for-watch', function () {
80-
return gulp.src(SOURCE).pipe(plumber()).pipe(build());
81-
});
82-
83-
gulp.task('build', function () {
84-
return gulp.src(SOURCE).pipe(build());
85-
});
86-
87-
gulp.task('test', [ 'lint', 'build' ], function () {
66+
gulp.task('test', function () {
8867
return gulp.src(TEST)
8968
.pipe(mocha({
9069
reporter: 'spec',
9170
timeout: 100000 // 100s
9271
}));
9372
});
9473

95-
gulp.task('watch', [ 'build-for-watch' ], function () {
96-
gulp.watch(SOURCE, [ 'build-for-watch' ]);
97-
});
98-
9974
// Currently, not works for ES6.
10075
gulp.task('lint', function () {
10176
return gulp.src(SOURCE)
@@ -135,9 +110,9 @@ function inc(importance) {
135110
}));
136111
}
137112

138-
gulp.task('patch', [ 'build' ], function () { return inc('patch'); })
139-
gulp.task('minor', [ 'build' ], function () { return inc('minor'); })
140-
gulp.task('major', [ 'build' ], function () { return inc('major'); })
113+
gulp.task('patch', function () { return inc('patch'); })
114+
gulp.task('minor', function () { return inc('minor'); })
115+
gulp.task('major', function () { return inc('major'); })
141116

142117
gulp.task('travis', [ 'test' ]);
143118
gulp.task('default', [ 'travis' ]);

package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "eslint-scope",
33
"description": "ECMAScript scope analyzer for ESLint",
44
"homepage": "http://github.com/eslint/eslint-scope",
5-
"main": "lib/index.js",
5+
"main": "src/index.js",
66
"version": "3.6.0",
77
"engines": {
88
"node": ">=0.4.0"
@@ -29,15 +29,11 @@
2929
"estraverse": "^4.1.1"
3030
},
3131
"devDependencies": {
32-
"babel": "^6.3.26",
33-
"babel-preset-es2015": "^6.3.13",
34-
"babel-register": "^6.3.13",
3532
"chai": "^3.4.1",
3633
"eslint-release": "^0.10.1",
3734
"espree": "^3.1.1",
3835
"esprima": "^2.7.1",
3936
"gulp": "^3.9.0",
40-
"gulp-babel": "^6.1.1",
4137
"gulp-bump": "^1.0.0",
4238
"gulp-eslint": "^1.1.1",
4339
"gulp-espower": "^1.0.2",
@@ -49,6 +45,7 @@
4945
"gulp-tag-version": "^1.3.0",
5046
"lazypipe": "^1.0.1",
5147
"vinyl-source-stream": "^1.1.0",
48+
"typescript": "~2.0.10",
5249
"typescript-eslint-parser": "^1.0.0"
5350
}
5451
}

src/definition.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@
2121
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2222
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2323
*/
24+
"use strict";
2425

25-
import Variable from './variable';
26+
const Variable = require('./variable');
2627

2728
/**
2829
* @class Definition
2930
*/
30-
export default class Definition {
31+
class Definition {
3132
constructor(type, name, node, parent, index, kind) {
3233
/**
3334
* @member {String} Definition#type - type of the occurrence (e.g. "Parameter", "Variable", ...).
@@ -70,9 +71,9 @@ class ParameterDefinition extends Definition {
7071
}
7172
}
7273

73-
export {
74+
module.exports = {
7475
ParameterDefinition,
7576
Definition
76-
}
77+
};
7778

7879
/* vim: set sw=4 ts=4 et tw=80 : */

src/index.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,18 @@
4545
* The main interface is the {@link analyze} function.
4646
* @module escope
4747
*/
48+
"use strict";
4849

4950
/*jslint bitwise:true */
5051

51-
import assert from 'assert';
52+
const assert = require('assert');
5253

53-
import ScopeManager from './scope-manager';
54-
import Referencer from './referencer';
55-
import Reference from './reference';
56-
import Variable from './variable';
57-
import Scope from './scope';
58-
import { version } from '../package.json';
54+
const ScopeManager = require('./scope-manager');
55+
const Referencer = require('./referencer');
56+
const Reference = require('./reference');
57+
const Variable = require('./variable');
58+
const Scope = require('./scope');
59+
const version = require('../package.json').version;
5960

6061
function defaultOptions() {
6162
return {
@@ -114,7 +115,7 @@ function updateDeeply(target, override) {
114115
* @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.
115116
* @return {ScopeManager}
116117
*/
117-
export function analyze(tree, providedOptions) {
118+
function analyze(tree, providedOptions) {
118119
var scopeManager, referencer, options;
119120

120121
options = updateDeeply(defaultOptions(), providedOptions);
@@ -129,7 +130,7 @@ export function analyze(tree, providedOptions) {
129130
return scopeManager;
130131
}
131132

132-
export {
133+
module.exports = {
133134
/** @name module:escope.version */
134135
version,
135136
/** @name module:escope.Reference */
@@ -139,7 +140,8 @@ export {
139140
/** @name module:escope.Scope */
140141
Scope,
141142
/** @name module:escope.ScopeManager */
142-
ScopeManager
143+
ScopeManager,
144+
analyze
143145
};
144146

145147

src/pattern-visitor.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,16 @@
2121
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2222
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2323
*/
24+
"use strict";
2425

25-
import { Syntax } from 'estraverse';
26-
import esrecurse from 'esrecurse';
26+
const Syntax = require('estraverse').Syntax;
27+
const esrecurse = require('esrecurse');
2728

2829
function getLast(xs) {
2930
return xs[xs.length - 1] || null;
3031
}
3132

32-
export default class PatternVisitor extends esrecurse.Visitor {
33+
class PatternVisitor extends esrecurse.Visitor {
3334
static isPattern(node) {
3435
var nodeType = node.type;
3536
return (
@@ -131,4 +132,6 @@ export default class PatternVisitor extends esrecurse.Visitor {
131132
}
132133
}
133134

135+
module.exports = PatternVisitor;
136+
134137
/* vim: set sw=4 ts=4 et tw=80 : */

src/reference.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2222
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2323
*/
24+
"use strict";
2425

2526
const READ = 0x1;
2627
const WRITE = 0x2;
@@ -30,7 +31,7 @@ const RW = READ | WRITE;
3031
* A Reference represents a single occurrence of an identifier in code.
3132
* @class Reference
3233
*/
33-
export default class Reference {
34+
class Reference {
3435
constructor(ident, scope, flag, writeExpr, maybeImplicitGlobal, partial, init) {
3536
/**
3637
* Identifier syntax node.
@@ -151,4 +152,6 @@ Reference.WRITE = WRITE;
151152
*/
152153
Reference.RW = RW;
153154

155+
module.exports = Reference;
156+
154157
/* vim: set sw=4 ts=4 et tw=80 : */

src/referencer.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,18 @@
2121
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2222
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2323
*/
24-
import { Syntax } from 'estraverse';
25-
import esrecurse from 'esrecurse';
26-
import Reference from './reference';
27-
import Variable from './variable';
28-
import PatternVisitor from './pattern-visitor';
29-
import { ParameterDefinition, Definition } from './definition';
30-
import assert from 'assert';
24+
"use strict";
25+
26+
const Syntax = require('estraverse').Syntax;
27+
const esrecurse = require('esrecurse');
28+
const Reference = require('./reference');
29+
const Variable = require('./variable');
30+
const PatternVisitor = require('./pattern-visitor');
31+
const definition = require('./definition');
32+
const assert = require('assert');
33+
34+
const ParameterDefinition = definition.ParameterDefinition;
35+
const Definition = definition.Definition;
3136

3237
function traverseIdentifierInPattern(options, rootPattern, referencer, callback) {
3338
// Call the callback at left hand identifier nodes, and Collect right hand nodes.
@@ -90,7 +95,7 @@ class Importer extends esrecurse.Visitor {
9095
}
9196

9297
// Referencing variables and creating bindings.
93-
export default class Referencer extends esrecurse.Visitor {
98+
class Referencer extends esrecurse.Visitor {
9499
constructor(options, scopeManager) {
95100
super(null, options);
96101
this.options = options;
@@ -585,4 +590,6 @@ export default class Referencer extends esrecurse.Visitor {
585590
}
586591
}
587592

593+
module.exports = Referencer;
594+
588595
/* vim: set sw=4 ts=4 et tw=80 : */

src/scope-manager.js

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,28 @@
2121
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2222
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2323
*/
24-
25-
import WeakMap from 'es6-weak-map';
26-
import Scope from './scope';
27-
import assert from 'assert';
28-
29-
import {
30-
GlobalScope,
31-
CatchScope,
32-
WithScope,
33-
ModuleScope,
34-
ClassScope,
35-
SwitchScope,
36-
FunctionScope,
37-
ForScope,
38-
TDZScope,
39-
FunctionExpressionNameScope,
40-
BlockScope
41-
} from './scope';
24+
"use strict";
25+
26+
const WeakMap = require('es6-weak-map');
27+
const Scope = require('./scope');
28+
const assert = require('assert');
29+
30+
const GlobalScope = Scope.GlobalScope;
31+
const CatchScope = Scope.CatchScope;
32+
const WithScope = Scope.WithScope;
33+
const ModuleScope = Scope.ModuleScope;
34+
const ClassScope = Scope.ClassScope;
35+
const SwitchScope = Scope.SwitchScope;
36+
const FunctionScope = Scope.FunctionScope;
37+
const ForScope = Scope.ForScope;
38+
const TDZScope = Scope.TDZScope;
39+
const FunctionExpressionNameScope = Scope.FunctionExpressionNameScope;
40+
const BlockScope = Scope.BlockScope;
4241

4342
/**
4443
* @class ScopeManager
4544
*/
46-
export default class ScopeManager {
45+
class ScopeManager {
4746
constructor(options) {
4847
this.scopes = [];
4948
this.globalScope = null;
@@ -242,4 +241,6 @@ export default class ScopeManager {
242241
}
243242
}
244243

244+
module.exports = ScopeManager;
245+
245246
/* vim: set sw=4 ts=4 et tw=80 : */

0 commit comments

Comments
 (0)