Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Commit

Permalink
Fix codegen and node api tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaReiser committed Sep 23, 2022
1 parent fc06d58 commit ca53a38
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
1 change: 1 addition & 0 deletions crates/rome_formatter/src/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ impl<'buf, Context> Formatter<'buf, Context> {
match elements.len() {
0 => None,
// Doesn't get cheaper than calling clone, use the element directly
// SAFETY: Safe because of the `len == 1` check in the match arm.
1 => Some(elements.pop().unwrap()),
_ => Some(FormatElement::Interned(Interned::new(elements))),
}
Expand Down
2 changes: 1 addition & 1 deletion crates/rome_formatter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ impl std::fmt::Display for FormatError {
fmt,
"formatting range {input:?} is larger than syntax tree {tree:?}"
),
FormatError::InvalidDocument(error) => std::write!(fmt, "Invalid document: {error}\n\n This is an internal Rome error. Please open an issue https://github.com/rome/tools/issues."),
FormatError::InvalidDocument(error) => std::write!(fmt, "Invalid document: {error}\n\n This is an internal Rome error. Please report if necessary."),
}
}
}
Expand Down
14 changes: 5 additions & 9 deletions npm/rome/tests/daemon/formatContent.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe("Rome Deamon formatter", async () => {
expect(result.content).toEqual("function f() {}\n");
expect(result.diagnostics).toEqual([]);
expect(result.ir).toMatchInlineSnapshot(
'"[\\"function\\", \\" \\", \\"f\\", group([\\"(\\", \\")\\"]), \\" \\", \\"{\\", \\"}\\", hard_line_break]"',
'"[\\"function f\\", group([\\"()\\"]), \\" {}\\", hard_line_break]"',
);
});

Expand All @@ -75,16 +75,12 @@ describe("Rome Deamon formatter", async () => {
expect(result.ir).toMatchInlineSnapshot(
`
"[
group([\\"let\\", \\" \\", \\"a\\"]),
group([\\"let a\\"]),
\\";\\",
hard_line_break,
\\"function\\",
\\" \\",
\\"g\\",
group([\\"(\\", \\")\\"]),
\\" \\",
\\"{\\",
\\"}\\",
\\"function g\\",
group([\\"()\\"]),
\\" {}\\",
hard_line_break
]"
`,
Expand Down
2 changes: 1 addition & 1 deletion xtask/codegen/src/generate_bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ pub(crate) fn generate_workspace_bindings(mode: Mode) -> Result<()> {
.build();

let formatted = format_node(JsFormatOptions::new(SourceType::ts()), module.syntax()).unwrap();
let printed = formatted.print();
let printed = formatted.print().unwrap();
let code = printed.into_code();

update(&bindings_path, &code, &mode)?;
Expand Down

0 comments on commit ca53a38

Please sign in to comment.