From 5117bb1537c1bff471ffd80f300c0360540144c3 Mon Sep 17 00:00:00 2001 From: Azat S Date: Wed, 9 Nov 2022 04:00:07 +0300 Subject: [PATCH] Remove lodash --- package.json | 20 ++++++++++++++++++-- src/common/error-utils.ts | 2 +- src/common/lines-and-columns.ts | 2 +- src/common/location-calculator.ts | 2 +- src/common/token-utils.ts | 4 ++-- src/external/node-event-generator.ts | 6 +++--- src/external/token-store/utils.ts | 2 +- src/html/intermediate-tokenizer.ts | 2 +- src/html/parser.ts | 8 ++++---- src/script/index.ts | 6 +++--- test/ast.js | 4 ++-- 11 files changed, 37 insertions(+), 21 deletions(-) diff --git a/package.json b/package.json index b3503c63..81ccc8ac 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,15 @@ "eslint-visitor-keys": "^3.3.0", "espree": "^9.3.1", "esquery": "^1.4.0", - "lodash": "^4.17.21", + "lodash.findlastindex": "^4.6.0", + "lodash.first": "^3.0.0", + "lodash.intersection": "^4.4.0", + "lodash.last": "^3.0.0", + "lodash.memoize": "^4.1.2", + "lodash.sortedindexby": "^4.6.0", + "lodash.sortedlastindex": "^4.1.0", + "lodash.sortedlastindexby": "^4.6.0", + "lodash.union": "^4.6.0", "semver": "^7.3.6" }, "devDependencies": { @@ -30,7 +38,15 @@ "@types/debug": "^4.1.7", "@types/eslint": "^8.4.6", "@types/estree": "^1.0.0", - "@types/lodash": "^4.14.186", + "@types/lodash.findlastindex": "^4.6.7", + "@types/lodash.first": "^3.0.7", + "@types/lodash.intersection": "^4.4.7", + "@types/lodash.last": "^3.0.7", + "@types/lodash.memoize": "^4.1.7", + "@types/lodash.sortedindexby": "^4.6.7", + "@types/lodash.sortedlastindex": "^4.1.7", + "@types/lodash.sortedlastindexby": "^4.6.7", + "@types/lodash.union": "^4.6.7", "@types/mocha": "^9.0.0", "@types/node": "^18.8.4", "@types/semver": "^7.3.12", diff --git a/src/common/error-utils.ts b/src/common/error-utils.ts index 2aad6de4..63cba2d8 100644 --- a/src/common/error-utils.ts +++ b/src/common/error-utils.ts @@ -1,5 +1,5 @@ import type { ParseError, VDocumentFragment } from "../ast" -import sortedIndexBy from "lodash/sortedIndexBy" +import sortedIndexBy from "lodash.sortedindexby" /** * Insert the given error. * @param document The document that the node is belonging to. diff --git a/src/common/lines-and-columns.ts b/src/common/lines-and-columns.ts index ff1feef5..3d72ea38 100644 --- a/src/common/lines-and-columns.ts +++ b/src/common/lines-and-columns.ts @@ -1,4 +1,4 @@ -import sortedLastIndex from "lodash/sortedLastIndex" +import sortedLastIndex from "lodash.sortedlastindex" import type { Location } from "../ast" import type { LocationCalculator } from "./location-calculator" /** diff --git a/src/common/location-calculator.ts b/src/common/location-calculator.ts index 987d5bf4..563e65a1 100644 --- a/src/common/location-calculator.ts +++ b/src/common/location-calculator.ts @@ -3,7 +3,7 @@ * @copyright 2017 Toru Nagashima. All rights reserved. * See LICENSE file in root directory for full license. */ -import sortedLastIndex from "lodash/sortedLastIndex" +import sortedLastIndex from "lodash.sortedlastindex" import type { Location } from "../ast" import { LinesAndColumns } from "./lines-and-columns" diff --git a/src/common/token-utils.ts b/src/common/token-utils.ts index 4ce11d19..f84085ab 100644 --- a/src/common/token-utils.ts +++ b/src/common/token-utils.ts @@ -1,5 +1,5 @@ -import sortedIndexBy from "lodash/sortedIndexBy" -import sortedLastIndexBy from "lodash/sortedLastIndexBy" +import sortedIndexBy from "lodash.sortedindexby" +import sortedLastIndexBy from "lodash.sortedlastindexby" import type { LocationRange, Token, VDocumentFragment } from "../ast" import type { LinesAndColumns } from "./lines-and-columns" diff --git a/src/external/node-event-generator.ts b/src/external/node-event-generator.ts index 7c74c54a..9ccf830c 100644 --- a/src/external/node-event-generator.ts +++ b/src/external/node-event-generator.ts @@ -3,9 +3,9 @@ */ import EventEmitter from "events" import esquery, {ESQueryOptions, Selector} from "esquery" -import union from "lodash/union" -import intersection from "lodash/intersection" -import memoize from "lodash/memoize" +import union from "lodash.union" +import intersection from "lodash.intersection" +import memoize from "lodash.memoize" import {Node} from "../ast" interface NodeSelector { diff --git a/src/external/token-store/utils.ts b/src/external/token-store/utils.ts index d8e35831..a6465a8e 100644 --- a/src/external/token-store/utils.ts +++ b/src/external/token-store/utils.ts @@ -2,7 +2,7 @@ * @fileoverview Define utilify functions for token store. * @author Toru Nagashima */ -import sortedIndexBy from "lodash/sortedIndexBy" +import sortedIndexBy from "lodash.sortedindexby" import {HasLocation} from "../../ast" /** diff --git a/src/html/intermediate-tokenizer.ts b/src/html/intermediate-tokenizer.ts index 9ba22236..b0a4744a 100644 --- a/src/html/intermediate-tokenizer.ts +++ b/src/html/intermediate-tokenizer.ts @@ -4,7 +4,7 @@ * See LICENSE file in root directory for full license. */ import assert from "assert" -import last from "lodash/last" +import last from "lodash.last" import type { ErrorCode, HasLocation, diff --git a/src/html/parser.ts b/src/html/parser.ts index 5d66ca16..3ef56ad6 100644 --- a/src/html/parser.ts +++ b/src/html/parser.ts @@ -4,8 +4,8 @@ * See LICENSE file in root directory for full license. */ import assert from "assert" -import last from "lodash/last" -import findLastIndex from "lodash/findLastIndex" +import last from "lodash.last" +import findLastIndex from "lodash.findlastindex" import type { ErrorCode, HasLocation, @@ -52,8 +52,8 @@ import { getScriptParser, getParserLangFromSFC, } from "../common/parser-options" -import sortedIndexBy from "lodash/sortedIndexBy" -import sortedLastIndexBy from "lodash/sortedLastIndexBy" +import sortedIndexBy from "lodash.sortedindexby" +import sortedLastIndexBy from "lodash.sortedlastindexby" import type { CustomTemplateTokenizer, CustomTemplateTokenizerConstructor, diff --git a/src/script/index.ts b/src/script/index.ts index a2e9d14e..56a0eb3b 100644 --- a/src/script/index.ts +++ b/src/script/index.ts @@ -3,9 +3,9 @@ * @copyright 2017 Toru Nagashima. All rights reserved. * See LICENSE file in root directory for full license. */ -import first from "lodash/first" -import last from "lodash/last" -import sortedIndexBy from "lodash/sortedIndexBy" +import first from "lodash.first" +import last from "lodash.last" +import sortedIndexBy from "lodash.sortedindexby" import type { ESLintArrayExpression, ESLintArrayPattern, diff --git a/test/ast.js b/test/ast.js index 98ca9b89..e73fce5e 100644 --- a/test/ast.js +++ b/test/ast.js @@ -12,7 +12,7 @@ const assert = require("assert") const fs = require("fs") const path = require("path") -const lodash = require("lodash") +const last = require("lodash.last") const parser = require("../src") const Linter = require("./fixtures/eslint").Linter const semver = require("semver") @@ -135,7 +135,7 @@ function validateParent(source, parserOptions) { ruleContext.parserServices.defineTemplateBodyVisitor({ "*"(node) { if (stack.length >= 1) { - const parent = lodash.last(stack) + const parent = last(stack) assert( node.parent === parent, `The parent of ${nodeToString(