chore: unified code style (#55406)

This commit is contained in:
lijianan
2025-10-22 19:31:22 +08:00
committed by GitHub
parent 2131d9f7e2
commit ec44482a1b
12 changed files with 54 additions and 21 deletions

View File

@@ -20,7 +20,9 @@
const isEnabled = always || enabledCondition.every(Boolean); const isEnabled = always || enabledCondition.every(Boolean);
if (!isEnabled) return; if (!isEnabled) {
return;
}
const prefixCls = 'antd-mirror-notify'; const prefixCls = 'antd-mirror-notify';
const primaryColor = '#1677ff'; const primaryColor = '#1677ff';

View File

@@ -39,7 +39,9 @@ jobs:
const now = new Date(); const now = new Date();
for (const issue of issues) { for (const issue of issues) {
if (issue.pull_request) continue; if (issue.pull_request) {
continue;
}
const updatedAt = new Date(issue.updated_at); const updatedAt = new Date(issue.updated_at);
const daysInactive = (now - updatedAt) / (1000 * 60 * 60 * 24); const daysInactive = (now - updatedAt) / (1000 * 60 * 60 * 24);

View File

@@ -176,7 +176,9 @@ const Alert = React.forwardRef<AlertRef, AlertProps>((props, ref) => {
// closeable when closeText or closeIcon is assigned // closeable when closeText or closeIcon is assigned
const isClosable = React.useMemo<boolean>(() => { const isClosable = React.useMemo<boolean>(() => {
if (typeof closable === 'object' && closable.closeIcon) return true; if (typeof closable === 'object' && closable.closeIcon) {
return true;
}
if (closeText) { if (closeText) {
return true; return true;
} }

View File

@@ -65,8 +65,12 @@ const App: React.FC = () => {
}; };
const cellRender: CalendarProps<Dayjs>['cellRender'] = (current, info) => { const cellRender: CalendarProps<Dayjs>['cellRender'] = (current, info) => {
if (info.type === 'date') return dateCellRender(current); if (info.type === 'date') {
if (info.type === 'month') return monthCellRender(current); return dateCellRender(current);
}
if (info.type === 'month') {
return monthCellRender(current);
}
return info.originNode; return info.originNode;
}; };

View File

@@ -13,8 +13,12 @@ const PickerWithType = ({
type: PickerType; type: PickerType;
onChange: TimePickerProps['onChange'] | DatePickerProps['onChange']; onChange: TimePickerProps['onChange'] | DatePickerProps['onChange'];
}) => { }) => {
if (type === 'time') return <TimePicker onChange={onChange} />; if (type === 'time') {
if (type === 'date') return <DatePicker onChange={onChange} />; return <TimePicker onChange={onChange} />;
}
if (type === 'date') {
return <DatePicker onChange={onChange} />;
}
return <DatePicker picker={type} onChange={onChange} />; return <DatePicker picker={type} onChange={onChange} />;
}; };

View File

@@ -11,8 +11,9 @@ const formItemNameBlackList = ['parentNode'];
const defaultItemNamePrefixCls: string = 'form_item'; const defaultItemNamePrefixCls: string = 'form_item';
export function toArray<T>(candidate?: T | T[] | false): T[] { export function toArray<T>(candidate?: T | T[] | false): T[] {
if (candidate === undefined || candidate === false) return []; if (candidate === undefined || candidate === false) {
return [];
}
return Array.isArray(candidate) ? candidate : [candidate]; return Array.isArray(candidate) ? candidate : [candidate];
} }

View File

@@ -16,8 +16,9 @@ const App: React.FC = () => {
fetch(`https://api.github.com/search/users?q=${key}`) fetch(`https://api.github.com/search/users?q=${key}`)
.then((res) => res.json()) .then((res) => res.json())
.then(({ items = [] }) => { .then(({ items = [] }) => {
if (ref.current !== key) return; if (ref.current !== key) {
return;
}
setLoading(false); setLoading(false);
setUsers(items.slice(0, 10)); setUsers(items.slice(0, 10));
}); });

View File

@@ -39,7 +39,9 @@ const App: React.FC = () => {
}; };
const remove = (targetKey: TargetKey) => { const remove = (targetKey: TargetKey) => {
if (!items) return; if (!items) {
return;
}
const targetIndex = items.findIndex((item) => item.key === targetKey); const targetIndex = items.findIndex((item) => item.key === targetKey);
const newItems = items.filter((item) => item.key !== targetKey); const newItems = items.filter((item) => item.key !== targetKey);

View File

@@ -22,13 +22,23 @@ const TimelineItemList: React.FC<TimelineProps & { hashId: string; direction?: s
}) => { }) => {
const getPositionCls = (position: string, idx: number) => { const getPositionCls = (position: string, idx: number) => {
if (mode === 'alternate') { if (mode === 'alternate') {
if (position === 'right') return `${prefixCls}-item-right`; if (position === 'right') {
if (position === 'left') return `${prefixCls}-item-left`; return `${prefixCls}-item-right`;
}
if (position === 'left') {
return `${prefixCls}-item-left`;
}
return idx % 2 === 0 ? `${prefixCls}-item-left` : `${prefixCls}-item-right`; return idx % 2 === 0 ? `${prefixCls}-item-left` : `${prefixCls}-item-right`;
} }
if (mode === 'left') return `${prefixCls}-item-left`; if (mode === 'left') {
if (mode === 'right') return `${prefixCls}-item-right`; return `${prefixCls}-item-left`;
if (position === 'right') return `${prefixCls}-item-right`; }
if (mode === 'right') {
return `${prefixCls}-item-right`;
}
if (position === 'right') {
return `${prefixCls}-item-right`;
}
return ''; return '';
}; };
const mergedItems = [...(items || [])]; const mergedItems = [...(items || [])];

View File

@@ -76,8 +76,9 @@ const Editable: React.FC<EditableProps> = (props) => {
const onKeyDown: React.KeyboardEventHandler<HTMLTextAreaElement> = ({ keyCode }) => { const onKeyDown: React.KeyboardEventHandler<HTMLTextAreaElement> = ({ keyCode }) => {
// We don't record keyCode when IME is using // We don't record keyCode when IME is using
if (inComposition.current) return; if (inComposition.current) {
return;
}
lastKeyCode.current = keyCode; lastKeyCode.current = keyCode;
}; };

View File

@@ -249,7 +249,9 @@ export default function Page() {
queryClient.invalidateQueries({ queryKey: ['products'] }); queryClient.invalidateQueries({ queryKey: ['products'] });
}, },
}); });
if (productsQuery.isLoading) return null; if (productsQuery.isLoading) {
return null;
}
return ( return (
<div> <div>
<h1 className={styles.title}>Page products</h1> <h1 className={styles.title}>Page products</h1>

View File

@@ -249,7 +249,9 @@ export default function Page() {
queryClient.invalidateQueries({ queryKey: ['products'] }); queryClient.invalidateQueries({ queryKey: ['products'] });
}, },
}); });
if (productsQuery.isLoading) return null; if (productsQuery.isLoading) {
return null;
}
return ( return (
<div> <div>
<h1 className={styles.title}>Page products</h1> <h1 className={styles.title}>Page products</h1>