Skip to content
Discussion options

You must be logged in to vote

Putting a return in front of redirect works, but feels like a hacky workaround. You might argue it makes code more readable though, clearly showing that redirect exits the function:

export const actions = {
  deleteAccount: async ({ locals }) => {
    const user = await authenticate(locals);
    if (user) {
      await prisma.user.delete({
        where: { email: user.email },
      });
      return {};
    }
    return redirect(303, '/');
  },
} satisfies Actions;

The only other option would be to disable the rule for that function:

// eslint-disable-next-line consistent-return

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@teemingc
Comment options

teemingc Jan 3, 2025
Collaborator

Answer selected by teemingc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants