From 7b75aab9afcecc35e89a2a0ba357301dcdd32983 Mon Sep 17 00:00:00 2001 From: afc163 Date: Thu, 19 Jun 2025 14:53:18 +0800 Subject: [PATCH] chore: fix eslint errors and warnings (#54137) --- .dumi/pages/index/components/Theme/index.tsx | 1 - .dumi/pages/theme-editor/index.tsx | 1 - .dumi/theme/common/CodePreview.tsx | 1 - .dumi/theme/common/SemanticPreview.tsx | 1 - .dumi/theme/slots/Header/index.tsx | 1 - components/_util/warning.ts | 5 +++-- components/date-picker/demo/external-panel.tsx | 2 +- components/message/index.tsx | 16 ++++++++-------- components/notification/index.tsx | 16 ++++++++-------- docs/blog/css-tricks/condition.tsx | 1 - docs/blog/css-tricks/scope.tsx | 1 - package.json | 2 +- 12 files changed, 21 insertions(+), 27 deletions(-) diff --git a/.dumi/pages/index/components/Theme/index.tsx b/.dumi/pages/index/components/Theme/index.tsx index 27992dc38c..0f699775a5 100644 --- a/.dumi/pages/index/components/Theme/index.tsx +++ b/.dumi/pages/index/components/Theme/index.tsx @@ -1,4 +1,3 @@ -/* eslint-disable react-hooks-extra/no-direct-set-state-in-use-effect */ import * as React from 'react'; import { defaultAlgorithm, defaultTheme } from '@ant-design/compatible'; import { FastColor } from '@ant-design/fast-color'; diff --git a/.dumi/pages/theme-editor/index.tsx b/.dumi/pages/theme-editor/index.tsx index a104cd5ac5..06094b9700 100644 --- a/.dumi/pages/theme-editor/index.tsx +++ b/.dumi/pages/theme-editor/index.tsx @@ -1,4 +1,3 @@ -/* eslint-disable react-hooks-extra/no-direct-set-state-in-use-effect */ import React, { Suspense, useEffect } from 'react'; import { App, Button, Skeleton } from 'antd'; import { enUS, zhCN } from 'antd-token-previewer'; diff --git a/.dumi/theme/common/CodePreview.tsx b/.dumi/theme/common/CodePreview.tsx index 3f7347120b..41ddabf49a 100644 --- a/.dumi/theme/common/CodePreview.tsx +++ b/.dumi/theme/common/CodePreview.tsx @@ -1,4 +1,3 @@ -/* eslint-disable react-hooks-extra/no-direct-set-state-in-use-effect */ import type { ComponentProps } from 'react'; import React, { useEffect, useMemo } from 'react'; import { Button, Tabs, Typography } from 'antd'; diff --git a/.dumi/theme/common/SemanticPreview.tsx b/.dumi/theme/common/SemanticPreview.tsx index 80596b65d5..0435ec76d2 100644 --- a/.dumi/theme/common/SemanticPreview.tsx +++ b/.dumi/theme/common/SemanticPreview.tsx @@ -1,4 +1,3 @@ -/* eslint-disable react-hooks-extra/no-direct-set-state-in-use-effect */ import React from 'react'; import { InfoCircleOutlined, PushpinOutlined } from '@ant-design/icons'; import get from 'rc-util/lib/utils/get'; diff --git a/.dumi/theme/slots/Header/index.tsx b/.dumi/theme/slots/Header/index.tsx index 5a12d7267d..46435ef687 100644 --- a/.dumi/theme/slots/Header/index.tsx +++ b/.dumi/theme/slots/Header/index.tsx @@ -1,4 +1,3 @@ -/* eslint-disable react-hooks-extra/no-direct-set-state-in-use-effect */ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { GithubOutlined, MenuOutlined } from '@ant-design/icons'; import { Alert, Button, Col, ConfigProvider, Popover, Row, Select, Tooltip } from 'antd'; diff --git a/components/_util/warning.ts b/components/_util/warning.ts index c792e39a3a..5b5a5d9dc9 100644 --- a/components/_util/warning.ts +++ b/components/_util/warning.ts @@ -12,9 +12,9 @@ export function resetWarned() { type Warning = (valid: boolean, component: string, message?: string) => void; -let warning: Warning = noop; +let _warning: Warning = noop; if (process.env.NODE_ENV !== 'production') { - warning = (valid, component, message) => { + _warning = (valid, component, message) => { rcWarning(valid, `[antd: ${component}] ${message}`); // StrictMode will inject console which will not throw warning in React 17. @@ -23,6 +23,7 @@ if (process.env.NODE_ENV !== 'production') { } }; } +const warning = _warning; type BaseTypeWarning = ( valid: boolean, diff --git a/components/date-picker/demo/external-panel.tsx b/components/date-picker/demo/external-panel.tsx index f784126d6c..d464a7894c 100644 --- a/components/date-picker/demo/external-panel.tsx +++ b/components/date-picker/demo/external-panel.tsx @@ -7,7 +7,7 @@ const DatePickerDemo: React.FC = () => { const [visible, setVisible] = React.useState(false); const [panelVisible, setPanelVisible] = React.useState(false); - const [date, setDate] = React.useState(dayjs()); + const [date, setDate] = React.useState(() => dayjs()); return ( { // ============================================================================== const noop = () => {}; -/** @internal Only Work in test env */ -export let actWrapper: (wrapper: any) => void = noop; - +let _actWrapper: (wrapper: any) => void = noop; if (process.env.NODE_ENV === 'test') { - actWrapper = (wrapper) => { + _actWrapper = (wrapper) => { act = wrapper; }; } +const actWrapper = _actWrapper; +export { actWrapper }; -/** @internal Only Work in test env */ -export let actDestroy = noop; - +let _actDestroy = noop; if (process.env.NODE_ENV === 'test') { - actDestroy = () => { + _actDestroy = () => { message = null; }; } +const actDestroy = _actDestroy; +export { actDestroy }; export default staticMethods; diff --git a/components/notification/index.tsx b/components/notification/index.tsx index 6f9ffefef2..9dd178bf8b 100755 --- a/components/notification/index.tsx +++ b/components/notification/index.tsx @@ -256,22 +256,22 @@ methods.forEach((type: keyof NoticeMethods) => { // ============================================================================== const noop = () => {}; -/** @internal Only Work in test env */ -export let actWrapper: (wrapper: any) => void = noop; - +let _actWrapper: (wrapper: any) => void = noop; if (process.env.NODE_ENV === 'test') { - actWrapper = (wrapper) => { + _actWrapper = (wrapper) => { act = wrapper; }; } +const actWrapper = _actWrapper; +export { actWrapper }; -/** @internal Only Work in test env */ -export let actDestroy = noop; - +let _actDestroy = noop; if (process.env.NODE_ENV === 'test') { - actDestroy = () => { + _actDestroy = () => { notification = null; }; } +const actDestroy = _actDestroy; +export { actDestroy }; export default staticMethods; diff --git a/docs/blog/css-tricks/condition.tsx b/docs/blog/css-tricks/condition.tsx index 946e553d7c..56844de421 100644 --- a/docs/blog/css-tricks/condition.tsx +++ b/docs/blog/css-tricks/condition.tsx @@ -1,4 +1,3 @@ -/* eslint-disable react-dom/no-dangerously-set-innerhtml */ import React from 'react'; import { Flex } from 'antd'; diff --git a/docs/blog/css-tricks/scope.tsx b/docs/blog/css-tricks/scope.tsx index 5486186681..9e34859830 100644 --- a/docs/blog/css-tricks/scope.tsx +++ b/docs/blog/css-tricks/scope.tsx @@ -1,4 +1,3 @@ -/* eslint-disable react-dom/no-dangerously-set-innerhtml */ import React from 'react'; import { Flex } from 'antd'; diff --git a/package.json b/package.json index b5315196b7..1ef20b4f48 100644 --- a/package.json +++ b/package.json @@ -164,7 +164,7 @@ "@ant-design/happy-work-theme": "^1.0.0", "@ant-design/tools": "^18.0.3", "@ant-design/v5-patch-for-react-19": "^1.0.2", - "@antfu/eslint-config": "^4.0.0", + "@antfu/eslint-config": "^4.15.0", "@antv/g6": "^4.8.24", "@biomejs/biome": "^2.0.0", "@codecov/webpack-plugin": "^1.4.0",