[tgui] Linter fixes 1 (#91951)

## About The Pull Request
Atomized PR from converting us to biome. This converts all cases where
we're using `let` but it's never reassigned. This is considered a safe
fix
https://biomejs.dev/linter/rules/use-const/

## Command
Get [Biome](https://biomejs.dev/guides/manual-installation/) (the
executable, at least)
`biome lint --write --only "useConst"`


## Why It's Good For The Game
Moving us to a simple linter/formatter and shaving off a number of
packages, tech debt
## Changelog
Should be absolutely zero effect on gameplay
This commit is contained in:
Jeremiah
2025-07-06 22:10:21 +02:00
committed by GitHub
parent d898e32445
commit 8757460daf
53 changed files with 130 additions and 127 deletions
+2 -2
View File
@@ -14,9 +14,9 @@ const FRAME_DURATION = 1000 / FPS;
// True if Performance API is supported
const supportsPerf = !!window.performance?.now;
// High precision markers
let hpMarkersByName: Record<string, number> = {};
const hpMarkersByName: Record<string, number> = {};
// Low precision markers
let lpMarkersByName: Record<string, number> = {};
const lpMarkersByName: Record<string, number> = {};
/**
* Marks a certain spot in the code for later measurements.
+1 -1
View File
@@ -56,7 +56,7 @@ export const createStore = <State, ActionType extends Action = AnyAction>(
}
let currentState: State;
let listeners: Array<() => void> = [];
const listeners: Array<() => void> = [];
const getState = (): State => currentState;
+3 -3
View File
@@ -50,7 +50,7 @@ export class DreamSeeker {
const instances: DreamSeeker[] = [];
const pidsToResolve: number[] = [];
for (let pid of pids) {
for (const pid of pids) {
const instance = instanceByPid.get(pid);
if (instance) {
instances.push(instance);
@@ -76,7 +76,7 @@ export class DreamSeeker {
const entries: Entry[] = [];
const lines = stdout.split('\r\n');
for (let line of lines) {
for (const line of lines) {
const words = line.match(/\S+/g);
if (!words || words.length === 0) {
continue;
@@ -92,7 +92,7 @@ export class DreamSeeker {
const len = entries.length;
logger.log('found', len, plural('instance', len));
for (let entry of entries) {
for (const entry of entries) {
const { pid, addr } = entry;
const instance = new DreamSeeker(pid, addr);
instances.push(instance);
+1 -1
View File
@@ -22,7 +22,7 @@ function ensureConnection() {
socket.onmessage = (event) => {
const msg = JSON.parse(event.data);
for (let subscriber of subscribers) {
for (const subscriber of subscribers) {
subscriber(msg);
}
};
@@ -25,7 +25,7 @@ export async function loadSourceMaps(bundleDir: string): Promise<void> {
// Load new sourcemaps
const files = await resolveGlob(bundleDir, '*.map');
for (let file of files) {
for (const file of files) {
try {
const loc = path.resolve(bundleDir, file);
const parsed = await Bun.file(loc).json();
+9 -6
View File
@@ -40,7 +40,7 @@ export async function findCacheRoot(): Promise<string | undefined> {
logger.log('looking for byond cache');
// Find BYOND cache folders
for (let pattern of SEARCH_LOCATIONS) {
for (const pattern of SEARCH_LOCATIONS) {
if (!pattern) {
continue;
}
@@ -56,7 +56,10 @@ export async function findCacheRoot(): Promise<string | undefined> {
// Query the Windows Registry
if (process.platform === 'win32') {
logger.log('querying windows registry');
let userpath = await regQuery('HKCU\\Software\\Dantom\\BYOND', 'userpath');
const userpath = await regQuery(
'HKCU\\Software\\Dantom\\BYOND',
'userpath',
);
if (userpath) {
cacheRoot = userpath.replace(/\\$/, '').replace(/\\/g, '/') + '/cache';
await onCacheRootFound(cacheRoot);
@@ -91,10 +94,10 @@ export async function reloadByondCache(bundleDir: string): Promise<void> {
// Copy assets
const assets = await resolveGlob(bundleDir, bundleGlob);
for (let cacheDir of cacheDirs) {
for (const cacheDir of cacheDirs) {
// Clear garbage
const garbage = await resolveGlob(cacheDir, bundleGlob);
for (let file of garbage) {
for (const file of garbage) {
await Bun.file(file).delete();
}
@@ -103,7 +106,7 @@ export async function reloadByondCache(bundleDir: string): Promise<void> {
await Bun.write(cacheDir + '/dummy.htm', '');
// Copy assets
for (let asset of assets) {
for (const asset of assets) {
const destination = resolvePath(cacheDir, path.basename(asset));
const input = Bun.file(asset);
const output = Bun.file(destination);
@@ -120,7 +123,7 @@ export async function reloadByondCache(bundleDir: string): Promise<void> {
const dss = await dssPromise;
if (dss.length > 0) {
logger.log(`notifying dreamseeker`);
for (let dreamseeker of dss) {
for (const dreamseeker of dss) {
dreamseeker.topic({
tgui: 1,
type: 'cacheReloaded',
+1 -1
View File
@@ -63,7 +63,7 @@ const loadChatFromStorage = async (store: Store) => {
return;
}
if (messages) {
for (let message of messages) {
for (const message of messages) {
if (message.html) {
message.html = DOMPurify.sanitize(message.html, {
FORBID_TAGS,
+3 -3
View File
@@ -12,9 +12,9 @@ export const canPageAcceptType = (page, type) =>
type.startsWith(MESSAGE_TYPE_INTERNAL) || page.acceptedTypes[type];
export const createPage = (obj) => {
let acceptedTypes = {};
const acceptedTypes = {};
for (let typeDef of MESSAGE_TYPES) {
for (const typeDef of MESSAGE_TYPES) {
acceptedTypes[typeDef.type] = !!typeDef.important;
}
@@ -32,7 +32,7 @@ export const createPage = (obj) => {
export const createMainPage = () => {
const acceptedTypes = {};
for (let typeDef of MESSAGE_TYPES) {
for (const typeDef of MESSAGE_TYPES) {
acceptedTypes[typeDef.type] = true;
}
return createPage({
+5 -5
View File
@@ -42,11 +42,11 @@ export const chatReducer = (state = initialState, action) => {
// Enable any filters that are not explicitly set, that are
// enabled by default on the main page.
// NOTE: This mutates acceptedTypes on the state.
for (let id of Object.keys(payload.pageById)) {
for (const id of Object.keys(payload.pageById)) {
const page = payload.pageById[id];
const filters = page.acceptedTypes;
const defaultFilters = mainPage.acceptedTypes;
for (let type of Object.keys(defaultFilters)) {
for (const type of Object.keys(defaultFilters)) {
if (filters[type] === undefined) {
filters[type] = defaultFilters[type];
}
@@ -55,7 +55,7 @@ export const chatReducer = (state = initialState, action) => {
// Reset page message counts
// NOTE: We are mutably changing the payload on the assumption
// that it is a copy that comes straight from the web storage.
for (let id of Object.keys(payload.pageById)) {
for (const id of Object.keys(payload.pageById)) {
const page = payload.pageById[id];
page.unreadCount = 0;
}
@@ -88,9 +88,9 @@ export const chatReducer = (state = initialState, action) => {
const pages = state.pages.map((id) => state.pageById[id]);
const currentPage = state.pageById[state.currentPageId];
const nextPageById = { ...state.pageById };
for (let page of pages) {
for (const page of pages) {
let unreadCount = 0;
for (let type of Object.keys(countByType)) {
for (const type of Object.keys(countByType)) {
// Message does not belong here
if (!canPageAcceptType(page, type)) {
continue;
+7 -7
View File
@@ -196,7 +196,7 @@ class ChatRenderer {
}
assignStyle(style = {}) {
for (let key of Object.keys(style)) {
for (const key of Object.keys(style)) {
this.rootNode.style.setProperty(key, style[key]);
}
}
@@ -235,7 +235,7 @@ class ChatRenderer {
if (lines.length === 0) {
return;
}
let regexExpressions = [];
const regexExpressions = [];
// Organize each highlight entry into regex expressions and words
for (let line of lines) {
// Regex expression syntax is /[exp]/
@@ -307,7 +307,7 @@ class ChatRenderer {
// Re-add message nodes
const fragment = document.createDocumentFragment();
let node;
for (let message of this.messages) {
for (const message of this.messages) {
if (canPageAcceptType(page, message.type)) {
node = message.node;
fragment.appendChild(node);
@@ -362,7 +362,7 @@ class ChatRenderer {
const fragment = document.createDocumentFragment();
const countByType = {};
let node;
for (let payload of batch) {
for (const payload of batch) {
const message = createMessage(payload);
// Combine messages
const combinable = this.getCombinableMessage(message);
@@ -398,7 +398,7 @@ class ChatRenderer {
const childNode = nodes[i];
const targetName = childNode.getAttribute('data-component');
// Let's pull out the attibute info we need
let outputProps = {};
const outputProps = {};
for (let j = 0; j < childNode.attributes.length; j++) {
const attribute = childNode.attributes[j];
@@ -558,7 +558,7 @@ class ChatRenderer {
);
const messages = this.messages.slice(fromIndex);
// Remove existing nodes
for (let message of messages) {
for (const message of messages) {
message.node = undefined;
}
// Fast clear of the root node
@@ -610,7 +610,7 @@ class ChatRenderer {
cssText += 'body, html { background-color: #141414 }\n';
// Compile chat log as HTML text
let messagesHtml = '';
for (let message of this.visibleMessages) {
for (const message of this.visibleMessages) {
if (message.node) {
messagesHtml += message.node.outerHTML + '\n';
}
@@ -90,7 +90,7 @@ export const replaceInTextNode = (regex, words, createNode) => (node) => {
if (words) {
let i = 0;
let wordRegexStr = '(';
for (let word of words) {
for (const word of words) {
// Capture if the word is at the beginning, end, middle,
// or by itself in a message
wordRegexStr += `^${word}\\s\\W|\\s\\W${word}\\s\\W|\\s\\W${word}$|^${word}\\s\\W$`;
@@ -102,7 +102,7 @@ export const replaceInTextNode = (regex, words, createNode) => (node) => {
wordRegexStr += ')';
const wordRegex = new RegExp(wordRegexStr, 'gi');
if (regex && nodes) {
for (let a_node of nodes) {
for (const a_node of nodes) {
result = regexParseNode({
node: a_node,
regex: wordRegex,
+1 -1
View File
@@ -18,7 +18,7 @@ export class ChannelIterator {
}
for (let index = 1; index <= this.channels.length; index++) {
let nextIndex = (this.index + index) % this.channels.length;
const nextIndex = (this.index + index) % this.channels.length;
if (!this.blacklist.includes(this.channels[nextIndex])) {
this.index = nextIndex;
break;
+1 -1
View File
@@ -162,7 +162,7 @@ export function TguiSay() {
const iterator = channelIterator.current;
let newValue = event.currentTarget.value;
let newPrefix = getPrefix(newValue) || currentPrefix;
const newPrefix = getPrefix(newValue) || currentPrefix;
// Handles switching prefixes
if (newPrefix && newPrefix !== currentPrefix) {
setButtonContent(RADIO_PREFIXES[newPrefix]);
+1 -1
View File
@@ -59,7 +59,7 @@ export function getPrefix(
return;
}
let adjusted = value
const adjusted = value
.slice(0, 3)
?.toLowerCase()
?.replace('.', ':') as keyof typeof RADIO_PREFIXES;
+3 -3
View File
@@ -77,7 +77,7 @@ export const backendReducer = (state = initialState, action) => {
// Merge shared states
const shared = { ...state.shared };
if (payload.shared) {
for (let key of Object.keys(payload.shared)) {
for (const key of Object.keys(payload.shared)) {
const value = payload.shared[key];
if (value === '') {
shared[key] = undefined;
@@ -316,7 +316,7 @@ const chunkSplitter = {
[Symbol.split]: (string: string) => {
const charSeq = string[Symbol.iterator]().toArray();
const length = charSeq.length;
let chunks: string[] = [];
const chunks: string[] = [];
let startIndex = 0;
let endIndex = 1024;
while (startIndex < length) {
@@ -371,7 +371,7 @@ export const sendAct = (action: string, payload: object = {}) => {
'',
).length;
if (urlSize > 2048) {
let chunks: string[] = stringifiedPayload.split(chunkSplitter);
const chunks: string[] = stringifiedPayload.split(chunkSplitter);
const id = `${Date.now()}`;
globalStore?.dispatch(backendCreatePayloadQueue({ id, chunks }));
Byond.sendMessage('oversizedPayloadRequest', {
+1 -1
View File
@@ -180,7 +180,7 @@ export const recallWindowGeometry = async (
// Setup draggable window
export const setupDrag = async () => {
// Calculate screen offset caused by the windows taskbar
let windowPosition = getWindowPosition();
const windowPosition = getWindowPosition();
screenOffsetPromise = Byond.winget(Byond.windowId, 'pos').then((pos) => [
pos.x - windowPosition[0],
+1 -1
View File
@@ -139,7 +139,7 @@ function getErrorText(
message: string,
target: boolean,
) {
let reasonList: string[] = [];
const reasonList: string[] = [];
if (!target) reasonList.push('target');
if (!name) reasonList.push('name');
if (!job) reasonList.push('job');
@@ -112,7 +112,7 @@ const PressureIndicator = (props) => {
const {
currentStatus: { icon, color },
} = props;
let spin = icon === 'fan';
const spin = icon === 'fan';
return (
<Box color={color}>
+1 -1
View File
@@ -180,7 +180,7 @@ class PaintCanvas extends Component<PaintCanvasProps> {
if (this.modifiedElements.some(checkPointCoords.bind(null, x, y))) {
return;
}
let p: PointData = { x, y };
const p: PointData = { x, y };
this.modifiedElements.push(p);
const canvas = this.canvasRef.current!;
const ctx = canvas.getContext('2d')!;
@@ -40,7 +40,7 @@ export const CellularEmporium = (props) => {
const { can_readapt, genetic_points_count } = data;
const readaptTracker = (can_readapt: number): string => {
let firstPart = 'Readapt(';
const firstPart = 'Readapt(';
return firstPart.concat(can_readapt.toString(), ')');
};
return (
@@ -48,7 +48,7 @@ export const ColorMatrixEditor = (props) => {
width="50px"
format={(value) => toFixed(value, 2)}
onDrag={(value) => {
let retColor = currentColor;
const retColor = currentColor;
retColor[row * 4 + col] = value;
act('transition_color', {
color: retColor,
@@ -54,7 +54,7 @@ export function SubsystemViews(props: Props) {
let currentMax = 0;
if (inDeciseconds) {
for (let i = 0; i < sorted.length; i++) {
let value = sorted[i][propName];
const value = sorted[i][propName];
if (typeof value !== 'number') {
continue;
}
@@ -66,9 +66,9 @@ export function DetectiveBoard(props) {
}
function handleEvidenceRemoved(evidence: DataEvidence) {
let pinPosition = getPinPosition(evidence);
let new_connections: Connection[] = [];
for (let old_connection of connections) {
const pinPosition = getPinPosition(evidence);
const new_connections: Connection[] = [];
for (const old_connection of connections) {
if (
(old_connection.to.x === pinPosition.x &&
old_connection.to.y === pinPosition.y) ||
@@ -81,8 +81,8 @@ export function DetectiveBoard(props) {
}
setConnections(new_connections);
if (movingEvidenceConnections) {
let new_mov_connections: TypedConnection[] = [];
for (let old_connection of movingEvidenceConnections) {
const new_mov_connections: TypedConnection[] = [];
for (const old_connection of movingEvidenceConnections) {
if (
(old_connection.connection.to.x === pinPosition.x &&
old_connection.connection.to.y === pinPosition.y) ||
@@ -133,8 +133,8 @@ export function DetectiveBoard(props) {
function handleMouseUp(args: MouseEvent) {
if (movingEvidenceConnections && connectingEvidence) {
let new_connections: Connection[] = [];
for (let con of movingEvidenceConnections) {
const new_connections: Connection[] = [];
for (const con of movingEvidenceConnections) {
if (con.type === 'from') {
new_connections.push({
color: con.connection.color,
@@ -161,9 +161,9 @@ export function DetectiveBoard(props) {
!connectingEvidence.connections.includes(evidence.ref) &&
!evidence.connections.includes(connectingEvidence.ref)
) {
let new_connections: Connection[] = [];
const new_connections: Connection[] = [];
if (movingEvidenceConnections) {
for (let con of movingEvidenceConnections) {
for (const con of movingEvidenceConnections) {
if (con.type === 'from') {
new_connections.push({
color: con.connection.color,
@@ -199,10 +199,10 @@ export function DetectiveBoard(props) {
}
function handleEvidenceStartMoving(evidence: DataEvidence) {
let moving_connections: TypedConnection[] = [];
let pinPosition = getPinPosition(evidence);
let new_connections: Connection[] = [];
for (let con of connections) {
const moving_connections: TypedConnection[] = [];
const pinPosition = getPinPosition(evidence);
const new_connections: Connection[] = [];
for (const con of connections) {
if (con.from.x === pinPosition.x && con.from.y === pinPosition.y) {
moving_connections.push({ type: 'from', connection: con });
} else if (con.to.x === pinPosition.x && con.to.y === pinPosition.y) {
@@ -217,8 +217,8 @@ export function DetectiveBoard(props) {
function handleEvidenceMoving(evidence: DataEvidence, position: Position) {
if (movingEvidenceConnections) {
let new_connections: TypedConnection[] = [];
for (let con of movingEvidenceConnections) {
const new_connections: TypedConnection[] = [];
for (const con of movingEvidenceConnections) {
if (con.type === 'from') {
new_connections.push({
type: con.type,
@@ -245,8 +245,8 @@ export function DetectiveBoard(props) {
function handleEvidenceStopMoving(evidence: DataEvidence) {
if (movingEvidenceConnections) {
let new_connections: Connection[] = [];
for (let con of movingEvidenceConnections) {
const new_connections: Connection[] = [];
for (const con of movingEvidenceConnections) {
if (con.type === 'from') {
new_connections.push({
color: con.connection.color,
@@ -267,8 +267,8 @@ export function DetectiveBoard(props) {
}
function retrieveConnections(typedConnections: TypedConnection[]) {
let result: Connection[] = [];
for (let con of typedConnections) {
const result: Connection[] = [];
for (const con of typedConnections) {
result.push(con.connection);
}
return result;
@@ -178,14 +178,14 @@ export function ExperimentConfigure(props) {
const { act, data } = useBackend<Data>();
const { always_active, has_start_callback } = data;
let techwebs = data.techwebs ?? [];
const techwebs = data.techwebs ?? [];
const experiments = data.experiments.sort((a, b) =>
a.name.localeCompare(b.name),
);
// Group servers together by web
let webs = new Map();
const webs = new Map();
for (const x of techwebs) {
if (x.web_id !== null) {
if (!webs.has(x.web_id)) {
@@ -68,7 +68,7 @@ const ensure_gases = (gas_array: HypertorusGas[] = [], gasids) => {
gases_by_id[gas.id] = true;
});
for (let gasid of gasids) {
for (const gasid of gasids) {
if (!gases_by_id[gasid]) {
gas_array.push({ id: gasid, amount: 0 });
}
@@ -36,7 +36,7 @@ const height = 200;
const VerticalBar = (props) => {
const { color, value, progressHeight } = props;
let y = height - progressHeight;
const y = height - progressHeight;
return (
<div className="hypertorus-temperatures__vertical-bar">
@@ -88,7 +88,7 @@ export const InfuserBook = (props) => {
const paginatedEntries = paginateEntries(entries);
let currentEntry = paginatedEntries[chapter][pageInChapter];
const currentEntry = paginatedEntries[chapter][pageInChapter];
const switchChapter = (newChapter) => {
if (chapter === newChapter) {
@@ -301,7 +301,7 @@ const paginateEntries = (collection: Entry[]): Entry[][] => {
});
// negative 1 to account for introduction, which has no entries
let tier = -1;
for (let _ in range(tier, maxTier + 1)) {
for (const _ in range(tier, maxTier + 1)) {
pages.push(collection.filter((entry) => entry.tier === tier));
tier++;
}
@@ -73,8 +73,8 @@ export class ComponentMenu extends Component {
} = this.state;
const tabs = ['All'];
let shownComponents = componentData.filter((val) => {
let shouldShow = showAll || components.includes(val.type);
const shownComponents = componentData.filter((val) => {
const shouldShow = showAll || components.includes(val.type);
if (shouldShow) {
if (!tabs.includes(val.category)) {
tabs.push(val.category);
@@ -54,8 +54,8 @@ export class ObjectComponent extends Component {
if (dragPos && isDragging) {
e.preventDefault();
const { screenZoomX, screenZoomY, screenX, screenY } = e;
let xPos = screenZoomX || screenX;
let yPos = screenZoomY || screenY;
const xPos = screenZoomX || screenX;
const yPos = screenZoomY || screenY;
if (lastMousePos) {
this.setState({
dragPos: {
+1 -1
View File
@@ -42,7 +42,7 @@ const linkDecomposeRegex = /\[([^[]+)\]\(([^)]+)\)/;
// Renders any markdown-style links within a provided body of text
const linkifyText = (text: string) => {
let parts: ReactNode[] = text.split(linkRegex);
const parts: ReactNode[] = text.split(linkRegex);
for (let i = 1; i < parts.length; i += 2) {
const match = linkDecomposeRegex.exec(parts[i] as string);
if (!match) continue;
+1 -1
View File
@@ -90,7 +90,7 @@ export const LawPrintout = (props: { cyborg_ref: string; lawset: Law[] }) => {
const { data, act } = useBackend<Law>();
const { cyborg_ref, lawset } = props;
let num_of_each_lawtype = [];
const num_of_each_lawtype = [];
lawset.forEach((law) => {
if (!num_of_each_lawtype[law.lawtype]) {
+1 -1
View File
@@ -153,7 +153,7 @@ const validateRegExp = (str: string) => {
const CategoryViewer = (props: CategoryViewerProps) => {
const [search, setSearch] = useState('');
let [searchRegex, setSearchRegex] = useState(false);
let [caseSensitive, setCaseSensitive] = useState(false);
const [caseSensitive, setCaseSensitive] = useState(false);
if (!search && searchRegex) {
setSearchRegex(false);
searchRegex = false;
@@ -192,9 +192,9 @@ export const ListMapper = (props: ListMapperProps) => {
const ListMapperInner = (element: ListElement, i: number) => {
const { key, value } = element;
const basePath: ListPath = path ? path : [];
let keyPath: ListPath = [...basePath, { index: i + 1, type: 'key' }];
let valuePath: ListPath = [...basePath, { index: i + 1, type: 'value' }];
let entryPath: ListPath = [...basePath, { index: i + 1, type: 'entry' }];
const keyPath: ListPath = [...basePath, { index: i + 1, type: 'key' }];
const valuePath: ListPath = [...basePath, { index: i + 1, type: 'value' }];
const entryPath: ListPath = [...basePath, { index: i + 1, type: 'entry' }];
if (key === null && skipNulls) {
return;
@@ -204,7 +204,7 @@ export const ListMapper = (props: ListMapperProps) => {
* Finding a function only accessible as a table's key is too awkward to
* deal with for now
*/
let keyNode = ThingNode(key, keyPath, false);
const keyNode = ThingNode(key, keyPath, false);
/*
* Likewise, since table, thread, and userdata equality is tested by
@@ -215,7 +215,7 @@ export const ListMapper = (props: ListMapperProps) => {
typeof key === 'string' ||
typeof key === 'number' ||
(React.isValidElement(key) && key.key === 'ref');
let valueNode = ThingNode(
const valueNode = ThingNode(
value,
typeof key === 'number' ? keyPath : valuePath,
uniquelyIndexable,
+1 -1
View File
@@ -88,7 +88,7 @@ export const MODpaint = (props) => {
stepPixelSize={0.75}
format={(value) => `${value}%`}
onChange={(e, value) => {
let retColor = currentColor;
const retColor = currentColor;
retColor[row * 4 + col] = value / 100;
act('transition_color', { color: retColor });
}}
@@ -146,7 +146,7 @@ export class ChatScreen extends Component<ChatScreenProps, ChatScreenState> {
const { act } = useBackend();
const { chatRef, recipient } = this.props;
let ref = chatRef ? chatRef : recipient.ref;
const ref = chatRef ? chatRef : recipient.ref;
act('PDA_sendMessage', {
ref: ref,
@@ -175,7 +175,7 @@ export class ChatScreen extends Component<ChatScreenProps, ChatScreenState> {
} = this.props;
const { message, canSend, previewingImage, selectingPhoto } = this.state;
let filteredMessages: React.JSX.Element[] = [];
const filteredMessages: React.JSX.Element[] = [];
for (let index = 0; index < messages.length; index++) {
const message = messages[index];
@@ -497,7 +497,7 @@ const PetIcon = (props) => {
const { pet_state_icons = [] } = data;
const { our_pet_state } = props;
let icon_display = pet_state_icons.find(
const icon_display = pet_state_icons.find(
(pet_icon) => pet_icon.name === our_pet_state,
);
@@ -46,7 +46,7 @@ export const SymptomDisplay = (props) => {
/** Displays threshold data */
const Thresholds = (props) => {
const { thresholds = [] } = props;
let convertedThresholds = Object.entries<Threshold>(thresholds);
const convertedThresholds = Object.entries<Threshold>(thresholds);
return (
<Section mt={1} title="Thresholds">
@@ -187,7 +187,7 @@ export class PreviewView extends Component<PreviewViewProps> {
this.lastReadOnly = readOnly;
raw_text_input?.forEach((value) => {
let rawText = value.raw_text.trim();
const rawText = value.raw_text.trim();
if (!rawText.length) {
return;
}
@@ -197,7 +197,7 @@ export class PreviewView extends Component<PreviewViewProps> {
const fontBold = value.bold || false;
const advancedHtml = value.advanced_html || false;
let processingOutput = this.formatAndProcessRawText(
const processingOutput = this.formatAndProcessRawText(
rawText,
fontFace,
fontColor,
@@ -244,7 +244,7 @@ export class PreviewView extends Component<PreviewViewProps> {
const fontFace = held_item_details?.font || default_pen_font;
const fontBold = held_item_details?.use_bold || false;
let processingOutput = this.formatAndProcessRawText(
const processingOutput = this.formatAndProcessRawText(
textArea,
fontFace,
fontColor,
@@ -480,7 +480,7 @@ export class PreviewView extends Component<PreviewViewProps> {
const fieldData = field.field_data;
let input = document.createElement('input');
const input = document.createElement('input');
input.setAttribute('type', 'text');
input.style.fontSize = field.is_signature ? '15px' : `${fontSize}px`;
@@ -140,7 +140,7 @@ export class PrimaryView extends Component {
setTextAreaText(value);
if (this.scrollableRef.current) {
let thisDistFromBottom =
const thisDistFromBottom =
this.scrollableRef.current.scrollHeight -
this.scrollableRef.current.scrollTop;
this.scrollableRef.current.scrollTop +=
@@ -7,7 +7,7 @@ export const editKeyOf = (
let returnval = {};
Object.keys(icon_state).forEach((key) => {
if (key === old_key) {
let newPair = { [new_key]: icon_state[old_key] };
const newPair = { [new_key]: icon_state[old_key] };
returnval = { ...returnval, ...newPair };
} else {
returnval = { ...returnval, [key]: icon_state[key] };
+4 -4
View File
@@ -98,8 +98,8 @@ export const PetBuilder = (props) => {
const [selectedGender, setSelectedGender] = useState(pet_gender);
const ScrollPetSpecies = (direction: string) => {
let dir = direction === 'next' ? 1 : -1;
let currindex = pet_types.indexOf(selectedSpecie);
const dir = direction === 'next' ? 1 : -1;
const currindex = pet_types.indexOf(selectedSpecie);
const newSpecie =
pet_types[(currindex + dir + pet_types.length) % pet_types.length];
@@ -113,8 +113,8 @@ export const PetBuilder = (props) => {
if (!selectedPet) {
return;
}
let dir = direction === 'next' ? 1 : -1;
let currindex = filteredPetList.indexOf(selectedPet);
const dir = direction === 'next' ? 1 : -1;
const currindex = filteredPetList.indexOf(selectedPet);
setSelectedPet(
filteredPetList[
(currindex + dir + filteredPetList.length) % filteredPetList.length
@@ -261,7 +261,7 @@ function SpeciesPageInner(props: SpeciesPageInnerProps) {
const { act, data } = useBackend<PreferencesMenuData>();
const setSpecies = createSetPreference(act, 'species');
let species: [string, Species][] = Object.entries(props.species).map(
const species: [string, Species][] = Object.entries(props.species).map(
([species, data]) => {
return [species, data];
},
@@ -35,10 +35,10 @@ export function FeatureDropdownInput(props: DropdownInputProps) {
const { choices = [] } = serverData;
let newOptions: DropdownOptions = [];
const newOptions: DropdownOptions = [];
for (const choice of choices) {
let displayText: ReactNode = serverData.display_names
const displayText: ReactNode = serverData.display_names
? serverData.display_names[choice]
: capitalizeFirst(choice);
@@ -81,7 +81,7 @@ export function FeatureIconnedDropdownInput(props: IconnedDropdownInputProps) {
if (!serverData) return;
const { icons = {}, choices = [] } = serverData;
let newOptions: DropdownOptions = [];
const newOptions: DropdownOptions = [];
for (const choice of choices) {
let displayText: ReactNode = serverData.display_names?.[choice]
@@ -35,7 +35,7 @@ export function RecipeLibrary(props: ReagentsProps) {
if (!reagentFilter || currentReagents === null) {
return true;
}
let matches = reaction.reactants.filter((reactant) =>
const matches = reaction.reactants.filter((reactant) =>
currentReagents.includes(reactant.id),
).length;
return matches === currentReagents.length;
@@ -358,8 +358,8 @@ export const ReagentTooltip = (props) => {
props.reagents.forEach((reagent) => {
rate_total += reagent.rate;
});
let reagent_volumes: number[] = [];
let reagent_percentages: number[] = [];
const reagent_volumes: number[] = [];
const reagent_percentages: number[] = [];
props.reagents.forEach((reagent) => {
reagent_percentages.push(reagent.rate / Math.max(1, rate_total));
reagent_volumes.push(
+1 -1
View File
@@ -648,7 +648,7 @@ export const Spellbook = (props) => {
// Has a chance of selecting a random funny verb instead of "Searching"
const SelectSearchVerb = () => {
let found = Math.random();
const found = Math.random();
if (found <= 0.03) {
return 'Seeking';
}
@@ -34,7 +34,7 @@ function selectRemappedStaticData(data: TechWebData) {
// decompress the node IDs
const node_cache = {} as RemappedNode;
for (let id of Object.keys(data.static_data.node_cache)) {
for (const id of Object.keys(data.static_data.node_cache)) {
const node = data.static_data.node_cache[id];
const costs = Object.keys(node.costs || {}).map((x) => ({
@@ -56,7 +56,7 @@ function selectRemappedStaticData(data: TechWebData) {
// Do the same as the above for the design cache
const design_cache = {} as RemappedDesignCache;
for (let id of Object.keys(data.static_data.design_cache)) {
for (const id of Object.keys(data.static_data.design_cache)) {
const [name, classes] = data.static_data.design_cache[id];
design_cache[remapId(id)] = {
name: name,
@@ -33,7 +33,7 @@ export const GenericUplink = (props: GenericUplinkProps) => {
const [searchText, setSearchText] = useState('');
const [selectedCategory, setSelectedCategory] = useState(categories[0]);
const [compactMode, setCompactMode] = useState(false);
let items = props.items.filter((value) => {
const items = props.items.filter((value) => {
if (searchText.length === 0) {
return value.category === selectedCategory;
}
@@ -78,7 +78,7 @@ export function AccessConfig(props: ConfigProps) {
function checkAccessIcon(accesses: Area[]) {
let oneAccess = false;
let oneInaccess = false;
for (let element of accesses) {
for (const element of accesses) {
if (selectedList.includes(element.ref)) {
oneAccess = true;
} else {
@@ -253,7 +253,7 @@ const RegionAccessList = (props) => {
]);
const allWildcards = Object.keys(wildcardSlots);
let wcAccess = {};
const wcAccess = {};
allWildcards.forEach((wildcard) => {
wildcardSlots[wildcard].usage.forEach((access) => {
wcAccess[access] = wildcard;
+3 -3
View File
@@ -44,7 +44,7 @@ var __export = (target, all) => {
};
var __reExport = (target, module2, desc) => {
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
for (let key of __getOwnPropNames(module2))
for (const key of __getOwnPropNames(module2))
if (!__hasOwnProp.call(target, key) && key !== "default")
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
}
@@ -4755,7 +4755,7 @@ var glob = (globPath) => {
silent: true
});
const safePaths = [];
for (let path2 of unsafePaths) {
for (const path2 of unsafePaths) {
try {
import_fs3.default.lstatSync(path2);
safePaths.push(path2);
@@ -4834,7 +4834,7 @@ var runner = new class Runner {
args: []
});
}
let toVisit = Array.from(targetsToRun.entries());
const toVisit = Array.from(targetsToRun.entries());
while (true) {
const node = toVisit.shift();
if (!node) {
+1 -1
View File
@@ -4,7 +4,7 @@ import Juke from "../juke/index.js";
export function downloadFile(url: string, file: string): Promise<string> {
return new Promise((resolve, reject) => {
let file_stream = fs.createWriteStream(file);
const file_stream = fs.createWriteStream(file);
https
.get(url, function (response) {
if (response.statusCode === 302 && response.headers.location) {
+13 -13
View File
@@ -2,8 +2,8 @@ import * as autoLabelConfig from "./autoLabelConfig.js";
function keyword_to_cl_label() {
const keyword_to_cl_label = {};
for (let label in autoLabelConfig.changelog_labels) {
for (let keyword of autoLabelConfig.changelog_labels[label].keywords) {
for (const label in autoLabelConfig.changelog_labels) {
for (const keyword of autoLabelConfig.changelog_labels[label].keywords) {
keyword_to_cl_label[keyword] = label;
}
}
@@ -23,7 +23,7 @@ function check_body_for_labels(body) {
const keywords = keyword_to_cl_label();
let found_cl = false;
for (let line of body.split("\n")) {
for (const line of body.split("\n")) {
if (line.startsWith(":cl:")) {
found_cl = true;
continue;
@@ -53,9 +53,9 @@ function check_body_for_labels(body) {
function check_title_for_labels(title) {
const labels_to_add = [];
const title_lower = title.toLowerCase();
for (let label in autoLabelConfig.title_labels) {
for (const label in autoLabelConfig.title_labels) {
let found = false;
for (let keyword of autoLabelConfig.title_labels[label].keywords) {
for (const keyword of autoLabelConfig.title_labels[label].keywords) {
if (title_lower.includes(keyword)) {
found = true;
break;
@@ -81,10 +81,10 @@ async function check_diff_for_labels(diff_url) {
const diff = await fetch(diff_url);
if (diff.ok) {
const diff_txt = await diff.text();
for (let label in autoLabelConfig.file_labels) {
for (const label in autoLabelConfig.file_labels) {
let found = false;
const { filepaths, add_only } = autoLabelConfig.file_labels[label];
for (let filepath of filepaths) {
for (const filepath of filepaths) {
if (check_diff_line_for_element(diff_txt, filepath)) {
found = true;
break;
@@ -115,30 +115,30 @@ export async function get_updated_label_set({ github, context }) {
title = "",
} = pull_request;
let updated_labels = new Set();
for (let label of labels) {
const updated_labels = new Set();
for (const label of labels) {
updated_labels.add(label.name);
}
// diff is always checked
if (diff_url) {
const diff_tags = await check_diff_for_labels(diff_url);
for (let label of diff_tags.labels_to_add) {
for (const label of diff_tags.labels_to_add) {
updated_labels.add(label);
}
for (let label of diff_tags.labels_to_remove) {
for (const label of diff_tags.labels_to_remove) {
updated_labels.delete(label);
}
}
// body and title are only checked on open, not on sync
if (action === "opened") {
if (title) {
for (let label of check_title_for_labels(title)) {
for (const label of check_title_for_labels(title)) {
updated_labels.add(label);
}
}
if (body) {
for (let label of check_body_for_labels(body)) {
for (const label of check_body_for_labels(body)) {
updated_labels.add(label);
}
}