diff --git a/packages/babel-cli/src/babel/options.js b/packages/babel-cli/src/babel/options.js index 6b94f75cd675..0aa54b3ef607 100644 --- a/packages/babel-cli/src/babel/options.js +++ b/packages/babel-cli/src/babel/options.js @@ -4,7 +4,6 @@ import fs from "fs"; import commander from "commander"; import { version } from "@babel/core"; -import uniq from "lodash/uniq"; import glob from "glob"; import pkg from "../../package.json"; @@ -195,7 +194,7 @@ export default function parseArgv(args: Array): CmdOptions | null { return globbed.concat(files); }, []); - filenames = uniq(filenames); + filenames = Array.from(new Set(filenames)); filenames.forEach(function (filename) { if (!fs.existsSync(filename)) { diff --git a/packages/babel-cli/src/babel/util.js b/packages/babel-cli/src/babel/util.js index 752203cd0620..868382232d02 100644 --- a/packages/babel-cli/src/babel/util.js +++ b/packages/babel-cli/src/babel/util.js @@ -2,7 +2,6 @@ import readdirRecursive from "fs-readdir-recursive"; import * as babel from "@babel/core"; -import includes from "lodash/includes"; import path from "path"; import fs from "fs"; @@ -47,7 +46,7 @@ export function isCompilableExtension( ): boolean { const exts = altExts || babel.DEFAULT_EXTENSIONS; const ext = path.extname(filename); - return includes(exts, ext); + return exts.includes(ext); } export function addSourceMappingUrl(code: string, loc: string): string { diff --git a/packages/babel-generator/package.json b/packages/babel-generator/package.json index 0fa7b675ef14..545b27db7e44 100644 --- a/packages/babel-generator/package.json +++ b/packages/babel-generator/package.json @@ -20,7 +20,6 @@ "dependencies": { "@babel/types": "^7.10.4", "jsesc": "^2.5.1", - "lodash": "^4.17.13", "source-map": "^0.5.0" }, "devDependencies": { diff --git a/packages/babel-generator/src/printer.js b/packages/babel-generator/src/printer.js index bed3698545c7..83a0321a0a70 100644 --- a/packages/babel-generator/src/printer.js +++ b/packages/babel-generator/src/printer.js @@ -1,5 +1,3 @@ -import isInteger from "lodash/isInteger"; -import repeat from "lodash/repeat"; import Buffer from "./buffer"; import * as n from "./node"; import * as t from "@babel/types"; @@ -138,7 +136,7 @@ export default class Printer { // Integer tokens need special handling because they cannot have '.'s inserted // immediately after them. this._endsWithInteger = - isInteger(+str) && + Number.isInteger(+str) && !NON_DECIMAL_LITERAL.test(str) && !SCIENTIFIC_NOTATION.test(str) && !ZERO_DECIMAL_INTEGER.test(str) && @@ -324,7 +322,7 @@ export default class Printer { */ _getIndent(): string { - return repeat(this.format.indent.style, this._indent); + return this.format.indent.style.repeat(this._indent); } /** @@ -616,7 +614,7 @@ export default class Printer { this._getIndent().length, this._buf.getCurrentColumn(), ); - val = val.replace(/\n(?!$)/g, `\n${repeat(" ", indentSize)}`); + val = val.replace(/\n(?!$)/g, `\n${" ".repeat(indentSize)}`); } // Avoid creating //* comments 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 568e18376048..1ff7233d1975 100644 --- a/packages/babel-helper-transform-fixture-test-runner/src/index.js +++ b/packages/babel-helper-transform-fixture-test-runner/src/index.js @@ -5,7 +5,6 @@ import getFixtures from "@babel/helper-fixtures"; import sourceMap from "source-map"; import { codeFrameColumns } from "@babel/code-frame"; import defaults from "lodash/defaults"; -import includes from "lodash/includes"; import escapeRegExp from "lodash/escapeRegExp"; import * as helpers from "./helpers"; import extend from "lodash/extend"; @@ -352,7 +351,7 @@ export default function ( const suites = getFixtures(fixturesLoc); for (const testSuite of suites) { - if (includes(suiteOpts.ignoreSuites, testSuite.title)) continue; + if (suiteOpts.ignoreSuites?.includes(testSuite.title)) continue; describe(name + "/" + testSuite.title, function () { jest.addMatchers({ @@ -361,8 +360,8 @@ export default function ( for (const task of testSuite.tests) { if ( - includes(suiteOpts.ignoreTasks, task.title) || - includes(suiteOpts.ignoreTasks, testSuite.title + "/" + task.title) + suiteOpts.ignoreTasks?.includes(task.title) || + suiteOpts.ignoreTasks?.includes(testSuite.title + "/" + task.title) ) { continue; } diff --git a/packages/babel-traverse/src/index.js b/packages/babel-traverse/src/index.js index 1af05587ca2b..3d3af0f79e03 100644 --- a/packages/babel-traverse/src/index.js +++ b/packages/babel-traverse/src/index.js @@ -1,6 +1,5 @@ import TraversalContext from "./context"; import * as visitors from "./visitors"; -import includes from "lodash/includes"; import * as t from "@babel/types"; import * as cache from "./cache"; @@ -87,10 +86,10 @@ function hasBlacklistedType(path, state) { traverse.hasType = function ( tree: Object, type: Object, - blacklistTypes: Array, + blacklistTypes?: Array, ): boolean { // the node we're searching in is blacklisted - if (includes(blacklistTypes, tree.type)) return false; + if (blacklistTypes?.includes(tree.type)) return false; // the type we're looking for is the same as the passed node if (tree.type === type) return true; diff --git a/packages/babel-traverse/src/path/introspection.js b/packages/babel-traverse/src/path/introspection.js index b660cf666e94..7060b6a2f51f 100644 --- a/packages/babel-traverse/src/path/introspection.js +++ b/packages/babel-traverse/src/path/introspection.js @@ -1,7 +1,6 @@ // This file contains methods responsible for introspecting the current path for certain values. import type NodePath from "./index"; -import includes from "lodash/includes"; import * as t from "@babel/types"; /** @@ -149,7 +148,7 @@ export function isStatementOrBlock() { ) { return false; } else { - return includes(t.STATEMENT_OR_BLOCK_KEYS, this.key); + return t.STATEMENT_OR_BLOCK_KEYS.includes(this.key); } } diff --git a/packages/babel-traverse/src/scope/index.js b/packages/babel-traverse/src/scope/index.js index f309baf316e2..4a7a7f83efa1 100644 --- a/packages/babel-traverse/src/scope/index.js +++ b/packages/babel-traverse/src/scope/index.js @@ -1,5 +1,3 @@ -import includes from "lodash/includes"; -import repeat from "lodash/repeat"; import Renamer from "./lib/renamer"; import type NodePath from "../path"; import traverse from "../index"; @@ -502,7 +500,7 @@ export default class Scope { } dump() { - const sep = repeat("-", 60); + const sep = "-".repeat(60); console.log(sep); let scope = this; do { @@ -1038,8 +1036,8 @@ export default class Scope { if (this.hasOwnBinding(name)) return true; if (this.parentHasBinding(name, noGlobals)) return true; if (this.hasUid(name)) return true; - if (!noGlobals && includes(Scope.globals, name)) return true; - if (!noGlobals && includes(Scope.contextVariables, name)) return true; + if (!noGlobals && Scope.globals.includes(name)) return true; + if (!noGlobals && Scope.contextVariables.includes(name)) return true; return false; } diff --git a/packages/babel-types/src/utils/inherit.js b/packages/babel-types/src/utils/inherit.js index 276e0d91436f..be57867e8bd3 100644 --- a/packages/babel-types/src/utils/inherit.js +++ b/packages/babel-types/src/utils/inherit.js @@ -1,12 +1,12 @@ // @flow -import uniq from "lodash/uniq"; - export default function inherit( key: string, child: Object, parent: Object, ): void { if (child && parent) { - child[key] = uniq([].concat(child[key], parent[key]).filter(Boolean)); + child[key] = Array.from( + new Set([].concat(child[key], parent[key]).filter(Boolean)), + ); } }