-
Notifications
You must be signed in to change notification settings - Fork 660
feat(rome_js_formatter): Indent Doc comments #3129
Conversation
Deploying with Cloudflare Pages
|
5b6740c
to
6816c07
Compare
#[derive(Eq, PartialEq, Copy, Clone, Debug, Default)] | ||
pub struct JsCommentStyle; | ||
|
||
impl CommentStyle<JsLanguage> for JsCommentStyle { |
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.
I moved this from context.rs
CONNECTING: Object.freeze({ kind: "CONNECTING" }), | ||
NOT_CONNECTED: Object.freeze({ kind: "NOT_CONNECTED" }), | ||
}); | ||
- | ||
-/* A comment */ | ||
-/** | ||
- * A type that can be written to a buffer. | ||
+/* A comment */ /** |
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.
Prettier inserts a line break here. We aren't able to do this yet because Prettier only does so if the doc is a trailing comment of a node. We'll only have this distinction (at least in a cheap way) after the comments refactor.
The only difference is that the block comments start on the same line. A user can fix this by manually inserting a line break, which is what they also have to do for other block comments that start on the same line.
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.
You should run cargo codegen-bindings
, that will update the types with comments.
crates/rome_js_formatter/tests/specs/prettier/js/comments/trailing-jsdocs.js.snap
Show resolved
Hide resolved
!bench_formatter |
Formatter Benchmark Results
|
This PR adds support for indenting js doc comments. ```javascript /* * a comment */ ``` Becomes ```javascript /* * a comment * ``` The PR introduces a new `LeadingCommentRule` type on the `CstFormatContext` that is used to format any leading comment. This allows languages to implement formatting of a comment's content, something that wasn't possible before. ## Tests **Average compatibility**: 83.70 -> 84.04 <details> <summary>Definition</summary> $$average = \frac\{\sum_{file}^\{files}compatibility_\{file}}\{files}$$ </details> **Compatible lines**: 80.79 -> 81.22
d89d467
to
5fd2ac8
Compare
This PR adds support for indenting js doc comments.
Becomes
The PR introduces a new
LeadingCommentRule
type on theCstFormatContext
that is used to format any leading comment. This allows languages to implement formatting of a comment's content, something that wasn't possible before.Tests
Average compatibility: 83.70 -> 84.04
Compatible lines: 80.79 -> 81.22