Skip to content

Commit c0f418e

Browse files
stephenwademdjermanovic
andauthoredMay 21, 2021
Chore: Remove lodash (#14287)
* Chore: Update table to ^6.0.9 * Chore: Remove lodash.last lodash.last(array) -> array[array.length - 1] * Chore: Remove lodash.get v = lodash.get(a, "b.c") -> if (a && a.b && a.b.c) v = a.b.c * Chore: Remove lodash.noop lodash.noop -> () => {} * Chore: Remove lodash.union https://exploringjs.com/impatient-js/ch_sets.html#union-a-b * Chore: Remove lodash.intersection https://exploringjs.com/impatient-js/ch_sets.html#intersection-a-b * Chore: Remove lodash.findLast lodash.findLast(array) -> [...array].reverse().find(_ =>_) * Chore: Remove lodash.overSome * Chore: Remove lodash.isPlainObject * Chore: Remove lodash.isString lodash.isString(str) -> typeof str === "string"; * Chore: Remove lodash.range * Chore: Remove lodash.sortedLastIndex https://www.30secondsofcode.org/js/s/sorted-last-index * Chore: Remove lodash.sortedIndexBy https://www.30secondsofcode.org/js/s/sorted-index-by * Chore: Remove lodash.sample https://www.30secondsofcode.org/js/s/sample * Chore: Remove lodash.flatMap * Chore: Remove lodash.flatten * Chore: Remove lodash.template * Chore: Remove lodash.escapeRegExp Add the escape-string-regexp package * Chore: Remove lodash.isEqual Add the fast-deep-equal package * Chore: Remove lodash.merge Add the deep-extend package * Chore: Remove lodash.cloneDeep Add the clone package * Chore: Remove lodash.omit Add the omit package * Chore: Remove lodash.upperFirst Add the upper-case-first package * Chore: Remove lodash.memoize Add the fast-memoize package * Chore: Remove lodash.mapValues Add the map-values package * Chore: Remove lodash.flatten * Chore: Remove lodash * Chore: Replace arrays.flat() * Chore: Replace clone with rfdc * Chore: Add comment about map-values * Chore: Remove omit dependency * Chore: Remove rfdc dependency * Chore: Remove upper-case-first dependency * Chore: Remove fast-memoize dependency * Chore: Apply suggestions in lib/linter/node-event-generator.js Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com> * Chore: Add tests for upperCaseFirst * Chore: Remove map-values dependency * Chore: Apply review suggestions * Chore: Upgrade deep-extend to ^0.6.0 * Chore: Replace deep-extend dependency with lodash.merge * Chore: Apply review suggestion * Chore: Simplify search code * Chore: Apply review suggestions Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>
1 parent 52655dd commit c0f418e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+526
-220
lines changed
 

‎bin/eslint.js

+2-12
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,8 @@ function readStdin() {
6666
*/
6767
function getErrorMessage(error) {
6868

69-
// Lazy loading because those are used only if error happened.
70-
const fs = require("fs");
71-
const path = require("path");
69+
// Lazy loading because this is used only if an error happened.
7270
const util = require("util");
73-
const lodash = require("lodash");
7471

7572
// Foolproof -- thirdparty module might throw non-object.
7673
if (typeof error !== "object" || error === null) {
@@ -80,14 +77,7 @@ function getErrorMessage(error) {
8077
// Use templates if `error.messageTemplate` is present.
8178
if (typeof error.messageTemplate === "string") {
8279
try {
83-
const templateFilePath = path.resolve(
84-
__dirname,
85-
`../messages/${error.messageTemplate}.txt`
86-
);
87-
88-
// Use sync API because Node.js should exit at this tick.
89-
const templateText = fs.readFileSync(templateFilePath, "utf-8");
90-
const template = lodash.template(templateText);
80+
const template = require(`../messages/${error.messageTemplate}.js`);
9181

9282
return template(error.messageData || {});
9383
} catch {

‎docs/developer-guide/code-path-analysis.md

+5-7
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,6 @@ bar();
195195
### To check whether or not this is reachable
196196

197197
```js
198-
var last = require("lodash").last;
199-
200198
function isReachable(segment) {
201199
return segment.reachable;
202200
}
@@ -215,7 +213,7 @@ module.exports = function(context) {
215213

216214
// Checks reachable or not.
217215
"ExpressionStatement": function(node) {
218-
var codePath = last(codePathStack);
216+
var codePath = codePathStack[codePathStack.length - 1];
219217

220218
// Checks the current code path segments.
221219
if (!codePath.currentSegments.some(isReachable)) {
@@ -239,8 +237,6 @@ So a rule must not modify those instances.
239237
Please use a map of information instead.
240238

241239
```js
242-
var last = require("lodash").last;
243-
244240
function hasCb(node, context) {
245241
if (node.type.indexOf("Function") !== -1) {
246242
return context.getDeclaredVariables(node).some(function(v) {
@@ -285,8 +281,10 @@ module.exports = function(context) {
285281

286282
// Manages state of code paths.
287283
"onCodePathSegmentStart": function(segment) {
284+
var funcInfo = funcInfoStack[funcInfoStack.length - 1];
285+
288286
// Ignores if `cb` doesn't exist.
289-
if (!last(funcInfoStack).hasCb) {
287+
if (!funcInfo.hasCb) {
290288
return;
291289
}
292290

@@ -304,7 +302,7 @@ module.exports = function(context) {
304302

305303
// Checks reachable or not.
306304
"CallExpression": function(node) {
307-
var funcInfo = last(funcInfoStack);
305+
var funcInfo = funcInfoStack[funcInfoStack.length - 1];
308306

309307
// Ignores if `cb` doesn't exist.
310308
if (!funcInfo.hasCb) {

0 commit comments

Comments
 (0)
Please sign in to comment.