Skip to content
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

[FEAT] Add option to skip formatting the Frontmatter #417

Merged
merged 4 commits into from
May 23, 2024

Conversation

cstrlcs
Copy link
Contributor

@cstrlcs cstrlcs commented May 15, 2024

Changes

I know this is a very specific use case, but I thought: Why not? Maybe someone else will find useful.

  • Adds a new option called "astroSkipFrontmatter" that preserves the content of the front matter. Useful for when the developer wants to format only the template.
  • This is useful for integrating with other tools like Biome (https://biomejs.dev) that can format and lint Astro's frontmatter but not the template/html (yet).

My use case: I added a new script to my package.json that can format all my astro components without interfering with BIome's onSave lint/format.

Testing

  • Added fixtures for the new option
  • Did not add tests for it, since all the other tests for previous options were commented out.

Docs

  • Added new section on README.md describing the option.

Thanks!

Copy link

changeset-bot bot commented May 15, 2024

🦋 Changeset detected

Latest commit: 63e11a5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
prettier-plugin-astro Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@cstrlcs cstrlcs changed the title feat: astroSkipFrontmatter Add option to skip formatting the Frontmatter May 15, 2024
@cstrlcs cstrlcs changed the title Add option to skip formatting the Frontmatter [FEATURE] Add option to skip formatting the Frontmatter May 15, 2024
@cstrlcs cstrlcs changed the title [FEATURE] Add option to skip formatting the Frontmatter [FEAT] Add option to skip formatting the Frontmatter May 15, 2024
@Princesseuh
Copy link
Member

Hmm, I'm not sure why the other tests for options specific to Astro were commented out. I feel like they should work. That's something to look at for another PR though, this looks great to me.

@cstrlcs
Copy link
Contributor Author

cstrlcs commented May 23, 2024

Hi! I forgot to run format before committing. Just pushed a fix adding the commas and semis the bot was complaining. Please, let me know if there is something I can change to improve this PR.

Thanks!!

Copy link
Member

@Princesseuh Princesseuh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks awesome, thank you for contributing this!

@Princesseuh Princesseuh merged commit bb756df into withastro:main May 23, 2024
5 checks passed
@tinchoz49
Copy link

Hi @cstrlcs, thanks for doing this. Question: doest it work also for <script> tags?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants