Skip to content
Draft
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
8 changes: 0 additions & 8 deletions .eslintignore

This file was deleted.

92 changes: 0 additions & 92 deletions .eslintrc.js

This file was deleted.

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

This file was deleted.

58 changes: 58 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { tdesign } from '@tdesign/eslint-config';

export default tdesign(
{
preset: 'base',
tests: true,
ignores: ['lib/**', 'public/**', 'dist/**', 'static/**', 'site/**', '**/*/*.test.js'],
},
{
name: 'tdesign-common/overrides',
files: ['**/*.{js,mjs,cjs,jsx,ts,tsx}'],
rules: {
'no-unassigned-vars': 'off',
'no-useless-assignment': 'off',
'preserve-caught-error': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/consistent-type-imports': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unsafe-function-type': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/no-wrapper-object-types': 'off',
'simple-import-sort/exports': 'off',
'simple-import-sort/imports': 'off',
'no-restricted-imports': [
'error',
{
paths: [
{
name: 'lodash',
message: 'Please use lodash-es instead.',
},
],
patterns: [
{
group: ['js/*'],
message: 'Importing from paths starting with "js/" is not allowed. Please use "../" instead.',
},
],
},
],
},
},
{
name: 'tdesign-common/legacy-disable-directives',
linterOptions: {
reportUnusedDisableDirectives: 'off',
},
},
{
name: 'tdesign-common/tooling-overrides',
files: ['*.config.js', 'test/script/*'],
rules: {
'no-console': 'off',
'@typescript-eslint/no-require-imports': 'off',
},
},
);
2 changes: 1 addition & 1 deletion js/color-picker/color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class Color {
this.isGradient = true;
const object = gradientColors as GradientColors;
const points = object.points.map((c, index) =>
genGradientPoint(c.left, c.color, this.gradientStates.colors[index]?.id)
genGradientPoint(c.left, c.color, this.gradientStates.colors[index]?.id),
);
this.gradientStates = {
colors: points,
Expand Down
2 changes: 1 addition & 1 deletion js/color-picker/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const getColorFormatInputs = (format: ColorFormat = 'RGB', enableAlpha: b
if (enableAlpha) {
finalFormat =
Object.keys(ALPHA_FORMAT_MAP).find(
(key) => key in ALPHA_FORMAT_MAP && ALPHA_FORMAT_MAP[key as AlphaConvertibleFormat] === format
(key) => key in ALPHA_FORMAT_MAP && ALPHA_FORMAT_MAP[key as AlphaConvertibleFormat] === format,
) || format;
} else {
finalFormat = format;
Expand Down
4 changes: 2 additions & 2 deletions js/color-picker/gradient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const generateRegExp = (): RegExpLib => {
const // "red", "transparent".
rColor = combineRegExp(
['(?:', rColorHex, '|', '(?:rgb|hsl)', rDigits3, '|', '(?:rgba|hsla)', rDigits4, '|', rKeyword, ')'],
''
'',
);
const rColorStop = combineRegExp([rColor, '(?:\\s+', rValue, '(?:\\s+', rValue, ')?)?'], '');
const // Single Color Stop, optional %, optional length.
Expand All @@ -79,7 +79,7 @@ const generateRegExp = (): RegExpLib => {
const // Capture 1:"line", 2:"angle" (optional), 3:"side corner" (optional) and 4:"stop list".
rColorStopSearch = combineRegExp(
['\\s*(', rColor, ')', '(?:\\s+', '(', rValue, '))?', '(?:', rComma, '\\s*)?'],
searchFlags
searchFlags,
); // Capture 1:"color" and 2:"position" (optional).

return {
Expand Down
12 changes: 6 additions & 6 deletions js/date-picker/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function parseToDayjs(
format: string,
timeOfDay?: string,
dayjsLocale?: string,
defaultTime?: string
defaultTime?: string,
) {
if (value === '' || value === null) return dayjs();

Expand Down Expand Up @@ -109,7 +109,7 @@ export function parseToDayjs(
if (!result.isValid()) {
log.error(
'DatePicker',
`Check whether the format、value format is valid.\n value: '${value}', format: '${format}'`
`Check whether the format、value format is valid.\n value: '${value}', format: '${format}'`,
);
return dayjs();
}
Expand Down Expand Up @@ -155,7 +155,7 @@ function formatRange({
if (!newDate || !Array.isArray(newDate)) return [];

let dayjsDateList = newDate.map(
(d, i) => d && parseToDayjs(d, format, undefined, undefined, defaultTime?.[i]).locale(dayjsLocale)
(d, i) => d && parseToDayjs(d, format, undefined, undefined, defaultTime?.[i]).locale(dayjsLocale),
);

// 保证后面的时间大于前面的时间
Expand All @@ -173,7 +173,7 @@ function formatRange({
if (dayjsDateList.some((r) => r && !r.isValid())) {
log.error(
'DatePicker',
`Check whether the value、format、valueType format is valid.\nformat: '${format}' value: '${newDate}' valueType: '${targetFormat}'`
`Check whether the value、format、valueType format is valid.\nformat: '${format}' value: '${newDate}' valueType: '${targetFormat}'`,
);
return [];
}
Expand Down Expand Up @@ -208,7 +208,7 @@ function formatSingle({
if (!dayJsDate.isValid()) {
log.error(
'DatePicker',
`Check whether the format、value format is valid.\nformat: '${format}' value: '${newDate}'`
`Check whether the format、value format is valid.\nformat: '${format}' value: '${newDate}'`,
);
return '';
}
Expand Down Expand Up @@ -249,7 +249,7 @@ export function formatDate(
targetFormat?: string;
autoSwap?: boolean;
defaultTime?: string | string[];
}
},
) {
let result;

Expand Down
14 changes: 7 additions & 7 deletions js/date-picker/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ export function getWeeks(
maxDate,
dayjsLocale = 'zh-cn',
cancelRangeSelectLimit = false,
}: OptionsType
}: OptionsType,
) {
const prependDay = getFirstDayOfMonth({ year, month });
const appendDay = getLastDayOfMonth({ year, month });
Expand Down Expand Up @@ -298,7 +298,7 @@ export function getQuarters(
quarterLocal,
dayjsLocale = 'zh-cn',
cancelRangeSelectLimit = false,
}: OptionsType
}: OptionsType,
) {
const quarterArr = [];
const today = getToday();
Expand All @@ -323,7 +323,7 @@ export function getQuarters(

export function getYears(
year: number,
{ disableDate = () => false, minDate, maxDate, dayjsLocale = 'zh-cn', cancelRangeSelectLimit = false }: OptionsType
{ disableDate = () => false, minDate, maxDate, dayjsLocale = 'zh-cn', cancelRangeSelectLimit = false }: OptionsType,
) {
const startYear = parseInt((year / 10).toString(), 10) * 10;
const endYear = startYear + 9;
Expand Down Expand Up @@ -416,14 +416,14 @@ export function flagActive(data: any[], { ...args }: FlagActiveOptions) {

if (multiple) {
_item.active = (value as DateValue[])?.some?.(
(val) => isSame(dayjs(val).toDate(), _item.value, type) && !_item.additional
(val) => isSame(dayjs(val).toDate(), _item.value, type) && !_item.additional,
);
} else {
_item.active = start && isSame(item.value, start, type) && !_item.additional;
}

return _item;
})
}),
);
}

Expand All @@ -450,7 +450,7 @@ export function flagActive(data: any[], { ...args }: FlagActiveOptions) {
_item.hoverEndOfRange = isHoverEnd;
}
return _item;
})
}),
);
}

Expand Down Expand Up @@ -610,7 +610,7 @@ export function computePaginationDisabled(
range: PickerDateRange,
mode: 'date' | 'week' | 'month' | 'quarter' | 'year',
year: number,
month: number | undefined
month: number | undefined,
): { prev: boolean; next: boolean } {
const monthCountMap: Record<string, number> = { date: 1, week: 1, month: 12, quarter: 12, year: 120 };
const monthCount = monthCountMap[mode] || 0;
Expand Down
6 changes: 3 additions & 3 deletions js/image-viewer/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export function calcZoomOutScale(oldScale: number, step: number, min: number, ma
export function calculateTranslateOffset(
oldScale: number,
newScale: number,
options?: ZoomOptions
options?: ZoomOptions,
): TranslateOffset | undefined {
if (options?.mouseOffsetX == null || options?.mouseOffsetY == null) {
return undefined;
Expand All @@ -109,7 +109,7 @@ export function zoomIn(
step: number,
min: number,
max: number,
options?: ZoomOptions
options?: ZoomOptions,
): { newScale: number; zoomResult: ZoomResult } {
const newScale = calcZoomInScale(oldScale, step, min, max);
return {
Expand All @@ -127,7 +127,7 @@ export function zoomOut(
step: number,
min: number,
max: number,
options?: ZoomOptions
options?: ZoomOptions,
): { newScale: number; zoomResult: ZoomResult } {
const newScale = calcZoomOutScale(oldScale, step, min, max);
return {
Expand Down
4 changes: 2 additions & 2 deletions js/input-number/large-number.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export function compareNumber(num1: string | number, num2: string | number, larg
export function largeIntegerNumberSubtract(
num1: string,
num2: string,
p?: { decimal?: boolean; stayZero?: boolean; filledZero?: boolean }
p?: { decimal?: boolean; stayZero?: boolean; filledZero?: boolean },
): string {
if (num1 === num2) return '0';
const { decimal, stayZero, filledZero } = p || {};
Expand Down Expand Up @@ -380,7 +380,7 @@ export function decimalPlacesToFixedNum(num: number, decimalPlaces: InputNumberD
export function largeNumberToFixed(
number: string | number,
decimalPlaces: InputNumberDecimalPlaces = 0,
largeNumber: boolean = true
largeNumber: boolean = true,
): string {
if (Number.isNaN(Number(number))) return '';
if (!largeNumber) {
Expand Down
Loading
Loading