From 1d4b8b69896776cf8831b8202e69424e14067011 Mon Sep 17 00:00:00 2001 From: Evan Rusackas Date: Tue, 23 Jan 2024 12:39:37 -0700 Subject: [PATCH] fix(dependencies): stopping (and preventing) full lodash library import... now using only method level imports. (#26710) --- superset-frontend/.eslintrc.js | 2 ++ superset-frontend/package-lock.json | 25 +++++++++++++++++++ superset-frontend/package.json | 1 + .../generators/plugin-chart/index.js | 19 +++++++++----- .../src/query/normalizeOrderBy.ts | 3 +-- .../src/query/normalizeTimeColumn.ts | 2 +- .../src/utils/convertKeysToCamelCase.ts | 4 +-- .../src/Gauge/transformProps.ts | 2 +- .../src/utils/treeBuilder.ts | 8 +++--- .../src/SqlLab/actions/sqlLab.js | 3 +-- .../src/SqlLab/components/App/index.jsx | 2 +- .../src/SqlLab/components/SqlEditor/index.tsx | 4 +-- .../components/TabbedSqlEditors/index.jsx | 2 +- .../src/SqlLab/hooks/useQueryEditor/index.ts | 2 +- .../utils/reduxStateToLocalStorageHelper.js | 2 +- .../src/components/DropdownButton/index.tsx | 2 +- .../src/components/Icons/index.tsx | 4 +-- .../src/components/Select/AsyncSelect.tsx | 3 +-- .../src/components/TableView/TableView.tsx | 2 +- .../DashboardBuilder/DashboardContainer.tsx | 2 +- .../components/SyncDashboardState/index.tsx | 2 +- .../nativeFilters/FilterBar/Vertical.tsx | 2 +- .../src/dashboard/util/charts/useChartIds.ts | 2 +- .../components/DataTableControl/index.tsx | 2 +- .../useResizeButton.tsx | 2 +- .../components/controls/TextControl/index.tsx | 2 +- .../getFormDataWithDashboardContext.ts | 2 +- .../components/Select/SelectFilterPlugin.tsx | 2 +- .../src/utils/downloadAsImage.ts | 2 +- superset-frontend/src/utils/downloadAsPdf.ts | 2 +- superset-websocket/.eslintrc.js | 2 ++ superset-websocket/package-lock.json | 25 +++++++++++++++++++ superset-websocket/package.json | 1 + superset-websocket/src/config.ts | 4 +-- 34 files changed, 101 insertions(+), 45 deletions(-) diff --git a/superset-frontend/.eslintrc.js b/superset-frontend/.eslintrc.js index 6eebb0d2df..5f57860ad9 100644 --- a/superset-frontend/.eslintrc.js +++ b/superset-frontend/.eslintrc.js @@ -71,6 +71,7 @@ module.exports = { 'prettier', 'react', 'file-progress', + 'lodash', 'theme-colors', 'translation-vars', ], @@ -241,6 +242,7 @@ module.exports = { 'jsx-a11y/anchor-is-valid': 1, 'jsx-a11y/click-events-have-key-events': 0, // re-enable up for discussion 'jsx-a11y/mouse-events-have-key-events': 0, // re-enable up for discussion + 'lodash/import-scope': [2, 'member'], 'new-cap': 0, 'no-bitwise': 0, 'no-continue': 0, diff --git a/superset-frontend/package-lock.json b/superset-frontend/package-lock.json index c96049ea46..11df4c044a 100644 --- a/superset-frontend/package-lock.json +++ b/superset-frontend/package-lock.json @@ -224,6 +224,7 @@ "eslint-plugin-jest": "^24.7.0", "eslint-plugin-jest-dom": "^3.6.5", "eslint-plugin-jsx-a11y": "^6.4.1", + "eslint-plugin-lodash": "^7.4.0", "eslint-plugin-no-only-tests": "^2.4.0", "eslint-plugin-prettier": "^4.0.0", "eslint-plugin-react": "^7.22.0", @@ -31363,6 +31364,21 @@ "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", "dev": true }, + "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-no-only-tests": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/eslint-plugin-no-only-tests/-/eslint-plugin-no-only-tests-2.4.0.tgz", @@ -89302,6 +89318,15 @@ } } }, + "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, + "requires": { + "lodash": "^4.17.21" + } + }, "eslint-plugin-no-only-tests": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/eslint-plugin-no-only-tests/-/eslint-plugin-no-only-tests-2.4.0.tgz", diff --git a/superset-frontend/package.json b/superset-frontend/package.json index 5995cd7324..53fc2466e4 100644 --- a/superset-frontend/package.json +++ b/superset-frontend/package.json @@ -290,6 +290,7 @@ "eslint-plugin-jest": "^24.7.0", "eslint-plugin-jest-dom": "^3.6.5", "eslint-plugin-jsx-a11y": "^6.4.1", + "eslint-plugin-lodash": "^7.4.0", "eslint-plugin-no-only-tests": "^2.4.0", "eslint-plugin-prettier": "^4.0.0", "eslint-plugin-react": "^7.22.0", diff --git a/superset-frontend/packages/generator-superset/generators/plugin-chart/index.js b/superset-frontend/packages/generator-superset/generators/plugin-chart/index.js index d704150554..b30f7f80a8 100644 --- a/superset-frontend/packages/generator-superset/generators/plugin-chart/index.js +++ b/superset-frontend/packages/generator-superset/generators/plugin-chart/index.js @@ -20,7 +20,14 @@ /* eslint-disable sort-keys */ const Generator = require('yeoman-generator'); -const _ = require('lodash'); +// eslint-disable-next-line lodash/import-scope +const kebabCase = require('lodash/kebabCase'); +// eslint-disable-next-line lodash/import-scope +const startCase = require('lodash/startCase'); +// eslint-disable-next-line lodash/import-scope +const camelCase = require('lodash/camelCase'); +// eslint-disable-next-line lodash/import-scope +const upperFirst = require('lodash/upperFirst'); module.exports = class extends Generator { async prompting() { @@ -32,15 +39,15 @@ module.exports = class extends Generator { name: 'packageName', message: 'Package name:', // Default to current folder name, e.g. superset-plugin-chart-hello-world - default: _.kebabCase(this.appname), + default: kebabCase(this.appname), }, { type: 'input', name: 'pluginName', message: 'Plugin name:', // Hello World - default: _.startCase( - _.camelCase(this.appname.replace('superset plugin chart', '').trim()), + default: startCase( + camelCase(this.appname.replace('superset plugin chart', '').trim()), ), }, { @@ -48,7 +55,7 @@ module.exports = class extends Generator { name: 'description', message: 'Description:', // Superset Plugin Chart Hello World - default: _.upperFirst(_.startCase(this.appname)), + default: upperFirst(startCase(this.appname)), }, { type: 'list', @@ -70,7 +77,7 @@ module.exports = class extends Generator { writing() { // SupersetPluginChartHelloWorld - const packageLabel = _.upperFirst(_.camelCase(this.answers.packageName)); + const packageLabel = upperFirst(camelCase(this.answers.packageName)); const params = { ...this.answers, diff --git a/superset-frontend/packages/superset-ui-core/src/query/normalizeOrderBy.ts b/superset-frontend/packages/superset-ui-core/src/query/normalizeOrderBy.ts index e38e682abb..b07338781c 100644 --- a/superset-frontend/packages/superset-ui-core/src/query/normalizeOrderBy.ts +++ b/superset-frontend/packages/superset-ui-core/src/query/normalizeOrderBy.ts @@ -16,8 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import isEmpty from 'lodash/isEmpty'; -import isBoolean from 'lodash/isBoolean'; +import { isEmpty, isBoolean } from 'lodash'; import { QueryObject } from './types'; diff --git a/superset-frontend/packages/superset-ui-core/src/query/normalizeTimeColumn.ts b/superset-frontend/packages/superset-ui-core/src/query/normalizeTimeColumn.ts index 5fb9590c68..33c27f2337 100644 --- a/superset-frontend/packages/superset-ui-core/src/query/normalizeTimeColumn.ts +++ b/superset-frontend/packages/superset-ui-core/src/query/normalizeTimeColumn.ts @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import omit from 'lodash/omit'; +import { omit } from 'lodash'; import { AdhocColumn, diff --git a/superset-frontend/packages/superset-ui-core/src/utils/convertKeysToCamelCase.ts b/superset-frontend/packages/superset-ui-core/src/utils/convertKeysToCamelCase.ts index 88dcbe1d85..fb39add609 100644 --- a/superset-frontend/packages/superset-ui-core/src/utils/convertKeysToCamelCase.ts +++ b/superset-frontend/packages/superset-ui-core/src/utils/convertKeysToCamelCase.ts @@ -17,9 +17,7 @@ * under the License. */ -import camelCase from 'lodash/camelCase'; -import isPlainObject from 'lodash/isPlainObject'; -import mapKeys from 'lodash/mapKeys'; +import { camelCase, isPlainObject, mapKeys } from 'lodash'; export default function convertKeysToCamelCase(object: T) { if (object === null || object === undefined) { diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Gauge/transformProps.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Gauge/transformProps.ts index f32993b1df..269e2a8a18 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Gauge/transformProps.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Gauge/transformProps.ts @@ -28,7 +28,7 @@ import { import { EChartsCoreOption, GaugeSeriesOption } from 'echarts'; import { GaugeDataItemOption } from 'echarts/types/src/chart/gauge/GaugeSeries'; import { CallbackDataParams } from 'echarts/types/src/util/types'; -import range from 'lodash/range'; +import { range } from 'lodash'; import { parseNumbersList } from '../utils/controls'; import { DEFAULT_FORM_DATA as DEFAULT_GAUGE_FORM_DATA, diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/utils/treeBuilder.ts b/superset-frontend/plugins/plugin-chart-echarts/src/utils/treeBuilder.ts index 97916997d4..cda78da93a 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/utils/treeBuilder.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/utils/treeBuilder.ts @@ -17,7 +17,7 @@ * under the License. */ import { DataRecord, DataRecordValue } from '@superset-ui/core'; -import _ from 'lodash'; +import { groupBy as _groupBy, isNumber, transform } from 'lodash'; export type TreeNode = { name: DataRecordValue; @@ -28,7 +28,7 @@ export type TreeNode = { }; function getMetricValue(datum: DataRecord, metric: string) { - return _.isNumber(datum[metric]) ? (datum[metric] as number) : 0; + return isNumber(datum[metric]) ? (datum[metric] as number) : 0; } export function treeBuilder( @@ -38,8 +38,8 @@ export function treeBuilder( secondaryMetric?: string, ): TreeNode[] { const [curGroupBy, ...restGroupby] = groupBy; - const curData = _.groupBy(data, curGroupBy); - return _.transform( + const curData = _groupBy(data, curGroupBy); + return transform( curData, (result, value, key) => { const name = curData[key][0][curGroupBy]!; diff --git a/superset-frontend/src/SqlLab/actions/sqlLab.js b/superset-frontend/src/SqlLab/actions/sqlLab.js index 567d3383d7..2ee82b1552 100644 --- a/superset-frontend/src/SqlLab/actions/sqlLab.js +++ b/superset-frontend/src/SqlLab/actions/sqlLab.js @@ -24,8 +24,7 @@ import { t, isFeatureEnabled, } from '@superset-ui/core'; -import invert from 'lodash/invert'; -import mapKeys from 'lodash/mapKeys'; +import { invert, mapKeys } from 'lodash'; import { now } from 'src/utils/dates'; import { diff --git a/superset-frontend/src/SqlLab/components/App/index.jsx b/superset-frontend/src/SqlLab/components/App/index.jsx index aab4e78d4f..b830454e19 100644 --- a/superset-frontend/src/SqlLab/components/App/index.jsx +++ b/superset-frontend/src/SqlLab/components/App/index.jsx @@ -22,7 +22,7 @@ import { bindActionCreators } from 'redux'; import { connect } from 'react-redux'; import { Redirect } from 'react-router-dom'; import { css, styled, t } from '@superset-ui/core'; -import throttle from 'lodash/throttle'; +import { throttle } from 'lodash'; import { LOCALSTORAGE_MAX_USAGE_KB, LOCALSTORAGE_WARNING_THRESHOLD, diff --git a/superset-frontend/src/SqlLab/components/SqlEditor/index.tsx b/superset-frontend/src/SqlLab/components/SqlEditor/index.tsx index 0881434487..e09f0c2889 100644 --- a/superset-frontend/src/SqlLab/components/SqlEditor/index.tsx +++ b/superset-frontend/src/SqlLab/components/SqlEditor/index.tsx @@ -44,8 +44,7 @@ import { } from '@superset-ui/core'; import type { QueryEditor, SqlLabRootState } from 'src/SqlLab/types'; import type { DatabaseObject } from 'src/features/databases/types'; -import debounce from 'lodash/debounce'; -import throttle from 'lodash/throttle'; +import { debounce, throttle, isBoolean, isEmpty } from 'lodash'; import Modal from 'src/components/Modal'; import Mousetrap from 'mousetrap'; import Button from 'src/components/Button'; @@ -93,7 +92,6 @@ import { } from 'src/utils/localStorageHelpers'; import { EmptyStateBig } from 'src/components/EmptyState'; import getBootstrapData from 'src/utils/getBootstrapData'; -import { isBoolean, isEmpty } from 'lodash'; import TemplateParamsEditor from '../TemplateParamsEditor'; import SouthPane from '../SouthPane'; import SaveQuery, { QueryPayload } from '../SaveQuery'; diff --git a/superset-frontend/src/SqlLab/components/TabbedSqlEditors/index.jsx b/superset-frontend/src/SqlLab/components/TabbedSqlEditors/index.jsx index 166cce18f9..35479c48b5 100644 --- a/superset-frontend/src/SqlLab/components/TabbedSqlEditors/index.jsx +++ b/superset-frontend/src/SqlLab/components/TabbedSqlEditors/index.jsx @@ -17,7 +17,7 @@ * under the License. */ import React from 'react'; -import pick from 'lodash/pick'; +import { pick } from 'lodash'; import PropTypes from 'prop-types'; import { EditableTabs } from 'src/components/Tabs'; import { connect } from 'react-redux'; diff --git a/superset-frontend/src/SqlLab/hooks/useQueryEditor/index.ts b/superset-frontend/src/SqlLab/hooks/useQueryEditor/index.ts index 89301716c0..4d0e0c984b 100644 --- a/superset-frontend/src/SqlLab/hooks/useQueryEditor/index.ts +++ b/superset-frontend/src/SqlLab/hooks/useQueryEditor/index.ts @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import pick from 'lodash/pick'; +import { pick } from 'lodash'; import { shallowEqual, useSelector } from 'react-redux'; import { SqlLabRootState, QueryEditor } from 'src/SqlLab/types'; diff --git a/superset-frontend/src/SqlLab/utils/reduxStateToLocalStorageHelper.js b/superset-frontend/src/SqlLab/utils/reduxStateToLocalStorageHelper.js index f82711362d..5b7a31b304 100644 --- a/superset-frontend/src/SqlLab/utils/reduxStateToLocalStorageHelper.js +++ b/superset-frontend/src/SqlLab/utils/reduxStateToLocalStorageHelper.js @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import pick from 'lodash/pick'; +import { pick } from 'lodash'; import { tableApiUtil } from 'src/hooks/apiResources/tables'; import { BYTES_PER_CHAR, diff --git a/superset-frontend/src/components/DropdownButton/index.tsx b/superset-frontend/src/components/DropdownButton/index.tsx index a35e66b5d7..ba40b4a4af 100644 --- a/superset-frontend/src/components/DropdownButton/index.tsx +++ b/superset-frontend/src/components/DropdownButton/index.tsx @@ -19,7 +19,7 @@ import React, { ReactNode } from 'react'; import { AntdDropdown, AntdTooltip } from 'src/components'; import { styled } from '@superset-ui/core'; -import kebabCase from 'lodash/kebabCase'; +import { kebabCase } from 'lodash'; const StyledDropdownButton = styled.div` .ant-btn-group { diff --git a/superset-frontend/src/components/Icons/index.tsx b/superset-frontend/src/components/Icons/index.tsx index 29ccb1dd36..fcf03df25b 100644 --- a/superset-frontend/src/components/Icons/index.tsx +++ b/superset-frontend/src/components/Icons/index.tsx @@ -18,7 +18,7 @@ */ import React from 'react'; -import _ from 'lodash'; +import { startCase } from 'lodash'; import AntdEnhancedIcons from './AntdEnhanced'; import Icon from './Icon'; import IconType from './IconType'; @@ -168,7 +168,7 @@ const IconFileNames = [ const iconOverrides: Record> = {}; IconFileNames.forEach(fileName => { - const keyName = _.startCase(fileName).replace(/ /g, ''); + const keyName = startCase(fileName).replace(/ /g, ''); iconOverrides[keyName] = (props: IconType) => ( ); diff --git a/superset-frontend/src/components/Select/AsyncSelect.tsx b/superset-frontend/src/components/Select/AsyncSelect.tsx index 015a12cb96..d41c87f047 100644 --- a/superset-frontend/src/components/Select/AsyncSelect.tsx +++ b/superset-frontend/src/components/Select/AsyncSelect.tsx @@ -31,8 +31,7 @@ import React, { } from 'react'; import { ensureIsArray, t, usePrevious } from '@superset-ui/core'; import { LabeledValue as AntdLabeledValue } from 'antd/lib/select'; -import debounce from 'lodash/debounce'; -import { isEqual, uniq } from 'lodash'; +import { debounce, isEqual, uniq } from 'lodash'; import Icons from 'src/components/Icons'; import { getClientErrorObject } from 'src/utils/getClientErrorObject'; import { FAST_DEBOUNCE, SLOW_DEBOUNCE } from 'src/constants'; diff --git a/superset-frontend/src/components/TableView/TableView.tsx b/superset-frontend/src/components/TableView/TableView.tsx index 5bf3933636..e3a081a1d0 100644 --- a/superset-frontend/src/components/TableView/TableView.tsx +++ b/superset-frontend/src/components/TableView/TableView.tsx @@ -17,7 +17,7 @@ * under the License. */ import React, { useEffect, useRef } from 'react'; -import isEqual from 'lodash/isEqual'; +import { isEqual } from 'lodash'; import { styled, t } from '@superset-ui/core'; import { useFilters, usePagination, useSortBy, useTable } from 'react-table'; import { Empty } from 'src/components'; diff --git a/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx b/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx index 5f03eeaf1a..ba5fee6dd1 100644 --- a/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx +++ b/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx @@ -28,7 +28,7 @@ import { useComponentDidUpdate, } from '@superset-ui/core'; import { ParentSize } from '@visx/responsive'; -import pick from 'lodash/pick'; +import { pick } from 'lodash'; import Tabs from 'src/components/Tabs'; import DashboardGrid from 'src/dashboard/containers/DashboardGrid'; import { diff --git a/superset-frontend/src/dashboard/components/SyncDashboardState/index.tsx b/superset-frontend/src/dashboard/components/SyncDashboardState/index.tsx index b25d243292..fd252e83c6 100644 --- a/superset-frontend/src/dashboard/components/SyncDashboardState/index.tsx +++ b/superset-frontend/src/dashboard/components/SyncDashboardState/index.tsx @@ -17,7 +17,7 @@ * under the License. */ import React, { useEffect } from 'react'; -import pick from 'lodash/pick'; +import { pick } from 'lodash'; import { shallowEqual, useSelector } from 'react-redux'; import { DashboardContextForExplore } from 'src/types/DashboardContextForExplore'; import { diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/Vertical.tsx b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/Vertical.tsx index 998c460dfc..cb6da807d6 100644 --- a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/Vertical.tsx +++ b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/Vertical.tsx @@ -18,7 +18,7 @@ */ /* eslint-disable no-param-reassign */ -import throttle from 'lodash/throttle'; +import { throttle } from 'lodash'; import React, { useEffect, useState, diff --git a/superset-frontend/src/dashboard/util/charts/useChartIds.ts b/superset-frontend/src/dashboard/util/charts/useChartIds.ts index 575c94d370..c95327a94a 100644 --- a/superset-frontend/src/dashboard/util/charts/useChartIds.ts +++ b/superset-frontend/src/dashboard/util/charts/useChartIds.ts @@ -17,7 +17,7 @@ * under the License. */ import { useSelector } from 'react-redux'; -import isEqual from 'lodash/isEqual'; +import { isEqual } from 'lodash'; import { createSelector } from '@reduxjs/toolkit'; import { RootState } from 'src/dashboard/types'; import { useMemoCompare } from 'src/hooks/useMemoCompare'; diff --git a/superset-frontend/src/explore/components/DataTableControl/index.tsx b/superset-frontend/src/explore/components/DataTableControl/index.tsx index 2deddf664e..b98a495c0a 100644 --- a/superset-frontend/src/explore/components/DataTableControl/index.tsx +++ b/superset-frontend/src/explore/components/DataTableControl/index.tsx @@ -29,7 +29,7 @@ import { } from '@superset-ui/core'; import { Global } from '@emotion/react'; import { Column } from 'react-table'; -import debounce from 'lodash/debounce'; +import { debounce } from 'lodash'; import { Space } from 'src/components'; import { Input } from 'src/components/Input'; import { diff --git a/superset-frontend/src/explore/components/controls/DndColumnSelectControl/useResizeButton.tsx b/superset-frontend/src/explore/components/controls/DndColumnSelectControl/useResizeButton.tsx index 71d5047c6a..e6976ab963 100644 --- a/superset-frontend/src/explore/components/controls/DndColumnSelectControl/useResizeButton.tsx +++ b/superset-frontend/src/explore/components/controls/DndColumnSelectControl/useResizeButton.tsx @@ -18,7 +18,7 @@ */ import React, { useCallback, useEffect, useState } from 'react'; -import throttle from 'lodash/throttle'; +import { throttle } from 'lodash'; import { POPOVER_INITIAL_HEIGHT, POPOVER_INITIAL_WIDTH, diff --git a/superset-frontend/src/explore/components/controls/TextControl/index.tsx b/superset-frontend/src/explore/components/controls/TextControl/index.tsx index f15bd95c1b..c10a796c11 100644 --- a/superset-frontend/src/explore/components/controls/TextControl/index.tsx +++ b/superset-frontend/src/explore/components/controls/TextControl/index.tsx @@ -18,7 +18,7 @@ */ import React from 'react'; import { legacyValidateNumber, legacyValidateInteger } from '@superset-ui/core'; -import debounce from 'lodash/debounce'; +import { debounce } from 'lodash'; import { FAST_DEBOUNCE } from 'src/constants'; import ControlHeader from 'src/explore/components/ControlHeader'; import { Input } from 'src/components/Input'; diff --git a/superset-frontend/src/explore/controlUtils/getFormDataWithDashboardContext.ts b/superset-frontend/src/explore/controlUtils/getFormDataWithDashboardContext.ts index 1f12d3f6f7..3018491ef8 100644 --- a/superset-frontend/src/explore/controlUtils/getFormDataWithDashboardContext.ts +++ b/superset-frontend/src/explore/controlUtils/getFormDataWithDashboardContext.ts @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import isEqual from 'lodash/isEqual'; +import { isEqual } from 'lodash'; import { AdhocFilter, ensureIsArray, diff --git a/superset-frontend/src/filters/components/Select/SelectFilterPlugin.tsx b/superset-frontend/src/filters/components/Select/SelectFilterPlugin.tsx index a4b9f5b05e..e25eb03c4a 100644 --- a/superset-frontend/src/filters/components/Select/SelectFilterPlugin.tsx +++ b/superset-frontend/src/filters/components/Select/SelectFilterPlugin.tsx @@ -31,7 +31,7 @@ import { tn, } from '@superset-ui/core'; import { LabeledValue as AntdLabeledValue } from 'antd/lib/select'; -import debounce from 'lodash/debounce'; +import { debounce } from 'lodash'; import { useImmerReducer } from 'use-immer'; import { Select } from 'src/components'; import { SLOW_DEBOUNCE } from 'src/constants'; diff --git a/superset-frontend/src/utils/downloadAsImage.ts b/superset-frontend/src/utils/downloadAsImage.ts index a6f50926bc..63b65cb60b 100644 --- a/superset-frontend/src/utils/downloadAsImage.ts +++ b/superset-frontend/src/utils/downloadAsImage.ts @@ -18,7 +18,7 @@ */ import { SyntheticEvent } from 'react'; import domToImage from 'dom-to-image-more'; -import kebabCase from 'lodash/kebabCase'; +import { kebabCase } from 'lodash'; import { t, supersetTheme } from '@superset-ui/core'; import { addWarningToast } from 'src/components/MessageToasts/actions'; diff --git a/superset-frontend/src/utils/downloadAsPdf.ts b/superset-frontend/src/utils/downloadAsPdf.ts index eebca66b8b..5095a75d26 100644 --- a/superset-frontend/src/utils/downloadAsPdf.ts +++ b/superset-frontend/src/utils/downloadAsPdf.ts @@ -18,7 +18,7 @@ */ import { SyntheticEvent } from 'react'; import domToPdf from 'dom-to-pdf'; -import kebabCase from 'lodash/kebabCase'; +import { kebabCase } from 'lodash'; import { logging, t } from '@superset-ui/core'; import { addWarningToast } from 'src/components/MessageToasts/actions'; diff --git a/superset-websocket/.eslintrc.js b/superset-websocket/.eslintrc.js index f1aaa4512c..c60fd24d67 100644 --- a/superset-websocket/.eslintrc.js +++ b/superset-websocket/.eslintrc.js @@ -25,6 +25,7 @@ module.exports = { }, plugins: [ '@typescript-eslint', + 'lodash', ], extends: [ 'eslint:recommended', @@ -32,6 +33,7 @@ module.exports = { 'prettier', ], rules: { + "lodash/import-scope": [2, "member"], "@typescript-eslint/explicit-module-boundary-types": 0, "@typescript-eslint/no-var-requires": 0, }, diff --git a/superset-websocket/package-lock.json b/superset-websocket/package-lock.json index aaeff29d0e..e787a295fb 100644 --- a/superset-websocket/package-lock.json +++ b/superset-websocket/package-lock.json @@ -31,6 +31,7 @@ "@typescript-eslint/parser": "^5.62.0", "eslint": "^8.56.0", "eslint-config-prettier": "^9.1.0", + "eslint-plugin-lodash": "^7.4.0", "jest": "^27.3.1", "prettier": "^3.0.3", "ts-jest": "^27.0.7", @@ -2670,6 +2671,21 @@ "eslint": ">=7.0.0" } }, + "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-scope": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", @@ -8347,6 +8363,15 @@ "dev": true, "requires": {} }, + "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, + "requires": { + "lodash": "^4.17.21" + } + }, "eslint-scope": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", diff --git a/superset-websocket/package.json b/superset-websocket/package.json index 301aad75d1..ae512d8779 100644 --- a/superset-websocket/package.json +++ b/superset-websocket/package.json @@ -38,6 +38,7 @@ "@typescript-eslint/parser": "^5.62.0", "eslint": "^8.56.0", "eslint-config-prettier": "^9.1.0", + "eslint-plugin-lodash": "^7.4.0", "jest": "^27.3.1", "prettier": "^3.0.3", "ts-jest": "^27.0.7", diff --git a/superset-websocket/src/config.ts b/superset-websocket/src/config.ts index 7c25048928..0c6dc7440d 100644 --- a/superset-websocket/src/config.ts +++ b/superset-websocket/src/config.ts @@ -17,7 +17,7 @@ * under the License. */ -import * as _ from 'lodash'; +import { merge as _merge } from 'lodash'; export interface RedisConfig { port: number; @@ -142,6 +142,6 @@ function applyEnvOverrides(config: ConfigType): ConfigType { } export function buildConfig(): ConfigType { - const config = _.merge(defaultConfig(), configFromFile()); + const config = _merge(defaultConfig(), configFromFile()); return applyEnvOverrides(config); }