@tsrx/prettier-plugin 0.3.96 → 0.3.97
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/index.test.js +48 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsrx/prettier-plugin",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.97",
|
|
4
4
|
"description": "Ripple plugin for Prettier",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"prettier": "^3.8.4"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@tsrx/core": "0.1.
|
|
30
|
+
"@tsrx/core": "0.1.40"
|
|
31
31
|
},
|
|
32
32
|
"files": [
|
|
33
33
|
"src/"
|
package/src/index.test.js
CHANGED
|
@@ -510,6 +510,54 @@ function App() {
|
|
|
510
510
|
}`);
|
|
511
511
|
});
|
|
512
512
|
|
|
513
|
+
it('formats a multiline parenthesized self-closing expression', async () => {
|
|
514
|
+
const result = await format(`const value = (
|
|
515
|
+
<Item />
|
|
516
|
+
);`);
|
|
517
|
+
|
|
518
|
+
expect(result).toBeWithNewline('const value = <Item />;');
|
|
519
|
+
});
|
|
520
|
+
|
|
521
|
+
it('formats a return ternary from a self-closing element to a fragment', async () => {
|
|
522
|
+
const input = `function ElementToFragment(condition) {
|
|
523
|
+
return condition ? (
|
|
524
|
+
<Item />
|
|
525
|
+
) : (
|
|
526
|
+
<>
|
|
527
|
+
<Item />
|
|
528
|
+
</>
|
|
529
|
+
);
|
|
530
|
+
}`;
|
|
531
|
+
const expected = `function ElementToFragment(condition) {
|
|
532
|
+
return condition
|
|
533
|
+
? <Item />
|
|
534
|
+
: <>
|
|
535
|
+
<Item />
|
|
536
|
+
</>;
|
|
537
|
+
}`;
|
|
538
|
+
|
|
539
|
+
const result = await format(input);
|
|
540
|
+
expect(result).toBeWithNewline(expected);
|
|
541
|
+
expect(await format(result)).toBe(result);
|
|
542
|
+
});
|
|
543
|
+
|
|
544
|
+
it('formats a return ternary from a self-closing element to an array', async () => {
|
|
545
|
+
const input = `function ElementToArray(condition) {
|
|
546
|
+
return condition ? (
|
|
547
|
+
<Item />
|
|
548
|
+
) : (
|
|
549
|
+
[<Item />]
|
|
550
|
+
);
|
|
551
|
+
}`;
|
|
552
|
+
const expected = `function ElementToArray(condition) {
|
|
553
|
+
return condition ? <Item /> : [<Item />];
|
|
554
|
+
}`;
|
|
555
|
+
|
|
556
|
+
const result = await format(input);
|
|
557
|
+
expect(result).toBeWithNewline(expected);
|
|
558
|
+
expect(await format(result)).toBe(result);
|
|
559
|
+
});
|
|
560
|
+
|
|
513
561
|
it('hugs a `@{ }` code block to an element body', async () => {
|
|
514
562
|
const input = `function App(){return <div>@{const x=1;<span>{x}</span>}</div>}`;
|
|
515
563
|
const expected = `function App() {
|