@tsrx/prettier-plugin 0.3.54 → 0.3.57
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 +9 -4
- package/src/index.test.js +35 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsrx/prettier-plugin",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.57",
|
|
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.
|
|
30
|
+
"@tsrx/core": "0.1.7"
|
|
31
31
|
},
|
|
32
32
|
"files": [
|
|
33
33
|
"src/"
|
package/src/index.js
CHANGED
|
@@ -3061,11 +3061,13 @@ function printCallArguments(path, options, print) {
|
|
|
3061
3061
|
}, 'arguments');
|
|
3062
3062
|
const trailingComma = shouldPrintComma(options, 'all') ? ',' : '';
|
|
3063
3063
|
|
|
3064
|
-
// Special case: single array argument should keep opening
|
|
3064
|
+
// Special case: single array/object argument should keep opening delimiter inline
|
|
3065
3065
|
const isSingleArrayArgument = args.length === 1 && args[0] && args[0].type === 'ArrayExpression';
|
|
3066
|
+
const isSingleObjectArgument =
|
|
3067
|
+
args.length === 1 && args[0] && args[0].type === 'ObjectExpression';
|
|
3066
3068
|
|
|
3067
|
-
if (isSingleArrayArgument) {
|
|
3068
|
-
// Don't use group() - just concat to allow
|
|
3069
|
+
if (isSingleArrayArgument || isSingleObjectArgument) {
|
|
3070
|
+
// Don't use group() - just concat to allow the argument to control its own breaking
|
|
3069
3071
|
// For single argument, no trailing comma needed
|
|
3070
3072
|
return ['(', argumentDocs[0], ')'];
|
|
3071
3073
|
} // Check if we should hug arrow functions (keep params inline even when body breaks)
|
|
@@ -6594,7 +6596,10 @@ function printAttribute(node, path, options, print) {
|
|
|
6594
6596
|
parts.push('=');
|
|
6595
6597
|
const useJsxSingleQuote = options.jsxSingleQuote === true;
|
|
6596
6598
|
parts.push(
|
|
6597
|
-
formatStringLiteral(node.value.value, {
|
|
6599
|
+
formatStringLiteral(node.value.value, {
|
|
6600
|
+
...options,
|
|
6601
|
+
singleQuote: useJsxSingleQuote,
|
|
6602
|
+
}),
|
|
6598
6603
|
);
|
|
6599
6604
|
} else {
|
|
6600
6605
|
// All other values need curly braces: numbers, booleans, null, expressions, etc.
|
package/src/index.test.js
CHANGED
|
@@ -1705,6 +1705,17 @@ function bind_element_rect(maybe_tracked, type) {
|
|
|
1705
1705
|
expect(result).toBeWithNewline(expected);
|
|
1706
1706
|
});
|
|
1707
1707
|
|
|
1708
|
+
it('should keep a single object argument attached when the object breaks', async () => {
|
|
1709
|
+
const input = `foo({ a: 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz' });`;
|
|
1710
|
+
|
|
1711
|
+
const expected = `foo({
|
|
1712
|
+
a: 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz',
|
|
1713
|
+
});`;
|
|
1714
|
+
|
|
1715
|
+
const result = await format(input, { singleQuote: true, printWidth: 85 });
|
|
1716
|
+
expect(result).toBeWithNewline(expected);
|
|
1717
|
+
});
|
|
1718
|
+
|
|
1708
1719
|
it('should break up call expressions on new lines with inline jsdoc comments with printWidth 100', async () => {
|
|
1709
1720
|
const input = `for (const quasi of template.quasis) {
|
|
1710
1721
|
quasi.value.raw = sanitize_template_string(/** @type {string} */ (quasi.value.cooked));
|
|
@@ -3710,7 +3721,10 @@ const fn = <T>(arg: T): T => arg;`;
|
|
|
3710
3721
|
};
|
|
3711
3722
|
}`;
|
|
3712
3723
|
|
|
3713
|
-
const result = await format(input, {
|
|
3724
|
+
const result = await format(input, {
|
|
3725
|
+
singleQuote: true,
|
|
3726
|
+
arrowParens: 'always',
|
|
3727
|
+
});
|
|
3714
3728
|
expect(result).toBeWithNewline(expected);
|
|
3715
3729
|
});
|
|
3716
3730
|
|
|
@@ -3766,7 +3780,10 @@ function inputRef(node) {
|
|
|
3766
3780
|
|
|
3767
3781
|
//yet more`;
|
|
3768
3782
|
|
|
3769
|
-
const result = await format(input, {
|
|
3783
|
+
const result = await format(input, {
|
|
3784
|
+
singleQuote: true,
|
|
3785
|
+
arrowParens: 'always',
|
|
3786
|
+
});
|
|
3770
3787
|
expect(result).toBeWithNewline(expected);
|
|
3771
3788
|
});
|
|
3772
3789
|
|
|
@@ -3801,7 +3818,10 @@ try {
|
|
|
3801
3818
|
}
|
|
3802
3819
|
}`;
|
|
3803
3820
|
|
|
3804
|
-
const result = await format(input, {
|
|
3821
|
+
const result = await format(input, {
|
|
3822
|
+
singleQuote: true,
|
|
3823
|
+
arrowParens: 'always',
|
|
3824
|
+
});
|
|
3805
3825
|
expect(result).toBeWithNewline(expected);
|
|
3806
3826
|
});
|
|
3807
3827
|
|
|
@@ -3868,7 +3888,10 @@ try {
|
|
|
3868
3888
|
},
|
|
3869
3889
|
];`;
|
|
3870
3890
|
|
|
3871
|
-
const result = await format(input, {
|
|
3891
|
+
const result = await format(input, {
|
|
3892
|
+
singleQuote: true,
|
|
3893
|
+
arrowParens: 'always',
|
|
3894
|
+
});
|
|
3872
3895
|
expect(result).toBeWithNewline(expected);
|
|
3873
3896
|
});
|
|
3874
3897
|
|
|
@@ -3979,7 +4002,10 @@ component RowList({ rows, Row }) {
|
|
|
3979
4002
|
Medium,
|
|
3980
4003
|
Large
|
|
3981
4004
|
}`;
|
|
3982
|
-
const result = await format(input, {
|
|
4005
|
+
const result = await format(input, {
|
|
4006
|
+
singleQuote: true,
|
|
4007
|
+
trailingComma: 'none',
|
|
4008
|
+
});
|
|
3983
4009
|
expect(result).toBeWithNewline(expected);
|
|
3984
4010
|
});
|
|
3985
4011
|
|
|
@@ -4668,7 +4694,10 @@ component Polygon() {
|
|
|
4668
4694
|
<polygon points="0,0 30,0 15,10" />
|
|
4669
4695
|
}`;
|
|
4670
4696
|
|
|
4671
|
-
const result = await format(expected, {
|
|
4697
|
+
const result = await format(expected, {
|
|
4698
|
+
singleQuote: true,
|
|
4699
|
+
printWidth: 100,
|
|
4700
|
+
});
|
|
4672
4701
|
expect(result).toBeWithNewline(expected);
|
|
4673
4702
|
});
|
|
4674
4703
|
|