Skip to content

Commit f102c5a

Browse files
committed
chore: strengthen ts lint
1 parent 2e1aef6 commit f102c5a

54 files changed

Lines changed: 469 additions & 493 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.json

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"root": true,
33
"ignorePatterns": ["**/*"],
4-
"plugins": ["@nrwl/nx", "import", "markdown"],
5-
"extends": ["plugin:prettier/recommended"],
4+
"plugins": ["@nrwl/nx", "import", "markdown", "jsdoc"],
5+
"extends": ["plugin:prettier/recommended", "plugin:jsdoc/recommended"],
66
"overrides": [
77
{
88
"files": ["**/*.md"],
@@ -43,20 +43,16 @@
4343
},
4444
"warnOnUnassignedImports": true
4545
}
46-
]
46+
],
47+
"jsdoc/require-jsdoc": "off"
4748
}
4849
},
4950
{
5051
"files": ["*.ts", "*.tsx"],
5152
"extends": ["plugin:@nrwl/nx/typescript"],
5253
"rules": {
5354
"no-unreachable": "error",
54-
"@typescript-eslint/array-type": [
55-
"error",
56-
{
57-
"default": "array-simple"
58-
}
59-
],
55+
"@typescript-eslint/array-type": "error",
6056
"@typescript-eslint/ban-types": [
6157
"error",
6258
{

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
"eslint-config-prettier": "^8.3.0",
7676
"eslint-plugin-cypress": "^2.12.1",
7777
"eslint-plugin-import": "^2.25.4",
78+
"eslint-plugin-jsdoc": "^37.6.3",
7879
"eslint-plugin-jsx-a11y": "^6.5.1",
7980
"eslint-plugin-markdown": "^2.2.1",
8081
"eslint-plugin-prettier": "^4.0.0",

packages/site/src/app/components/route/RouteArticle.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ import marked, { toString } from './utils';
99

1010
export interface AppRouteArticleProps {
1111
html?: number[];
12-
links?: Array<{ href: string; title: string }>;
12+
links?: { href: string; title: string }[];
1313
children?: React.ReactNode;
1414
}
1515

1616
export function AppRouteArticle(props: AppRouteArticleProps) {
1717
const html = props.html ? marked(toString(props.html)) : undefined;
1818

19-
const [links, setLinks] = useImmer<Array<{ href: string; title: string }>>(props.links ?? []);
19+
const [links, setLinks] = useImmer<{ href: string; title: string }[]>(props.links ?? []);
2020
const [menuOpen, setMenuOpen] = useState(false);
2121
const [el, ref] = useRefCallback();
2222

@@ -54,7 +54,7 @@ m -673.67664,1221.6502 -231.2455,-231.24803 55.6165,
5454

5555
useLayoutEffect(() => {
5656
if (isUndefined(props.links)) {
57-
const arr: Array<{ href: string; title: string }> = [];
57+
const arr: { href: string; title: string }[] = [];
5858
document.querySelectorAll('.app-route-article h2').forEach((el) => {
5959
arr.push({ href: '#' + el.id, title: el.id });
6060
});

packages/site/src/app/components/route/component/ComponentRouteArticle.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export interface AppComponentRouteArticleProps {
1313
description: number[];
1414
api: number[];
1515
demos: React.ReactNode;
16-
links: Array<{ href: string; title: string }>;
16+
links: { href: string; title: string }[];
1717
}
1818

1919
export function AppComponentRouteArticle(props: AppComponentRouteArticleProps) {

packages/site/src/app/components/sidebar/Sidebar.tsx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,18 @@ export function AppSidebar() {
1818

1919
useEffect(() => {
2020
if (pageMounted && window.location.href.includes(String.raw`/components/`)) {
21-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
22-
const to = window.location.href.match(/\/components\/[a-zA-Z]+/)![0];
23-
menu.forEach((group) => {
24-
const child = group.children.find((child) => child.to === to);
25-
if (child) {
26-
setActiveId(child.title);
27-
}
28-
});
21+
const to = window.location.href.match(/\/components\/[a-zA-Z]+/)?.[0];
22+
if (to) {
23+
menu.forEach((group) => {
24+
const child = group.children.find((child) => child.to === to);
25+
if (child) {
26+
setActiveId(child.title);
27+
}
28+
});
2929

30-
if (to === '/components/Interface') {
31-
setActiveId('Interface');
30+
if (to === '/components/Interface') {
31+
setActiveId('Interface');
32+
}
3233
}
3334
}
3435
}, [pageMounted, setActiveId]);

packages/ui/src/components/_alert-dialog/AlertDialog.tsx

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,16 @@ export function DAlertDialog(props: DAlertDialogProps) {
5151
// eslint-disable-next-line react-hooks/exhaustive-deps
5252
}, []);
5353

54-
return (
55-
// eslint-disable-next-line react/jsx-no-useless-fragment
56-
<>
57-
{!dHidden && (
58-
<div
59-
{...restProps}
60-
ref={dDialogRef}
61-
role="alertdialog"
62-
aria-modal="true"
63-
onMouseEnter={handleMouseEnter}
64-
onMouseLeave={handleMouseLeave}
65-
>
66-
{children}
67-
</div>
68-
)}
69-
</>
54+
return dHidden ? null : (
55+
<div
56+
{...restProps}
57+
ref={dDialogRef}
58+
role="alertdialog"
59+
aria-modal="true"
60+
onMouseEnter={handleMouseEnter}
61+
onMouseLeave={handleMouseLeave}
62+
>
63+
{children}
64+
</div>
7065
);
7166
}

packages/ui/src/components/_dialog/Dialog.tsx

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,17 @@ export function DDialog(props: DDialogProps) {
5353
};
5454
}, [asyncCapture, dEscClosable, dVisible, onClose]);
5555

56-
return (
57-
// eslint-disable-next-line react/jsx-no-useless-fragment
58-
<>
59-
{!(dDestroy && dHidden) && (
60-
<div
61-
{...restProps}
62-
ref={dDialogRef}
63-
className={getClassName(className, `${dPrefix}dialog`)}
64-
style={mergeStyle({ display: dHidden ? 'none' : undefined }, style)}
65-
role="dialog"
66-
aria-modal="true"
67-
>
68-
{dMask && <DMask dVisible={dVisible} onClose={handleMaskClose} />}
69-
{children}
70-
</div>
71-
)}
72-
</>
56+
return dDestroy && dHidden ? null : (
57+
<div
58+
{...restProps}
59+
ref={dDialogRef}
60+
className={getClassName(className, `${dPrefix}dialog`)}
61+
style={mergeStyle({ display: dHidden ? 'none' : undefined }, style)}
62+
role="dialog"
63+
aria-modal="true"
64+
>
65+
{dMask && <DMask dVisible={dVisible} onClose={handleMaskClose} />}
66+
{children}
67+
</div>
7368
);
7469
}

packages/ui/src/components/_dialog/Mask.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,5 @@ export function DMask(props: DMaskProps) {
5454
...dTransitionProps,
5555
});
5656

57-
return (
58-
// eslint-disable-next-line react/jsx-no-useless-fragment
59-
<>{!hidden && <div {...restProps} ref={ref} className={getClassName(className, `${dPrefix}mask`)} onClick={handleClick}></div>}</>
60-
);
57+
return hidden ? null : <div {...restProps} ref={ref} className={getClassName(className, `${dPrefix}mask`)} onClick={handleClick}></div>;
6158
}

packages/ui/src/components/_select-box/SelectBox.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@ import { getClassName, getVerticalSideStyle } from '../../utils';
88
import { DPopup } from '../_popup';
99
import { DIcon } from '../icon';
1010

11+
export type DExtendsSelectBoxProps = Pick<
12+
DSelectBoxProps,
13+
| 'dSearchable'
14+
| 'dClearIcon'
15+
| 'dSize'
16+
| 'dPlaceholder'
17+
| 'dDisabled'
18+
| 'dLoading'
19+
| 'dPopupClassName'
20+
| 'onClear'
21+
| 'onSearch'
22+
| 'onVisibleChange'
23+
>;
24+
1125
export interface DSelectBoxProps extends React.HTMLAttributes<HTMLDivElement> {
1226
dPopupContent: React.ReactNode;
1327
dSuffix?: React.ReactNode;
@@ -25,7 +39,7 @@ export interface DSelectBoxProps extends React.HTMLAttributes<HTMLDivElement> {
2539
dAutoMaxWidth?: boolean;
2640
onClear?: () => void;
2741
onSearch?: (value: string) => void;
28-
onVisibleChange?: (expanded: boolean) => void;
42+
onVisibleChange?: (visible: boolean) => void;
2943
onRendered?: () => void;
3044
}
3145

packages/ui/src/components/_trigger/Trigger.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,5 @@ export function DTrigger(props: DTriggerProps) {
125125
return renderProps;
126126
}, [asyncCapture, dMouseEnterDelay, dMouseLeaveDelay, dTrigger, onTrigger]);
127127

128-
// eslint-disable-next-line react/jsx-no-useless-fragment
129-
return <>{dRender?.(renderProps)}</>;
128+
return (dRender?.(renderProps) as React.ReactElement) ?? null;
130129
}

0 commit comments

Comments
 (0)