@tsrx/prettier-plugin 0.3.71 → 0.3.72

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsrx/prettier-plugin",
3
- "version": "0.3.71",
3
+ "version": "0.3.72",
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.3"
28
28
  },
29
29
  "dependencies": {
30
- "@tsrx/core": "0.1.19"
30
+ "@tsrx/core": "0.1.20"
31
31
  },
32
32
  "files": [
33
33
  "src/"
package/src/index.js CHANGED
@@ -2253,14 +2253,10 @@ function printRippleNode(node, path, options, print, args) {
2253
2253
  nodeContent = printTsxCompat(node, path, options, print);
2254
2254
  break;
2255
2255
 
2256
- case 'Tsrx':
2256
+ case 'TsrxFragment':
2257
2257
  nodeContent = printTsrx(node, path, options, print);
2258
2258
  break;
2259
2259
 
2260
- case 'Tsx':
2261
- nodeContent = printTsx(node, path, options, print);
2262
- break;
2263
-
2264
2260
  case 'JSXElement':
2265
2261
  nodeContent = printJSXElement(node, path, options, print);
2266
2262
  break;
@@ -2694,9 +2690,8 @@ function printArrowFunction(node, path, options, print, args) {
2694
2690
  */
2695
2691
  function isTemplateExpression(node) {
2696
2692
  return (
2697
- node.type === 'Tsx' ||
2698
2693
  node.type === 'TsxCompat' ||
2699
- node.type === 'Tsrx' ||
2694
+ node.type === 'TsrxFragment' ||
2700
2695
  node.type === 'JSXElement' ||
2701
2696
  node.type === 'JSXFragment'
2702
2697
  );
@@ -5583,67 +5578,9 @@ function createElementLevelCommentPartsTrimmed(comments) {
5583
5578
  }
5584
5579
 
5585
5580
  /**
5586
- * Print a Tsx node - renders Ripple template children inside <tsx>...</tsx>
5587
- * or fragment shorthand <>...</> when the original source used a fragment.
5588
- * @param {AST.Tsx} node - The Tsx node
5589
- * @param {AstPath<AST.Tsx>} path - The AST path
5590
- * @param {RippleFormatOptions} options - Prettier options
5591
- * @param {PrintFn} print - Print callback
5592
- * @returns {Doc}
5593
- */
5594
- function printTsx(node, path, options, print) {
5595
- const is_fragment = !node.openingElement?.name;
5596
- const tagName = is_fragment ? '<>' : '<tsx>';
5597
- const closingTagName = is_fragment ? '</>' : '</tsx>';
5598
-
5599
- const hasChildren = Array.isArray(node.children) && node.children.length > 0;
5600
-
5601
- if (!hasChildren) {
5602
- return [tagName, closingTagName];
5603
- }
5604
-
5605
- // Print children - these are Ripple template children (Element, Text, etc.)
5606
- const printedChildren = [];
5607
-
5608
- for (let i = 0; i < node.children.length; i++) {
5609
- const child = node.children[i];
5610
-
5611
- if (child.type === 'JSXText') {
5612
- const text = child.value.trim();
5613
- if (!text) continue;
5614
- printedChildren.push(text);
5615
- } else {
5616
- const printedChild = path.call(print, 'children', i);
5617
- printedChildren.push(printedChild);
5618
- }
5619
- }
5620
-
5621
- if (printedChildren.length === 0) {
5622
- return [tagName, closingTagName];
5623
- }
5624
-
5625
- if (!is_fragment || printedChildren.length > 1) {
5626
- return group([
5627
- tagName,
5628
- indent([hardline, join(hardline, printedChildren)]),
5629
- hardline,
5630
- closingTagName,
5631
- ]);
5632
- }
5633
-
5634
- // Use softline to allow single-line when content fits
5635
- return group([
5636
- tagName,
5637
- indent([softline, join(softline, printedChildren)]),
5638
- softline,
5639
- closingTagName,
5640
- ]);
5641
- }
5642
-
5643
- /**
5644
- * Print a Tsrx node - renders native TSRX template children inside a fragment.
5645
- * @param {AST.Tsrx} node - The Tsrx node
5646
- * @param {AstPath<AST.Tsrx>} path - The AST path
5581
+ * Print a TsrxFragment node - renders native TSRX template children inside a fragment.
5582
+ * @param {AST.TsrxFragment} node - The TsrxFragment node
5583
+ * @param {AstPath<AST.TsrxFragment>} path - The AST path
5647
5584
  * @param {RippleFormatOptions} options - Prettier options
5648
5585
  * @param {PrintFn} print - Print callback
5649
5586
  * @returns {Doc}
package/src/index.test.js CHANGED
@@ -78,13 +78,13 @@ describe('prettier-plugin', () => {
78
78
  expect(result).toBeWithNewline(expected);
79
79
  });
80
80
 
81
- it('keeps explicit tsx blocks expression based', async () => {
82
- const input = `function App(){return <tsx><div>Hello world</div>{value}</tsx>}`;
81
+ it('keeps native fragments expression based', async () => {
82
+ const input = `function App(){return <><div>"Hello world"</div>{value}</>}`;
83
83
  const expected = `function App() {
84
- return <tsx>
85
- <div>Hello world</div>
84
+ return <>
85
+ <div>"Hello world"</div>
86
86
  {value}
87
- </tsx>;
87
+ </>;
88
88
  }`;
89
89
 
90
90
  const result = await format(input);