mirror of
https://github.com/gethomepage/homepage.git
synced 2026-09-28 15:01:17 -07:00
Fix: re-enable global lint, fix un-caught warnings / errors (#6990)
This commit is contained in:
@@ -16,14 +16,16 @@ export default function Component({ service }) {
|
||||
widget.fields = widget.fields.slice(0, MAX_FIELDS);
|
||||
}
|
||||
|
||||
if (widget?.env == null || widget.env === "") {
|
||||
const envNotSet = widget.env == null || widget.env === "";
|
||||
|
||||
const { data: containers, error: containersError } = useWidgetAPI(widget, envNotSet ? "" : "containers");
|
||||
const { data: images, error: imagesError } = useWidgetAPI(widget, envNotSet ? "" : "images");
|
||||
const { data: updates, error: updatesError } = useWidgetAPI(widget, envNotSet ? "" : "updates");
|
||||
|
||||
if (envNotSet) {
|
||||
return <Container service={service} error={t("arcane.environment_required")} />;
|
||||
}
|
||||
|
||||
const { data: containers, error: containersError } = useWidgetAPI(widget, "containers");
|
||||
const { data: images, error: imagesError } = useWidgetAPI(widget, "images");
|
||||
const { data: updates, error: updatesError } = useWidgetAPI(widget, "updates");
|
||||
|
||||
const error =
|
||||
containersError ?? imagesError ?? updatesError ?? containers?.detail ?? images?.detail ?? updates?.detail;
|
||||
if (error) {
|
||||
|
||||
@@ -20,11 +20,15 @@ describe("widgets/arcane/component", () => {
|
||||
});
|
||||
|
||||
it("shows an environment required error when env is missing", () => {
|
||||
useWidgetAPI.mockImplementation(() => ({ data: undefined, error: undefined }));
|
||||
|
||||
renderWithProviders(<Component service={{ widget: { type: "arcane" } }} />, {
|
||||
settings: { hideErrors: false },
|
||||
});
|
||||
|
||||
expect(useWidgetAPI).not.toHaveBeenCalled();
|
||||
// hooks always run; the empty endpoint is what skips the request
|
||||
expect(useWidgetAPI).toHaveBeenCalledTimes(3);
|
||||
useWidgetAPI.mock.calls.forEach((call) => expect(call[1]).toBe(""));
|
||||
expect(screen.getByText("arcane.environment_required")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ export default function Component({ service }) {
|
||||
}
|
||||
|
||||
// uptime info
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const [hour, minutes, seconds] = infoData.data.up_time.split(":");
|
||||
const days = Math.floor(hour / 24);
|
||||
const uptime = `${t("common.number", { value: days })} ${t("diskstation.days")}`;
|
||||
|
||||
@@ -28,7 +28,6 @@ export default function Component({ service }) {
|
||||
|
||||
useEffect(() => {
|
||||
if (data && !data.error) {
|
||||
// eslint-disable-next-line eqeqeq
|
||||
const gpuData = data.find((item) => item[item.key] == gpuName);
|
||||
|
||||
if (gpuData) {
|
||||
@@ -56,7 +55,6 @@ export default function Component({ service }) {
|
||||
);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line eqeqeq
|
||||
const gpuData = data.find((item) => item[item.key] == gpuName);
|
||||
|
||||
if (!gpuData) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import Block from "components/services/widget/block";
|
||||
import Container from "components/services/widget/container";
|
||||
import { useTranslation } from "next-i18next/pages";
|
||||
|
||||
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||
|
||||
export default function Component({ service }) {
|
||||
|
||||
@@ -8,7 +8,6 @@ export default function Component({ service }) {
|
||||
const { t } = useTranslation();
|
||||
const { widget } = service;
|
||||
|
||||
// eslint-disable-next-line prefer-const
|
||||
let { data: spoolData, error: spoolError } = useWidgetAPI(widget, "spools");
|
||||
|
||||
if (spoolError) {
|
||||
@@ -20,7 +19,6 @@ export default function Component({ service }) {
|
||||
return (
|
||||
<Container service={service}>
|
||||
{[...Array(nBlocksGuess)].map((_, i) => (
|
||||
// eslint-disable-next-line react/no-array-index-key
|
||||
<Block key={i} label="spoolman.loading" />
|
||||
))}
|
||||
</Container>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* eslint-disable camelcase */
|
||||
import Container from "components/services/widget/container";
|
||||
import { useTranslation } from "next-i18next/pages";
|
||||
import { BsCpu, BsFillCpuFill, BsFillPlayFill, BsPauseFill } from "react-icons/bs";
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* eslint-disable camelcase */
|
||||
import Block from "components/services/widget/block";
|
||||
import Container from "components/services/widget/container";
|
||||
import { useTranslation } from "next-i18next/pages";
|
||||
|
||||
@@ -38,8 +38,8 @@ export default function Component({ service }) {
|
||||
const lan = defaultSite.health.find((h) => h.subsystem === "lan");
|
||||
const wlan = defaultSite.health.find((h) => h.subsystem === "wlan");
|
||||
[wan, lan, wlan].forEach((s) => {
|
||||
s.up = s.status === "ok"; // eslint-disable-line no-param-reassign
|
||||
s.show = s.status !== "unknown"; // eslint-disable-line no-param-reassign
|
||||
s.up = s.status === "ok";
|
||||
s.show = s.status !== "unknown";
|
||||
});
|
||||
|
||||
const uptime = wan["gw_system-stats"]
|
||||
|
||||
Reference in New Issue
Block a user