chore: fix various eslint issues #1176

Merged
Sainan merged 1 commits from eslint-fix into main 2025-03-15 03:24:39 -07:00
Owner
No description provided.
Sainan added 1 commit 2025-03-14 05:22:45 -07:00
chore: fix various eslint issues
All checks were successful
Build / build (18) (pull_request) Successful in 43s
Build / build (22) (pull_request) Successful in 1m4s
Build / build (18) (push) Successful in 44s
Build / build (20) (push) Successful in 1m3s
Build / build (22) (push) Successful in 1m2s
Build / build (20) (pull_request) Successful in 40s
1c4d5c5543
OrdisPrime reviewed 2025-03-14 06:08:07 -07:00
@ -31,4 +30,2 @@
return ship;
};
export const getShipLean = async (shipOwnerId: string) => {
Owner

only because this function is currently not used, does not mean it has to be deleted.

only because this function is currently not used, does not mean it has to be deleted.
Author
Owner

I don't even understand the intended purpose of it. Under which circumstances would you ever want an unhydrated ship combined with the loadout presets?

I don't even understand the intended purpose of it. Under which circumstances would you ever want an unhydrated ship combined with the loadout presets?
Owner

hydration is ONLY needed when you want to use a mongoose document's functions.
So, all get requests should generally only use .lean() versions, so mongoose doesn't hydrate them (which takes lots of resources)

hydration is ONLY needed when you want to use a mongoose document's functions. So, all get requests should generally only use .lean() versions, so mongoose doesn't hydrate them (which takes lots of resources)
Owner

I left the function there as a reminder to do that

I left the function there as a reminder to do that
Author
Owner

lean also seems to skip casing and validation, potentially invalidating the types.

`lean` also seems to skip casing and validation, potentially invalidating the types.
Owner

I am not aware of that.
https://github.com/Automattic/mongoose/blob/master/docs/tutorials/lean.md
it describes getters as a good use case for using lean, which makes sense to me

I am not aware of that. https://github.com/Automattic/mongoose/blob/master/docs/tutorials/lean.md it describes getters as a good use case for using lean, which makes sense to me
Author
Owner

Literally search for "Casting and validation" on that page.

Literally search for "Casting and validation" on that page.
Author
Owner

The ship model also makes use of transformations, so we'd not get a correct client representation if we used lean.

The ship model also makes use of transformations, so we'd not get a correct client representation if we used `lean`.
Owner

Right, however I don't think validation or casting is required during retrieval of a document, since that also happens during saving, so it should be impossible to even have invalid objects. Other than when someone would manually change stuff, but accounting for that possibility does not seem reasonable.

Since we use virtuals, and they rely on hydration apparently, we cannot use .lean() indeed.

However, your change was sus to me, because you just removed it while it had a purpose. What we discovered now does not change that removing stuff just like that is not so great

Right, however I don't think validation or casting is required during retrieval of a document, since that also happens during saving, so it should be impossible to even have invalid objects. Other than when someone would manually change stuff, but accounting for that possibility does not seem reasonable. Since we use virtuals, and they rely on hydration apparently, we cannot use .lean() indeed. However, your change was sus to me, because you just removed it while it had a purpose. What we discovered now does not change that removing stuff just like that is not so great
Author
Owner

I removed it because it didn't serve any apparent purpose and did not have a return type, hence raising a warning.

I removed it because it didn't serve any apparent purpose and did not have a return type, hence raising a warning.
OrdisPrime marked this conversation as resolved
Sainan merged commit 2891e2fef5 into main 2025-03-15 03:24:39 -07:00
Sainan deleted branch eslint-fix 2025-03-15 03:24:40 -07:00
Sign in to join this conversation.
No description provided.