formatter: alpha
- [x]
FormatNodeRuleequivalent- https://github.com/biomejs/biome/blob/0df653f95e01122e77610e4c9df8a877cf5cb305/crates/biome_js_formatter/src/lib.rs#L349
- Layers of
fmt/fmt_node/fmt_fieldsand hooks for comments and need_parens - Do we just adjust the
FormatWrite? - yes
- [x] Where to define
needs_parentheses?- Implement it together with
FormatWriteor separated mod? - Some of the call timing may be different, but no problem?
- https://github.com/biomejs/biome/blob/0df653f95e01122e77610e4c9df8a877cf5cb305/crates/biome_js_formatter/src/js/expressions/class_expression.rs#L13
- Implement it together with
- [ ]
format().with_options()pattern- https://github.com/biomejs/biome/blob/0df653f95e01122e77610e4c9df8a877cf5cb305/crates/biome_js_formatter/src/js/auxiliary/template_element.rs#L82
- How do we deal with this without intermediate struct?
- [ ]
FormatState:snapshot() -> FormatStateSnapshot- May be needed relatively soon?
- [x] separated.rs
- Seems to be needed for the list formatting in general
- There are implementations on each language side as well as in the base formatter
- https://github.com/biomejs/biome/blob/0df653f95e01122e77610e4c9df8a877cf5cb305/crates/biome_formatter/src/separated.rs
- https://github.com/biomejs/biome/blob/0df653f95e01122e77610e4c9df8a877cf5cb305/crates/biome_js_formatter/src/separated.rs
- [ ]
format_or_verbatim()- https://github.com/biomejs/biome/blob/0df653f95e01122e77610e4c9df8a877cf5cb305/crates/biome_formatter/src/verbatim.rs#L186
- This seems to be used relatively often for list formatting
- [ ] Pre-transform AST
- https://github.com/biomejs/biome/blob/0df653f95e01122e77610e4c9df8a877cf5cb305/crates/biome_js_formatter/src/syntax_rewriter.rs#L432
- Removal of truly unnecessary
()andLogicalExprrebalance
- [x]
FormatNodeRuleequivalent- https://github.com/biomejs/biome/blob/0df653f95e01122e77610e4c9df8a877cf5cb305/crates/biome_js_formatter/src/lib.rs#L349
- Layers of
fmt/fmt_node/fmt_fieldsand hooks for comments and need_parens - Do we just adjust the
FormatWrite? - yes
- [x] Where to define
needs_parentheses?- Implement it together with
FormatWriteor separated mod? - Some of the call timing may be different, but no problem?
- https://github.com/biomejs/biome/blob/0df653f95e01122e77610e4c9df8a877cf5cb305/crates/biome_js_formatter/src/js/expressions/class_expression.rs#L13
- Implement it together with
- [ ]
format().with_options()pattern- https://github.com/biomejs/biome/blob/0df653f95e01122e77610e4c9df8a877cf5cb305/crates/biome_js_formatter/src/js/auxiliary/template_element.rs#L82
- How do we deal with this without intermediate struct?
- [ ]
FormatState:snapshot() -> FormatStateSnapshot- May be needed relatively soon?
- [x] separated.rs
- Seems to be needed for the list formatting in general
- There are implementations on each language side as well as in the base formatter
- https://github.com/biomejs/biome/blob/0df653f95e01122e77610e4c9df8a877cf5cb305/crates/biome_formatter/src/separated.rs
- https://github.com/biomejs/biome/blob/0df653f95e01122e77610e4c9df8a877cf5cb305/crates/biome_js_formatter/src/separated.rs
- [ ]
format_or_verbatim()- https://github.com/biomejs/biome/blob/0df653f95e01122e77610e4c9df8a877cf5cb305/crates/biome_formatter/src/verbatim.rs#L186
- This seems to be used relatively often for list formatting
- [ ] Pre-transform AST
- https://github.com/biomejs/biome/blob/0df653f95e01122e77610e4c9df8a877cf5cb305/crates/biome_js_formatter/src/syntax_rewriter.rs#L432
- Removal of truly unnecessary
()andLogicalExprrebalance
Organize imports should be part of the alpha release: https://www.npmjs.com/package/prettier-plugin-organize-imports
Biome actually put a lot of work into better organize import https://github.com/biomejs/biome/issues/3177 not sure if possible but if formatter is using some biome logic mayby this could also be reused?
Jotting down things that need to take some time to port:
- crates/biome_js_formatter/src/js/expressions/call_arguments.rs
- crates/biome_js_syntax/src/binary_like_expression.rs
People also want sort keys: https://github.com/nkzw-tech/eslint-config/blob/main/index.js#L10-L12
Some features I would love from years of working with other formatters:
-
backtick quotes (https://github.com/dprint/dprint-plugin-typescript/issues/345)
-
single line mode. Sometimes I want something on one line but still want to benefit from formatting within it. Example:
// oxlint-single-next-line <-- example directive I imagine using for this throw new Error(`A long error message for ${foo} that I do not ${ bool ? 'yes' : 'really yes' }` to be extended over multiple lines ty`) // oxlint-single-line <-- or here (I want single line after all...)I want formatting help to remain for that ternary. I imagine having these two directives:
// oxlint-single-next-line// oxlint-single-line
-
Deep customization options around chaining
a().b().c()format, ability to configure "presets" and then use them as directives, e.g.:// oxlint-chain-<mypreset-1> Foo.create().thing().that().does().stuff() // oxlint-chain-<mypreset-2> Foo .create() .thing() .that() .does() .stuff()/* oxlint-chain-<mypreset-2> */ // <- module wideetc.
Some features I would love from years of working with other formatters:
backtick quotes (Support for quote style of template literal strings dprint/dprint-plugin-typescript#345)
single line mode. Sometimes I want something on one line but still want to benefit from formatting within it. Example: // oxlint-single-next-line <-- example directive I imagine using for this throw new Error(
A long error message for ${foo} that I do not ${ bool ? 'yes' : 'really yes' }to be extended over multiple lines ty`) // oxlint-single-line <-- or here (I want single line after all...)I want formatting help to remain for that ternary. I imagine having these two directives:
// oxlint-single-next-line// oxlint-single-lineDeep customization options around chaining
a().b().c()format, ability to configure "presets" and then use them as directives, e.g.: // oxlint-chain-Foo.create().thing().that().does().stuff() // oxlint-chain-
Foo .create() .thing() .that() .does() .stuff() /* oxlint-chain-
*/ // <- module wide etc.
all great points I would love to see this too
Hello guys, this is so exciting !!
I have a question about keeping lines imports/exports in one line and not split them into multiple lines as prettier does. It that something that is planned/achievable/desired ?
I know there are quite some issues for prettier/biome about this so I just wanted to ask about it.
@leaysgur Not sure if you are aware of its existence, but there's a great rust based formatter that I've been using for a while, dprint. It has an html/embedded languages plugin, which works with vue/svelte. Perhaps delegating to it instead of prettier is more straighforward (I don't know much about Rust).
@leaysgur Not sure if you are aware of its existence, but there's a great rust based formatter that I've been using for a while, dprint. It has an html/embedded languages plugin, which works with vue/svelte. Perhaps delegating to it instead of prettier is more straighforward (I don't know much about Rust).
We are aware of dprint (All oxc codebases are formatted by dprint btw). But we want to adopt the prettier ecosystem for maximum compatibility.
We'll use the the milestone https://github.com/oxc-project/oxc/milestone/14 to keep track of individual tasks.
For discussion, see
- https://github.com/oxc-project/oxc/discussions/13608