Skip to content

Commit fd7ee2c

Browse files
chore(lint): forbid declaring tests inside for loops (#14921)
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
1 parent a892771 commit fd7ee2c

86 files changed

Lines changed: 6133 additions & 6050 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/desktop/scripts/browser-secret-native.test.mjs‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,19 @@ describe.skipIf(hostPlatform !== "linux")("bundled libsecret helper", () => {
7878
expect(result.stderr.length).toBe(0);
7979
});
8080

81-
for (const [scenario, code] of [
81+
it.each([
8282
["missing", 2],
8383
["empty", 2],
8484
["locked", 3],
8585
["cancelled", 3],
8686
["denied", 3],
8787
["unavailable", 4],
8888
["unloaded", 4],
89-
]) {
90-
it(`reports ${scenario} without emitting a secret`, () => {
91-
const result = run([scenario]);
92-
expect(result.status).toBe(code);
93-
expect(result.stdout.length).toBe(0);
94-
});
95-
}
89+
])("reports %s without emitting a secret", (scenario, code) => {
90+
const result = run([scenario]);
91+
expect(result.status).toBe(code);
92+
expect(result.stdout.length).toBe(0);
93+
});
9694
it("rejects invalid arguments before accessing the keyring", () => {
9795
for (const args of [[], [""], ["chrome", "extra"]]) {
9896
const result = run(args);

‎apps/desktop/src/app/DesktopClerk.test.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,9 @@ it.effect(
303303
},
304304
);
305305

306-
for (const entry of ["startup", "open-url"] as const) {
307-
it.effect(`receives hosted web sign-in through the desktop ${entry} handler`, () =>
306+
it.effect.each(["startup", "open-url"] as const)(
307+
"receives hosted web sign-in through the desktop %s handler",
308+
(entry) =>
308309
Effect.gen(function* () {
309310
storageMock.mockReturnValue(storageAdapter);
310311
createClerkBridgeMock.mockReturnValue({ cleanup: vi.fn(), isPrimaryInstance: true });
@@ -382,5 +383,4 @@ for (const entry of ["startup", "open-url"] as const) {
382383
),
383384
);
384385
}).pipe(Effect.scoped),
385-
);
386-
}
386+
);

‎apps/desktop/src/app/DesktopLifecycle.test.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,9 @@ function makeDesktopWindowLayer(
101101
}
102102

103103
describe("DesktopLifecycle", () => {
104-
for (const platform of ["darwin", "win32", "linux"] satisfies ReadonlyArray<NodeJS.Platform>) {
105-
it.effect(`lets the updater's quit event proceed on ${platform}`, () => {
104+
it.effect.each(["darwin", "win32", "linux"] satisfies ReadonlyArray<NodeJS.Platform>)(
105+
"lets the updater's quit event proceed on %s",
106+
(platform) => {
106107
const appListeners = new Map<string, (...args: readonly unknown[]) => void>();
107108
let windowsDestroyed = false;
108109
const environmentLayer = Layer.succeed(DesktopEnvironment.DesktopEnvironment, {
@@ -152,8 +153,8 @@ describe("DesktopLifecycle", () => {
152153
assert.isTrue(yield* Ref.get(state.quitting));
153154
}),
154155
).pipe(Effect.provide(layer));
155-
});
156-
}
156+
},
157+
);
157158

158159
it.effect("destroys windows before waiting for backend shutdown", () =>
159160
Effect.gen(function* () {

‎apps/desktop/src/app/DesktopPreReadyPlatform.test.ts‎

Lines changed: 45 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -81,54 +81,52 @@ describe("DesktopPreReadyPlatform", () => {
8181
);
8282
});
8383

84-
for (const previousEntry of [undefined, 'Exec="/Applications/deleted-previous.AppImage" %U']) {
85-
it.effect(
86-
`prepares a ${previousEntry ? "stale" : "missing"} Linux desktop entry before startup yields`,
87-
() => {
88-
vi.stubEnv("VITE_DEV_SERVER_URL", "");
89-
vi.stubEnv("XDG_DATA_HOME", "/xdg");
90-
vi.stubEnv("APPIMAGE", "/Applications/current.AppImage");
91-
getSwitchValueMock.mockReturnValue("");
92-
let desktopName = "t3code.desktop";
93-
let desktopEntry = previousEntry;
94-
let iconInstalled = false;
95-
copyFileSyncMock.mockImplementation((_source: string, destination: string) => {
96-
iconInstalled = destination === "/xdg/icons/com.t3tools.T3Code.desktop.png";
97-
});
98-
setDesktopNameMock.mockImplementation((name: string) => {
99-
desktopName = name;
100-
});
101-
writeFileSyncMock.mockImplementation((path: string, contents: string) => {
102-
if (path === "/xdg/applications/com.t3tools.T3Code.desktop") desktopEntry = contents;
103-
});
84+
it.effect.each([
85+
{ previousEntry: undefined, label: "missing" },
86+
{ previousEntry: 'Exec="/Applications/deleted-previous.AppImage" %U', label: "stale" },
87+
])("prepares a $label Linux desktop entry before startup yields", ({ previousEntry }) => {
88+
vi.stubEnv("VITE_DEV_SERVER_URL", "");
89+
vi.stubEnv("XDG_DATA_HOME", "/xdg");
90+
vi.stubEnv("APPIMAGE", "/Applications/current.AppImage");
91+
getSwitchValueMock.mockReturnValue("");
92+
let desktopName = "t3code.desktop";
93+
let desktopEntry = previousEntry;
94+
let iconInstalled = false;
95+
copyFileSyncMock.mockImplementation((_source: string, destination: string) => {
96+
iconInstalled = destination === "/xdg/icons/com.t3tools.T3Code.desktop.png";
97+
});
98+
setDesktopNameMock.mockImplementation((name: string) => {
99+
desktopName = name;
100+
});
101+
writeFileSyncMock.mockImplementation((path: string, contents: string) => {
102+
if (path === "/xdg/applications/com.t3tools.T3Code.desktop") desktopEntry = contents;
103+
});
104104

105-
return Effect.scoped(
106-
Effect.gen(function* () {
107-
const portalIdentity = Promise.resolve().then(() => ({
108-
desktopName,
109-
desktopEntry,
110-
iconInstalled,
111-
}));
112-
yield* Layer.build(
113-
DesktopPreReadyPlatform.layer.pipe(
114-
Layer.provide(Layer.succeed(HostProcessPlatform, "linux")),
115-
),
116-
);
117-
const identity = yield* Effect.promise(() => portalIdentity);
118-
assert.equal(identity.desktopName, "com.t3tools.T3Code.desktop");
119-
assert.include(identity.desktopEntry ?? "", 'Exec="/Applications/current.AppImage" %U');
120-
assert.include(identity.desktopEntry ?? "", "Name=T3 Code (Alpha)");
121-
assert.include(identity.desktopEntry ?? "", "MimeType=x-scheme-handler/t3code;");
122-
assert.include(
123-
identity.desktopEntry ?? "",
124-
"Icon=/xdg/icons/com.t3tools.T3Code.desktop.png",
125-
);
126-
assert.isTrue(identity.iconInstalled);
127-
}),
128-
).pipe(Effect.ensuring(Effect.sync(() => vi.unstubAllEnvs())));
129-
},
130-
);
131-
}
105+
return Effect.scoped(
106+
Effect.gen(function* () {
107+
const portalIdentity = Promise.resolve().then(() => ({
108+
desktopName,
109+
desktopEntry,
110+
iconInstalled,
111+
}));
112+
yield* Layer.build(
113+
DesktopPreReadyPlatform.layer.pipe(
114+
Layer.provide(Layer.succeed(HostProcessPlatform, "linux")),
115+
),
116+
);
117+
const identity = yield* Effect.promise(() => portalIdentity);
118+
assert.equal(identity.desktopName, "com.t3tools.T3Code.desktop");
119+
assert.include(identity.desktopEntry ?? "", 'Exec="/Applications/current.AppImage" %U');
120+
assert.include(identity.desktopEntry ?? "", "Name=T3 Code (Alpha)");
121+
assert.include(identity.desktopEntry ?? "", "MimeType=x-scheme-handler/t3code;");
122+
assert.include(
123+
identity.desktopEntry ?? "",
124+
"Icon=/xdg/icons/com.t3tools.T3Code.desktop.png",
125+
);
126+
assert.isTrue(identity.iconInstalled);
127+
}),
128+
).pipe(Effect.ensuring(Effect.sync(() => vi.unstubAllEnvs())));
129+
});
132130

133131
it.effect("keeps startup available when the early desktop entry cannot be written", () => {
134132
getSwitchValueMock.mockReturnValue("");

‎apps/desktop/src/app/DesktopUserData.test.ts‎

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -37,39 +37,37 @@ it.effect("identifies a failed source read and preserves its cause", () => {
3737
);
3838
});
3939

40-
for (const sourceName of ["t3code", "T3 Code (Alpha)"]) {
41-
it.effect(
42-
`preserves Windows credential keys from ${sourceName} without copying browser databases`,
43-
() =>
44-
Effect.gen(function* () {
45-
const fs = yield* FileSystem.FileSystem;
46-
const path = yield* Path.Path;
47-
const directory = yield* fs.makeTempDirectoryScoped({ prefix: "t3-v2-profile-" });
48-
const source = path.join(directory, sourceName);
49-
const destination = path.join(directory, "t3code-v2");
50-
const state = '{"os_crypt":{"encrypted_key":"test-encrypted-key"}}';
51-
yield* fs.makeDirectory(path.join(directory, "T3 Code (Alpha)"), { recursive: true });
52-
yield* fs.makeDirectory(path.join(source, "IndexedDB"), { recursive: true });
53-
yield* fs.writeFileString(path.join(source, "Local State"), state);
54-
yield* fs.writeFileString(path.join(source, "IndexedDB", "LOCK"), "V1 owns this database");
55-
yield* resolveUserDataPath({
56-
appDataDirectory: directory,
57-
isDevelopment: false,
58-
platform: "win32",
59-
});
60-
assert.equal(yield* fs.readFileString(path.join(destination, "Local State")), state);
61-
assert.equal(yield* fs.readFileString(path.join(source, "Local State")), state);
62-
assert.isFalse(yield* fs.exists(path.join(destination, "IndexedDB")));
63-
yield* fs.writeFileString(path.join(destination, "Local State"), "existing V2 state");
64-
yield* resolveUserDataPath({
65-
appDataDirectory: directory,
66-
isDevelopment: false,
67-
platform: "win32",
68-
});
69-
assert.equal(
70-
yield* fs.readFileString(path.join(destination, "Local State")),
71-
"existing V2 state",
72-
);
73-
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
74-
);
75-
}
40+
it.effect.each(["t3code", "T3 Code (Alpha)"])(
41+
"preserves Windows credential keys from %s without copying browser databases",
42+
(sourceName) =>
43+
Effect.gen(function* () {
44+
const fs = yield* FileSystem.FileSystem;
45+
const path = yield* Path.Path;
46+
const directory = yield* fs.makeTempDirectoryScoped({ prefix: "t3-v2-profile-" });
47+
const source = path.join(directory, sourceName);
48+
const destination = path.join(directory, "t3code-v2");
49+
const state = '{"os_crypt":{"encrypted_key":"test-encrypted-key"}}';
50+
yield* fs.makeDirectory(path.join(directory, "T3 Code (Alpha)"), { recursive: true });
51+
yield* fs.makeDirectory(path.join(source, "IndexedDB"), { recursive: true });
52+
yield* fs.writeFileString(path.join(source, "Local State"), state);
53+
yield* fs.writeFileString(path.join(source, "IndexedDB", "LOCK"), "V1 owns this database");
54+
yield* resolveUserDataPath({
55+
appDataDirectory: directory,
56+
isDevelopment: false,
57+
platform: "win32",
58+
});
59+
assert.equal(yield* fs.readFileString(path.join(destination, "Local State")), state);
60+
assert.equal(yield* fs.readFileString(path.join(source, "Local State")), state);
61+
assert.isFalse(yield* fs.exists(path.join(destination, "IndexedDB")));
62+
yield* fs.writeFileString(path.join(destination, "Local State"), "existing V2 state");
63+
yield* resolveUserDataPath({
64+
appDataDirectory: directory,
65+
isDevelopment: false,
66+
platform: "win32",
67+
});
68+
assert.equal(
69+
yield* fs.readFileString(path.join(destination, "Local State")),
70+
"existing V2 state",
71+
);
72+
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
73+
);

‎apps/desktop/src/preview/BrowserImport/FirefoxCookies.test.ts‎

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -386,45 +386,43 @@ describe("parseFirefoxProfiles", () => {
386386
}),
387387
);
388388

389-
for (const [platform, root] of [
390-
["Linux", "/home/user/.mozilla/firefox"],
391-
["macOS", "/Users/user/Library/Application Support/Firefox"],
392-
] as const) {
393-
it.effect(`validates relative and absolute ${platform} profile paths`, () =>
394-
Effect.gen(function* () {
395-
const parsed = yield* parsePosixFirefoxProfiles(
396-
[
397-
"[Profile0]",
398-
"Name=Relative",
399-
"IsRelative=1",
400-
"Path=Profiles/relative.default",
401-
"[Profile1]",
402-
"Name=Custom",
403-
"IsRelative=0",
404-
"Path=/mnt/custom/firefox-profile",
405-
"[Profile2]",
406-
"IsRelative=1",
407-
"Path=../../escape",
408-
"[Profile3]",
409-
"IsRelative=1",
410-
"Path=/absolute-marked-relative",
411-
"[Profile4]",
412-
"IsRelative=0",
413-
"Path=relative-marked-absolute",
414-
"[Profile5]",
415-
"IsRelative=1",
416-
"Path=Profiles/nul\u0000escape",
417-
].join("\n"),
418-
root,
419-
);
389+
it.effect.each([
390+
{ platform: "Linux", root: "/home/user/.mozilla/firefox" },
391+
{ platform: "macOS", root: "/Users/user/Library/Application Support/Firefox" },
392+
])("validates relative and absolute $platform profile paths", ({ root }) =>
393+
Effect.gen(function* () {
394+
const parsed = yield* parsePosixFirefoxProfiles(
395+
[
396+
"[Profile0]",
397+
"Name=Relative",
398+
"IsRelative=1",
399+
"Path=Profiles/relative.default",
400+
"[Profile1]",
401+
"Name=Custom",
402+
"IsRelative=0",
403+
"Path=/mnt/custom/firefox-profile",
404+
"[Profile2]",
405+
"IsRelative=1",
406+
"Path=../../escape",
407+
"[Profile3]",
408+
"IsRelative=1",
409+
"Path=/absolute-marked-relative",
410+
"[Profile4]",
411+
"IsRelative=0",
412+
"Path=relative-marked-absolute",
413+
"[Profile5]",
414+
"IsRelative=1",
415+
"Path=Profiles/nul\u0000escape",
416+
].join("\n"),
417+
root,
418+
);
420419

421-
expect(parsed).toEqual([
422-
{ directory: "Profiles/relative.default", name: "Relative" },
423-
{ directory: "/mnt/custom/firefox-profile", name: "Custom" },
424-
]);
425-
}),
426-
);
427-
}
420+
expect(parsed).toEqual([
421+
{ directory: "Profiles/relative.default", name: "Relative" },
422+
{ directory: "/mnt/custom/firefox-profile", name: "Custom" },
423+
]);
424+
}),
425+
);
428426

429427
it.effect("uses Windows path rules for relative and absolute profiles", () =>
430428
Effect.gen(function* () {

‎apps/desktop/src/preview/BrowserImport/Sources.test.ts‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -763,8 +763,9 @@ describe("listSourceProfiles Firefox fallback", () => {
763763
{ platform: "win32" as const, profileDirectory: NodePath.join("Profiles", "windows.default") },
764764
];
765765

766-
for (const { platform, profileDirectory } of cases) {
767-
it.effect(`scans the ${platform} profile location and excludes stale entries`, () =>
766+
it.effect.each(cases)(
767+
"scans the $platform profile location and excludes stale entries",
768+
({ platform, profileDirectory }) =>
768769
run(
769770
Effect.gen(function* () {
770771
const fileSystem = yield* FileSystem.FileSystem;
@@ -800,8 +801,7 @@ describe("listSourceProfiles Firefox fallback", () => {
800801
]);
801802
}),
802803
),
803-
);
804-
}
804+
);
805805

806806
it.effect("scans for profiles when profiles.ini declares only ones without cookies", () =>
807807
run(
@@ -1166,8 +1166,9 @@ describe("Safari profiles", () => {
11661166
),
11671167
);
11681168

1169-
for (const metadataState of ["missing", "corrupt"] as const) {
1170-
it.effect(`recovers separate cookie stores when metadata is ${metadataState}`, () =>
1169+
it.effect.each(["missing", "corrupt"] as const)(
1170+
"recovers separate cookie stores when metadata is %s",
1171+
(metadataState) =>
11711172
run(
11721173
Effect.gen(function* () {
11731174
const { context, store, metadata } = yield* fixture();
@@ -1181,8 +1182,7 @@ describe("Safari profiles", () => {
11811182
assert.isTrue(yield* isSourceInstalled(safari, context));
11821183
}),
11831184
),
1184-
);
1185-
}
1185+
);
11861186

11871187
it.effect("keeps Safari without profiles available", () =>
11881188
run(

0 commit comments

Comments
 (0)