diff --git a/package.json b/package.json index 6f082e6cd173..30fdfe614941 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "codecov": "^1.0.1", "derequire": "^2.0.2", "eslint": "^3.9.0", - "eslint-config-babel": "^5.0.0", + "eslint-config-babel": "^6.0.0", "eslint-plugin-flowtype": "^2.20.0", "flow-bin": "^0.34.0", "gulp": "^3.9.0", diff --git a/packages/babel-code-frame/src/index.js b/packages/babel-code-frame/src/index.js index 9476ef617d22..e2a1b84ebe5c 100644 --- a/packages/babel-code-frame/src/index.js +++ b/packages/babel-code-frame/src/index.js @@ -1,4 +1,4 @@ -import jsTokens, {matchToToken} from "js-tokens"; +import jsTokens, { matchToToken } from "js-tokens"; import esutils from "esutils"; import Chalk from "chalk"; diff --git a/packages/babel-code-frame/test/index.js b/packages/babel-code-frame/test/index.js index e11f0c8a7f91..b6906100ee15 100644 --- a/packages/babel-code-frame/test/index.js +++ b/packages/babel-code-frame/test/index.js @@ -109,7 +109,7 @@ describe("babel-code-frame", function () { it("opts.highlightCode", function () { const rawLines = "console.log('babel')"; - const result = codeFrame(rawLines, 1, 9, {highlightCode: true}); + const result = codeFrame(rawLines, 1, 9, { highlightCode: true }); const stripped = chalk.stripColor(result); assert.ok(result.length > stripped.length); assert.equal(stripped, [ diff --git a/packages/babel-core/src/transformation/internal-plugins/shadow-functions.js b/packages/babel-core/src/transformation/internal-plugins/shadow-functions.js index 6b5995fc27d2..1b50aa759c74 100644 --- a/packages/babel-core/src/transformation/internal-plugins/shadow-functions.js +++ b/packages/babel-core/src/transformation/internal-plugins/shadow-functions.js @@ -7,7 +7,7 @@ const superVisitor = { CallExpression(path) { if (!path.get("callee").isSuper()) return; - const {node} = path; + const { node } = path; if (node[SUPER_THIS_BOUND]) return; node[SUPER_THIS_BOUND] = true; @@ -101,7 +101,7 @@ function remap(path, key) { const classPath = fnPath.findParent((p) => p.isClass()); const hasSuperClass = !!(classPath && classPath.node && classPath.node.superClass); - if (key === "this" && fnPath.isMethod({kind: "constructor"}) && hasSuperClass) { + if (key === "this" && fnPath.isMethod({ kind: "constructor" }) && hasSuperClass) { fnPath.scope.push({ id }); fnPath.traverse(superVisitor, { id }); diff --git a/packages/babel-core/test/evaluation.js b/packages/babel-core/test/evaluation.js index b0741a5149b0..f7ee8ef47961 100644 --- a/packages/babel-core/test/evaluation.js +++ b/packages/babel-core/test/evaluation.js @@ -64,6 +64,6 @@ describe("evaluation", function () { addTest("'abc' === 'xyz' || (1 === 1 && 'four' === 'four')", "LogicalExpression", true); addTest("'abc' === 'abc' && (1 === 1 && 'four' === 'four')", "LogicalExpression", true); addTest("({})", "ObjectExpression", {}); - addTest("({a: '1'})", "ObjectExpression", {a: "1"}); - addTest("({['a' + 'b']: 10 * 20, 'z': [1, 2, 3]})", "ObjectExpression", {ab: 200, z: [1, 2, 3]}); + addTest("({a: '1'})", "ObjectExpression", { a: "1" }); + addTest("({['a' + 'b']: 10 * 20, 'z': [1, 2, 3]})", "ObjectExpression", { ab: 200, z: [1, 2, 3] }); }); diff --git a/packages/babel-generator/src/buffer.js b/packages/babel-generator/src/buffer.js index 72894c440a25..d1187be27531 100644 --- a/packages/babel-generator/src/buffer.js +++ b/packages/babel-generator/src/buffer.js @@ -55,7 +55,7 @@ export default class Buffer { return this.map = map.get(); }, set(value) { - Object.defineProperty(this, "map", {value, writable: true}); + Object.defineProperty(this, "map", { value, writable: true }); }, }); } diff --git a/packages/babel-generator/src/index.js b/packages/babel-generator/src/index.js index a3031f16796e..138336546c50 100644 --- a/packages/babel-generator/src/index.js +++ b/packages/babel-generator/src/index.js @@ -2,7 +2,7 @@ import detectIndent from "detect-indent"; import SourceMap from "./source-map"; import * as messages from "babel-messages"; import Printer from "./printer"; -import type {Format} from "./printer"; +import type { Format } from "./printer"; /** * Babel's code generator, turns an ast into code, maintaining sourcemaps, diff --git a/packages/babel-generator/src/node/parentheses.js b/packages/babel-generator/src/node/parentheses.js index 203ed8a3aa76..e6424aced671 100644 --- a/packages/babel-generator/src/node/parentheses.js +++ b/packages/babel-generator/src/node/parentheses.js @@ -43,7 +43,7 @@ export function UpdateExpression(node: Object, parent: Object): boolean { } export function ObjectExpression(node: Object, parent: Object, printStack: Array): boolean { - return isFirstInStatement(printStack, {considerArrow: true}); + return isFirstInStatement(printStack, { considerArrow: true }); } export function Binary(node: Object, parent: Object): boolean { @@ -150,7 +150,7 @@ export function YieldExpression(node: Object, parent: Object): boolean { export { YieldExpression as AwaitExpression }; export function ClassExpression(node: Object, parent: Object, printStack: Array): boolean { - return isFirstInStatement(printStack, {considerDefaultExports: true}); + return isFirstInStatement(printStack, { considerDefaultExports: true }); } export function UnaryLike(node: Object, parent: Object): boolean { @@ -166,7 +166,7 @@ export function UnaryLike(node: Object, parent: Object): boolean { } export function FunctionExpression(node: Object, parent: Object, printStack: Array): boolean { - return isFirstInStatement(printStack, {considerDefaultExports: true}); + return isFirstInStatement(printStack, { considerDefaultExports: true }); } export function ArrowFunctionExpression(node: Object, parent: Object): boolean { diff --git a/packages/babel-plugin-transform-class-properties/src/index.js b/packages/babel-plugin-transform-class-properties/src/index.js index af383d44bd1f..9c5e7d24a21c 100644 --- a/packages/babel-plugin-transform-class-properties/src/index.js +++ b/packages/babel-plugin-transform-class-properties/src/index.js @@ -29,13 +29,13 @@ export default function ({ types: t }) { }); `); - const buildClassPropertySpec = (ref, {key, value, computed}) => buildObjectDefineProperty({ + const buildClassPropertySpec = (ref, { key, value, computed }) => buildObjectDefineProperty({ REF: ref, KEY: (t.isIdentifier(key) && !computed) ? t.stringLiteral(key.name) : key, VALUE: value ? value : t.identifier("undefined") }); - const buildClassPropertyNonSpec = (ref, {key, value, computed}) => t.expressionStatement( + const buildClassPropertyNonSpec = (ref, { key, value, computed }) => t.expressionStatement( t.assignmentExpression("=", t.memberExpression(ref, key, computed || t.isLiteral(key)), value) ); diff --git a/packages/babel-plugin-transform-es2015-destructuring/src/index.js b/packages/babel-plugin-transform-es2015-destructuring/src/index.js index bbe1f9018fcb..0bdfb8b695ae 100644 --- a/packages/babel-plugin-transform-es2015-destructuring/src/index.js +++ b/packages/babel-plugin-transform-es2015-destructuring/src/index.js @@ -506,7 +506,7 @@ export default function ({ types: t }) { for (const nodeOut of nodesOut) { if (!nodeOut.declarations) continue; for (const declaration of nodeOut.declarations) { - const {name} = declaration.id; + const { name } = declaration.id; if (scope.bindings[name]) { scope.bindings[name].kind = nodeOut.kind; } diff --git a/packages/babel-plugin-transform-es2015-modules-commonjs/src/index.js b/packages/babel-plugin-transform-es2015-modules-commonjs/src/index.js index a7285da44645..1b491ea72380 100644 --- a/packages/babel-plugin-transform-es2015-modules-commonjs/src/index.js +++ b/packages/babel-plugin-transform-es2015-modules-commonjs/src/index.js @@ -355,7 +355,7 @@ export default function () { } for (const source in imports) { - const {specifiers, maxBlockHoist} = imports[source]; + const { specifiers, maxBlockHoist } = imports[source]; if (specifiers.length) { const uid = addRequire(source, maxBlockHoist); diff --git a/packages/babel-plugin-transform-es2015-modules-commonjs/test/esmodule-flag.js b/packages/babel-plugin-transform-es2015-modules-commonjs/test/esmodule-flag.js index 2ab422c89b68..920733e6162d 100644 --- a/packages/babel-plugin-transform-es2015-modules-commonjs/test/esmodule-flag.js +++ b/packages/babel-plugin-transform-es2015-modules-commonjs/test/esmodule-flag.js @@ -21,7 +21,7 @@ test("Re-export doesn't overwrite __esModule flag", function () { code = babel.transform(code, { "plugins": [ - [require("../"), {loose: true}], + [require("../"), { loose: true }], ], "ast": false, }).code; diff --git a/packages/babel-plugin-transform-es2015-parameters/src/rest.js b/packages/babel-plugin-transform-es2015-parameters/src/rest.js index 3ae51ed5488b..d0ff2846cb45 100644 --- a/packages/babel-plugin-transform-es2015-parameters/src/rest.js +++ b/packages/babel-plugin-transform-es2015-parameters/src/rest.js @@ -67,7 +67,7 @@ const memberExpressionOptimisationVisitor = { if (state.noOptimise) { state.deopted = true; } else { - const {parentPath} = path; + const { parentPath } = path; // Is this identifier the right hand side of a default parameter? if (parentPath.listKey === "params" && parentPath.key < state.offset) { @@ -117,13 +117,13 @@ const memberExpressionOptimisationVisitor = { // if we know that this member expression is referencing a number then // we can safely optimise it if (parentPath.get("property").isBaseType("number")) { - state.candidates.push({cause: "indexGetter", path}); + state.candidates.push({ cause: "indexGetter", path }); return; } } // args.length else if (parentPath.node.property.name === "length") { - state.candidates.push({cause: "lengthGetter", path}); + state.candidates.push({ cause: "lengthGetter", path }); return; } } @@ -136,7 +136,7 @@ const memberExpressionOptimisationVisitor = { if (state.offset === 0 && parentPath.isSpreadElement()) { const call = parentPath.parentPath; if (call.isCallExpression() && call.node.arguments.length === 1) { - state.candidates.push({cause: "argSpread", path}); + state.candidates.push({ cause: "argSpread", path }); return; } } @@ -176,7 +176,7 @@ function optimiseIndexGetter(path, argsId, offset) { const { scope } = path; if (!scope.isPure(index)) { const temp = scope.generateUidIdentifierBasedOnNode(index); - scope.push({id: temp, kind: "var"}); + scope.push({ id: temp, kind: "var" }); path.parentPath.replaceWith(restIndexImpure({ ARGUMENTS: argsId, INDEX: index, @@ -246,7 +246,7 @@ export const visitor = { // There are only "shorthand" references if (!state.deopted && !state.references.length) { - for (const {path, cause} of (state.candidates: Array)) { + for (const { path, cause } of (state.candidates: Array)) { switch (cause) { case "indexGetter": optimiseIndexGetter(path, argsId, state.offset); diff --git a/packages/babel-plugin-transform-es3-property-literals/src/index.js b/packages/babel-plugin-transform-es3-property-literals/src/index.js index e62a88f8ee27..0dbb2ee2155d 100644 --- a/packages/babel-plugin-transform-es3-property-literals/src/index.js +++ b/packages/babel-plugin-transform-es3-property-literals/src/index.js @@ -2,7 +2,7 @@ export default function ({ types: t }) { return { visitor: { ObjectProperty: { - exit({node}) { + exit({ node }) { const key = node.key; if (!node.computed && t.isIdentifier(key) && !t.isValidIdentifier(key.name)) { // default: "bar" -> "default": "bar" diff --git a/packages/babel-plugin-transform-react-jsx-source/src/index.js b/packages/babel-plugin-transform-react-jsx-source/src/index.js index 039e9e5adc60..9bde06650001 100644 --- a/packages/babel-plugin-transform-react-jsx-source/src/index.js +++ b/packages/babel-plugin-transform-react-jsx-source/src/index.js @@ -50,7 +50,7 @@ export default function ({ types: t }) { : null; const fileNameIdentifier = path.scope.generateUidIdentifier(FILE_NAME_VAR); - path.hub.file.scope.push({id: fileNameIdentifier, init: t.stringLiteral(fileName)}); + path.hub.file.scope.push({ id: fileNameIdentifier, init: t.stringLiteral(fileName) }); state.fileNameIdentifier = fileNameIdentifier; } diff --git a/packages/babel-preset-es2015/test/index.js b/packages/babel-preset-es2015/test/index.js index b04436210bb2..b7847d1b8355 100644 --- a/packages/babel-preset-es2015/test/index.js +++ b/packages/babel-preset-es2015/test/index.js @@ -21,7 +21,7 @@ describe("es2015 preset", function () { describe("loose", function () { it("throws on non-boolean value", function () { expect(function () { - es2015.buildPreset(null, { loose: 1}); + es2015.buildPreset(null, { loose: 1 }); }).to.throw(/must be a boolean/); }); }); diff --git a/packages/babel-template/src/index.js b/packages/babel-template/src/index.js index 4abd2a460803..164652c1439d 100644 --- a/packages/babel-template/src/index.js +++ b/packages/babel-template/src/index.js @@ -36,7 +36,7 @@ export default function (code: string, opts?: Object): Function { try { ast = babylon.parse(code, opts); - ast = traverse.removeProperties(ast, {preserveComments: opts.preserveComments}); + ast = traverse.removeProperties(ast, { preserveComments: opts.preserveComments }); traverse.cheap(ast, function (node) { node[FROM_TEMPLATE] = true; diff --git a/packages/babel-template/test/index.js b/packages/babel-template/test/index.js index bad7d69f8d23..216d6a89396c 100644 --- a/packages/babel-template/test/index.js +++ b/packages/babel-template/test/index.js @@ -13,7 +13,7 @@ describe("templating", function () { it("import statements are allowed with sourceType: module", function () { chai.expect(function () { - template("import foo from 'foo'", {sourceType: "module"})({}); + template("import foo from 'foo'", { sourceType: "module" })({}); }).not.to.throw(); }); @@ -24,7 +24,7 @@ describe("templating", function () { }); it("should preserve comments with a flag", function () { - const output = template(comments, {preserveComments: true})(); + const output = template(comments, { preserveComments: true })(); chai.expect(generator(output).code).to.be.equal(comments); }); }); diff --git a/packages/babel-traverse/test/inference.js b/packages/babel-traverse/test/inference.js index 5819cd1b06d0..225f2c743034 100644 --- a/packages/babel-traverse/test/inference.js +++ b/packages/babel-traverse/test/inference.js @@ -4,7 +4,7 @@ import { parse } from "babylon"; import * as t from "babel-types"; function getPath(code) { - const ast = parse(code, {plugins: ["flow", "asyncGenerators"]}); + const ast = parse(code, { plugins: ["flow", "asyncGenerators"] }); let path; traverse(ast, { Program: function (_path) { diff --git a/packages/babel-types/test/retrievers.js b/packages/babel-types/test/retrievers.js index 68eb34c4f309..15f4149cd17d 100644 --- a/packages/babel-types/test/retrievers.js +++ b/packages/babel-types/test/retrievers.js @@ -3,7 +3,7 @@ import assert from "assert"; import { parse } from "babylon"; function getBody(program) { - return parse(program, {sourceType: "module"}).program.body; + return parse(program, { sourceType: "module" }).program.body; } describe("retrievers", function () {