-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(lint): fix eslint issues in src/routes
#1347
Merged
Merged
+172
−95
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
req.file is of type "Express.Multer.File | undefined". Returning with an "uploaded: false" type object -> same handling as in image.ts
this is in preparation for updating the routes/handleException method, to get rid of "any" (and improve in general)
also gets rid of "any" type :-)
also gets rid of "any" type :-)
in this case using "{}" allows all primitive values, which seems to be what is required here. so let's disable the rule "@typescript-eslint/no-empty-object-type" for this line
cdf1ebc
to
91c37fa
Compare
…r pageUrl -> the value is already sanitized in line 112, there's no need to call htmlSanitizer a second time here
…ve code duplication
eliandoran
approved these changes
Mar 8, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix eslint issues reported for
src/routes
fixes all of the above errors, except for:
as I do not fully understand what form these any types can take
——
This PR also includes two changes which are not strictly linting related, but helped fix those errors.
I hope it's ok to just include them in this PR anyways.
They both have to do with the way we check for errors in the try/catch blocks.
Since in JS you can throw anything, we need to make sure that we are dealing with an actual Error instance, before we can use the message and stack properties.
a) I've added a
HttpError
class, which extends from theError
class, and made theValidationError
andNotFoundError
extend fromHttpError
class – this makes handling these errors a bit easier, as these errors are now instances ofError
.b) I've added an
safeExtractMessageAndStackFromError
to extract the message and stack properties from an "unknown" type error - it will check if the error is of instance Error, and return these. If it isn't it will use fallback strings. This get rid of code duplication in all of these error blocks.