Skip to content

Commit 7e3d257

Browse files
committed
refactor: set @typescript-eslint/no-non-null-assertion to error only for ui
1 parent 1b5ec00 commit 7e3d257

9 files changed

Lines changed: 9 additions & 20 deletions

File tree

.eslintrc.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@
8181
"ignoreProperties": true
8282
}
8383
],
84-
"@typescript-eslint/no-non-null-assertion": "error",
8584
"no-unused-vars": "off",
8685
"@typescript-eslint/no-unused-vars": [
8786
"error",

packages/platform/src/app/components/map/MapMarkerCluster.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ export function AppMapMarkerCluster<T extends MarkerClusterDataOption>(props: Ap
103103
if (!isUndefined(color)) {
104104
content.style.color = color;
105105
}
106-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
107106
content.firstElementChild!.innerHTML = String(context.count);
108107

109108
context.marker.setOffset(new AMap.Pixel(-size / 2, -size / 2));

packages/platform/src/app/components/table/Table.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ export function AppTable<T = any>(props: AppTableProps<T>): JSX.Element | null {
174174
dPlacement="bottom-right"
175175
onItemClick={(id) => {
176176
if (actions[id].link) {
177-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
178177
navigate(actions[id].link!);
179178
} else {
180179
return actions[id].onclick?.();
@@ -262,7 +261,6 @@ export function AppTable<T = any>(props: AppTableProps<T>): JSX.Element | null {
262261
dPlacement="bottom-right"
263262
onItemClick={(id) => {
264263
if (actions[id].link) {
265-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
266264
navigate(actions[id].link!);
267265
} else {
268266
return actions[id].onclick?.();
@@ -315,7 +313,6 @@ export function AppTable<T = any>(props: AppTableProps<T>): JSX.Element | null {
315313
<DCard.Action
316314
title="edit"
317315
onClick={() => {
318-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
319316
navigate(action.link!);
320317
}}
321318
>
@@ -344,7 +341,6 @@ export function AppTable<T = any>(props: AppTableProps<T>): JSX.Element | null {
344341
dPlacement="bottom-right"
345342
onItemClick={(id) => {
346343
if (actions[id].link) {
347-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
348344
navigate(actions[id].link!);
349345
} else {
350346
return actions[id].onclick?.();

packages/platform/src/app/core/http/mock.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ if (environment.http.mock) {
127127
mock.onGet(/\/api\/v1\/device\/[0-9]+/).reply((config) => {
128128
return new Promise((resolve) => {
129129
setTimeout(() => {
130-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
131130
resolve([200, deviceList.find((device) => device.id === Number(config.url!.match(/[0-9]+$/)![0]))]);
132131
}, 500);
133132
});

packages/platform/src/app/routes/list/standard-table/DeviceModal.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ export function AppDeviceModal(props: AppDeviceModalProps): JSX.Element | null {
3030
model: new FormControl<string | null>(null, Validators.required),
3131
});
3232
if (aDevice) {
33-
form.reset({ name: aDevice.name });
33+
form.reset({
34+
name: aDevice.name,
35+
model: aDevice.model,
36+
});
3437
}
3538
return form;
3639
});
@@ -47,10 +50,6 @@ export function AppDeviceModal(props: AppDeviceModalProps): JSX.Element | null {
4750
disabled: model.disabled,
4851
}))
4952
);
50-
if (aDevice) {
51-
form.patchValue({ model: aDevice.model });
52-
updateForm();
53-
}
5453
},
5554
});
5655
});

packages/platform/src/app/routes/list/standard-table/StandardTable.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export default AppRoute(() => {
4141
page: 1,
4242
pageSize: 10,
4343
});
44-
const [deviceQuery, setDeviceQuery] = useImmer<DeviceQueryParams>({ ...deviceQuerySaved, model: [] });
44+
const [deviceQuery, setDeviceQuery] = useImmer(deviceQuerySaved);
4545
const queryEmptyStatus = (() => {
4646
const getEmptyStatus = (query: DeviceQueryParams) => ({
4747
keyword: query.keyword.length === 0,
@@ -80,9 +80,6 @@ export default AppRoute(() => {
8080
disabled: model.disabled,
8181
}))
8282
);
83-
setDeviceQuery((draft) => {
84-
draft.model = deviceQuerySaved.model;
85-
});
8683
},
8784
});
8885
});
@@ -198,8 +195,8 @@ export default AppRoute(() => {
198195
node: (
199196
<DSelect
200197
style={{ width: '16em' }}
201-
dList={modelList ?? []}
202198
dModel={deviceQuery.model}
199+
dList={modelList ?? []}
203200
dLoading={isUndefined(modelList)}
204201
dPlaceholder="Model"
205202
dMultiple

packages/platform/src/app/routes/list/standard-table/detail/Detail.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export default AppRoute(() => {
2222
const deviceApi = useAPI(http, '/device');
2323

2424
const { id: _id } = useParams();
25-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
2625
const id = Number(_id!);
2726

2827
const [deviceLoading, setDeviceLoading] = useState(true);

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ export function AppIcon() {
4848
dType="success"
4949
onClose={() => {
5050
setToasts((draft) => {
51-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
5251
draft.find((n) => n.key === key)!.visible = false;
5352
});
5453
}}

packages/ui/.eslintrc.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
},
1616
{
1717
"files": ["*.ts", "*.tsx"],
18-
"rules": {}
18+
"rules": {
19+
"@typescript-eslint/no-non-null-assertion": "error"
20+
}
1921
},
2022
{
2123
"files": ["*.js", "*.jsx"],

0 commit comments

Comments
 (0)