Skip to content

Commit 7b9e542

Browse files
committed
Use let or const instead of var
1 parent 5e77f7b commit 7b9e542

Some content is hidden

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

116 files changed

+692
-659
lines changed

.eslintrc.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ module.exports = {
1313
es6: true
1414
},
1515
rules: {
16+
"prefer-const": "error",
17+
"no-var": "error",
1618
"prettier/prettier": "error"
1719
}
1820
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "src/index.js",
66
"scripts": {
77
"lint": "eslint src/*.js src/**/*.js",
8-
"test": "npm run lint && node node_modules/mocha/bin/mocha test --stack-size=5000",
8+
"test": "mocha test --stack-size=5000",
99
"cover": "node --stack-size=5000 node_modules/istanbul/lib/cli.js cover node_modules/mocha/bin/_mocha"
1010
},
1111
"repository": {

src/ast.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
* @url http://gla*yzzle.com
55
*/
66

7-
var Location = require("./ast/location");
8-
var Position = require("./ast/position");
7+
const Location = require("./ast/location");
8+
const Position = require("./ast/position");
99

1010
/**
1111
* ## Class hierarchy
@@ -104,7 +104,7 @@ var Position = require("./ast/position");
104104
* @property {Boolean} withPositions - Should locate any node (by default false)
105105
* @property {Boolean} withSource - Should extract the node original code (by default false)
106106
*/
107-
var AST = function(withPositions, withSource) {
107+
const AST = function(withPositions, withSource) {
108108
this.withPositions = withPositions;
109109
this.withSource = withSource;
110110
};
@@ -233,17 +233,17 @@ AST.prototype.resolvePrecedence = function(result) {
233233
* @return {Function}
234234
*/
235235
AST.prototype.prepare = function(kind, parser) {
236-
var start = null;
236+
let start = null;
237237
if (this.withPositions || this.withSource) {
238238
start = this.position(parser);
239239
}
240-
var self = this;
240+
const self = this;
241241
// returns the node
242242
return function() {
243-
var location = null;
244-
var args = Array.prototype.slice.call(arguments);
243+
let location = null;
244+
const args = Array.prototype.slice.call(arguments);
245245
if (self.withPositions || self.withSource) {
246-
var src = null;
246+
let src = null;
247247
if (self.withSource) {
248248
src = parser.lexer._input.substring(
249249
start.offset,
@@ -271,11 +271,11 @@ AST.prototype.prepare = function(kind, parser) {
271271
kind = args.shift();
272272
}
273273
// build the object
274-
var node = self[kind];
274+
const node = self[kind];
275275
if (typeof node !== "function") {
276276
throw new Error('Undefined node "' + kind + '"');
277277
}
278-
var result = Object.create(node.prototype);
278+
const result = Object.create(node.prototype);
279279
node.apply(result, args);
280280
return self.resolvePrecedence(result);
281281
};
@@ -370,7 +370,7 @@ AST.prototype.prepare = function(kind, parser) {
370370
require("./ast/yield"),
371371
require("./ast/yieldfrom")
372372
].forEach(function(ctor) {
373-
var kind = ctor.prototype.constructor.name.toLowerCase();
373+
let kind = ctor.prototype.constructor.name.toLowerCase();
374374
if (kind[0] === "_") kind = kind.substring(1);
375375
AST.prototype[kind] = ctor;
376376
});

src/ast/array.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
* @url http://glayzzle.com
55
*/
66

7-
var Expr = require("./expression");
8-
var KIND = "array";
7+
const Expr = require("./expression");
8+
const KIND = "array";
99

1010
/**
1111
* Defines an array structure
@@ -36,7 +36,7 @@ var KIND = "array";
3636
* @property {Entry[]} items List of array items
3737
* @property {boolean} shortForm Indicate if the short array syntax is used, ex `[]` instead `array()`
3838
*/
39-
var Array = Expr.extends(function Array(shortForm, items, location) {
39+
const Array = Expr.extends(function Array(shortForm, items, location) {
4040
Expr.apply(this, [KIND, location]);
4141
this.items = items;
4242
this.shortForm = shortForm;

src/ast/assign.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
* @url http://glayzzle.com
55
*/
66

7-
var Statement = require("./statement");
8-
var KIND = "assign";
7+
const Statement = require("./statement");
8+
const KIND = "assign";
99

1010
/**
1111
* Assigns a value to the specified target
@@ -15,7 +15,7 @@ var KIND = "assign";
1515
* @property {Expression} right
1616
* @property {String} operator
1717
*/
18-
var Assign = Statement.extends(function Assign(
18+
const Assign = Statement.extends(function Assign(
1919
left,
2020
right,
2121
operator,

src/ast/bin.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
*/
66
"use strict";
77

8-
var Operation = require("./operation");
9-
var KIND = "bin";
8+
const Operation = require("./operation");
9+
const KIND = "bin";
1010
/**
1111
* Binary operations
1212
* @constructor Bin
@@ -15,7 +15,7 @@ var KIND = "bin";
1515
* @property {Expression} left
1616
* @property {Expression} right
1717
*/
18-
var Bin = Operation.extends(function Bin(type, left, right, location) {
18+
const Bin = Operation.extends(function Bin(type, left, right, location) {
1919
Operation.apply(this, [KIND, location]);
2020
this.type = type;
2121
this.left = left;

src/ast/block.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
* @url http://glayzzle.com
55
*/
66

7-
var Statement = require("./statement");
8-
var KIND = "block";
7+
const Statement = require("./statement");
8+
const KIND = "block";
99

1010
/**
1111
* A block statement, i.e., a sequence of statements surrounded by braces.
1212
* @constructor Block
1313
* @extends {Statement}
1414
* @property {Node[]} children
1515
*/
16-
var Block = Statement.extends(function Block(kind, children, location) {
16+
const Block = Statement.extends(function Block(kind, children, location) {
1717
Statement.apply(this, [kind || KIND, location]);
1818
this.children = children.filter(Boolean);
1919
});

src/ast/boolean.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
* @url http://glayzzle.com
55
*/
66

7-
var Literal = require("./literal");
8-
var KIND = "boolean";
7+
const Literal = require("./literal");
8+
const KIND = "boolean";
99

1010
/**
1111
* Defines a boolean value (true/false)
1212
* @constructor Boolean
1313
* @extends {Literal}
1414
*/
15-
var Boolean = Literal.extends(function Boolean(value, location) {
15+
const Boolean = Literal.extends(function Boolean(value, location) {
1616
Literal.apply(this, [KIND, value, location]);
1717
});
1818

src/ast/break.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
* @url http://glayzzle.com
55
*/
66
"use strict";
7-
var Node = require("./node");
8-
var KIND = "break";
7+
const Node = require("./node");
8+
const KIND = "break";
99

1010
/**
1111
* A break statement
1212
* @constructor Break
1313
* @extends {Node}
1414
* @property {Number|Null} level
1515
*/
16-
var Break = Node.extends(function Break(level, location) {
16+
const Break = Node.extends(function Break(level, location) {
1717
Node.apply(this, [KIND, location]);
1818
this.level = level;
1919
});

src/ast/call.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
*/
66
"use strict";
77

8-
var Statement = require("./statement");
9-
var KIND = "call";
8+
const Statement = require("./statement");
9+
const KIND = "call";
1010

1111
/**
1212
* Executes a call statement
@@ -15,7 +15,7 @@ var KIND = "call";
1515
* @property {Identifier|Variable|??} what
1616
* @property {Arguments[]} arguments
1717
*/
18-
var Call = Statement.extends(function Call(what, args, location) {
18+
const Call = Statement.extends(function Call(what, args, location) {
1919
Statement.apply(this, [KIND, location]);
2020
this.what = what;
2121
this.arguments = args;

src/ast/case.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
* @url http://glayzzle.com
55
*/
66
"use strict";
7-
var Node = require("./node");
8-
var KIND = "case";
7+
const Node = require("./node");
8+
const KIND = "case";
99

1010
/**
1111
* A switch case statement
@@ -14,7 +14,7 @@ var KIND = "case";
1414
* @property {Expression|null} test - if null, means that the default case
1515
* @property {Block|null} body
1616
*/
17-
var Case = Node.extends(function Case(test, body, location) {
17+
const Case = Node.extends(function Case(test, body, location) {
1818
Node.apply(this, [KIND, location]);
1919
this.test = test;
2020
this.body = body;

src/ast/cast.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
*/
66
"use strict";
77

8-
var Operation = require("./operation");
9-
var KIND = "cast";
8+
const Operation = require("./operation");
9+
const KIND = "cast";
1010

1111
/**
1212
* Binary operations
@@ -15,7 +15,7 @@ var KIND = "cast";
1515
* @property {String} type
1616
* @property {Expression} what
1717
*/
18-
var Cast = Operation.extends(function Cast(type, what, location) {
18+
const Cast = Operation.extends(function Cast(type, what, location) {
1919
Operation.apply(this, [KIND, location]);
2020
this.type = type;
2121
this.what = what;

src/ast/catch.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
*/
66
"use strict";
77

8-
var Statement = require("./statement");
9-
var KIND = "catch";
8+
const Statement = require("./statement");
9+
const KIND = "catch";
1010

1111
/**
1212
* Defines a catch statement
@@ -17,7 +17,7 @@ var KIND = "catch";
1717
* @property {Statement} body
1818
* @see http://php.net/manual/en/language.exceptions.php
1919
*/
20-
var Catch = Statement.extends(function Catch(body, what, variable, location) {
20+
const Catch = Statement.extends(function Catch(body, what, variable, location) {
2121
Statement.apply(this, [KIND, location]);
2222
this.body = body;
2323
this.what = what;

src/ast/class.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
* @url http://glayzzle.com
55
*/
66

7-
var Declaration = require("./declaration");
8-
var KIND = "class";
7+
const Declaration = require("./declaration");
8+
const KIND = "class";
99

1010
/**
1111
* A class definition
@@ -18,7 +18,7 @@ var KIND = "class";
1818
* @property {boolean} isAbstract
1919
* @property {boolean} isFinal
2020
*/
21-
var Class = Declaration.extends(function Class(
21+
const Class = Declaration.extends(function Class(
2222
name,
2323
ext,
2424
impl,

src/ast/classconstant.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
* @url http://glayzzle.com
55
*/
66

7-
var Constant = require("./constant");
8-
var KIND = "classconstant";
7+
const Constant = require("./constant");
8+
const KIND = "classconstant";
99

1010
/**
1111
* Defines a class/interface/trait constant
@@ -14,7 +14,7 @@ var KIND = "classconstant";
1414
* @property {boolean} isStatic
1515
* @property {string} visibility
1616
*/
17-
var ClassConstant = Constant.extends(function ClassConstant(
17+
const ClassConstant = Constant.extends(function ClassConstant(
1818
name,
1919
value,
2020
flags,

src/ast/clone.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
* @url http://glayzzle.com
55
*/
66

7-
var Statement = require("./statement");
8-
var KIND = "clone";
7+
const Statement = require("./statement");
8+
const KIND = "clone";
99

1010
/**
1111
* Defines a clone call
1212
* @constructor Clone
1313
* @extends {Statement}
1414
* @property {Expression} what
1515
*/
16-
var Clone = Statement.extends(function Clone(what, location) {
16+
const Clone = Statement.extends(function Clone(what, location) {
1717
Statement.apply(this, [KIND, location]);
1818
this.what = what;
1919
});

src/ast/closure.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
* @url http://glayzzle.com
55
*/
66
"use strict";
7-
var Statement = require("./statement");
8-
var KIND = "closure";
7+
const Statement = require("./statement");
8+
const KIND = "closure";
99

1010
/**
1111
* Defines a closure
@@ -19,7 +19,7 @@ var KIND = "closure";
1919
* @property {Block|null} body
2020
* @property {boolean} isStatic
2121
*/
22-
var Closure = Statement.extends(function Closure(
22+
const Closure = Statement.extends(function Closure(
2323
args,
2424
byref,
2525
uses,

src/ast/constant.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
* @url http://glayzzle.com
55
*/
66

7-
var Declaration = require("./declaration");
8-
var KIND = "constant";
7+
const Declaration = require("./declaration");
8+
const KIND = "constant";
99

1010
/**
1111
* Defines a namespace constant
1212
* @constructor Constant
1313
* @extends {Declaration}
1414
* @property {Node|null} value
1515
*/
16-
var Constant = Declaration.extends(function Constant(name, value, location) {
16+
const Constant = Declaration.extends(function Constant(name, value, location) {
1717
Declaration.apply(this, [KIND, name, location]);
1818
this.value = value;
1919
});

0 commit comments

Comments
 (0)