Skip to content

fix: support markup syntaxes#16

Open
jaredLunde wants to merge 3 commits intodprint:mainfrom
jaredLunde:support-markup-syntaxes
Open

fix: support markup syntaxes#16
jaredLunde wants to merge 3 commits intodprint:mainfrom
jaredLunde:support-markup-syntaxes

Conversation

@jaredLunde
Copy link
Copy Markdown

@jaredLunde jaredLunde commented Sep 11, 2024

Allows downstream packages like markup_fmt pass extensions for files that use markup/frontmatter syntaxes.

Closes #15

In general, users should be able to configure the plugin to run on these files since Biome can parse/format them on its own.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Sep 11, 2024

CLA assistant check
All committers have signed the CLA.

@jaredLunde jaredLunde changed the title fix: support markup syntaxes in format_text fix: support markup syntaxes Sep 11, 2024
Comment thread src/format_text.rs
printed.into_code()
}
Some("js" | "jsx" | "ts" | "tsx" | "cjs" | "mjs" | "cts" | "mts") => {
Some("js" | "jsx" | "ts" | "tsx" | "cjs" | "mjs" | "cts" | "mts" | "astro" | "svelte" | "vue") => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The code below formats js files, so won't this cause errors to surface for these file types? Maybe adding a test to this PR might help demonstrate the fix?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This line below determines the JS syntax from the file path:

let Ok(syntax) = JsFileSource::try_from(file_path) else {

Which winds up here: https://github.com/biomejs/biome/blob/561b54c93625c9a83035562022af47237e6c00b2/crates/biome_js_syntax/src/file_source.rs#L300

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I'm down to add a test though : )

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oh, interesting. For adding a test it would just be adding a file like this one: https://github.com/dprint/dprint-plugin-biome/blob/main/tests/specs/Json.txt (but making the top line have a .svelte extension) then running cargo test

Copy link
Copy Markdown

@Eveeifyeve Eveeifyeve Oct 14, 2024

Choose a reason for hiding this comment

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

Also don't forget to add a thing for json and jsonc since it's fully supported in biome.
https://biomejs.dev/internals/language-support/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Some("json" | "jsonc") => {

Copy link
Copy Markdown
Member

@dsherret dsherret left a comment

Choose a reason for hiding this comment

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

I tried writing a test and this doesn't work from what I can tell. I don't see any docs about biome being able to format these kind of files, but maybe it's there somewhere. It also seems to go into the biome_js_parser.

@Eveeifyeve
Copy link
Copy Markdown

Eveeifyeve commented May 18, 2025

I tried writing a test and this doesn't work from what I can tell. I don't see any docs about biome being able to format these kind of files, but maybe it's there somewhere. It also seems to go into the biome_js_parser.

https://biomejs.dev/internals/language-support/
https://github.com/biomejs/biome/blob/a82a1f2e50c5c9b22cc696960bc167631d1de455/crates/biome_js_syntax/src/file_source.rs#L203-L215

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.

Support for "astro", "vue", and "svelte" extensions

4 participants