Skip to content

Commit 071dafb

Browse files
committed
Allow any in test files
vitest-dev/vitest#4543 (comment)
1 parent 522bba0 commit 071dafb

7 files changed

Lines changed: 28 additions & 26 deletions

File tree

apps/web/src/components/Code.tsx

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -155,16 +155,19 @@ function CodePanel({
155155
const childrenArray = Children.toArray(children);
156156
const child = childrenArray.length === 1 ? childrenArray[0] : null;
157157

158-
if (isValidElement(child)) {
159-
// @ts-expect-error TODO: Fix this somehow
160-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
161-
tag = child.props.tag ?? tag;
162-
// @ts-expect-error TODO: Fix this somehow
163-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
164-
label = child.props.label ?? label;
165-
// @ts-expect-error TODO: Fix this somehow
166-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
167-
code = child.props.code ?? code;
158+
if (
159+
isValidElement(child) &&
160+
typeof child.props === "object" &&
161+
child.props !== null
162+
) {
163+
const props = child.props as {
164+
tag?: string;
165+
label?: string;
166+
code?: string;
167+
};
168+
tag = props.tag ?? tag;
169+
label = props.label ?? label;
170+
code = props.code ?? code;
168171
}
169172

170173
// If no code prop is provided, try to extract it from children

eslint.config.mjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,15 @@ export default defineConfig(
7777
"react-hooks/exhaustive-deps": "error",
7878
},
7979
},
80+
{
81+
// https://github.com/vitest-dev/vitest/issues/4543#issuecomment-1824881253
82+
files: ["**/*.test.ts", "**/*.test.tsx"],
83+
rules: {
84+
"@typescript-eslint/no-unsafe-assignment": "off",
85+
"@typescript-eslint/no-unsafe-member-access": "off",
86+
"@typescript-eslint/no-unsafe-argument": "off",
87+
"@typescript-eslint/no-unsafe-call": "off",
88+
"@typescript-eslint/no-unsafe-return": "off",
89+
},
90+
},
8091
);

packages/common/test/Console.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ const mockDate = vi.fn();
3131
vi.stubGlobal(
3232
"Date",
3333
vi.fn().mockImplementation(function (this: any) {
34-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
3534
return mockDate();
3635
}),
3736
);

packages/common/test/Error.test.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ describe("createTransferableError", () => {
99
expect(result.type).toBe("TransferableError");
1010
expect(result.error).toMatchObject({
1111
message: "Test error",
12-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
1312
stack: expect.any(String),
1413
});
1514
});
@@ -22,20 +21,19 @@ describe("createTransferableError", () => {
2221
expect(result.type).toBe("TransferableError");
2322
expect(result.error).toMatchObject({
2423
message: "Outer error",
25-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
2624
stack: expect.any(String),
2725
cause: {
2826
message: "Inner error",
29-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
3027
stack: expect.any(String),
3128
},
3229
});
3330
});
3431

3532
test("excludes non-transferable error properties", () => {
3633
const error = new Error("Test error");
37-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-empty-function
38-
(error as any).nonTransferable = () => {};
34+
(error as any).nonTransferable = () => {
35+
//
36+
};
3937
const result = createTransferableError(error);
4038

4139
expect(result.type).toBe("TransferableError");
@@ -79,7 +77,6 @@ describe("createTransferableError", () => {
7977

8078
test("handles circular references", () => {
8179
const error: any = {};
82-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
8380
error.self = error; // Create a circular reference
8481
const result = createTransferableError(error);
8582

packages/common/test/Result.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,13 @@ test("trySync", () => {
7373
ok: false,
7474
error: {
7575
type: "ParseError",
76-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
7776
message: expect.stringContaining("SyntaxError"),
7877
},
7978
});
8079
});
8180

8281
test("tryAsync", async () => {
83-
// eslint-disable-next-line @typescript-eslint/require-await
84-
const successfulPromise = async () => "success";
82+
const successfulPromise = () => Promise.resolve("success");
8583

8684
const successResult = await tryAsync(successfulPromise, (error) => ({
8785
type: "TestError",

packages/common/test/Type.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3073,9 +3073,7 @@ describe("Standard Schema V1", () => {
30733073
};
30743074

30753075
expect(user).toEqual({
3076-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
30773076
name: expect.schemaMatching(NonEmptyTrimmedString100),
3078-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
30793077
age: expect.schemaMatching(PositiveInt),
30803078
});
30813079
});

packages/web/test/SharedWebWorker.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-unsafe-call */
2-
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
3-
/* eslint-disable @typescript-eslint/no-unsafe-return */
4-
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
51
import { expect, test, vi, beforeEach, afterEach } from "vitest";
62
import { createSharedWebWorker } from "../src/SharedWebWorker.js";
73
import { SimpleName, wait } from "@evolu/common";

0 commit comments

Comments
 (0)