homarr-labs / homarr

Detected the use of variables before they are defined JS-0357
Anti-pattern
Major
35 occurrences in this check
'IntegrationPill' was used before it was defined
 56    onChange(multiSelectValues.filter((v) => v !== val));
 57
 58  const values = multiSelectValues.map((item) => (
 59    <IntegrationPill 60      key={item}
 61      option={data.find((i) => i.id === item)!}
 62      onRemove={() => handleValueRemove(item)}
'decryptSecret' was used before it was defined
192        }
193        const decryptedSecrets = integration.secrets.map((secret) => ({
194          ...secret,
195          value: decryptSecret(secret.value),196        }));
197
198        // Add secrets that are not defined in the input from the database
'encryptSecret' was used before it was defined
131          await ctx.db
132            .update(integrationSecrets)
133            .set({
134              value: encryptSecret(changedSecret.value),135              updatedAt: new Date(),
136            })
137            .where(
'decryptSecret' was used before it was defined
114
115      const decryptedSecrets = integration.secrets.map((secret) => ({
116        ...secret,
117        value: decryptSecret(secret.value),118      }));
119
120      const changedSecrets = input.secrets.filter(
'encryptSecret' was used before it was defined
 81      for (const secret of input.secrets) {
 82        await ctx.db.insert(integrationSecrets).values({
 83          kind: secret.kind,
 84          value: encryptSecret(secret.value), 85          updatedAt: new Date(),
 86          integrationId,
 87        });
'decryptSecret' was used before it was defined
 61          kind: secret.kind,
 62          // Only return the value if the secret is public, so for example the username
 63          value: integrationSecretKindObject[secret.kind].isPublic
 64            ? decryptSecret(secret.value) 65            : null,
 66          updatedAt: secret.updatedAt,
 67        })),
'parseSection' was used before it was defined
244  return {
245    ...otherBoardProperties,
246    sections: sections.map((section) =>
247      parseSection({248        ...section,
249        items: section.items.map((item) => ({
250          ...item,
'getFullBoardByName' was used before it was defined
 64    .input(validation.board.save)
 65    .mutation(async ({ input, ctx }) => {
 66      await ctx.db.transaction(async (tx) => {
 67        const dbBoard = await getFullBoardByName(tx, input.name); 68
 69        const addedSections = filterAddedItems(
 70          input.sections,
'getFullBoardByName' was used before it was defined
 53  byName: publicProcedure
 54    .input(validation.board.byName)
 55    .query(async ({ input, ctx }) => {
 56      return await getFullBoardByName(ctx.db, input.name); 57    }),
 58  saveGeneralSettings: publicProcedure
 59    .input(validation.board.saveGeneralSettings)
'getFullBoardByName' was used before it was defined
 48
 49export const boardRouter = createTRPCRouter({
 50  default: publicProcedure.query(async ({ ctx }) => {
 51    return await getFullBoardByName(ctx.db, "default"); 52  }),
 53  byName: publicProcedure
 54    .input(validation.board.byName)
'NavLinkWithItems' was used before it was defined
41  "href" in props ? (
42    <NavLinkHref {...props} />
43  ) : (
44    <NavLinkWithItems {...props} />45  );
46
47const NavLinkHref = (props: NavigationLinkHref) =>
'NavLinkHref' was used before it was defined
39
40const CommonNavLink = (props: NavigationLink) =>
41  "href" in props ? (
42    <NavLinkHref {...props} />43  ) : (
44    <NavLinkWithItems {...props} />
45  );
'CommonNavLink' was used before it was defined
29        component={ScrollArea}
30      >
31        {links.map((link) => (
32          <CommonNavLink key={link.label} {...link} />33        ))}
34      </AppShellSection>
35      {footerSection && <AppShellSection>{footerSection}</AppShellSection>}
'useSectionColumnCount' was used before it was defined
 48
 49  useCssVariableConfiguration({ section, mainRef, gridRef });
 50
 51  const sectionColumnCount = useSectionColumnCount(section.kind); 52
 53  const items = useMemo(() => section.items, [section.items]);
 54
'useCssVariableConfiguration' was used before it was defined
 46  // reference of the gridstack object for modifications after initialization
 47  const gridRef = useRef<GridStack>();
 48
 49  useCssVariableConfiguration({ section, mainRef, gridRef }); 50
 51  const sectionColumnCount = useSectionColumnCount(section.kind);
 52
'ItemMenu' was used before it was defined
 67  const newItem = { ...item, options };
 68  return (
 69    <>
 70      <ItemMenu offset={8} item={newItem} /> 71      <Comp options={options as never} integrations={item.integrations} />
 72    </>
 73  );
'BoardItem' was used before it was defined
 49          ref={refs.items.current[item.id] as RefObject<HTMLDivElement>}
 50        >
 51          <Card className="grid-stack-item-content" withBorder>
 52            <BoardItem item={item} /> 53          </Card>
 54        </div>
 55      ))}
'useNonEditModeActions' was used before it was defined
 59const useActions = (category: CategorySection) => {
 60  const isEditMode = useAtomValue(editModeAtom);
 61  const editModeActions = useEditModeActions(category);
 62  const nonEditModeActions = useNonEditModeActions(category); 63
 64  return useMemo(
 65    () => (isEditMode ? editModeActions : nonEditModeActions),
'useEditModeActions' was used before it was defined
 58
 59const useActions = (category: CategorySection) => {
 60  const isEditMode = useAtomValue(editModeAtom);
 61  const editModeActions = useEditModeActions(category); 62  const nonEditModeActions = useNonEditModeActions(category);
 63
 64  return useMemo(
 26}
 27
 28export const CategoryMenu = ({ category }: Props) => {
 29  const actions = useActions(category); 30  const t = useScopedI18n("section.category");
 31
 32  if (actions.length === 0) return null;
'calculateYHeightWithOffset' was used before it was defined
220
221        // Calculate the yOffset for the items in the currentCategory and removedWrapper to add them with the same offset to the aboveWrapper
222        const aboveYOffset = calculateYHeightWithOffset(aboveWrapper);
223        const categoryYOffset = calculateYHeightWithOffset(currentCategory);224
225        const previousCategoryItems = currentCategory.items.map((item) => ({
226          ...item,
'calculateYHeightWithOffset' was used before it was defined
219        if (!aboveWrapper || !removedWrapper) return previous;
220
221        // Calculate the yOffset for the items in the currentCategory and removedWrapper to add them with the same offset to the aboveWrapper
222        const aboveYOffset = calculateYHeightWithOffset(aboveWrapper);223        const categoryYOffset = calculateYHeightWithOffset(currentCategory);
224
225        const previousCategoryItems = currentCategory.items.map((item) => ({
'WidgetItem' was used before it was defined
16    <Grid>
17      {objectEntries(widgetImports).map(([key, value]) => {
18        return (
19          <WidgetItem20            key={key}
21            kind={key}
22            definition={value.definition}
'isCredentialsRequest' was used before it was defined
 6  return await createHandlers(isCredentialsRequest(req)).handlers.GET(req);
 7};
 8export const POST = async (req: NextRequest) => {
 9  return await createHandlers(isCredentialsRequest(req)).handlers.POST(req);10};
11
12const isCredentialsRequest = (req: NextRequest) => {
'isCredentialsRequest' was used before it was defined
 3import { createHandlers } from "@homarr/auth";
 4
 5export const GET = async (req: NextRequest) => {
 6  return await createHandlers(isCredentialsRequest(req)).handlers.GET(req); 7};
 8export const POST = async (req: NextRequest) => {
 9  return await createHandlers(isCredentialsRequest(req)).handlers.POST(req);