Skip to content

Commit

Permalink
refactor: set @typescript-eslint/no-non-null-assertion to error only …
Browse files Browse the repository at this point in the history
…for ui
  • Loading branch information
xiejay97 committed Mar 16, 2023
1 parent 1b5ec00 commit 7e3d257
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 20 deletions.
1 change: 0 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
"ignoreProperties": true
}
],
"@typescript-eslint/no-non-null-assertion": "error",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"error",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ export function AppMapMarkerCluster<T extends MarkerClusterDataOption>(props: Ap
if (!isUndefined(color)) {
content.style.color = color;
}
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
content.firstElementChild!.innerHTML = String(context.count);

context.marker.setOffset(new AMap.Pixel(-size / 2, -size / 2));
Expand Down
4 changes: 0 additions & 4 deletions packages/platform/src/app/components/table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ export function AppTable<T = any>(props: AppTableProps<T>): JSX.Element | null {
dPlacement="bottom-right"
onItemClick={(id) => {
if (actions[id].link) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
navigate(actions[id].link!);
} else {
return actions[id].onclick?.();
Expand Down Expand Up @@ -262,7 +261,6 @@ export function AppTable<T = any>(props: AppTableProps<T>): JSX.Element | null {
dPlacement="bottom-right"
onItemClick={(id) => {
if (actions[id].link) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
navigate(actions[id].link!);
} else {
return actions[id].onclick?.();
Expand Down Expand Up @@ -315,7 +313,6 @@ export function AppTable<T = any>(props: AppTableProps<T>): JSX.Element | null {
<DCard.Action
title="edit"
onClick={() => {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
navigate(action.link!);
}}
>
Expand Down Expand Up @@ -344,7 +341,6 @@ export function AppTable<T = any>(props: AppTableProps<T>): JSX.Element | null {
dPlacement="bottom-right"
onItemClick={(id) => {
if (actions[id].link) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
navigate(actions[id].link!);
} else {
return actions[id].onclick?.();
Expand Down
1 change: 0 additions & 1 deletion packages/platform/src/app/core/http/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ if (environment.http.mock) {
mock.onGet(/\/api\/v1\/device\/[0-9]+/).reply((config) => {
return new Promise((resolve) => {
setTimeout(() => {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
resolve([200, deviceList.find((device) => device.id === Number(config.url!.match(/[0-9]+$/)![0]))]);
}, 500);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ export function AppDeviceModal(props: AppDeviceModalProps): JSX.Element | null {
model: new FormControl<string | null>(null, Validators.required),
});
if (aDevice) {
form.reset({ name: aDevice.name });
form.reset({
name: aDevice.name,
model: aDevice.model,
});
}
return form;
});
Expand All @@ -47,10 +50,6 @@ export function AppDeviceModal(props: AppDeviceModalProps): JSX.Element | null {
disabled: model.disabled,
}))
);
if (aDevice) {
form.patchValue({ model: aDevice.model });
updateForm();
}
},
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default AppRoute(() => {
page: 1,
pageSize: 10,
});
const [deviceQuery, setDeviceQuery] = useImmer<DeviceQueryParams>({ ...deviceQuerySaved, model: [] });
const [deviceQuery, setDeviceQuery] = useImmer(deviceQuerySaved);
const queryEmptyStatus = (() => {
const getEmptyStatus = (query: DeviceQueryParams) => ({
keyword: query.keyword.length === 0,
Expand Down Expand Up @@ -80,9 +80,6 @@ export default AppRoute(() => {
disabled: model.disabled,
}))
);
setDeviceQuery((draft) => {
draft.model = deviceQuerySaved.model;
});
},
});
});
Expand Down Expand Up @@ -198,8 +195,8 @@ export default AppRoute(() => {
node: (
<DSelect
style={{ width: '16em' }}
dList={modelList ?? []}
dModel={deviceQuery.model}
dList={modelList ?? []}
dLoading={isUndefined(modelList)}
dPlaceholder="Model"
dMultiple
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export default AppRoute(() => {
const deviceApi = useAPI(http, '/device');

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

const [deviceLoading, setDeviceLoading] = useState(true);
Expand Down
1 change: 0 additions & 1 deletion packages/site/src/app/components/route/component/Icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ export function AppIcon() {
dType="success"
onClose={() => {
setToasts((draft) => {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
draft.find((n) => n.key === key)!.visible = false;
});
}}
Expand Down
4 changes: 3 additions & 1 deletion packages/ui/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
"rules": {
"@typescript-eslint/no-non-null-assertion": "error"
}
},
{
"files": ["*.js", "*.jsx"],
Expand Down

0 comments on commit 7e3d257

Please sign in to comment.