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
17 changes: 0 additions & 17 deletions .eslintignore

This file was deleted.

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

This file was deleted.

89 changes: 89 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import importPlugin from 'eslint-plugin-import';
import reactHooksPlugin from 'eslint-plugin-react-hooks';

import { base, react } from '@rss1102/eslint-config-tdesign';

export default [
...base,
...react,
{
ignores: [
'**/dist/**',
'**/es/**',
'**/esm/**',
'**/lib/**',
'**/cjs/**',
'**/_example-js/**',
'**/node_modules/**',
'snapshot*/**',
'static/**',
'cypress/**',
'script/test/cypress/**',
'_site/**',
'temp*/**',
'packages/common/**',
'packages/ai-core/**',
'site/engineering/static/**',
],
},
{
files: ['**/*.{js,mjs,cjs,jsx,ts,tsx}'],
plugins: {
import: importPlugin,
'react-hooks': reactHooksPlugin,
},
rules: {
'no-restricted-imports': [
'error',
{
paths: [
{
name: 'lodash',
message: 'Please use lodash-es instead.',
},
],
},
],
'@typescript-eslint/no-unused-vars': 'error',
'import/first': 'off',
'no-useless-assignment': 'off',
'no-unused-vars': 'off',
'react-hooks/component-hook-factories': 'off',
'react-hooks/error-boundaries': 'off',
'react-hooks/exhaustive-deps': 'warn',
'react-hooks/globals': 'off',
'react-hooks/immutability': 'off',
'react-hooks/incompatible-library': 'off',
'react-hooks/preserve-manual-memoization': 'off',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/purity': 'off',
'react-hooks/refs': 'off',
'react-hooks/set-state-in-render': 'off',
'react-hooks/set-state-in-effect': 'off',
'react-hooks/static-components': 'off',
'react-hooks/unsupported-syntax': 'off',
'react-hooks/use-memo': 'off',
'react-hooks/void-use-memo': 'off',
'simple-import-sort/exports': 'off',
'simple-import-sort/imports': 'off',
},
},
{
files: ['**/_usage/**/*', '**/_example/**/*', '**/__tests__/**/*'],
rules: {
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'no-unused-vars': 'off',
'react-hooks/exhaustive-deps': 'off',
'react-hooks/immutability': 'off',
'react-hooks/set-state-in-effect': 'off',
'simple-import-sort/imports': 'off',
},
},
{
files: ['**/_example/**/*', '**/__tests__/**/*'],
rules: {
'no-console': 'off',
},
},
];
18 changes: 7 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"dev:aigc": "pnpm run build:aigc-jsx-demo && pnpm -C packages/tdesign-react-aigc/site dev",
"site:aigc": "pnpm run build:aigc-jsx-demo && pnpm -C packages/tdesign-react-aigc/site build",
"site:aigc-preview": "pnpm -C packages/tdesign-react-aigc/site preview",
"lint": "pnpm run lint:tsc && eslint --ext .ts,.tsx ./ --max-warnings 0",
"lint:fix": "eslint --ext .ts,.tsx ./packages/components --ignore-pattern ./packages/components/__tests__ --max-warnings 0 --fix",
"lint:aigc-fix": "eslint --ext .ts,.tsx ./packages/pro-components --ignore-pattern ./packages/pro-components/__tests__ --max-warnings 0 --fix",
"lint": "pnpm run lint:tsc && eslint \"**/*.{ts,tsx}\" --max-warnings 0",
"lint:fix": "eslint \"packages/components/**/*.{ts,tsx}\" --ignore-pattern ./packages/components/__tests__ --max-warnings 0 --fix",
"lint:aigc-fix": "eslint \"packages/pro-components/**/*.{ts,tsx}\" --ignore-pattern ./packages/pro-components/__tests__ --max-warnings 0 --fix",
"lint:tsc": "tsc -p ./tsconfig.dev.json ",
"generate:usage": "node script/generate-usage/index.js",
"generate:coverage-badge": "pnpm run test:coverage && node script/generate-coverage.js",
Expand Down Expand Up @@ -88,8 +88,8 @@
"@types/react-dom": "^18.2.0",
"@types/rimraf": "^4.0.5",
"@types/testing-library__jest-dom": "5.14.2",
"@typescript-eslint/eslint-plugin": "^5.13.0",
"@typescript-eslint/parser": "^5.13.0",
"@rss1102/eslint-config-tdesign": "^0.0.2",
"@rss1102/prettier-config-tdesign": "^0.0.1",
"@vitejs/plugin-react": "^5.1.1",
"@vitest/coverage-istanbul": "^2.1.1",
"@vitest/coverage-v8": "^2.1.1",
Expand All @@ -101,12 +101,8 @@
"cz-conventional-changelog": "^3.3.0",
"dom-parser": "^0.1.6",
"esbuild": "^0.14.9",
"eslint": "^7.32.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-react": "~7.28.0",
"eslint-plugin-react-hooks": "^4.0.0",
"eslint-plugin-simple-import-sort": "^13.0.0",
"eslint": "^10.5.0",
"eslint-plugin-import": "^2.32.0",
"fs-extra": "^11.3.0",
"glob": "^9.0.3",
"husky": "^7.0.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/components/_util/parseTNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function parseContentTNode<T>(tnode: TNode<T>, props: T) {
if (!tnode || ['string', 'number', 'boolean'].includes(typeof tnode)) return tnode as ReactNode;
try {
return React.cloneElement(tnode as ReactElement, { ...props });
} catch (e) {
} catch {
log.warn('parseContentTNode', `${tnode} is not a valid ReactNode`);
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/components/_util/react-render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ try {
if (mainVersion >= 18 && mainVersion < 19) {
legacyCreateRoot = fullClone.createRoot;
}
} catch (e) {
} catch {
// Do nothing;
}

Expand Down
8 changes: 4 additions & 4 deletions packages/components/descriptions/_example/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from 'react';
import { Col, Descriptions, Radio, Row, Space } from 'tdesign-react';

type Layout = 'horizontal' | 'vertical';
type LayoutType = 'horizontal' | 'vertical';

export default function Layout() {
const [layout, setLayout] = React.useState<Layout>('horizontal');
const [itemLayout, setItemLayout] = React.useState<Layout>('horizontal');
const [layout, setLayout] = React.useState<LayoutType>('horizontal');
const [itemLayout, setItemLayout] = React.useState<LayoutType>('horizontal');

const items = [
{
Expand Down Expand Up @@ -39,7 +39,7 @@ export default function Layout() {
<Radio.Group
variant="default-filled"
value={layout}
onChange={(val: Layout) => setLayout(val)}
onChange={(val: LayoutType) => setLayout(val)}
options={layoutOptions}
/>
</Col>
Expand Down
3 changes: 2 additions & 1 deletion packages/components/form/hooks/useWatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export default function useWatch(name: NamePath, form: InternalFormInstance) {
useEffect(() => {
if (!isValidForm) return;

const { registerWatch = noop } = form.getInternalHooks?.(HOOK_MARK);
const internalHooks = form.getInternalHooks?.(HOOK_MARK);
const { registerWatch = noop } = internalHooks || {};

const cancelRegister = registerWatch(() => {
const allFieldsValue = form.getFieldsValue?.(true);
Expand Down
4 changes: 2 additions & 2 deletions packages/components/message/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import type {
TdMessageProps,
} from './type';

export interface MessagePlugin {
export interface MessagePluginType {
(theme: MessageThemeList, message: TNode | MessageOptions, duration?: number): Promise<MessageInstance>;
info: MessageInfoMethod;
success: MessageSuccessMethod;
Expand Down Expand Up @@ -248,7 +248,7 @@ const messageMethod: MessageMethod = (theme: MessageThemeList, content, duration
return Promise.resolve(renderElement(theme, getMessageConfig(config)));
};

export const MessagePlugin: MessagePlugin = (theme, message, duration) => messageMethod(theme, message, duration);
export const MessagePlugin: MessagePluginType = (theme, message, duration) => messageMethod(theme, message, duration);
MessagePlugin.info = (content, duration) => messageMethod('info', content, duration);
MessagePlugin.error = (content, duration) => messageMethod('error', content, duration);
MessagePlugin.warning = (content, duration) => messageMethod('warning', content, duration);
Expand Down
2 changes: 1 addition & 1 deletion packages/components/popup/Popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ const Popup = forwardRef<PopupInstanceFunctions, PopupProps>((originalProps, ref
onVisibleChange(false, { trigger: 'document' });
}
}
} catch (e) {
} catch {
// 直接尝试更新
popper.update();
}
Expand Down
2 changes: 1 addition & 1 deletion packages/components/table/hooks/useDragSort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ function useDragSort(props: TdEnhancedTableProps, options: DragSortOptions) {
handle: `.${tableDraggableClasses.handle}`,
});
}
} catch (error) {
} catch {
//
}
updateLastRowList();
Expand Down
Loading
Loading