Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ temp*
static/
packages/common
packages/ai-core
site/engineering/static
26 changes: 21 additions & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
module.exports = {
extends: [
'airbnb-base',
'prettier', // eslint-config-prettier 处理冲突
'plugin:react/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'react-hooks', 'simple-import-sort'],
plugins: ['@typescript-eslint', 'react-hooks', 'simple-import-sort', 'prettier'],
env: {
browser: true,
node: true,
Expand Down Expand Up @@ -69,7 +69,25 @@ module.exports = {
],
'max-len': 'off',
'no-shadow': 'off',

'prettier/prettier': [
'error',
{
printWidth: 120,
tabWidth: 2,
useTabs: false,
semi: true,
singleQuote: true,
quoteProps: 'as-needed',
jsxSingleQuote: false,
trailingComma: 'all',
bracketSpacing: true,
jsxBracketSameLine: false,
arrowParens: 'always',
proseWrap: 'preserve',
htmlWhitespaceSensitivity: 'css',
endOfLine: 'lf',
},
],
// import config
'import/order': 'off',
'import/extensions': 'off',
Expand Down Expand Up @@ -103,7 +121,6 @@ module.exports = {
},
],
'simple-import-sort/exports': 'error',

// typescript config
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/ban-types': 'off',
Expand All @@ -125,7 +142,6 @@ module.exports = {
disallowTypeAnnotations: false,
},
],

// react config
'react/display-name': 'off',
'react-hooks/exhaustive-deps': 'warn',
Expand Down
1 change: 0 additions & 1 deletion .prettierignore

This file was deleted.

39 changes: 0 additions & 39 deletions .prettierrc.js

This file was deleted.

10 changes: 5 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"],
"[html]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[typescriptreact]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[javascriptreact]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[typescript]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[javascript]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
Expand Down
3 changes: 1 addition & 2 deletions packages/components/auto-complete/AutoComplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ import type { OptionsListProps } from './OptionList';
import type { AutoCompleteOption, TdAutoCompleteProps } from './type';

export interface AutoCompleteProps<T extends AutoCompleteOption = AutoCompleteOption>
extends TdAutoCompleteProps<T>,
StyledProps {}
extends TdAutoCompleteProps<T>, StyledProps {}

export interface AutoCompleteRef {
inputRef: InputRef;
Expand Down
2 changes: 1 addition & 1 deletion packages/components/badge/_example/color.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useState } from 'react';
import { Badge, Checkbox } from 'tdesign-react';

const colors = [
Expand Down
3 changes: 1 addition & 2 deletions packages/components/button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import { buttonDefaultProps } from './defaultProps';
import type { TdButtonProps } from './type';

export interface ButtonProps
extends TdButtonProps,
Omit<React.AllHTMLAttributes<HTMLElement>, 'content' | 'shape' | 'size' | 'type'> {}
extends TdButtonProps, Omit<React.AllHTMLAttributes<HTMLElement>, 'content' | 'shape' | 'size' | 'type'> {}

const Button = forwardRef((originProps: ButtonProps, ref: React.RefObject<HTMLElement>) => {
const props = useDefaultProps(originProps, buttonDefaultProps);
Expand Down
3 changes: 1 addition & 2 deletions packages/components/cascader/components/Panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import type { CascaderContextType, TreeNode } from '../interface';
import type { TdCascaderProps } from '../type';

export interface CascaderPanelProps
extends StyledProps,
Pick<TdCascaderProps, 'trigger' | 'empty' | 'onChange' | 'loading' | 'loadingText' | 'option'> {
extends StyledProps, Pick<TdCascaderProps, 'trigger' | 'empty' | 'onChange' | 'loading' | 'loadingText' | 'option'> {
cascaderContext: CascaderContextType;
}

Expand Down
35 changes: 17 additions & 18 deletions packages/components/cascader/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,23 @@ import type { TdSelectInputProps } from '../select-input/type';
import type { CascaderChangeSource, CascaderValue, TdCascaderProps } from './type';

export * from './type';
export interface CascaderContextType
extends Pick<
TdCascaderProps,
| 'size'
| 'disabled'
| 'checkStrictly'
| 'lazy'
| 'multiple'
| 'filterable'
| 'filter'
| 'clearable'
| 'checkProps'
| 'showAllLevels'
| 'max'
| 'value'
| 'minCollapsedNum'
| 'valueType'
> {
export interface CascaderContextType extends Pick<
TdCascaderProps,
| 'size'
| 'disabled'
| 'checkStrictly'
| 'lazy'
| 'multiple'
| 'filterable'
| 'filter'
| 'clearable'
| 'checkProps'
| 'showAllLevels'
| 'max'
| 'value'
| 'minCollapsedNum'
| 'valueType'
> {
treeStore: TreeStore;
setValue: (val: CascaderValue, source: CascaderChangeSource, node?: TreeNodeModel) => void;
visible: boolean;
Expand Down
3 changes: 1 addition & 2 deletions packages/components/checkbox/CheckboxGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ import type {
} from './type';

export interface CheckboxGroupProps<T extends CheckboxGroupValue = CheckboxGroupValue>
extends TdCheckboxGroupProps<T>,
StyledProps {
extends TdCheckboxGroupProps<T>, StyledProps {
children?: React.ReactNode;
}

Expand Down
6 changes: 4 additions & 2 deletions packages/components/color-picker/components/trigger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import useClassName from '../hooks/useClassNames';
import type { TdColorPickerProps } from '..';
import type { TdColorContext } from '../interface';

export interface ColorTriggerProps
extends Pick<TdColorPickerProps, 'disabled' | 'inputProps' | 'borderless' | 'clearable' | 'onClear'> {
export interface ColorTriggerProps extends Pick<
TdColorPickerProps,
'disabled' | 'inputProps' | 'borderless' | 'clearable' | 'onClear'
> {
value?: string;
onChange?: (v?: string, context?: TdColorContext) => {};
}
Expand Down
3 changes: 2 additions & 1 deletion packages/components/date-picker/base/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import type { DateMultipleValue, DateRangeValue, DateValue, TdDatePickerProps }
dayjs.extend(isoWeek);

export interface DatePickerTableProps
extends Pick<TdDatePickerProps, 'mode' | 'firstDayOfWeek' | 'format' | 'multiple' | 'cell'>,
extends
Pick<TdDatePickerProps, 'mode' | 'firstDayOfWeek' | 'format' | 'multiple' | 'cell'>,
Pick<SinglePanelProps, 'onCellClick' | 'onCellMouseEnter' | 'onCellMouseLeave'>,
Pick<PanelContentProps, 'value'> {
data?: Array<any>;
Expand Down
9 changes: 4 additions & 5 deletions packages/components/date-picker/panel/ExtraContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ import DateFooter from '../base/Footer';
import type { DateMultipleValue, DateValue, TdDatePickerProps, TdDateRangePickerProps } from '../type';
import type { SinglePanelProps } from './SinglePanel';

export interface ExtraContentProps
extends Pick<
SinglePanelProps,
'enableTimePicker' | 'presetsPlacement' | 'onPresetClick' | 'onConfirmClick' | 'needConfirm'
> {
export interface ExtraContentProps extends Pick<
SinglePanelProps,
'enableTimePicker' | 'presetsPlacement' | 'onPresetClick' | 'onConfirmClick' | 'needConfirm'
> {
selectedValue?: DateValue | DateMultipleValue;
presets?: TdDatePickerProps['presets'] | TdDateRangePickerProps['presets'];
onTimeModeChange?: () => void;
Expand Down
9 changes: 6 additions & 3 deletions packages/components/date-picker/panel/SinglePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import type { TdTimePickerProps } from '../../time-picker';
import type { DateValue, TdDatePickerProps, TdDateRangePickerProps } from '../type';

export interface SinglePanelProps
extends Omit<TdDatePickerProps, 'enableTimePicker' | 'onYearChange' | 'onMonthChange'>,
StyledProps {
extends Omit<TdDatePickerProps, 'enableTimePicker' | 'onYearChange' | 'onMonthChange'>, StyledProps {
year?: number;
month?: number;
time?: string;
Expand Down Expand Up @@ -65,7 +64,11 @@ const SinglePanel = forwardRef<HTMLDivElement, SinglePanelProps>((originalProps,
enableTimePicker: props.enableTimePicker,
});

const disableDateOptions = useDisableDate({ disableDate: props.disableDate, mode: props.mode, format });
const disableDateOptions = useDisableDate({
disableDate: props.disableDate,
mode: props.mode,
format,
});

const disableTimeOptions: TdTimePickerProps['disableTime'] = (h: number, m: number, s: number, ms: number) => {
if (!isFunction(disableTime) || !value) {
Expand Down
2 changes: 1 addition & 1 deletion packages/components/drawer/hooks/useLockStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function useLockStyle(props) {
left: `margin: 0 0 0 ${sizeValue}`,
right: `margin: 0 0 0 -${sizeValue}`,
bottom: `margin: -${sizeValue} 0 0 0`,
}[placement]),
})[placement],
[placement, sizeValue],
);

Expand Down
4 changes: 2 additions & 2 deletions packages/components/empty/Empty.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ const Empty: React.FC<EmptyProps> = (props) => {
const typeImageProps = defaultMaps[type] ?? null;

const { image, description, title } = {
image: propsImage ? propsImage : typeImageProps?.image ?? null,
title: propsTitle ? propsTitle : typeImageProps?.title ?? null,
image: propsImage ? propsImage : (typeImageProps?.image ?? null),
title: propsTitle ? propsTitle : (typeImageProps?.title ?? null),
description: propsDescription,
};

Expand Down
11 changes: 7 additions & 4 deletions packages/components/hooks/useRipple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,13 @@ export default function useRipple(el: HTMLElement, fixedRippleColor?: string): v
el.removeEventListener('pointerup', handleClearRipple, false);
el.removeEventListener('pointerleave', handleClearRipple, false);

setTimeout(() => {
ripple.remove();
if (rippleContainer.children.length === 0) rippleContainer.remove();
}, period * 2 + 100);
setTimeout(
() => {
ripple.remove();
if (rippleContainer.children.length === 0) rippleContainer.remove();
},
period * 2 + 100,
);
};

el.addEventListener('pointerup', handleClearRipple, false);
Expand Down
17 changes: 13 additions & 4 deletions packages/components/input-adornment/_example/select.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
import React from 'react';
import React from 'react';
import { Input, InputAdornment, Select, Space } from 'tdesign-react';

export default function BaseExample() {
const protocolSelect = (
<Select
autoWidth
options={['http://', 'https://'].map((value) => ({ label: value, value }))}
options={['http://', 'https://'].map((value) => ({
label: value,
value,
}))}
defaultValue="http://"
/>
);

const tldSelect = (
<Select
autoWidth
options={['.com', '.cn', '.net', '.org'].map((value) => ({ label: value, value }))}
options={['.com', '.cn', '.net', '.org'].map((value) => ({
label: value,
value,
}))}
defaultValue=".cn"
/>
);
Expand All @@ -30,7 +36,10 @@ export default function BaseExample() {

<InputAdornment prepend={protocolSelect} append={tldSelect}>
<Select
options={['tencent', 'qq', 'cloud.tencent'].map((value) => ({ label: value, value }))}
options={['tencent', 'qq', 'cloud.tencent'].map((value) => ({
label: value,
value,
}))}
defaultValue="tencent"
/>
</InputAdornment>
Expand Down
2 changes: 1 addition & 1 deletion packages/components/input-adornment/_example/text.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React from 'react';
import { Input, InputAdornment, Space, TagInput } from 'tdesign-react';

export default function BaseExample() {
Expand Down
2 changes: 1 addition & 1 deletion packages/components/input/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ const Input = forwardRefWithStatics(
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

const innerValue = composingRef.current ? composingValue : value ?? '';
const innerValue = composingRef.current ? composingValue : (value ?? '');
const formatDisplayValue = format && !isFocused ? format(innerValue) : innerValue;

const renderInput = (
Expand Down
2 changes: 1 addition & 1 deletion packages/components/input/_example/disabled.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React from 'react';
import { Input } from 'tdesign-react';

export default function InputExample() {
Expand Down
2 changes: 1 addition & 1 deletion packages/components/input/_example/format.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useState } from 'react';
import { Input } from 'tdesign-react';

import type { InputProps } from 'tdesign-react';
Expand Down
2 changes: 1 addition & 1 deletion packages/components/input/_example/max-length-count.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useState } from 'react';
import { Input, Space } from 'tdesign-react';

export default function InputExample() {
Expand Down
Loading
Loading