prettier 1.15.1 → 1.15.2
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/bin-prettier.js +150 -51
- package/index.js +150 -51
- package/package.json +1 -1
- package/parser-angular.js +1 -1
- package/parser-babylon.js +1 -1
- package/parser-flow.js +1 -1
- package/parser-html.js +1 -1
- package/parser-markdown.js +1 -1
- package/parser-typescript.js +1 -1
- package/standalone.js +148 -49
package/standalone.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
}(this, (function () { 'use strict';
|
|
6
6
|
|
|
7
7
|
var name = "prettier";
|
|
8
|
-
var version$1 = "1.15.
|
|
8
|
+
var version$1 = "1.15.2";
|
|
9
9
|
var description = "Prettier is an opinionated code formatter";
|
|
10
10
|
var bin = {
|
|
11
11
|
"prettier": "./bin/prettier.js"
|
|
@@ -24,7 +24,7 @@ var dependencies = {
|
|
|
24
24
|
"@babel/parser": "7.1.5",
|
|
25
25
|
"@glimmer/syntax": "0.30.3",
|
|
26
26
|
"@iarna/toml": "2.0.0",
|
|
27
|
-
"angular-estree-parser": "1.1.
|
|
27
|
+
"angular-estree-parser": "1.1.5",
|
|
28
28
|
"angular-html-parser": "1.0.0",
|
|
29
29
|
"camelcase": "4.1.0",
|
|
30
30
|
"chalk": "2.1.0",
|
|
@@ -101,7 +101,7 @@ var devDependencies = {
|
|
|
101
101
|
"jest-snapshot-serializer-raw": "1.1.0",
|
|
102
102
|
"jest-watch-typeahead": "0.1.0",
|
|
103
103
|
"mkdirp": "0.5.1",
|
|
104
|
-
"prettier": "1.15.
|
|
104
|
+
"prettier": "1.15.1",
|
|
105
105
|
"prettylint": "1.0.0",
|
|
106
106
|
"rimraf": "2.6.2",
|
|
107
107
|
"rollup": "0.47.6",
|
|
@@ -11195,6 +11195,17 @@ function optionInfoToSchema(optionInfo, _ref7) {
|
|
|
11195
11195
|
|
|
11196
11196
|
if (optionInfo.deprecated) {
|
|
11197
11197
|
handlers.deprecated = true;
|
|
11198
|
+
} // allow CLI overriding, e.g., prettier package.json --tab-width 1 --tab-width 2
|
|
11199
|
+
|
|
11200
|
+
|
|
11201
|
+
if (isCLI && !optionInfo.array) {
|
|
11202
|
+
var originalPreprocess = parameters.preprocess || function (x) {
|
|
11203
|
+
return x;
|
|
11204
|
+
};
|
|
11205
|
+
|
|
11206
|
+
parameters.preprocess = function (value, schema, utils) {
|
|
11207
|
+
return schema.preprocess(originalPreprocess(Array.isArray(value) ? value[value.length - 1] : value), utils);
|
|
11208
|
+
};
|
|
11198
11209
|
}
|
|
11199
11210
|
|
|
11200
11211
|
return optionInfo.array ? lib$1.ArraySchema.create(Object.assign(isCLI ? {
|
|
@@ -13610,9 +13621,8 @@ function isNextLineEmpty(text, node, locEnd) {
|
|
|
13610
13621
|
return isNextLineEmptyAfterIndex(text, locEnd(node));
|
|
13611
13622
|
}
|
|
13612
13623
|
|
|
13613
|
-
function
|
|
13624
|
+
function getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, idx) {
|
|
13614
13625
|
var oldIdx = null;
|
|
13615
|
-
var idx = locEnd(node);
|
|
13616
13626
|
|
|
13617
13627
|
while (idx !== oldIdx) {
|
|
13618
13628
|
oldIdx = idx;
|
|
@@ -13625,6 +13635,10 @@ function getNextNonSpaceNonCommentCharacterIndex(text, node, locEnd) {
|
|
|
13625
13635
|
return idx;
|
|
13626
13636
|
}
|
|
13627
13637
|
|
|
13638
|
+
function getNextNonSpaceNonCommentCharacterIndex(text, node, locEnd) {
|
|
13639
|
+
return getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, locEnd(node));
|
|
13640
|
+
}
|
|
13641
|
+
|
|
13628
13642
|
function getNextNonSpaceNonCommentCharacter(text, node, locEnd) {
|
|
13629
13643
|
return text.charAt(getNextNonSpaceNonCommentCharacterIndex(text, node, locEnd));
|
|
13630
13644
|
}
|
|
@@ -14018,6 +14032,7 @@ var util = {
|
|
|
14018
14032
|
getParentExportDeclaration: getParentExportDeclaration,
|
|
14019
14033
|
getPenultimate: getPenultimate,
|
|
14020
14034
|
getLast: getLast$3,
|
|
14035
|
+
getNextNonSpaceNonCommentCharacterIndexWithStartIndex: getNextNonSpaceNonCommentCharacterIndexWithStartIndex,
|
|
14021
14036
|
getNextNonSpaceNonCommentCharacterIndex: getNextNonSpaceNonCommentCharacterIndex,
|
|
14022
14037
|
getNextNonSpaceNonCommentCharacter: getNextNonSpaceNonCommentCharacter,
|
|
14023
14038
|
skip: skip,
|
|
@@ -17157,7 +17172,7 @@ function genericPrint(path, options, print) {
|
|
|
17157
17172
|
return concat$4(["@", // If a Less file ends up being parsed with the SCSS parser, Less
|
|
17158
17173
|
// variable declarations will be parsed as at-rules with names ending
|
|
17159
17174
|
// with a colon, so keep the original case then.
|
|
17160
|
-
isDetachedRulesetCallNode(node) || node.name.endsWith(":") ? node.name : maybeToLowerCase(node.name), node.params ? concat$4([isDetachedRulesetCallNode(node) ? "" : isTemplatePlaceholderNode(node) ? node.raws.afterName : " ", path.call(print, "params")]) : "", node.selector ? indent$2(concat$4([" ", path.call(print, "selector")])) : "", node.value ? group$1(concat$4([" ", path.call(print, "value"), isSCSSControlDirectiveNode(node) ? hasParensAroundNode(node) ? " " : line$3 : ""])) : node.name === "else" ? " " : "", node.nodes ? concat$4([isSCSSControlDirectiveNode(node) ? "" : " ", "{", indent$2(concat$4([node.nodes.length > 0 ? softline$1 : "", printNodeSequence(path, options, print)])), softline$1, "}"]) : isTemplatePlaceholderNode(node) && !_parentNode.raws.semicolon && options.originalText[options.locEnd(node) - 1] !== ";" ? "" : ";"]);
|
|
17175
|
+
isDetachedRulesetCallNode(node) || node.name.endsWith(":") ? node.name : maybeToLowerCase(node.name), node.params ? concat$4([isDetachedRulesetCallNode(node) ? "" : isTemplatePlaceholderNode(node) && /^\s*\n/.test(node.raws.afterName) ? /^\s*\n\s*\n/.test(node.raws.afterName) ? concat$4([hardline$3, hardline$3]) : hardline$3 : " ", path.call(print, "params")]) : "", node.selector ? indent$2(concat$4([" ", path.call(print, "selector")])) : "", node.value ? group$1(concat$4([" ", path.call(print, "value"), isSCSSControlDirectiveNode(node) ? hasParensAroundNode(node) ? " " : line$3 : ""])) : node.name === "else" ? " " : "", node.nodes ? concat$4([isSCSSControlDirectiveNode(node) ? "" : " ", "{", indent$2(concat$4([node.nodes.length > 0 ? softline$1 : "", printNodeSequence(path, options, print)])), softline$1, "}"]) : isTemplatePlaceholderNode(node) && !_parentNode.raws.semicolon && options.originalText[options.locEnd(node) - 1] !== ";" ? "" : ";"]);
|
|
17161
17176
|
}
|
|
17162
17177
|
// postcss-media-query-parser
|
|
17163
17178
|
|
|
@@ -17459,7 +17474,7 @@ function genericPrint(path, options, print) {
|
|
|
17459
17474
|
|
|
17460
17475
|
|
|
17461
17476
|
if (isGridValue) {
|
|
17462
|
-
if (iNode.source.start.line !== iNextNode.source.start.line) {
|
|
17477
|
+
if (iNode.source && iNextNode.source && iNode.source.start.line !== iNextNode.source.start.line) {
|
|
17463
17478
|
_parts.push(hardline$3);
|
|
17464
17479
|
|
|
17465
17480
|
didBreak = true;
|
|
@@ -18999,33 +19014,47 @@ function mapObject(object, fn) {
|
|
|
18999
19014
|
return newObject;
|
|
19000
19015
|
}
|
|
19001
19016
|
|
|
19002
|
-
function
|
|
19003
|
-
|
|
19017
|
+
function shouldPreserveContent$1(node) {
|
|
19018
|
+
if (node.type === "element" && node.fullName === "template" && node.attrMap.lang && node.attrMap.lang !== "html") {
|
|
19019
|
+
return true;
|
|
19020
|
+
} // unterminated node in ie conditional comment
|
|
19021
|
+
// e.g. <!--[if lt IE 9]><html><![endif]-->
|
|
19004
19022
|
|
|
19005
|
-
|
|
19006
|
-
|
|
19023
|
+
|
|
19024
|
+
if (node.type === "ieConditionalComment" && node.lastChild && !node.lastChild.isSelfClosing && !node.lastChild.endSourceSpan) {
|
|
19025
|
+
return true;
|
|
19026
|
+
} // incomplete html in ie conditional comment
|
|
19027
|
+
// e.g. <!--[if lt IE 9]></div><![endif]-->
|
|
19028
|
+
|
|
19029
|
+
|
|
19030
|
+
if (node.type === "ieConditionalComment" && !node.complete) {
|
|
19031
|
+
return true;
|
|
19007
19032
|
} // TODO: handle non-text children in <pre>
|
|
19008
19033
|
|
|
19009
19034
|
|
|
19010
19035
|
if (isPreLikeNode$1(node) && node.children.some(function (child) {
|
|
19011
|
-
return child.type !== "text";
|
|
19036
|
+
return child.type !== "text" && child.type !== "interpolation";
|
|
19012
19037
|
})) {
|
|
19013
19038
|
return true;
|
|
19014
19039
|
}
|
|
19015
19040
|
|
|
19016
|
-
|
|
19041
|
+
return false;
|
|
19042
|
+
}
|
|
19017
19043
|
|
|
19018
|
-
|
|
19044
|
+
function hasPrettierIgnore$1(node) {
|
|
19045
|
+
if (node.type === "attribute" || node.type === "text") {
|
|
19019
19046
|
return false;
|
|
19020
19047
|
}
|
|
19021
19048
|
|
|
19022
|
-
|
|
19049
|
+
if (!node.parent) {
|
|
19050
|
+
return false;
|
|
19051
|
+
}
|
|
19023
19052
|
|
|
19024
|
-
if (typeof index !== "number" || index === 0) {
|
|
19053
|
+
if (typeof node.index !== "number" || node.index === 0) {
|
|
19025
19054
|
return false;
|
|
19026
19055
|
}
|
|
19027
19056
|
|
|
19028
|
-
var prevNode =
|
|
19057
|
+
var prevNode = node.parent.children[node.index - 1];
|
|
19029
19058
|
return isPrettierIgnore(prevNode);
|
|
19030
19059
|
}
|
|
19031
19060
|
|
|
@@ -19072,6 +19101,10 @@ function isLeadingSpaceSensitiveNode(node) {
|
|
|
19072
19101
|
return false;
|
|
19073
19102
|
}
|
|
19074
19103
|
|
|
19104
|
+
if ((node.type === "text" || node.type === "interpolation") && node.prev && (node.prev.type === "text" || node.prev.type === "interpolation")) {
|
|
19105
|
+
return true;
|
|
19106
|
+
}
|
|
19107
|
+
|
|
19075
19108
|
if (!node.parent || node.parent.cssDisplay === "none") {
|
|
19076
19109
|
return false;
|
|
19077
19110
|
}
|
|
@@ -19100,6 +19133,10 @@ function isTrailingSpaceSensitiveNode(node) {
|
|
|
19100
19133
|
return false;
|
|
19101
19134
|
}
|
|
19102
19135
|
|
|
19136
|
+
if ((node.type === "text" || node.type === "interpolation") && node.next && (node.next.type === "text" || node.next.type === "interpolation")) {
|
|
19137
|
+
return true;
|
|
19138
|
+
}
|
|
19139
|
+
|
|
19103
19140
|
if (!node.parent || node.parent.cssDisplay === "none") {
|
|
19104
19141
|
return false;
|
|
19105
19142
|
}
|
|
@@ -19166,7 +19203,7 @@ function isCustomElementWithSurroundingLineBreak(node) {
|
|
|
19166
19203
|
}
|
|
19167
19204
|
|
|
19168
19205
|
function isCustomElement(node) {
|
|
19169
|
-
return node.type === "element" && !node.namespace && node.name.includes("-");
|
|
19206
|
+
return node.type === "element" && !node.namespace && (node.name.includes("-") || /[A-Z]/.test(node.name[0]));
|
|
19170
19207
|
}
|
|
19171
19208
|
|
|
19172
19209
|
function hasSurroundingLineBreak(node) {
|
|
@@ -19470,6 +19507,10 @@ function identity(x) {
|
|
|
19470
19507
|
return x;
|
|
19471
19508
|
}
|
|
19472
19509
|
|
|
19510
|
+
function shouldNotPrintClosingTag$1(node) {
|
|
19511
|
+
return !node.isSelfClosing && !node.endSourceSpan && (hasPrettierIgnore$1(node) || shouldPreserveContent$1(node.parent));
|
|
19512
|
+
}
|
|
19513
|
+
|
|
19473
19514
|
var utils_1$3 = {
|
|
19474
19515
|
HTML_ELEMENT_ATTRIBUTES: HTML_ELEMENT_ATTRIBUTES,
|
|
19475
19516
|
HTML_TAGS: HTML_TAGS,
|
|
@@ -19499,7 +19540,9 @@ var utils_1$3 = {
|
|
|
19499
19540
|
preferHardlineAsLeadingSpaces: preferHardlineAsLeadingSpaces$1,
|
|
19500
19541
|
preferHardlineAsTrailingSpaces: preferHardlineAsTrailingSpaces,
|
|
19501
19542
|
replaceDocNewlines: replaceDocNewlines$1,
|
|
19502
|
-
replaceNewlines: replaceNewlines$1
|
|
19543
|
+
replaceNewlines: replaceNewlines$1,
|
|
19544
|
+
shouldNotPrintClosingTag: shouldNotPrintClosingTag$1,
|
|
19545
|
+
shouldPreserveContent: shouldPreserveContent$1
|
|
19503
19546
|
};
|
|
19504
19547
|
|
|
19505
19548
|
var canHaveInterpolation$1 = utils_1$3.canHaveInterpolation;
|
|
@@ -20370,6 +20413,8 @@ var normalizeParts = utils_1$3.normalizeParts;
|
|
|
20370
20413
|
var preferHardlineAsLeadingSpaces = utils_1$3.preferHardlineAsLeadingSpaces;
|
|
20371
20414
|
var replaceDocNewlines = utils_1$3.replaceDocNewlines;
|
|
20372
20415
|
var replaceNewlines = utils_1$3.replaceNewlines;
|
|
20416
|
+
var shouldNotPrintClosingTag = utils_1$3.shouldNotPrintClosingTag;
|
|
20417
|
+
var shouldPreserveContent = utils_1$3.shouldPreserveContent;
|
|
20373
20418
|
var insertPragma$5 = pragma$6.insertPragma;
|
|
20374
20419
|
var printVueFor = syntaxVue.printVueFor;
|
|
20375
20420
|
var printVueSlotScope = syntaxVue.printVueSlotScope;
|
|
@@ -20480,7 +20525,7 @@ function genericPrint$2(path, options, print) {
|
|
|
20480
20525
|
}) : isScriptLikeTag(node) && node.parent.type === "root" && options.parser === "vue" ? childrenDoc : indent$5(childrenDoc);
|
|
20481
20526
|
}(concat$8([shouldHugContent ? ifBreak$4(softline$4, "", {
|
|
20482
20527
|
groupId: attrGroupId
|
|
20483
|
-
}) : node.firstChild.type === "text" && node.firstChild.isWhitespaceSensitive && node.firstChild.isIndentationSensitive ? node.firstChild.value.indexOf("\n") === -1 ? "" : literalline$2 : node.firstChild.hasLeadingSpaces && node.firstChild.isLeadingSpaceSensitive ? line$6 : softline$4, printChildren(path, options, print)])), (node.next ? needsToBorrowPrevClosingTagEndMarker(node.next) : needsToBorrowLastChildClosingTagEndMarker(node.parent)) ? node.lastChild.hasTrailingSpaces && node.lastChild.isTrailingSpaceSensitive ? " " : "" : shouldHugContent ? ifBreak$4(softline$4, "", {
|
|
20528
|
+
}) : node.firstChild.type === "text" && node.firstChild.isWhitespaceSensitive && node.firstChild.isIndentationSensitive ? node.children.length === 1 && node.firstChild.type === "text" && node.firstChild.value.indexOf("\n") === -1 || node.firstChild.sourceSpan.start.line === node.lastChild.sourceSpan.end.line ? "" : literalline$2 : node.firstChild.hasLeadingSpaces && node.firstChild.isLeadingSpaceSensitive ? line$6 : softline$4, printChildren(path, options, print)])), (node.next ? needsToBorrowPrevClosingTagEndMarker(node.next) : needsToBorrowLastChildClosingTagEndMarker(node.parent)) ? node.lastChild.hasTrailingSpaces && node.lastChild.isTrailingSpaceSensitive ? " " : "" : shouldHugContent ? ifBreak$4(softline$4, "", {
|
|
20484
20529
|
groupId: attrGroupId
|
|
20485
20530
|
}) : node.lastChild.hasTrailingSpaces && node.lastChild.isTrailingSpaceSensitive ? line$6 : node.type === "element" && isPreLikeNode(node) && node.lastChild.type === "text" && (node.lastChild.value.indexOf("\n") === -1 || new RegExp("\\n\\s{".concat(options.tabWidth * countParents(path, function (n) {
|
|
20486
20531
|
return n.parent && n.parent.type !== "root";
|
|
@@ -20598,12 +20643,17 @@ function printChildren(path, options, print) {
|
|
|
20598
20643
|
}, "children"));
|
|
20599
20644
|
|
|
20600
20645
|
function printChild(childPath) {
|
|
20601
|
-
|
|
20602
|
-
|
|
20646
|
+
var child = childPath.getValue();
|
|
20647
|
+
|
|
20648
|
+
if (hasPrettierIgnore(child)) {
|
|
20649
|
+
return concat$8([].concat(printOpeningTagPrefix(child), replaceNewlines(options.originalText.slice(options.locStart(child) + (child.prev && needsToBorrowNextOpeningTagStartMarker(child.prev) ? printOpeningTagStartMarker(child).length : 0), options.locEnd(child) - (child.next && needsToBorrowPrevClosingTagEndMarker(child.next) ? printClosingTagEndMarker(child).length : 0)), literalline$2), printClosingTagSuffix(child)));
|
|
20603
20650
|
}
|
|
20604
20651
|
|
|
20605
|
-
|
|
20606
|
-
|
|
20652
|
+
if (shouldPreserveContent(child)) {
|
|
20653
|
+
return concat$8([].concat(printOpeningTagPrefix(child), group$8(printOpeningTag(childPath, options, print)), replaceNewlines(options.originalText.slice(child.startSourceSpan.end.offset - (child.firstChild && needsToBorrowParentOpeningTagEndMarker(child.firstChild) ? printOpeningTagEndMarker(child).length : 0), child.endSourceSpan.start.offset + (child.lastChild && needsToBorrowParentClosingTagStartMarker(child.lastChild) ? printClosingTagStartMarker(child).length : 0)), literalline$2), printClosingTag(child), printClosingTagSuffix(child)));
|
|
20654
|
+
}
|
|
20655
|
+
|
|
20656
|
+
return print(childPath);
|
|
20607
20657
|
}
|
|
20608
20658
|
|
|
20609
20659
|
function printBetweenLine(prevNode, nextNode) {
|
|
@@ -20661,7 +20711,7 @@ function printOpeningTag(path, options, print) {
|
|
|
20661
20711
|
};
|
|
20662
20712
|
return path.map(function (attrPath) {
|
|
20663
20713
|
var attr = attrPath.getValue();
|
|
20664
|
-
return hasPrettierIgnoreAttribute(attr) ? options.originalText.slice(options.locStart(attr), options.locEnd(attr)) : print(attrPath);
|
|
20714
|
+
return hasPrettierIgnoreAttribute(attr) ? concat$8(replaceNewlines(options.originalText.slice(options.locStart(attr), options.locEnd(attr)), literalline$2)) : print(attrPath);
|
|
20665
20715
|
}, "attrs");
|
|
20666
20716
|
}(node.prev && node.prev.type === "comment" && getPrettierIgnoreAttributeCommentData(node.prev.value)))])),
|
|
20667
20717
|
/**
|
|
@@ -20807,6 +20857,10 @@ function printOpeningTagEndMarker(node) {
|
|
|
20807
20857
|
function printClosingTagStartMarker(node) {
|
|
20808
20858
|
assert$3(!node.isSelfClosing);
|
|
20809
20859
|
|
|
20860
|
+
if (shouldNotPrintClosingTag(node)) {
|
|
20861
|
+
return "";
|
|
20862
|
+
}
|
|
20863
|
+
|
|
20810
20864
|
switch (node.type) {
|
|
20811
20865
|
case "ieConditionalComment":
|
|
20812
20866
|
return "<!";
|
|
@@ -20817,6 +20871,10 @@ function printClosingTagStartMarker(node) {
|
|
|
20817
20871
|
}
|
|
20818
20872
|
|
|
20819
20873
|
function printClosingTagEndMarker(node) {
|
|
20874
|
+
if (shouldNotPrintClosingTag(node)) {
|
|
20875
|
+
return "";
|
|
20876
|
+
}
|
|
20877
|
+
|
|
20820
20878
|
switch (node.type) {
|
|
20821
20879
|
case "comment":
|
|
20822
20880
|
return "-->";
|
|
@@ -20919,7 +20977,8 @@ function printEmbeddedAttributeValue(node, originalTextToDoc, options) {
|
|
|
20919
20977
|
// copied from https://github.com/vuejs/vue/blob/v2.5.17/src/compiler/codegen/events.js#L3-L4
|
|
20920
20978
|
var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/;
|
|
20921
20979
|
var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
|
|
20922
|
-
var value = getValue()
|
|
20980
|
+
var value = getValue() // https://github.com/vuejs/vue/blob/v2.5.17/src/compiler/helpers.js#L104
|
|
20981
|
+
.trim();
|
|
20923
20982
|
return printMaybeHug(simplePathRE.test(value) || fnExpRE.test(value) ? textToDoc(value, {
|
|
20924
20983
|
parser: "__js_expression"
|
|
20925
20984
|
}) : stripTrailingHardline$1(textToDoc(value, {
|
|
@@ -22116,8 +22175,19 @@ function handleLastFunctionArgComments(text, precedingNode, enclosingNode, follo
|
|
|
22116
22175
|
}
|
|
22117
22176
|
|
|
22118
22177
|
if (enclosingNode && enclosingNode.type === "FunctionDeclaration" && followingNode && followingNode.type === "BlockStatement") {
|
|
22119
|
-
|
|
22120
|
-
|
|
22178
|
+
var functionParamRightParenIndex = function () {
|
|
22179
|
+
if (enclosingNode.params.length !== 0) {
|
|
22180
|
+
return util.getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, options.locEnd(util.getLast(enclosingNode.params)));
|
|
22181
|
+
}
|
|
22182
|
+
|
|
22183
|
+
var functionParamLeftParenIndex = util.getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, options.locEnd(enclosingNode.id));
|
|
22184
|
+
return util.getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, functionParamLeftParenIndex + 1);
|
|
22185
|
+
}();
|
|
22186
|
+
|
|
22187
|
+
if (options.locStart(comment) > functionParamRightParenIndex) {
|
|
22188
|
+
addBlockStatementFirstComment(followingNode, comment);
|
|
22189
|
+
return true;
|
|
22190
|
+
}
|
|
22121
22191
|
}
|
|
22122
22192
|
|
|
22123
22193
|
return false;
|
|
@@ -22719,6 +22789,7 @@ function needsParens(path, options) {
|
|
|
22719
22789
|
case "SpreadProperty":
|
|
22720
22790
|
case "BinaryExpression":
|
|
22721
22791
|
case "LogicalExpression":
|
|
22792
|
+
case "NGPipeExpression":
|
|
22722
22793
|
case "ExportDefaultDeclaration":
|
|
22723
22794
|
case "AwaitExpression":
|
|
22724
22795
|
case "JSXSpreadAttribute":
|
|
@@ -22981,13 +23052,14 @@ function genericPrint$3(path, options, printPath, args) {
|
|
|
22981
23052
|
var parentExportDecl = getParentExportDeclaration$1(path);
|
|
22982
23053
|
var decorators = [];
|
|
22983
23054
|
|
|
22984
|
-
if (node.
|
|
23055
|
+
if (node.type === "ClassMethod" || node.type === "ClassProperty" || node.type === "TSAbstractClassProperty" || node.type === "ClassPrivateProperty") {// their decorators are handled themselves
|
|
23056
|
+
} else if (node.decorators && node.decorators.length > 0 && // If the parent node is an export declaration and the decorator
|
|
22985
23057
|
// was written before the export, the export will be responsible
|
|
22986
23058
|
// for printing the decorators.
|
|
22987
23059
|
!(parentExportDecl && options.locStart(parentExportDecl, {
|
|
22988
23060
|
ignoreDecorators: true
|
|
22989
23061
|
}) > options.locStart(node.decorators[0]))) {
|
|
22990
|
-
var shouldBreak = node.type === "
|
|
23062
|
+
var shouldBreak = node.type === "ClassExpression" || node.type === "ClassDeclaration" || hasNewlineBetweenOrAfterDecorators(node, options);
|
|
22991
23063
|
var separator = shouldBreak ? hardline$8 : line$8;
|
|
22992
23064
|
path.each(function (decoratorPath) {
|
|
22993
23065
|
var decorator = decoratorPath.getValue();
|
|
@@ -23050,6 +23122,15 @@ function genericPrint$3(path, options, printPath, args) {
|
|
|
23050
23122
|
return concat$12(parts);
|
|
23051
23123
|
}
|
|
23052
23124
|
|
|
23125
|
+
function hasNewlineBetweenOrAfterDecorators(node, options) {
|
|
23126
|
+
return hasNewlineInRange$1(options.originalText, options.locStart(node.decorators[0]), options.locEnd(getLast$4(node.decorators))) || hasNewline$3(options.originalText, options.locEnd(getLast$4(node.decorators)));
|
|
23127
|
+
}
|
|
23128
|
+
|
|
23129
|
+
function printDecorators(path, options, print) {
|
|
23130
|
+
var node = path.getValue();
|
|
23131
|
+
return group$10(concat$12([join$7(line$8, path.map(print, "decorators")), hasNewlineBetweenOrAfterDecorators(node, options) ? hardline$8 : line$8]));
|
|
23132
|
+
}
|
|
23133
|
+
|
|
23053
23134
|
function hasPrettierIgnore$2(path) {
|
|
23054
23135
|
return hasIgnoreComment$3(path) || hasJsxIgnoreComment(path);
|
|
23055
23136
|
}
|
|
@@ -23740,7 +23821,7 @@ function printPathNoParens(path, options, print, args) {
|
|
|
23740
23821
|
parts.push(n.abstract ? "abstract " : "", printTypeScriptModifiers(path, options, print), "interface ", path.call(print, "id"), n.typeParameters ? path.call(print, "typeParameters") : "", " ");
|
|
23741
23822
|
|
|
23742
23823
|
if (n.heritage.length) {
|
|
23743
|
-
parts.push(group$10(indent$6(concat$12([softline$5, "extends ", indent$6(join$7(concat$12([",", line$8]), path.map(print, "heritage"))), " "]))));
|
|
23824
|
+
parts.push(group$10(indent$6(concat$12([softline$5, "extends ", (n.heritage.length === 1 ? identity$1 : indent$6)(join$7(concat$12([",", line$8]), path.map(print, "heritage"))), " "]))));
|
|
23744
23825
|
}
|
|
23745
23826
|
|
|
23746
23827
|
parts.push(path.call(print, "body"));
|
|
@@ -23781,10 +23862,10 @@ function printPathNoParens(path, options, print, args) {
|
|
|
23781
23862
|
|
|
23782
23863
|
var _parent3 = path.getParentNode(0);
|
|
23783
23864
|
|
|
23784
|
-
var
|
|
23865
|
+
var isFlowInterfaceLikeBody = isTypeAnnotation && _parent3 && (_parent3.type === "InterfaceDeclaration" || _parent3.type === "DeclareInterface" || _parent3.type === "DeclareClass") && path.getName() === "body";
|
|
23866
|
+
var shouldBreak = n.type === "TSInterfaceBody" || isFlowInterfaceLikeBody || n.type === "ObjectPattern" && _parent3.type !== "FunctionDeclaration" && _parent3.type !== "FunctionExpression" && _parent3.type !== "ArrowFunctionExpression" && _parent3.type !== "AssignmentPattern" && _parent3.type !== "CatchClause" && n.properties.some(function (property) {
|
|
23785
23867
|
return property.value && (property.value.type === "ObjectPattern" || property.value.type === "ArrayPattern");
|
|
23786
23868
|
}) || n.type !== "ObjectPattern" && firstProperty && hasNewlineInRange$1(options.originalText, options.locStart(n), options.locStart(firstProperty));
|
|
23787
|
-
var isFlowInterfaceLikeBody = isTypeAnnotation && _parent3 && (_parent3.type === "InterfaceDeclaration" || _parent3.type === "DeclareInterface" || _parent3.type === "DeclareClass") && path.getName() === "body";
|
|
23788
23869
|
var separator = isFlowInterfaceLikeBody ? ";" : n.type === "TSInterfaceBody" || n.type === "TSTypeLiteral" ? ifBreak$6(semi, ";") : ",";
|
|
23789
23870
|
var leftBrace = n.exact ? "{|" : "{";
|
|
23790
23871
|
var rightBrace = n.exact ? "|}" : "}"; // Unfortunately, things are grouped together in the ast can be
|
|
@@ -23878,6 +23959,10 @@ function printPathNoParens(path, options, print, args) {
|
|
|
23878
23959
|
// Babel 6
|
|
23879
23960
|
|
|
23880
23961
|
case "ClassMethod":
|
|
23962
|
+
if (n.decorators && n.decorators.length !== 0) {
|
|
23963
|
+
parts.push(printDecorators(path, options, print));
|
|
23964
|
+
}
|
|
23965
|
+
|
|
23881
23966
|
if (n.static) {
|
|
23882
23967
|
parts.push("static ");
|
|
23883
23968
|
}
|
|
@@ -24396,6 +24481,10 @@ function printPathNoParens(path, options, print, args) {
|
|
|
24396
24481
|
case "TSAbstractClassProperty":
|
|
24397
24482
|
case "ClassPrivateProperty":
|
|
24398
24483
|
{
|
|
24484
|
+
if (n.decorators && n.decorators.length !== 0) {
|
|
24485
|
+
parts.push(printDecorators(path, options, print));
|
|
24486
|
+
}
|
|
24487
|
+
|
|
24399
24488
|
if (n.accessibility) {
|
|
24400
24489
|
parts.push(n.accessibility + " ");
|
|
24401
24490
|
}
|
|
@@ -24763,7 +24852,7 @@ function printPathNoParens(path, options, print, args) {
|
|
|
24763
24852
|
}
|
|
24764
24853
|
|
|
24765
24854
|
if (n["extends"].length > 0) {
|
|
24766
|
-
parts.push(group$10(indent$6(concat$12([line$8, "extends ", indent$6(join$7(concat$12([",", line$8]), path.map(print, "extends")))]))));
|
|
24855
|
+
parts.push(group$10(indent$6(concat$12([line$8, "extends ", (n.extends.length === 1 ? identity$1 : indent$6)(join$7(concat$12([",", line$8]), path.map(print, "extends")))]))));
|
|
24767
24856
|
}
|
|
24768
24857
|
|
|
24769
24858
|
parts.push(" ", path.call(print, "body"));
|
|
@@ -25306,13 +25395,14 @@ function printPathNoParens(path, options, print, args) {
|
|
|
25306
25395
|
parts.push("declare ");
|
|
25307
25396
|
}
|
|
25308
25397
|
|
|
25309
|
-
parts.push(printTypeScriptModifiers(path, options, print));
|
|
25398
|
+
parts.push(printTypeScriptModifiers(path, options, print));
|
|
25399
|
+
var textBetweenNodeAndItsId = options.originalText.slice(options.locStart(n), options.locStart(n.id)); // Global declaration looks like this:
|
|
25310
25400
|
// (declare)? global { ... }
|
|
25311
25401
|
|
|
25312
|
-
var isGlobalDeclaration = n.id.type === "Identifier" && n.id.name === "global" && !/namespace|module/.test(
|
|
25402
|
+
var isGlobalDeclaration = n.id.type === "Identifier" && n.id.name === "global" && !/namespace|module/.test(textBetweenNodeAndItsId);
|
|
25313
25403
|
|
|
25314
25404
|
if (!isGlobalDeclaration) {
|
|
25315
|
-
parts.push(isExternalModule ? "module " : "namespace ");
|
|
25405
|
+
parts.push(isExternalModule || /\smodule\s/.test(textBetweenNodeAndItsId) ? "module " : "namespace ");
|
|
25316
25406
|
}
|
|
25317
25407
|
}
|
|
25318
25408
|
|
|
@@ -25595,7 +25685,8 @@ var functionCompositionFunctionNames = new Set(["pipe", // RxJS, Ramda
|
|
|
25595
25685
|
"composeK", // Ramda
|
|
25596
25686
|
"flow", // Lodash
|
|
25597
25687
|
"flowRight", // Lodash
|
|
25598
|
-
"connect" // Redux
|
|
25688
|
+
"connect", // Redux
|
|
25689
|
+
"createSelector" // Reselect
|
|
25599
25690
|
]);
|
|
25600
25691
|
|
|
25601
25692
|
function isFunctionCompositionFunction(node) {
|
|
@@ -27345,7 +27436,7 @@ function isTestCall(n, parent) {
|
|
|
27345
27436
|
return false;
|
|
27346
27437
|
}
|
|
27347
27438
|
|
|
27348
|
-
return isFunctionOrArrowExpression(n.arguments[1]) && n.arguments[1].params.length <= 1 || isAngularTestWrapper(n.arguments[1]);
|
|
27439
|
+
return (n.arguments.length === 2 ? isFunctionOrArrowExpression(n.arguments[1]) : isFunctionOrArrowExpressionWithBody(n.arguments[1]) && n.arguments[1].params.length <= 1) || isAngularTestWrapper(n.arguments[1]);
|
|
27349
27440
|
}
|
|
27350
27441
|
}
|
|
27351
27442
|
|
|
@@ -27370,13 +27461,17 @@ function isFunctionOrArrowExpression(node) {
|
|
|
27370
27461
|
return node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression";
|
|
27371
27462
|
}
|
|
27372
27463
|
|
|
27464
|
+
function isFunctionOrArrowExpressionWithBody(node) {
|
|
27465
|
+
return node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression" && node.body.type === "BlockStatement";
|
|
27466
|
+
}
|
|
27467
|
+
|
|
27373
27468
|
function isUnitTestSetUp(n) {
|
|
27374
27469
|
var unitTestSetUpRe = /^(before|after)(Each|All)$/;
|
|
27375
27470
|
return n.callee.type === "Identifier" && unitTestSetUpRe.test(n.callee.name) && n.arguments.length === 1;
|
|
27376
27471
|
}
|
|
27377
27472
|
|
|
27378
27473
|
function isTheOnlyJSXElementInMarkdown(options, path) {
|
|
27379
|
-
if (options.parentParser !== "markdown") {
|
|
27474
|
+
if (options.parentParser !== "markdown" && options.parentParser !== "mdx") {
|
|
27380
27475
|
return false;
|
|
27381
27476
|
}
|
|
27382
27477
|
|
|
@@ -27461,6 +27556,10 @@ function rawText(node) {
|
|
|
27461
27556
|
return node.extra ? node.extra.raw : node.raw;
|
|
27462
27557
|
}
|
|
27463
27558
|
|
|
27559
|
+
function identity$1(x) {
|
|
27560
|
+
return x;
|
|
27561
|
+
}
|
|
27562
|
+
|
|
27464
27563
|
var printerEstree = {
|
|
27465
27564
|
preprocess: preprocess_1$2,
|
|
27466
27565
|
print: genericPrint$3,
|
|
@@ -27937,7 +28036,7 @@ var languageJs = {
|
|
|
27937
28036
|
printers: printers$4
|
|
27938
28037
|
};
|
|
27939
28038
|
|
|
27940
|
-
const json$9 = {"cjkPattern":"[\\u1100-\\u11ff\\u2e80-\\u2e99\\u2e9b-\\u2ef3\\u2f00-\\u2fd5\\u3000-\\u303f\\u3041-\\u3096\\u309d-\\u309f\\u30a1-\\u30fa\\
|
|
28039
|
+
const json$9 = {"cjkPattern":"[\\u1100-\\u11ff\\u2e80-\\u2e99\\u2e9b-\\u2ef3\\u2f00-\\u2fd5\\u3000-\\u303f\\u3041-\\u3096\\u309d-\\u309f\\u30a1-\\u30fa\\u30fc-\\u30ff\\u3105-\\u312e\\u3131-\\u318e\\u3190-\\u3191\\u3196-\\u31ba\\u31c0-\\u31e3\\u31f0-\\u321e\\u322a-\\u3247\\u3260-\\u327e\\u328a-\\u32b0\\u32c0-\\u32cb\\u32d0-\\u32fe\\u3300-\\u3370\\u337b-\\u337f\\u33e0-\\u33fe\\u3400-\\u4db5\\u4e00-\\u9fea\\ua960-\\ua97c\\uac00-\\ud7a3\\ud7b0-\\ud7c6\\ud7cb-\\ud7fb\\uf900-\\ufa6d\\ufa70-\\ufad9\\ufe10-\\ufe1f\\ufe30-\\ufe6f\\uff00-\\uffef]|[\\ud840-\\ud868\\ud86a-\\ud86c\\ud86f-\\ud872\\ud874-\\ud879][\\udc00-\\udfff]|\\ud82c[\\udc00-\\udd1e]|\\ud83c[\\ude00\\ude50-\\ude51]|\\ud869[\\udc00-\\uded6\\udf00-\\udfff]|\\ud86d[\\udc00-\\udf34\\udf40-\\udfff]|\\ud86e[\\udc00-\\udc1d\\udc20-\\udfff]|\\ud873[\\udc00-\\udea1\\udeb0-\\udfff]|\\ud87a[\\udc00-\\udfe0]|\\ud87e[\\udc00-\\ude1d]","kPattern":"[\\u1100-\\u11ff\\u3001-\\u3003\\u3008-\\u3011\\u3013-\\u301f\\u302e-\\u3030\\u3037\\u30fb\\u3131-\\u318e\\u3200-\\u321e\\u3260-\\u327e\\ua960-\\ua97c\\uac00-\\ud7a3\\ud7b0-\\ud7c6\\ud7cb-\\ud7fb\\ufe45-\\ufe46\\uff61-\\uff65\\uffa0-\\uffbe\\uffc2-\\uffc7\\uffca-\\uffcf\\uffd2-\\uffd7\\uffda-\\uffdc]","punctuationPattern":"[\\u0021-\\u002f\\u003a-\\u0040\\u005b-\\u0060\\u007b-\\u007e\\u00a1\\u00a7\\u00ab\\u00b6-\\u00b7\\u00bb\\u00bf\\u037e\\u0387\\u055a-\\u055f\\u0589-\\u058a\\u05be\\u05c0\\u05c3\\u05c6\\u05f3-\\u05f4\\u0609-\\u060a\\u060c-\\u060d\\u061b\\u061e-\\u061f\\u066a-\\u066d\\u06d4\\u0700-\\u070d\\u07f7-\\u07f9\\u0830-\\u083e\\u085e\\u0964-\\u0965\\u0970\\u09fd\\u0af0\\u0df4\\u0e4f\\u0e5a-\\u0e5b\\u0f04-\\u0f12\\u0f14\\u0f3a-\\u0f3d\\u0f85\\u0fd0-\\u0fd4\\u0fd9-\\u0fda\\u104a-\\u104f\\u10fb\\u1360-\\u1368\\u1400\\u166d-\\u166e\\u169b-\\u169c\\u16eb-\\u16ed\\u1735-\\u1736\\u17d4-\\u17d6\\u17d8-\\u17da\\u1800-\\u180a\\u1944-\\u1945\\u1a1e-\\u1a1f\\u1aa0-\\u1aa6\\u1aa8-\\u1aad\\u1b5a-\\u1b60\\u1bfc-\\u1bff\\u1c3b-\\u1c3f\\u1c7e-\\u1c7f\\u1cc0-\\u1cc7\\u1cd3\\u2010-\\u2027\\u2030-\\u2043\\u2045-\\u2051\\u2053-\\u205e\\u207d-\\u207e\\u208d-\\u208e\\u2308-\\u230b\\u2329-\\u232a\\u2768-\\u2775\\u27c5-\\u27c6\\u27e6-\\u27ef\\u2983-\\u2998\\u29d8-\\u29db\\u29fc-\\u29fd\\u2cf9-\\u2cfc\\u2cfe-\\u2cff\\u2d70\\u2e00-\\u2e2e\\u2e30-\\u2e49\\u3001-\\u3003\\u3008-\\u3011\\u3014-\\u301f\\u3030\\u303d\\u30a0\\u30fb\\ua4fe-\\ua4ff\\ua60d-\\ua60f\\ua673\\ua67e\\ua6f2-\\ua6f7\\ua874-\\ua877\\ua8ce-\\ua8cf\\ua8f8-\\ua8fa\\ua8fc\\ua92e-\\ua92f\\ua95f\\ua9c1-\\ua9cd\\ua9de-\\ua9df\\uaa5c-\\uaa5f\\uaade-\\uaadf\\uaaf0-\\uaaf1\\uabeb\\ufd3e-\\ufd3f\\ufe10-\\ufe19\\ufe30-\\ufe52\\ufe54-\\ufe61\\ufe63\\ufe68\\ufe6a-\\ufe6b\\uff01-\\uff03\\uff05-\\uff0a\\uff0c-\\uff0f\\uff1a-\\uff1b\\uff1f-\\uff20\\uff3b-\\uff3d\\uff3f\\uff5b\\uff5d\\uff5f-\\uff65]|\\ud800[\\udd00-\\udd02\\udf9f\\udfd0]|\\ud801[\\udd6f]|\\ud802[\\udc57\\udd1f\\udd3f\\ude50-\\ude58\\ude7f\\udef0-\\udef6\\udf39-\\udf3f\\udf99-\\udf9c]|\\ud804[\\udc47-\\udc4d\\udcbb-\\udcbc\\udcbe-\\udcc1\\udd40-\\udd43\\udd74-\\udd75\\uddc5-\\uddc9\\uddcd\\udddb\\udddd-\\udddf\\ude38-\\ude3d\\udea9]|\\ud805[\\udc4b-\\udc4f\\udc5b\\udc5d\\udcc6\\uddc1-\\uddd7\\ude41-\\ude43\\ude60-\\ude6c\\udf3c-\\udf3e]|\\ud806[\\ude3f-\\ude46\\ude9a-\\ude9c\\ude9e-\\udea2]|\\ud807[\\udc41-\\udc45\\udc70-\\udc71]|\\ud809[\\udc70-\\udc74]|\\ud81a[\\ude6e-\\ude6f\\udef5\\udf37-\\udf3b\\udf44]|\\ud82f[\\udc9f]|\\ud836[\\ude87-\\ude8b]|\\ud83a[\\udd5e-\\udd5f]"};
|
|
27941
28040
|
|
|
27942
28041
|
var cjkPattern = json$9.cjkPattern;
|
|
27943
28042
|
var kPattern = json$9.kPattern;
|
|
@@ -27945,10 +28044,10 @@ var punctuationPattern$1 = json$9.punctuationPattern;
|
|
|
27945
28044
|
var getLast$5 = util.getLast;
|
|
27946
28045
|
var kRegex = new RegExp(kPattern);
|
|
27947
28046
|
var punctuationRegex = new RegExp(punctuationPattern$1);
|
|
27948
|
-
/**
|
|
27949
|
-
* split text into whitespaces and words
|
|
27950
|
-
* @param {string} text
|
|
27951
|
-
* @return {Array<{ type: "whitespace", value: " " | "\n" | "" } | { type: "word", value: string }>}
|
|
28047
|
+
/**
|
|
28048
|
+
* split text into whitespaces and words
|
|
28049
|
+
* @param {string} text
|
|
28050
|
+
* @return {Array<{ type: "whitespace", value: " " | "\n" | "" } | { type: "word", value: string }>}
|
|
27952
28051
|
*/
|
|
27953
28052
|
|
|
27954
28053
|
function splitText$1(text, options) {
|
|
@@ -28058,7 +28157,7 @@ function getFencedCodeBlockValue$2(node, originalText) {
|
|
|
28058
28157
|
var text = originalText.slice(node.position.start.offset, node.position.end.offset);
|
|
28059
28158
|
var leadingSpaceCount = text.match(/^\s*/)[0].length;
|
|
28060
28159
|
var replaceRegex = new RegExp("^\\s{0,".concat(leadingSpaceCount, "}"));
|
|
28061
|
-
var lineContents = text.split("\n");
|
|
28160
|
+
var lineContents = text.replace(/\r\n?/g, "\n").split("\n");
|
|
28062
28161
|
var markerStyle = text[leadingSpaceCount]; // ` or ~
|
|
28063
28162
|
|
|
28064
28163
|
var marker = text.slice(leadingSpaceCount).match(new RegExp("^[".concat(markerStyle, "]+")))[0]; // https://spec.commonmark.org/0.28/#example-104: Closing fences may be indented by 0-3 spaces
|
|
@@ -28599,7 +28698,7 @@ function genericPrint$5(path, options, print) {
|
|
|
28599
28698
|
if (node.isIndented) {
|
|
28600
28699
|
// indented code block
|
|
28601
28700
|
var alignment = " ".repeat(4);
|
|
28602
|
-
return align$2(alignment, concat$16([alignment,
|
|
28701
|
+
return align$2(alignment, concat$16([alignment, replaceNewlinesWith(node.value, hardline$11)]));
|
|
28603
28702
|
} // fenced code block
|
|
28604
28703
|
|
|
28605
28704
|
|
|
@@ -28607,7 +28706,7 @@ function genericPrint$5(path, options, print) {
|
|
|
28607
28706
|
|
|
28608
28707
|
var _style2 = styleUnit.repeat(Math.max(3, util.getMaxContinuousCount(node.value, styleUnit) + 1));
|
|
28609
28708
|
|
|
28610
|
-
return concat$16([_style2, node.lang || "", hardline$11,
|
|
28709
|
+
return concat$16([_style2, node.lang || "", hardline$11, replaceNewlinesWith(getFencedCodeBlockValue(node, options.originalText), hardline$11), hardline$11, _style2]);
|
|
28611
28710
|
}
|
|
28612
28711
|
|
|
28613
28712
|
case "yaml":
|
|
@@ -28763,7 +28862,7 @@ function getNthListSiblingIndex(node, parentNode) {
|
|
|
28763
28862
|
}
|
|
28764
28863
|
|
|
28765
28864
|
function replaceNewlinesWith(str, doc$$2) {
|
|
28766
|
-
return join$11(doc$$2, str.split("\n"));
|
|
28865
|
+
return join$11(doc$$2, str.replace(/\r\n?/g, "\n").split("\n"));
|
|
28767
28866
|
}
|
|
28768
28867
|
|
|
28769
28868
|
function getNthSiblingIndex(node, parentNode, condition) {
|