@tsrx/prettier-plugin 0.3.28 → 0.3.29

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.28",
3
+ "version": "0.3.29",
4
4
  "description": "Ripple plugin for Prettier",
5
5
  "type": "module",
6
6
  "module": "src/index.js",
@@ -26,11 +26,11 @@
26
26
  "devDependencies": {
27
27
  "@types/node": "^24.3.0",
28
28
  "prettier": "^3.8.3",
29
- "ripple": "0.3.28"
29
+ "ripple": "0.3.29"
30
30
  },
31
31
  "dependencies": {
32
- "@tsrx/core": "0.0.8",
33
- "@tsrx/ripple": "0.0.10"
32
+ "@tsrx/core": "0.0.9",
33
+ "@tsrx/ripple": "0.0.11"
34
34
  },
35
35
  "files": [
36
36
  "src/"
package/src/index.js CHANGED
@@ -5554,6 +5554,7 @@ function createElementLevelCommentPartsTrimmed(comments) {
5554
5554
 
5555
5555
  /**
5556
5556
  * Print a Tsx node - renders Ripple template children inside <tsx>...</tsx>
5557
+ * or fragment shorthand <>...</> when the original source used a fragment.
5557
5558
  * @param {AST.Tsx} node - The Tsx node
5558
5559
  * @param {AstPath<AST.Tsx>} path - The AST path
5559
5560
  * @param {RippleFormatOptions} options - Prettier options
@@ -5561,8 +5562,9 @@ function createElementLevelCommentPartsTrimmed(comments) {
5561
5562
  * @returns {Doc}
5562
5563
  */
5563
5564
  function printTsx(node, path, options, print) {
5564
- const tagName = '<tsx>';
5565
- const closingTagName = '</tsx>';
5565
+ const is_fragment = !node.openingElement?.name;
5566
+ const tagName = is_fragment ? '<>' : '<tsx>';
5567
+ const closingTagName = is_fragment ? '</>' : '</tsx>';
5566
5568
 
5567
5569
  const hasChildren = Array.isArray(node.children) && node.children.length > 0;
5568
5570
 
package/src/index.test.js CHANGED
@@ -1935,6 +1935,40 @@ files = [...(files ?? []), ...dt.files];`;
1935
1935
  expect(result).toBeWithNewline(expected);
1936
1936
  });
1937
1937
 
1938
+ it('should preserve fragment shorthand in class methods', async () => {
1939
+ const input = `class Foo {
1940
+ bar() {
1941
+ return <>{"Hello"}</>;
1942
+ }
1943
+ }`;
1944
+
1945
+ const expected = `class Foo {
1946
+ bar() {
1947
+ return <>{'Hello'}</>;
1948
+ }
1949
+ }`;
1950
+
1951
+ const result = await format(input, { singleQuote: true, printWidth: 100 });
1952
+ expect(result).toBeWithNewline(expected);
1953
+ });
1954
+
1955
+ it('should preserve explicit tsx blocks in class methods', async () => {
1956
+ const input = `class Foo {
1957
+ bar() {
1958
+ return <tsx>{"Hello"}</tsx>;
1959
+ }
1960
+ }`;
1961
+
1962
+ const expected = `class Foo {
1963
+ bar() {
1964
+ return <tsx>{'Hello'}</tsx>;
1965
+ }
1966
+ }`;
1967
+
1968
+ const result = await format(input, { singleQuote: true, printWidth: 100 });
1969
+ expect(result).toBeWithNewline(expected);
1970
+ });
1971
+
1938
1972
  it('should format class with a literal component method', async () => {
1939
1973
  const input = `class TestClass {
1940
1974
  component 'something'() {