mirror of
https://github.com/ant-design/ant-design.git
synced 2026-02-09 02:49:18 +08:00
chore: add namespace for Number api (#55107)
* chore: add namespace for Number api * fix * fix * Update biome.json Co-authored-by: thinkasany <480968828@qq.com> Signed-off-by: lijianan <574980606@qq.com> --------- Signed-off-by: lijianan <574980606@qq.com> Co-authored-by: thinkasany <480968828@qq.com>
This commit is contained in:
@@ -27,7 +27,12 @@ const BezierVisualizer = (props: BezierVisualizerProps) => {
|
||||
const controls = useMemo(() => {
|
||||
const m = RE.exec(value.toLowerCase().trim());
|
||||
if (m) {
|
||||
return m[1].split(',').map((v) => parseFloat(v.trim())) as [number, number, number, number];
|
||||
return m[1].split(',').map((v) => Number.parseFloat(v.trim())) as [
|
||||
number,
|
||||
number,
|
||||
number,
|
||||
number,
|
||||
];
|
||||
}
|
||||
return null;
|
||||
}, [value]);
|
||||
|
||||
@@ -58,7 +58,6 @@
|
||||
},
|
||||
"suspicious": {
|
||||
"noTsIgnore": "off",
|
||||
"noGlobalIsFinite": "off",
|
||||
"noExplicitAny": "off",
|
||||
"noArrayIndexKey": "off",
|
||||
"noConfusingVoidType": "off",
|
||||
|
||||
@@ -63,8 +63,8 @@ const WaveEffect = (props: WaveEffectProps) => {
|
||||
|
||||
// Rect
|
||||
const { borderLeftWidth, borderTopWidth } = nodeStyle;
|
||||
setLeft(isStatic ? target.offsetLeft : validateNum(-parseFloat(borderLeftWidth)));
|
||||
setTop(isStatic ? target.offsetTop : validateNum(-parseFloat(borderTopWidth)));
|
||||
setLeft(isStatic ? target.offsetLeft : validateNum(-Number.parseFloat(borderLeftWidth)));
|
||||
setTop(isStatic ? target.offsetTop : validateNum(-Number.parseFloat(borderTopWidth)));
|
||||
setWidth(target.offsetWidth);
|
||||
setHeight(target.offsetHeight);
|
||||
|
||||
@@ -82,7 +82,7 @@ const WaveEffect = (props: WaveEffectProps) => {
|
||||
borderTopRightRadius,
|
||||
borderBottomRightRadius,
|
||||
borderBottomLeftRadius,
|
||||
].map((radius) => validateNum(parseFloat(radius))),
|
||||
].map((radius) => validateNum(Number.parseFloat(radius))),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -123,9 +123,9 @@ const InternalBadge = React.forwardRef<HTMLSpanElement, BadgeProps>((props, ref)
|
||||
const offsetStyle: React.CSSProperties = { marginTop: offset[1] };
|
||||
|
||||
if (direction === 'rtl') {
|
||||
offsetStyle.left = parseInt(offset[0] as string, 10);
|
||||
offsetStyle.left = Number.parseInt(offset[0] as string, 10);
|
||||
} else {
|
||||
offsetStyle.right = -parseInt(offset[0] as string, 10);
|
||||
offsetStyle.right = -Number.parseInt(offset[0] as string, 10);
|
||||
}
|
||||
|
||||
return { ...offsetStyle, ...badge?.style, ...style };
|
||||
|
||||
@@ -14,7 +14,7 @@ const defaultReactRender: RenderType = (node, container) => {
|
||||
// TODO: Remove in v6
|
||||
// Warning for React 19
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
const majorVersion = parseInt(React.version.split('.')[0], 10);
|
||||
const majorVersion = Number.parseInt(React.version.split('.')[0], 10);
|
||||
const fullKeys = Object.keys(ReactDOM);
|
||||
|
||||
warning(
|
||||
|
||||
@@ -16,7 +16,7 @@ describe('UnstableContext', () => {
|
||||
|
||||
// TODO: Remove in v6
|
||||
it('should warning', async () => {
|
||||
const majorVersion = parseInt(version.split('.')[0], 10);
|
||||
const majorVersion = Number.parseInt(version.split('.')[0], 10);
|
||||
|
||||
if (majorVersion >= 19) {
|
||||
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
||||
|
||||
@@ -8,7 +8,7 @@ type WaveConfig = GetProp<ConfigProviderProps, 'wave'>;
|
||||
// Prepare effect holder
|
||||
const createHolder = (node: HTMLElement) => {
|
||||
const { borderWidth } = getComputedStyle(node);
|
||||
const borderWidthNum = parseInt(borderWidth, 10);
|
||||
const borderWidthNum = Number.parseInt(borderWidth, 10);
|
||||
|
||||
const div = document.createElement('div');
|
||||
div.style.position = 'absolute';
|
||||
|
||||
@@ -72,7 +72,7 @@ export default function ItemHolder(props: ItemHolderProps) {
|
||||
// The element must be part of the DOMTree to use getComputedStyle
|
||||
// https://stackoverflow.com/questions/35360711/getcomputedstyle-returns-a-cssstyledeclaration-but-all-properties-are-empty-on-a
|
||||
const itemStyle = getComputedStyle(itemRef.current);
|
||||
setMarginBottom(parseInt(itemStyle.marginBottom, 10));
|
||||
setMarginBottom(Number.parseInt(itemStyle.marginBottom, 10));
|
||||
}
|
||||
}, [hasError, isOnScreen]);
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ const PriceInput: React.FC<PriceInputProps> = (props) => {
|
||||
};
|
||||
|
||||
const onNumberChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const newNumber = parseInt(e.target.value || '0', 10);
|
||||
const newNumber = Number.parseInt(e.target.value || '0', 10);
|
||||
if (Number.isNaN(number)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,8 @@ const dimensionMaxMap = {
|
||||
xxl: '1599.98px',
|
||||
};
|
||||
|
||||
const isNumeric = (value: any) => !Number.isNaN(Number.parseFloat(value)) && isFinite(value);
|
||||
const isNumeric = (val: any) =>
|
||||
!Number.isNaN(Number.parseFloat(val)) && Number.isFinite(Number(val));
|
||||
|
||||
export interface SiderContextProps {
|
||||
siderCollapsed?: boolean;
|
||||
@@ -148,7 +149,7 @@ const Sider = React.forwardRef<HTMLDivElement, SiderProps>((props, ref) => {
|
||||
const siderWidth = isNumeric(rawWidth) ? `${rawWidth}px` : String(rawWidth);
|
||||
// special trigger when collapsedWidth == 0
|
||||
const zeroWidthTrigger =
|
||||
parseFloat(String(collapsedWidth || 0)) === 0 ? (
|
||||
Number.parseFloat(String(collapsedWidth || 0)) === 0 ? (
|
||||
<span
|
||||
onClick={toggle}
|
||||
className={classNames(
|
||||
@@ -194,7 +195,7 @@ const Sider = React.forwardRef<HTMLDivElement, SiderProps>((props, ref) => {
|
||||
[`${prefixCls}-collapsed`]: !!collapsed,
|
||||
[`${prefixCls}-has-trigger`]: collapsible && trigger !== null && !zeroWidthTrigger,
|
||||
[`${prefixCls}-below`]: !!below,
|
||||
[`${prefixCls}-zero-width`]: parseFloat(siderWidth) === 0,
|
||||
[`${prefixCls}-zero-width`]: Number.parseFloat(siderWidth) === 0,
|
||||
},
|
||||
className,
|
||||
hashId,
|
||||
|
||||
@@ -33,7 +33,7 @@ interface LineProps extends ProgressProps {
|
||||
export const sortGradient = (gradients: StringGradients) => {
|
||||
let tempArr: { key: number; value?: string }[] = [];
|
||||
Object.keys(gradients).forEach((key) => {
|
||||
const formattedKey = parseFloat(key.replace(/%/g, ''));
|
||||
const formattedKey = Number.parseFloat(key.replace(/%/g, ''));
|
||||
if (!Number.isNaN(formattedKey)) {
|
||||
tempArr.push({ key: formattedKey, value: gradients[key] });
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ const Progress = React.forwardRef<HTMLDivElement, ProgressProps>((props, ref) =>
|
||||
|
||||
const percentNumber = React.useMemo<number>(() => {
|
||||
const successPercent = getSuccessPercent(props);
|
||||
return parseInt(
|
||||
return Number.parseInt(
|
||||
successPercent !== undefined ? (successPercent ?? 0)?.toString() : (percent ?? 0)?.toString(),
|
||||
10,
|
||||
);
|
||||
|
||||
@@ -281,7 +281,7 @@ describe('Table.pagination', () => {
|
||||
fireEvent.mouseDown(container.querySelector('.ant-select-selector')!);
|
||||
expect(container.querySelectorAll('.ant-select-item-option').length).toBe(4);
|
||||
fireEvent.click(container.querySelectorAll('.ant-select-item-option')[1]);
|
||||
const newPageSize = parseInt(
|
||||
const newPageSize = Number.parseInt(
|
||||
container.querySelectorAll('.ant-select-item-option')?.[1]?.textContent!,
|
||||
10,
|
||||
);
|
||||
@@ -308,7 +308,7 @@ describe('Table.pagination', () => {
|
||||
fireEvent.mouseDown(container.querySelector('.ant-select-selector')!);
|
||||
expect(container.querySelectorAll('.ant-select-item-option').length).toBe(4);
|
||||
fireEvent.click(container.querySelectorAll('.ant-select-item-option')[1]);
|
||||
const newPageSize = parseInt(
|
||||
const newPageSize = Number.parseInt(
|
||||
container.querySelectorAll('.ant-select-item-option')?.[1]?.textContent!,
|
||||
10,
|
||||
);
|
||||
|
||||
@@ -7,9 +7,8 @@ export default function useContainerWidth(prefixCls: string) {
|
||||
|
||||
if (container) {
|
||||
const style = getComputedStyle(container);
|
||||
const borderLeft = parseInt(style.borderLeftWidth, 10);
|
||||
const borderRight = parseInt(style.borderRightWidth, 10);
|
||||
|
||||
const borderLeft = Number.parseInt(style.borderLeftWidth, 10);
|
||||
const borderRight = Number.parseInt(style.borderRightWidth, 10);
|
||||
returnWidth = width - borderLeft - borderRight;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ const props: UploadProps = {
|
||||
'100%': '#87d068',
|
||||
},
|
||||
strokeWidth: 3,
|
||||
format: (percent) => percent && `${parseFloat(percent.toFixed(2))}%`,
|
||||
format: (percent) => percent && `${Number.parseFloat(percent.toFixed(2))}%`,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -4,15 +4,15 @@ import os from 'os';
|
||||
import path from 'path';
|
||||
import { Readable } from 'stream';
|
||||
import { finished } from 'stream/promises';
|
||||
import blazediff from '@blazediff/core';
|
||||
import chalk from 'chalk';
|
||||
import fse from 'fs-extra';
|
||||
import difference from 'lodash/difference';
|
||||
import filter from 'lodash/filter';
|
||||
import minimist from 'minimist';
|
||||
import blazediff from '@blazediff/core';
|
||||
import { PNG } from 'pngjs';
|
||||
import sharp from 'sharp';
|
||||
import simpleGit from 'simple-git';
|
||||
import filter from 'lodash/filter';
|
||||
|
||||
import markdown2Html from './convert';
|
||||
import { generate as genAlternativeReport } from './reportAdapter';
|
||||
@@ -157,7 +157,7 @@ async function parseArgs() {
|
||||
const baseRef = argv['base-ref'];
|
||||
assert(baseRef, 'Missing --base-ref');
|
||||
|
||||
const maxWorkers = argv['max-workers'] ? parseInt(argv['max-workers'], 10) : 1;
|
||||
const maxWorkers = argv['max-workers'] ? Number.parseInt(argv['max-workers'], 10) : 1;
|
||||
|
||||
const { latest } = await git.log();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user