From d4d64923698bde87c40306f46e8b710b8fd005c2 Mon Sep 17 00:00:00 2001 From: lijianan <574980606@qq.com> Date: Wed, 4 Dec 2024 23:56:09 +0800 Subject: [PATCH] site: fix some eslint error (#51901) --- .../common/Color/ColorPaletteToolDark.tsx | 4 ++-- .dumi/theme/common/Color/Palette.tsx | 3 +++ .dumi/theme/common/JSONEditor/index.tsx | 18 +++++++++++------- .dumi/theme/common/styles/Demo.tsx | 11 ++++++----- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/.dumi/theme/common/Color/ColorPaletteToolDark.tsx b/.dumi/theme/common/Color/ColorPaletteToolDark.tsx index 7032c035d1..c74f75804b 100644 --- a/.dumi/theme/common/Color/ColorPaletteToolDark.tsx +++ b/.dumi/theme/common/Color/ColorPaletteToolDark.tsx @@ -1,7 +1,7 @@ import React, { useMemo, useState } from 'react'; import { Col, ColorPicker, Row } from 'antd'; -import { FormattedMessage } from 'dumi'; import type { Color } from 'antd/es/color-picker'; +import { FormattedMessage } from 'dumi'; import useLocale from '../../../hooks/useLocale'; import ColorPatterns from './ColorPatterns'; @@ -34,7 +34,7 @@ const ColorPaletteTool: React.FC = () => { setPrimaryColorInstance(color); }; - const handleChangeBackgroundColor = (_, hex: string) => { + const handleChangeBackgroundColor = (_: Color, hex: string) => { setBackgroundColor(hex); }; diff --git a/.dumi/theme/common/Color/Palette.tsx b/.dumi/theme/common/Color/Palette.tsx index bf0f8d35cf..f00c7b8c8d 100644 --- a/.dumi/theme/common/Color/Palette.tsx +++ b/.dumi/theme/common/Color/Palette.tsx @@ -5,6 +5,9 @@ import CopyToClipboard from 'react-copy-to-clipboard'; const rgbToHex = (rgbString: string): string => { const rgb = rgbString.match(/\d+/g); + if (!rgb) { + return ''; + } let r = parseInt(rgb[0], 10).toString(16); let g = parseInt(rgb[1], 10).toString(16); let b = parseInt(rgb[2], 10).toString(16); diff --git a/.dumi/theme/common/JSONEditor/index.tsx b/.dumi/theme/common/JSONEditor/index.tsx index 2d66f93cc9..73d11a8bc8 100644 --- a/.dumi/theme/common/JSONEditor/index.tsx +++ b/.dumi/theme/common/JSONEditor/index.tsx @@ -1,16 +1,20 @@ import React, { useEffect, useRef } from 'react'; -import type { JSONEditorPropsOptional } from 'vanilla-jsoneditor'; -import { JSONEditor, Mode } from 'vanilla-jsoneditor'; +import type { JsonEditor, JSONEditorPropsOptional } from 'vanilla-jsoneditor'; +import { createJSONEditor, Mode } from 'vanilla-jsoneditor'; const Editor: React.FC = (props) => { - const editorRef = useRef(null); + const editorRef = useRef(); const container = useRef(null); useEffect(() => { - editorRef.current = new JSONEditor({ - target: container.current, - props: { mode: Mode.text }, - }); + if (container.current) { + editorRef.current = createJSONEditor({ + target: container.current, + props: { + mode: Mode.text, + }, + }); + } return () => { editorRef.current?.destroy(); }; diff --git a/.dumi/theme/common/styles/Demo.tsx b/.dumi/theme/common/styles/Demo.tsx index d9d21ef6ed..912bd88afb 100644 --- a/.dumi/theme/common/styles/Demo.tsx +++ b/.dumi/theme/common/styles/Demo.tsx @@ -347,12 +347,13 @@ const GlobalDemoStyles: React.FC = () => { display: flex; align-items: center; column-gap: ${token.marginXS}px; + } - ${antCls}-btn { - opacity: 0.6; - &.icon-enabled { - background: ${token.colorFillSecondary}; - opacity: 1; + ${antCls}-btn { + opacity: 0.6; + &.icon-enabled { + background: ${token.colorFillSecondary}; + opacity: 1; ${iconCls} { color: ${token.colorTextBase}; font-weight: bold;