2021-02-12 08:11:24 +09:00
|
|
|
#### Consistent indentations for conditional operators (#10187, #10266 by @sosukesuzuki)
|
2021-02-07 23:53:05 +09:00
|
|
|
|
|
|
|
|
<!-- prettier-ignore -->
|
|
|
|
|
```ts
|
|
|
|
|
// Prettier stable
|
|
|
|
|
const dotNotationMemberExpression = (callNode.parent?.type ===
|
|
|
|
|
AST_NODE_TYPES.ChainExpression
|
|
|
|
|
? callNode.parent.parent
|
|
|
|
|
: callNode.parent
|
|
|
|
|
).TSESTree.BinaryExpression;
|
2021-04-12 12:42:45 +03:00
|
|
|
|
2021-02-07 23:53:05 +09:00
|
|
|
const computedMemberExpression = (callNode.parent?.type ===
|
|
|
|
|
AST_NODE_TYPES.ChainExpression
|
|
|
|
|
? callNode.parent.parent
|
|
|
|
|
: callNode.parent)[TSESTree.BinaryExpression];
|
2021-04-12 12:42:45 +03:00
|
|
|
|
2021-02-07 23:53:05 +09:00
|
|
|
const callExpressionCallee = (callNode.parent?.type ===
|
|
|
|
|
AST_NODE_TYPES.ChainExpression
|
|
|
|
|
? callNode.parent.parent
|
|
|
|
|
: callNode.parent)(TSESTree.BinaryExpression);
|
2021-04-12 12:42:45 +03:00
|
|
|
|
2021-02-07 23:53:05 +09:00
|
|
|
const typeScriptAsExpression = (callNode.parent?.type ===
|
|
|
|
|
AST_NODE_TYPES.ChainExpression
|
|
|
|
|
? callNode.parent.parent
|
|
|
|
|
: callNode.parent) as TSESTree.BinaryExpression;
|
|
|
|
|
|
|
|
|
|
// Prettier main
|
|
|
|
|
const dotNotationMemberExpression = (
|
|
|
|
|
callNode.parent?.type === AST_NODE_TYPES.ChainExpression
|
|
|
|
|
? callNode.parent.parent
|
|
|
|
|
: callNode.parent
|
|
|
|
|
).TSESTree.BinaryExpression;
|
2021-04-12 12:42:45 +03:00
|
|
|
|
2021-02-07 23:53:05 +09:00
|
|
|
const computedMemberExpression = (
|
|
|
|
|
callNode.parent?.type === AST_NODE_TYPES.ChainExpression
|
|
|
|
|
? callNode.parent.parent
|
|
|
|
|
: callNode.parent
|
|
|
|
|
)[TSESTree.BinaryExpression];
|
2021-04-12 12:42:45 +03:00
|
|
|
|
2021-02-07 23:53:05 +09:00
|
|
|
const callExpressionCallee = (
|
|
|
|
|
callNode.parent?.type === AST_NODE_TYPES.ChainExpression
|
|
|
|
|
? callNode.parent.parent
|
|
|
|
|
: callNode.parent
|
|
|
|
|
)(TSESTree.BinaryExpression);
|
2021-04-12 12:42:45 +03:00
|
|
|
|
2021-02-07 23:53:05 +09:00
|
|
|
const typeScriptAsExpression = (
|
|
|
|
|
callNode.parent?.type === AST_NODE_TYPES.ChainExpression
|
|
|
|
|
? callNode.parent.parent
|
|
|
|
|
: callNode.parent
|
|
|
|
|
) as TSESTree.BinaryExpression;
|
|
|
|
|
```
|