diff --git a/.eslintrc b/.eslintrc index 00dd6a98ad..02f7711758 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,7 +1,6 @@ { "extends": "babel", "rules": { - "max-len": 0 }, "env": { "node": true, diff --git a/.gitignore b/.gitignore index 1b6989d7b1..702ae50d45 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ node_modules test/tmp *.log *.cache +/.eslintcache /templates.json /tests.json /browser.js diff --git a/babel.sublime-project b/babel.sublime-project index 8fc404b28a..1f18a8cc50 100644 --- a/babel.sublime-project +++ b/babel.sublime-project @@ -1,7 +1,7 @@ { "settings": { "rulers": [ - 100 + 110 ], // Set to false to disable detection of tabs vs. spaces on load diff --git a/packages/babel-cli/src/babel-node.js b/packages/babel-cli/src/babel-node.js index e3d0c2e901..ee25b5f48a 100755 --- a/packages/babel-cli/src/babel-node.js +++ b/packages/babel-cli/src/babel-node.js @@ -1,5 +1,3 @@ -/* eslint indent: 0 */ - /** * This tiny wrapper file checks for known node flags and appends them * when found, before invoking the "real" _babel-node(1) executable. diff --git a/packages/babel-cli/src/babel/index.js b/packages/babel-cli/src/babel/index.js index 3f7f143987..194254bf61 100755 --- a/packages/babel-cli/src/babel/index.js +++ b/packages/babel-cli/src/babel/index.js @@ -1,7 +1,4 @@ #!/usr/bin/env node -/* eslint max-len: 0 */ - -require("babel-core"); const fs = require("fs"); const commander = require("commander"); @@ -38,6 +35,7 @@ Object.keys(options).forEach(function (key) { commander.option(arg, desc.join(" ")); }); +/* eslint-disable max-len */ commander.option("-x, --extensions [extensions]", "List of extensions to compile when a directory has been input [.es6,.js,.es,.jsx]"); commander.option("-w, --watch", "Recompile files on changes"); commander.option("--skip-initial-build", "Do not compile files before watching"); @@ -45,6 +43,7 @@ commander.option("-o, --out-file [out]", "Compile all input files into a single commander.option("-d, --out-dir [out]", "Compile an input directory of modules into an output directory"); commander.option("-D, --copy-files", "When compiling a directory copy over non-compilable files"); commander.option("-q, --quiet", "Don't log anything"); +/* eslint-enable max-len */ const pkg = require("../../package.json"); commander.version(pkg.version + " (babel-core " + require("babel-core").version + ")"); diff --git a/packages/babel-cli/test/index.js b/packages/babel-cli/test/index.js index 1655a4e79b..9da8405733 100644 --- a/packages/babel-cli/test/index.js +++ b/packages/babel-cli/test/index.js @@ -46,7 +46,8 @@ const assertTest = function (stdout, stderr, opts) { if (opts.stderr) { if (opts.stderrContains) { - assert.ok(includes(stderr, expectStderr), "stderr " + JSON.stringify(stderr) + " didn't contain " + JSON.stringify(expectStderr)); + assert.ok(includes(stderr, expectStderr), "stderr " + JSON.stringify(stderr) + + " didn't contain " + JSON.stringify(expectStderr)); } else { chai.expect(stderr).to.equal(expectStderr, "stderr didn't match"); } @@ -60,7 +61,8 @@ const assertTest = function (stdout, stderr, opts) { if (opts.stdout) { if (opts.stdoutContains) { - assert.ok(includes(stdout, expectStdout), "stdout " + JSON.stringify(stdout) + " didn't contain " + JSON.stringify(expectStdout)); + assert.ok(includes(stdout, expectStdout), "stdout " + JSON.stringify(stdout) + + " didn't contain " + JSON.stringify(expectStdout)); } else { chai.expect(stdout).to.equal(expectStdout, "stdout didn't match"); } diff --git a/packages/babel-code-frame/test/index.js b/packages/babel-code-frame/test/index.js index b6906100ee..f91727cb24 100644 --- a/packages/babel-code-frame/test/index.js +++ b/packages/babel-code-frame/test/index.js @@ -197,10 +197,12 @@ describe("babel-code-frame", function () { "", "" ].join("\n"); - assert.equal(codeFrame(rawLines, 3, null, { linesAbove: 1, linesBelow: 1, forceColor: true }), chalk.reset([ - " " + gutter(" 2 | "), - marker(">") + gutter(" 3 | "), - " " + gutter(" 4 | ") - ].join("\n"))); + assert.equal(codeFrame(rawLines, 3, null, { linesAbove: 1, linesBelow: 1, forceColor: true }), + chalk.reset([ + " " + gutter(" 2 | "), + marker(">") + gutter(" 3 | "), + " " + gutter(" 4 | ") + ].join("\n")) + ); }); }); diff --git a/packages/babel-core/src/tools/build-external-helpers.js b/packages/babel-core/src/tools/build-external-helpers.js index b97d25c2d1..8eb206f5ff 100644 --- a/packages/babel-core/src/tools/build-external-helpers.js +++ b/packages/babel-core/src/tools/build-external-helpers.js @@ -1,5 +1,3 @@ -/* eslint max-len: 0 */ - import * as helpers from "babel-helpers"; import generator from "babel-generator"; import * as messages from "babel-messages"; @@ -23,12 +21,14 @@ const buildUmdWrapper = template(` function buildGlobal(namespace, builder) { const body = []; const container = t.functionExpression(null, [t.identifier("global")], t.blockStatement(body)); - const tree = t.program([t.expressionStatement(t.callExpression(container, [helpers.get("selfGlobal")]))]); + const tree = t.program([ + t.expressionStatement(t.callExpression(container, [helpers.get("selfGlobal")]))]); body.push(t.variableDeclaration("var", [ t.variableDeclarator( namespace, - t.assignmentExpression("=", t.memberExpression(t.identifier("global"), namespace), t.objectExpression([])) + t.assignmentExpression("=", t.memberExpression(t.identifier("global"), namespace), + t.objectExpression([])) ) ])); diff --git a/packages/babel-core/src/transformation/file/index.js b/packages/babel-core/src/transformation/file/index.js index a013eb5d6a..50b641c194 100644 --- a/packages/babel-core/src/transformation/file/index.js +++ b/packages/babel-core/src/transformation/file/index.js @@ -1,5 +1,4 @@ /* global BabelFileResult, BabelParserOptions, BabelFileMetadata */ -/* eslint max-len: 0 */ import getHelper from "babel-helpers"; import * as metadataVisitor from "./metadata"; @@ -339,7 +338,7 @@ export default class File extends Store { this.scope.push({ id: uid, init: init, - _blockHoist: 1.9 // This ensures that we don't fail if not using function expression helpers + _blockHoist: 1.9 // This ensures that we don't fail if not using function expression helpers }); return uid; } @@ -378,8 +377,8 @@ export default class File extends Store { sourceRoot: inputMapConsumer.sourceRoot }); - // This assumes the output map always has a single source, since Babel always compiles a single source file to a - // single output file. + // This assumes the output map always has a single source, since Babel always compiles a + // single source file to a single output file. const source = outputMapConsumer.sources[0]; inputMapConsumer.eachMapping(function (mapping) { @@ -424,7 +423,8 @@ export default class File extends Store { if (parser) { parseCode = require(parser).parse; } else { - throw new Error(`Couldn't find parser ${parserOpts.parser} with "parse" method relative to directory ${dirname}`); + throw new Error(`Couldn't find parser ${parserOpts.parser} with "parse" method ` + + `relative to directory ${dirname}`); } } else { parseCode = parserOpts.parser; @@ -472,7 +472,8 @@ export default class File extends Store { this.log.debug("Start transform traverse"); // merge all plugin visitors into a single visitor - const visitor = traverse.visitors.merge(this.pluginVisitors[i], pluginPasses, this.opts.wrapPluginVisitorMethod); + const visitor = traverse.visitors.merge(this.pluginVisitors[i], pluginPasses, + this.opts.wrapPluginVisitorMethod); traverse(this.ast, visitor, this.scope); this.log.debug("End transform traverse"); @@ -610,14 +611,16 @@ export default class File extends Store { if (generator) { gen = require(generator).print; } else { - throw new Error(`Couldn't find generator ${gen} with "print" method relative to directory ${dirname}`); + throw new Error(`Couldn't find generator ${gen} with "print" method relative ` + + `to directory ${dirname}`); } } } this.log.debug("Generation start"); - const _result = gen(ast, opts.generatorOpts ? Object.assign(opts, opts.generatorOpts) : opts, this.code); + const _result = gen(ast, opts.generatorOpts ? Object.assign(opts, opts.generatorOpts) : opts, + this.code); result.code = _result.code; result.map = _result.map; diff --git a/packages/babel-core/src/transformation/file/options/config.js b/packages/babel-core/src/transformation/file/options/config.js index 7b11963f38..dbc60c6043 100644 --- a/packages/babel-core/src/transformation/file/options/config.js +++ b/packages/babel-core/src/transformation/file/options/config.js @@ -1,4 +1,4 @@ -/* eslint max-len: 0 */ +/* eslint max-len: "off" */ module.exports = { filename: { diff --git a/packages/babel-core/src/transformation/file/options/option-manager.js b/packages/babel-core/src/transformation/file/options/option-manager.js index c4736355a6..f4b25206bc 100644 --- a/packages/babel-core/src/transformation/file/options/option-manager.js +++ b/packages/babel-core/src/transformation/file/options/option-manager.js @@ -1,5 +1,3 @@ -/* eslint max-len: 0 */ - import * as context from "../../../api/node"; import type Logger from "../logger"; import Plugin from "../../plugin"; @@ -180,10 +178,13 @@ export default class OptionManager { // check for an unknown option if (!option && this.log) { if (removed[key]) { - this.log.error(`Using removed Babel 5 option: ${alias}.${key} - ${removed[key].message}`, ReferenceError); + this.log.error(`Using removed Babel 5 option: ${alias}.${key} - ${removed[key].message}`, + ReferenceError); } else { + /* eslint-disable max-len */ const unknownOptErr = `Unknown option: ${alias}.${key}. Check out http://babeljs.io/docs/usage/options/ for more information about options.`; const presetConfigErr = "A common cause of this error is the presence of a configuration options object without the corresponding preset name. Example:\n\nInvalid:\n `{ presets: [{option: value}] }`\nValid:\n `{ presets: [['presetName', {option: value}]] }`\n\nFor more detailed information on preset configuration, please see http://babeljs.io/docs/plugins/#pluginpresets-options."; + /* eslint-enable max-len */ this.log.error(`${unknownOptErr}\n\n${presetConfigErr}`, ReferenceError); } diff --git a/packages/babel-core/src/transformation/file/options/removed.js b/packages/babel-core/src/transformation/file/options/removed.js index 00a24ea61e..cb0077cb92 100644 --- a/packages/babel-core/src/transformation/file/options/removed.js +++ b/packages/babel-core/src/transformation/file/options/removed.js @@ -1,4 +1,4 @@ -/* eslint max-len: 0 */ +/* eslint max-len: "off" */ module.exports = { "auxiliaryComment": { diff --git a/packages/babel-core/src/transformation/plugin.js b/packages/babel-core/src/transformation/plugin.js index f3461ae9bf..d6c5406574 100644 --- a/packages/babel-core/src/transformation/plugin.js +++ b/packages/babel-core/src/transformation/plugin.js @@ -1,5 +1,3 @@ -/* eslint max-len: 0 */ - import OptionManager from "./file/options/option-manager"; import * as messages from "babel-messages"; import Store from "../store"; @@ -85,7 +83,8 @@ export default class Plugin extends Store { normaliseVisitor(visitor: Object): Object { for (const key of GLOBAL_VISITOR_PROPS) { if (visitor[key]) { - throw new Error("Plugins aren't allowed to specify catch-all enter/exit handlers. Please target individual nodes."); + throw new Error("Plugins aren't allowed to specify catch-all enter/exit handlers. " + + "Please target individual nodes."); } } diff --git a/packages/babel-core/test/api.js b/packages/babel-core/test/api.js index 6342792020..7236f385a0 100644 --- a/packages/babel-core/test/api.js +++ b/packages/babel-core/test/api.js @@ -265,6 +265,7 @@ describe("api", function () { it("source map merging", function () { const result = babel.transform([ + /* eslint-disable max-len */ "function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }", "", "let Foo = function Foo() {", @@ -272,6 +273,7 @@ describe("api", function () { "};", "", "//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0ZG91dCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztJQUFNLEdBQUcsWUFBSCxHQUFHO3dCQUFILEdBQUciLCJmaWxlIjoidW5kZWZpbmVkIiwic291cmNlc0NvbnRlbnQiOlsiY2xhc3MgRm9vIHt9XG4iXX0=" + /* eslint-enable max-len */ ].join("\n"), { sourceMap: true }); @@ -329,12 +331,14 @@ describe("api", function () { }; }] }).then(function (result) { - assert.equal(result.code, "/*before*/start;\n/*after*/class Foo {}\n/*before*/end;\n/*after*/"); + assert.equal(result.code, + "/*before*/start;\n/*after*/class Foo {}\n/*before*/end;\n/*after*/"); }); }); it("modules metadata", function () { return Promise.all([ + // eslint-disable-next-line max-len transformAsync("import { externalName as localName } from \"external\";").then(function (result) { assert.deepEqual(result.metadata.modules.imports[0], { source: "external", @@ -586,8 +590,10 @@ describe("api", function () { }); it("resolveModuleSource option", function () { + /* eslint-disable max-len */ const actual = "import foo from \"foo-import-default\";\nimport \"foo-import-bare\";\nexport { foo } from \"foo-export-named\";"; const expected = "import foo from \"resolved/foo-import-default\";\nimport \"resolved/foo-import-bare\";\nexport { foo } from \"resolved/foo-export-named\";"; + /* eslint-enable max-len */ return transformAsync(actual, { resolveModuleSource: function (originalSource) { diff --git a/packages/babel-core/test/option-manager.js b/packages/babel-core/test/option-manager.js index 2606a4bca0..2ca432dd20 100644 --- a/packages/babel-core/test/option-manager.js +++ b/packages/babel-core/test/option-manager.js @@ -35,6 +35,7 @@ describe("option-manager", () => { "blacklist": true }); }, + // eslint-disable-next-line max-len /Using removed Babel 5 option: base.auxiliaryComment - Use `auxiliaryCommentBefore` or `auxiliaryCommentAfter`/ ); }); @@ -59,6 +60,7 @@ describe("option-manager", () => { "presets": [{ option: "value" }] }); }, + // eslint-disable-next-line max-len /Unknown option: foreign.option\.(?:.|\n)+A common cause of this error is the presence of a configuration options object without the corresponding preset name/ ); }); diff --git a/packages/babel-generator/src/generators/expressions.js b/packages/babel-generator/src/generators/expressions.js index 0cf5f2093e..8ba9491071 100644 --- a/packages/babel-generator/src/generators/expressions.js +++ b/packages/babel-generator/src/generators/expressions.js @@ -1,5 +1,3 @@ -/* eslint max-len: 0 */ - import * as t from "babel-types"; import * as n from "../node"; diff --git a/packages/babel-generator/src/generators/flow.js b/packages/babel-generator/src/generators/flow.js index 668ba0e2b3..9f5c6f3623 100644 --- a/packages/babel-generator/src/generators/flow.js +++ b/packages/babel-generator/src/generators/flow.js @@ -1,5 +1,3 @@ -/* eslint max-len: 0 */ - export function AnyTypeAnnotation() { this.word("any"); } diff --git a/packages/babel-generator/src/generators/methods.js b/packages/babel-generator/src/generators/methods.js index 97bbcd3129..2ad6d41ffb 100644 --- a/packages/babel-generator/src/generators/methods.js +++ b/packages/babel-generator/src/generators/methods.js @@ -93,5 +93,6 @@ export function ArrowFunctionExpression(node: Object) { } function hasTypes(node, param) { - return node.typeParameters || node.returnType || param.typeAnnotation || param.optional || param.trailingComments; + return node.typeParameters || node.returnType || param.typeAnnotation || param.optional || + param.trailingComments; } diff --git a/packages/babel-generator/src/generators/types.js b/packages/babel-generator/src/generators/types.js index fa8498aff7..5fada08e79 100644 --- a/packages/babel-generator/src/generators/types.js +++ b/packages/babel-generator/src/generators/types.js @@ -1,6 +1,3 @@ -/* eslint max-len: 0 */ -/* eslint quotes: 0 */ - import * as t from "babel-types"; import jsesc from "jsesc"; @@ -62,7 +59,8 @@ export function ObjectProperty(node: Object) { this.token("]"); } else { // print `({ foo: foo = 5 } = {})` as `({ foo = 5 } = {});` - if (t.isAssignmentPattern(node.value) && t.isIdentifier(node.key) && node.key.name === node.value.left.name) { + if (t.isAssignmentPattern(node.value) && t.isIdentifier(node.key) && + node.key.name === node.value.left.name) { this.print(node.value, node); return; } diff --git a/packages/babel-generator/src/printer.js b/packages/babel-generator/src/printer.js index e03298d1f9..6d164fc2fe 100644 --- a/packages/babel-generator/src/printer.js +++ b/packages/babel-generator/src/printer.js @@ -1,5 +1,3 @@ -/* eslint max-len: 0 */ - import find from "lodash/find"; import findLast from "lodash/findLast"; import isInteger from "lodash/isInteger"; @@ -321,6 +319,7 @@ export default class Printer { const printMethod = this[node.type]; if (!printMethod) { + // eslint-disable-next-line max-len throw new ReferenceError(`unknown node of type ${JSON.stringify(node.type)} with constructor ${JSON.stringify(node && node.constructor.name)}`); } diff --git a/packages/babel-generator/test/index.js b/packages/babel-generator/test/index.js index 813bd57f59..2aad5ed984 100644 --- a/packages/babel-generator/test/index.js +++ b/packages/babel-generator/test/index.js @@ -312,7 +312,10 @@ suites.forEach(function (testSuite) { }); const result = generate(actualAst, task.options, actualCode); - if (!expect.code && result.code && fs.statSync(path.dirname(expect.loc)).isDirectory() && !process.env.CI) { + if ( + !expect.code && result.code && fs.statSync(path.dirname(expect.loc)).isDirectory() && + !process.env.CI + ) { console.log(`New test file created: ${expect.loc}`); fs.writeFileSync(expect.loc, result.code); } else { diff --git a/packages/babel-helper-builder-react-jsx/src/index.js b/packages/babel-helper-builder-react-jsx/src/index.js index 1a0a1ca626..86d66d2b4d 100644 --- a/packages/babel-helper-builder-react-jsx/src/index.js +++ b/packages/babel-helper-builder-react-jsx/src/index.js @@ -128,7 +128,8 @@ export default function (opts) { const useBuiltIns = file.opts.useBuiltIns || false; if (typeof useBuiltIns !== "boolean") { - throw new Error("transform-react-jsx currently only accepts a boolean option for useBuiltIns (defaults to false)"); + throw new Error("transform-react-jsx currently only accepts a boolean option for " + + "useBuiltIns (defaults to false)"); } function pushProps() { diff --git a/packages/babel-helper-define-map/src/index.js b/packages/babel-helper-define-map/src/index.js index 05fa5ee886..b0c45ab7e1 100644 --- a/packages/babel-helper-define-map/src/index.js +++ b/packages/babel-helper-define-map/src/index.js @@ -1,5 +1,3 @@ -/* eslint max-len: 0 */ - import nameFunction from "babel-helper-function-name"; import has from "lodash/has"; import * as t from "babel-types"; @@ -36,7 +34,8 @@ export function push(mutatorMap: Object, node: Object, kind: string, file, scope if (node.decorators) { const decorators = map.decorators = map.decorators || t.arrayExpression([]); - decorators.elements = decorators.elements.concat(node.decorators.map((dec) => dec.expression).reverse()); + decorators.elements = decorators.elements.concat( + node.decorators.map((dec) => dec.expression).reverse()); } if (map.value || map.initializer) { @@ -63,7 +62,8 @@ export function push(mutatorMap: Object, node: Object, kind: string, file, scope } // infer function name - if (scope && t.isStringLiteral(key) && (kind === "value" || kind === "initializer") && t.isFunctionExpression(value)) { + if (scope && t.isStringLiteral(key) && (kind === "value" || kind === "initializer") && + t.isFunctionExpression(value)) { value = nameFunction({ id: key, node: value, scope }); } diff --git a/packages/babel-helper-function-name/src/index.js b/packages/babel-helper-function-name/src/index.js index 7623bf0a10..1c38e531ab 100644 --- a/packages/babel-helper-function-name/src/index.js +++ b/packages/babel-helper-function-name/src/index.js @@ -1,5 +1,3 @@ -/* eslint max-len: 0 */ - import getFunctionArity from "babel-helper-get-function-arity"; import template from "babel-template"; import * as t from "babel-types"; @@ -131,7 +129,8 @@ export default function ({ node, parent, scope, id }) { // has an `id` so we don't need to infer one if (node.id) return; - if ((t.isObjectProperty(parent) || t.isObjectMethod(parent, { kind: "method" })) && (!parent.computed || t.isLiteral(parent.key))) { + if ((t.isObjectProperty(parent) || t.isObjectMethod(parent, { kind: "method" })) && + (!parent.computed || t.isLiteral(parent.key))) { // { foo() {} }; id = parent.key; } else if (t.isVariableDeclarator(parent)) { diff --git a/packages/babel-helper-optimise-call-expression/src/index.js b/packages/babel-helper-optimise-call-expression/src/index.js index d96f2e64c6..485f986321 100644 --- a/packages/babel-helper-optimise-call-expression/src/index.js +++ b/packages/babel-helper-optimise-call-expression/src/index.js @@ -1,9 +1,8 @@ -/* eslint max-len: 0 */ - import * as t from "babel-types"; export default function (callee, thisNode, args) { - if (args.length === 1 && t.isSpreadElement(args[0]) && t.isIdentifier(args[0].argument, { name: "arguments" })) { + if (args.length === 1 && t.isSpreadElement(args[0]) && + t.isIdentifier(args[0].argument, { name: "arguments" })) { // eg. super(...arguments); return t.callExpression( t.memberExpression(callee, t.identifier("apply")), diff --git a/packages/babel-helper-replace-supers/src/index.js b/packages/babel-helper-replace-supers/src/index.js index 8214753552..7fa593bb36 100644 --- a/packages/babel-helper-replace-supers/src/index.js +++ b/packages/babel-helper-replace-supers/src/index.js @@ -1,5 +1,3 @@ -/* eslint max-len: 0 */ - import type { NodePath, Scope } from "babel-traverse"; import optimiseCall from "babel-helper-optimise-call-expression"; import * as messages from "babel-messages"; @@ -144,7 +142,8 @@ export default class ReplaceSupers { * * @example * - * _set(CLASS.prototype.__proto__ || Object.getPrototypeOf(CLASS.prototype), "METHOD", "VALUE", this) + * _set(CLASS.prototype.__proto__ || Object.getPrototypeOf(CLASS.prototype), "METHOD", "VALUE", + * this) * */ @@ -227,9 +226,8 @@ export default class ReplaceSupers { t.variableDeclaration("var", [ t.variableDeclarator(ref, node.left) ]), - t.expressionStatement( - t.assignmentExpression("=", node.left, t.binaryExpression(node.operator[0], ref, node.right)) - ) + t.expressionStatement(t.assignmentExpression("=", node.left, + t.binaryExpression(node.operator[0], ref, node.right))) ]; } } @@ -251,22 +249,30 @@ export default class ReplaceSupers { if (t.isSuper(callee)) { return; } else if (isMemberExpressionSuper(callee)) { - // super.test(); -> _get(Object.getPrototypeOf(objectRef.prototype), "test", this).call(this); + // super.test(); + // to + // _get(Object.getPrototypeOf(objectRef.prototype), "test", this).call(this); property = callee.property; computed = callee.computed; args = node.arguments; } } else if (t.isMemberExpression(node) && t.isSuper(node.object)) { - // super.name; -> _get(Object.getPrototypeOf(objectRef.prototype), "name", this); + // super.name; + // to + // _get(Object.getPrototypeOf(objectRef.prototype), "name", this); property = node.property; computed = node.computed; } else if (t.isUpdateExpression(node) && isMemberExpressionSuper(node.argument)) { const binary = t.binaryExpression(node.operator[0], node.argument, t.numericLiteral(1)); if (node.prefix) { - // ++super.foo; -> super.foo += 1; + // ++super.foo; + // to + // super.foo += 1; return this.specHandleAssignmentExpression(null, path, binary); } else { - // super.foo++; -> let _ref = super.foo; super.foo = _ref + 1; + // super.foo++; + // to + // let _ref = super.foo; super.foo = _ref + 1; const ref = path.scope.generateUidIdentifier("ref"); return this.specHandleAssignmentExpression(ref, path, binary).concat(t.expressionStatement(ref)); } diff --git a/packages/babel-helper-transform-fixture-test-runner/src/index.js b/packages/babel-helper-transform-fixture-test-runner/src/index.js index 39a8aa8d33..fbca0c3949 100644 --- a/packages/babel-helper-transform-fixture-test-runner/src/index.js +++ b/packages/babel-helper-transform-fixture-test-runner/src/index.js @@ -24,7 +24,8 @@ function wrapPackagesArray(type, names, optionsDir) { if (val[0][0] === ".") { if (!optionsDir) { - throw new Error("Please provide an options.json in test dir when using a relative plugin path."); + throw new Error("Please provide an options.json in test dir when using a " + + "relative plugin path."); } val[0] = path.resolve(optionsDir, val[0]); @@ -53,7 +54,8 @@ function run(task) { newOpts.plugins = wrapPackagesArray("plugin", newOpts.plugins, optionsDir); newOpts.presets = wrapPackagesArray("preset", newOpts.presets, optionsDir).map(function (val) { if (val.length > 2) { - throw new Error(`Unexpected extra options ${JSON.stringify(val.slice(2))} passed to preset.`); + throw new Error("Unexpected extra options " + JSON.stringify(val.slice(2)) + + " passed to preset."); } return val; @@ -85,7 +87,10 @@ function run(task) { const expectCode = expect.code; if (!execCode || actualCode) { result = babel.transform(actualCode, getOpts(actual)); - if (!expect.code && result.code && !opts.throws && fs.statSync(path.dirname(expect.loc)).isDirectory() && !process.env.CI) { + if ( + !expect.code && result.code && !opts.throws && fs.statSync(path.dirname(expect.loc)).isDirectory() && + !process.env.CI + ) { console.log(`New test file created: ${expect.loc}`); fs.writeFileSync(expect.loc, result.code); } else { diff --git a/packages/babel-helpers/src/helpers.js b/packages/babel-helpers/src/helpers.js index cdd63768da..d7d20aedfd 100644 --- a/packages/babel-helpers/src/helpers.js +++ b/packages/babel-helpers/src/helpers.js @@ -1,4 +1,4 @@ -/* eslint max-len: 0 */ +/* eslint max-len: "off" */ import template from "babel-template"; diff --git a/packages/babel-helpers/src/index.js b/packages/babel-helpers/src/index.js index 207318cf27..c25dce9c14 100644 --- a/packages/babel-helpers/src/index.js +++ b/packages/babel-helpers/src/index.js @@ -1,5 +1,3 @@ -/* eslint no-confusing-arrow: 0 */ - import helpers from "./helpers"; export function get(name) { @@ -10,7 +8,7 @@ export function get(name) { } export const list = Object.keys(helpers) - .map((name) => name[0] === "_" ? name.slice(1) : name) + .map((name) => name.replace(/^_/, "")) .filter((name) => name !== "__esModule"); export default get; diff --git a/packages/babel-messages/src/index.js b/packages/babel-messages/src/index.js index 7064bd69b9..e6f94cab3a 100644 --- a/packages/babel-messages/src/index.js +++ b/packages/babel-messages/src/index.js @@ -1,4 +1,4 @@ -/* eslint max-len: 0 */ +/* eslint max-len: "off" */ import * as util from "util"; diff --git a/packages/babel-plugin-transform-class-properties/src/index.js b/packages/babel-plugin-transform-class-properties/src/index.js index 9c5e7d24a2..1873757ee9 100644 --- a/packages/babel-plugin-transform-class-properties/src/index.js +++ b/packages/babel-plugin-transform-class-properties/src/index.js @@ -1,4 +1,3 @@ -/* eslint max-len: 0 */ import nameFunction from "babel-helper-function-name"; import template from "babel-template"; @@ -44,7 +43,8 @@ export default function ({ types: t }) { visitor: { Class(path, state) { - const buildClassProperty = state.opts.spec ? buildClassPropertySpec : buildClassPropertyNonSpec; + const buildClassProperty = state.opts.spec ? buildClassPropertySpec : + buildClassPropertyNonSpec; const isDerived = !!path.node.superClass; let constructor; const props = []; @@ -92,7 +92,8 @@ export default function ({ types: t }) { if (instanceBody.length) { if (!constructor) { - const newConstructor = t.classMethod("constructor", t.identifier("constructor"), [], t.blockStatement([])); + const newConstructor = t.classMethod("constructor", t.identifier("constructor"), [], + t.blockStatement([])); if (isDerived) { newConstructor.params = [t.restElement(t.identifier("args"))]; newConstructor.body.body.push( @@ -129,7 +130,8 @@ export default function ({ types: t }) { instanceBody = [ t.expressionStatement( - t.callExpression(t.memberExpression(initialisePropsRef, t.identifier("call")), [t.thisExpression()]) + t.callExpression(t.memberExpression(initialisePropsRef, t.identifier("call")), [ + t.thisExpression()]) ) ]; } diff --git a/packages/babel-plugin-transform-es2015-block-scoping/src/index.js b/packages/babel-plugin-transform-es2015-block-scoping/src/index.js index 19a36f558c..8c698542c2 100644 --- a/packages/babel-plugin-transform-es2015-block-scoping/src/index.js +++ b/packages/babel-plugin-transform-es2015-block-scoping/src/index.js @@ -1,5 +1,3 @@ -/* eslint max-len: 0 */ - import type NodePath from "babel-traverse"; import type Scope from "babel-traverse"; import type File from "../../../file"; @@ -397,7 +395,8 @@ class BlockScoping { const isSwitch = this.blockPath.isSwitchStatement(); // build the closure that we're going to wrap the block with, possible wrapping switch(){} - const fn = t.functionExpression(null, params, t.blockStatement(isSwitch ? [block] : block.body)); + const fn = t.functionExpression(null, params, + t.blockStatement(isSwitch ? [block] : block.body)); fn.shadow = true; // continuation @@ -654,7 +653,8 @@ class BlockScoping { for (let i = 0; i < cases.length; i++) { const caseConsequent = cases[i].consequent[0]; if (t.isBreakStatement(caseConsequent) && !caseConsequent.label) { - caseConsequent.label = this.loopLabel = this.loopLabel || this.scope.generateUidIdentifier("loop"); + caseConsequent.label = this.loopLabel = this.loopLabel || + this.scope.generateUidIdentifier("loop"); } } } diff --git a/packages/babel-plugin-transform-es2015-classes/src/vanilla.js b/packages/babel-plugin-transform-es2015-classes/src/vanilla.js index b38a00fa02..a9a36d4680 100644 --- a/packages/babel-plugin-transform-es2015-classes/src/vanilla.js +++ b/packages/babel-plugin-transform-es2015-classes/src/vanilla.js @@ -1,5 +1,3 @@ -/* eslint max-len: 0 */ - import type { NodePath } from "babel-traverse"; import { visitors } from "babel-traverse"; import ReplaceSupers from "babel-helper-replace-supers"; @@ -28,7 +26,10 @@ const noMethodVisitor = { const verifyConstructorVisitor = visitors.merge([noMethodVisitor, { Super(path) { - if (this.isDerived && !this.hasBareSuper && !path.parentPath.isCallExpression({ callee: path.node })) { + if ( + this.isDerived && !this.hasBareSuper && + !path.parentPath.isCallExpression({ callee: path.node }) + ) { throw path.buildCodeFrameError("'super.*' is not allowed before super()"); } }, @@ -88,7 +89,8 @@ export default class ClassTransformer { this.classId = this.node.id; // this is the name of the binding that will **always** reference the class we've constructed - this.classRef = this.node.id ? t.identifier(this.node.id.name) : this.scope.generateUidIdentifier("class"); + this.classRef = this.node.id ? t.identifier(this.node.id.name) : + this.scope.generateUidIdentifier("class"); this.superName = this.node.superClass || t.identifier("Function"); this.isDerived = !!this.node.superClass; @@ -123,10 +125,12 @@ export default class ClassTransformer { this.buildBody(); // make sure this class isn't directly called - constructorBody.body.unshift(t.expressionStatement(t.callExpression(file.addHelper("classCallCheck"), [ - t.thisExpression(), - this.classRef - ]))); + constructorBody.body.unshift(t.expressionStatement(t.callExpression( + file.addHelper("classCallCheck"), [ + t.thisExpression(), + this.classRef + ] + ))); body = body.concat(this.staticPropBody.map((fn) => fn(this.classRef))); @@ -227,7 +231,8 @@ export default class ClassTransformer { } if (node.decorators) { - throw path.buildCodeFrameError("Method has decorators, put the decorator plugin before the classes one."); + throw path.buildCodeFrameError( + "Method has decorators, put the decorator plugin before the classes one."); } if (t.isClassMethod(node)) { @@ -294,8 +299,13 @@ export default class ClassTransformer { const nullNode = t.nullLiteral(); - // (Constructor, instanceDescriptors, staticDescriptors, instanceInitializers, staticInitializers) - let args = [this.classRef, nullNode, nullNode, nullNode, nullNode]; + let args = [ + this.classRef, // Constructor + nullNode, // instanceDescriptors + nullNode, // staticDescriptors + nullNode, // instanceInitializers + nullNode, // staticInitializers + ]; if (instanceProps) args[1] = instanceProps; if (staticProps) args[2] = staticProps; @@ -336,7 +346,11 @@ export default class ClassTransformer { if (this.isLoose) { bareSuperNode.arguments.unshift(t.thisExpression()); - if (bareSuperNode.arguments.length === 2 && t.isSpreadElement(bareSuperNode.arguments[1]) && t.isIdentifier(bareSuperNode.arguments[1].argument, { name: "arguments" })) { + if ( + bareSuperNode.arguments.length === 2 && + t.isSpreadElement(bareSuperNode.arguments[1]) && + t.isIdentifier(bareSuperNode.arguments[1].argument, { name: "arguments" }) + ) { // special case single arguments spread bareSuperNode.arguments[1] = bareSuperNode.arguments[1].argument; bareSuperNode.callee = t.memberExpression(superRef, t.identifier("apply")); @@ -365,7 +379,11 @@ export default class ClassTransformer { const bareSuperAfter = this.bareSuperAfter.map((fn) => fn(thisRef)); - if (bareSuper.parentPath.isExpressionStatement() && bareSuper.parentPath.container === body.node.body && body.node.body.length - 1 === bareSuper.parentPath.key) { + if ( + bareSuper.parentPath.isExpressionStatement() && + bareSuper.parentPath.container === body.node.body && + body.node.body.length - 1 === bareSuper.parentPath.key + ) { // this super call is the last statement in the body so we can just straight up // turn it into a return @@ -435,7 +453,8 @@ export default class ClassTransformer { // return const bodyPaths = body.get("body"); if (bodyPaths.length && !bodyPaths.pop().isReturnStatement()) { - body.pushContainer("body", t.returnStatement(guaranteedSuperBeforeFinish ? thisRef : wrapReturn())); + body.pushContainer("body", t.returnStatement( + guaranteedSuperBeforeFinish ? thisRef : wrapReturn())); } for (const returnPath of this.superReturns) { diff --git a/packages/babel-plugin-transform-es2015-destructuring/src/index.js b/packages/babel-plugin-transform-es2015-destructuring/src/index.js index 0bdfb8b695..2609076a80 100644 --- a/packages/babel-plugin-transform-es2015-destructuring/src/index.js +++ b/packages/babel-plugin-transform-es2015-destructuring/src/index.js @@ -1,5 +1,3 @@ -/* eslint max-len: 0 */ - export default function ({ types: t }) { /** @@ -153,7 +151,8 @@ export default function ({ types: t }) { // - const value = t.callExpression(this.file.addHelper("objectWithoutProperties"), [objRef, keys]); + const value = t.callExpression( + this.file.addHelper("objectWithoutProperties"), [objRef, keys]); this.nodes.push(this.buildVariableAssignment(spreadProp.argument, value)); } @@ -294,7 +293,8 @@ export default function ({ types: t }) { if (t.isRestElement(elem)) { elemRef = this.toArray(arrayRef); - elemRef = t.callExpression(t.memberExpression(elemRef, t.identifier("slice")), [t.numericLiteral(i)]); + elemRef = t.callExpression(t.memberExpression(elemRef, t.identifier("slice")), + [t.numericLiteral(i)]); // set the element to the rest element argument since we've dealt with it // being a rest already @@ -485,14 +485,18 @@ export default function ({ types: t }) { t.inherits(nodes[nodes.length - 1], declar); } } else { - nodes.push(t.inherits(destructuring.buildVariableAssignment(declar.id, declar.init), declar)); + nodes.push(t.inherits( + destructuring.buildVariableAssignment(declar.id, declar.init), declar)); } } const nodesOut = []; for (const node of nodes) { const tail = nodesOut[nodesOut.length - 1]; - if (tail && t.isVariableDeclaration(tail) && t.isVariableDeclaration(node) && tail.kind === node.kind) { + if ( + tail && t.isVariableDeclaration(tail) && t.isVariableDeclaration(node) && + tail.kind === node.kind + ) { // Create a single compound let/var rather than many. tail.declarations.push(...node.declarations); } else { diff --git a/packages/babel-plugin-transform-es2015-for-of/src/index.js b/packages/babel-plugin-transform-es2015-for-of/src/index.js index 760e0e69b0..958eae6bce 100644 --- a/packages/babel-plugin-transform-es2015-for-of/src/index.js +++ b/packages/babel-plugin-transform-es2015-for-of/src/index.js @@ -1,5 +1,3 @@ -/* eslint max-len: 0 */ - export default function ({ messages, template, types: t }) { const buildForOfArray = template(` for (var KEY = 0; KEY < ARR.length; KEY++) BODY; @@ -22,6 +20,7 @@ export default function ({ messages, template, types: t }) { } `); + /* eslint-disable max-len */ const buildForOf = template(` var ITERATOR_COMPLETION = true; var ITERATOR_HAD_ERROR_KEY = false; @@ -44,6 +43,7 @@ export default function ({ messages, template, types: t }) { } } `); + /* eslint-enable max-len */ function _ForOfStatementArray(path) { const { node, scope } = path; @@ -76,7 +76,8 @@ export default function ({ messages, template, types: t }) { left.declarations[0].init = iterationValue; loop.body.body.unshift(left); } else { - loop.body.body.unshift(t.expressionStatement(t.assignmentExpression("=", left, iterationValue))); + loop.body.body.unshift(t.expressionStatement( + t.assignmentExpression("=", left, iterationValue))); } if (path.parentPath.isLabeledStatement()) { 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 9c0ef6b69b..74af212c55 100644 --- a/packages/babel-plugin-transform-es2015-modules-commonjs/src/index.js +++ b/packages/babel-plugin-transform-es2015-modules-commonjs/src/index.js @@ -1,5 +1,3 @@ -/* eslint max-len: 0 */ - import { basename, extname } from "path"; import template from "babel-template"; import * as t from "babel-types"; @@ -43,7 +41,8 @@ const buildExportAll = template(` }); `); -const THIS_BREAK_KEYS = ["FunctionExpression", "FunctionDeclaration", "ClassProperty", "ClassMethod", "ObjectMethod"]; +const THIS_BREAK_KEYS = ["FunctionExpression", "FunctionDeclaration", "ClassProperty", + "ClassMethod", "ObjectMethod"]; export default function () { const REASSIGN_REMAP_SKIP = Symbol(); @@ -61,7 +60,8 @@ export default function () { path.replaceWith(t.sequenceExpression([t.numericLiteral(0), remap])); } else if (path.isJSXIdentifier() && t.isMemberExpression(remap)) { const { object, property } = remap; - path.replaceWith(t.JSXMemberExpression(t.JSXIdentifier(object.name), t.JSXIdentifier(property.name))); + path.replaceWith(t.JSXMemberExpression(t.JSXIdentifier(object.name), + t.JSXIdentifier(property.name))); } else { path.replaceWith(remap); } @@ -327,9 +327,15 @@ export default function () { // todo } else if (specifier.isExportSpecifier()) { if (specifier.node.local.name === "default") { - topNodes.push(buildExportsFrom(t.stringLiteral(specifier.node.exported.name), t.memberExpression(t.callExpression(this.addHelper("interopRequireDefault"), [ref]), specifier.node.local))); + topNodes.push(buildExportsFrom(t.stringLiteral(specifier.node.exported.name), + t.memberExpression( + t.callExpression(this.addHelper("interopRequireDefault"), [ref]), + specifier.node.local + ) + )); } else { - topNodes.push(buildExportsFrom(t.stringLiteral(specifier.node.exported.name), t.memberExpression(ref, specifier.node.local))); + topNodes.push(buildExportsFrom(t.stringLiteral(specifier.node.exported.name), + t.memberExpression(ref, specifier.node.local))); } nonHoistedExportNames[specifier.node.exported.name] = true; } @@ -414,7 +420,8 @@ export default function () { topNodes.push(varDecl); } } - remaps[specifier.local.name] = t.memberExpression(target, t.cloneWithoutLoc(specifier.imported)); + remaps[specifier.local.name] = t.memberExpression(target, + t.cloneWithoutLoc(specifier.imported)); } } } else { @@ -431,13 +438,20 @@ export default function () { const maxHoistedExportsNodeAssignmentLength = 100; const nonHoistedExportNamesArr = Object.keys(nonHoistedExportNames); - for (let currentExportsNodeAssignmentLength = 0; currentExportsNodeAssignmentLength < nonHoistedExportNamesArr.length; currentExportsNodeAssignmentLength += maxHoistedExportsNodeAssignmentLength ) { - const nonHoistedExportNamesChunk = nonHoistedExportNamesArr.slice(currentExportsNodeAssignmentLength, currentExportsNodeAssignmentLength + maxHoistedExportsNodeAssignmentLength); + for ( + let currentExportsNodeAssignmentLength = 0; + currentExportsNodeAssignmentLength < nonHoistedExportNamesArr.length; + currentExportsNodeAssignmentLength += maxHoistedExportsNodeAssignmentLength + ) { + const nonHoistedExportNamesChunk = nonHoistedExportNamesArr.slice( + currentExportsNodeAssignmentLength, + currentExportsNodeAssignmentLength + maxHoistedExportsNodeAssignmentLength); let hoistedExportsNode = t.identifier("undefined"); nonHoistedExportNamesChunk.forEach(function (name) { - hoistedExportsNode = buildExportsAssignment(t.identifier(name), hoistedExportsNode).expression; + hoistedExportsNode = buildExportsAssignment(t.identifier(name), hoistedExportsNode) + .expression; }); const node = t.expressionStatement(hoistedExportsNode); diff --git a/packages/babel-plugin-transform-es2015-modules-systemjs/src/index.js b/packages/babel-plugin-transform-es2015-modules-systemjs/src/index.js index c79baab12b..c995a972b3 100644 --- a/packages/babel-plugin-transform-es2015-modules-systemjs/src/index.js +++ b/packages/babel-plugin-transform-es2015-modules-systemjs/src/index.js @@ -1,5 +1,3 @@ -/* eslint max-len: 0 */ - import hoistVariables from "babel-helper-hoist-variables"; import template from "babel-template"; @@ -76,7 +74,8 @@ export default function ({ types: t }) { CallExpression(path, state) { if (path.node.callee.type === TYPE_IMPORT) { const contextIdent = state.contextIdent; - path.replaceWith(t.callExpression(t.memberExpression(contextIdent, t.identifier("import")), path.node.arguments)); + path.replaceWith(t.callExpression(t.memberExpression(contextIdent, t.identifier("import")), + path.node.arguments)); } }, @@ -236,7 +235,8 @@ export default function ({ types: t }) { } if (t.isImportSpecifier(specifier)) { - setterBody.push(t.expressionStatement(t.assignmentExpression("=", specifier.local, t.memberExpression(target, specifier.imported)))); + setterBody.push(t.expressionStatement(t.assignmentExpression("=", specifier.local, + t.memberExpression(target, specifier.imported)))); } } @@ -256,7 +256,8 @@ export default function ({ types: t }) { })); } else if (t.isExportSpecifier(node)) { setterBody.push(t.expressionStatement( - t.assignmentExpression("=", t.memberExpression(exportObjRef, node.exported), t.memberExpression(target, node.local)) + t.assignmentExpression("=", t.memberExpression(exportObjRef, node.exported), + t.memberExpression(target, node.local)) )); } else { // todo @@ -279,7 +280,8 @@ export default function ({ types: t }) { } if (variableIds.length) { - beforeBody.unshift(t.variableDeclaration("var", variableIds.map((id) => t.variableDeclarator(id)))); + beforeBody.unshift(t.variableDeclaration("var", + variableIds.map((id) => t.variableDeclarator(id)))); } path.traverse(reassignmentVisitor, { @@ -294,7 +296,8 @@ export default function ({ types: t }) { path.node.body = [ buildTemplate({ - SYSTEM_REGISTER: t.memberExpression(t.identifier(state.opts.systemGlobal || "System"), t.identifier("register")), + SYSTEM_REGISTER: t.memberExpression( + t.identifier(state.opts.systemGlobal || "System"), t.identifier("register")), BEFORE_BODY: beforeBody, MODULE_NAME: moduleName, SETTERS: setters, diff --git a/packages/babel-plugin-transform-es2015-modules-umd/src/index.js b/packages/babel-plugin-transform-es2015-modules-umd/src/index.js index b13ab6af37..46405fc0f3 100644 --- a/packages/babel-plugin-transform-es2015-modules-umd/src/index.js +++ b/packages/babel-plugin-transform-es2015-modules-umd/src/index.js @@ -1,5 +1,3 @@ -/* eslint max-len: 0 */ - import { basename, extname } from "path"; import template from "babel-template"; diff --git a/packages/babel-plugin-transform-es2015-parameters/src/default.js b/packages/babel-plugin-transform-es2015-parameters/src/default.js index f123ed195e..8213efff57 100644 --- a/packages/babel-plugin-transform-es2015-parameters/src/default.js +++ b/packages/babel-plugin-transform-es2015-parameters/src/default.js @@ -1,5 +1,3 @@ -/* eslint max-len: 0 */ - import getFunctionArity from "babel-helper-get-function-arity"; import callDelegate from "babel-helper-call-delegate"; import template from "babel-template"; diff --git a/packages/babel-plugin-transform-es2015-parameters/src/rest.js b/packages/babel-plugin-transform-es2015-parameters/src/rest.js index d0ff2846cb..1297b13f15 100644 --- a/packages/babel-plugin-transform-es2015-parameters/src/rest.js +++ b/packages/babel-plugin-transform-es2015-parameters/src/rest.js @@ -1,5 +1,3 @@ -/* eslint indent: 0 */ - import template from "babel-template"; import * as t from "babel-types"; diff --git a/packages/babel-plugin-transform-es2015-typeof-symbol/src/index.js b/packages/babel-plugin-transform-es2015-typeof-symbol/src/index.js index 4cea5acd1a..754b496f0e 100644 --- a/packages/babel-plugin-transform-es2015-typeof-symbol/src/index.js +++ b/packages/babel-plugin-transform-es2015-typeof-symbol/src/index.js @@ -1,5 +1,3 @@ -/* eslint max-len: 0 */ - export default function ({ types: t }) { const IGNORE = Symbol(); @@ -18,10 +16,17 @@ export default function ({ types: t }) { if (node[IGNORE]) return; if (path.find((path) => path.node && !!path.node._generated)) return; - if (path.parentPath.isBinaryExpression() && t.EQUALITY_BINARY_OPERATORS.indexOf(parent.operator) >= 0) { - // optimise `typeof foo === "string"` since we can determine that they'll never need to handle symbols + if ( + path.parentPath.isBinaryExpression() && + t.EQUALITY_BINARY_OPERATORS.indexOf(parent.operator) >= 0 + ) { + // optimise `typeof foo === "string"` since we can determine that they'll never + // need to handle symbols const opposite = path.getOpposite(); - if (opposite.isLiteral() && opposite.node.value !== "symbol" && opposite.node.value !== "object") { + if ( + opposite.isLiteral() && opposite.node.value !== "symbol" && + opposite.node.value !== "object" + ) { return; } } diff --git a/packages/babel-plugin-transform-object-rest-spread/src/index.js b/packages/babel-plugin-transform-object-rest-spread/src/index.js index 8de5e5eea2..91f7a0c40a 100644 --- a/packages/babel-plugin-transform-object-rest-spread/src/index.js +++ b/packages/babel-plugin-transform-object-rest-spread/src/index.js @@ -94,11 +94,14 @@ export default function ({ types: t }) { // to avoid calling foo() twice, as a first step convert it to: // const _foo = foo(), // { a, ...b } = _foo; - const initRef = path.scope.generateUidIdentifierBasedOnNode(this.originalPath.node.init, "ref"); + const initRef = path.scope.generateUidIdentifierBasedOnNode( + this.originalPath.node.init, "ref"); // insert _foo = foo() - this.originalPath.insertBefore(t.variableDeclarator(initRef, this.originalPath.node.init)); + this.originalPath.insertBefore(t.variableDeclarator(initRef, + this.originalPath.node.init)); // replace foo() with _foo - this.originalPath.replaceWith(t.variableDeclarator(this.originalPath.node.id, initRef)); + this.originalPath.replaceWith(t.variableDeclarator( + this.originalPath.node.id, initRef)); return; } @@ -247,7 +250,8 @@ export default function ({ types: t }) { const useBuiltIns = file.opts.useBuiltIns || false; if (typeof useBuiltIns !== "boolean") { - throw new Error("transform-object-rest-spread currently only accepts a boolean option for useBuiltIns (defaults to false)"); + throw new Error("transform-object-rest-spread currently only accepts a boolean " + + "option for useBuiltIns (defaults to false)"); } const args = []; diff --git a/packages/babel-plugin-transform-proto-to-assign/src/index.js b/packages/babel-plugin-transform-proto-to-assign/src/index.js index 41b0ff442d..c139e20de4 100644 --- a/packages/babel-plugin-transform-proto-to-assign/src/index.js +++ b/packages/babel-plugin-transform-proto-to-assign/src/index.js @@ -1,5 +1,3 @@ -/* eslint max-len: 0 */ - import pull from "lodash/pull"; export default function ({ types: t }) { @@ -9,7 +7,8 @@ export default function ({ types: t }) { function isProtoAssignmentExpression(node) { const left = node.left; - return t.isMemberExpression(left) && t.isLiteral(t.toComputedKey(left, left.property), { value: "__proto__" }); + return t.isMemberExpression(left) && + t.isLiteral(t.toComputedKey(left, left.property), { value: "__proto__" }); } function buildDefaultsCallExpression(expr, ref, file) { diff --git a/packages/babel-plugin-transform-react-jsx/src/index.js b/packages/babel-plugin-transform-react-jsx/src/index.js index 65758283c0..bb57b52d7f 100644 --- a/packages/babel-plugin-transform-react-jsx/src/index.js +++ b/packages/babel-plugin-transform-react-jsx/src/index.js @@ -1,5 +1,3 @@ -/* eslint max-len: 0 */ - import jsx from "babel-plugin-syntax-jsx"; import helper from "babel-helper-builder-react-jsx"; @@ -31,7 +29,8 @@ export default function ({ types: t }) { if (matches) { id = matches[1]; if (id === "React.DOM") { - throw file.buildCodeFrameError(comment, "The @jsx React.DOM pragma has been deprecated as of React 0.12"); + throw file.buildCodeFrameError(comment, + "The @jsx React.DOM pragma has been deprecated as of React 0.12"); } else { break; } diff --git a/packages/babel-polyfill/src/index.js b/packages/babel-polyfill/src/index.js index 2dfde7b6d7..61434e6fb5 100644 --- a/packages/babel-polyfill/src/index.js +++ b/packages/babel-polyfill/src/index.js @@ -1,5 +1,3 @@ -/* eslint max-len: 0 */ - if (global._babelPolyfill) { throw new Error("only one instance of babel-polyfill is allowed"); } @@ -24,6 +22,7 @@ function define(O, key, value) { define(String.prototype, "padLeft", "".padStart); define(String.prototype, "padRight", "".padEnd); +// eslint-disable-next-line max-len "pop,reverse,shift,keys,values,entries,indexOf,every,some,forEach,map,filter,find,findIndex,includes,join,slice,concat,push,splice,unshift,sort,lastIndexOf,reduce,reduceRight,copyWithin,fill".split(",").forEach(function(key) { [][key] && define(Array, key, Function.call.bind([][key])); }); diff --git a/packages/babel-template/src/index.js b/packages/babel-template/src/index.js index 164652c143..0384dfec16 100644 --- a/packages/babel-template/src/index.js +++ b/packages/babel-template/src/index.js @@ -1,5 +1,3 @@ -/* eslint max-len: 0 */ - import cloneDeep from "lodash/cloneDeep"; import assign from "lodash/assign"; import has from "lodash/has"; @@ -15,7 +13,8 @@ export default function (code: string, opts?: Object): Function { // original stack to append if it errors when parsing let stack; try { - // error stack gets populated in IE only on throw (https://msdn.microsoft.com/en-us/library/hh699850(v=vs.94).aspx) + // error stack gets populated in IE only on throw + // (https://msdn.microsoft.com/en-us/library/hh699850(v=vs.94).aspx) throw new Error(); } catch (error) { if (error.stack) { diff --git a/packages/babel-traverse/src/index.js b/packages/babel-traverse/src/index.js index 464a5a150f..1c5c96b58c 100644 --- a/packages/babel-traverse/src/index.js +++ b/packages/babel-traverse/src/index.js @@ -1,5 +1,3 @@ -/* eslint max-len: 0 */ - import TraversalContext from "./context"; import * as visitors from "./visitors"; import * as messages from "babel-messages"; @@ -45,7 +43,14 @@ traverse.cheap = function (node, enter) { return t.traverseFast(node, enter); }; -traverse.node = function (node: Object, opts: Object, scope: Object, state: Object, parentPath: Object, skipKeys?) { +traverse.node = function ( + node: Object, + opts: Object, + scope: Object, + state: Object, + parentPath: Object, + skipKeys? +) { const keys: Array = t.VISITOR_KEYS[node.type]; if (!keys) return; @@ -74,7 +79,12 @@ function hasBlacklistedType(path, state) { } } -traverse.hasType = function (tree: Object, scope: Object, type: Object, blacklistTypes: Array): boolean { +traverse.hasType = function ( + tree: Object, + scope: Object, + type: Object, + blacklistTypes: Array +): boolean { // the node we're searching in is blacklisted if (includes(blacklistTypes, tree.type)) return false; diff --git a/packages/babel-traverse/src/path/evaluation.js b/packages/babel-traverse/src/path/evaluation.js index 82c15a743e..57699b561f 100644 --- a/packages/babel-traverse/src/path/evaluation.js +++ b/packages/babel-traverse/src/path/evaluation.js @@ -1,12 +1,7 @@ -/* eslint indent: 0 */ -/* eslint max-len: 0 */ - import type NodePath from "./index"; // This file contains Babels metainterpreter that can evaluate static code. -/* eslint eqeqeq: 0 */ - const VALID_CALLEES = ["String", "Number", "Math"]; const INVALID_METHODS = ["random"]; @@ -316,7 +311,7 @@ export function evaluate(): { confident: boolean; value: any } { case ">": return left > right; case "<=": return left <= right; case ">=": return left >= right; - case "==": return left == right; + case "==": return left == right; // eslint-disable-line eqeqeq case "!=": return left != right; case "===": return left === right; case "!==": return left !== right; @@ -335,7 +330,10 @@ export function evaluate(): { confident: boolean; value: any } { let func; // Number(1); - if (callee.isIdentifier() && !path.scope.getBinding(callee.node.name, true) && VALID_CALLEES.indexOf(callee.node.name) >= 0) { + if ( + callee.isIdentifier() && !path.scope.getBinding(callee.node.name, true) && + VALID_CALLEES.indexOf(callee.node.name) >= 0 + ) { func = global[node.callee.name]; } @@ -344,7 +342,11 @@ export function evaluate(): { confident: boolean; value: any } { const property = callee.get("property"); // Math.min(1, 2) - if (object.isIdentifier() && property.isIdentifier() && VALID_CALLEES.indexOf(object.node.name) >= 0 && INVALID_METHODS.indexOf(property.node.name) < 0) { + if ( + object.isIdentifier() && property.isIdentifier() && + VALID_CALLEES.indexOf(object.node.name) >= 0 && + INVALID_METHODS.indexOf(property.node.name) < 0 + ) { context = global[object.node.name]; func = context[property.node.name]; } diff --git a/packages/babel-traverse/src/path/index.js b/packages/babel-traverse/src/path/index.js index 853a735bb8..c66d0e8482 100644 --- a/packages/babel-traverse/src/path/index.js +++ b/packages/babel-traverse/src/path/index.js @@ -1,5 +1,3 @@ -/* eslint max-len: 0 */ - import type Hub from "../hub"; import type TraversalContext from "../context"; import * as virtualTypes from "./lib/virtual-types"; diff --git a/packages/babel-traverse/src/path/lib/hoister.js b/packages/babel-traverse/src/path/lib/hoister.js index 243e9c18ac..93b9323bd3 100644 --- a/packages/babel-traverse/src/path/lib/hoister.js +++ b/packages/babel-traverse/src/path/lib/hoister.js @@ -153,7 +153,8 @@ export default class PathHoister { const attachTo = this.getAttachmentPath(); if (!attachTo) return; - // don't bother hoisting to the same function as this will cause multiple branches to be evaluated more than once leading to a bad optimisation + // don't bother hoisting to the same function as this will cause multiple branches to be + // evaluated more than once leading to a bad optimisation if (attachTo.getFunctionParent() === this.path.getFunctionParent()) return; // generate declaration and insert it to our point diff --git a/packages/babel-traverse/src/path/lib/removal-hooks.js b/packages/babel-traverse/src/path/lib/removal-hooks.js index 0678d1da28..73341ae651 100644 --- a/packages/babel-traverse/src/path/lib/removal-hooks.js +++ b/packages/babel-traverse/src/path/lib/removal-hooks.js @@ -6,28 +6,29 @@ export const hooks = [ function (self, parent) { - let removeParent = false; + const removeParent = + // while (NODE); + // removing the test of a while/switch, we can either just remove it entirely *or* turn the + // `test` into `true` unlikely that the latter will ever be what's wanted so we just remove + // the loop to avoid infinite recursion + (self.key === "test" && (parent.isWhile() || parent.isSwitchCase())) || - // while (NODE); - // removing the test of a while/switch, we can either just remove it entirely *or* turn the `test` into `true` - // unlikely that the latter will ever be what's wanted so we just remove the loop to avoid infinite recursion - removeParent = removeParent || (self.key === "test" && (parent.isWhile() || parent.isSwitchCase())); + // export NODE; + // just remove a declaration for an export as this is no longer valid + (self.key === "declaration" && parent.isExportDeclaration()) || - // export NODE; - // just remove a declaration for an export as this is no longer valid - removeParent = removeParent || (self.key === "declaration" && parent.isExportDeclaration()); + // label: NODE + // stray labeled statement with no body + (self.key === "body" && parent.isLabeledStatement()) || - // label: NODE - // stray labeled statement with no body - removeParent = removeParent || (self.key === "body" && parent.isLabeledStatement()); + // let NODE; + // remove an entire declaration if there are no declarators left + (self.listKey === "declarations" && parent.isVariableDeclaration() && + parent.node.declarations.length === 1) || - // let NODE; - // remove an entire declaration if there are no declarators left - removeParent = removeParent || (self.listKey === "declarations" && parent.isVariableDeclaration() && parent.node.declarations.length === 1); - - // NODE; - // remove the entire expression statement if there's no expression - removeParent = removeParent || (self.key === "expression" && parent.isExpressionStatement()); + // NODE; + // remove the entire expression statement if there's no expression + (self.key === "expression" && parent.isExpressionStatement()); if (removeParent) { parent.remove(); diff --git a/packages/babel-traverse/src/path/modification.js b/packages/babel-traverse/src/path/modification.js index 704014c16e..9df7ecc873 100644 --- a/packages/babel-traverse/src/path/modification.js +++ b/packages/babel-traverse/src/path/modification.js @@ -1,4 +1,3 @@ -/* eslint max-len: 0 */ // This file contains methods that modify the path/node in some ways. import { path as pathCache } from "../cache"; @@ -17,7 +16,10 @@ export function insertBefore(nodes) { if (this.parentPath.isExpressionStatement() || this.parentPath.isLabeledStatement()) { return this.parentPath.insertBefore(nodes); - } else if (this.isNodeType("Expression") || (this.parentPath.isForStatement() && this.key === "init")) { + } else if ( + this.isNodeType("Expression") || + (this.parentPath.isForStatement() && this.key === "init") + ) { if (this.node) nodes.push(this.node); this.replaceExpressionWithStatements(nodes); } else { @@ -28,7 +30,8 @@ export function insertBefore(nodes) { if (this.node) nodes.push(this.node); this._replaceWith(t.blockStatement(nodes)); } else { - throw new Error("We don't know what to do with this node type. We were previously a Statement but we can't fit in here?"); + throw new Error("We don't know what to do with this node type. " + + "We were previously a Statement but we can't fit in here?"); } } @@ -88,7 +91,8 @@ export function _containerInsertAfter(nodes) { export function _maybePopFromStatements(nodes) { const last = nodes[nodes.length - 1]; - const isIdentifier = t.isIdentifier(last) || (t.isExpressionStatement(last) && t.isIdentifier(last.expression)); + const isIdentifier = t.isIdentifier(last) || + (t.isExpressionStatement(last) && t.isIdentifier(last.expression)); if (isIdentifier && !this.isCompletionRecord()) { nodes.pop(); @@ -107,7 +111,10 @@ export function insertAfter(nodes) { if (this.parentPath.isExpressionStatement() || this.parentPath.isLabeledStatement()) { return this.parentPath.insertAfter(nodes); - } else if (this.isNodeType("Expression") || (this.parentPath.isForStatement() && this.key === "init")) { + } else if ( + this.isNodeType("Expression") || + (this.parentPath.isForStatement() && this.key === "init") + ) { if (this.node) { const temp = this.scope.generateDeclaredUidIdentifier(); nodes.unshift(t.expressionStatement(t.assignmentExpression("=", temp, this.node))); @@ -122,7 +129,8 @@ export function insertAfter(nodes) { if (this.node) nodes.unshift(this.node); this._replaceWith(t.blockStatement(nodes)); } else { - throw new Error("We don't know what to do with this node type. We were previously a Statement but we can't fit in here?"); + throw new Error("We don't know what to do with this node type. " + + "We were previously a Statement but we can't fit in here?"); } } diff --git a/packages/babel-traverse/src/path/replacement.js b/packages/babel-traverse/src/path/replacement.js index 08df6ce16c..1a8cdbef54 100644 --- a/packages/babel-traverse/src/path/replacement.js +++ b/packages/babel-traverse/src/path/replacement.js @@ -1,4 +1,3 @@ -/* eslint max-len: 0 */ // This file contains methods responsible for replacing a node with another. import codeFrame from "babel-code-frame"; @@ -114,22 +113,30 @@ export function replaceWith(replacement) { } if (Array.isArray(replacement)) { - throw new Error("Don't use `path.replaceWith()` with an array of nodes, use `path.replaceWithMultiple()`"); + throw new Error( + "Don't use `path.replaceWith()` with an array of nodes, use `path.replaceWithMultiple()`"); } if (typeof replacement === "string") { - throw new Error("Don't use `path.replaceWith()` with a source string, use `path.replaceWithSourceString()`"); + throw new Error( + "Don't use `path.replaceWith()` with a source string, use `path.replaceWithSourceString()`"); } if (this.isNodeType("Statement") && t.isExpression(replacement)) { - if (!this.canHaveVariableDeclarationOrExpression() && !this.canSwapBetweenExpressionAndStatement(replacement)) { + if ( + !this.canHaveVariableDeclarationOrExpression() && + !this.canSwapBetweenExpressionAndStatement(replacement) + ) { // replacing a statement with an expression so wrap it in an expression statement replacement = t.expressionStatement(replacement); } } if (this.isNodeType("Expression") && t.isStatement(replacement)) { - if (!this.canHaveVariableDeclarationOrExpression() && !this.canSwapBetweenExpressionAndStatement(replacement)) { + if ( + !this.canHaveVariableDeclarationOrExpression() && + !this.canSwapBetweenExpressionAndStatement(replacement) + ) { // replacing an expression with a statement so let's explode it return this.replaceExpressionWithStatements([replacement]); } diff --git a/packages/babel-traverse/src/scope/index.js b/packages/babel-traverse/src/scope/index.js index b7b3388b8d..25d17f97f0 100644 --- a/packages/babel-traverse/src/scope/index.js +++ b/packages/babel-traverse/src/scope/index.js @@ -1,5 +1,3 @@ -/* eslint max-len: 0 */ - import includes from "lodash/includes"; import repeat from "lodash/repeat"; import Renamer from "./lib/renamer"; @@ -341,13 +339,11 @@ export default class Scope { // ignore hoisted functions if there's also a local let if (kind === "hoisted" && local.kind === "let") return; - let duplicate = false; - - // don't allow duplicate bindings to exist alongside - if (!duplicate) duplicate = kind === "let" || local.kind === "let" || local.kind === "const" || local.kind === "module"; - - // don't allow a local of param with a kind of let - if (!duplicate) duplicate = local.kind === "param" && (kind === "let" || kind === "const"); + const duplicate = + // don't allow duplicate bindings to exist alongside + kind === "let" || local.kind === "let" || local.kind === "const" || local.kind === "module" || + // don't allow a local of param with a kind of let + local.kind === "param" && (kind === "let" || kind === "const"); if (duplicate) { throw this.hub.file.buildCodeFrameError(id, messages.get("scopeDuplicateDeclaration", name), TypeError); diff --git a/packages/babel-traverse/test/evaluation.js b/packages/babel-traverse/test/evaluation.js index 3c53fbf615..5a3d93f765 100644 --- a/packages/babel-traverse/test/evaluation.js +++ b/packages/babel-traverse/test/evaluation.js @@ -33,7 +33,8 @@ describe("evaluation", function () { it("should bail out on recursive evaluation", function () { assert.strictEqual( - getPath("function fn(a) { var g = a ? 1 : 2, a = g * this.foo; }").get("body.0.body.body.0.declarations.1.init").evaluate().confident, + getPath("function fn(a) { var g = a ? 1 : 2, a = g * this.foo; }") + .get("body.0.body.body.0.declarations.1.init").evaluate().confident, false ); }); @@ -54,7 +55,8 @@ describe("evaluation", function () { it("should deopt when var is redeclared in the same scope", function () { assert.strictEqual( - getPath("var x = 2; var y = x + 2; { var x = 3 }").get("body.1.declarations.0.init").evaluate().confident, + getPath("var x = 2; var y = x + 2; { var x = 3 }") + .get("body.1.declarations.0.init").evaluate().confident, false ); }); @@ -73,7 +75,8 @@ describe("evaluation", function () { it("it should not deopt let/const inside blocks", function () { assert.strictEqual( - getPath("let x = 5; { let x = 1; } let y = x + 5").get("body.2.declarations.0.init").evaluate().value, + getPath("let x = 5; { let x = 1; } let y = x + 5") + .get("body.2.declarations.0.init").evaluate().value, 10 ); const constExample = "const d = true; if (d && true || false) { const d = false; d && 5; }"; diff --git a/packages/babel-traverse/test/inference.js b/packages/babel-traverse/test/inference.js index 225f2c7430..03ff842ecf 100644 --- a/packages/babel-traverse/test/inference.js +++ b/packages/babel-traverse/test/inference.js @@ -36,7 +36,8 @@ describe("inference", function () { }); it("it should bail when type changes", function () { - const path = getPath("var x = 1; if (foo) x = null;else x = 3; x === 2").get("body")[2].get("expression"); + const path = getPath("var x = 1; if (foo) x = null;else x = 3; x === 2") + .get("body")[2].get("expression"); const left = path.get("left"); const right = path.get("right"); @@ -144,7 +145,8 @@ describe("inference", function () { it("should infer call return type using async generator function", function () { const path = getPath("(async function * (): string {})()").get("body")[0].get("expression"); const type = path.getTypeAnnotation(); - assert.ok(t.isGenericTypeAnnotation(type) && type.id.name === "AsyncIterator", "should be AsyncIterator"); + assert.ok(t.isGenericTypeAnnotation(type) && type.id.name === "AsyncIterator", + "should be AsyncIterator"); }); it("should infer number from x/y", function () { const path = getPath("x/y").get("body")[0].get("expression"); diff --git a/packages/babel-traverse/test/scope.js b/packages/babel-traverse/test/scope.js index db51118fcf..7f823ecfd6 100644 --- a/packages/babel-traverse/test/scope.js +++ b/packages/babel-traverse/test/scope.js @@ -17,22 +17,29 @@ function getPath(code) { describe("scope", function () { describe("binding paths", function () { it("function declaration id", function () { - assert.ok(getPath("function foo() {}").scope.getBinding("foo").path.type === "FunctionDeclaration"); + assert.ok(getPath("function foo() {}") + .scope.getBinding("foo").path.type === "FunctionDeclaration"); }); it("function expression id", function () { - assert.ok(getPath("(function foo() {})").get("body")[0].get("expression").scope.getBinding("foo").path.type === "FunctionExpression"); + assert.ok(getPath("(function foo() {})").get("body")[0].get("expression") + .scope.getBinding("foo").path.type === "FunctionExpression"); }); it("function param", function () { - assert.ok(getPath("(function (foo) {})").get("body")[0].get("expression").scope.getBinding("foo").path.type === "Identifier"); + assert.ok(getPath("(function (foo) {})").get("body")[0].get("expression") + .scope.getBinding("foo").path.type === "Identifier"); }); it("variable declaration", function () { - assert.ok(getPath("var foo = null;").scope.getBinding("foo").path.type === "VariableDeclarator"); - assert.ok(getPath("var { foo } = null;").scope.getBinding("foo").path.type === "VariableDeclarator"); - assert.ok(getPath("var [ foo ] = null;").scope.getBinding("foo").path.type === "VariableDeclarator"); - assert.ok(getPath("var { bar: [ foo ] } = null;").scope.getBinding("foo").path.type === "VariableDeclarator"); + assert.ok(getPath("var foo = null;") + .scope.getBinding("foo").path.type === "VariableDeclarator"); + assert.ok(getPath("var { foo } = null;") + .scope.getBinding("foo").path.type === "VariableDeclarator"); + assert.ok(getPath("var [ foo ] = null;") + .scope.getBinding("foo").path.type === "VariableDeclarator"); + assert.ok(getPath("var { bar: [ foo ] } = null;") + .scope.getBinding("foo").path.type === "VariableDeclarator"); }); it("purity", function () { diff --git a/packages/babel-traverse/test/traverse.js b/packages/babel-traverse/test/traverse.js index 3f62821ce5..5434620947 100644 --- a/packages/babel-traverse/test/traverse.js +++ b/packages/babel-traverse/test/traverse.js @@ -31,7 +31,8 @@ describe("traverse", function () { it("traverse", function () { const expect = [ body[0], body[0].declarations[0], body[0].declarations[0].id, body[0].declarations[0].init, - body[1], body[1].expression, body[1].expression.left, body[1].expression.left.object, body[1].expression.left.property, body[1].expression.right + body[1], body[1].expression, body[1].expression.left, body[1].expression.left.object, + body[1].expression.left.property, body[1].expression.right ]; const actual = []; diff --git a/packages/babel-types/src/constants.js b/packages/babel-types/src/constants.js index 72f0a16387..1ed965382e 100644 --- a/packages/babel-types/src/constants.js +++ b/packages/babel-types/src/constants.js @@ -1,4 +1,4 @@ -/* eslint max-len: 0 */ +/* eslint max-len: "off" */ export const STATEMENT_OR_BLOCK_KEYS = ["consequent", "body", "alternate"]; export const FLATTENABLE_KEYS = ["body", "expressions"]; diff --git a/packages/babel-types/src/definitions/core.js b/packages/babel-types/src/definitions/core.js index 276db2048a..e7b7a272e0 100644 --- a/packages/babel-types/src/definitions/core.js +++ b/packages/babel-types/src/definitions/core.js @@ -1,4 +1,4 @@ -/* eslint max-len: 0 */ +/* eslint max-len: "off" */ import * as t from "../index"; diff --git a/packages/babel-types/src/definitions/es2015.js b/packages/babel-types/src/definitions/es2015.js index 843a831fa6..f0231478d3 100644 --- a/packages/babel-types/src/definitions/es2015.js +++ b/packages/babel-types/src/definitions/es2015.js @@ -1,4 +1,4 @@ -/* eslint max-len: 0 */ +/* eslint max-len: "off" */ import defineType, { assertNodeType, diff --git a/packages/babel-types/src/validators.js b/packages/babel-types/src/validators.js index 183a304a9b..c5f25327bd 100644 --- a/packages/babel-types/src/validators.js +++ b/packages/babel-types/src/validators.js @@ -1,5 +1,3 @@ -/* eslint indent: 0 */ - import { getBindingIdentifiers } from "./retrievers"; import esutils from "esutils"; import * as t from "./index"; @@ -276,7 +274,7 @@ export function isNodesEquivalent(a, b) { } if (!isNodesEquivalent(a[field], b[field])) { - return false; + return false; } } diff --git a/packages/babel-types/test/converters.js b/packages/babel-types/test/converters.js index 56dabf6586..b89e6dbe3f 100644 --- a/packages/babel-types/test/converters.js +++ b/packages/babel-types/test/converters.js @@ -25,7 +25,8 @@ describe("converters", function () { assert.deepEqual(t.valueToNode(/abc.+/gm), t.regExpLiteral("abc.+", "gm")); }); it("array", function () { - assert.deepEqual(t.valueToNode([1, "a"]), t.arrayExpression([t.numericLiteral(1), t.stringLiteral("a")])); + assert.deepEqual(t.valueToNode([1, "a"]), + t.arrayExpression([t.numericLiteral(1), t.stringLiteral("a")])); }); it("object", function () { assert.deepEqual(t.valueToNode({