From f8e9c254fb24d8d23d83dcf0578fc55cfb6f2c78 Mon Sep 17 00:00:00 2001
From: szymonrybczak <szymon.rybczak@gmail.com>
Date: Fri, 20 Sep 2024 08:57:40 +0200
Subject: [PATCH] feat: add eslint import rule for lodash

---
 .eslintrc.js                                |  3 ++-
 .github/libs/promiseWhile.ts                |  1 +
 package-lock.json                           | 24 ++++++++++++++++++---
 package.json                                |  1 +
 src/hooks/useDebounce.ts                    |  1 +
 src/pages/home/report/ReportActionsList.tsx |  1 +
 6 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/.eslintrc.js b/.eslintrc.js
index cb1219533278..d9e25cc596f7 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -108,7 +108,7 @@ module.exports = {
         'plugin:you-dont-need-lodash-underscore/all',
         'plugin:prettier/recommended',
     ],
-    plugins: ['@typescript-eslint', 'jsdoc', 'you-dont-need-lodash-underscore', 'react-native-a11y', 'react', 'testing-library', 'eslint-plugin-react-compiler'],
+    plugins: ['@typescript-eslint', 'jsdoc', 'you-dont-need-lodash-underscore', 'react-native-a11y', 'react', 'testing-library', 'eslint-plugin-react-compiler', 'lodash'],
     ignorePatterns: ['lib/**'],
     parser: '@typescript-eslint/parser',
     parserOptions: {
@@ -231,6 +231,7 @@ module.exports = {
         'you-dont-need-lodash-underscore/throttle': 'off',
         // The suggested alternative (structuredClone) is not supported in Hermes:https://github.com/facebook/hermes/issues/684
         'you-dont-need-lodash-underscore/clone-deep': 'off',
+        'lodash/import-scope': ['error', 'method'],
         'prefer-regex-literals': 'off',
         'valid-jsdoc': 'off',
         'jsdoc/no-types': 'error',
diff --git a/.github/libs/promiseWhile.ts b/.github/libs/promiseWhile.ts
index 8bedceb894fd..bdd5713be43a 100644
--- a/.github/libs/promiseWhile.ts
+++ b/.github/libs/promiseWhile.ts
@@ -1,3 +1,4 @@
+// eslint-disable-next-line lodash/import-scope
 import type {DebouncedFunc} from 'lodash';
 
 /**
diff --git a/package-lock.json b/package-lock.json
index a5ae221a1e14..87c7dd3d2600 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -221,6 +221,7 @@
         "eslint-plugin-deprecation": "^3.0.0",
         "eslint-plugin-jest": "^28.6.0",
         "eslint-plugin-jsdoc": "^46.2.6",
+        "eslint-plugin-lodash": "^7.4.0",
         "eslint-plugin-react-compiler": "0.0.0-experimental-9ed098e-20240725",
         "eslint-plugin-react-native-a11y": "^3.3.0",
         "eslint-plugin-storybook": "^0.8.0",
@@ -23446,6 +23447,21 @@
         "semver": "bin/semver.js"
       }
     },
+    "node_modules/eslint-plugin-lodash": {
+      "version": "7.4.0",
+      "resolved": "https://registry.npmjs.org/eslint-plugin-lodash/-/eslint-plugin-lodash-7.4.0.tgz",
+      "integrity": "sha512-Tl83UwVXqe1OVeBRKUeWcfg6/pCW1GTRObbdnbEJgYwjxp5Q92MEWQaH9+dmzbRt6kvYU1Mp893E79nJiCSM8A==",
+      "dev": true,
+      "dependencies": {
+        "lodash": "^4.17.21"
+      },
+      "engines": {
+        "node": ">=10"
+      },
+      "peerDependencies": {
+        "eslint": ">=2"
+      }
+    },
     "node_modules/eslint-plugin-prettier": {
       "version": "4.2.1",
       "dev": true,
@@ -23655,8 +23671,9 @@
     },
     "node_modules/eslint-plugin-you-dont-need-lodash-underscore": {
       "version": "6.14.0",
+      "resolved": "https://registry.npmjs.org/eslint-plugin-you-dont-need-lodash-underscore/-/eslint-plugin-you-dont-need-lodash-underscore-6.14.0.tgz",
+      "integrity": "sha512-3zkkU/O1agczP7szJGHmisZJS/AknfVl6mb0Zqoc95dvFsdmfK+cbhrn+Ffy0UWB1pgDJwQr7kIO3rPstWs3Dw==",
       "dev": true,
-      "license": "MIT",
       "dependencies": {
         "kebab-case": "^1.0.0"
       },
@@ -30001,8 +30018,9 @@
     },
     "node_modules/kebab-case": {
       "version": "1.0.2",
-      "dev": true,
-      "license": "MIT"
+      "resolved": "https://registry.npmjs.org/kebab-case/-/kebab-case-1.0.2.tgz",
+      "integrity": "sha512-7n6wXq4gNgBELfDCpzKc+mRrZFs7D+wgfF5WRFLNAr4DA/qtr9Js8uOAVAfHhuLMfAcQ0pRKqbpjx+TcJVdE1Q==",
+      "dev": true
     },
     "node_modules/keyv": {
       "version": "4.5.2",
diff --git a/package.json b/package.json
index 3d808af65ba2..056d29a36c19 100644
--- a/package.json
+++ b/package.json
@@ -288,6 +288,7 @@
     "eslint-plugin-storybook": "^0.8.0",
     "eslint-plugin-testing-library": "^6.2.2",
     "eslint-plugin-you-dont-need-lodash-underscore": "^6.14.0",
+    "eslint-plugin-lodash": "^7.4.0",
     "html-webpack-plugin": "^5.5.0",
     "http-server": "^14.1.1",
     "jest": "29.4.1",
diff --git a/src/hooks/useDebounce.ts b/src/hooks/useDebounce.ts
index c3d6c22abf86..b5e3f333c44a 100644
--- a/src/hooks/useDebounce.ts
+++ b/src/hooks/useDebounce.ts
@@ -1,3 +1,4 @@
+// eslint-disable-next-line lodash/import-scope
 import type {DebouncedFunc, DebounceSettings} from 'lodash';
 import lodashDebounce from 'lodash/debounce';
 import {useCallback, useEffect, useRef} from 'react';
diff --git a/src/pages/home/report/ReportActionsList.tsx b/src/pages/home/report/ReportActionsList.tsx
index 6828e10e7e3b..bf01d57dbca7 100644
--- a/src/pages/home/report/ReportActionsList.tsx
+++ b/src/pages/home/report/ReportActionsList.tsx
@@ -1,6 +1,7 @@
 import type {ListRenderItemInfo} from '@react-native/virtualized-lists/Lists/VirtualizedList';
 import {useIsFocused, useRoute} from '@react-navigation/native';
 import type {RouteProp} from '@react-navigation/native';
+// eslint-disable-next-line lodash/import-scope
 import type {DebouncedFunc} from 'lodash';
 import React, {memo, useCallback, useEffect, useMemo, useRef, useState} from 'react';
 import {DeviceEventEmitter, InteractionManager, View} from 'react-native';
