chore: make lint pass for vitest tests

This commit is contained in:
shamoon
2026-02-03 14:47:47 -08:00
parent 641562ac85
commit 87deb24cd0
3 changed files with 12 additions and 6 deletions

View File

@@ -65,5 +65,14 @@ export default defineConfig([
],
},
},
// Vitest tests often intentionally place imports after `vi.mock(...)` to ensure
// modules under test see the mocked dependencies. `import/order` can't safely
// auto-fix those cases, so disable it for test files.
{
files: ["src/**/*.test.{js,jsx}", "src/**/*.spec.{js,jsx}"],
rules: {
"import/order": "off",
},
},
globalIgnores(["./config/", "./.venv/", "./.next/", "./site/"]),
]);

View File

@@ -53,12 +53,7 @@ describe("widgets/linkwarden/component", () => {
useWidgetAPI.mockImplementation((_widget, endpoint) => {
if (endpoint === "collections") {
return {
data: [
// eslint-disable-next-line no-underscore-dangle
{ _count: { links: 2 } },
// eslint-disable-next-line no-underscore-dangle
{ _count: { links: 3 } },
],
data: [{ _count: { links: 2 } }, { _count: { links: 3 } }],
error: undefined,
};
}

View File

@@ -7,6 +7,8 @@ import { describe, expect, it, vi } from "vitest";
vi.mock("next/image", () => ({
default: (props) => {
const { src, alt, objectFit, className, onError } = props;
// This is a unit-test stub for next/image; using <img> is intentional here.
// eslint-disable-next-line @next/next/no-img-element
return <img alt={alt} src={src} data-object-fit={objectFit} className={className} onError={onError} />;
},
}));