Skip to content

Commit

Permalink
Use lodash-es instead of lodash
Browse files Browse the repository at this point in the history
When ESLint is configured to prefer TypeScript modules over JavaScript
(even in JavaScript files), attempting to import a named export from
`lodash` fails the `import/named` rule with something like:

    capitalize not found in 'lodash'

This seems to happen because `index.d.ts` links to other `.d.ts` files
via `/// <reference ...>`, and either `eslint-plugin-import` or
`eslint-import-resolver-typescript` does not know to follow those links.
(I say "either" because I haven't quite been able to figure out where the
exact issue is. The current maintainer of
`eslint-import-resolver-typescript` hasn't provided any useful
information; [here][1] is the closest issue on GitHub I've been able to
find that could explain something.) However, `lodash-es` does not
exhibit this issue, as its `index.d.ts` just imports types for
individual functions from other files instead of using `/// <reference
...>`.

[1]: import-js/eslint-import-resolver-typescript#31
  • Loading branch information
mcmire committed Feb 2, 2022
1 parent 7a808ab commit 91bc52c
Show file tree
Hide file tree
Showing 125 changed files with 125 additions and 125 deletions.
2 changes: 1 addition & 1 deletion app/scripts/controllers/incoming-transactions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { strict as assert } from 'assert';
import sinon from 'sinon';
import proxyquire from 'proxyquire';
import nock from 'nock';
import { cloneDeep } from 'lodash';
import { cloneDeep } from 'lodash-es';

import waitUntilCalled from '../../../test/lib/wait-until-called';
import {
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/controllers/metametrics.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { merge, omit, omitBy } from 'lodash';
import { merge, omit, omitBy } from 'lodash-es';
import { ObservableStore } from '@metamask/obs-store';
import { bufferToHex, keccak } from 'ethereumjs-util';
import { generateUUID } from 'pubnub';
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/controllers/permissions/selectors.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cloneDeep } from 'lodash';
import { cloneDeep } from 'lodash-es';
import { getChangedAccounts, getPermittedAccountsByOrigin } from './selectors';

describe('PermissionController selectors', () => {
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/controllers/swaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ethers } from 'ethers';
import log from 'loglevel';
import BigNumber from 'bignumber.js';
import { ObservableStore } from '@metamask/obs-store';
import { mapValues, cloneDeep } from 'lodash';
import { mapValues, cloneDeep } from 'lodash-es';
import abi from 'human-standard-token-abi';
import { calcTokenAmount } from '../../../ui/helpers/utils/token-util';
import { calcGasTotal } from '../../../ui/pages/send/send.utils';
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/controllers/swaps.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { strict as assert } from 'assert';
import sinon from 'sinon';

import { ethers } from 'ethers';
import { mapValues } from 'lodash';
import { mapValues } from 'lodash-es';
import BigNumber from 'bignumber.js';
import {
ROPSTEN_NETWORK_ID,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import jsonDiffer from 'fast-json-patch';
import { cloneDeep } from 'lodash';
import { cloneDeep } from 'lodash-es';

/**
* converts non-initial history entries into diffs
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/controllers/transactions/tx-gas-utils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import EthQuery from 'ethjs-query';
import log from 'loglevel';
import { addHexPrefix } from 'ethereumjs-util';
import { cloneDeep } from 'lodash';
import { cloneDeep } from 'lodash-es';
import { hexToBn, BnMultiplyByFraction, bnToHex } from '../../lib/util';

/**
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/controllers/transactions/tx-state-manager.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import EventEmitter from 'safe-event-emitter';
import { ObservableStore } from '@metamask/obs-store';
import log from 'loglevel';
import { keyBy, mapValues, omitBy, pickBy, sortBy } from 'lodash';
import { keyBy, mapValues, omitBy, pickBy, sortBy } from 'lodash-es';
import createId from '../../../../shared/modules/random-id';
import { TRANSACTION_STATUSES } from '../../../../shared/constants/transaction';
import { METAMASK_CONTROLLER_EVENTS } from '../../metamask-controller';
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/lib/getObjStructure.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cloneDeep } from 'lodash';
import { cloneDeep } from 'lodash-es';

// This will create an object that represents the structure of the given object
// it replaces all values with the result of their type
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/lib/migrator/index.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable jest/no-conditional-expect */
import fs from 'fs';
import { cloneDeep } from 'lodash';
import { cloneDeep } from 'lodash-es';
import liveMigrations from '../../migrations';
import data from '../../first-time-state';
import Migrator from '.';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ethErrors, errorCodes } from 'eth-rpc-errors';
import validUrl from 'valid-url';
import { omit } from 'lodash';
import { omit } from 'lodash-es';
import { MESSAGE_TYPE } from '../../../../../shared/constants/app';
import {
isPrefixedFormattedHexString,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ethErrors } from 'eth-rpc-errors';
import { omit } from 'lodash';
import { omit } from 'lodash-es';
import { MESSAGE_TYPE } from '../../../../../shared/constants/app';
import {
ETH_SYMBOL,
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/lib/seed-phrase-verifier.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @jest-environment node
* https://github.com/facebook/jest/issues/7780
*/
import { cloneDeep } from 'lodash';
import { cloneDeep } from 'lodash-es';
import KeyringController from 'eth-keyring-controller';
import firstTimeState from '../first-time-state';
import mockEncryptor from '../../../test/lib/mock-encryptor';
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/lib/util.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import extension from 'extensionizer';
import { stripHexPrefix } from 'ethereumjs-util';
import BN from 'bn.js';
import { memoize } from 'lodash';
import { memoize } from 'lodash-es';
import {
MAINNET_CHAIN_ID,
TEST_CHAINS,
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import pump from 'pump';
import { ObservableStore } from '@metamask/obs-store';
import { storeAsStream } from '@metamask/obs-store/dist/asStream';
import { JsonRpcEngine } from 'json-rpc-engine';
import { debounce } from 'lodash';
import { debounce } from 'lodash-es';
import createEngineStream from 'json-rpc-middleware-stream/engineStream';
import createFilterMiddleware from 'eth-json-rpc-filters';
import createSubscriptionManager from 'eth-json-rpc-filters/subscriptionManager';
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/metamask-controller.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { strict as assert } from 'assert';
import sinon from 'sinon';
import { cloneDeep } from 'lodash';
import { cloneDeep } from 'lodash-es';
import nock from 'nock';
import { pubToAddress, bufferToHex } from 'ethereumjs-util';
import { obj as createThoughStream } from 'through2';
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/migrations/002.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cloneDeep } from 'lodash';
import { cloneDeep } from 'lodash-es';

const version = 2;

Expand Down
2 changes: 1 addition & 1 deletion app/scripts/migrations/003.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cloneDeep } from 'lodash';
import { cloneDeep } from 'lodash-es';

const version = 3;
const oldTestRpc = 'https://rawtestrpc.metamask.io/';
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/migrations/004.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cloneDeep } from 'lodash';
import { cloneDeep } from 'lodash-es';

const version = 4;

Expand Down
2 changes: 1 addition & 1 deletion app/scripts/migrations/005.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This migration moves state from the flat state trie into KeyringController subst
*/

import { cloneDeep } from 'lodash';
import { cloneDeep } from 'lodash-es';

const version = 5;

Expand Down
2 changes: 1 addition & 1 deletion app/scripts/migrations/006.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This migration moves KeyringController.selectedAddress to PreferencesController.
*/

import { cloneDeep } from 'lodash';
import { cloneDeep } from 'lodash-es';

const version = 6;

Expand Down
2 changes: 1 addition & 1 deletion app/scripts/migrations/007.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This migration breaks out the TransactionManager substate
*/

import { cloneDeep } from 'lodash';
import { cloneDeep } from 'lodash-es';

const version = 7;

Expand Down
2 changes: 1 addition & 1 deletion app/scripts/migrations/008.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This migration breaks out the NoticeController substate
*/

import { cloneDeep } from 'lodash';
import { cloneDeep } from 'lodash-es';

const version = 8;

Expand Down
2 changes: 1 addition & 1 deletion app/scripts/migrations/009.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This migration breaks out the CurrencyController substate
*/

import { cloneDeep, merge } from 'lodash';
import { cloneDeep, merge } from 'lodash-es';

const version = 9;

Expand Down
2 changes: 1 addition & 1 deletion app/scripts/migrations/010.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This migration breaks out the ShapeShiftController substate
*/

import { cloneDeep, merge } from 'lodash';
import { cloneDeep, merge } from 'lodash-es';

const version = 10;

Expand Down
2 changes: 1 addition & 1 deletion app/scripts/migrations/011.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This migration removes the discaimer state from our app, which was integrated in
*/

import { cloneDeep } from 'lodash';
import { cloneDeep } from 'lodash-es';

const version = 11;

Expand Down
2 changes: 1 addition & 1 deletion app/scripts/migrations/012.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This migration modifies our notices to delete their body after being read.
*/

import { cloneDeep } from 'lodash';
import { cloneDeep } from 'lodash-es';

const version = 12;

Expand Down
2 changes: 1 addition & 1 deletion app/scripts/migrations/013.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This migration modifies the network config from ambiguous 'testnet' to explicit
*/

import { cloneDeep } from 'lodash';
import { cloneDeep } from 'lodash-es';

const version = 13;

Expand Down
2 changes: 1 addition & 1 deletion app/scripts/migrations/014.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This migration removes provider from config and moves it too NetworkController.
*/

import { cloneDeep } from 'lodash';
import { cloneDeep } from 'lodash-es';

const version = 14;

Expand Down
2 changes: 1 addition & 1 deletion app/scripts/migrations/015.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ to a 'failed' stated
*/

import { cloneDeep } from 'lodash';
import { cloneDeep } from 'lodash-es';
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction';

const version = 15;
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/migrations/016.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ to a 'failed' stated
*/

import { cloneDeep } from 'lodash';
import { cloneDeep } from 'lodash-es';
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction';

const version = 16;
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/migrations/017.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This migration sets transactions who were retried and marked as failed to submit
*/

import { cloneDeep } from 'lodash';
import { cloneDeep } from 'lodash-es';
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction';

const version = 17;
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/migrations/018.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This migration updates "transaction state history" to diffs style
*/

import { cloneDeep } from 'lodash';
import { cloneDeep } from 'lodash-es';
import {
snapshotFromTxMeta,
migrateFromSnapshotsToDiffs,
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/migrations/019.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ whos nonce is too high
*/

import { cloneDeep } from 'lodash';
import { cloneDeep } from 'lodash-es';
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction';

const version = 19;
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/migrations/020.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ so that we can version notices in the future.
*/

import { cloneDeep } from 'lodash';
import { cloneDeep } from 'lodash-es';

const version = 20;

Expand Down
2 changes: 1 addition & 1 deletion app/scripts/migrations/021.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This migration removes the BlackListController from disk state
*/

import { cloneDeep } from 'lodash';
import { cloneDeep } from 'lodash-es';

const version = 21;

Expand Down
2 changes: 1 addition & 1 deletion app/scripts/migrations/022.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This migration adds submittedTime to the txMeta if it is not their
*/

import { cloneDeep } from 'lodash';
import { cloneDeep } from 'lodash-es';
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction';

const version = 22;
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/migrations/023.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This migration removes transactions that are no longer usefull down to 40 total
*/

import { cloneDeep } from 'lodash';
import { cloneDeep } from 'lodash-es';
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction';

const version = 23;
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/migrations/024.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ all unapproved transactions
*/

import { cloneDeep } from 'lodash';
import { cloneDeep } from 'lodash-es';
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction';

const version = 24;
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/migrations/025.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
normalizes txParams on unconfirmed txs
*/
import { cloneDeep } from 'lodash';
import { cloneDeep } from 'lodash-es';
import { addHexPrefix } from '../lib/util';
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction';

Expand Down
2 changes: 1 addition & 1 deletion app/scripts/migrations/026.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This migration moves the identities stored in the KeyringController
*/

import { cloneDeep } from 'lodash';
import { cloneDeep } from 'lodash-es';

const version = 26;

Expand Down
2 changes: 1 addition & 1 deletion app/scripts/migrations/027.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
normalizes txParams on unconfirmed txs
*/
import { cloneDeep } from 'lodash';
import { cloneDeep } from 'lodash-es';
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction';

const version = 27;
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/migrations/028.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
normalizes txParams on unconfirmed txs
*/
import { cloneDeep } from 'lodash';
import { cloneDeep } from 'lodash-es';

const version = 28;

Expand Down
2 changes: 1 addition & 1 deletion app/scripts/migrations/030.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ removes invalid chaids from preferences and networkController for custom rpcs
*/

import { cloneDeep } from 'lodash';
import { cloneDeep } from 'lodash-es';

const version = 30;

Expand Down
2 changes: 1 addition & 1 deletion app/scripts/migrations/031.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// next version number
import { cloneDeep } from 'lodash';
import { cloneDeep } from 'lodash-es';

const version = 31;

Expand Down
2 changes: 1 addition & 1 deletion app/scripts/migrations/032.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cloneDeep } from 'lodash';
import { cloneDeep } from 'lodash-es';

const version = 32;

Expand Down
2 changes: 1 addition & 1 deletion app/scripts/migrations/033.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Cleans up notices and assocated notice controller code
*/

import { cloneDeep } from 'lodash';
import { cloneDeep } from 'lodash-es';

const version = 33;

Expand Down
2 changes: 1 addition & 1 deletion app/scripts/migrations/034.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cloneDeep } from 'lodash';
import { cloneDeep } from 'lodash-es';

const version = 34;

Expand Down
Loading

0 comments on commit 91bc52c

Please sign in to comment.