@tsrx/prettier-plugin 0.3.35 → 0.3.37
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 +4 -4
- package/src/index.js +11 -6
- package/src/index.test.js +12 -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.37",
|
|
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.
|
|
29
|
+
"ripple": "0.3.37"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@tsrx/core": "0.0.
|
|
33
|
-
"@tsrx/ripple": "0.0.
|
|
32
|
+
"@tsrx/core": "0.0.17",
|
|
33
|
+
"@tsrx/ripple": "0.0.19"
|
|
34
34
|
},
|
|
35
35
|
"files": [
|
|
36
36
|
"src/"
|
package/src/index.js
CHANGED
|
@@ -2225,6 +2225,11 @@ function printRippleNode(node, path, options, print, args) {
|
|
|
2225
2225
|
}
|
|
2226
2226
|
|
|
2227
2227
|
case 'Text': {
|
|
2228
|
+
if (typeof node.raw === 'string') {
|
|
2229
|
+
nodeContent = node.raw;
|
|
2230
|
+
break;
|
|
2231
|
+
}
|
|
2232
|
+
|
|
2228
2233
|
const expressionDoc = suppressExpressionLeadingComments
|
|
2229
2234
|
? path.call((exprPath) => print(exprPath, { suppressLeadingComments: true }), 'expression')
|
|
2230
2235
|
: path.call(print, 'expression');
|
|
@@ -5480,15 +5485,15 @@ function shouldInlineSingleChild(parentNode, firstChild, childDoc) {
|
|
|
5480
5485
|
return false;
|
|
5481
5486
|
}
|
|
5482
5487
|
|
|
5483
|
-
|
|
5484
|
-
return childDoc.length <= 20 && !childDoc.includes('\n');
|
|
5485
|
-
}
|
|
5486
|
-
|
|
5487
|
-
// Always inline Html and Text nodes — they are short prefixed expressions ({html ...}, {text ...})
|
|
5488
|
+
// Always inline Html and Text nodes — they are explicit text/raw-markup child forms.
|
|
5488
5489
|
if (firstChild.type === 'Text' || firstChild.type === 'Html') {
|
|
5489
5490
|
return true;
|
|
5490
5491
|
}
|
|
5491
5492
|
|
|
5493
|
+
if (typeof childDoc === 'string') {
|
|
5494
|
+
return childDoc.length <= 20 && !childDoc.includes('\n');
|
|
5495
|
+
}
|
|
5496
|
+
|
|
5492
5497
|
// Inline JSX expressions if they fit, but respect original multi-line formatting
|
|
5493
5498
|
// for non-literal expressions (e.g. {children} should stay multi-line if written that way)
|
|
5494
5499
|
if (firstChild.type === 'TSRXExpression' || firstChild.type === 'JSXExpressionContainer') {
|
|
@@ -6403,7 +6408,7 @@ function printElement(element, path, options, print) {
|
|
|
6403
6408
|
firstChild && firstChild.type === 'Element' && !firstChild.selfClosing;
|
|
6404
6409
|
const isElementChild = firstChild && firstChild.type === 'Element';
|
|
6405
6410
|
|
|
6406
|
-
if (typeof child === 'string' &&
|
|
6411
|
+
if (typeof child === 'string' && shouldInlineSingleChild(node, firstChild, child)) {
|
|
6407
6412
|
elementOutput = group([openingTag, child, closingTag]);
|
|
6408
6413
|
} else if (
|
|
6409
6414
|
child &&
|
package/src/index.test.js
CHANGED
|
@@ -3091,6 +3091,18 @@ const items = [] as unknown[];`;
|
|
|
3091
3091
|
expect(result).toBeWithNewline(expected);
|
|
3092
3092
|
});
|
|
3093
3093
|
|
|
3094
|
+
it('should preserve direct double-quoted text children', async () => {
|
|
3095
|
+
const input = `export component App(){<div>"Hello & "TSRX""</div><div>{text message}</div>}`;
|
|
3096
|
+
|
|
3097
|
+
const expected = `export component App() {
|
|
3098
|
+
<div>"Hello & "TSRX""</div>
|
|
3099
|
+
<div>{text message}</div>
|
|
3100
|
+
}`;
|
|
3101
|
+
|
|
3102
|
+
const result = await format(input, { singleQuote: true });
|
|
3103
|
+
expect(result).toBeWithNewline(expected);
|
|
3104
|
+
});
|
|
3105
|
+
|
|
3094
3106
|
it('should not insert a new line between js and jsx if not provided', async () => {
|
|
3095
3107
|
const expected = `export component App() {
|
|
3096
3108
|
let text = 'something';
|