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

feat(vscode): enable formatting for JSX and TSX files #2795

Merged
merged 3 commits into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ impl FormatNodeRule<JsxExpressionAttributeValue> for FormatJsxExpressionAttribut
JsAnyExpression::JsObjectExpression(_)
| JsAnyExpression::JsArrayExpression(_)
| JsAnyExpression::JsCallExpression(_)
| JsAnyExpression::JsArrowFunctionExpression(_)
) {
write!(f, [expression.format()])?;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ useMemo(() => {
[a, b]
)

useEffect(() => {
if (clipboardStatus !== "normal") {
setClipboardStatus("normal");
}
}, [formatter_ir]);

test.expect(t => {
t.true(a)
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: crates/rome_js_formatter/tests/spec_test.rs
assertion_line: 257
assertion_line: 256
expression: call_expression.js
---
# Input
Expand All @@ -22,6 +22,12 @@ useMemo(() => {
[a, b]
)

useEffect(() => {
if (clipboardStatus !== "normal") {
setClipboardStatus("normal");
}
}, [formatter_ir]);

test.expect(t => {
t.true(a)
})
Expand Down Expand Up @@ -63,6 +69,12 @@ useMemo(() => {

useMemo(() => {}, [a, b]); // some comment

useEffect(() => {
if (clipboardStatus !== "normal") {
setClipboardStatus("normal");
}
}, [formatter_ir]);

test.expect((t) => {
t.true(a);
});
Expand Down
40 changes: 18 additions & 22 deletions crates/rome_js_formatter/tests/specs/jsx/element.jsx.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: crates/rome_js_formatter/tests/spec_test.rs
assertion_line: 257
assertion_line: 256
expression: element.jsx
---
# Input
Expand Down Expand Up @@ -191,16 +191,14 @@ function Tabs() {
value={code}
language={language}
placeholder="Enter some code here"
onChange={
(evn) => {
setPlaygroundState(
(state) => ({
...state,
code: evn.target.value,
}),
);
}
}
onChange={(evn) => {
setPlaygroundState(
(state) => ({
...state,
code: evn.target.value,
}),
);
}}
style={{
fontSize: 12,
height: "100vh",
Expand Down Expand Up @@ -277,12 +275,10 @@ function Tabs() {
function LoginForm() {
return (
<form
onChange={
(e) => {
e.preventDefault();
console.log("Submitted form!");
}
}
onChange={(e) => {
e.preventDefault();
console.log("Submitted form!");
}}
>
<input value={username} onChange={(e) => setUsername(e.target.value)} />
<input
Expand Down Expand Up @@ -354,9 +350,9 @@ let a = <a>{/* comment */ " "}</a>;
## Lines exceeding width of 80 characters

5: The films of Wong Kar-Wai exemplify the synthesis of French New Wave cinema—specifically the unrelenting experimental technique and fascination with American/western culture—with more conventional melodramatic, romantic narratives.
41: "ui-monospace,SFMono-Regular,SF Mono,Consolas,Liberation Mono,Menlo,monospace",
62: "ui-monospace,SFMono-Regular,SF Mono,Consolas,Liberation Mono,Menlo,monospace",
75: "ui-monospace,SFMono-Regular,SF Mono,Consolas,Liberation Mono,Menlo,monospace",
101: className="h-screen overflow-y-scroll whitespace-pre-wrap text-red-500 text-xs"
159: the quick brown fox jumps over the lazy dog and then jumps over the lazy cat and then over the lazy fish.
39: "ui-monospace,SFMono-Regular,SF Mono,Consolas,Liberation Mono,Menlo,monospace",
60: "ui-monospace,SFMono-Regular,SF Mono,Consolas,Liberation Mono,Menlo,monospace",
73: "ui-monospace,SFMono-Regular,SF Mono,Consolas,Liberation Mono,Menlo,monospace",
99: className="h-screen overflow-y-scroll whitespace-pre-wrap text-red-500 text-xs"
155: the quick brown fox jumps over the lazy dog and then jumps over the lazy cat and then over the lazy fish.

Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@ expression: jsx.js
# Output
```js
<div
onClick={
() =>
doSomething({
foo: bar,
})
}
onClick={() =>
doSomething({
foo: bar,
})}
/>;

```
Expand Down
Loading