@tsrx/prettier-plugin 0.3.136 → 0.3.138
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 +5 -0
- package/src/index.test.js +28 -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.138",
|
|
4
4
|
"description": "TSRX plugin for Prettier",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"prettier": "^3.9.6"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@tsrx/core": "0.1.
|
|
30
|
+
"@tsrx/core": "0.1.71"
|
|
31
31
|
},
|
|
32
32
|
"files": [
|
|
33
33
|
"src/"
|
package/src/index.js
CHANGED
|
@@ -496,6 +496,11 @@ function assignmentExpressionNeedsParens(node, parent) {
|
|
|
496
496
|
return true;
|
|
497
497
|
}
|
|
498
498
|
|
|
499
|
+
// `({ a } = obj);` — without the parentheses the statement starts with a block.
|
|
500
|
+
if (parent.type === 'ExpressionStatement') {
|
|
501
|
+
return node.left.type === 'ObjectPattern';
|
|
502
|
+
}
|
|
503
|
+
|
|
499
504
|
if (parent.type === 'ConditionalExpression') {
|
|
500
505
|
return parent.test === node;
|
|
501
506
|
}
|
package/src/index.test.js
CHANGED
|
@@ -1610,6 +1610,34 @@ async function load() {
|
|
|
1610
1610
|
expect(result).toBeWithNewline(expected);
|
|
1611
1611
|
});
|
|
1612
1612
|
|
|
1613
|
+
it('keeps the parentheses of an object destructuring assignment statement', async () => {
|
|
1614
|
+
const input = `function swap() {
|
|
1615
|
+
({ other } = { other: 'y' });
|
|
1616
|
+
[label] = ['b'];
|
|
1617
|
+
({ other } = source).other;
|
|
1618
|
+
}
|
|
1619
|
+
export function Pair() @{
|
|
1620
|
+
const swap = () => {
|
|
1621
|
+
({ other } = { other: 'y' });
|
|
1622
|
+
};
|
|
1623
|
+
<span onClick={swap}>{other}</span>
|
|
1624
|
+
}`;
|
|
1625
|
+
const expected = `function swap() {
|
|
1626
|
+
({ other } = { other: 'y' });
|
|
1627
|
+
[label] = ['b'];
|
|
1628
|
+
({ other } = source).other;
|
|
1629
|
+
}
|
|
1630
|
+
export function Pair() @{
|
|
1631
|
+
const swap = () => {
|
|
1632
|
+
({ other } = { other: 'y' });
|
|
1633
|
+
};
|
|
1634
|
+
<span onClick={swap}>{other}</span>
|
|
1635
|
+
}`;
|
|
1636
|
+
|
|
1637
|
+
const result = await format(input, { singleQuote: true });
|
|
1638
|
+
expect(result).toBeWithNewline(expected);
|
|
1639
|
+
});
|
|
1640
|
+
|
|
1613
1641
|
it('should not change formatting for function object properties and properties in square brackets', async () => {
|
|
1614
1642
|
const expected = `export function App() {
|
|
1615
1643
|
const SYMBOL_PROP = Symbol();
|