Skip to content

fix(lint): no-explicit-any in auth and removal of magiclink method#828

Merged
CodeWithCJ merged 3 commits intoCodeWithCJ:mainfrom
Sim-sat:no-explicit-any-auth
Mar 3, 2026
Merged

fix(lint): no-explicit-any in auth and removal of magiclink method#828
CodeWithCJ merged 3 commits intoCodeWithCJ:mainfrom
Sim-sat:no-explicit-any-auth

Conversation

@Sim-sat
Copy link
Contributor

@Sim-sat Sim-sat commented Mar 3, 2026

Description

Removes explicit anys from api/auth. While fixing the anys I realized that the verfiyMagicLink method is not used at all (and could never work since it uses a method that doesn't exist). I removed everything so nobody gets confused about the dead code. Since this is auth related please test it too just to be sure.

Related Issue

PR type [ ] Issue [x] New Feature [ ] Documentation
Linked Issue: #795

Checklist

Please check all that apply:

  • [MANDATORY for new feature] Alignment: I have raised a GitHub issue and it was reviewed/approved by maintainers
  • Tests: I have included automated tests for my changes.
  • [MANDATORY for UI changes] Screenshots: I have attached "Before" vs "After" screenshots below.
  • [MANDATORY for Frontend changes] Quality: I have run pnpm run validate (especially for Frontend).
  • Translations: I have only updated the English (en) translation file (if applicable).
  • Architecture: My code follows the existing architecture standards.
  • Database Security: I have updated rls_policies.sql for any new user-specific tables.
  • [MANDATORY - ALL] Integrity & License: I certify this is my own work, free of malicious code(phishing, malware, etc.) and I agree to the License terms.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on improving the type safety and code cleanliness within the authentication-related modules. It removes the usage of explicit any types, eliminates dead code, and refactors the API call parameter handling for better reliability. The changes enhance the overall maintainability and reduce potential errors in the authentication flow.

Highlights

  • Explicit any Removal: This PR eliminates the use of explicit any types in the api/auth.ts file, enhancing type safety and code maintainability.
  • Dead Code Removal: The verifyMagicLink method, which was found to be unused and non-functional, has been removed from api/auth.ts to prevent confusion.
  • Improved Type Definitions: Introduced new interfaces (AuthError, BetterAuthUser, BetterAuthResponse) to provide more specific type information for authentication-related data.
  • Refactored API Call Parameters: The apiCall function in api/api.ts was refactored to improve handling of URL parameters, ensuring correct string conversion and preventing null or undefined values.
Changelog
  • api/api.ts
    • Refactored apiCall to handle URL parameters correctly.
    • Improved type definitions for API call options.
  • api/auth.ts
    • Removed explicit any types.
    • Removed the unused verifyMagicLink method.
    • Added interfaces for better type definitions.
  • hooks/Auth/useAuth.ts
    • Removed the useVerifyMagicLinkMutation hook.
  • pages/Auth/Auth.tsx
    • Removed the useVerifyMagicLinkMutation hook import and usage.
Activity
  • The PR addresses issue Eslint errors in Frontend #795.
  • Automated tests are included for the changes.
  • Frontend code has been validated using pnpm run validate.
  • Code follows existing architecture standards.
  • The author certifies the code is their own work and free of malicious code.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@Sim-sat Sim-sat force-pushed the no-explicit-any-auth branch from 4fcf690 to c8165e6 Compare March 3, 2026 06:40
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request focuses on improving the authentication logic by removing explicit any types and eliminating unused code. The verifyMagicLink method and related code have been removed, and explicit type casting has been implemented to enhance type safety. The changes also include modifications to the apiCall function to handle URL parameters more effectively. The removal of no-explicit-any eslint disables and the dead code improves code quality and maintainability.

I am having trouble creating individual review comments. Click here to see my feedback.

SparkyFitnessFrontend/src/api/Auth/auth.ts (56-59)

high

high: Instead of casting the Error object, consider creating a custom error class that extends Error and includes the code property. This would provide better type safety and avoid the need for casting.

class UserExistsError extends Error implements AuthError {
  code: string;
  constructor(message: string, code: string) {
    super(message);
    this.code = code;
    this.name = 'UserExistsError'; // Optional: Set a custom error name
  }
}

if (error.status === 409) {
  throw new UserExistsError('User with this email already exists.', '23505');
}

SparkyFitnessFrontend/src/api/Auth/auth.ts (69-71)

medium

medium: Consider adding a check to ensure authData is not null before accessing its properties to avoid potential null reference errors.

userId: authData?.user?.id ?? '', // Provide a default value if authData or user is null
role: authData?.user?.role || 'user',
fullName: authData?.user?.name || '',

SparkyFitnessFrontend/src/api/api.ts (27-29)

medium

medium: The condition value !== undefined && value !== null can be simplified to value != null.

if (value != null) {
  searchParams.append(key, String(value));
}
if (value != null) {
  searchParams.append(key, String(value));
}

SparkyFitnessFrontend/src/api/api.ts (81-85)

medium

medium: It seems like the condition typeof rawBody === 'object' is redundant since the !options.isFormData condition already checks if the body is an object. Consider removing this condition to simplify the logic.

if (!options.isFormData && typeof options.body === 'object') {
  config.body = JSON.stringify(options.body);
} else {
  config.body = String(rawBody); // Sicherstellen, dass es ein BodyInit kompatibler Typ ist
}
if (!options.isFormData && typeof options.body === 'object') {
  config.body = JSON.stringify(options.body);
} else {
  config.body = String(rawBody); // Sicherstellen, dass es ein BodyInit kompatibler Typ ist
}

@Sim-sat Sim-sat force-pushed the no-explicit-any-auth branch from c8165e6 to 40e06fa Compare March 3, 2026 06:42
@Sim-sat
Copy link
Contributor Author

Sim-sat commented Mar 3, 2026

Regarding the Gemini comments: I accidently commited the api/api.ts file. Already removed it. The first one does not make sense if we only have this error at one place

@Sim-sat
Copy link
Contributor Author

Sim-sat commented Mar 3, 2026

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request does a great job of improving type safety by removing explicit any types in api/auth.ts and introducing well-defined interfaces. The removal of the unused verifyMagicLink function and its associated code is a solid cleanup of dead code, enhancing maintainability. I've found one minor issue with a copied error message that should be corrected.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@CodeWithCJ CodeWithCJ merged commit ee79dcb into CodeWithCJ:main Mar 3, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants