From 5228c0e1d050b1e9455fbd41f560c366ea2f188e Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Sat, 25 May 2024 10:10:15 +0000 Subject: [PATCH 1/2] refactor: replace short hand type conversions with function calls Prefer using explicit casts by calling `Number`, `Boolean`, or `String` over using operators like `+`, `!!` or `"" +`. This is considered best practice as it improves readability. --- src/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils.ts b/src/utils.ts index 141ddde..68293a7 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -6,6 +6,6 @@ export async function getPosts(collection: keyof ContentEntryMap) { return data.draft !== true }) return posts.sort((a, b) => - a.data.pubDate && b.data.pubDate ? +b.data.pubDate - +a.data.pubDate : 0 + a.data.pubDate && b.data.pubDate ? Number(b.data.pubDate) - Number(a.data.pubDate) : 0 ) } \ No newline at end of file From e835b2aa2cd1bf1595d18cebf3c45393661eb6fc Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Sat, 25 May 2024 10:10:27 +0000 Subject: [PATCH 2/2] style: format code with Prettier This commit fixes the style issues introduced in 5228c0e according to the output from Prettier. Details: https://github.com/Fluffy-Bean/website/pull/3 --- src/utils.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index 68293a7..c839127 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -3,9 +3,11 @@ import { type ContentEntryMap, getCollection } from "astro:content"; // https://github.com/hellotham/hello-astro/blob/e05706cf488bcec6e4c5494a622eedfc4e47d763/src/config.ts#L55C1-L62C2 export async function getPosts(collection: keyof ContentEntryMap) { const posts = await getCollection(collection, ({ data }) => { - return data.draft !== true - }) + return data.draft !== true; + }); return posts.sort((a, b) => - a.data.pubDate && b.data.pubDate ? Number(b.data.pubDate) - Number(a.data.pubDate) : 0 - ) -} \ No newline at end of file + a.data.pubDate && b.data.pubDate + ? Number(b.data.pubDate) - Number(a.data.pubDate) + : 0, + ); +}