-
Notifications
You must be signed in to change notification settings - Fork 0
update Biome formatting #26
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
Conversation
✅ Deploy Preview for mmert9008-astroblogtutorial ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Summary of ChangesHello @mmert9008, 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 applying automated code formatting using Biome across the project. The changes ensure a unified code style, addressing inconsistencies in whitespace, newline characters, import statement syntax, and array/object literal formatting throughout various Astro components, pages, and configuration files. This effort aims to enhance code readability and maintain a consistent codebase. Highlights
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
|
There was a problem hiding this 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 applies formatting changes across the project using Biome, which is great for code consistency. The formatting changes look good. I've also taken the opportunity to suggest improvements to type safety in a few files. By replacing the any type with a specific Frontmatter interface for your blog posts, you can leverage TypeScript's full power to catch errors early and improve code maintainability.
| const allPosts = Object.values( | ||
| import.meta.glob("./posts/*.md", { eager: true }), | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To improve type safety and avoid using any when mapping over allPosts later in this file, you can provide a type to import.meta.glob. This will give you type checking and autocompletion for your post frontmatter.
First, you'll need to import MarkdownInstance and define an interface for your frontmatter at the top of your --- block:
import type { MarkdownInstance } from 'astro';
interface Frontmatter {
title: string;
pubDate: Date;
description: string;
author: string;
image: { url: string; alt: string; };
tags: string[];
}Then, you can update this block to use it:
const allPosts = Object.values(
import.meta.glob<MarkdownInstance<Frontmatter>>("./posts/*.md", { eager: true })
);| const uniqueTags = [...new Set(allPosts.map((post: any) => post.frontmatter.tags).flat())]; | ||
| const uniqueTags = [ | ||
| ...new Set(allPosts.map((post: any) => post.frontmatter.tags).flat()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using any bypasses TypeScript's type checking, which can hide bugs. It's better to provide a proper type for post. You can achieve this by strongly typing allPosts where it's defined.
First, define an interface for your frontmatter at the top of the script section:
import type { MarkdownInstance } from 'astro';
interface Frontmatter {
title: string;
pubDate: Date;
description: string;
author: string;
image: { url: string; alt: string; };
tags: string[];
}Then, update the allPosts definition:
const allPosts = Object.values(
import.meta.glob<MarkdownInstance<Frontmatter>>("../posts/*.md", { eager: true })
);After this, you can remove : any here and in other places where allPosts is used, and TypeScript will correctly infer the type of post.
...new Set(allPosts.map((post) => post.frontmatter.tags).flat()),
| import.meta.glob("../posts/*.md", { eager: true }), | ||
| ); | ||
| const tags = [ | ||
| ...new Set(allPosts.map((post: any) => post.frontmatter.tags).flat()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using any is not recommended as it disables type checking for post. To improve type safety, you can define a Frontmatter interface and use it to type allPosts when calling import.meta.glob.
Example of how to type allPosts:
import type { MarkdownInstance } from 'astro';
interface Frontmatter {
title: string;
pubDate: Date;
description: string;
author: string;
image: { url: string; alt: string; };
tags: string[];
}
const allPosts = Object.values(
import.meta.glob<MarkdownInstance<Frontmatter>>("../posts/*.md", { eager: true })
);This change will allow you to remove : any from this line.
...new Set(allPosts.map((post) => post.frontmatter.tags).flat()),
No description provided.