[tgui] Linter fixes 5 (#92051)

## About The Pull Request
Batch of fixes from the biome linter. Many files could have their syntax
shortened.

I also fixed a prettier ignore file issue so that tgui.html can properly
get formatted
## Command
Get [Biome](https://biomejs.dev/guides/manual-installation/) (the
executable, at least)
`biome lint --write --only "useOptionalChain" --unsafe`

## Why It's Good For The Game
Moving us to a simple linter/formatter and shaving off a number of
packages, tech debt
## Changelog
This commit is contained in:
Jeremiah
2025-07-10 23:27:59 -07:00
committed by Roxy
parent 4043623715
commit 93ef5c2455
19 changed files with 36 additions and 57 deletions

View File

@@ -4,16 +4,11 @@ data
font-awesome font-awesome
jquery jquery
juke juke
**/build
**/dist
**/node_modules
## Tgui
node_modules
.yarn
# Avoid running on any bundles.
tgui/public
# Running it on tgui.html is fine, however.
!/tgui/public/tgui.html
# Specific files
package-lock.json
# File names / types # File names / types
*.min.* *.min.*
*.pnp.* *.pnp.*
*.bundle.*

View File

@@ -1,8 +1,5 @@
.pnp.*
.yarn
node_modules node_modules
public
# Avoid running on any bundles.
/public/**/*
# Running it on tgui.html is fine, however. # Running it on tgui.html is fine, however.
!/public/tgui.html !/public/tgui.html

View File

@@ -542,9 +542,9 @@ const TravelTargetSelectionScreen = (props: {
dest.band_info[s] !== undefined && dest.band_info[s] !== 0; dest.band_info[s] !== undefined && dest.band_info[s] !== 0;
return Object.keys(all_bands).filter(band_check); return Object.keys(all_bands).filter(band_check);
}; };
const valid_destinations = const valid_destinations = sites?.filter(
sites && (destination) => !site || destination.ref !== site.ref,
sites.filter((destination) => !site || destination.ref !== site.ref); );
return ( return (
(drone.drone_status === DroneStatusEnum.Travel && ( (drone.drone_status === DroneStatusEnum.Travel && (
<TravelDimmer drone={drone} /> <TravelDimmer drone={drone} />

View File

@@ -224,10 +224,9 @@ export const ExoscannerConsole = (props) => {
</Stack.Item> </Stack.Item>
</Stack> </Stack>
<Section title="Special Scan Condtions"> <Section title="Special Scan Condtions">
{scan_conditions && {scan_conditions?.map((condition) => (
scan_conditions.map((condition) => ( <NoticeBox key={condition}>{condition}</NoticeBox>
<NoticeBox key={condition}>{condition}</NoticeBox> ))}
))}
</Section> </Section>
</Section> </Section>
</Stack.Item> </Stack.Item>

View File

@@ -330,14 +330,11 @@ const QueueList = (props: QueueListProps) => {
<Box <Box
width={'32px'} width={'32px'}
height={'32px'} height={'32px'}
className={classes([ className={classes(['design32x32', entry.design?.icon])}
'design32x32',
entry.design && entry.design.icon,
])}
/> />
</div> </div>
<div className="FabricatorRecipe__Label"> <div className="FabricatorRecipe__Label">
{entry.design && entry.design.name} {entry.design?.name}
</div> </div>
</div> </div>
</Tooltip> </Tooltip>

View File

@@ -500,7 +500,7 @@ const CategoryView = <T extends Design = Design>(
title={category.title} title={category.title}
key={category.anchorKey} key={category.anchorKey}
container_id={category.anchorKey} container_id={category.anchorKey}
buttons={categoryButtons && categoryButtons(category)} buttons={categoryButtons?.(category)}
> >
{body} {body}
</Section> </Section>

View File

@@ -63,7 +63,7 @@ export const MaterialAccessBar = (props: MaterialAccessBarProps) => {
material={material} material={material}
SHEET_MATERIAL_AMOUNT={SHEET_MATERIAL_AMOUNT} SHEET_MATERIAL_AMOUNT={SHEET_MATERIAL_AMOUNT}
onEjectRequested={(quantity) => onEjectRequested={(quantity) =>
onEjectRequested && onEjectRequested(material, quantity) onEjectRequested?.(material, quantity)
} }
/> />
</Flex.Item> </Flex.Item>

View File

@@ -429,7 +429,7 @@ export class IntegratedCircuit extends Component {
for (const output of input.connected_to) { for (const output of input.connected_to) {
const output_port = locations[output]; const output_port = locations[output];
connections.push({ connections.push({
color: (output_port && output_port.color) || 'blue', color: output_port?.color || 'blue',
from: output_port, from: output_port,
to: locations[input.ref], to: locations[input.ref],
}); });
@@ -446,7 +446,7 @@ export class IntegratedCircuit extends Component {
y: (mouseY + ABSOLUTE_Y_OFFSET) * Math.pow(zoom, -1), y: (mouseY + ABSOLUTE_Y_OFFSET) * Math.pow(zoom, -1),
}; };
connections.push({ connections.push({
color: (portLocation && portLocation.color) || 'blue', color: portLocation?.color || 'blue',
from: isOutput ? portLocation : mouseCoords, from: isOutput ? portLocation : mouseCoords,
to: isOutput ? mouseCoords : portLocation, to: isOutput ? mouseCoords : portLocation,
}); });

View File

@@ -264,7 +264,7 @@ export const ListMapper = (props: ListMapperProps) => {
const inner = ( const inner = (
<> <>
{list && list.map(ListMapperInner)} {list?.map(ListMapperInner)}
{editable && ( {editable && (
<Button <Button
icon="plus" icon="plus"

View File

@@ -164,12 +164,7 @@ export const MafiaPanel = (props) => {
const { act, data } = useBackend<MafiaData>(); const { act, data } = useBackend<MafiaData>();
const { roleinfo } = data; const { roleinfo } = data;
return ( return (
<Window <Window title="Mafia" theme={roleinfo?.role_theme} width={900} height={600}>
title="Mafia"
theme={roleinfo && roleinfo.role_theme}
width={900}
height={600}
>
<Window.Content> <Window.Content>
<MafiaPanelData /> <MafiaPanelData />
</Window.Content> </Window.Content>

View File

@@ -13,8 +13,8 @@ import { Window } from '../layouts';
export const MechBayPowerConsole = (props) => { export const MechBayPowerConsole = (props) => {
const { act, data } = useBackend(); const { act, data } = useBackend();
const { recharge_port } = data; const { recharge_port } = data;
const mech = recharge_port && recharge_port.mech; const mech = recharge_port?.mech;
const cell = mech && mech.cell; const cell = mech?.cell;
return ( return (
<Window width={400} height={200}> <Window width={400} height={200}>
<Window.Content> <Window.Content>

View File

@@ -171,14 +171,14 @@ export const NtosNetChat = (props) => {
</Stack.Item> </Stack.Item>
{!!in_channel && ( {!!in_channel && (
<Input <Input
backgroundColor={this_client && this_client.muted && 'red'} backgroundColor={this_client?.muted && 'red'}
height="22px" height="22px"
placeholder={ placeholder={
(this_client && this_client.muted && 'You are muted!') || (this_client?.muted && 'You are muted!') ||
'Message ' + title 'Message ' + title
} }
fluid fluid
disabled={this_client && this_client.muted} disabled={this_client?.muted}
selfClear selfClear
mt={1} mt={1}
onEnter={(value) => onEnter={(value) =>

View File

@@ -229,14 +229,12 @@ export function RecipeContent(props: FullProps) {
{(item.tool_paths || item.tool_behaviors) && ( {(item.tool_paths || item.tool_behaviors) && (
<Box> <Box>
<GroupTitle title="Tools" /> <GroupTitle title="Tools" />
{item.tool_paths && {item.tool_paths?.map((tool) => (
item.tool_paths.map((tool) => ( <AtomContent key={tool} atom_id={tool} amount={1} />
<AtomContent key={tool} atom_id={tool} amount={1} /> ))}
))} {item.tool_behaviors?.map((tool) => (
{item.tool_behaviors && <ToolContent key={tool} tool={tool} />
item.tool_behaviors.map((tool) => ( ))}
<ToolContent key={tool} tool={tool} />
))}
</Box> </Box>
)} )}
{item.machinery && ( {item.machinery && (

View File

@@ -111,8 +111,7 @@ function AntagSelection(props: AntagSelectionProps) {
const isBanned = const isBanned =
data.antag_bans && data.antag_bans.indexOf(antagonist.key) !== -1; data.antag_bans && data.antag_bans.indexOf(antagonist.key) !== -1;
const daysLeft = const daysLeft = data.antag_days_left?.[antagonist.key] || 0;
(data.antag_days_left && data.antag_days_left[antagonist.key]) || 0;
return ( return (
<Flex.Item <Flex.Item

View File

@@ -193,8 +193,7 @@ function JobRow(props: JobRowProps) {
const createSetPriority = createCreateSetPriorityFromName(name); const createSetPriority = createCreateSetPriorityFromName(name);
const experienceNeeded = const experienceNeeded = data.job_required_experience?.[name];
data.job_required_experience && data.job_required_experience[name];
const daysLeft = data.job_days_left ? data.job_days_left[name] : 0; const daysLeft = data.job_days_left ? data.job_days_left[name] : 0;
// SKYRAT EDIT ADDITION // SKYRAT EDIT ADDITION

View File

@@ -490,7 +490,7 @@ export function MainPage(props: MainPageProps) {
const serverData = useServerPrefs(); const serverData = useServerPrefs();
const currentSpeciesData = const currentSpeciesData =
serverData && serverData.species[data.character_preferences.misc.species]; serverData?.species[data.character_preferences.misc.species];
const contextualPreferences = const contextualPreferences =
data.character_preferences.secondary_features || []; data.character_preferences.secondary_features || [];

View File

@@ -626,7 +626,7 @@ const CategoryDisplay = (props: { ActiveCat: TabType }) => {
</Stack.Item> </Stack.Item>
)} )}
<Stack.Item> <Stack.Item>
{(ActiveCat.component && ActiveCat.component()) || ( {ActiveCat.component?.() || (
<SpellTabDisplay TabSpells={TabSpells} PointOffset={38} /> <SpellTabDisplay TabSpells={TabSpells} PointOffset={38} />
)} )}
</Stack.Item> </Stack.Item>

View File

@@ -219,7 +219,7 @@ const ProductDisplay = (props: {
<Stack> <Stack>
{!all_products_free && user && ( {!all_products_free && user && (
<Stack.Item fontSize="16px" color="green"> <Stack.Item fontSize="16px" color="green">
{(user && user.cash) || 0} {user?.cash || 0}
{displayed_currency_name} {displayed_currency_name}
<Icon name={displayed_currency_icon} color="gold" /> <Icon name={displayed_currency_icon} color="gold" />
</Stack.Item> </Stack.Item>

View File

@@ -38,7 +38,7 @@ function Story() {
setTimeout(() => { setTimeout(() => {
try { try {
const result = new Function('return (' + code + ')')(); const result = new Function('return (' + code + ')')();
if (result && result.then) { if (result?.then) {
logger.log('Promise'); logger.log('Promise');
result.then(logger.log); result.then(logger.log);
} else { } else {