mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-20 15:43:13 +09:00
Fix bad typings detected by linting
Fix badly typed expressions that were detected by turning on `@typescript-eslint/no-unnecessary-condition` in eslint.
This commit is contained in:
1 parent
90a88f7e01
commit
ec734c92bc
29 files changed
+62
-73
No files matched your search
@@ -74,7 +74,7 @@ export default function AssignInstanceModal(props: AssignInstanceModalProps) {
|
||||
the instance. Note that reassigning an instance from
|
||||
one host to another will not move the server save over.
|
||||
</Paragraph>
|
||||
<Form form={form} initialValues={{ host: props.hostId === null ? "null" : props.hostId }}>
|
||||
<Form form={form} initialValues={{ host: props.hostId ?? "null" }}>
|
||||
<Form.Item name="host" label="Host">
|
||||
<Select>
|
||||
<Select.Option value={"null"}>
|
||||
|
||||
@@ -189,7 +189,7 @@ export default function HostsPage() {
|
||||
return <PageLayout nav={[{ name: "Hosts" }]}>
|
||||
<PageHeader
|
||||
title="Hosts"
|
||||
extra={account.hasPermission("core.host.generate_token") && <GenerateHostTokenButton /> || undefined}
|
||||
extra={account.hasPermission("core.host.generate_token") ? <GenerateHostTokenButton /> : undefined}
|
||||
/>
|
||||
<Table
|
||||
columns={[
|
||||
|
||||
@@ -34,7 +34,7 @@ function InstanceDescription(props: InstanceDescriptionProps) {
|
||||
let account = useAccount();
|
||||
|
||||
const { host, instance } = props;
|
||||
let assigned = instance.assignedHost !== null;
|
||||
let assigned = instance.assignedHost !== undefined;
|
||||
return <Descriptions
|
||||
bordered
|
||||
size="small"
|
||||
|
||||
@@ -8,7 +8,7 @@ const { useBreakpoint } = Grid;
|
||||
|
||||
type ModDetailsProps<T> = {
|
||||
mod: T;
|
||||
actions: (mod: T) => React.JSX.Element;
|
||||
actions?: (mod: T) => React.JSX.Element;
|
||||
};
|
||||
export default function ModDetails<T extends lib.ModInfo | lib.ModRecord>(props: ModDetailsProps<T>) {
|
||||
let screens = useBreakpoint();
|
||||
|
||||
@@ -296,13 +296,11 @@ function ModsTable(props: ModsTableProps) {
|
||||
>remove</Typography.Link>}
|
||||
{(deletedMods.has(mod.name) || changedMods.has(mod.name)) && <Typography.Link
|
||||
onClick={() => {
|
||||
if (props.onRevert) {
|
||||
props.onRevert({
|
||||
type: deletedMods.has(mod.name) ? "mods.delete" : "mods.set",
|
||||
name: mod.name,
|
||||
value: mod,
|
||||
});
|
||||
}
|
||||
props.onRevert({
|
||||
type: deletedMods.has(mod.name) ? "mods.delete" : "mods.set",
|
||||
name: mod.name,
|
||||
value: mod,
|
||||
});
|
||||
}}
|
||||
>revert</Typography.Link>}
|
||||
</Space>;
|
||||
@@ -464,7 +462,7 @@ const SettingsTableField = memo((props: SettingsTableFieldProps) => {
|
||||
return Promise.resolve();
|
||||
},
|
||||
}] : []]}
|
||||
className={ props.changed && "changed" || "" }
|
||||
className={props.changed ? "changed" : ""}
|
||||
>
|
||||
{input}
|
||||
</Form.Item>;
|
||||
@@ -669,11 +667,11 @@ function applyModPackChanges(modPack: lib.ModPack, changes: ModChange[]) {
|
||||
} else if (change.type === "mods.delete") {
|
||||
modifiedModPack.mods.delete(change.name!);
|
||||
} else if (change.type === "settings.set") {
|
||||
if (change.scope && change.name) {
|
||||
if (change.name) {
|
||||
modifiedModPack.settings[change.scope].set(change.name, change.value);
|
||||
}
|
||||
} else if (change.type === "settings.delete") {
|
||||
if (change.scope && change.name) {
|
||||
if (change.name) {
|
||||
modifiedModPack.settings[change.scope].delete(change.name);
|
||||
}
|
||||
} else {
|
||||
@@ -828,7 +826,7 @@ export default function ModPackViewPage() {
|
||||
<Descriptions.Item span={3} label="Name">
|
||||
<Form.Item noStyle name="name">
|
||||
<Input
|
||||
className={hasChange(changes, { type: "name" }) && "changed" || ""}
|
||||
className={hasChange(changes, { type: "name" }) ? "changed" : ""}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Descriptions.Item>
|
||||
@@ -836,7 +834,7 @@ export default function ModPackViewPage() {
|
||||
<Form.Item noStyle name="description">
|
||||
<Input.TextArea
|
||||
autoSize={{ minRows: 2 }}
|
||||
className={hasChange(changes, { type: "description" }) && "changed" || ""}
|
||||
className={hasChange(changes, { type: "description" }) ? "changed" : ""}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Descriptions.Item>
|
||||
@@ -853,7 +851,7 @@ export default function ModPackViewPage() {
|
||||
}]}
|
||||
>
|
||||
<Input
|
||||
className={hasChange(changes, { type: "factorioVersion" }) && "changed" || ""}
|
||||
className={hasChange(changes, { type: "factorioVersion" }) ? "changed" : ""}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Descriptions.Item>
|
||||
|
||||
@@ -11,7 +11,7 @@ import notify from "../util/notify";
|
||||
export default function PluginViewPage() {
|
||||
let params = useParams();
|
||||
let plugins = useContext(ControlContext).plugins;
|
||||
let [pluginList, setPluginList] = useState<PluginWebApi[]>([]);
|
||||
let [pluginList, setPluginList] = useState<PluginWebApi[]>();
|
||||
let pluginName = String(params.name);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -74,7 +74,7 @@ export default function RolesPage() {
|
||||
return <PageLayout nav={[{ name: "Roles" }]}>
|
||||
<PageHeader
|
||||
title="Roles"
|
||||
extra={account.hasPermission("core.role.create") && <CreateRoleButton /> || undefined}
|
||||
extra={account.hasPermission("core.role.create") ? <CreateRoleButton /> : undefined}
|
||||
/>
|
||||
<Table
|
||||
columns={[
|
||||
|
||||
@@ -93,7 +93,7 @@ export default function UserViewPage() {
|
||||
return role?.name.toLowerCase().includes(inputValue.toLowerCase()) ?? false;
|
||||
}}
|
||||
>
|
||||
{roles && [...roles.values()].map(r => <Select.Option
|
||||
{[...roles.values()].map(r => <Select.Option
|
||||
key={r.id}
|
||||
value={r.id}
|
||||
>{r.name}</Select.Option>)}
|
||||
@@ -182,7 +182,7 @@ export default function UserViewPage() {
|
||||
{account.hasPermission("core.user.update_roles")
|
||||
? roleSelector
|
||||
: [...user.roleIds!].map(id => <Tag key={id}>{
|
||||
roles ? (roles.get(id) || { name: id }).name : id
|
||||
roles?.get(id)?.name ?? id
|
||||
}</Tag>)
|
||||
}
|
||||
</Col>
|
||||
|
||||
@@ -75,7 +75,7 @@ export default function UsersPage() {
|
||||
return <PageLayout nav={[{ name: "Users" }]}>
|
||||
<PageHeader
|
||||
title="Users"
|
||||
extra={account.hasPermission("core.user.create") && <CreateUserButton /> || undefined}
|
||||
extra={account.hasPermission("core.user.create") ? <CreateUserButton /> : undefined}
|
||||
/>
|
||||
<Table
|
||||
columns={[
|
||||
|
||||
Reference in new issue
Block a user