Merge pull request #1113 from fosrl/copilot/fix-1112

Fix ESLint issues: prefer-const warnings and missing semicolons
This commit is contained in:
Owen Schwartz
2025-08-10 10:15:58 -07:00
committed by GitHub
40 changed files with 52 additions and 51 deletions

View File

@@ -271,7 +271,7 @@ export async function getNextAvailableClientSubnet(
) )
].filter((address) => address !== null) as string[]; ].filter((address) => address !== null) as string[];
let subnet = findNextAvailableCidr(addresses, 32, org.subnet); // pick the sites address in the org const subnet = findNextAvailableCidr(addresses, 32, org.subnet); // pick the sites address in the org
if (!subnet) { if (!subnet) {
throw new Error("No available subnets remaining in space"); throw new Error("No available subnets remaining in space");
} }
@@ -289,7 +289,7 @@ export async function getNextAvailableOrgSubnet(): Promise<string> {
const addresses = existingAddresses.map((org) => org.subnet!); const addresses = existingAddresses.map((org) => org.subnet!);
let subnet = findNextAvailableCidr( const subnet = findNextAvailableCidr(
addresses, addresses,
config.getRawConfig().orgs.block_size, config.getRawConfig().orgs.block_size,
config.getRawConfig().orgs.subnet_group config.getRawConfig().orgs.subnet_group

View File

@@ -1,6 +1,6 @@
import { MemoryStore, Store } from "express-rate-limit"; import { MemoryStore, Store } from "express-rate-limit";
export function createStore(): Store { export function createStore(): Store {
let rateLimitStore: Store = new MemoryStore(); const rateLimitStore: Store = new MemoryStore();
return rateLimitStore; return rateLimitStore;
} }

View File

@@ -222,7 +222,7 @@ export async function listAccessTokens(
(resource) => resource.resourceId (resource) => resource.resourceId
); );
let countQuery: any = db const countQuery: any = db
.select({ count: count() }) .select({ count: count() })
.from(resources) .from(resources)
.where(inArray(resources.resourceId, accessibleResourceIds)); .where(inArray(resources.resourceId, accessibleResourceIds));

View File

@@ -48,7 +48,7 @@ export async function getAllRelays(
} }
// Fetch exit node // Fetch exit node
let [exitNode] = await db.select().from(exitNodes).where(eq(exitNodes.publicKey, publicKey)); const [exitNode] = await db.select().from(exitNodes).where(eq(exitNodes.publicKey, publicKey));
if (!exitNode) { if (!exitNode) {
return next(createHttpError(HttpCode.NOT_FOUND, "Exit node not found")); return next(createHttpError(HttpCode.NOT_FOUND, "Exit node not found"));
} }
@@ -63,7 +63,7 @@ export async function getAllRelays(
} }
// Initialize mappings object for multi-peer support // Initialize mappings object for multi-peer support
let mappings: { [key: string]: ProxyMapping } = {}; const mappings: { [key: string]: ProxyMapping } = {};
// Process each site // Process each site
for (const site of sitesRes) { for (const site of sitesRes) {

View File

@@ -112,7 +112,7 @@ export async function getConfig(
) )
); );
let peers = await Promise.all( const peers = await Promise.all(
sitesRes.map(async (site) => { sitesRes.map(async (site) => {
if (site.type === "wireguard") { if (site.type === "wireguard") {
return { return {

View File

@@ -68,7 +68,7 @@ export async function createOidcIdp(
); );
} }
let { const {
clientId, clientId,
clientSecret, clientSecret,
authUrl, authUrl,

View File

@@ -85,7 +85,7 @@ export async function updateOidcIdp(
} }
const { idpId } = parsedParams.data; const { idpId } = parsedParams.data;
let { const {
clientId, clientId,
clientSecret, clientSecret,
authUrl, authUrl,

View File

@@ -238,7 +238,7 @@ export async function validateOidcCallback(
const defaultRoleMapping = existingIdp.idp.defaultRoleMapping; const defaultRoleMapping = existingIdp.idp.defaultRoleMapping;
const defaultOrgMapping = existingIdp.idp.defaultOrgMapping; const defaultOrgMapping = existingIdp.idp.defaultOrgMapping;
let userOrgInfo: { orgId: string; roleId: number }[] = []; const userOrgInfo: { orgId: string; roleId: number }[] = [];
for (const org of allOrgs) { for (const org of allOrgs) {
const [idpOrgRes] = await db const [idpOrgRes] = await db
.select() .select()
@@ -314,7 +314,7 @@ export async function validateOidcCallback(
let existingUserId = existingUser?.userId; let existingUserId = existingUser?.userId;
let orgUserCounts: { orgId: string; userCount: number }[] = []; const orgUserCounts: { orgId: string; userCount: number }[] = [];
// sync the user with the orgs and roles // sync the user with the orgs and roles
await db.transaction(async (trx) => { await db.transaction(async (trx) => {

View File

@@ -55,7 +55,7 @@ export const handleNewtPingRequestMessage: MessageHandler = async (context) => {
); );
if (currentConnections.count >= maxConnections) { if (currentConnections.count >= maxConnections) {
return null return null;
} }
weight = weight =

View File

@@ -37,7 +37,7 @@ export const startOfflineChecker = (): void => {
}, OFFLINE_CHECK_INTERVAL); }, OFFLINE_CHECK_INTERVAL);
logger.info("Started offline checker interval"); logger.info("Started offline checker interval");
} };
/** /**
* Stops the background interval that checks for offline clients * Stops the background interval that checks for offline clients
@@ -48,7 +48,7 @@ export const stopOfflineChecker = (): void => {
offlineCheckerInterval = null; offlineCheckerInterval = null;
logger.info("Stopped offline checker interval"); logger.info("Stopped offline checker interval");
} }
} };
/** /**
* Handles ping messages from clients and responds with pong * Handles ping messages from clients and responds with pong

View File

@@ -102,7 +102,7 @@ export const handleOlmRegisterMessage: MessageHandler = async (context) => {
.where(eq(clientSites.clientId, client.clientId)); .where(eq(clientSites.clientId, client.clientId));
// Prepare an array to store site configurations // Prepare an array to store site configurations
let siteConfigurations = []; const siteConfigurations = [];
logger.debug(`Found ${sitesData.length} sites for client ${client.clientId}`); logger.debug(`Found ${sitesData.length} sites for client ${client.clientId}`);
if (sitesData.length === 0) { if (sitesData.length === 0) {

View File

@@ -35,7 +35,7 @@ const listResourceRulesSchema = z.object({
}); });
function queryResourceRules(resourceId: number) { function queryResourceRules(resourceId: number) {
let baseQuery = db const baseQuery = db
.select({ .select({
ruleId: resourceRules.ruleId, ruleId: resourceRules.ruleId,
resourceId: resourceRules.resourceId, resourceId: resourceRules.resourceId,
@@ -117,7 +117,7 @@ export async function listResourceRules(
const baseQuery = queryResourceRules(resourceId); const baseQuery = queryResourceRules(resourceId);
let countQuery = db const countQuery = db
.select({ count: sql<number>`cast(count(*) as integer)` }) .select({ count: sql<number>`cast(count(*) as integer)` })
.from(resourceRules) .from(resourceRules)
.where(eq(resourceRules.resourceId, resourceId)); .where(eq(resourceRules.resourceId, resourceId));

View File

@@ -231,7 +231,7 @@ export async function listResources(
(resource) => resource.resourceId (resource) => resource.resourceId
); );
let countQuery: any = db const countQuery: any = db
.select({ count: count() }) .select({ count: count() })
.from(resources) .from(resources)
.where(inArray(resources.resourceId, accessibleResourceIds)); .where(inArray(resources.resourceId, accessibleResourceIds));

View File

@@ -100,7 +100,7 @@ export async function listRoles(
const { orgId } = parsedParams.data; const { orgId } = parsedParams.data;
let countQuery: any = db const countQuery: any = db
.select({ count: sql<number>`cast(count(*) as integer)` }) .select({ count: sql<number>`cast(count(*) as integer)` })
.from(roles) .from(roles)
.where(eq(roles.orgId, orgId)); .where(eq(roles.orgId, orgId));

View File

@@ -176,7 +176,7 @@ export async function listSites(
const accessibleSiteIds = accessibleSites.map((site) => site.siteId); const accessibleSiteIds = accessibleSites.map((site) => site.siteId);
const baseQuery = querySites(orgId, accessibleSiteIds); const baseQuery = querySites(orgId, accessibleSiteIds);
let countQuery = db const countQuery = db
.select({ count: count() }) .select({ count: count() })
.from(sites) .from(sites)
.where( .where(

View File

@@ -86,7 +86,7 @@ export async function pickSiteDefaults(
.where(eq(sites.exitNodeId, exitNode.exitNodeId)); .where(eq(sites.exitNodeId, exitNode.exitNodeId));
// TODO: we need to lock this subnet for some time so someone else does not take it // TODO: we need to lock this subnet for some time so someone else does not take it
let subnets = sitesQuery.map((site) => site.subnet).filter((subnet) => subnet !== null); const subnets = sitesQuery.map((site) => site.subnet).filter((subnet) => subnet !== null);
// exclude the exit node address by replacing after the / with a site block size // exclude the exit node address by replacing after the / with a site block size
subnets.push( subnets.push(
exitNode.address.replace( exitNode.address.replace(

View File

@@ -2,7 +2,7 @@ import { db } from "@server/db";
import { resources, targets } from "@server/db"; import { resources, targets } from "@server/db";
import { eq } from "drizzle-orm"; import { eq } from "drizzle-orm";
let currentBannedPorts: number[] = []; const currentBannedPorts: number[] = [];
export async function pickPort(siteId: number): Promise<{ export async function pickPort(siteId: number): Promise<{
internalPort: number; internalPort: number;
@@ -15,8 +15,8 @@ export async function pickPort(siteId: number): Promise<{
// TODO: is this all inefficient? // TODO: is this all inefficient?
// Fetch targets for all resources of this site // Fetch targets for all resources of this site
let targetIps: string[] = []; const targetIps: string[] = [];
let targetInternalPorts: number[] = []; const targetInternalPorts: number[] = [];
await Promise.all( await Promise.all(
resourcesRes.map(async (resource) => { resourcesRes.map(async (resource) => {
const targetsRes = await db const targetsRes = await db

View File

@@ -35,7 +35,7 @@ const listTargetsSchema = z.object({
}); });
function queryTargets(resourceId: number) { function queryTargets(resourceId: number) {
let baseQuery = db const baseQuery = db
.select({ .select({
targetId: targets.targetId, targetId: targets.targetId,
ip: targets.ip, ip: targets.ip,
@@ -99,7 +99,7 @@ export async function listTargets(
const baseQuery = queryTargets(resourceId); const baseQuery = queryTargets(resourceId);
let countQuery = db const countQuery = db
.select({ count: sql<number>`cast(count(*) as integer)` }) .select({ count: sql<number>`cast(count(*) as integer)` })
.from(targets) .from(targets)
.where(eq(targets.resourceId, resourceId)); .where(eq(targets.resourceId, resourceId));

View File

@@ -62,7 +62,7 @@ const wss: WebSocketServer = new WebSocketServer({ noServer: true });
const NODE_ID = uuidv4(); const NODE_ID = uuidv4();
// Client tracking map (local to this node) // Client tracking map (local to this node)
let connectedClients: Map<string, AuthenticatedWebSocket[]> = new Map(); const connectedClients: Map<string, AuthenticatedWebSocket[]> = new Map();
// Helper to get map key // Helper to get map key
const getClientMapKey = (clientId: string) => clientId; const getClientMapKey = (clientId: string) => clientId;

View File

@@ -36,8 +36,8 @@ export default async function migration() {
} }
// Read and parse the YAML file // Read and parse the YAML file
let rawConfig: any;
const fileContents = fs.readFileSync(filePath, "utf8"); const fileContents = fs.readFileSync(filePath, "utf8");
let rawConfig: any;
rawConfig = yaml.load(fileContents); rawConfig = yaml.load(fileContents);
if (rawConfig.server?.trust_proxy) { if (rawConfig.server?.trust_proxy) {

View File

@@ -23,8 +23,8 @@ export default async function migration() {
} }
// Read and parse the YAML file // Read and parse the YAML file
let rawConfig: any;
const fileContents = fs.readFileSync(filePath, "utf8"); const fileContents = fs.readFileSync(filePath, "utf8");
let rawConfig: any;
rawConfig = yaml.load(fileContents); rawConfig = yaml.load(fileContents);
delete rawConfig.server.secure_cookies; delete rawConfig.server.secure_cookies;

View File

@@ -25,8 +25,8 @@ export default async function migration() {
} }
// Read and parse the YAML file // Read and parse the YAML file
let rawConfig: any;
const fileContents = fs.readFileSync(filePath, "utf8"); const fileContents = fs.readFileSync(filePath, "utf8");
let rawConfig: any;
rawConfig = yaml.load(fileContents); rawConfig = yaml.load(fileContents);
if (!rawConfig.flags) { if (!rawConfig.flags) {

View File

@@ -30,8 +30,8 @@ export default async function migration() {
} }
// Read and parse the YAML file // Read and parse the YAML file
let rawConfig: any;
const fileContents = fs.readFileSync(filePath, "utf8"); const fileContents = fs.readFileSync(filePath, "utf8");
let rawConfig: any;
rawConfig = yaml.load(fileContents); rawConfig = yaml.load(fileContents);
const baseDomain = rawConfig.app.base_domain; const baseDomain = rawConfig.app.base_domain;

View File

@@ -22,8 +22,8 @@ export default async function migration() {
} }
// Read and parse the YAML file // Read and parse the YAML file
let rawConfig: any;
const fileContents = fs.readFileSync(filePath, "utf8"); const fileContents = fs.readFileSync(filePath, "utf8");
let rawConfig: any;
rawConfig = yaml.load(fileContents); rawConfig = yaml.load(fileContents);
// Validate the structure // Validate the structure

View File

@@ -22,8 +22,8 @@ export default async function migration() {
} }
// Read and parse the YAML file // Read and parse the YAML file
let rawConfig: any;
const fileContents = fs.readFileSync(filePath, "utf8"); const fileContents = fs.readFileSync(filePath, "utf8");
let rawConfig: any;
rawConfig = yaml.load(fileContents); rawConfig = yaml.load(fileContents);
// Validate the structure // Validate the structure

View File

@@ -25,8 +25,8 @@ export default async function migration() {
} }
// Read and parse the YAML file // Read and parse the YAML file
let rawConfig: any;
const fileContents = fs.readFileSync(filePath, "utf8"); const fileContents = fs.readFileSync(filePath, "utf8");
let rawConfig: any;
rawConfig = yaml.load(fileContents); rawConfig = yaml.load(fileContents);
// Validate the structure // Validate the structure

View File

@@ -23,8 +23,8 @@ export default async function migration() {
} }
// Read and parse the YAML file // Read and parse the YAML file
let rawConfig: any;
const fileContents = fs.readFileSync(filePath, "utf8"); const fileContents = fs.readFileSync(filePath, "utf8");
let rawConfig: any;
rawConfig = yaml.load(fileContents); rawConfig = yaml.load(fileContents);
// Validate the structure // Validate the structure

View File

@@ -58,8 +58,8 @@ export default async function migration() {
} }
// Read and parse the YAML file // Read and parse the YAML file
let rawConfig: any;
const fileContents = fs.readFileSync(filePath, "utf8"); const fileContents = fs.readFileSync(filePath, "utf8");
let rawConfig: any;
rawConfig = yaml.load(fileContents); rawConfig = yaml.load(fileContents);
rawConfig.server.resource_session_request_param = rawConfig.server.resource_session_request_param =
@@ -122,7 +122,7 @@ export default async function migration() {
const traefikFileContents = fs.readFileSync(traefikPath, "utf8"); const traefikFileContents = fs.readFileSync(traefikPath, "utf8");
const traefikConfig = yaml.load(traefikFileContents) as any; const traefikConfig = yaml.load(traefikFileContents) as any;
let parsedConfig: any = schema.safeParse(traefikConfig); const parsedConfig: any = schema.safeParse(traefikConfig);
if (parsedConfig.success) { if (parsedConfig.success) {
// Ensure websecure entrypoint exists // Ensure websecure entrypoint exists
@@ -179,7 +179,7 @@ export default async function migration() {
const traefikFileContents = fs.readFileSync(traefikPath, "utf8"); const traefikFileContents = fs.readFileSync(traefikPath, "utf8");
const traefikConfig = yaml.load(traefikFileContents) as any; const traefikConfig = yaml.load(traefikFileContents) as any;
let parsedConfig: any = schema.safeParse(traefikConfig); const parsedConfig: any = schema.safeParse(traefikConfig);
if (parsedConfig.success) { if (parsedConfig.success) {
// delete permanent from redirect-to-https middleware // delete permanent from redirect-to-https middleware

View File

@@ -43,8 +43,8 @@ export default async function migration() {
} }
// Read and parse the YAML file // Read and parse the YAML file
let rawConfig: any;
const fileContents = fs.readFileSync(filePath, "utf8"); const fileContents = fs.readFileSync(filePath, "utf8");
let rawConfig: any;
rawConfig = yaml.load(fileContents); rawConfig = yaml.load(fileContents);
if (!rawConfig.flags) { if (!rawConfig.flags) {

View File

@@ -177,7 +177,8 @@ export default async function migration() {
} }
const fileContents = fs.readFileSync(filePath, "utf8"); const fileContents = fs.readFileSync(filePath, "utf8");
let rawConfig: any = yaml.load(fileContents); let rawConfig: any;
rawConfig = yaml.load(fileContents);
if (!rawConfig.server.secret) { if (!rawConfig.server.secret) {
rawConfig.server.secret = generateIdFromEntropySize(32); rawConfig.server.secret = generateIdFromEntropySize(32);

View File

@@ -44,8 +44,8 @@ export default async function migration() {
} }
// Read and parse the YAML file // Read and parse the YAML file
let rawConfig: any;
const fileContents = fs.readFileSync(filePath, "utf8"); const fileContents = fs.readFileSync(filePath, "utf8");
let rawConfig: any;
rawConfig = yaml.load(fileContents); rawConfig = yaml.load(fileContents);
if (rawConfig.cors?.headers) { if (rawConfig.cors?.headers) {

View File

@@ -45,8 +45,8 @@ export default async function migration() {
} }
// Read and parse the YAML file // Read and parse the YAML file
let rawConfig: any;
const fileContents = fs.readFileSync(filePath, "utf8"); const fileContents = fs.readFileSync(filePath, "utf8");
let rawConfig: any;
rawConfig = yaml.load(fileContents); rawConfig = yaml.load(fileContents);
if (rawConfig.server?.trust_proxy) { if (rawConfig.server?.trust_proxy) {

View File

@@ -108,7 +108,7 @@ export default function Page() {
async function onSubmit(data: CreateFormValues) { async function onSubmit(data: CreateFormValues) {
setCreateLoading(true); setCreateLoading(true);
let payload: CreateOrgApiKeyBody = { const payload: CreateOrgApiKeyBody = {
name: data.name name: data.name
}; };

View File

@@ -290,7 +290,7 @@ export default function ClientsTable({ clients, orgId }: ClientTableProps) {
columns={columns} columns={columns}
data={rows} data={rows}
addClient={() => { addClient={() => {
router.push(`/${orgId}/settings/clients/create`) router.push(`/${orgId}/settings/clients/create`);
}} }}
/> />
</> </>

View File

@@ -280,7 +280,7 @@ export default function Page() {
return; return;
} }
let payload: CreateClientBody = { const payload: CreateClientBody = {
name: data.name, name: data.name,
type: data.method as "olm", type: data.method as "olm",
siteIds: data.siteIds.map((site) => parseInt(site.id)), siteIds: data.siteIds.map((site) => parseInt(site.id)),

View File

@@ -29,7 +29,7 @@ export default function ResourceInfoBox({}: ResourceInfoBoxType) {
const { isEnabled, isAvailable } = useDockerSocket(site!); const { isEnabled, isAvailable } = useDockerSocket(site!);
const t = useTranslations(); const t = useTranslations();
let fullUrl = `${resource.ssl ? "https" : "http"}://${resource.fullDomain}`; const fullUrl = `${resource.ssl ? "https" : "http"}://${resource.fullDomain}`;
return ( return (
<Alert> <Alert>

View File

@@ -327,7 +327,7 @@ export default function ReverseProxyTargets(props: {
setProxySettingsLoading(true); setProxySettingsLoading(true);
// Save targets // Save targets
for (let target of targets) { for (const target of targets) {
const data = { const data = {
ip: target.ip, ip: target.ip,
port: target.port, port: target.port,

View File

@@ -271,7 +271,7 @@ export default function ResourceRules(props: {
} }
// Save rules // Save rules
for (let rule of rules) { for (const rule of rules) {
const data = { const data = {
action: rule.action, action: rule.action,
match: rule.match, match: rule.match,
@@ -348,7 +348,7 @@ export default function ResourceRules(props: {
setRules([ setRules([
...rules.map((r) => { ...rules.map((r) => {
let res = { const res = {
...r, ...r,
new: false, new: false,
updated: false updated: false

View File

@@ -106,7 +106,7 @@ export default function Page() {
async function onSubmit(data: CreateFormValues) { async function onSubmit(data: CreateFormValues) {
setCreateLoading(true); setCreateLoading(true);
let payload: CreateOrgApiKeyBody = { const payload: CreateOrgApiKeyBody = {
name: data.name name: data.name
}; };

View File

@@ -34,7 +34,7 @@ export default async function RootLayout({
const env = pullEnv(); const env = pullEnv();
const locale = await getLocale(); const locale = await getLocale();
let supporterData = { const supporterData = {
visible: true visible: true
} as any; } as any;