Skip to content

Commit

Permalink
devDeps: eslint-config-babel v5.0.0 (#376)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaicataldo authored and hzoo committed Jan 16, 2017
1 parent df0d9d9 commit e5ec515
Show file tree
Hide file tree
Showing 23 changed files with 149 additions and 147 deletions.
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
},
"devDependencies": {
"babel-core": "^6.18.2",
"babel-eslint": "^7.1.1",
"babel-jest": "^16.0.0",
"babel-plugin-transform-es2015-block-scoping": "^6.18.0",
"babel-preset-env": "^0.0.8",
Expand All @@ -37,8 +38,9 @@
"cli-table": "^0.3.1",
"closure-compiler": "^0.2.12",
"commander": "^2.9.0",
"eslint": "~3.0.0",
"eslint-config-babel": "^1.0.0",
"eslint": "^3.13.1",
"eslint-config-babel": "^5.0.0",
"eslint-plugin-flowtype": "^2.29.2",
"google-closure-compiler-js": "^20160822.0.0",
"gulp": "github:gulpjs/gulp#4.0",
"gulp-babel": "^6.1.2",
Expand Down
8 changes: 4 additions & 4 deletions packages/babel-helper-flip-expressions/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ module.exports = function(t) {
if (t.isBinaryExpression(node)) {
let operator;
switch (node.operator) {
case "!==": operator = "==="; break;
case "===": operator = "!=="; break;
case "!=": operator = "=="; break;
case "==": operator = "!="; break;
case "!==": operator = "==="; break;
case "===": operator = "!=="; break;
case "!=": operator = "=="; break;
case "==": operator = "!="; break;
}

if (operator) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

module.exports = function(t) {
return function toMultipleSequenceExpressions(statements) {
let retStatements = [];
const retStatements = [];
let bailed;
do {
let res = convert(statements);
const res = convert(statements);
bailed = res.bailed;
let {seq, bailedAtIndex} = res;
const {seq, bailedAtIndex} = res;
if (seq) {
retStatements.push(t.expressionStatement(seq));
}
Expand All @@ -25,10 +25,10 @@ module.exports = function(t) {
return retStatements;

function convert(nodes) {
let exprs = [];
const exprs = [];

for (let i = 0; i < nodes.length; i++) {
let bail = () => {
const bail = () => {
let seq;
if (exprs.length === 1) {
seq = exprs[0];
Expand All @@ -43,7 +43,7 @@ module.exports = function(t) {
};
};

let node = nodes[i];
const node = nodes[i];
if (t.isExpression(node)) {
exprs.push(node);
} else if (t.isExpressionStatement(node)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ describe("dce-plugin", () => {
expect(transform(source).trim()).toBe(expected);
});

it("should remove redundant returns" , () => {
it("should remove redundant returns", () => {
const source = unpad(`
function foo() {
if (a) {
Expand All @@ -495,7 +495,7 @@ describe("dce-plugin", () => {
expect(transform(source).trim()).toBe(expected);
});

it("should remove redundant returns part 2" , () => {
it("should remove redundant returns part 2", () => {
const source = unpad(`
function foo() {
y();
Expand All @@ -511,7 +511,7 @@ describe("dce-plugin", () => {
expect(transform(source).trim()).toBe(expected);
});

it("should remove redundant returns (complex)" , () => {
it("should remove redundant returns (complex)", () => {
const source = unpad(`
function foo() {
if (a) {
Expand All @@ -536,7 +536,7 @@ describe("dce-plugin", () => {
expect(transform(source).trim()).toBe(expected);
});

it("should keep needed returns" , () => {
it("should keep needed returns", () => {
const source = unpad(`
function foo() {
if (a) {
Expand Down Expand Up @@ -635,7 +635,7 @@ describe("dce-plugin", () => {
expect(transform(source).trim()).toBe(expected);
});

it("should handle orphaned + redundant returns" , () => {
it("should handle orphaned + redundant returns", () => {
const source = unpad(`
var x = true;
function foo() {
Expand Down
26 changes: 13 additions & 13 deletions packages/babel-plugin-minify-dead-code-elimination/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ module.exports = ({ types: t, traverse }) => {
const seen = new Set();
const declars = [];
const mutations = [];
for (let name in scope.bindings) {
let binding = scope.bindings[name];
for (const name in scope.bindings) {
const binding = scope.bindings[name];
if (!binding.path.isVariableDeclarator()) {
continue;
}
Expand All @@ -61,7 +61,7 @@ module.exports = ({ types: t, traverse }) => {
}

const assignmentSequence = [];
for (let declar of declarPath.node.declarations) {
for (const declar of declarPath.node.declarations) {
declars.push(declar);
if (declar.init) {
assignmentSequence.push(t.assignmentExpression("=", declar.id, declar.init));
Expand All @@ -78,7 +78,7 @@ module.exports = ({ types: t, traverse }) => {

if (declars.length) {
mutations.forEach((f) => f());
for (let statement of node.body.body) {
for (const statement of node.body.body) {
if (t.isVariableDeclaration(statement)) {
statement.declarations.push(...declars);
return;
Expand Down Expand Up @@ -146,8 +146,8 @@ module.exports = ({ types: t, traverse }) => {
break;
}

for (let name in scope.bindings) {
let binding = scope.bindings[name];
for (const name in scope.bindings) {
const binding = scope.bindings[name];

if (!binding.referenced && binding.kind !== "module") {
if (binding.kind === "param" && (this.keepFnArgs || !binding[markForRemoval])) {
Expand Down Expand Up @@ -215,7 +215,7 @@ module.exports = ({ types: t, traverse }) => {
(binding.path.isVariableDeclarator() && binding.path.get("init").isFunction())) {
const fun = binding.path.isFunctionDeclaration() ? binding.path : binding.path.get("init");
let allInside = true;
for (let ref of binding.referencePaths) {
for (const ref of binding.referencePaths) {
if (!ref.find((p) => p.node === fun.node)) {
allInside = false;
break;
Expand Down Expand Up @@ -541,7 +541,7 @@ module.exports = ({ types: t, traverse }) => {
const consequent = cases[i].get("consequent");

for (let j = 0; j < consequent.length; j++) {
let _isBreaking = isBreaking(consequent[j], path);
const _isBreaking = isBreaking(consequent[j], path);
if (_isBreaking.bail) {
result.bail = true;
return result;
Expand Down Expand Up @@ -729,7 +729,7 @@ module.exports = ({ types: t, traverse }) => {
let hasBlockScoped = false;

for (let i = 0; i < node.body.length; i++) {
let bodyNode = node.body[i];
const bodyNode = node.body[i];
if (t.isBlockScoped(bodyNode)) {
hasBlockScoped = true;
}
Expand All @@ -749,10 +749,10 @@ module.exports = ({ types: t, traverse }) => {
// drops are inits
// extractVars({ var x = 5, y = x }) => var x, y;
function extractVars(path) {
let declarators = [];
const declarators = [];

if (path.isVariableDeclaration({ kind: "var" })) {
for (let decl of path.node.declarations) {
for (const decl of path.node.declarations) {
declarators.push(t.variableDeclarator(decl.id));
}
} else {
Expand All @@ -761,7 +761,7 @@ module.exports = ({ types: t, traverse }) => {
if (!varPath.isVariableDeclaration({ kind: "var" })) return;
if (!isSameFunctionScope(varPath, path)) return;

for (let decl of varPath.node.declarations) {
for (const decl of varPath.node.declarations) {
declarators.push(t.variableDeclarator(decl.id));
}
}
Expand Down Expand Up @@ -839,7 +839,7 @@ module.exports = ({ types: t, traverse }) => {
return;
}

let index = binding.referencePaths.indexOf(path);
const index = binding.referencePaths.indexOf(path);
if (index === -1) {
return;
}
Expand Down
8 changes: 4 additions & 4 deletions packages/babel-plugin-minify-flip-comparisons/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ module.exports = function({ types: t }) {
node.right = left;
let operator;
switch (node.operator) {
case ">": operator = "<"; break;
case "<": operator = ">"; break;
case ">=": operator = "<="; break;
case "<=": operator = ">="; break;
case ">": operator = "<"; break;
case "<": operator = ">"; break;
case ">=": operator = "<="; break;
case "<=": operator = ">="; break;
}
node.operator = operator;
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ describe("mangle-names", () => {
expect(transform(source)).toBe(expected);
});

it("should not mangle vars in scope with eval" , () => {
it("should not mangle vars in scope with eval", () => {
const source = unpad(`
function foo() {
var inScopeOuter = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2304,15 +2304,15 @@ describe("simplify-plugin", () => {
});

it("should transform complex logical expressions", () => {
let sources = unpad(`
const sources = unpad(`
a = true && 1 && foo
a = 1 && 4 * 2 && console.log("asdf")
a = 4 * 2 && NaN && foo()
a = 10 == 11 || undefined && foo() + bar() && bar()
a = -1 && undefined || 5 << foo
`).split("\n");

let expected = unpad(`
const expected = unpad(`
a = foo;
a = console.log("asdf");
a = NaN;
Expand Down
42 changes: 21 additions & 21 deletions packages/babel-plugin-minify-simplify/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ module.exports = ({ types: t }) => {
[EX, EX, false, (e, c) => and(notnot(e), c)]
]);

let result = matcher.match(
const result = matcher.match(
[test, consequent, alternate],
isPatternMatchesPath
);
Expand All @@ -372,7 +372,7 @@ module.exports = ({ types: t }) => {
return;
}

let mutations = [];
const mutations = [];
let firstLeft = null;
let operator = null;
function visit(path) {
Expand Down Expand Up @@ -409,7 +409,7 @@ module.exports = ({ types: t }) => {
);
}

let bail = visit(topPath);
const bail = visit(topPath);
if (bail) {
return;
}
Expand Down Expand Up @@ -488,9 +488,9 @@ module.exports = ({ types: t }) => {
return;
}

let inits = [];
let empty = [];
for (let decl of node.declarations) {
const inits = [];
const empty = [];
for (const decl of node.declarations) {
if (!decl.init) {
empty.push(decl);
} else {
Expand Down Expand Up @@ -636,7 +636,7 @@ module.exports = ({ types: t }) => {
return;
}

let rest = [];
const rest = [];

if (breakAt = "consequent") {
if (t.isBlockStatement(ifStatement.alternate)) {
Expand Down Expand Up @@ -745,7 +745,7 @@ module.exports = ({ types: t }) => {
return;
}

for (let statement of statements) {
for (const statement of statements) {
if (!t.isExpressionStatement(statement)) {
return;
}
Expand Down Expand Up @@ -1102,7 +1102,7 @@ module.exports = ({ types: t }) => {

const expr = exprs.length === 1 ? exprs[0] : t.sequenceExpression(exprs);

let replacement = t.logicalExpression("&&", node.test, expr);
const replacement = t.logicalExpression("&&", node.test, expr);

path.replaceWith(t.ifStatement(
replacement,
Expand Down Expand Up @@ -1131,8 +1131,8 @@ module.exports = ({ types: t }) => {

function flatten(node) {
node[seqExprSeen] = true;
let ret = [];
for (let n of node.expressions) {
const ret = [];
for (const n of node.expressions) {
if (t.isSequenceExpression(n)) {
ret.push(...flatten(n));
} else {
Expand Down Expand Up @@ -1176,7 +1176,7 @@ module.exports = ({ types: t }) => {
const consTestPairs = [];
let fallThru = [];
let defaultRet;
for (let switchCase of node.cases) {
for (const switchCase of node.cases) {
if (switchCase.consequent.length > 1) {
return;
}
Expand Down Expand Up @@ -1277,7 +1277,7 @@ module.exports = ({ types: t }) => {
const exprTestPairs = [];
let fallThru = [];
let defaultExpr;
for (let switchCase of node.cases) {
for (const switchCase of node.cases) {
if (!switchCase.test) {
if (switchCase.consequent.length !== 1) {
return;
Expand Down Expand Up @@ -1368,7 +1368,7 @@ module.exports = ({ types: t }) => {
return;
}

let test = node.test;
const test = node.test;
let flip = false;

if (t.isBinaryExpression(test)) {
Expand All @@ -1389,7 +1389,7 @@ module.exports = ({ types: t }) => {
}

if (flip) {
let consequent = node.consequent;
const consequent = node.consequent;
node.consequent = node.alternate;
node.alternate = consequent;
}
Expand Down Expand Up @@ -1496,11 +1496,11 @@ module.exports = ({ types: t }) => {
function createPrevExpressionEater(keyword) {
let key;
switch (keyword) {
case "switch": key = "discriminant"; break;
case "throw":
case "return": key = "argument"; break;
case "if": key = "test"; break;
case "for-in": key = "right"; break;
case "switch": key = "discriminant"; break;
case "throw":
case "return": key = "argument"; break;
case "if": key = "test"; break;
case "for-in": key = "right"; break;
}

return function(path) {
Expand Down Expand Up @@ -1558,7 +1558,7 @@ module.exports = ({ types: t }) => {
return patternValue(inputPath);
}
if (isNodeOfType(inputPath.node, patternValue)) return true;
let evalResult = inputPath.evaluate();
const evalResult = inputPath.evaluate();
if (!evalResult.confident || !inputPath.isPure()) return false;
return evalResult.value === patternValue;
}
Expand Down
Loading

0 comments on commit e5ec515

Please sign in to comment.