fix(lint): no-explicit-any in auth and removal of magiclink method#828
fix(lint): no-explicit-any in auth and removal of magiclink method#828CodeWithCJ merged 3 commits intoCodeWithCJ:mainfrom
Conversation
Summary of ChangesHello, 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 Highlights
Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
4fcf690 to
c8165e6
Compare
There was a problem hiding this comment.
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: 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: 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: 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: 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
}c8165e6 to
40e06fa
Compare
|
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 |
|
/gemini review |
There was a problem hiding this comment.
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>
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:
pnpm run validate(especially for Frontend).en) translation file (if applicable).rls_policies.sqlfor any new user-specific tables.