Skip to content

Use let or const instead of var #109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ module.exports = {
es6: true
},
rules: {
"prefer-const": "error",
"no-var": "error",
"prettier/prettier": "error"
}
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "src/index.js",
"scripts": {
"lint": "eslint src/*.js src/**/*.js",
"test": "npm run lint && node node_modules/mocha/bin/mocha test --stack-size=5000",
"test": "mocha test --stack-size=5000",
"cover": "node --stack-size=5000 node_modules/istanbul/lib/cli.js cover node_modules/mocha/bin/_mocha"
},
"repository": {
Expand Down
22 changes: 11 additions & 11 deletions src/ast.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* @url http://gla*yzzle.com
*/

var Location = require("./ast/location");
var Position = require("./ast/position");
const Location = require("./ast/location");
const Position = require("./ast/position");

/**
* ## Class hierarchy
Expand Down Expand Up @@ -104,7 +104,7 @@ var Position = require("./ast/position");
* @property {Boolean} withPositions - Should locate any node (by default false)
* @property {Boolean} withSource - Should extract the node original code (by default false)
*/
var AST = function(withPositions, withSource) {
const AST = function(withPositions, withSource) {
this.withPositions = withPositions;
this.withSource = withSource;
};
Expand Down Expand Up @@ -233,17 +233,17 @@ AST.prototype.resolvePrecedence = function(result) {
* @return {Function}
*/
AST.prototype.prepare = function(kind, parser) {
var start = null;
let start = null;
if (this.withPositions || this.withSource) {
start = this.position(parser);
}
var self = this;
const self = this;
// returns the node
return function() {
var location = null;
var args = Array.prototype.slice.call(arguments);
let location = null;
const args = Array.prototype.slice.call(arguments);
if (self.withPositions || self.withSource) {
var src = null;
let src = null;
if (self.withSource) {
src = parser.lexer._input.substring(
start.offset,
Expand Down Expand Up @@ -271,11 +271,11 @@ AST.prototype.prepare = function(kind, parser) {
kind = args.shift();
}
// build the object
var node = self[kind];
const node = self[kind];
if (typeof node !== "function") {
throw new Error('Undefined node "' + kind + '"');
}
var result = Object.create(node.prototype);
const result = Object.create(node.prototype);
node.apply(result, args);
return self.resolvePrecedence(result);
};
Expand Down Expand Up @@ -370,7 +370,7 @@ AST.prototype.prepare = function(kind, parser) {
require("./ast/yield"),
require("./ast/yieldfrom")
].forEach(function(ctor) {
var kind = ctor.prototype.constructor.name.toLowerCase();
let kind = ctor.prototype.constructor.name.toLowerCase();
if (kind[0] === "_") kind = kind.substring(1);
AST.prototype[kind] = ctor;
});
Expand Down
6 changes: 3 additions & 3 deletions src/ast/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* @url http://glayzzle.com
*/

var Expr = require("./expression");
var KIND = "array";
const Expr = require("./expression");
const KIND = "array";

/**
* Defines an array structure
Expand Down Expand Up @@ -36,7 +36,7 @@ var KIND = "array";
* @property {Entry[]} items List of array items
* @property {boolean} shortForm Indicate if the short array syntax is used, ex `[]` instead `array()`
*/
var Array = Expr.extends(function Array(shortForm, items, location) {
const Array = Expr.extends(function Array(shortForm, items, location) {
Expr.apply(this, [KIND, location]);
this.items = items;
this.shortForm = shortForm;
Expand Down
6 changes: 3 additions & 3 deletions src/ast/assign.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* @url http://glayzzle.com
*/

var Statement = require("./statement");
var KIND = "assign";
const Statement = require("./statement");
const KIND = "assign";

/**
* Assigns a value to the specified target
Expand All @@ -15,7 +15,7 @@ var KIND = "assign";
* @property {Expression} right
* @property {String} operator
*/
var Assign = Statement.extends(function Assign(
const Assign = Statement.extends(function Assign(
left,
right,
operator,
Expand Down
6 changes: 3 additions & 3 deletions src/ast/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
*/
"use strict";

var Operation = require("./operation");
var KIND = "bin";
const Operation = require("./operation");
const KIND = "bin";
/**
* Binary operations
* @constructor Bin
Expand All @@ -15,7 +15,7 @@ var KIND = "bin";
* @property {Expression} left
* @property {Expression} right
*/
var Bin = Operation.extends(function Bin(type, left, right, location) {
const Bin = Operation.extends(function Bin(type, left, right, location) {
Operation.apply(this, [KIND, location]);
this.type = type;
this.left = left;
Expand Down
6 changes: 3 additions & 3 deletions src/ast/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
* @url http://glayzzle.com
*/

var Statement = require("./statement");
var KIND = "block";
const Statement = require("./statement");
const KIND = "block";

/**
* A block statement, i.e., a sequence of statements surrounded by braces.
* @constructor Block
* @extends {Statement}
* @property {Node[]} children
*/
var Block = Statement.extends(function Block(kind, children, location) {
const Block = Statement.extends(function Block(kind, children, location) {
Statement.apply(this, [kind || KIND, location]);
this.children = children.filter(Boolean);
});
Expand Down
6 changes: 3 additions & 3 deletions src/ast/boolean.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
* @url http://glayzzle.com
*/

var Literal = require("./literal");
var KIND = "boolean";
const Literal = require("./literal");
const KIND = "boolean";

/**
* Defines a boolean value (true/false)
* @constructor Boolean
* @extends {Literal}
*/
var Boolean = Literal.extends(function Boolean(value, location) {
const Boolean = Literal.extends(function Boolean(value, location) {
Literal.apply(this, [KIND, value, location]);
});

Expand Down
6 changes: 3 additions & 3 deletions src/ast/break.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
* @url http://glayzzle.com
*/
"use strict";
var Node = require("./node");
var KIND = "break";
const Node = require("./node");
const KIND = "break";

/**
* A break statement
* @constructor Break
* @extends {Node}
* @property {Number|Null} level
*/
var Break = Node.extends(function Break(level, location) {
const Break = Node.extends(function Break(level, location) {
Node.apply(this, [KIND, location]);
this.level = level;
});
Expand Down
6 changes: 3 additions & 3 deletions src/ast/call.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
*/
"use strict";

var Statement = require("./statement");
var KIND = "call";
const Statement = require("./statement");
const KIND = "call";

/**
* Executes a call statement
Expand All @@ -15,7 +15,7 @@ var KIND = "call";
* @property {Identifier|Variable|??} what
* @property {Arguments[]} arguments
*/
var Call = Statement.extends(function Call(what, args, location) {
const Call = Statement.extends(function Call(what, args, location) {
Statement.apply(this, [KIND, location]);
this.what = what;
this.arguments = args;
Expand Down
6 changes: 3 additions & 3 deletions src/ast/case.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* @url http://glayzzle.com
*/
"use strict";
var Node = require("./node");
var KIND = "case";
const Node = require("./node");
const KIND = "case";

/**
* A switch case statement
Expand All @@ -14,7 +14,7 @@ var KIND = "case";
* @property {Expression|null} test - if null, means that the default case
* @property {Block|null} body
*/
var Case = Node.extends(function Case(test, body, location) {
const Case = Node.extends(function Case(test, body, location) {
Node.apply(this, [KIND, location]);
this.test = test;
this.body = body;
Expand Down
6 changes: 3 additions & 3 deletions src/ast/cast.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
*/
"use strict";

var Operation = require("./operation");
var KIND = "cast";
const Operation = require("./operation");
const KIND = "cast";

/**
* Binary operations
Expand All @@ -15,7 +15,7 @@ var KIND = "cast";
* @property {String} type
* @property {Expression} what
*/
var Cast = Operation.extends(function Cast(type, what, location) {
const Cast = Operation.extends(function Cast(type, what, location) {
Operation.apply(this, [KIND, location]);
this.type = type;
this.what = what;
Expand Down
6 changes: 3 additions & 3 deletions src/ast/catch.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
*/
"use strict";

var Statement = require("./statement");
var KIND = "catch";
const Statement = require("./statement");
const KIND = "catch";

/**
* Defines a catch statement
Expand All @@ -17,7 +17,7 @@ var KIND = "catch";
* @property {Statement} body
* @see http://php.net/manual/en/language.exceptions.php
*/
var Catch = Statement.extends(function Catch(body, what, variable, location) {
const Catch = Statement.extends(function Catch(body, what, variable, location) {
Statement.apply(this, [KIND, location]);
this.body = body;
this.what = what;
Expand Down
6 changes: 3 additions & 3 deletions src/ast/class.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* @url http://glayzzle.com
*/

var Declaration = require("./declaration");
var KIND = "class";
const Declaration = require("./declaration");
const KIND = "class";

/**
* A class definition
Expand All @@ -18,7 +18,7 @@ var KIND = "class";
* @property {boolean} isAbstract
* @property {boolean} isFinal
*/
var Class = Declaration.extends(function Class(
const Class = Declaration.extends(function Class(
name,
ext,
impl,
Expand Down
6 changes: 3 additions & 3 deletions src/ast/classconstant.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* @url http://glayzzle.com
*/

var Constant = require("./constant");
var KIND = "classconstant";
const Constant = require("./constant");
const KIND = "classconstant";

/**
* Defines a class/interface/trait constant
Expand All @@ -14,7 +14,7 @@ var KIND = "classconstant";
* @property {boolean} isStatic
* @property {string} visibility
*/
var ClassConstant = Constant.extends(function ClassConstant(
const ClassConstant = Constant.extends(function ClassConstant(
name,
value,
flags,
Expand Down
6 changes: 3 additions & 3 deletions src/ast/clone.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
* @url http://glayzzle.com
*/

var Statement = require("./statement");
var KIND = "clone";
const Statement = require("./statement");
const KIND = "clone";

/**
* Defines a clone call
* @constructor Clone
* @extends {Statement}
* @property {Expression} what
*/
var Clone = Statement.extends(function Clone(what, location) {
const Clone = Statement.extends(function Clone(what, location) {
Statement.apply(this, [KIND, location]);
this.what = what;
});
Expand Down
6 changes: 3 additions & 3 deletions src/ast/closure.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* @url http://glayzzle.com
*/
"use strict";
var Statement = require("./statement");
var KIND = "closure";
const Statement = require("./statement");
const KIND = "closure";

/**
* Defines a closure
Expand All @@ -19,7 +19,7 @@ var KIND = "closure";
* @property {Block|null} body
* @property {boolean} isStatic
*/
var Closure = Statement.extends(function Closure(
const Closure = Statement.extends(function Closure(
args,
byref,
uses,
Expand Down
6 changes: 3 additions & 3 deletions src/ast/constant.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
* @url http://glayzzle.com
*/

var Declaration = require("./declaration");
var KIND = "constant";
const Declaration = require("./declaration");
const KIND = "constant";

/**
* Defines a namespace constant
* @constructor Constant
* @extends {Declaration}
* @property {Node|null} value
*/
var Constant = Declaration.extends(function Constant(name, value, location) {
const Constant = Declaration.extends(function Constant(name, value, location) {
Declaration.apply(this, [KIND, name, location]);
this.value = value;
});
Expand Down
Loading