diff --git a/.eslintrc.js b/.eslintrc.js index 12e49328d2..ca15e66249 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -25,7 +25,16 @@ module.exports = { }, }, parser: '@typescript-eslint/parser', - plugins: ['react', '@babel', 'jest', '@typescript-eslint', 'react-hooks', 'unicorn', 'markdown'], + plugins: [ + 'react', + '@babel', + 'jest', + '@typescript-eslint', + 'react-hooks', + 'unicorn', + 'markdown', + 'lodash', + ], // https://github.com/typescript-eslint/typescript-eslint/issues/46#issuecomment-470486034 overrides: [ { @@ -156,6 +165,7 @@ module.exports = { 'react/no-unused-class-component-methods': 0, 'import/extensions': 0, 'import/no-cycle': 2, + 'lodash/import-scope': 2, 'import/no-extraneous-dependencies': [ 'error', { diff --git a/components/config-provider/__tests__/theme.test.tsx b/components/config-provider/__tests__/theme.test.tsx index d3c14df61c..dc691224be 100644 --- a/components/config-provider/__tests__/theme.test.tsx +++ b/components/config-provider/__tests__/theme.test.tsx @@ -1,10 +1,11 @@ -import { kebabCase } from 'lodash'; -import canUseDom from 'rc-util/lib/Dom/canUseDom'; import React from 'react'; +import kebabCase from 'lodash/kebabCase'; +import canUseDom from 'rc-util/lib/Dom/canUseDom'; + import ConfigProvider from '..'; import { InputNumber } from '../..'; -import { render } from '../../../tests/utils'; import { resetWarned } from '../../_util/warning'; +import { render } from '../../../tests/utils'; import theme from '../../theme'; import { useToken } from '../../theme/internal'; diff --git a/components/form/demo/custom-feedback-icons.tsx b/components/form/demo/custom-feedback-icons.tsx index 7af3c276a3..4719749dae 100644 --- a/components/form/demo/custom-feedback-icons.tsx +++ b/components/form/demo/custom-feedback-icons.tsx @@ -1,9 +1,8 @@ import React from 'react'; -import { uniqueId } from 'lodash'; - -import { createStyles, css } from 'antd-style'; import { AlertFilled, CloseSquareFilled } from '@ant-design/icons'; import { Button, Form, Input, Tooltip } from 'antd'; +import { createStyles, css } from 'antd-style'; +import uniqueId from 'lodash/uniqueId'; const useStyle = createStyles(() => ({ 'custom-feedback-icons': css` diff --git a/components/upload/__tests__/upload.test.tsx b/components/upload/__tests__/upload.test.tsx index 891c899c11..6e1d790dd5 100644 --- a/components/upload/__tests__/upload.test.tsx +++ b/components/upload/__tests__/upload.test.tsx @@ -1,13 +1,14 @@ -import { produce } from 'immer'; -import { cloneDeep } from 'lodash'; -import type { UploadRequestOption } from 'rc-upload/lib/interface'; import React, { useEffect, useRef } from 'react'; +import { produce } from 'immer'; +import cloneDeep from 'lodash/cloneDeep'; +import type { UploadRequestOption } from 'rc-upload/lib/interface'; + import type { RcFile, UploadFile, UploadProps } from '..'; import Upload from '..'; +import { resetWarned } from '../../_util/warning'; import mountTest from '../../../tests/shared/mountTest'; import rtlTest from '../../../tests/shared/rtlTest'; import { act, fireEvent, render, waitFakeTimer } from '../../../tests/utils'; -import { resetWarned } from '../../_util/warning'; import Form from '../../form'; import { getFileItem, isImageUrl, removeFileItem } from '../utils'; import { setup, teardown } from './mock'; diff --git a/package.json b/package.json index cffb89ad0a..a9392971f2 100644 --- a/package.json +++ b/package.json @@ -232,6 +232,7 @@ "eslint-plugin-import": "^2.28.0", "eslint-plugin-jest": "^27.0.1", "eslint-plugin-jsx-a11y": "^6.2.1", + "eslint-plugin-lodash": "^7.4.0", "eslint-plugin-markdown": "^3.0.0", "eslint-plugin-react": "^7.31.8", "eslint-plugin-react-hooks": "^4.1.2", diff --git a/scripts/generate-authors.ts b/scripts/generate-authors.ts index 0195abad01..648d40d320 100644 --- a/scripts/generate-authors.ts +++ b/scripts/generate-authors.ts @@ -1,6 +1,8 @@ import fs from 'fs'; import path from 'path'; -import _ from 'lodash'; +import remove from 'lodash/remove'; +import sortBy from 'lodash/sortBy'; +import unionBy from 'lodash/unionBy'; import simpleGit from 'simple-git'; const cwd = process.cwd(); @@ -18,7 +20,7 @@ const excludes = [ async function execute() { let { all } = await git.log(); - all = _.remove(all, ({ author_email: email }) => { + all = remove(all, ({ author_email: email }) => { for (let i = 0; i < excludes.length; i++) { const item = excludes[i]; if (email.includes(item)) { @@ -28,7 +30,7 @@ async function execute() { return true; }); - all = _.sortBy(_.unionBy(all, 'author_email'), 'author_name'); + all = sortBy(unionBy(all, 'author_email'), 'author_name'); fs.writeFileSync( path.join(cwd, 'contributors.json'), diff --git a/tests/shared/demoTest.tsx b/tests/shared/demoTest.tsx index 620bed701f..538a4a3c7e 100644 --- a/tests/shared/demoTest.tsx +++ b/tests/shared/demoTest.tsx @@ -1,15 +1,16 @@ /* eslint-disable react/jsx-no-constructed-context-values */ import path from 'path'; +import * as React from 'react'; import { createCache, StyleProvider } from '@ant-design/cssinjs'; import { globSync } from 'glob'; -import * as React from 'react'; +import kebabCase from 'lodash/kebabCase'; import { renderToString } from 'react-dom/server'; -import { kebabCase } from 'lodash'; + +import { resetWarned } from '../../components/_util/warning'; import { render } from '../utils'; import { TriggerMockContext } from './demoTestContext'; import { excludeWarning, isSafeWarning } from './excludeWarning'; import rootPropsTest from './rootPropsTest'; -import { resetWarned } from '../../components/_util/warning'; export { rootPropsTest };