prettier 2.7.1 → 2.8.0
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/LICENSE +10 -66
- package/cli.js +75 -24
- package/doc.js +178 -97
- package/esm/parser-angular.mjs +2 -2
- package/esm/parser-babel.mjs +23 -21
- package/esm/parser-espree.mjs +18 -18
- package/esm/parser-flow.mjs +24 -24
- package/esm/parser-glimmer.mjs +15 -15
- package/esm/parser-html.mjs +20 -20
- package/esm/parser-markdown.mjs +47 -47
- package/esm/parser-meriyah.mjs +11 -11
- package/esm/parser-postcss.mjs +36 -36
- package/esm/parser-typescript.mjs +47 -70
- package/esm/parser-yaml.mjs +133 -133
- package/esm/standalone.mjs +76 -76
- package/index.js +658 -55
- package/package.json +1 -1
- package/parser-angular.js +2 -2
- package/parser-babel.js +23 -21
- package/parser-espree.js +18 -18
- package/parser-flow.js +24 -24
- package/parser-glimmer.js +18 -18
- package/parser-html.js +20 -20
- package/parser-markdown.js +49 -49
- package/parser-meriyah.js +11 -11
- package/parser-postcss.js +57 -57
- package/parser-typescript.js +47 -70
- package/parser-yaml.js +130 -130
- package/standalone.js +78 -78
package/index.js
CHANGED
|
@@ -6378,17 +6378,14 @@ var require_loc = __commonJS2({
|
|
|
6378
6378
|
"src/language-js/loc.js"(exports2, module2) {
|
|
6379
6379
|
"use strict";
|
|
6380
6380
|
var isNonEmptyArray = require_is_non_empty_array();
|
|
6381
|
-
function locStart(node
|
|
6382
|
-
|
|
6383
|
-
|
|
6384
|
-
|
|
6385
|
-
if (
|
|
6386
|
-
|
|
6387
|
-
if (isNonEmptyArray(decorators)) {
|
|
6388
|
-
return locStart(decorators[0]);
|
|
6389
|
-
}
|
|
6381
|
+
function locStart(node) {
|
|
6382
|
+
var _node$declaration$dec, _node$declaration;
|
|
6383
|
+
const start = node.range ? node.range[0] : node.start;
|
|
6384
|
+
const decorators = (_node$declaration$dec = (_node$declaration = node.declaration) === null || _node$declaration === void 0 ? void 0 : _node$declaration.decorators) !== null && _node$declaration$dec !== void 0 ? _node$declaration$dec : node.decorators;
|
|
6385
|
+
if (isNonEmptyArray(decorators)) {
|
|
6386
|
+
return Math.min(locStart(decorators[0]), start);
|
|
6390
6387
|
}
|
|
6391
|
-
return
|
|
6388
|
+
return start;
|
|
6392
6389
|
}
|
|
6393
6390
|
function locEnd(node) {
|
|
6394
6391
|
return node.range ? node.range[1] : node.end;
|
|
@@ -7347,7 +7344,7 @@ var require_parser = __commonJS2({
|
|
|
7347
7344
|
error.message += "\n" + error.codeFrame;
|
|
7348
7345
|
throw error;
|
|
7349
7346
|
}
|
|
7350
|
-
throw error
|
|
7347
|
+
throw error;
|
|
7351
7348
|
}
|
|
7352
7349
|
}
|
|
7353
7350
|
module2.exports = {
|
|
@@ -8480,6 +8477,9 @@ var require_range_util = __commonJS2({
|
|
|
8480
8477
|
} else {
|
|
8481
8478
|
break;
|
|
8482
8479
|
}
|
|
8480
|
+
if (resultStartNode === resultEndNode) {
|
|
8481
|
+
break;
|
|
8482
|
+
}
|
|
8483
8483
|
}
|
|
8484
8484
|
return {
|
|
8485
8485
|
startNode: resultStartNode,
|
|
@@ -21722,7 +21722,7 @@ var require_utils7 = __commonJS2({
|
|
|
21722
21722
|
return typeof result === "boolean" ? result : Object.values(node).some((value) => hasNode(value, fn));
|
|
21723
21723
|
}
|
|
21724
21724
|
function hasNakedLeftSide(node) {
|
|
21725
|
-
return node.type === "AssignmentExpression" || node.type === "BinaryExpression" || node.type === "LogicalExpression" || node.type === "NGPipeExpression" || node.type === "ConditionalExpression" || isCallExpression(node) || isMemberExpression(node) || node.type === "SequenceExpression" || node.type === "TaggedTemplateExpression" || node.type === "BindExpression" || node.type === "UpdateExpression" && !node.prefix || node
|
|
21725
|
+
return node.type === "AssignmentExpression" || node.type === "BinaryExpression" || node.type === "LogicalExpression" || node.type === "NGPipeExpression" || node.type === "ConditionalExpression" || isCallExpression(node) || isMemberExpression(node) || node.type === "SequenceExpression" || node.type === "TaggedTemplateExpression" || node.type === "BindExpression" || node.type === "UpdateExpression" && !node.prefix || isTSTypeExpression(node) || node.type === "TSNonNullExpression";
|
|
21726
21726
|
}
|
|
21727
21727
|
function getLeftSide(node) {
|
|
21728
21728
|
var _ref2, _ref3, _ref4, _ref5, _ref6, _node$left;
|
|
@@ -21991,7 +21991,20 @@ var require_utils7 = __commonJS2({
|
|
|
21991
21991
|
if (isMemberExpression(node)) {
|
|
21992
21992
|
return isSimpleCallArgument(node.object, depth) && isSimpleCallArgument(node.property, depth);
|
|
21993
21993
|
}
|
|
21994
|
-
|
|
21994
|
+
const targetUnaryExpressionOperators = {
|
|
21995
|
+
"!": true,
|
|
21996
|
+
"-": true,
|
|
21997
|
+
"+": true,
|
|
21998
|
+
"~": true
|
|
21999
|
+
};
|
|
22000
|
+
if (node.type === "UnaryExpression" && targetUnaryExpressionOperators[node.operator]) {
|
|
22001
|
+
return isSimpleCallArgument(node.argument, depth);
|
|
22002
|
+
}
|
|
22003
|
+
const targetUpdateExpressionOperators = {
|
|
22004
|
+
"++": true,
|
|
22005
|
+
"--": true
|
|
22006
|
+
};
|
|
22007
|
+
if (node.type === "UpdateExpression" && targetUpdateExpressionOperators[node.operator]) {
|
|
21995
22008
|
return isSimpleCallArgument(node.argument, depth);
|
|
21996
22009
|
}
|
|
21997
22010
|
if (node.type === "TSNonNullExpression") {
|
|
@@ -22043,6 +22056,7 @@ var require_utils7 = __commonJS2({
|
|
|
22043
22056
|
return node.object && startsWithNoLookaheadToken(node.object, forbidFunctionClassAndDoExpr);
|
|
22044
22057
|
case "SequenceExpression":
|
|
22045
22058
|
return startsWithNoLookaheadToken(node.expressions[0], forbidFunctionClassAndDoExpr);
|
|
22059
|
+
case "TSSatisfiesExpression":
|
|
22046
22060
|
case "TSAsExpression":
|
|
22047
22061
|
case "TSNonNullExpression":
|
|
22048
22062
|
return startsWithNoLookaheadToken(node.expression, forbidFunctionClassAndDoExpr);
|
|
@@ -22226,6 +22240,9 @@ var require_utils7 = __commonJS2({
|
|
|
22226
22240
|
return Boolean(options.__isUsingHackPipeline);
|
|
22227
22241
|
}
|
|
22228
22242
|
var markerForIfWithoutBlockAndSameLineComment = Symbol("ifWithoutBlockAndSameLineComment");
|
|
22243
|
+
function isTSTypeExpression(node) {
|
|
22244
|
+
return node.type === "TSAsExpression" || node.type === "TSSatisfiesExpression";
|
|
22245
|
+
}
|
|
22229
22246
|
module2.exports = {
|
|
22230
22247
|
getFunctionParameters,
|
|
22231
22248
|
iterateFunctionParametersPath,
|
|
@@ -22289,7 +22306,8 @@ var require_utils7 = __commonJS2({
|
|
|
22289
22306
|
hasComment,
|
|
22290
22307
|
getComments,
|
|
22291
22308
|
CommentCheckFlags,
|
|
22292
|
-
markerForIfWithoutBlockAndSameLineComment
|
|
22309
|
+
markerForIfWithoutBlockAndSameLineComment,
|
|
22310
|
+
isTSTypeExpression
|
|
22293
22311
|
};
|
|
22294
22312
|
}
|
|
22295
22313
|
});
|
|
@@ -22324,7 +22342,8 @@ var require_template_literal = __commonJS2({
|
|
|
22324
22342
|
isJestEachTemplateLiteral,
|
|
22325
22343
|
isSimpleTemplateLiteral,
|
|
22326
22344
|
hasComment,
|
|
22327
|
-
isMemberExpression
|
|
22345
|
+
isMemberExpression,
|
|
22346
|
+
isTSTypeExpression
|
|
22328
22347
|
} = require_utils7();
|
|
22329
22348
|
function printTemplateLiteral(path, print, options) {
|
|
22330
22349
|
const node = path.getValue();
|
|
@@ -22360,7 +22379,7 @@ var require_template_literal = __commonJS2({
|
|
|
22360
22379
|
let printed = expressions[i];
|
|
22361
22380
|
if (!isSimple) {
|
|
22362
22381
|
const expression = node[expressionsKey][i];
|
|
22363
|
-
if (hasComment(expression) || isMemberExpression(expression) || expression.type === "ConditionalExpression" || expression.type === "SequenceExpression" || expression
|
|
22382
|
+
if (hasComment(expression) || isMemberExpression(expression) || expression.type === "ConditionalExpression" || expression.type === "SequenceExpression" || isTSTypeExpression(expression) || isBinaryish(expression)) {
|
|
22364
22383
|
printed = [indent([softline, printed]), softline];
|
|
22365
22384
|
}
|
|
22366
22385
|
}
|
|
@@ -22983,7 +23002,7 @@ var require_build = __commonJS2({
|
|
|
22983
23002
|
};
|
|
22984
23003
|
}
|
|
22985
23004
|
var commentEndRe = /\*\/$/;
|
|
22986
|
-
var commentStartRe =
|
|
23005
|
+
var commentStartRe = /^\/\*\*?/;
|
|
22987
23006
|
var docblockRe = /^\s*(\/\*\*?(.|\r?\n)*?\*\/)/;
|
|
22988
23007
|
var lineCommentRe = /(^|\s+)\/\/([^\r\n]*)/g;
|
|
22989
23008
|
var ltrimNewlineRe = /^(\r?\n)+/;
|
|
@@ -23036,7 +23055,7 @@ var require_build = __commonJS2({
|
|
|
23036
23055
|
const start = " *";
|
|
23037
23056
|
const tail = " */";
|
|
23038
23057
|
const keys = Object.keys(pragmas);
|
|
23039
|
-
const printedObject = keys.map((key) => printKeyValues(key, pragmas[key])).reduce((arr, next) => arr.concat(next), []).map((keyValue) => start
|
|
23058
|
+
const printedObject = keys.map((key) => printKeyValues(key, pragmas[key])).reduce((arr, next) => arr.concat(next), []).map((keyValue) => `${start} ${keyValue}${line}`).join("");
|
|
23040
23059
|
if (!comments) {
|
|
23041
23060
|
if (keys.length === 0) {
|
|
23042
23061
|
return "";
|
|
@@ -23708,7 +23727,8 @@ var require_needs_parens = __commonJS2({
|
|
|
23708
23727
|
getPrecedence,
|
|
23709
23728
|
isCallExpression,
|
|
23710
23729
|
isMemberExpression,
|
|
23711
|
-
isObjectProperty
|
|
23730
|
+
isObjectProperty,
|
|
23731
|
+
isTSTypeExpression
|
|
23712
23732
|
} = require_utils7();
|
|
23713
23733
|
function needsParens(path, options) {
|
|
23714
23734
|
const parent = path.getParentNode();
|
|
@@ -23834,12 +23854,14 @@ var require_needs_parens = __commonJS2({
|
|
|
23834
23854
|
}
|
|
23835
23855
|
case "TSTypeAssertion":
|
|
23836
23856
|
case "TSAsExpression":
|
|
23857
|
+
case "TSSatisfiesExpression":
|
|
23837
23858
|
case "LogicalExpression":
|
|
23838
23859
|
switch (parent.type) {
|
|
23860
|
+
case "TSSatisfiesExpression":
|
|
23839
23861
|
case "TSAsExpression":
|
|
23840
|
-
return node
|
|
23862
|
+
return !isTSTypeExpression(node);
|
|
23841
23863
|
case "ConditionalExpression":
|
|
23842
|
-
return node
|
|
23864
|
+
return isTSTypeExpression(node);
|
|
23843
23865
|
case "CallExpression":
|
|
23844
23866
|
case "NewExpression":
|
|
23845
23867
|
case "OptionalCallExpression":
|
|
@@ -23863,7 +23885,7 @@ var require_needs_parens = __commonJS2({
|
|
|
23863
23885
|
return name === "object";
|
|
23864
23886
|
case "AssignmentExpression":
|
|
23865
23887
|
case "AssignmentPattern":
|
|
23866
|
-
return name === "left" && (node.type === "TSTypeAssertion" || node
|
|
23888
|
+
return name === "left" && (node.type === "TSTypeAssertion" || isTSTypeExpression(node));
|
|
23867
23889
|
case "LogicalExpression":
|
|
23868
23890
|
if (node.type === "LogicalExpression") {
|
|
23869
23891
|
return parent.operator !== node.operator;
|
|
@@ -23913,7 +23935,7 @@ var require_needs_parens = __commonJS2({
|
|
|
23913
23935
|
return true;
|
|
23914
23936
|
}
|
|
23915
23937
|
case "YieldExpression":
|
|
23916
|
-
if (parent.type === "UnaryExpression" || parent.type === "AwaitExpression" || parent
|
|
23938
|
+
if (parent.type === "UnaryExpression" || parent.type === "AwaitExpression" || isTSTypeExpression(parent) || parent.type === "TSNonNullExpression") {
|
|
23917
23939
|
return true;
|
|
23918
23940
|
}
|
|
23919
23941
|
case "AwaitExpression":
|
|
@@ -23924,6 +23946,7 @@ var require_needs_parens = __commonJS2({
|
|
|
23924
23946
|
case "SpreadElement":
|
|
23925
23947
|
case "SpreadProperty":
|
|
23926
23948
|
case "TSAsExpression":
|
|
23949
|
+
case "TSSatisfiesExpression":
|
|
23927
23950
|
case "TSNonNullExpression":
|
|
23928
23951
|
case "BindExpression":
|
|
23929
23952
|
return true;
|
|
@@ -23951,6 +23974,12 @@ var require_needs_parens = __commonJS2({
|
|
|
23951
23974
|
}
|
|
23952
23975
|
case "TSFunctionType":
|
|
23953
23976
|
case "TSConstructorType":
|
|
23977
|
+
if (name === "extendsType" && parent.type === "TSConditionalType") {
|
|
23978
|
+
const returnTypeAnnotation = (node.returnType || node.typeAnnotation).typeAnnotation;
|
|
23979
|
+
if (returnTypeAnnotation.type === "TSInferType" && returnTypeAnnotation.typeParameter.constraint) {
|
|
23980
|
+
return true;
|
|
23981
|
+
}
|
|
23982
|
+
}
|
|
23954
23983
|
if (name === "checkType" && parent.type === "TSConditionalType") {
|
|
23955
23984
|
return true;
|
|
23956
23985
|
}
|
|
@@ -24034,6 +24063,7 @@ var require_needs_parens = __commonJS2({
|
|
|
24034
24063
|
case "TSTypeAssertion":
|
|
24035
24064
|
case "TypeCastExpression":
|
|
24036
24065
|
case "TSAsExpression":
|
|
24066
|
+
case "TSSatisfiesExpression":
|
|
24037
24067
|
case "TSNonNullExpression":
|
|
24038
24068
|
return true;
|
|
24039
24069
|
case "NewExpression":
|
|
@@ -24071,6 +24101,7 @@ var require_needs_parens = __commonJS2({
|
|
|
24071
24101
|
case "OptionalMemberExpression":
|
|
24072
24102
|
return name === "object";
|
|
24073
24103
|
case "TSAsExpression":
|
|
24104
|
+
case "TSSatisfiesExpression":
|
|
24074
24105
|
case "TSNonNullExpression":
|
|
24075
24106
|
case "BindExpression":
|
|
24076
24107
|
case "TaggedTemplateExpression":
|
|
@@ -24318,7 +24349,6 @@ var require_binaryish = __commonJS2({
|
|
|
24318
24349
|
group,
|
|
24319
24350
|
indent,
|
|
24320
24351
|
align,
|
|
24321
|
-
ifBreak,
|
|
24322
24352
|
indentIfBreak
|
|
24323
24353
|
},
|
|
24324
24354
|
utils: {
|
|
@@ -24395,7 +24425,7 @@ var require_binaryish = __commonJS2({
|
|
|
24395
24425
|
const shouldInline = shouldInlineLogicalExpression(node);
|
|
24396
24426
|
const lineBeforeOperator = (node.operator === "|>" || node.type === "NGPipeExpression" || node.operator === "|" && options.parser === "__vue_expression") && !hasLeadingOwnLineComment(options.originalText, node.right);
|
|
24397
24427
|
const operator = node.type === "NGPipeExpression" ? "|" : node.operator;
|
|
24398
|
-
const rightSuffix = node.type === "NGPipeExpression" && node.arguments.length > 0 ? group(indent([
|
|
24428
|
+
const rightSuffix = node.type === "NGPipeExpression" && node.arguments.length > 0 ? group(indent([line, ": ", join([line, ": "], path.map(print, "arguments").map((arg) => align(2, group(arg))))])) : "";
|
|
24399
24429
|
let right;
|
|
24400
24430
|
if (shouldInline) {
|
|
24401
24431
|
right = [operator, " ", print("right"), rightSuffix];
|
|
@@ -24794,14 +24824,26 @@ var require_jsx = __commonJS2({
|
|
|
24794
24824
|
if (node.attributes && node.attributes.length === 1 && node.attributes[0].value && isStringLiteral(node.attributes[0].value) && !node.attributes[0].value.value.includes("\n") && !nameHasComments && !hasComment(node.attributes[0])) {
|
|
24795
24825
|
return group(["<", print("name"), print("typeParameters"), " ", ...path.map(print, "attributes"), node.selfClosing ? " />" : ">"]);
|
|
24796
24826
|
}
|
|
24797
|
-
const lastAttrHasTrailingComments = node.attributes.length > 0 && hasComment(getLast(node.attributes), CommentCheckFlags.Trailing);
|
|
24798
|
-
const bracketSameLine = node.attributes.length === 0 && !nameHasComments || (options.bracketSameLine || options.jsxBracketSameLine) && (!nameHasComments || node.attributes.length > 0) && !lastAttrHasTrailingComments;
|
|
24799
24827
|
const shouldBreak = node.attributes && node.attributes.some((attr) => attr.value && isStringLiteral(attr.value) && attr.value.value.includes("\n"));
|
|
24800
24828
|
const attributeLine = options.singleAttributePerLine && node.attributes.length > 1 ? hardline : line;
|
|
24801
|
-
return group(["<", print("name"), print("typeParameters"), indent(path.map(() => [attributeLine, print()], "attributes")), node
|
|
24829
|
+
return group(["<", print("name"), print("typeParameters"), indent(path.map(() => [attributeLine, print()], "attributes")), ...printEndOfOpeningTag(node, options, nameHasComments)], {
|
|
24802
24830
|
shouldBreak
|
|
24803
24831
|
});
|
|
24804
24832
|
}
|
|
24833
|
+
function printEndOfOpeningTag(node, options, nameHasComments) {
|
|
24834
|
+
if (node.selfClosing) {
|
|
24835
|
+
return [line, "/>"];
|
|
24836
|
+
}
|
|
24837
|
+
const bracketSameLine = shouldPrintBracketSameLine(node, options, nameHasComments);
|
|
24838
|
+
if (bracketSameLine) {
|
|
24839
|
+
return [">"];
|
|
24840
|
+
}
|
|
24841
|
+
return [softline, ">"];
|
|
24842
|
+
}
|
|
24843
|
+
function shouldPrintBracketSameLine(node, options, nameHasComments) {
|
|
24844
|
+
const lastAttrHasTrailingComments = node.attributes.length > 0 && hasComment(getLast(node.attributes), CommentCheckFlags.Trailing);
|
|
24845
|
+
return node.attributes.length === 0 && !nameHasComments || (options.bracketSameLine || options.jsxBracketSameLine) && (!nameHasComments || node.attributes.length > 0) && !lastAttrHasTrailingComments;
|
|
24846
|
+
}
|
|
24805
24847
|
function printJsxClosingElement(path, options, print) {
|
|
24806
24848
|
const node = path.getValue();
|
|
24807
24849
|
const parts = [];
|
|
@@ -24928,6 +24970,546 @@ var require_jsx = __commonJS2({
|
|
|
24928
24970
|
};
|
|
24929
24971
|
}
|
|
24930
24972
|
});
|
|
24973
|
+
var require_doc_builders = __commonJS2({
|
|
24974
|
+
"src/document/doc-builders.js"(exports2, module2) {
|
|
24975
|
+
"use strict";
|
|
24976
|
+
function concat(parts) {
|
|
24977
|
+
if (false) {
|
|
24978
|
+
for (const part of parts) {
|
|
24979
|
+
assertDoc(part);
|
|
24980
|
+
}
|
|
24981
|
+
}
|
|
24982
|
+
return {
|
|
24983
|
+
type: "concat",
|
|
24984
|
+
parts
|
|
24985
|
+
};
|
|
24986
|
+
}
|
|
24987
|
+
function indent(contents) {
|
|
24988
|
+
if (false) {
|
|
24989
|
+
assertDoc(contents);
|
|
24990
|
+
}
|
|
24991
|
+
return {
|
|
24992
|
+
type: "indent",
|
|
24993
|
+
contents
|
|
24994
|
+
};
|
|
24995
|
+
}
|
|
24996
|
+
function align(widthOrString, contents) {
|
|
24997
|
+
if (false) {
|
|
24998
|
+
assertDoc(contents);
|
|
24999
|
+
}
|
|
25000
|
+
return {
|
|
25001
|
+
type: "align",
|
|
25002
|
+
contents,
|
|
25003
|
+
n: widthOrString
|
|
25004
|
+
};
|
|
25005
|
+
}
|
|
25006
|
+
function group(contents, opts = {}) {
|
|
25007
|
+
if (false) {
|
|
25008
|
+
assertDoc(contents);
|
|
25009
|
+
}
|
|
25010
|
+
return {
|
|
25011
|
+
type: "group",
|
|
25012
|
+
id: opts.id,
|
|
25013
|
+
contents,
|
|
25014
|
+
break: Boolean(opts.shouldBreak),
|
|
25015
|
+
expandedStates: opts.expandedStates
|
|
25016
|
+
};
|
|
25017
|
+
}
|
|
25018
|
+
function dedentToRoot(contents) {
|
|
25019
|
+
return align(Number.NEGATIVE_INFINITY, contents);
|
|
25020
|
+
}
|
|
25021
|
+
function markAsRoot(contents) {
|
|
25022
|
+
return align({
|
|
25023
|
+
type: "root"
|
|
25024
|
+
}, contents);
|
|
25025
|
+
}
|
|
25026
|
+
function dedent(contents) {
|
|
25027
|
+
return align(-1, contents);
|
|
25028
|
+
}
|
|
25029
|
+
function conditionalGroup(states, opts) {
|
|
25030
|
+
return group(states[0], Object.assign(Object.assign({}, opts), {}, {
|
|
25031
|
+
expandedStates: states
|
|
25032
|
+
}));
|
|
25033
|
+
}
|
|
25034
|
+
function fill(parts) {
|
|
25035
|
+
if (false) {
|
|
25036
|
+
for (const part of parts) {
|
|
25037
|
+
assertDoc(part);
|
|
25038
|
+
}
|
|
25039
|
+
}
|
|
25040
|
+
return {
|
|
25041
|
+
type: "fill",
|
|
25042
|
+
parts
|
|
25043
|
+
};
|
|
25044
|
+
}
|
|
25045
|
+
function ifBreak(breakContents, flatContents, opts = {}) {
|
|
25046
|
+
if (false) {
|
|
25047
|
+
if (breakContents) {
|
|
25048
|
+
assertDoc(breakContents);
|
|
25049
|
+
}
|
|
25050
|
+
if (flatContents) {
|
|
25051
|
+
assertDoc(flatContents);
|
|
25052
|
+
}
|
|
25053
|
+
}
|
|
25054
|
+
return {
|
|
25055
|
+
type: "if-break",
|
|
25056
|
+
breakContents,
|
|
25057
|
+
flatContents,
|
|
25058
|
+
groupId: opts.groupId
|
|
25059
|
+
};
|
|
25060
|
+
}
|
|
25061
|
+
function indentIfBreak(contents, opts) {
|
|
25062
|
+
return {
|
|
25063
|
+
type: "indent-if-break",
|
|
25064
|
+
contents,
|
|
25065
|
+
groupId: opts.groupId,
|
|
25066
|
+
negate: opts.negate
|
|
25067
|
+
};
|
|
25068
|
+
}
|
|
25069
|
+
function lineSuffix(contents) {
|
|
25070
|
+
if (false) {
|
|
25071
|
+
assertDoc(contents);
|
|
25072
|
+
}
|
|
25073
|
+
return {
|
|
25074
|
+
type: "line-suffix",
|
|
25075
|
+
contents
|
|
25076
|
+
};
|
|
25077
|
+
}
|
|
25078
|
+
var lineSuffixBoundary = {
|
|
25079
|
+
type: "line-suffix-boundary"
|
|
25080
|
+
};
|
|
25081
|
+
var breakParent = {
|
|
25082
|
+
type: "break-parent"
|
|
25083
|
+
};
|
|
25084
|
+
var trim = {
|
|
25085
|
+
type: "trim"
|
|
25086
|
+
};
|
|
25087
|
+
var hardlineWithoutBreakParent = {
|
|
25088
|
+
type: "line",
|
|
25089
|
+
hard: true
|
|
25090
|
+
};
|
|
25091
|
+
var literallineWithoutBreakParent = {
|
|
25092
|
+
type: "line",
|
|
25093
|
+
hard: true,
|
|
25094
|
+
literal: true
|
|
25095
|
+
};
|
|
25096
|
+
var line = {
|
|
25097
|
+
type: "line"
|
|
25098
|
+
};
|
|
25099
|
+
var softline = {
|
|
25100
|
+
type: "line",
|
|
25101
|
+
soft: true
|
|
25102
|
+
};
|
|
25103
|
+
var hardline = concat([hardlineWithoutBreakParent, breakParent]);
|
|
25104
|
+
var literalline = concat([literallineWithoutBreakParent, breakParent]);
|
|
25105
|
+
var cursor = {
|
|
25106
|
+
type: "cursor",
|
|
25107
|
+
placeholder: Symbol("cursor")
|
|
25108
|
+
};
|
|
25109
|
+
function join(sep, arr) {
|
|
25110
|
+
const res = [];
|
|
25111
|
+
for (let i = 0; i < arr.length; i++) {
|
|
25112
|
+
if (i !== 0) {
|
|
25113
|
+
res.push(sep);
|
|
25114
|
+
}
|
|
25115
|
+
res.push(arr[i]);
|
|
25116
|
+
}
|
|
25117
|
+
return concat(res);
|
|
25118
|
+
}
|
|
25119
|
+
function addAlignmentToDoc(doc2, size, tabWidth) {
|
|
25120
|
+
let aligned = doc2;
|
|
25121
|
+
if (size > 0) {
|
|
25122
|
+
for (let i = 0; i < Math.floor(size / tabWidth); ++i) {
|
|
25123
|
+
aligned = indent(aligned);
|
|
25124
|
+
}
|
|
25125
|
+
aligned = align(size % tabWidth, aligned);
|
|
25126
|
+
aligned = align(Number.NEGATIVE_INFINITY, aligned);
|
|
25127
|
+
}
|
|
25128
|
+
return aligned;
|
|
25129
|
+
}
|
|
25130
|
+
function label(label2, contents) {
|
|
25131
|
+
return {
|
|
25132
|
+
type: "label",
|
|
25133
|
+
label: label2,
|
|
25134
|
+
contents
|
|
25135
|
+
};
|
|
25136
|
+
}
|
|
25137
|
+
module2.exports = {
|
|
25138
|
+
concat,
|
|
25139
|
+
join,
|
|
25140
|
+
line,
|
|
25141
|
+
softline,
|
|
25142
|
+
hardline,
|
|
25143
|
+
literalline,
|
|
25144
|
+
group,
|
|
25145
|
+
conditionalGroup,
|
|
25146
|
+
fill,
|
|
25147
|
+
lineSuffix,
|
|
25148
|
+
lineSuffixBoundary,
|
|
25149
|
+
cursor,
|
|
25150
|
+
breakParent,
|
|
25151
|
+
ifBreak,
|
|
25152
|
+
trim,
|
|
25153
|
+
indent,
|
|
25154
|
+
indentIfBreak,
|
|
25155
|
+
align,
|
|
25156
|
+
addAlignmentToDoc,
|
|
25157
|
+
markAsRoot,
|
|
25158
|
+
dedentToRoot,
|
|
25159
|
+
dedent,
|
|
25160
|
+
hardlineWithoutBreakParent,
|
|
25161
|
+
literallineWithoutBreakParent,
|
|
25162
|
+
label
|
|
25163
|
+
};
|
|
25164
|
+
}
|
|
25165
|
+
});
|
|
25166
|
+
var require_doc_utils = __commonJS2({
|
|
25167
|
+
"src/document/doc-utils.js"(exports2, module2) {
|
|
25168
|
+
"use strict";
|
|
25169
|
+
var getLast = require_get_last();
|
|
25170
|
+
var {
|
|
25171
|
+
literalline,
|
|
25172
|
+
join
|
|
25173
|
+
} = require_doc_builders();
|
|
25174
|
+
var isConcat = (doc2) => Array.isArray(doc2) || doc2 && doc2.type === "concat";
|
|
25175
|
+
var getDocParts = (doc2) => {
|
|
25176
|
+
if (Array.isArray(doc2)) {
|
|
25177
|
+
return doc2;
|
|
25178
|
+
}
|
|
25179
|
+
if (doc2.type !== "concat" && doc2.type !== "fill") {
|
|
25180
|
+
throw new Error("Expect doc type to be `concat` or `fill`.");
|
|
25181
|
+
}
|
|
25182
|
+
return doc2.parts;
|
|
25183
|
+
};
|
|
25184
|
+
var traverseDocOnExitStackMarker = {};
|
|
25185
|
+
function traverseDoc(doc2, onEnter, onExit, shouldTraverseConditionalGroups) {
|
|
25186
|
+
const docsStack = [doc2];
|
|
25187
|
+
while (docsStack.length > 0) {
|
|
25188
|
+
const doc3 = docsStack.pop();
|
|
25189
|
+
if (doc3 === traverseDocOnExitStackMarker) {
|
|
25190
|
+
onExit(docsStack.pop());
|
|
25191
|
+
continue;
|
|
25192
|
+
}
|
|
25193
|
+
if (onExit) {
|
|
25194
|
+
docsStack.push(doc3, traverseDocOnExitStackMarker);
|
|
25195
|
+
}
|
|
25196
|
+
if (!onEnter || onEnter(doc3) !== false) {
|
|
25197
|
+
if (isConcat(doc3) || doc3.type === "fill") {
|
|
25198
|
+
const parts = getDocParts(doc3);
|
|
25199
|
+
for (let ic = parts.length, i = ic - 1; i >= 0; --i) {
|
|
25200
|
+
docsStack.push(parts[i]);
|
|
25201
|
+
}
|
|
25202
|
+
} else if (doc3.type === "if-break") {
|
|
25203
|
+
if (doc3.flatContents) {
|
|
25204
|
+
docsStack.push(doc3.flatContents);
|
|
25205
|
+
}
|
|
25206
|
+
if (doc3.breakContents) {
|
|
25207
|
+
docsStack.push(doc3.breakContents);
|
|
25208
|
+
}
|
|
25209
|
+
} else if (doc3.type === "group" && doc3.expandedStates) {
|
|
25210
|
+
if (shouldTraverseConditionalGroups) {
|
|
25211
|
+
for (let ic = doc3.expandedStates.length, i = ic - 1; i >= 0; --i) {
|
|
25212
|
+
docsStack.push(doc3.expandedStates[i]);
|
|
25213
|
+
}
|
|
25214
|
+
} else {
|
|
25215
|
+
docsStack.push(doc3.contents);
|
|
25216
|
+
}
|
|
25217
|
+
} else if (doc3.contents) {
|
|
25218
|
+
docsStack.push(doc3.contents);
|
|
25219
|
+
}
|
|
25220
|
+
}
|
|
25221
|
+
}
|
|
25222
|
+
}
|
|
25223
|
+
function mapDoc(doc2, cb) {
|
|
25224
|
+
const mapped = /* @__PURE__ */ new Map();
|
|
25225
|
+
return rec(doc2);
|
|
25226
|
+
function rec(doc3) {
|
|
25227
|
+
if (mapped.has(doc3)) {
|
|
25228
|
+
return mapped.get(doc3);
|
|
25229
|
+
}
|
|
25230
|
+
const result = process2(doc3);
|
|
25231
|
+
mapped.set(doc3, result);
|
|
25232
|
+
return result;
|
|
25233
|
+
}
|
|
25234
|
+
function process2(doc3) {
|
|
25235
|
+
if (Array.isArray(doc3)) {
|
|
25236
|
+
return cb(doc3.map(rec));
|
|
25237
|
+
}
|
|
25238
|
+
if (doc3.type === "concat" || doc3.type === "fill") {
|
|
25239
|
+
const parts = doc3.parts.map(rec);
|
|
25240
|
+
return cb(Object.assign(Object.assign({}, doc3), {}, {
|
|
25241
|
+
parts
|
|
25242
|
+
}));
|
|
25243
|
+
}
|
|
25244
|
+
if (doc3.type === "if-break") {
|
|
25245
|
+
const breakContents = doc3.breakContents && rec(doc3.breakContents);
|
|
25246
|
+
const flatContents = doc3.flatContents && rec(doc3.flatContents);
|
|
25247
|
+
return cb(Object.assign(Object.assign({}, doc3), {}, {
|
|
25248
|
+
breakContents,
|
|
25249
|
+
flatContents
|
|
25250
|
+
}));
|
|
25251
|
+
}
|
|
25252
|
+
if (doc3.type === "group" && doc3.expandedStates) {
|
|
25253
|
+
const expandedStates = doc3.expandedStates.map(rec);
|
|
25254
|
+
const contents = expandedStates[0];
|
|
25255
|
+
return cb(Object.assign(Object.assign({}, doc3), {}, {
|
|
25256
|
+
contents,
|
|
25257
|
+
expandedStates
|
|
25258
|
+
}));
|
|
25259
|
+
}
|
|
25260
|
+
if (doc3.contents) {
|
|
25261
|
+
const contents = rec(doc3.contents);
|
|
25262
|
+
return cb(Object.assign(Object.assign({}, doc3), {}, {
|
|
25263
|
+
contents
|
|
25264
|
+
}));
|
|
25265
|
+
}
|
|
25266
|
+
return cb(doc3);
|
|
25267
|
+
}
|
|
25268
|
+
}
|
|
25269
|
+
function findInDoc(doc2, fn, defaultValue) {
|
|
25270
|
+
let result = defaultValue;
|
|
25271
|
+
let hasStopped = false;
|
|
25272
|
+
function findInDocOnEnterFn(doc3) {
|
|
25273
|
+
const maybeResult = fn(doc3);
|
|
25274
|
+
if (maybeResult !== void 0) {
|
|
25275
|
+
hasStopped = true;
|
|
25276
|
+
result = maybeResult;
|
|
25277
|
+
}
|
|
25278
|
+
if (hasStopped) {
|
|
25279
|
+
return false;
|
|
25280
|
+
}
|
|
25281
|
+
}
|
|
25282
|
+
traverseDoc(doc2, findInDocOnEnterFn);
|
|
25283
|
+
return result;
|
|
25284
|
+
}
|
|
25285
|
+
function willBreakFn(doc2) {
|
|
25286
|
+
if (doc2.type === "group" && doc2.break) {
|
|
25287
|
+
return true;
|
|
25288
|
+
}
|
|
25289
|
+
if (doc2.type === "line" && doc2.hard) {
|
|
25290
|
+
return true;
|
|
25291
|
+
}
|
|
25292
|
+
if (doc2.type === "break-parent") {
|
|
25293
|
+
return true;
|
|
25294
|
+
}
|
|
25295
|
+
}
|
|
25296
|
+
function willBreak(doc2) {
|
|
25297
|
+
return findInDoc(doc2, willBreakFn, false);
|
|
25298
|
+
}
|
|
25299
|
+
function breakParentGroup(groupStack) {
|
|
25300
|
+
if (groupStack.length > 0) {
|
|
25301
|
+
const parentGroup = getLast(groupStack);
|
|
25302
|
+
if (!parentGroup.expandedStates && !parentGroup.break) {
|
|
25303
|
+
parentGroup.break = "propagated";
|
|
25304
|
+
}
|
|
25305
|
+
}
|
|
25306
|
+
return null;
|
|
25307
|
+
}
|
|
25308
|
+
function propagateBreaks(doc2) {
|
|
25309
|
+
const alreadyVisitedSet = /* @__PURE__ */ new Set();
|
|
25310
|
+
const groupStack = [];
|
|
25311
|
+
function propagateBreaksOnEnterFn(doc3) {
|
|
25312
|
+
if (doc3.type === "break-parent") {
|
|
25313
|
+
breakParentGroup(groupStack);
|
|
25314
|
+
}
|
|
25315
|
+
if (doc3.type === "group") {
|
|
25316
|
+
groupStack.push(doc3);
|
|
25317
|
+
if (alreadyVisitedSet.has(doc3)) {
|
|
25318
|
+
return false;
|
|
25319
|
+
}
|
|
25320
|
+
alreadyVisitedSet.add(doc3);
|
|
25321
|
+
}
|
|
25322
|
+
}
|
|
25323
|
+
function propagateBreaksOnExitFn(doc3) {
|
|
25324
|
+
if (doc3.type === "group") {
|
|
25325
|
+
const group = groupStack.pop();
|
|
25326
|
+
if (group.break) {
|
|
25327
|
+
breakParentGroup(groupStack);
|
|
25328
|
+
}
|
|
25329
|
+
}
|
|
25330
|
+
}
|
|
25331
|
+
traverseDoc(doc2, propagateBreaksOnEnterFn, propagateBreaksOnExitFn, true);
|
|
25332
|
+
}
|
|
25333
|
+
function removeLinesFn(doc2) {
|
|
25334
|
+
if (doc2.type === "line" && !doc2.hard) {
|
|
25335
|
+
return doc2.soft ? "" : " ";
|
|
25336
|
+
}
|
|
25337
|
+
if (doc2.type === "if-break") {
|
|
25338
|
+
return doc2.flatContents || "";
|
|
25339
|
+
}
|
|
25340
|
+
return doc2;
|
|
25341
|
+
}
|
|
25342
|
+
function removeLines(doc2) {
|
|
25343
|
+
return mapDoc(doc2, removeLinesFn);
|
|
25344
|
+
}
|
|
25345
|
+
var isHardline = (doc2, nextDoc) => doc2 && doc2.type === "line" && doc2.hard && nextDoc && nextDoc.type === "break-parent";
|
|
25346
|
+
function stripDocTrailingHardlineFromDoc(doc2) {
|
|
25347
|
+
if (!doc2) {
|
|
25348
|
+
return doc2;
|
|
25349
|
+
}
|
|
25350
|
+
if (isConcat(doc2) || doc2.type === "fill") {
|
|
25351
|
+
const parts = getDocParts(doc2);
|
|
25352
|
+
while (parts.length > 1 && isHardline(...parts.slice(-2))) {
|
|
25353
|
+
parts.length -= 2;
|
|
25354
|
+
}
|
|
25355
|
+
if (parts.length > 0) {
|
|
25356
|
+
const lastPart = stripDocTrailingHardlineFromDoc(getLast(parts));
|
|
25357
|
+
parts[parts.length - 1] = lastPart;
|
|
25358
|
+
}
|
|
25359
|
+
return Array.isArray(doc2) ? parts : Object.assign(Object.assign({}, doc2), {}, {
|
|
25360
|
+
parts
|
|
25361
|
+
});
|
|
25362
|
+
}
|
|
25363
|
+
switch (doc2.type) {
|
|
25364
|
+
case "align":
|
|
25365
|
+
case "indent":
|
|
25366
|
+
case "indent-if-break":
|
|
25367
|
+
case "group":
|
|
25368
|
+
case "line-suffix":
|
|
25369
|
+
case "label": {
|
|
25370
|
+
const contents = stripDocTrailingHardlineFromDoc(doc2.contents);
|
|
25371
|
+
return Object.assign(Object.assign({}, doc2), {}, {
|
|
25372
|
+
contents
|
|
25373
|
+
});
|
|
25374
|
+
}
|
|
25375
|
+
case "if-break": {
|
|
25376
|
+
const breakContents = stripDocTrailingHardlineFromDoc(doc2.breakContents);
|
|
25377
|
+
const flatContents = stripDocTrailingHardlineFromDoc(doc2.flatContents);
|
|
25378
|
+
return Object.assign(Object.assign({}, doc2), {}, {
|
|
25379
|
+
breakContents,
|
|
25380
|
+
flatContents
|
|
25381
|
+
});
|
|
25382
|
+
}
|
|
25383
|
+
}
|
|
25384
|
+
return doc2;
|
|
25385
|
+
}
|
|
25386
|
+
function stripTrailingHardline(doc2) {
|
|
25387
|
+
return stripDocTrailingHardlineFromDoc(cleanDoc(doc2));
|
|
25388
|
+
}
|
|
25389
|
+
function cleanDocFn(doc2) {
|
|
25390
|
+
switch (doc2.type) {
|
|
25391
|
+
case "fill":
|
|
25392
|
+
if (doc2.parts.every((part) => part === "")) {
|
|
25393
|
+
return "";
|
|
25394
|
+
}
|
|
25395
|
+
break;
|
|
25396
|
+
case "group":
|
|
25397
|
+
if (!doc2.contents && !doc2.id && !doc2.break && !doc2.expandedStates) {
|
|
25398
|
+
return "";
|
|
25399
|
+
}
|
|
25400
|
+
if (doc2.contents.type === "group" && doc2.contents.id === doc2.id && doc2.contents.break === doc2.break && doc2.contents.expandedStates === doc2.expandedStates) {
|
|
25401
|
+
return doc2.contents;
|
|
25402
|
+
}
|
|
25403
|
+
break;
|
|
25404
|
+
case "align":
|
|
25405
|
+
case "indent":
|
|
25406
|
+
case "indent-if-break":
|
|
25407
|
+
case "line-suffix":
|
|
25408
|
+
if (!doc2.contents) {
|
|
25409
|
+
return "";
|
|
25410
|
+
}
|
|
25411
|
+
break;
|
|
25412
|
+
case "if-break":
|
|
25413
|
+
if (!doc2.flatContents && !doc2.breakContents) {
|
|
25414
|
+
return "";
|
|
25415
|
+
}
|
|
25416
|
+
break;
|
|
25417
|
+
}
|
|
25418
|
+
if (!isConcat(doc2)) {
|
|
25419
|
+
return doc2;
|
|
25420
|
+
}
|
|
25421
|
+
const parts = [];
|
|
25422
|
+
for (const part of getDocParts(doc2)) {
|
|
25423
|
+
if (!part) {
|
|
25424
|
+
continue;
|
|
25425
|
+
}
|
|
25426
|
+
const [currentPart, ...restParts] = isConcat(part) ? getDocParts(part) : [part];
|
|
25427
|
+
if (typeof currentPart === "string" && typeof getLast(parts) === "string") {
|
|
25428
|
+
parts[parts.length - 1] += currentPart;
|
|
25429
|
+
} else {
|
|
25430
|
+
parts.push(currentPart);
|
|
25431
|
+
}
|
|
25432
|
+
parts.push(...restParts);
|
|
25433
|
+
}
|
|
25434
|
+
if (parts.length === 0) {
|
|
25435
|
+
return "";
|
|
25436
|
+
}
|
|
25437
|
+
if (parts.length === 1) {
|
|
25438
|
+
return parts[0];
|
|
25439
|
+
}
|
|
25440
|
+
return Array.isArray(doc2) ? parts : Object.assign(Object.assign({}, doc2), {}, {
|
|
25441
|
+
parts
|
|
25442
|
+
});
|
|
25443
|
+
}
|
|
25444
|
+
function cleanDoc(doc2) {
|
|
25445
|
+
return mapDoc(doc2, (currentDoc) => cleanDocFn(currentDoc));
|
|
25446
|
+
}
|
|
25447
|
+
function normalizeParts(parts) {
|
|
25448
|
+
const newParts = [];
|
|
25449
|
+
const restParts = parts.filter(Boolean);
|
|
25450
|
+
while (restParts.length > 0) {
|
|
25451
|
+
const part = restParts.shift();
|
|
25452
|
+
if (!part) {
|
|
25453
|
+
continue;
|
|
25454
|
+
}
|
|
25455
|
+
if (isConcat(part)) {
|
|
25456
|
+
restParts.unshift(...getDocParts(part));
|
|
25457
|
+
continue;
|
|
25458
|
+
}
|
|
25459
|
+
if (newParts.length > 0 && typeof getLast(newParts) === "string" && typeof part === "string") {
|
|
25460
|
+
newParts[newParts.length - 1] += part;
|
|
25461
|
+
continue;
|
|
25462
|
+
}
|
|
25463
|
+
newParts.push(part);
|
|
25464
|
+
}
|
|
25465
|
+
return newParts;
|
|
25466
|
+
}
|
|
25467
|
+
function normalizeDoc(doc2) {
|
|
25468
|
+
return mapDoc(doc2, (currentDoc) => {
|
|
25469
|
+
if (Array.isArray(currentDoc)) {
|
|
25470
|
+
return normalizeParts(currentDoc);
|
|
25471
|
+
}
|
|
25472
|
+
if (!currentDoc.parts) {
|
|
25473
|
+
return currentDoc;
|
|
25474
|
+
}
|
|
25475
|
+
return Object.assign(Object.assign({}, currentDoc), {}, {
|
|
25476
|
+
parts: normalizeParts(currentDoc.parts)
|
|
25477
|
+
});
|
|
25478
|
+
});
|
|
25479
|
+
}
|
|
25480
|
+
function replaceEndOfLine(doc2) {
|
|
25481
|
+
return mapDoc(doc2, (currentDoc) => typeof currentDoc === "string" && currentDoc.includes("\n") ? replaceTextEndOfLine(currentDoc) : currentDoc);
|
|
25482
|
+
}
|
|
25483
|
+
function replaceTextEndOfLine(text, replacement = literalline) {
|
|
25484
|
+
return join(replacement, text.split("\n")).parts;
|
|
25485
|
+
}
|
|
25486
|
+
function canBreakFn(doc2) {
|
|
25487
|
+
if (doc2.type === "line") {
|
|
25488
|
+
return true;
|
|
25489
|
+
}
|
|
25490
|
+
}
|
|
25491
|
+
function canBreak(doc2) {
|
|
25492
|
+
return findInDoc(doc2, canBreakFn, false);
|
|
25493
|
+
}
|
|
25494
|
+
module2.exports = {
|
|
25495
|
+
isConcat,
|
|
25496
|
+
getDocParts,
|
|
25497
|
+
willBreak,
|
|
25498
|
+
traverseDoc,
|
|
25499
|
+
findInDoc,
|
|
25500
|
+
mapDoc,
|
|
25501
|
+
propagateBreaks,
|
|
25502
|
+
removeLines,
|
|
25503
|
+
stripTrailingHardline,
|
|
25504
|
+
normalizeParts,
|
|
25505
|
+
normalizeDoc,
|
|
25506
|
+
cleanDoc,
|
|
25507
|
+
replaceTextEndOfLine,
|
|
25508
|
+
replaceEndOfLine,
|
|
25509
|
+
canBreak
|
|
25510
|
+
};
|
|
25511
|
+
}
|
|
25512
|
+
});
|
|
24931
25513
|
var require_misc = __commonJS2({
|
|
24932
25514
|
"src/language-js/print/misc.js"(exports2, module2) {
|
|
24933
25515
|
"use strict";
|
|
@@ -25147,7 +25729,8 @@ var require_call_arguments = __commonJS2({
|
|
|
25147
25729
|
isNextLineEmpty,
|
|
25148
25730
|
isCallExpression,
|
|
25149
25731
|
isStringLiteral,
|
|
25150
|
-
isObjectProperty
|
|
25732
|
+
isObjectProperty,
|
|
25733
|
+
isTSTypeExpression
|
|
25151
25734
|
} = require_utils7();
|
|
25152
25735
|
var {
|
|
25153
25736
|
builders: {
|
|
@@ -25251,7 +25834,7 @@ var require_call_arguments = __commonJS2({
|
|
|
25251
25834
|
});
|
|
25252
25835
|
}
|
|
25253
25836
|
function couldGroupArg(arg, arrowChainRecursion = false) {
|
|
25254
|
-
return arg.type === "ObjectExpression" && (arg.properties.length > 0 || hasComment(arg)) || arg.type === "ArrayExpression" && (arg.elements.length > 0 || hasComment(arg)) || arg.type === "TSTypeAssertion" && couldGroupArg(arg.expression) || arg
|
|
25837
|
+
return arg.type === "ObjectExpression" && (arg.properties.length > 0 || hasComment(arg)) || arg.type === "ArrayExpression" && (arg.elements.length > 0 || hasComment(arg)) || arg.type === "TSTypeAssertion" && couldGroupArg(arg.expression) || isTSTypeExpression(arg) && couldGroupArg(arg.expression) || arg.type === "FunctionExpression" || arg.type === "ArrowFunctionExpression" && (!arg.returnType || !arg.returnType.typeAnnotation || arg.returnType.typeAnnotation.type !== "TSTypeReference" || isNonEmptyBlockStatement(arg.body)) && (arg.body.type === "BlockStatement" || arg.body.type === "ArrowFunctionExpression" && couldGroupArg(arg.body, true) || arg.body.type === "ObjectExpression" || arg.body.type === "ArrayExpression" || !arrowChainRecursion && (isCallExpression(arg.body) || arg.body.type === "ConditionalExpression") || isJsxNode(arg.body)) || arg.type === "DoExpression" || arg.type === "ModuleExpression";
|
|
25255
25838
|
}
|
|
25256
25839
|
function shouldGroupLastArg(args, options) {
|
|
25257
25840
|
const lastArg = getLast(args);
|
|
@@ -26766,9 +27349,7 @@ var require_decorators = __commonJS2({
|
|
|
26766
27349
|
return false;
|
|
26767
27350
|
}
|
|
26768
27351
|
const decorators = node.declaration && node.declaration.decorators;
|
|
26769
|
-
return isNonEmptyArray(decorators) && locStart(node
|
|
26770
|
-
ignoreDecorators: true
|
|
26771
|
-
}) > locStart(decorators[0]);
|
|
27352
|
+
return isNonEmptyArray(decorators) && locStart(node) === locStart(decorators[0]);
|
|
26772
27353
|
}
|
|
26773
27354
|
module2.exports = {
|
|
26774
27355
|
printDecorators,
|
|
@@ -27438,6 +28019,9 @@ var require_flow = __commonJS2({
|
|
|
27438
28019
|
locStart,
|
|
27439
28020
|
locEnd
|
|
27440
28021
|
} = require_loc();
|
|
28022
|
+
var {
|
|
28023
|
+
replaceTextEndOfLine
|
|
28024
|
+
} = require_doc_utils();
|
|
27441
28025
|
var {
|
|
27442
28026
|
printClass
|
|
27443
28027
|
} = require_class();
|
|
@@ -27618,7 +28202,7 @@ var require_flow = __commonJS2({
|
|
|
27618
28202
|
case "QualifiedTypeIdentifier":
|
|
27619
28203
|
return [print("qualification"), ".", print("id")];
|
|
27620
28204
|
case "StringLiteralTypeAnnotation":
|
|
27621
|
-
return printString(rawText(node), options);
|
|
28205
|
+
return replaceTextEndOfLine(printString(rawText(node), options));
|
|
27622
28206
|
case "NumberLiteralTypeAnnotation":
|
|
27623
28207
|
assert.strictEqual(typeof node.value, "number");
|
|
27624
28208
|
case "BigIntLiteralTypeAnnotation":
|
|
@@ -27719,7 +28303,8 @@ var require_ternary = __commonJS2({
|
|
|
27719
28303
|
isJsxNode,
|
|
27720
28304
|
getComments,
|
|
27721
28305
|
isCallExpression,
|
|
27722
|
-
isMemberExpression
|
|
28306
|
+
isMemberExpression,
|
|
28307
|
+
isTSTypeExpression
|
|
27723
28308
|
} = require_utils7();
|
|
27724
28309
|
var {
|
|
27725
28310
|
locStart,
|
|
@@ -27779,7 +28364,7 @@ var require_ternary = __commonJS2({
|
|
|
27779
28364
|
child = node2;
|
|
27780
28365
|
continue;
|
|
27781
28366
|
}
|
|
27782
|
-
if (node2.type === "NewExpression" && node2.callee === child || node2
|
|
28367
|
+
if (node2.type === "NewExpression" && node2.callee === child || isTSTypeExpression(node2) && node2.expression === child) {
|
|
27783
28368
|
parent = path.getParentNode(ancestorCount + 1);
|
|
27784
28369
|
child = node2;
|
|
27785
28370
|
} else {
|
|
@@ -28260,8 +28845,10 @@ var require_typescript = __commonJS2({
|
|
|
28260
28845
|
return printTypeParameters(path, options, print, "params");
|
|
28261
28846
|
case "TSTypeParameter":
|
|
28262
28847
|
return printTypeParameter(path, options, print);
|
|
28848
|
+
case "TSSatisfiesExpression":
|
|
28263
28849
|
case "TSAsExpression": {
|
|
28264
|
-
|
|
28850
|
+
const operator = node.type === "TSAsExpression" ? "as" : "satisfies";
|
|
28851
|
+
parts.push(print("expression"), ` ${operator} `, print("typeAnnotation"));
|
|
28265
28852
|
const parent = path.getParentNode();
|
|
28266
28853
|
if (isCallExpression(parent) && parent.callee === node || isMemberExpression(parent) && parent.object === node) {
|
|
28267
28854
|
return group([indent([softline, ...parts]), softline]);
|
|
@@ -28534,6 +29121,9 @@ var require_literal = __commonJS2({
|
|
|
28534
29121
|
printString,
|
|
28535
29122
|
printNumber
|
|
28536
29123
|
} = require_util();
|
|
29124
|
+
var {
|
|
29125
|
+
replaceTextEndOfLine
|
|
29126
|
+
} = require_doc_utils();
|
|
28537
29127
|
function printLiteral(path, options) {
|
|
28538
29128
|
const node = path.getNode();
|
|
28539
29129
|
switch (node.type) {
|
|
@@ -28544,7 +29134,7 @@ var require_literal = __commonJS2({
|
|
|
28544
29134
|
case "NumericLiteral":
|
|
28545
29135
|
return printNumber(node.extra.raw);
|
|
28546
29136
|
case "StringLiteral":
|
|
28547
|
-
return printString(node.extra.raw, options);
|
|
29137
|
+
return replaceTextEndOfLine(printString(node.extra.raw, options));
|
|
28548
29138
|
case "NullLiteral":
|
|
28549
29139
|
return "null";
|
|
28550
29140
|
case "BooleanLiteral":
|
|
@@ -28568,7 +29158,7 @@ var require_literal = __commonJS2({
|
|
|
28568
29158
|
return printNumber(node.raw);
|
|
28569
29159
|
}
|
|
28570
29160
|
if (typeof value === "string") {
|
|
28571
|
-
return printString(node.raw, options);
|
|
29161
|
+
return replaceTextEndOfLine(printString(node.raw, options));
|
|
28572
29162
|
}
|
|
28573
29163
|
return String(value);
|
|
28574
29164
|
}
|
|
@@ -30661,7 +31251,8 @@ var require_printer_postcss = __commonJS2({
|
|
|
30661
31251
|
return [".", adjustNumbers(adjustStrings(node.value, options))];
|
|
30662
31252
|
}
|
|
30663
31253
|
case "selector-attribute": {
|
|
30664
|
-
|
|
31254
|
+
var _node$operator;
|
|
31255
|
+
return ["[", node.namespace ? [node.namespace === true ? "" : node.namespace.trim(), "|"] : "", node.attribute.trim(), (_node$operator = node.operator) !== null && _node$operator !== void 0 ? _node$operator : "", node.value ? quoteAttributeValue(adjustStrings(node.value.trim(), options), options) : "", node.insensitive ? " i" : "", "]"];
|
|
30665
31256
|
}
|
|
30666
31257
|
case "selector-combinator": {
|
|
30667
31258
|
if (node.value === "+" || node.value === ">" || node.value === "~" || node.value === ">>>") {
|
|
@@ -30677,7 +31268,7 @@ var require_printer_postcss = __commonJS2({
|
|
|
30677
31268
|
return [node.namespace ? [node.namespace === true ? "" : node.namespace.trim(), "|"] : "", node.value];
|
|
30678
31269
|
}
|
|
30679
31270
|
case "selector-pseudo": {
|
|
30680
|
-
return [maybeToLowerCase(node.value), isNonEmptyArray(node.nodes) ? ["(", join(",
|
|
31271
|
+
return [maybeToLowerCase(node.value), isNonEmptyArray(node.nodes) ? group(["(", indent([softline, join([",", line], path.map(print, "nodes"))]), softline, ")"]) : ""];
|
|
30681
31272
|
}
|
|
30682
31273
|
case "selector-nesting": {
|
|
30683
31274
|
return node.value;
|
|
@@ -30723,6 +31314,7 @@ var require_printer_postcss = __commonJS2({
|
|
|
30723
31314
|
let insideSCSSInterpolationInString = false;
|
|
30724
31315
|
let didBreak = false;
|
|
30725
31316
|
for (let i = 0; i < node.groups.length; ++i) {
|
|
31317
|
+
var _iNode$value;
|
|
30726
31318
|
parts.push(printed[i]);
|
|
30727
31319
|
const iPrevNode = node.groups[i - 1];
|
|
30728
31320
|
const iNode = node.groups[i];
|
|
@@ -30839,6 +31431,9 @@ var require_printer_postcss = __commonJS2({
|
|
|
30839
31431
|
parts.push(" ");
|
|
30840
31432
|
continue;
|
|
30841
31433
|
}
|
|
31434
|
+
if ((_iNode$value = iNode.value) !== null && _iNode$value !== void 0 && _iNode$value.endsWith("#") && iNextNode.value === "{" && isParenGroupNode(iNextNode.group)) {
|
|
31435
|
+
continue;
|
|
31436
|
+
}
|
|
30842
31437
|
parts.push(line);
|
|
30843
31438
|
}
|
|
30844
31439
|
if (hasInlineComment) {
|
|
@@ -31311,9 +31906,9 @@ var require_printer_glimmer = __commonJS2({
|
|
|
31311
31906
|
}
|
|
31312
31907
|
case "BlockStatement": {
|
|
31313
31908
|
const pp = path.getParentNode(1);
|
|
31314
|
-
const
|
|
31315
|
-
if (
|
|
31316
|
-
return [
|
|
31909
|
+
const isElseIfLike = pp && pp.inverse && pp.inverse.body.length === 1 && pp.inverse.body[0] === node && pp.inverse.body[0].path.parts[0] === pp.path.parts[0];
|
|
31910
|
+
if (isElseIfLike) {
|
|
31911
|
+
return [printElseIfLikeBlock(path, print2, pp.inverse.body[0].path.parts[0]), printProgram(path, print2, options), printInverse(path, print2, options)];
|
|
31317
31912
|
}
|
|
31318
31913
|
return [printOpenBlock(path, print2), group([printProgram(path, print2, options), printInverse(path, print2, options), printCloseBlock(path, print2, options)])];
|
|
31319
31914
|
}
|
|
@@ -31584,9 +32179,9 @@ var require_printer_glimmer = __commonJS2({
|
|
|
31584
32179
|
function printElseBlock(node, options) {
|
|
31585
32180
|
return [options.htmlWhitespaceSensitivity === "ignore" ? hardline : "", printInverseBlockOpeningMustache(node), "else", printInverseBlockClosingMustache(node)];
|
|
31586
32181
|
}
|
|
31587
|
-
function
|
|
32182
|
+
function printElseIfLikeBlock(path, print2, ifLikeKeyword) {
|
|
31588
32183
|
const parentNode = path.getParentNode(1);
|
|
31589
|
-
return [printInverseBlockOpeningMustache(parentNode), "else
|
|
32184
|
+
return [printInverseBlockOpeningMustache(parentNode), "else ", ifLikeKeyword, " ", printParams(path, print2), printInverseBlockClosingMustache(parentNode)];
|
|
31590
32185
|
}
|
|
31591
32186
|
function printCloseBlock(path, print2, options) {
|
|
31592
32187
|
const node = path.getValue();
|
|
@@ -31599,8 +32194,8 @@ var require_printer_glimmer = __commonJS2({
|
|
|
31599
32194
|
function blockStatementHasOnlyWhitespaceInProgram(node) {
|
|
31600
32195
|
return isNodeOfSomeType(node, ["BlockStatement"]) && node.program.body.every((node2) => isWhitespaceNode(node2));
|
|
31601
32196
|
}
|
|
31602
|
-
function
|
|
31603
|
-
return blockStatementHasElse(node) && node.inverse.body.length === 1 && isNodeOfSomeType(node.inverse.body[0], ["BlockStatement"]) && node.inverse.body[0].path.parts[0] ===
|
|
32197
|
+
function blockStatementHasElseIfLike(node) {
|
|
32198
|
+
return blockStatementHasElse(node) && node.inverse.body.length === 1 && isNodeOfSomeType(node.inverse.body[0], ["BlockStatement"]) && node.inverse.body[0].path.parts[0] === node.path.parts[0];
|
|
31604
32199
|
}
|
|
31605
32200
|
function blockStatementHasElse(node) {
|
|
31606
32201
|
return isNodeOfSomeType(node, ["BlockStatement"]) && node.inverse;
|
|
@@ -31620,7 +32215,7 @@ var require_printer_glimmer = __commonJS2({
|
|
|
31620
32215
|
const node = path.getValue();
|
|
31621
32216
|
const inverse = print2("inverse");
|
|
31622
32217
|
const printed = options.htmlWhitespaceSensitivity === "ignore" ? [hardline, inverse] : inverse;
|
|
31623
|
-
if (
|
|
32218
|
+
if (blockStatementHasElseIfLike(node)) {
|
|
31624
32219
|
return printed;
|
|
31625
32220
|
}
|
|
31626
32221
|
if (blockStatementHasElse(node)) {
|
|
@@ -32386,7 +32981,7 @@ var require_print_preprocess2 = __commonJS2({
|
|
|
32386
32981
|
function preprocess(ast, options) {
|
|
32387
32982
|
ast = restoreUnescapedCharacter(ast, options);
|
|
32388
32983
|
ast = mergeContinuousTexts(ast);
|
|
32389
|
-
ast = transformInlineCode(ast);
|
|
32984
|
+
ast = transformInlineCode(ast, options);
|
|
32390
32985
|
ast = transformIndentedCodeblockAndMarkItsParentList(ast, options);
|
|
32391
32986
|
ast = markAlignedList(ast, options);
|
|
32392
32987
|
ast = splitTextIntoSentences(ast, options);
|
|
@@ -32404,9 +32999,9 @@ var require_print_preprocess2 = __commonJS2({
|
|
|
32404
32999
|
});
|
|
32405
33000
|
});
|
|
32406
33001
|
}
|
|
32407
|
-
function transformInlineCode(ast) {
|
|
33002
|
+
function transformInlineCode(ast, options) {
|
|
32408
33003
|
return mapAst(ast, (node) => {
|
|
32409
|
-
if (node.type !== "inlineCode") {
|
|
33004
|
+
if (node.type !== "inlineCode" || options.proseWrap === "preserve") {
|
|
32410
33005
|
return node;
|
|
32411
33006
|
}
|
|
32412
33007
|
return Object.assign(Object.assign({}, node), {}, {
|
|
@@ -32979,7 +33574,7 @@ var require_printer_markdown = __commonJS2({
|
|
|
32979
33574
|
if (ignoreRanges.length > 0) {
|
|
32980
33575
|
const ignoreRange = ignoreRanges[0];
|
|
32981
33576
|
if (index === ignoreRange.start.index) {
|
|
32982
|
-
return [children[ignoreRange.start.index]
|
|
33577
|
+
return [printIgnoreComment(children[ignoreRange.start.index]), options.originalText.slice(ignoreRange.start.offset, ignoreRange.end.offset), printIgnoreComment(children[ignoreRange.end.index])];
|
|
32983
33578
|
}
|
|
32984
33579
|
if (ignoreRange.start.index < index && index < ignoreRange.end.index) {
|
|
32985
33580
|
return false;
|
|
@@ -33032,6 +33627,14 @@ var require_printer_markdown = __commonJS2({
|
|
|
33032
33627
|
}, "children");
|
|
33033
33628
|
return postprocessor ? postprocessor(parts) : parts;
|
|
33034
33629
|
}
|
|
33630
|
+
function printIgnoreComment(node) {
|
|
33631
|
+
if (node.type === "html") {
|
|
33632
|
+
return node.value;
|
|
33633
|
+
}
|
|
33634
|
+
if (node.type === "paragraph" && Array.isArray(node.children) && node.children.length === 1 && node.children[0].type === "esComment") {
|
|
33635
|
+
return ["{/* ", node.children[0].value, " */}"];
|
|
33636
|
+
}
|
|
33637
|
+
}
|
|
33035
33638
|
function getLastDescendantNode(node) {
|
|
33036
33639
|
let current = node;
|
|
33037
33640
|
while (isNonEmptyArray(current.children)) {
|
|
@@ -36249,7 +36852,7 @@ var require_embed5 = __commonJS2({
|
|
|
36249
36852
|
"use strict";
|
|
36250
36853
|
function embed(path, print, textToDoc, options) {
|
|
36251
36854
|
const node = path.getValue();
|
|
36252
|
-
if (node.type === "root" && options.filepath && /(?:[/\\]|^)\.(?:prettier|stylelint)rc$/.test(options.filepath)) {
|
|
36855
|
+
if (node.type === "root" && options.filepath && /(?:[/\\]|^)\.(?:prettier|stylelint|lintstaged)rc$/.test(options.filepath)) {
|
|
36253
36856
|
return textToDoc(options.originalText, Object.assign(Object.assign({}, options), {}, {
|
|
36254
36857
|
parser: "json"
|
|
36255
36858
|
}));
|
|
@@ -37100,7 +37703,7 @@ var require_language_yaml = __commonJS2({
|
|
|
37100
37703
|
since: "1.14.0",
|
|
37101
37704
|
parsers: ["yaml"],
|
|
37102
37705
|
vscodeLanguageIds: ["yaml", "ansible", "home-assistant"],
|
|
37103
|
-
filenames: [...data.filenames.filter((filename) => filename !== "yarn.lock"), ".prettierrc", ".stylelintrc"]
|
|
37706
|
+
filenames: [...data.filenames.filter((filename) => filename !== "yarn.lock"), ".prettierrc", ".stylelintrc", ".lintstagedrc"]
|
|
37104
37707
|
}))];
|
|
37105
37708
|
module2.exports = {
|
|
37106
37709
|
languages,
|