@ripple-ts/prettier-plugin 0.2.174 → 0.2.176
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.js +8 -2
- package/src/index.test.js +15 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ripple-ts/prettier-plugin",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.176",
|
|
4
4
|
"description": "Ripple plugin for Prettier",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"prettier": "^3.6.2",
|
|
28
|
-
"ripple": "0.2.
|
|
28
|
+
"ripple": "0.2.176"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {},
|
|
31
31
|
"files": [
|
package/src/index.js
CHANGED
|
@@ -696,6 +696,7 @@ function printRippleNode(node, path, options, print, args) {
|
|
|
696
696
|
break;
|
|
697
697
|
|
|
698
698
|
case 'ClassDeclaration':
|
|
699
|
+
case 'ClassExpression':
|
|
699
700
|
nodeContent = printClassDeclaration(node, path, options, print);
|
|
700
701
|
break;
|
|
701
702
|
|
|
@@ -3073,8 +3074,13 @@ function printObjectExpression(node, path, options, print, args) {
|
|
|
3073
3074
|
|
|
3074
3075
|
function printClassDeclaration(node, path, options, print) {
|
|
3075
3076
|
const parts = [];
|
|
3076
|
-
parts.push('class
|
|
3077
|
-
|
|
3077
|
+
parts.push('class');
|
|
3078
|
+
|
|
3079
|
+
// Class name (optional for ClassExpression)
|
|
3080
|
+
if (node.id) {
|
|
3081
|
+
parts.push(' ');
|
|
3082
|
+
parts.push(node.id.name);
|
|
3083
|
+
}
|
|
3078
3084
|
|
|
3079
3085
|
// Add TypeScript generics if present
|
|
3080
3086
|
if (node.typeParameters) {
|
package/src/index.test.js
CHANGED
|
@@ -1717,6 +1717,13 @@ files = [...(files ?? []), ...dt.files];`;
|
|
|
1717
1717
|
const result = await format(input, { singleQuote: true, printWidth: 100 });
|
|
1718
1718
|
expect(result).toBeWithNewline(expected);
|
|
1719
1719
|
});
|
|
1720
|
+
|
|
1721
|
+
it('should recognize and preserve class assignments to variables', async () => {
|
|
1722
|
+
const expected = `let test = class MediaQueryList {};`;
|
|
1723
|
+
|
|
1724
|
+
const result = await format(expected, { singleQuote: true, printWidth: 100 });
|
|
1725
|
+
expect(result).toBeWithNewline(expected);
|
|
1726
|
+
});
|
|
1720
1727
|
});
|
|
1721
1728
|
|
|
1722
1729
|
describe('edge cases', () => {
|
|
@@ -2736,6 +2743,14 @@ try {
|
|
|
2736
2743
|
expect(result).toBeWithNewline(expected);
|
|
2737
2744
|
});
|
|
2738
2745
|
|
|
2746
|
+
it('should preserve inline comments inside jsx expressions', async () => {
|
|
2747
|
+
const expected = `<div>{/* 'This is visible text' */}</div>
|
|
2748
|
+
<div>{/* <div>{'Card Component'}</div> */}</div>`;
|
|
2749
|
+
|
|
2750
|
+
const result = await format(expected, { singleQuote: true });
|
|
2751
|
+
expect(result).toBeWithNewline(expected);
|
|
2752
|
+
});
|
|
2753
|
+
|
|
2739
2754
|
it('correctly formats array of objects and keys as either literals or identifiers', async () => {
|
|
2740
2755
|
const input = `const tt = [
|
|
2741
2756
|
{
|