Skip to content
This repository has been archived by the owner on May 19, 2018. It is now read-only.

Update eslint-config-babel to the latest version 🚀 #273

Merged
merged 3 commits into from
Jan 10, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"codecov": "^1.0.1",
"cross-env": "^2.0.0",
"eslint": "^3.7.1",
"eslint-config-babel": "^3.0.0",
"eslint-config-babel": "^4.0.1",
"eslint-plugin-babel": "^4.0.0",
"eslint-plugin-flowtype": "^2.20.0",
"flow-bin": "^0.37.0",
Expand Down
4 changes: 2 additions & 2 deletions src/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export const defaultOptions: {
// Interpret and default an options object

export function getOptions(opts?: Object): Object {
let options = {};
for (let key in defaultOptions) {
const options = {};
for (const key in defaultOptions) {
options[key] = opts && key in opts ? opts[key] : defaultOptions[key];
}
return options;
Expand Down
4 changes: 2 additions & 2 deletions src/parser/comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pp.addComment = function (comment) {
pp.processComment = function (node) {
if (node.type === "Program" && node.body.length > 0) return;

let stack = this.state.commentStack;
const stack = this.state.commentStack;

let lastChild, trailingComments, i, j;

Expand All @@ -63,7 +63,7 @@ pp.processComment = function (node) {
this.state.trailingComments.length = 0;
}
} else {
let lastInStack = last(stack);
const lastInStack = last(stack);
if (stack.length > 0 && lastInStack.trailingComments && lastInStack.trailingComments[0].start >= node.end) {
trailingComments = lastInStack.trailingComments;
lastInStack.trailingComments = null;
Expand Down
169 changes: 94 additions & 75 deletions src/parser/expression.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions src/parser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default class Parser extends Tokenizer {
pluginNames.push("flow");

pluginNames.forEach((name) => {
let plugin = plugins[name];
const plugin = plugins[name];
if (plugin) plugin(this);
});
}
Expand All @@ -73,19 +73,19 @@ export default class Parser extends Tokenizer {
return { "*": true };
}

let pluginMap = {};
const pluginMap = {};

if (pluginList.indexOf("flow") >= 0) {
// ensure flow plugin loads last
pluginList = pluginList.filter((plugin) => plugin !== "flow");
pluginList.push("flow");
}

for (let name of pluginList) {
for (const name of pluginList) {
if (!pluginMap[name]) {
pluginMap[name] = true;

let plugin = plugins[name];
const plugin = plugins[name];
if (plugin) plugin(this);
}
}
Expand All @@ -100,8 +100,8 @@ export default class Parser extends Tokenizer {
body: Array<Object>
}
} {
let file = this.startNode();
let program = this.startNode();
const file = this.startNode();
const program = this.startNode();
this.nextToken();
return this.parseTopLevel(file, program);
}
Expand Down
4 changes: 2 additions & 2 deletions src/parser/location.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ const pp = Parser.prototype;
// message.

pp.raise = function (pos, message) {
let loc = getLineInfo(this.input, pos);
const loc = getLineInfo(this.input, pos);
message += ` (${loc.line}:${loc.column})`;
let err = new SyntaxError(message);
const err = new SyntaxError(message);
err.pos = pos;
err.loc = loc;
throw err;
Expand Down
26 changes: 13 additions & 13 deletions src/parser/lval.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pp.toAssignable = function (node, isBinding, contextDescription) {

case "ObjectExpression":
node.type = "ObjectPattern";
for (let prop of (node.properties: Array<Object>)) {
for (const prop of (node.properties: Array<Object>)) {
if (prop.type === "ObjectMethod") {
if (prop.kind === "get" || prop.kind === "set") {
this.raise(prop.key.start, "Object pattern can't contain getter or setter");
Expand Down Expand Up @@ -72,12 +72,12 @@ pp.toAssignable = function (node, isBinding, contextDescription) {
pp.toAssignableList = function (exprList, isBinding, contextDescription) {
let end = exprList.length;
if (end) {
let last = exprList[end - 1];
const last = exprList[end - 1];
if (last && last.type === "RestElement") {
--end;
} else if (last && last.type === "SpreadElement") {
last.type = "RestElement";
let arg = last.argument;
const arg = last.argument;
this.toAssignable(arg, isBinding, contextDescription);
if (arg.type !== "Identifier" && arg.type !== "MemberExpression" && arg.type !== "ArrayPattern") {
this.unexpected(arg.start);
Expand All @@ -86,7 +86,7 @@ pp.toAssignableList = function (exprList, isBinding, contextDescription) {
}
}
for (let i = 0; i < end; i++) {
let elt = exprList[i];
const elt = exprList[i];
if (elt) this.toAssignable(elt, isBinding, contextDescription);
}
return exprList;
Expand All @@ -101,14 +101,14 @@ pp.toReferencedList = function (exprList) {
// Parses spread element.

pp.parseSpread = function (refShorthandDefaultPos) {
let node = this.startNode();
const node = this.startNode();
this.next();
node.argument = this.parseMaybeAssign(false, refShorthandDefaultPos);
return this.finishNode(node, "SpreadElement");
};

pp.parseRest = function () {
let node = this.startNode();
const node = this.startNode();
this.next();
node.argument = this.parseBindingIdentifier();
return this.finishNode(node, "RestElement");
Expand All @@ -133,7 +133,7 @@ pp.parseBindingAtom = function () {
return this.parseIdentifier(true);

case tt.bracketL:
let node = this.startNode();
const node = this.startNode();
this.next();
node.elements = this.parseBindingList(tt.bracketR, true);
return this.finishNode(node, "ArrayPattern");
Expand All @@ -147,7 +147,7 @@ pp.parseBindingAtom = function () {
};

pp.parseBindingList = function (close, allowEmpty) {
let elts = [];
const elts = [];
let first = true;
while (!this.eat(close)) {
if (first) {
Expand All @@ -164,11 +164,11 @@ pp.parseBindingList = function (close, allowEmpty) {
this.expect(close);
break;
} else {
let decorators = [];
const decorators = [];
while (this.match(tt.at)) {
decorators.push(this.parseDecorator());
}
let left = this.parseMaybeDefault();
const left = this.parseMaybeDefault();
if (decorators.length) {
left.decorators = decorators;
}
Expand All @@ -191,7 +191,7 @@ pp.parseMaybeDefault = function (startPos, startLoc, left) {
left = left || this.parseBindingAtom();
if (!this.eat(tt.eq)) return left;

let node = this.startNodeAt(startPos, startLoc);
const node = this.startNodeAt(startPos, startLoc);
node.left = left;
node.right = this.parseMaybeAssign();
return this.finishNode(node, "AssignmentPattern");
Expand All @@ -217,7 +217,7 @@ pp.checkLVal = function (expr, isBinding, checkClashes, contextDescription) {
// true
// > obj.__proto__
// null
let key = `_${expr.name}`;
const key = `_${expr.name}`;

if (checkClashes[key]) {
this.raise(expr.start, "Argument name clash in strict mode");
Expand All @@ -239,7 +239,7 @@ pp.checkLVal = function (expr, isBinding, checkClashes, contextDescription) {
break;

case "ArrayPattern":
for (let elem of (expr.elements: Array<Object>)) {
for (const elem of (expr.elements: Array<Object>)) {
if (elem) this.checkLVal(elem, isBinding, checkClashes, "array destructuring pattern");
}
break;
Expand Down
2 changes: 1 addition & 1 deletion src/parser/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Node {

__clone(): Node {
const node2 = new Node;
for (let key in this) {
for (const key in this) {
// Do not clone comments that are already attached to the node
if (commentKeys.indexOf(key) < 0) {
node2[key] = this[key];
Expand Down