From e5ec51539cf4f7b7870af91e1ccd98a1010274fa Mon Sep 17 00:00:00 2001 From: Kai Cataldo Date: Mon, 16 Jan 2017 10:00:24 -0500 Subject: [PATCH] devDeps: eslint-config-babel v5.0.0 (#376) --- package.json | 6 +- .../src/index.js | 8 +-- .../src/index.js | 12 ++-- .../__tests__/dead-code-elimination-test.js | 10 +-- .../src/index.js | 26 ++++---- .../src/index.js | 8 +-- .../__tests__/mangle-names-test.js | 2 +- .../__tests__/simplify-test.js | 4 +- .../babel-plugin-minify-simplify/src/index.js | 42 ++++++------ .../src/pattern-match.js | 8 +-- .../src/index.js | 2 +- .../src/index.js | 2 +- .../src/index.js | 2 +- .../src/index.js | 12 ++-- .../src/index.js | 2 +- .../src/index.js | 2 +- .../src/index.js | 38 +++++------ .../src/index.js | 6 +- packages/babel-preset-babili/src/index.js | 2 +- .../src/options-manager.js | 66 +++++++++---------- scripts/benchmark.js | 12 ++-- scripts/plugin-contribution.js | 12 ++-- scripts/plugin-timing.js | 12 ++-- 23 files changed, 149 insertions(+), 147 deletions(-) diff --git a/package.json b/package.json index c47e7bd57..c11d61d4c 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", diff --git a/packages/babel-helper-flip-expressions/src/index.js b/packages/babel-helper-flip-expressions/src/index.js index 56f4bdf04..494f9f17d 100644 --- a/packages/babel-helper-flip-expressions/src/index.js +++ b/packages/babel-helper-flip-expressions/src/index.js @@ -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) { diff --git a/packages/babel-helper-to-multiple-sequence-expressions/src/index.js b/packages/babel-helper-to-multiple-sequence-expressions/src/index.js index 82b2d3f54..5e0105448 100644 --- a/packages/babel-helper-to-multiple-sequence-expressions/src/index.js +++ b/packages/babel-helper-to-multiple-sequence-expressions/src/index.js @@ -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)); } @@ -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]; @@ -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)) { diff --git a/packages/babel-plugin-minify-dead-code-elimination/__tests__/dead-code-elimination-test.js b/packages/babel-plugin-minify-dead-code-elimination/__tests__/dead-code-elimination-test.js index 4cc160fb5..cd3922821 100644 --- a/packages/babel-plugin-minify-dead-code-elimination/__tests__/dead-code-elimination-test.js +++ b/packages/babel-plugin-minify-dead-code-elimination/__tests__/dead-code-elimination-test.js @@ -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) { @@ -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(); @@ -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) { @@ -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) { @@ -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() { diff --git a/packages/babel-plugin-minify-dead-code-elimination/src/index.js b/packages/babel-plugin-minify-dead-code-elimination/src/index.js index e193d924e..65efb3a0f 100644 --- a/packages/babel-plugin-minify-dead-code-elimination/src/index.js +++ b/packages/babel-plugin-minify-dead-code-elimination/src/index.js @@ -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; } @@ -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)); @@ -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; @@ -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])) { @@ -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; @@ -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; @@ -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; } @@ -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 { @@ -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)); } } @@ -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; } diff --git a/packages/babel-plugin-minify-flip-comparisons/src/index.js b/packages/babel-plugin-minify-flip-comparisons/src/index.js index c623b594c..91eca7aec 100644 --- a/packages/babel-plugin-minify-flip-comparisons/src/index.js +++ b/packages/babel-plugin-minify-flip-comparisons/src/index.js @@ -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; diff --git a/packages/babel-plugin-minify-mangle-names/__tests__/mangle-names-test.js b/packages/babel-plugin-minify-mangle-names/__tests__/mangle-names-test.js index 7ad879552..ade8c972b 100644 --- a/packages/babel-plugin-minify-mangle-names/__tests__/mangle-names-test.js +++ b/packages/babel-plugin-minify-mangle-names/__tests__/mangle-names-test.js @@ -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; diff --git a/packages/babel-plugin-minify-simplify/__tests__/simplify-test.js b/packages/babel-plugin-minify-simplify/__tests__/simplify-test.js index 687b4ec48..85367426c 100644 --- a/packages/babel-plugin-minify-simplify/__tests__/simplify-test.js +++ b/packages/babel-plugin-minify-simplify/__tests__/simplify-test.js @@ -2304,7 +2304,7 @@ 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() @@ -2312,7 +2312,7 @@ describe("simplify-plugin", () => { a = -1 && undefined || 5 << foo `).split("\n"); - let expected = unpad(` + const expected = unpad(` a = foo; a = console.log("asdf"); a = NaN; diff --git a/packages/babel-plugin-minify-simplify/src/index.js b/packages/babel-plugin-minify-simplify/src/index.js index 894c53fb7..1eba002aa 100644 --- a/packages/babel-plugin-minify-simplify/src/index.js +++ b/packages/babel-plugin-minify-simplify/src/index.js @@ -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 ); @@ -372,7 +372,7 @@ module.exports = ({ types: t }) => { return; } - let mutations = []; + const mutations = []; let firstLeft = null; let operator = null; function visit(path) { @@ -409,7 +409,7 @@ module.exports = ({ types: t }) => { ); } - let bail = visit(topPath); + const bail = visit(topPath); if (bail) { return; } @@ -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 { @@ -636,7 +636,7 @@ module.exports = ({ types: t }) => { return; } - let rest = []; + const rest = []; if (breakAt = "consequent") { if (t.isBlockStatement(ifStatement.alternate)) { @@ -745,7 +745,7 @@ module.exports = ({ types: t }) => { return; } - for (let statement of statements) { + for (const statement of statements) { if (!t.isExpressionStatement(statement)) { return; } @@ -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, @@ -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 { @@ -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; } @@ -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; @@ -1368,7 +1368,7 @@ module.exports = ({ types: t }) => { return; } - let test = node.test; + const test = node.test; let flip = false; if (t.isBinaryExpression(test)) { @@ -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; } @@ -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) { @@ -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; } diff --git a/packages/babel-plugin-minify-simplify/src/pattern-match.js b/packages/babel-plugin-minify-simplify/src/pattern-match.js index 8e5c0d172..e88002246 100644 --- a/packages/babel-plugin-minify-simplify/src/pattern-match.js +++ b/packages/babel-plugin-minify-simplify/src/pattern-match.js @@ -5,7 +5,7 @@ module.exports = class PatternMatch { this.decisionTree = this.makeDecisionTree(patterns); } handle(input, isMatch) { - let result = this.match(input, isMatch); + const result = this.match(input, isMatch); if (!result.match) { throw new Error("No Match Found for " + input.toString()); @@ -32,7 +32,7 @@ module.exports = class PatternMatch { let matchedKey = NO_MATCH; // because map doesn't support custom key equal function - for (let key of current.keys()) { + for (const key of current.keys()) { if (isMatch(key, input[i])) { matchedKey = key; result.keys.push(matchedKey); @@ -58,9 +58,9 @@ module.exports = class PatternMatch { } makeDecisionTree(patterns) { // order of keys in a Map is the order of insertion - let root = new Map; + const root = new Map; - for (let pattern of patterns) { + for (const pattern of patterns) { make(root, pattern); } diff --git a/packages/babel-plugin-transform-inline-consecutive-adds/src/index.js b/packages/babel-plugin-transform-inline-consecutive-adds/src/index.js index 517d5858c..cd1db5061 100644 --- a/packages/babel-plugin-transform-inline-consecutive-adds/src/index.js +++ b/packages/babel-plugin-transform-inline-consecutive-adds/src/index.js @@ -183,7 +183,7 @@ module.exports = function({ types: t }) { return; } - const [name,,] = topLevel; + const [name] = topLevel; const references = getIdAndFunctionReferences(name, varDecl.parentPath); if (references === false) { return; diff --git a/packages/babel-plugin-transform-inline-environment-variables/src/index.js b/packages/babel-plugin-transform-inline-environment-variables/src/index.js index 33ed26905..f31cf4cda 100644 --- a/packages/babel-plugin-transform-inline-environment-variables/src/index.js +++ b/packages/babel-plugin-transform-inline-environment-variables/src/index.js @@ -6,7 +6,7 @@ module.exports = function({ types: t }) { visitor: { MemberExpression(path) { if (path.get("object").matchesPattern("process.env")) { - let key = path.toComputedKey(); + const key = path.toComputedKey(); if (t.isStringLiteral(key)) { path.replaceWith(t.valueToNode(process.env[key.value])); } diff --git a/packages/babel-plugin-transform-member-expression-literals/src/index.js b/packages/babel-plugin-transform-member-expression-literals/src/index.js index 34833cccd..eaed79102 100644 --- a/packages/babel-plugin-transform-member-expression-literals/src/index.js +++ b/packages/babel-plugin-transform-member-expression-literals/src/index.js @@ -7,7 +7,7 @@ module.exports = function({ types: t }) { // foo['bar'] -> foo.bar MemberExpression: { exit({ node }) { - let prop = node.property; + const prop = node.property; if (!node.computed || !t.isStringLiteral(prop)) { return; } diff --git a/packages/babel-plugin-transform-merge-sibling-variables/src/index.js b/packages/babel-plugin-transform-merge-sibling-variables/src/index.js index 84cc00ec0..6c1a3766f 100644 --- a/packages/babel-plugin-transform-merge-sibling-variables/src/index.js +++ b/packages/babel-plugin-transform-merge-sibling-variables/src/index.js @@ -13,13 +13,13 @@ module.exports = function({ types: t }) { return; } - let firstNode = body[0].node.declarations[0]; + const firstNode = body[0].node.declarations[0]; if (!t.isIdentifier(firstNode.id) || !firstNode.init) { return; } - let init = path.get("init"); + const init = path.get("init"); if (!init.isVariableDeclaration({ kind: kind })) { return; } @@ -56,10 +56,10 @@ module.exports = function({ types: t }) { return; } - let { node } = path; + const { node } = path; while (true) { - let sibling = path.getSibling(path.key + 1); + const sibling = path.getSibling(path.key + 1); if (!sibling.isVariableDeclaration({ kind: node.kind })) { break; } @@ -82,12 +82,12 @@ module.exports = function({ types: t }) { return; } - let next = path.getSibling(path.key + 1); + const next = path.getSibling(path.key + 1); if (!next.isForStatement()) { return; } - let init = next.get("init"); + const init = next.get("init"); if (!init.isVariableDeclaration({ kind: node.kind })) { return; } diff --git a/packages/babel-plugin-transform-node-env-inline/src/index.js b/packages/babel-plugin-transform-node-env-inline/src/index.js index 035f9181e..78b289a00 100644 --- a/packages/babel-plugin-transform-node-env-inline/src/index.js +++ b/packages/babel-plugin-transform-node-env-inline/src/index.js @@ -9,7 +9,7 @@ module.exports = function({ types: t }) { path.replaceWith(t.valueToNode(process.env.NODE_ENV)); if (path.parentPath.isBinaryExpression()) { - let evaluated = path.parentPath.evaluate(); + const evaluated = path.parentPath.evaluate(); if (evaluated.confident) { path.parentPath.replaceWith(t.valueToNode(evaluated.value)); } diff --git a/packages/babel-plugin-transform-property-literals/src/index.js b/packages/babel-plugin-transform-property-literals/src/index.js index 23cdc0bfe..1dc6469e0 100644 --- a/packages/babel-plugin-transform-property-literals/src/index.js +++ b/packages/babel-plugin-transform-property-literals/src/index.js @@ -7,7 +7,7 @@ module.exports = function({ types: t }) { // { 'foo': 'bar' } -> { foo: 'bar' } ObjectProperty: { exit({ node }) { - let key = node.key; + const key = node.key; if (!t.isStringLiteral(key)) { return; } diff --git a/packages/babel-plugin-transform-remove-undefined/src/index.js b/packages/babel-plugin-transform-remove-undefined/src/index.js index 262dad84d..571f65303 100644 --- a/packages/babel-plugin-transform-remove-undefined/src/index.js +++ b/packages/babel-plugin-transform-remove-undefined/src/index.js @@ -90,29 +90,29 @@ module.exports = function() { VariableDeclaration(path) { switch (path.node.kind) { - case "const": - break; - case "let": - for (const declarator of path.get("declarations")) { - if (isPureAndUndefined(declarator.get("init"))) { - declarator.node.init = null; + case "const": + break; + case "let": + for (const declarator of path.get("declarations")) { + if (isPureAndUndefined(declarator.get("init"))) { + declarator.node.init = null; + } } - } - break; - case "var": - const start = path.node.start; - if (start === undefined) { - // This is common for plugin-generated nodes break; - } - const scope = path.scope; - for (const declarator of path.get("declarations")) { - if (isPureAndUndefined(declarator.get("init")) && + case "var": + const start = path.node.start; + if (start === undefined) { + // This is common for plugin-generated nodes + break; + } + const scope = path.scope; + for (const declarator of path.get("declarations")) { + if (isPureAndUndefined(declarator.get("init")) && !hasViolation(declarator, scope, start)) { - declarator.node.init = null; + declarator.node.init = null; + } } - } - break; + break; } }, }, diff --git a/packages/babel-plugin-transform-simplify-comparison-operators/src/index.js b/packages/babel-plugin-transform-simplify-comparison-operators/src/index.js index e3cadec86..01b9996a3 100644 --- a/packages/babel-plugin-transform-simplify-comparison-operators/src/index.js +++ b/packages/babel-plugin-transform-simplify-comparison-operators/src/index.js @@ -8,13 +8,13 @@ module.exports = function() { // that each value will always be of the same type BinaryExpression(path) { const { node } = path; - let op = node.operator; + const op = node.operator; if (op !== "===" && op !== "!==") { return; } - let left = path.get("left"); - let right = path.get("right"); + const left = path.get("left"); + const right = path.get("right"); const strictMatch = left.baseTypeStrictlyMatches(right); if (strictMatch) { node.operator = node.operator.slice(0, -1); diff --git a/packages/babel-preset-babili/src/index.js b/packages/babel-preset-babili/src/index.js index 1c5403f7d..1ae6ba704 100644 --- a/packages/babel-preset-babili/src/index.js +++ b/packages/babel-preset-babili/src/index.js @@ -34,7 +34,7 @@ function preset(context, _opts = {}) { const opts = isPlainObject(_opts) ? _opts : {}; // to track every plugin is used - let usedPlugins = new Set; + const usedPlugins = new Set; const optionsMap = PLUGINS .map((plugin) => option(plugin[0], plugin[1], plugin[2])) diff --git a/packages/babel-preset-babili/src/options-manager.js b/packages/babel-preset-babili/src/options-manager.js index 404ae20a7..37b6270fc 100644 --- a/packages/babel-preset-babili/src/options-manager.js +++ b/packages/babel-preset-babili/src/options-manager.js @@ -55,14 +55,14 @@ function generateResult(resolvedOpts) { const option = options[i]; switch (option.type) { - case "option": - if (option.resolvedValue) { - result.push(option.resolvedValue); - } - break; - case "group": - result.push(...generateResult(option)); - break; + case "option": + if (option.resolvedValue) { + result.push(option.resolvedValue); + } + break; + case "group": + result.push(...generateResult(option)); + break; } } @@ -82,23 +82,23 @@ function resolveOptions(optionTree, inputOpts = {}) { for (let i = 0; i < options.length; i++) { const option = options[i]; switch (option.type) { - case "option": - resolveTypeOption(option, inputOpts); - break; + case "option": + resolveTypeOption(option, inputOpts); + break; - case "group": - resolveTypeGroup(option, inputOpts); - break; + case "group": + resolveTypeGroup(option, inputOpts); + break; - case "proxy": - if (!hop(inputOpts, option.name)) { + case "proxy": + if (!hop(inputOpts, option.name)) { + break; + } + proxiesToResolve.push(option); break; - } - proxiesToResolve.push(option); - break; - default: - throw new TypeError("Option type not supported - " + option.type); + default: + throw new TypeError("Option type not supported - " + option.type); } } @@ -108,16 +108,16 @@ function resolveOptions(optionTree, inputOpts = {}) { for (let j = 0; j < proxy.to.length; j++) { const option = proxy.to[j]; switch (option.type) { - case "option": - resolveTypeProxyToOption(proxy, option, inputOpts); - break; + case "option": + resolveTypeProxyToOption(proxy, option, inputOpts); + break; - case "group": - case "proxy": - throw new Error(`proxy option cannot proxy to group/proxy. ${proxy.name} proxied to ${option.name}`); + case "group": + case "proxy": + throw new Error(`proxy option cannot proxy to group/proxy. ${proxy.name} proxied to ${option.name}`); - default: - throw new Error("Unsupported option type ${option.name}"); + default: + throw new Error("Unsupported option type ${option.name}"); } } } @@ -171,10 +171,10 @@ function resolveTypeGroup(option, inputOpts) { .reduce((acc, cur) => { let value; switch (option.defaultValue) { - case "all": value = true; break; - case "some": value = cur.defaultValue; break; - case "none": value = false; break; - default: throw new Error(`Unsupported defaultValue - ${option.defaultValue} for option ${option.name}`); + case "all": value = true; break; + case "some": value = cur.defaultValue; break; + case "none": value = false; break; + default: throw new Error(`Unsupported defaultValue - ${option.defaultValue} for option ${option.name}`); } return Object.assign({}, acc, { [cur.name]: value, diff --git a/scripts/benchmark.js b/scripts/benchmark.js index 6907a6872..c35d6448b 100755 --- a/scripts/benchmark.js +++ b/scripts/benchmark.js @@ -47,18 +47,18 @@ const table = new Table({ head: ["", "raw", "raw win", "gzip", "gzip win", "parse time", "run time (average)"], chars: { top: "", - "top-mid": "" , - "top-left": "" , + "top-mid": "", + "top-left": "", "top-right": "", - bottom: "" , - "bottom-mid": "" , - "bottom-left": "" , + bottom: "", + "bottom-mid": "", + "bottom-left": "", "bottom-right": "", left: "", "left-mid": "", mid: "", "mid-mid": "", - right: "" , + right: "", "right-mid": "", middle: " ", }, diff --git a/scripts/plugin-contribution.js b/scripts/plugin-contribution.js index 5795f4e75..9e4897ec6 100755 --- a/scripts/plugin-contribution.js +++ b/scripts/plugin-contribution.js @@ -132,18 +132,18 @@ function tableStyle() { return { chars: { top: "", - "top-mid": "" , - "top-left": "" , + "top-mid": "", + "top-left": "", "top-right": "", - bottom: "" , - "bottom-mid": "" , - "bottom-left": "" , + bottom: "", + "bottom-mid": "", + "bottom-left": "", "bottom-right": "", left: "", "left-mid": "", mid: "", "mid-mid": "", - right: "" , + right: "", "right-mid": "", middle: " ", }, diff --git a/scripts/plugin-timing.js b/scripts/plugin-timing.js index e4c50c0db..e3701fec5 100755 --- a/scripts/plugin-timing.js +++ b/scripts/plugin-timing.js @@ -65,18 +65,18 @@ function run (file) { head: ["pluginAlias", "time(ms)", "# visits", "time/visit(ms)"], chars: { top: "", - "top-mid": "" , - "top-left": "" , + "top-mid": "", + "top-left": "", "top-right": "", - bottom: "" , - "bottom-mid": "" , - "bottom-left": "" , + bottom: "", + "bottom-mid": "", + "bottom-left": "", "bottom-right": "", left: "", "left-mid": "", mid: "", "mid-mid": "", - right: "" , + right: "", "right-mid": "", middle: " ", },