homarr-labs / homarr

Found non-null assertions JS-0339
Anti-pattern
Major
38 occurrences in this check
116
117                  event.preventDefault();
118                  handleValueRemove(
119                    multiSelectValues[multiSelectValues.length - 1]!,120                  );
121                }}
122              />
 58  const values = multiSelectValues.map((item) => (
 59    <IntegrationPill
 60      key={item}
 61      option={data.find((i) => i.id === item)!} 62      onRemove={() => handleValueRemove(item)}
 63    />
 64  ));
Forbidden non-null assertion
 8
 9export const zodUnionFromArray = <T extends z.ZodTypeAny>(
10  array: CouldBeReadonlyArray<T>,
11) => z.union([array[0]!, array[1]!, ...array.slice(2)]);
Forbidden non-null assertion
 8
 9export const zodUnionFromArray = <T extends z.ZodTypeAny>(
10  array: CouldBeReadonlyArray<T>,
11) => z.union([array[0]!, array[1]!, ...array.slice(2)]);
Forbidden non-null assertion
 4
 5export const zodEnumFromArray = <T extends string>(
 6  array: CouldBeReadonlyArray<T>,
 7) => z.enum([array[0]!, ...array.slice(1)]); 8
 9export const zodUnionFromArray = <T extends z.ZodTypeAny>(
10  array: CouldBeReadonlyArray<T>,
Forbidden non-null assertion
 6export default {
 7  schema: "./schema",
 8  driver: "better-sqlite",
 9  dbCredentials: { url: process.env.DB_URL! },10  out: "./migrations",
11} satisfies Config;
Forbidden non-null assertion
 35    });
 36    expect(result.user).toBeDefined();
 37    expect(result.user!.id).toEqual(user.id);
 38    expect(result.user!.name).toEqual(user.name); 39  });
 40});
 41
Forbidden non-null assertion
 34      newSession: {},
 35    });
 36    expect(result.user).toBeDefined();
 37    expect(result.user!.id).toEqual(user.id); 38    expect(result.user!.name).toEqual(user.name);
 39  });
 40});
Forbidden non-null assertion
41
42    await adapter.createSession({
43      sessionToken,
44      userId: user.id!,45      expires: sessionExpiry,
46    });
47
248    expect(apiKey.updatedAt).toEqual(fakeNow);
249    expect(username.value).not.toEqual(usernameToInsert.value);
250    expect(password.value).toEqual(passwordToInsert.value);
251    expect(apiKey.value).not.toEqual(input.secrets[2]!.value);252  });
253
254  it("should throw an error if the integration does not exist", async () => {
228    expect(dbIntegration).toBeDefined();
229    expect(dbIntegration!.name).toBe(input.name);
230    expect(dbIntegration!.kind).toBe(input.kind);
231    expect(dbIntegration!.url).toBe(input.url);232
233    expect(dbSecrets.length).toBe(3);
234    const username = expectToBeDefined(
227
228    expect(dbIntegration).toBeDefined();
229    expect(dbIntegration!.name).toBe(input.name);
230    expect(dbIntegration!.kind).toBe(input.kind);231    expect(dbIntegration!.url).toBe(input.url);
232
233    expect(dbSecrets.length).toBe(3);
226    const dbSecrets = await db.query.integrationSecrets.findMany();
227
228    expect(dbIntegration).toBeDefined();
229    expect(dbIntegration!.name).toBe(input.name);230    expect(dbIntegration!.kind).toBe(input.kind);
231    expect(dbIntegration!.url).toBe(input.url);
232
164    expect(dbSecret).toBeDefined();
165    expect(dbSecret!.kind).toBe(input.secrets[0]!.kind);
166    expect(dbSecret!.value).toMatch(/^[a-f0-9]+.[a-f0-9]+$/);
167    expect(dbSecret!.updatedAt).toEqual(fakeNow);168  });
169});
170
163    expect(dbSecret!.integrationId).toBe(dbIntegration!.id);
164    expect(dbSecret).toBeDefined();
165    expect(dbSecret!.kind).toBe(input.secrets[0]!.kind);
166    expect(dbSecret!.value).toMatch(/^[a-f0-9]+.[a-f0-9]+$/);167    expect(dbSecret!.updatedAt).toEqual(fakeNow);
168  });
169});
162
163    expect(dbSecret!.integrationId).toBe(dbIntegration!.id);
164    expect(dbSecret).toBeDefined();
165    expect(dbSecret!.kind).toBe(input.secrets[0]!.kind);166    expect(dbSecret!.value).toMatch(/^[a-f0-9]+.[a-f0-9]+$/);
167    expect(dbSecret!.updatedAt).toEqual(fakeNow);
168  });
162
163    expect(dbSecret!.integrationId).toBe(dbIntegration!.id);
164    expect(dbSecret).toBeDefined();
165    expect(dbSecret!.kind).toBe(input.secrets[0]!.kind);166    expect(dbSecret!.value).toMatch(/^[a-f0-9]+.[a-f0-9]+$/);
167    expect(dbSecret!.updatedAt).toEqual(fakeNow);
168  });
160    expect(dbIntegration!.kind).toBe(input.kind);
161    expect(dbIntegration!.url).toBe(input.url);
162
163    expect(dbSecret!.integrationId).toBe(dbIntegration!.id);164    expect(dbSecret).toBeDefined();
165    expect(dbSecret!.kind).toBe(input.secrets[0]!.kind);
166    expect(dbSecret!.value).toMatch(/^[a-f0-9]+.[a-f0-9]+$/);
160    expect(dbIntegration!.kind).toBe(input.kind);
161    expect(dbIntegration!.url).toBe(input.url);
162
163    expect(dbSecret!.integrationId).toBe(dbIntegration!.id);164    expect(dbSecret).toBeDefined();
165    expect(dbSecret!.kind).toBe(input.secrets[0]!.kind);
166    expect(dbSecret!.value).toMatch(/^[a-f0-9]+.[a-f0-9]+$/);
158    expect(dbIntegration).toBeDefined();
159    expect(dbIntegration!.name).toBe(input.name);
160    expect(dbIntegration!.kind).toBe(input.kind);
161    expect(dbIntegration!.url).toBe(input.url);162
163    expect(dbSecret!.integrationId).toBe(dbIntegration!.id);
164    expect(dbSecret).toBeDefined();
157    const dbSecret = await db.query.integrationSecrets.findFirst();
158    expect(dbIntegration).toBeDefined();
159    expect(dbIntegration!.name).toBe(input.name);
160    expect(dbIntegration!.kind).toBe(input.kind);161    expect(dbIntegration!.url).toBe(input.url);
162
163    expect(dbSecret!.integrationId).toBe(dbIntegration!.id);
156    const dbIntegration = await db.query.integrations.findFirst();
157    const dbSecret = await db.query.integrationSecrets.findFirst();
158    expect(dbIntegration).toBeDefined();
159    expect(dbIntegration!.name).toBe(input.name);160    expect(dbIntegration!.kind).toBe(input.kind);
161    expect(dbIntegration!.url).toBe(input.url);
162
 38    const result = await caller.all();
 39    expect(result.length).toBe(2);
 40    expect(result[0]!.kind).toBe("plex");
 41    expect(result[1]!.kind).toBe("homeAssistant"); 42  });
 43});
 44
 37
 38    const result = await caller.all();
 39    expect(result.length).toBe(2);
 40    expect(result[0]!.kind).toBe("plex"); 41    expect(result[1]!.kind).toBe("homeAssistant");
 42  });
 43});
26
27  return (
28    <Avatar {...commonProps}>
29      {currentSession.user.name!.substring(0, 2).toUpperCase()}30    </Avatar>
31  );
32};