mirror of
https://github.com/gethomepage/homepage.git
synced 2026-02-07 16:30:52 +08:00
Chore: move to eslint (#6270)
This commit is contained in:
@@ -10,7 +10,6 @@ export function middleware(req) {
|
||||
allowedHosts = allowedHosts.concat(process.env.HOMEPAGE_ALLOWED_HOSTS.split(","));
|
||||
}
|
||||
if (!allowAll && (!host || !allowedHosts.includes(host))) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(
|
||||
`Host validation failed for: ${host}. Hint: Set the HOMEPAGE_ALLOWED_HOSTS environment variable to allow requests from this host / port.`,
|
||||
);
|
||||
|
||||
@@ -28,9 +28,7 @@ export default async function handler(req, res) {
|
||||
try {
|
||||
// maintain backwards compatibility with old ping where may be http://...
|
||||
hostname = new URL(pingHostOrURL).hostname;
|
||||
} catch (e) {
|
||||
// eslint-disable-line no-empty
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
try {
|
||||
const response = await ping.probe(hostname);
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* eslint-disable no-console */
|
||||
import { promises as fs } from "fs";
|
||||
import path from "path";
|
||||
|
||||
@@ -100,7 +99,6 @@ function convertLayoutGroupToGroup(name, layoutGroup) {
|
||||
function mergeSubgroups(configuredGroups, mergedGroup) {
|
||||
configuredGroups.forEach((group) => {
|
||||
if (group.name === mergedGroup.name) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
group.services = mergedGroup.services;
|
||||
} else if (group.groups) {
|
||||
mergeSubgroups(group.groups, mergedGroup);
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* eslint-disable no-console */
|
||||
import { copyFileSync, existsSync, mkdirSync, readFileSync } from "fs";
|
||||
import { join } from "path";
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
/* eslint-disable */
|
||||
|
||||
/*
|
||||
Code primarely based on shvl repository: https://github.com/robinvdvleuten/shvl
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
export const columnMap = [
|
||||
"grid-cols-1 md:grid-cols-1 lg:grid-cols-1",
|
||||
"grid-cols-1 md:grid-cols-1 lg:grid-cols-1",
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* eslint-disable no-console */
|
||||
import { format as utilFormat } from "node:util";
|
||||
|
||||
import winston from "winston";
|
||||
@@ -9,10 +8,9 @@ let winstonLogger;
|
||||
|
||||
function combineMessageAndSplat() {
|
||||
return {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
transform: (info, opts) => {
|
||||
// combine message and args if any
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
|
||||
info.message = utilFormat(info.message, ...(info[Symbol.for("splat")] || []));
|
||||
return info;
|
||||
},
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* eslint-disable no-param-reassign */
|
||||
import { Cookie, CookieJar } from "tough-cookie";
|
||||
|
||||
const cookieJar = new CookieJar();
|
||||
|
||||
@@ -30,7 +30,6 @@ export async function sendJsonRpcRequest(url, method, params, widget) {
|
||||
body,
|
||||
};
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const [status, contentType, data] = await httpProxy(url, httpRequestParams);
|
||||
if (status === 200) {
|
||||
const json = JSON.parse(data.toString());
|
||||
|
||||
@@ -48,7 +48,7 @@ async function getApiInfo(serviceWidget, apiName, serviceName) {
|
||||
}
|
||||
|
||||
const infoUrl = formatApiCall(INFO_ENDPOINT, serviceWidget);
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
|
||||
const [status, contentType, data] = await httpProxy(infoUrl);
|
||||
|
||||
if (status === 200) {
|
||||
@@ -74,7 +74,6 @@ async function getApiInfo(serviceWidget, apiName, serviceName) {
|
||||
async function handleUnsuccessfulResponse(serviceWidget, url, serviceName) {
|
||||
logger.debug(`Attempting login to ${serviceWidget.type}`);
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const [apiPath, maxVersion] = await getApiInfo(serviceWidget, AUTH_API_NAME, serviceName);
|
||||
|
||||
const authArgs = { path: apiPath ?? "entry.cgi", maxVersion: maxVersion ?? 7, ...serviceWidget };
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
/* eslint-disable prefer-promise-reject-errors */
|
||||
/* eslint-disable no-param-reassign */
|
||||
import { createUnzip, constants as zlibConstants } from "node:zlib";
|
||||
|
||||
import { http, https } from "follow-redirects";
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* eslint-disable no-console */
|
||||
import createLogger from "utils/logger";
|
||||
import widgets from "widgets/widgets";
|
||||
|
||||
|
||||
@@ -97,7 +97,6 @@ export default async function beszelProxyHandler(req, res) {
|
||||
return res.status(status).send(data);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
[status, , data] = await httpProxy(url, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
|
||||
@@ -65,7 +65,6 @@ export default async function delugeProxyHandler(req, res) {
|
||||
return res.status(status).end(data);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
[status, contentType, data] = await sendRpc(url, dataMethod, dataParams);
|
||||
}
|
||||
|
||||
|
||||
@@ -97,7 +97,6 @@ export default async function dispatcharrProxyHandler(req, res) {
|
||||
return res.status(status).send(data);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
[status, , data] = await httpProxy(url, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
|
||||
@@ -22,7 +22,6 @@ async function login(widget) {
|
||||
});
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const [status, contentType, data] = await httpProxy(loginUrl, loginParams);
|
||||
return [status, data];
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ async function login(widget, service) {
|
||||
const loginUrl = new URL(formatApiCall(api, { endpoint, ...widget }));
|
||||
const loginBody = { username: widget.username.toString(), password: widget.password.toString() };
|
||||
const headers = { "Content-Type": "application/json" };
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
|
||||
const [status, contentType, data, responseHeaders] = await httpProxy(loginUrl, {
|
||||
method: "POST",
|
||||
body: JSON.stringify(loginBody),
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* eslint-disable no-underscore-dangle */
|
||||
import crypto from "crypto";
|
||||
import querystring from "querystring";
|
||||
|
||||
|
||||
@@ -79,7 +79,6 @@ export default async function npmProxyHandler(req, res) {
|
||||
return res.status(status).send(data);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
[status, , data] = await httpProxy(url, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
|
||||
@@ -20,7 +20,6 @@ async function login(loginUrl, username, password, controllerVersionMajor) {
|
||||
};
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const [status, contentType, data] = await httpProxy(loginUrl, {
|
||||
method: "POST",
|
||||
body: JSON.stringify(params),
|
||||
@@ -234,7 +233,6 @@ export default async function omadaProxyHandler(req, res) {
|
||||
? `${url}/api/v2/sites/${siteName}/alerts/num?token=${token}¤tPage=1¤tPageSize=1000`
|
||||
: `${url}/${cId}/api/v2/sites/${siteName}/alerts/num?token=${token}¤tPage=1¤tPageSize=1000`;
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
[status, contentType, data] = await httpProxy(alertUrl, {
|
||||
headers: {
|
||||
"Csrf-Token": token,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* eslint-disable no-underscore-dangle */
|
||||
import cache from "memory-cache";
|
||||
import { xml2json } from "xml-js";
|
||||
|
||||
|
||||
@@ -40,7 +40,6 @@ async function fetchFromPyloadAPI(url, sessionId, params, service) {
|
||||
options.headers.Cookie = cache.get(`${sessionCacheKey}.${service}`);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const [status, contentType, data, responseHeaders] = await httpProxy(url, options);
|
||||
const returnData = parsePyloadResponse(url, data);
|
||||
return [status, returnData, responseHeaders];
|
||||
@@ -66,7 +65,6 @@ async function fetchFromPyloadAPIBasic(url, params, username, password) {
|
||||
options.body = JSON.stringify(params);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const [status, contentType, data, responseHeaders] = await httpProxy(parsedUrl, options);
|
||||
const returnData = parsePyloadResponse(parsedUrl, data);
|
||||
return [status, returnData, responseHeaders];
|
||||
|
||||
@@ -15,7 +15,6 @@ async function login(widget) {
|
||||
body: loginBody,
|
||||
};
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const [status, contentType, data] = await httpProxy(loginUrl, loginParams);
|
||||
return [status, data];
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ export default async function xteveProxyHandler(req, res) {
|
||||
const payload = { cmd: "status" };
|
||||
|
||||
if (widget.username && widget.password) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const [status, contentType, data] = await httpProxy(url, {
|
||||
method,
|
||||
body: JSON.stringify({
|
||||
|
||||
Reference in New Issue
Block a user