Consistent indentations for conditional operators (#10187)
This commit is contained in:
1 parent
22a10c5589
commit
cc1f0543e6
10 files changed
+2828
-2
No files matched your search
@@ -0,0 +1,67 @@
|
||||
#### Consistent indentations for conditional operators (#10187 by @sosukesuzuki)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```ts
|
||||
// Input
|
||||
const dotNotationMemberExpression = (
|
||||
callNode.parent?.type === AST_NODE_TYPES.ChainExpression
|
||||
? callNode.parent.parent
|
||||
: callNode.parent
|
||||
).TSESTree.BinaryExpression;
|
||||
const computedMemberExpression = (
|
||||
callNode.parent?.type === AST_NODE_TYPES.ChainExpression
|
||||
? callNode.parent.parent
|
||||
: callNode.parent
|
||||
)[TSESTree.BinaryExpression];
|
||||
const callExpressionCallee = (
|
||||
callNode.parent?.type === AST_NODE_TYPES.ChainExpression
|
||||
? callNode.parent.parent
|
||||
: callNode.parent
|
||||
)(TSESTree.BinaryExpression);
|
||||
const typeScriptAsExpression = (
|
||||
callNode.parent?.type === AST_NODE_TYPES.ChainExpression
|
||||
? callNode.parent.parent
|
||||
: callNode.parent
|
||||
) as TSESTree.BinaryExpression;
|
||||
|
||||
// Prettier stable
|
||||
const dotNotationMemberExpression = (callNode.parent?.type ===
|
||||
AST_NODE_TYPES.ChainExpression
|
||||
? callNode.parent.parent
|
||||
: callNode.parent
|
||||
).TSESTree.BinaryExpression;
|
||||
const computedMemberExpression = (callNode.parent?.type ===
|
||||
AST_NODE_TYPES.ChainExpression
|
||||
? callNode.parent.parent
|
||||
: callNode.parent)[TSESTree.BinaryExpression];
|
||||
const callExpressionCallee = (callNode.parent?.type ===
|
||||
AST_NODE_TYPES.ChainExpression
|
||||
? callNode.parent.parent
|
||||
: callNode.parent)(TSESTree.BinaryExpression);
|
||||
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;
|
||||
const computedMemberExpression = (
|
||||
callNode.parent?.type === AST_NODE_TYPES.ChainExpression
|
||||
? callNode.parent.parent
|
||||
: callNode.parent
|
||||
)[TSESTree.BinaryExpression];
|
||||
const callExpressionCallee = (
|
||||
callNode.parent?.type === AST_NODE_TYPES.ChainExpression
|
||||
? callNode.parent.parent
|
||||
: callNode.parent
|
||||
)(TSESTree.BinaryExpression);
|
||||
const typeScriptAsExpression = (
|
||||
callNode.parent?.type === AST_NODE_TYPES.ChainExpression
|
||||
? callNode.parent.parent
|
||||
: callNode.parent
|
||||
) as TSESTree.BinaryExpression;
|
||||
```
|
||||
@@ -6,6 +6,8 @@ const {
|
||||
isJsxNode,
|
||||
isBlockComment,
|
||||
getComments,
|
||||
isChainElement,
|
||||
isCallExpression,
|
||||
isMemberExpression,
|
||||
} = require("../utils");
|
||||
const { locStart, locEnd } = require("../loc");
|
||||
@@ -158,6 +160,56 @@ function printTernaryTest(path, options, print) {
|
||||
return printed;
|
||||
}
|
||||
|
||||
const ancestorNameMap = new Map([
|
||||
["AssignmentExpression", "right"],
|
||||
["VariableDeclarator", "init"],
|
||||
["ReturnStatement", "argument"],
|
||||
["ThrowStatement", "argument"],
|
||||
["UnaryExpression", "argument"],
|
||||
["YieldExpression", "argument"],
|
||||
]);
|
||||
function shouldExtraIndentForConditionalExpression(path) {
|
||||
const node = path.getValue();
|
||||
if (node.type !== "ConditionalExpression") {
|
||||
return false;
|
||||
}
|
||||
|
||||
let ancestorCount = 1;
|
||||
let ancestor = path.getParentNode(ancestorCount);
|
||||
if (!ancestor) {
|
||||
return false;
|
||||
}
|
||||
while (isChainElement(ancestor)) {
|
||||
ancestor = path.getParentNode(++ancestorCount);
|
||||
}
|
||||
const checkAncestor = (node) => {
|
||||
const name = ancestorNameMap.get(ancestor.type);
|
||||
return ancestor[name] === node;
|
||||
};
|
||||
|
||||
const parent = path.getParentNode();
|
||||
const name = path.getName();
|
||||
|
||||
if (
|
||||
((name === "callee" && parent.type === "NewExpression") ||
|
||||
(name === "expression" && parent.type === "TSAsExpression")) &&
|
||||
checkAncestor(parent)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (
|
||||
((name === "callee" && isCallExpression(parent)) ||
|
||||
(name === "object" && isMemberExpression(parent)) ||
|
||||
(name === "expression" && parent.type === "TSNonNullExpression")) &&
|
||||
checkAncestor(path.getParentNode(ancestorCount - 1))
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* The following is the shared logic for
|
||||
* ternary operators, namely ConditionalExpression
|
||||
@@ -313,13 +365,19 @@ function printTernary(path, options, print) {
|
||||
(parent.type === "NGPipeExpression" && parent.left === node)) &&
|
||||
!parent.computed;
|
||||
|
||||
const shouldExtraIndent = shouldExtraIndentForConditionalExpression(path);
|
||||
|
||||
const result = maybeGroup([
|
||||
printTernaryTest(path, options, print),
|
||||
forceNoIndent ? parts : indent(parts),
|
||||
isConditionalExpression && breakClosingParen ? softline : "",
|
||||
isConditionalExpression && breakClosingParen && !shouldExtraIndent
|
||||
? softline
|
||||
: "",
|
||||
]);
|
||||
|
||||
return isParentTest ? group([indent([softline, result]), softline]) : result;
|
||||
return isParentTest || shouldExtraIndent
|
||||
? group([indent([softline, result]), softline])
|
||||
: result;
|
||||
}
|
||||
|
||||
module.exports = { printTernary };
|
||||
@@ -1327,6 +1327,16 @@ function getComments(node, flags, fn) {
|
||||
const isNextLineEmpty = (node, { originalText }) =>
|
||||
isNextLineEmptyAfterIndex(originalText, locEnd(node));
|
||||
|
||||
function isChainElement(node) {
|
||||
return (
|
||||
node.type === "MemberExpression" ||
|
||||
node.type === "OptionalMemberExpression" ||
|
||||
node.type === "CallExpression" ||
|
||||
node.type === "OptionalCallExpression" ||
|
||||
node.type === "TSNonNullExpression"
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getFunctionParameters,
|
||||
iterateFunctionParametersPath,
|
||||
@@ -1347,6 +1357,7 @@ module.exports = {
|
||||
identity,
|
||||
isBinaryish,
|
||||
isBlockComment,
|
||||
isChainElement,
|
||||
isLineComment,
|
||||
isPrettierIgnoreComment,
|
||||
isCallExpression,
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,234 @@
|
||||
foo7 = (coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz)[Fooooooooooo];
|
||||
|
||||
foo8 = (condition ? firstValue : secondValue)[SomeType];
|
||||
|
||||
const foo9 = (coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz)[Fooooooooooo];
|
||||
|
||||
function foo10() {
|
||||
return (coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz)[Fooooooooooo];
|
||||
}
|
||||
|
||||
function foo11() {
|
||||
throw (coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz)[Fooooooooooo];
|
||||
}
|
||||
|
||||
function foo12() {
|
||||
void (coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz)[Fooooooooooo];
|
||||
}
|
||||
|
||||
foo13 = (coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz
|
||||
).Fooooooooooo.Fooooooooooo;
|
||||
|
||||
foo14 = (condition ? firstValue : secondValue)[SomeType];
|
||||
|
||||
const foo15 = (coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz
|
||||
).Fooooooooooo.Fooooooooooo;
|
||||
|
||||
function foo16() {
|
||||
return (coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz
|
||||
).Fooooooooooo.Fooooooooooo;
|
||||
}
|
||||
|
||||
function foo17() {
|
||||
throw (coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz
|
||||
).Fooooooooooo.Fooooooooooo;
|
||||
}
|
||||
|
||||
function foo18() {
|
||||
void (coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz
|
||||
).Fooooooooooo.Fooooooooooo;
|
||||
}
|
||||
|
||||
foo19 = (coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz)(Fooooooooooo.Fooooooooooo);
|
||||
|
||||
foo20 = (condition ? firstValue : secondValue)[SomeType];
|
||||
|
||||
const foo21 = (coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz)(Fooooooooooo.Fooooooooooo);
|
||||
|
||||
function foo22() {
|
||||
return (coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz)(Fooooooooooo.Fooooooooooo);
|
||||
}
|
||||
|
||||
function foo23() {
|
||||
throw (coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz)(Fooooooooooo.Fooooooooooo);
|
||||
}
|
||||
|
||||
function foo24() {
|
||||
void (coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz)(Fooooooooooo.Fooooooooooo);
|
||||
}
|
||||
|
||||
foo25 = (coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz)?.(Fooooooooooo.Fooooooooooo);
|
||||
|
||||
foo26 = (condition ? firstValue : secondValue)[SomeType];
|
||||
|
||||
const foo27 = (coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz)?.(Fooooooooooo.Fooooooooooo);
|
||||
|
||||
function foo28() {
|
||||
return (coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz)?.(Fooooooooooo.Fooooooooooo);
|
||||
}
|
||||
|
||||
function foo29() {
|
||||
throw (coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz)?.(Fooooooooooo.Fooooooooooo);
|
||||
}
|
||||
|
||||
function foo30() {
|
||||
void (coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz)?.(Fooooooooooo.Fooooooooooo);
|
||||
}
|
||||
|
||||
function* foo31() {
|
||||
yield (coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz)?.(Fooooooooooo.Fooooooooooo);
|
||||
yield (coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz)(Fooooooooooo.Fooooooooooo);
|
||||
yield (coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz).Fooooooooooo.Fooooooooooo;
|
||||
yield (coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz)[Fooooooooooo.Fooooooooooo];
|
||||
}
|
||||
|
||||
const foo32 = new (coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz
|
||||
)(Fooooooooooo.Fooooooooooo);
|
||||
|
||||
function foo33() {
|
||||
return new (coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz
|
||||
)(Fooooooooooo.Fooooooooooo);
|
||||
}
|
||||
|
||||
function foo34() {
|
||||
throw new (coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz
|
||||
)(Fooooooooooo.Fooooooooooo);
|
||||
}
|
||||
|
||||
function foo35() {
|
||||
void new (coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz
|
||||
)(Fooooooooooo.Fooooooooooo);
|
||||
}
|
||||
|
||||
foo36 = new (coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz
|
||||
)(Fooooooooooo.Fooooooooooo);
|
||||
|
||||
bifornCringerMoshedPerplexSawder =
|
||||
askTrovenaBeenaDependsRowans +
|
||||
((glimseGlyphsHazardNoopsTieTie === 0
|
||||
? averredBathersBoxroomBuggyNurl
|
||||
: anodyneCondosMalateOverateRetinol)[AnnularCooeedSplicesWalksWayWay]);
|
||||
|
||||
bifornCringerMoshedPerplexSawder =
|
||||
askTrovenaBeenaDependsRowans +
|
||||
((glimseGlyphsHazardNoopsTieTie === 0 &&
|
||||
kochabCooieGameOnOboleUnweave === Math.PI
|
||||
? averredBathersBoxroomBuggyNurl
|
||||
: anodyneCondosMalateOverateRetinol)[AnnularCooeedSplicesWalksWayWay]);
|
||||
|
||||
bifornCringerMoshedPerplexSawder =
|
||||
askTrovenaBeenaDependsRowans +
|
||||
((glimseGlyphsHazardNoopsTieTie === 0
|
||||
? averredBathersBoxroomBuggyNurl
|
||||
: anodyneCondosMalateOverateRetinol).Fooooooooooo.Fooooooooooo);
|
||||
|
||||
bifornCringerMoshedPerplexSawder =
|
||||
askTrovenaBeenaDependsRowans +
|
||||
((glimseGlyphsHazardNoopsTieTie === 0 &&
|
||||
kochabCooieGameOnOboleUnweave === Math.PI
|
||||
? averredBathersBoxroomBuggyNurl
|
||||
: anodyneCondosMalateOverateRetinol).Fooooooooooo.Fooooooooooo);
|
||||
|
||||
bifornCringerMoshedPerplexSawder =
|
||||
askTrovenaBeenaDependsRowans +
|
||||
((glimseGlyphsHazardNoopsTieTie === 0
|
||||
? averredBathersBoxroomBuggyNurl
|
||||
: anodyneCondosMalateOverateRetinol)(Fooooooooooo.Fooooooooooo));
|
||||
|
||||
bifornCringerMoshedPerplexSawder =
|
||||
askTrovenaBeenaDependsRowans +
|
||||
((glimseGlyphsHazardNoopsTieTie === 0 &&
|
||||
kochabCooieGameOnOboleUnweave === Math.PI
|
||||
? averredBathersBoxroomBuggyNurl
|
||||
: anodyneCondosMalateOverateRetinol)(Fooooooooooo.Fooooooooooo));
|
||||
|
||||
bifornCringerMoshedPerplexSawder = (
|
||||
glimseGlyphsHazardNoopsTieTie === 0 &&
|
||||
kochabCooieGameOnOboleUnweave === Math.PI
|
||||
? averredBathersBoxroomBuggyNurl
|
||||
: anodyneCondosMalateOverateRetinol
|
||||
).annularCooeedSplicesWalksWayWay
|
||||
.annularCooeedSplicesWalksWayWay(annularCooeedSplicesWalksWayWay)
|
||||
.annularCooeedSplicesWalksWayWay();
|
||||
|
||||
foo = (coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz)?.()?.()?.();
|
||||
|
||||
foo = (coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz)()()();
|
||||
|
||||
foo =
|
||||
foo.bar.baz[
|
||||
coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz
|
||||
];
|
||||
|
||||
const decorated = (arg, ignoreRequestError) => {
|
||||
return (
|
||||
typeof arg === "string" ||
|
||||
(arg && arg.valueOf && typeof arg.valueOf() === "string")
|
||||
? $delegate(arg, ignoreRequestError)
|
||||
: handleAsyncOperations(arg, ignoreRequestError)
|
||||
).foo();
|
||||
};
|
||||
@@ -333,3 +333,105 @@ function foo() {
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`ternary.ts format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["typescript"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
foo = (coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz) as Fooooooooooo;
|
||||
|
||||
foo = (condition ? firstValue : secondValue) as SomeType;
|
||||
|
||||
const foo = (coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz) as Fooooooooooo;
|
||||
|
||||
function foo() {
|
||||
return (coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz) as Fooooooooooo;
|
||||
}
|
||||
|
||||
function foo() {
|
||||
throw (coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz) as Fooooooooooo;
|
||||
}
|
||||
|
||||
function foo() {
|
||||
void ((coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz) as Fooooooooooo);
|
||||
}
|
||||
|
||||
bifornCringerMoshedPerplexSawder =
|
||||
askTrovenaBeenaDependsRowans +
|
||||
((glimseGlyphsHazardNoopsTieTie === 0
|
||||
? averredBathersBoxroomBuggyNurl
|
||||
: anodyneCondosMalateOverateRetinol) as AnnularCooeedSplicesWalksWayWay);
|
||||
|
||||
bifornCringerMoshedPerplexSawder =
|
||||
askTrovenaBeenaDependsRowans +
|
||||
((glimseGlyphsHazardNoopsTieTie === 0 &&
|
||||
kochabCooieGameOnOboleUnweave === Math.PI
|
||||
? averredBathersBoxroomBuggyNurl
|
||||
: anodyneCondosMalateOverateRetinol) as AnnularCooeedSplicesWalksWayWay);
|
||||
|
||||
=====================================output=====================================
|
||||
foo = (
|
||||
coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz
|
||||
) as Fooooooooooo;
|
||||
|
||||
foo = (condition ? firstValue : secondValue) as SomeType;
|
||||
|
||||
const foo = (
|
||||
coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz
|
||||
) as Fooooooooooo;
|
||||
|
||||
function foo() {
|
||||
return (
|
||||
coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz
|
||||
) as Fooooooooooo;
|
||||
}
|
||||
|
||||
function foo() {
|
||||
throw (
|
||||
coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz
|
||||
) as Fooooooooooo;
|
||||
}
|
||||
|
||||
function foo() {
|
||||
void ((
|
||||
coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz
|
||||
) as Fooooooooooo);
|
||||
}
|
||||
|
||||
bifornCringerMoshedPerplexSawder =
|
||||
askTrovenaBeenaDependsRowans +
|
||||
((glimseGlyphsHazardNoopsTieTie === 0
|
||||
? averredBathersBoxroomBuggyNurl
|
||||
: anodyneCondosMalateOverateRetinol) as AnnularCooeedSplicesWalksWayWay);
|
||||
|
||||
bifornCringerMoshedPerplexSawder =
|
||||
askTrovenaBeenaDependsRowans +
|
||||
((glimseGlyphsHazardNoopsTieTie === 0 &&
|
||||
kochabCooieGameOnOboleUnweave === Math.PI
|
||||
? averredBathersBoxroomBuggyNurl
|
||||
: anodyneCondosMalateOverateRetinol) as AnnularCooeedSplicesWalksWayWay);
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
@@ -0,0 +1,40 @@
|
||||
foo = (coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz) as Fooooooooooo;
|
||||
|
||||
foo = (condition ? firstValue : secondValue) as SomeType;
|
||||
|
||||
const foo = (coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz) as Fooooooooooo;
|
||||
|
||||
function foo() {
|
||||
return (coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz) as Fooooooooooo;
|
||||
}
|
||||
|
||||
function foo() {
|
||||
throw (coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz) as Fooooooooooo;
|
||||
}
|
||||
|
||||
function foo() {
|
||||
void ((coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz) as Fooooooooooo);
|
||||
}
|
||||
|
||||
bifornCringerMoshedPerplexSawder =
|
||||
askTrovenaBeenaDependsRowans +
|
||||
((glimseGlyphsHazardNoopsTieTie === 0
|
||||
? averredBathersBoxroomBuggyNurl
|
||||
: anodyneCondosMalateOverateRetinol) as AnnularCooeedSplicesWalksWayWay);
|
||||
|
||||
bifornCringerMoshedPerplexSawder =
|
||||
askTrovenaBeenaDependsRowans +
|
||||
((glimseGlyphsHazardNoopsTieTie === 0 &&
|
||||
kochabCooieGameOnOboleUnweave === Math.PI
|
||||
? averredBathersBoxroomBuggyNurl
|
||||
: anodyneCondosMalateOverateRetinol) as AnnularCooeedSplicesWalksWayWay);
|
||||
@@ -0,0 +1,123 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`indent.ts format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["typescript"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
foo = (callNode.parent?.type === AST_NODE_TYPES.ChainExpression
|
||||
? callNode.parent.parent
|
||||
: callNode.parent
|
||||
).TSESTree!.BinaryExpression;
|
||||
|
||||
foo = (callNode.parent?.type === AST_NODE_TYPES.ChainExpression
|
||||
? callNode.parent.parent
|
||||
: callNode.parent
|
||||
).TSESTree!.BinaryExpression;
|
||||
|
||||
bifornCringerMoshedPerplexSawder = (glimseGlyphsHazardNoopsTieTie === 0 &&
|
||||
kochabCooieGameOnOboleUnweave === Math.PI
|
||||
? averredBathersBoxroomBuggyNurl
|
||||
: anodyneCondosMalateOverateRetinol
|
||||
).annularCooeedSplicesWalksWayWay
|
||||
.annularCooeedSplicesWalksWayWay(annularCooeedSplicesWalksWayWay)!
|
||||
.annularCooeedSplicesWalksWayWay();
|
||||
|
||||
foo = (callNode.parent?.type === AST_NODE_TYPES.ChainExpression
|
||||
? callNode.parent.parent
|
||||
: callNode.parent
|
||||
).TSESTree!.BinaryExpression!;
|
||||
|
||||
foo = (callNode.parent?.type === AST_NODE_TYPES.ChainExpression
|
||||
? callNode.parent.parent
|
||||
: callNode.parent
|
||||
).TSESTree!.BinaryExpression!;
|
||||
|
||||
bifornCringerMoshedPerplexSawder = (glimseGlyphsHazardNoopsTieTie === 0 &&
|
||||
kochabCooieGameOnOboleUnweave === Math.PI
|
||||
? averredBathersBoxroomBuggyNurl
|
||||
: anodyneCondosMalateOverateRetinol
|
||||
).annularCooeedSplicesWalksWayWay
|
||||
.annularCooeedSplicesWalksWayWay(annularCooeedSplicesWalksWayWay)!
|
||||
.annularCooeedSplicesWalksWayWay()!;
|
||||
|
||||
bifornCringerMoshedPerplexSawder =
|
||||
askTrovenaBeenaDependsRowans +
|
||||
(glimseGlyphsHazardNoopsTieTie === 0
|
||||
? averredBathersBoxroomBuggyNurl
|
||||
: anodyneCondosMalateOverateRetinol
|
||||
).Foo!.foo;
|
||||
|
||||
foo = (coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz)!;
|
||||
|
||||
foo = (coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz)!!!!!;
|
||||
|
||||
=====================================output=====================================
|
||||
foo = (
|
||||
callNode.parent?.type === AST_NODE_TYPES.ChainExpression
|
||||
? callNode.parent.parent
|
||||
: callNode.parent
|
||||
).TSESTree!.BinaryExpression;
|
||||
|
||||
foo = (
|
||||
callNode.parent?.type === AST_NODE_TYPES.ChainExpression
|
||||
? callNode.parent.parent
|
||||
: callNode.parent
|
||||
).TSESTree!.BinaryExpression;
|
||||
|
||||
bifornCringerMoshedPerplexSawder = (
|
||||
glimseGlyphsHazardNoopsTieTie === 0 &&
|
||||
kochabCooieGameOnOboleUnweave === Math.PI
|
||||
? averredBathersBoxroomBuggyNurl
|
||||
: anodyneCondosMalateOverateRetinol
|
||||
).annularCooeedSplicesWalksWayWay
|
||||
.annularCooeedSplicesWalksWayWay(annularCooeedSplicesWalksWayWay)!
|
||||
.annularCooeedSplicesWalksWayWay();
|
||||
|
||||
foo = (
|
||||
callNode.parent?.type === AST_NODE_TYPES.ChainExpression
|
||||
? callNode.parent.parent
|
||||
: callNode.parent
|
||||
).TSESTree!.BinaryExpression!;
|
||||
|
||||
foo = (
|
||||
callNode.parent?.type === AST_NODE_TYPES.ChainExpression
|
||||
? callNode.parent.parent
|
||||
: callNode.parent
|
||||
).TSESTree!.BinaryExpression!;
|
||||
|
||||
bifornCringerMoshedPerplexSawder = (
|
||||
glimseGlyphsHazardNoopsTieTie === 0 &&
|
||||
kochabCooieGameOnOboleUnweave === Math.PI
|
||||
? averredBathersBoxroomBuggyNurl
|
||||
: anodyneCondosMalateOverateRetinol
|
||||
).annularCooeedSplicesWalksWayWay
|
||||
.annularCooeedSplicesWalksWayWay(annularCooeedSplicesWalksWayWay)!
|
||||
.annularCooeedSplicesWalksWayWay()!;
|
||||
|
||||
bifornCringerMoshedPerplexSawder =
|
||||
askTrovenaBeenaDependsRowans +
|
||||
(glimseGlyphsHazardNoopsTieTie === 0
|
||||
? averredBathersBoxroomBuggyNurl
|
||||
: anodyneCondosMalateOverateRetinol
|
||||
).Foo!.foo;
|
||||
|
||||
foo = (
|
||||
coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz
|
||||
)!;
|
||||
|
||||
foo = (
|
||||
coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz
|
||||
)!!!!!;
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
@@ -0,0 +1,50 @@
|
||||
foo = (callNode.parent?.type === AST_NODE_TYPES.ChainExpression
|
||||
? callNode.parent.parent
|
||||
: callNode.parent
|
||||
).TSESTree!.BinaryExpression;
|
||||
|
||||
foo = (callNode.parent?.type === AST_NODE_TYPES.ChainExpression
|
||||
? callNode.parent.parent
|
||||
: callNode.parent
|
||||
).TSESTree!.BinaryExpression;
|
||||
|
||||
bifornCringerMoshedPerplexSawder = (glimseGlyphsHazardNoopsTieTie === 0 &&
|
||||
kochabCooieGameOnOboleUnweave === Math.PI
|
||||
? averredBathersBoxroomBuggyNurl
|
||||
: anodyneCondosMalateOverateRetinol
|
||||
).annularCooeedSplicesWalksWayWay
|
||||
.annularCooeedSplicesWalksWayWay(annularCooeedSplicesWalksWayWay)!
|
||||
.annularCooeedSplicesWalksWayWay();
|
||||
|
||||
foo = (callNode.parent?.type === AST_NODE_TYPES.ChainExpression
|
||||
? callNode.parent.parent
|
||||
: callNode.parent
|
||||
).TSESTree!.BinaryExpression!;
|
||||
|
||||
foo = (callNode.parent?.type === AST_NODE_TYPES.ChainExpression
|
||||
? callNode.parent.parent
|
||||
: callNode.parent
|
||||
).TSESTree!.BinaryExpression!;
|
||||
|
||||
bifornCringerMoshedPerplexSawder = (glimseGlyphsHazardNoopsTieTie === 0 &&
|
||||
kochabCooieGameOnOboleUnweave === Math.PI
|
||||
? averredBathersBoxroomBuggyNurl
|
||||
: anodyneCondosMalateOverateRetinol
|
||||
).annularCooeedSplicesWalksWayWay
|
||||
.annularCooeedSplicesWalksWayWay(annularCooeedSplicesWalksWayWay)!
|
||||
.annularCooeedSplicesWalksWayWay()!;
|
||||
|
||||
bifornCringerMoshedPerplexSawder =
|
||||
askTrovenaBeenaDependsRowans +
|
||||
(glimseGlyphsHazardNoopsTieTie === 0
|
||||
? averredBathersBoxroomBuggyNurl
|
||||
: anodyneCondosMalateOverateRetinol
|
||||
).Foo!.foo;
|
||||
|
||||
foo = (coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz)!;
|
||||
|
||||
foo = (coooooooooooooooooooooooooooooooooooooooooooooooooooond
|
||||
? baaaaaaaaaaaaaaaaaaaaar
|
||||
: baaaaaaaaaaaaaaaaaaaaaz)!!!!!;
|
||||
@@ -0,0 +1 @@
|
||||
run_spec(__dirname, ["typescript"]);
|
||||
Reference in new issue
Block a user