prettier 1.16.4 → 1.17.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/bin-prettier.js +602 -483
- package/doc.js +1935 -0
- package/index.js +601 -482
- package/package.json +1 -4
- package/parser-babylon.js +1 -1
- package/parser-flow.js +1 -1
- package/parser-graphql.js +1 -1
- package/parser-html.js +1 -1
- package/parser-typescript.js +1 -1
- package/standalone.js +229 -141
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.
|
|
8
|
+
var version$1 = "1.17.0";
|
|
9
9
|
var description = "Prettier is an opinionated code formatter";
|
|
10
10
|
var bin = {
|
|
11
11
|
"prettier": "./bin/prettier.js"
|
|
@@ -19,11 +19,12 @@ var engines = {
|
|
|
19
19
|
"node": ">=6"
|
|
20
20
|
};
|
|
21
21
|
var dependencies = {
|
|
22
|
-
"@angular/compiler": "
|
|
23
|
-
"@babel/code-frame": "7.0.0
|
|
22
|
+
"@angular/compiler": "7.2.9",
|
|
23
|
+
"@babel/code-frame": "7.0.0",
|
|
24
24
|
"@babel/parser": "7.2.0",
|
|
25
25
|
"@glimmer/syntax": "0.30.3",
|
|
26
26
|
"@iarna/toml": "2.0.0",
|
|
27
|
+
"@typescript-eslint/typescript-estree": "1.6.0",
|
|
27
28
|
"angular-estree-parser": "1.1.5",
|
|
28
29
|
"angular-html-parser": "1.2.0",
|
|
29
30
|
"camelcase": "4.1.0",
|
|
@@ -42,11 +43,11 @@ var dependencies = {
|
|
|
42
43
|
"flow-parser": "0.84.0",
|
|
43
44
|
"get-stream": "3.0.0",
|
|
44
45
|
"globby": "6.1.0",
|
|
45
|
-
"graphql": "
|
|
46
|
+
"graphql": "14.2.0",
|
|
46
47
|
"html-element-attributes": "2.0.0",
|
|
47
48
|
"html-styles": "1.0.0",
|
|
48
49
|
"html-tag-names": "1.1.2",
|
|
49
|
-
"ignore": "
|
|
50
|
+
"ignore": "4.0.6",
|
|
50
51
|
"is-ci": "2.0.0",
|
|
51
52
|
"jest-docblock": "23.2.0",
|
|
52
53
|
"json-stable-stringify": "1.0.1",
|
|
@@ -71,8 +72,7 @@ var dependencies = {
|
|
|
71
72
|
"resolve": "1.5.0",
|
|
72
73
|
"semver": "5.4.1",
|
|
73
74
|
"string-width": "3.0.0",
|
|
74
|
-
"typescript": "3.
|
|
75
|
-
"typescript-estree": "18.0.0",
|
|
75
|
+
"typescript": "3.4.1",
|
|
76
76
|
"unicode-regex": "2.0.0",
|
|
77
77
|
"unified": "6.1.6",
|
|
78
78
|
"vnopts": "1.0.2",
|
|
@@ -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.16.
|
|
104
|
+
"prettier": "1.16.4",
|
|
105
105
|
"prettylint": "1.0.0",
|
|
106
106
|
"rimraf": "2.6.2",
|
|
107
107
|
"rollup": "0.47.6",
|
|
@@ -120,9 +120,6 @@ var devDependencies = {
|
|
|
120
120
|
"tempy": "0.2.1",
|
|
121
121
|
"webpack": "3.12.0"
|
|
122
122
|
};
|
|
123
|
-
var resolutions = {
|
|
124
|
-
"@babel/code-frame": "7.0.0-beta.46"
|
|
125
|
-
};
|
|
126
123
|
var scripts = {
|
|
127
124
|
"prepublishOnly": "echo \"Error: must publish from dist/\" && exit 1",
|
|
128
125
|
"prepare-release": "yarn && yarn build && yarn test:dist",
|
|
@@ -152,7 +149,6 @@ var _package = {
|
|
|
152
149
|
engines: engines,
|
|
153
150
|
dependencies: dependencies,
|
|
154
151
|
devDependencies: devDependencies,
|
|
155
|
-
resolutions: resolutions,
|
|
156
152
|
scripts: scripts
|
|
157
153
|
};
|
|
158
154
|
|
|
@@ -169,7 +165,6 @@ var _package$1 = Object.freeze({
|
|
|
169
165
|
engines: engines,
|
|
170
166
|
dependencies: dependencies,
|
|
171
167
|
devDependencies: devDependencies,
|
|
172
|
-
resolutions: resolutions,
|
|
173
168
|
scripts: scripts,
|
|
174
169
|
default: _package
|
|
175
170
|
});
|
|
@@ -6318,6 +6313,10 @@ var options$2 = {
|
|
|
6318
6313
|
value: "angular",
|
|
6319
6314
|
since: "1.15.0",
|
|
6320
6315
|
description: "Angular"
|
|
6316
|
+
}, {
|
|
6317
|
+
value: "lwc",
|
|
6318
|
+
since: "1.17.0",
|
|
6319
|
+
description: "Lightning Web Components"
|
|
6321
6320
|
}]
|
|
6322
6321
|
},
|
|
6323
6322
|
plugins: {
|
|
@@ -11332,19 +11331,20 @@ var loc = {
|
|
|
11332
11331
|
};
|
|
11333
11332
|
|
|
11334
11333
|
var jsTokens = createCommonjsModule(function (module, exports) {
|
|
11335
|
-
// Copyright 2014, 2015, 2016, 2017 Simon Lydell
|
|
11334
|
+
// Copyright 2014, 2015, 2016, 2017, 2018 Simon Lydell
|
|
11336
11335
|
// License: MIT. (See LICENSE.)
|
|
11337
11336
|
Object.defineProperty(exports, "__esModule", {
|
|
11338
11337
|
value: true
|
|
11339
11338
|
}); // This regex comes from regex.coffee, and is inserted here by generate-index.js
|
|
11340
11339
|
// (run `npm run build`).
|
|
11341
11340
|
|
|
11342
|
-
exports.default = /((['"])(?:(?!\2|\\).|\\(?:\r\n|[\s\S]))*(\2)?|`(?:[^`\\$]|\\[\s\S]|\$(?!\{)|\$\{(?:[^{}]|\{[^}]*\}?)*\}?)*(`)?)|(\/\/.*)|(\/\*(?:[^*]|\*(?!\/))*(\*\/)?)|(\/(?!\*)(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\]\\]).|\\.)+\/(?:(?!\s*(?:\b|[\u0080-\uFFFF$\\'"~({]|[+\-!](?!=)|\.?\d))|[
|
|
11341
|
+
exports.default = /((['"])(?:(?!\2|\\).|\\(?:\r\n|[\s\S]))*(\2)?|`(?:[^`\\$]|\\[\s\S]|\$(?!\{)|\$\{(?:[^{}]|\{[^}]*\}?)*\}?)*(`)?)|(\/\/.*)|(\/\*(?:[^*]|\*(?!\/))*(\*\/)?)|(\/(?!\*)(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\]\\]).|\\.)+\/(?:(?!\s*(?:\b|[\u0080-\uFFFF$\\'"~({]|[+\-!](?!=)|\.?\d))|[gmiyus]{1,6}\b(?![\u0080-\uFFFF$\\]|\s*(?:[+\-*%&|^<>!=?({]|\/(?![\/*])))))|(0[xX][\da-fA-F]+|0[oO][0-7]+|0[bB][01]+|(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?)|((?!\d)(?:(?!\s)[$\w\u0080-\uFFFF]|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+)|(--|\+\+|&&|\|\||=>|\.{3}|(?:[+\-\/%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2})=?|[?~.,:;[\](){}])|(\s+)|(^$|[\s\S])/g;
|
|
11343
11342
|
|
|
11344
11343
|
exports.matchToToken = function (match) {
|
|
11345
11344
|
var token = {
|
|
11346
11345
|
type: "invalid",
|
|
11347
|
-
value: match[0]
|
|
11346
|
+
value: match[0],
|
|
11347
|
+
closed: undefined
|
|
11348
11348
|
};
|
|
11349
11349
|
if (match[1]) token.type = "string", token.closed = !!(match[3] || match[4]);else if (match[5]) token.type = "comment";else if (match[6]) token.type = "comment", token.closed = !!match[7];else if (match[8]) token.type = "regex";else if (match[9]) token.type = "number";else if (match[10]) token.type = "name";else if (match[11]) token.type = "punctuator";else if (match[12]) token.type = "whitespace";
|
|
11350
11350
|
return token;
|
|
@@ -12465,7 +12465,7 @@ var lib$3 = createCommonjsModule(function (module, exports) {
|
|
|
12465
12465
|
exports.default = highlight;
|
|
12466
12466
|
|
|
12467
12467
|
function _jsTokens() {
|
|
12468
|
-
var data = _interopRequireWildcard(jsTokens);
|
|
12468
|
+
var data = _interopRequireWildcard$$1(jsTokens);
|
|
12469
12469
|
|
|
12470
12470
|
_jsTokens = function _jsTokens() {
|
|
12471
12471
|
return data;
|
|
@@ -12475,7 +12475,7 @@ var lib$3 = createCommonjsModule(function (module, exports) {
|
|
|
12475
12475
|
}
|
|
12476
12476
|
|
|
12477
12477
|
function _esutils() {
|
|
12478
|
-
var data = _interopRequireDefault(utils$2);
|
|
12478
|
+
var data = _interopRequireDefault$$1(utils$2);
|
|
12479
12479
|
|
|
12480
12480
|
_esutils = function _esutils() {
|
|
12481
12481
|
return data;
|
|
@@ -12485,7 +12485,7 @@ var lib$3 = createCommonjsModule(function (module, exports) {
|
|
|
12485
12485
|
}
|
|
12486
12486
|
|
|
12487
12487
|
function _chalk() {
|
|
12488
|
-
var data = _interopRequireDefault(chalk$5);
|
|
12488
|
+
var data = _interopRequireDefault$$1(chalk$5);
|
|
12489
12489
|
|
|
12490
12490
|
_chalk = function _chalk() {
|
|
12491
12491
|
return data;
|
|
@@ -12494,13 +12494,13 @@ var lib$3 = createCommonjsModule(function (module, exports) {
|
|
|
12494
12494
|
return data;
|
|
12495
12495
|
}
|
|
12496
12496
|
|
|
12497
|
-
function _interopRequireDefault(obj) {
|
|
12497
|
+
function _interopRequireDefault$$1(obj) {
|
|
12498
12498
|
return obj && obj.__esModule ? obj : {
|
|
12499
12499
|
default: obj
|
|
12500
12500
|
};
|
|
12501
12501
|
}
|
|
12502
12502
|
|
|
12503
|
-
function _interopRequireWildcard(obj) {
|
|
12503
|
+
function _interopRequireWildcard$$1(obj) {
|
|
12504
12504
|
if (obj && obj.__esModule) {
|
|
12505
12505
|
return obj;
|
|
12506
12506
|
} else {
|
|
@@ -12545,8 +12545,9 @@ var lib$3 = createCommonjsModule(function (module, exports) {
|
|
|
12545
12545
|
|
|
12546
12546
|
function getTokenType(match) {
|
|
12547
12547
|
var _match$slice = match.slice(-2),
|
|
12548
|
-
|
|
12549
|
-
|
|
12548
|
+
_match$slice2 = _slicedToArray(_match$slice, 2),
|
|
12549
|
+
offset = _match$slice2[0],
|
|
12550
|
+
text = _match$slice2[1];
|
|
12550
12551
|
|
|
12551
12552
|
var token = (0, _jsTokens().matchToToken)(match);
|
|
12552
12553
|
|
|
@@ -12611,10 +12612,8 @@ var lib$3 = createCommonjsModule(function (module, exports) {
|
|
|
12611
12612
|
return chalk;
|
|
12612
12613
|
}
|
|
12613
12614
|
|
|
12614
|
-
function highlight(code
|
|
12615
|
-
|
|
12616
|
-
options = {};
|
|
12617
|
-
}
|
|
12615
|
+
function highlight(code) {
|
|
12616
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
12618
12617
|
|
|
12619
12618
|
if (shouldHighlight(options)) {
|
|
12620
12619
|
var chalk = getChalk(options);
|
|
@@ -12684,7 +12683,7 @@ var lib$2 = createCommonjsModule(function (module, exports) {
|
|
|
12684
12683
|
var NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
|
|
12685
12684
|
|
|
12686
12685
|
function getMarkerLines(loc, source, opts) {
|
|
12687
|
-
var startLoc = Object.assign({
|
|
12686
|
+
var startLoc = Object.assign({
|
|
12688
12687
|
column: 0,
|
|
12689
12688
|
line: -1
|
|
12690
12689
|
}, loc.start);
|
|
@@ -12749,11 +12748,8 @@ var lib$2 = createCommonjsModule(function (module, exports) {
|
|
|
12749
12748
|
};
|
|
12750
12749
|
}
|
|
12751
12750
|
|
|
12752
|
-
function codeFrameColumns(rawLines, loc
|
|
12753
|
-
|
|
12754
|
-
opts = {};
|
|
12755
|
-
}
|
|
12756
|
-
|
|
12751
|
+
function codeFrameColumns(rawLines, loc) {
|
|
12752
|
+
var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
12757
12753
|
var highlighted = (opts.highlightCode || opts.forceColor) && (0, _highlight().shouldHighlight)(opts);
|
|
12758
12754
|
var chalk = (0, _highlight().getChalk)(opts);
|
|
12759
12755
|
var defs = getDefs(chalk);
|
|
@@ -12774,8 +12770,8 @@ var lib$2 = createCommonjsModule(function (module, exports) {
|
|
|
12774
12770
|
var numberMaxWidth = String(end).length;
|
|
12775
12771
|
var frame = lines.slice(start, end).map(function (line, index) {
|
|
12776
12772
|
var number = start + 1 + index;
|
|
12777
|
-
var paddedNumber =
|
|
12778
|
-
var gutter = " "
|
|
12773
|
+
var paddedNumber = " ".concat(number).slice(-numberMaxWidth);
|
|
12774
|
+
var gutter = " ".concat(paddedNumber, " | ");
|
|
12779
12775
|
var hasMarker = markerLines[number];
|
|
12780
12776
|
var lastMarkerLine = !markerLines[number + 1];
|
|
12781
12777
|
|
|
@@ -12794,12 +12790,12 @@ var lib$2 = createCommonjsModule(function (module, exports) {
|
|
|
12794
12790
|
|
|
12795
12791
|
return [maybeHighlight(defs.marker, ">"), maybeHighlight(defs.gutter, gutter), line, markerLine].join("");
|
|
12796
12792
|
} else {
|
|
12797
|
-
return " "
|
|
12793
|
+
return " ".concat(maybeHighlight(defs.gutter, gutter)).concat(line);
|
|
12798
12794
|
}
|
|
12799
12795
|
}).join("\n");
|
|
12800
12796
|
|
|
12801
12797
|
if (opts.message && !hasColumns) {
|
|
12802
|
-
frame = ""
|
|
12798
|
+
frame = "".concat(" ".repeat(numberMaxWidth + 1)).concat(opts.message, "\n").concat(frame);
|
|
12803
12799
|
}
|
|
12804
12800
|
|
|
12805
12801
|
if (highlighted) {
|
|
@@ -12809,10 +12805,8 @@ var lib$2 = createCommonjsModule(function (module, exports) {
|
|
|
12809
12805
|
}
|
|
12810
12806
|
}
|
|
12811
12807
|
|
|
12812
|
-
function _default(rawLines, lineNumber, colNumber
|
|
12813
|
-
|
|
12814
|
-
opts = {};
|
|
12815
|
-
}
|
|
12808
|
+
function _default(rawLines, lineNumber, colNumber) {
|
|
12809
|
+
var opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
12816
12810
|
|
|
12817
12811
|
if (!deprecationWarningShown) {
|
|
12818
12812
|
deprecationWarningShown = true;
|
|
@@ -13480,14 +13474,6 @@ function getPenultimate(arr) {
|
|
|
13480
13474
|
return null;
|
|
13481
13475
|
}
|
|
13482
13476
|
|
|
13483
|
-
function getLast$3(arr) {
|
|
13484
|
-
if (arr.length > 0) {
|
|
13485
|
-
return arr[arr.length - 1];
|
|
13486
|
-
}
|
|
13487
|
-
|
|
13488
|
-
return null;
|
|
13489
|
-
}
|
|
13490
|
-
|
|
13491
13477
|
function skip(chars) {
|
|
13492
13478
|
return function (text, index, opts) {
|
|
13493
13479
|
var backwards = opts && opts.backwards; // Allow `skip` functions to be threaded together without having
|
|
@@ -13902,7 +13888,7 @@ function printString(raw, options, isDirectiveLiteral) {
|
|
|
13902
13888
|
// sure that we consistently output the minimum amount of escaped quotes.
|
|
13903
13889
|
|
|
13904
13890
|
|
|
13905
|
-
return makeString(rawContent, enclosingQuote, !(options.parser === "css" || options.parser === "less" || options.parser === "scss" || options.parentParser === "html" || options.parentParser === "vue" || options.parentParser === "angular"));
|
|
13891
|
+
return makeString(rawContent, enclosingQuote, !(options.parser === "css" || options.parser === "less" || options.parser === "scss" || options.parentParser === "html" || options.parentParser === "vue" || options.parentParser === "angular" || options.parentParser === "lwc"));
|
|
13906
13892
|
}
|
|
13907
13893
|
|
|
13908
13894
|
function makeString(rawContent, enclosingQuote, unescapeUnnecessaryEscapes) {
|
|
@@ -14090,7 +14076,7 @@ var util = {
|
|
|
14090
14076
|
isExportDeclaration: isExportDeclaration,
|
|
14091
14077
|
getParentExportDeclaration: getParentExportDeclaration,
|
|
14092
14078
|
getPenultimate: getPenultimate,
|
|
14093
|
-
getLast: getLast
|
|
14079
|
+
getLast: getLast,
|
|
14094
14080
|
getNextNonSpaceNonCommentCharacterIndexWithStartIndex: getNextNonSpaceNonCommentCharacterIndexWithStartIndex,
|
|
14095
14081
|
getNextNonSpaceNonCommentCharacterIndex: getNextNonSpaceNonCommentCharacterIndex,
|
|
14096
14082
|
getNextNonSpaceNonCommentCharacter: getNextNonSpaceNonCommentCharacter,
|
|
@@ -15543,7 +15529,7 @@ function printTrailingComment(commentPath, print, options) {
|
|
|
15543
15529
|
return concat([" ", contents]);
|
|
15544
15530
|
}
|
|
15545
15531
|
|
|
15546
|
-
return concat([lineSuffix(" "
|
|
15532
|
+
return concat([lineSuffix(concat([" ", contents])), !isBlock ? breakParent : ""]);
|
|
15547
15533
|
}
|
|
15548
15534
|
|
|
15549
15535
|
function printDanglingComments(path, options, sameIndent, filter) {
|
|
@@ -18185,7 +18171,7 @@ function genericPrint$1(path, options, print) {
|
|
|
18185
18171
|
|
|
18186
18172
|
case "FragmentDefinition":
|
|
18187
18173
|
{
|
|
18188
|
-
return concat$6(["fragment ", path.call(print, "name"), " on ", path.call(print, "typeCondition"), printDirectives(path, print, n), " ", path.call(print, "selectionSet")]);
|
|
18174
|
+
return concat$6(["fragment ", path.call(print, "name"), n.variableDefinitions && n.variableDefinitions.length ? group$5(concat$6(["(", indent$3(concat$6([softline$2, join$3(concat$6([ifBreak$2("", ", "), softline$2]), path.map(print, "variableDefinitions"))])), softline$2, ")"])) : "", " on ", path.call(print, "typeCondition"), printDirectives(path, print, n), " ", path.call(print, "selectionSet")]);
|
|
18189
18175
|
}
|
|
18190
18176
|
|
|
18191
18177
|
case "SelectionSet":
|
|
@@ -18268,7 +18254,7 @@ function genericPrint$1(path, options, print) {
|
|
|
18268
18254
|
|
|
18269
18255
|
case "VariableDefinition":
|
|
18270
18256
|
{
|
|
18271
|
-
return concat$6([path.call(print, "variable"), ": ", path.call(print, "type"), n.defaultValue ? concat$6([" = ", path.call(print, "defaultValue")]) : ""]);
|
|
18257
|
+
return concat$6([path.call(print, "variable"), ": ", path.call(print, "type"), n.defaultValue ? concat$6([" = ", path.call(print, "defaultValue")]) : "", printDirectives(path, print, n)]);
|
|
18272
18258
|
}
|
|
18273
18259
|
|
|
18274
18260
|
case "TypeExtensionDefinition":
|
|
@@ -20674,6 +20660,15 @@ function embed$2(path, print, textToDoc, options) {
|
|
|
20674
20660
|
|
|
20675
20661
|
if (/^PRETTIER_HTML_PLACEHOLDER_\d+_IN_JS$/.test(options.originalText.slice(node.valueSpan.start.offset, node.valueSpan.end.offset))) {
|
|
20676
20662
|
return concat$8([node.rawName, "=", node.value]);
|
|
20663
|
+
} // lwc: html`<my-element data-for={value}></my-elememt>`
|
|
20664
|
+
|
|
20665
|
+
|
|
20666
|
+
if (options.parser === "lwc") {
|
|
20667
|
+
var interpolationRegex = /^\{[\s\S]*\}$/;
|
|
20668
|
+
|
|
20669
|
+
if (interpolationRegex.test(options.originalText.slice(node.valueSpan.start.offset, node.valueSpan.end.offset))) {
|
|
20670
|
+
return concat$8([node.rawName, "=", node.value]);
|
|
20671
|
+
}
|
|
20677
20672
|
}
|
|
20678
20673
|
|
|
20679
20674
|
var embeddedAttributeValueDoc = printEmbeddedAttributeValue(node, function (code, opts) {
|
|
@@ -21454,6 +21449,15 @@ var languages$3 = [createLanguage(require$$0$22, {
|
|
|
21454
21449
|
extensions: [".mjml" // MJML is considered XML in Linguist but it should be formatted as HTML
|
|
21455
21450
|
]
|
|
21456
21451
|
}
|
|
21452
|
+
}), createLanguage(require$$0$22, {
|
|
21453
|
+
override: {
|
|
21454
|
+
name: "Lightning Web Components",
|
|
21455
|
+
since: "1.17.0",
|
|
21456
|
+
parsers: ["lwc"],
|
|
21457
|
+
vscodeLanguageIds: ["html"],
|
|
21458
|
+
extensions: [],
|
|
21459
|
+
filenames: []
|
|
21460
|
+
}
|
|
21457
21461
|
}), createLanguage(require$$1$9, {
|
|
21458
21462
|
override: {
|
|
21459
21463
|
since: "1.10.0",
|
|
@@ -22978,7 +22982,6 @@ function needsParens(path, options) {
|
|
|
22978
22982
|
|
|
22979
22983
|
case "ClassExpression":
|
|
22980
22984
|
case "ClassDeclaration":
|
|
22981
|
-
case "TSAbstractClassDeclaration":
|
|
22982
22985
|
return name === "superClass" && parent.superClass === node;
|
|
22983
22986
|
|
|
22984
22987
|
case "TSTypeAssertion":
|
|
@@ -23227,6 +23230,7 @@ function needsParens(path, options) {
|
|
|
23227
23230
|
|
|
23228
23231
|
case "FunctionExpression":
|
|
23229
23232
|
switch (parent.type) {
|
|
23233
|
+
case "NewExpression":
|
|
23230
23234
|
case "CallExpression":
|
|
23231
23235
|
return name === "callee";
|
|
23232
23236
|
// Not strictly necessary, but it's clearer to the reader if IIFEs are wrapped in parentheses.
|
|
@@ -23271,7 +23275,16 @@ function needsParens(path, options) {
|
|
|
23271
23275
|
}
|
|
23272
23276
|
|
|
23273
23277
|
case "ClassExpression":
|
|
23274
|
-
|
|
23278
|
+
switch (parent.type) {
|
|
23279
|
+
case "ExportDefaultDeclaration":
|
|
23280
|
+
return true;
|
|
23281
|
+
|
|
23282
|
+
case "NewExpression":
|
|
23283
|
+
return name === "callee" && parent.callee === node;
|
|
23284
|
+
|
|
23285
|
+
default:
|
|
23286
|
+
return false;
|
|
23287
|
+
}
|
|
23275
23288
|
|
|
23276
23289
|
case "OptionalMemberExpression":
|
|
23277
23290
|
return parent.type === "MemberExpression";
|
|
@@ -23303,7 +23316,7 @@ function needsParens(path, options) {
|
|
|
23303
23316
|
return false;
|
|
23304
23317
|
|
|
23305
23318
|
case "NGPipeExpression":
|
|
23306
|
-
if (parent.type === "NGRoot" || parent.type === "ObjectProperty" || parent.type === "ArrayExpression" || (parent.type === "CallExpression" || parent.type === "OptionalCallExpression") && parent.arguments[name] === node || parent.type === "NGPipeExpression" && name === "right" || parent.type === "MemberExpression" && name === "property" || parent.type === "AssignmentExpression") {
|
|
23319
|
+
if (parent.type === "NGRoot" || parent.type === "NGMicrosyntaxExpression" || parent.type === "ObjectProperty" || parent.type === "ArrayExpression" || (parent.type === "CallExpression" || parent.type === "OptionalCallExpression") && parent.arguments[name] === node || parent.type === "NGPipeExpression" && name === "right" || parent.type === "MemberExpression" && name === "property" || parent.type === "AssignmentExpression") {
|
|
23307
23320
|
return false;
|
|
23308
23321
|
}
|
|
23309
23322
|
|
|
@@ -23314,7 +23327,7 @@ function needsParens(path, options) {
|
|
|
23314
23327
|
}
|
|
23315
23328
|
|
|
23316
23329
|
function isStatement(node) {
|
|
23317
|
-
return node.type === "BlockStatement" || node.type === "BreakStatement" || node.type === "ClassBody" || node.type === "ClassDeclaration" || node.type === "ClassMethod" || node.type === "ClassProperty" || node.type === "ClassPrivateProperty" || node.type === "ContinueStatement" || node.type === "DebuggerStatement" || node.type === "DeclareClass" || node.type === "DeclareExportAllDeclaration" || node.type === "DeclareExportDeclaration" || node.type === "DeclareFunction" || node.type === "DeclareInterface" || node.type === "DeclareModule" || node.type === "DeclareModuleExports" || node.type === "DeclareVariable" || node.type === "DoWhileStatement" || node.type === "ExportAllDeclaration" || node.type === "ExportDefaultDeclaration" || node.type === "ExportNamedDeclaration" || node.type === "ExpressionStatement" || node.type === "ForAwaitStatement" || node.type === "ForInStatement" || node.type === "ForOfStatement" || node.type === "ForStatement" || node.type === "FunctionDeclaration" || node.type === "IfStatement" || node.type === "ImportDeclaration" || node.type === "InterfaceDeclaration" || node.type === "LabeledStatement" || node.type === "MethodDefinition" || node.type === "ReturnStatement" || node.type === "SwitchStatement" || node.type === "ThrowStatement" || node.type === "TryStatement" || node.type === "
|
|
23330
|
+
return node.type === "BlockStatement" || node.type === "BreakStatement" || node.type === "ClassBody" || node.type === "ClassDeclaration" || node.type === "ClassMethod" || node.type === "ClassProperty" || node.type === "ClassPrivateProperty" || node.type === "ContinueStatement" || node.type === "DebuggerStatement" || node.type === "DeclareClass" || node.type === "DeclareExportAllDeclaration" || node.type === "DeclareExportDeclaration" || node.type === "DeclareFunction" || node.type === "DeclareInterface" || node.type === "DeclareModule" || node.type === "DeclareModuleExports" || node.type === "DeclareVariable" || node.type === "DoWhileStatement" || node.type === "ExportAllDeclaration" || node.type === "ExportDefaultDeclaration" || node.type === "ExportNamedDeclaration" || node.type === "ExpressionStatement" || node.type === "ForAwaitStatement" || node.type === "ForInStatement" || node.type === "ForOfStatement" || node.type === "ForStatement" || node.type === "FunctionDeclaration" || node.type === "IfStatement" || node.type === "ImportDeclaration" || node.type === "InterfaceDeclaration" || node.type === "LabeledStatement" || node.type === "MethodDefinition" || node.type === "ReturnStatement" || node.type === "SwitchStatement" || node.type === "ThrowStatement" || node.type === "TryStatement" || node.type === "TSDeclareFunction" || node.type === "TSEnumDeclaration" || node.type === "TSImportEqualsDeclaration" || node.type === "TSInterfaceDeclaration" || node.type === "TSModuleDeclaration" || node.type === "TSNamespaceExportDeclaration" || node.type === "TypeAlias" || node.type === "VariableDeclaration" || node.type === "WhileStatement" || node.type === "WithStatement";
|
|
23318
23331
|
}
|
|
23319
23332
|
|
|
23320
23333
|
function getUnparenthesizedNode(node) {
|
|
@@ -23464,7 +23477,7 @@ var shouldFlatten$1 = util.shouldFlatten;
|
|
|
23464
23477
|
var getNextNonSpaceNonCommentCharacter$1 = util.getNextNonSpaceNonCommentCharacter;
|
|
23465
23478
|
var hasNewline$3 = util.hasNewline;
|
|
23466
23479
|
var hasNewlineInRange$1 = util.hasNewlineInRange;
|
|
23467
|
-
var getLast$
|
|
23480
|
+
var getLast$3 = util.getLast;
|
|
23468
23481
|
var getStringWidth$2 = util.getStringWidth;
|
|
23469
23482
|
var printString$2 = util.printString;
|
|
23470
23483
|
var printNumber$2 = util.printNumber;
|
|
@@ -23486,6 +23499,7 @@ var isVueEventBindingExpression$2 = htmlBinding.isVueEventBindingExpression;
|
|
|
23486
23499
|
var hasNode = utils$8.hasNode;
|
|
23487
23500
|
var hasFlowAnnotationComment = utils$8.hasFlowAnnotationComment;
|
|
23488
23501
|
var hasFlowShorthandAnnotationComment = utils$8.hasFlowShorthandAnnotationComment;
|
|
23502
|
+
var needsQuoteProps = new WeakMap();
|
|
23489
23503
|
var _require$$6$builders = doc.builders;
|
|
23490
23504
|
var concat$11 = _require$$6$builders.concat;
|
|
23491
23505
|
var join$7 = _require$$6$builders.join;
|
|
@@ -23618,7 +23632,7 @@ function genericPrint$3(path, options, printPath, args) {
|
|
|
23618
23632
|
}
|
|
23619
23633
|
|
|
23620
23634
|
function hasNewlineBetweenOrAfterDecorators(node, options) {
|
|
23621
|
-
return hasNewlineInRange$1(options.originalText, options.locStart(node.decorators[0]), options.locEnd(getLast$
|
|
23635
|
+
return hasNewlineInRange$1(options.originalText, options.locStart(node.decorators[0]), options.locEnd(getLast$3(node.decorators))) || hasNewline$3(options.originalText, options.locEnd(getLast$3(node.decorators)));
|
|
23622
23636
|
}
|
|
23623
23637
|
|
|
23624
23638
|
function printDecorators(path, options, print) {
|
|
@@ -23935,7 +23949,7 @@ function printPathNoParens(path, options, print, args) {
|
|
|
23935
23949
|
return chain;
|
|
23936
23950
|
}
|
|
23937
23951
|
|
|
23938
|
-
var jsxPart = getLast$
|
|
23952
|
+
var jsxPart = getLast$3(_parts);
|
|
23939
23953
|
return group$10(concat$11([chain, ifBreak$6(indent$6(jsxPart), jsxPart, {
|
|
23940
23954
|
groupId: groupId
|
|
23941
23955
|
})]));
|
|
@@ -24280,7 +24294,7 @@ function printPathNoParens(path, options, print, args) {
|
|
|
24280
24294
|
if ( // We want to keep CommonJS- and AMD-style require calls, and AMD-style
|
|
24281
24295
|
// define calls, as a unit.
|
|
24282
24296
|
// e.g. `define(["some/lib", (lib) => {`
|
|
24283
|
-
!isNew && n.callee.type === "Identifier" && (n.callee.name === "require" || n.callee.name === "define") ||
|
|
24297
|
+
!isNew && n.callee.type === "Identifier" && (n.callee.name === "require" || n.callee.name === "define") || // Template literals as single arguments
|
|
24284
24298
|
n.arguments.length === 1 && isTemplateOnItsOwnLine(n.arguments[0], options.originalText, options) || // Keep test declarations on a single line
|
|
24285
24299
|
// e.g. `it('long name', () => {`
|
|
24286
24300
|
!isNew && isTestCall(n, path.getParentNode())) {
|
|
@@ -24400,7 +24414,7 @@ function printPathNoParens(path, options, print, args) {
|
|
|
24400
24414
|
props.push(concat$11(separatorParts.concat(group$10("..."))));
|
|
24401
24415
|
}
|
|
24402
24416
|
|
|
24403
|
-
var lastElem = getLast$
|
|
24417
|
+
var lastElem = getLast$3(n[propertiesField]);
|
|
24404
24418
|
var canHaveTrailingSeparator = !(lastElem && (lastElem.type === "RestProperty" || lastElem.type === "RestElement" || hasNodeIgnoreComment$1(lastElem) || n.inexact));
|
|
24405
24419
|
var content;
|
|
24406
24420
|
|
|
@@ -24482,7 +24496,7 @@ function printPathNoParens(path, options, print, args) {
|
|
|
24482
24496
|
parts.push(group$10(concat$11(["[", comments.printDanglingComments(path, options), softline$5, "]"])));
|
|
24483
24497
|
}
|
|
24484
24498
|
} else {
|
|
24485
|
-
var _lastElem = getLast$
|
|
24499
|
+
var _lastElem = getLast$3(n.elements);
|
|
24486
24500
|
|
|
24487
24501
|
var canHaveTrailingComma = !(_lastElem && _lastElem.type === "RestElement"); // JavaScript allows you to have empty elements in an array which
|
|
24488
24502
|
// changes its length based on the number of commas. The algorithm
|
|
@@ -24926,7 +24940,7 @@ function printPathNoParens(path, options, print, args) {
|
|
|
24926
24940
|
return group$10(concat$11(["<", path.call(print, "name"), path.call(print, "typeParameters"), " ", concat$11(path.map(print, "attributes")), _n.selfClosing ? " />" : ">"]));
|
|
24927
24941
|
}
|
|
24928
24942
|
|
|
24929
|
-
var lastAttrHasTrailingComments = _n.attributes.length && hasTrailingComment(getLast$
|
|
24943
|
+
var lastAttrHasTrailingComments = _n.attributes.length && hasTrailingComment(getLast$3(_n.attributes));
|
|
24930
24944
|
var bracketSameLine = // Simple tags (no attributes and no comment in tag name) should be
|
|
24931
24945
|
// kept unbroken regardless of `jsxBracketSameLine`
|
|
24932
24946
|
!_n.attributes.length && !nameHasComments || options.jsxBracketSameLine && ( // We should print the bracket in a new line for the following cases:
|
|
@@ -25032,7 +25046,6 @@ function printPathNoParens(path, options, print, args) {
|
|
|
25032
25046
|
|
|
25033
25047
|
case "ClassDeclaration":
|
|
25034
25048
|
case "ClassExpression":
|
|
25035
|
-
case "TSAbstractClassDeclaration":
|
|
25036
25049
|
if (isNodeStartingWithDeclare(n, options)) {
|
|
25037
25050
|
parts.push("declare ");
|
|
25038
25051
|
}
|
|
@@ -26095,18 +26108,27 @@ function printStatementSequence(path, options, print) {
|
|
|
26095
26108
|
|
|
26096
26109
|
function printPropertyKey(path, options, print) {
|
|
26097
26110
|
var node = path.getNode();
|
|
26111
|
+
var parent = path.getParentNode();
|
|
26098
26112
|
var key = node.key;
|
|
26099
26113
|
|
|
26100
|
-
if (
|
|
26114
|
+
if (options.quoteProps === "consistent" && !needsQuoteProps.has(parent)) {
|
|
26115
|
+
var objectHasStringProp = (parent.properties || parent.body || parent.members).some(function (prop) {
|
|
26116
|
+
return prop.key && prop.key.type !== "Identifier" && !isStringPropSafeToCoerceToIdentifier(prop, options);
|
|
26117
|
+
});
|
|
26118
|
+
needsQuoteProps.set(parent, objectHasStringProp);
|
|
26119
|
+
}
|
|
26120
|
+
|
|
26121
|
+
if (key.type === "Identifier" && !node.computed && (options.parser === "json" || options.quoteProps === "consistent" && needsQuoteProps.get(parent))) {
|
|
26101
26122
|
// a -> "a"
|
|
26123
|
+
var prop = printString$2(JSON.stringify(key.name), options);
|
|
26102
26124
|
return path.call(function (keyPath) {
|
|
26103
26125
|
return comments.printComments(keyPath, function () {
|
|
26104
|
-
return
|
|
26126
|
+
return prop;
|
|
26105
26127
|
}, options);
|
|
26106
26128
|
}, "key");
|
|
26107
26129
|
}
|
|
26108
26130
|
|
|
26109
|
-
if (
|
|
26131
|
+
if (isStringPropSafeToCoerceToIdentifier(node, options) && (options.quoteProps === "as-needed" || options.quoteProps === "consistent" && !needsQuoteProps.get(parent))) {
|
|
26110
26132
|
// 'a' -> a
|
|
26111
26133
|
return path.call(function (keyPath) {
|
|
26112
26134
|
return comments.printComments(keyPath, function () {
|
|
@@ -26165,7 +26187,7 @@ function couldGroupArg(arg) {
|
|
|
26165
26187
|
}
|
|
26166
26188
|
|
|
26167
26189
|
function shouldGroupLastArg(args) {
|
|
26168
|
-
var lastArg = getLast$
|
|
26190
|
+
var lastArg = getLast$3(args);
|
|
26169
26191
|
var penultimateArg = getPenultimate$1(args);
|
|
26170
26192
|
return !hasLeadingComment(lastArg) && !hasTrailingComment(lastArg) && couldGroupArg(lastArg) && ( // If the last two arguments are of the same type,
|
|
26171
26193
|
// disable last element expansion.
|
|
@@ -26261,7 +26283,8 @@ function printArgumentsList(path, options, print) {
|
|
|
26261
26283
|
|
|
26262
26284
|
return concat$11(parts);
|
|
26263
26285
|
}, "arguments");
|
|
26264
|
-
var maybeTrailingComma =
|
|
26286
|
+
var maybeTrailingComma = // Dynamic imports cannot have trailing commas
|
|
26287
|
+
!(node.callee && node.callee.type === "Import") && shouldPrintComma$1(options, "all") ? "," : "";
|
|
26265
26288
|
|
|
26266
26289
|
function allArgsBrokenOut() {
|
|
26267
26290
|
return group$10(concat$11(["(", indent$6(concat$11([line$8, concat$11(printedArguments)])), maybeTrailingComma, line$8, ")"]), {
|
|
@@ -26310,14 +26333,14 @@ function printArgumentsList(path, options, print) {
|
|
|
26310
26333
|
var somePrintedArgumentsWillBreak = printedArguments.some(willBreak$1);
|
|
26311
26334
|
return concat$11([somePrintedArgumentsWillBreak ? breakParent$3 : "", conditionalGroup$1([concat$11([ifBreak$6(indent$6(concat$11(["(", softline$5, concat$11(printedExpanded)])), concat$11(["(", concat$11(printedExpanded)])), somePrintedArgumentsWillBreak ? concat$11([ifBreak$6(maybeTrailingComma), softline$5]) : "", ")"]), shouldGroupFirst ? concat$11(["(", group$10(printedExpanded[0], {
|
|
26312
26335
|
shouldBreak: true
|
|
26313
|
-
}), concat$11(printedExpanded.slice(1)), ")"]) : concat$11(["(", concat$11(printedArguments.slice(0, -1)), group$10(getLast$
|
|
26336
|
+
}), concat$11(printedExpanded.slice(1)), ")"]) : concat$11(["(", concat$11(printedArguments.slice(0, -1)), group$10(getLast$3(printedExpanded), {
|
|
26314
26337
|
shouldBreak: true
|
|
26315
26338
|
}), ")"]), allArgsBrokenOut()], {
|
|
26316
26339
|
shouldBreak: shouldBreak
|
|
26317
26340
|
})]);
|
|
26318
26341
|
}
|
|
26319
26342
|
|
|
26320
|
-
return group$10(concat$11(["(", indent$6(concat$11([softline$5, concat$11(printedArguments)])), ifBreak$6(
|
|
26343
|
+
return group$10(concat$11(["(", indent$6(concat$11([softline$5, concat$11(printedArguments)])), ifBreak$6(maybeTrailingComma), softline$5, ")"]), {
|
|
26321
26344
|
shouldBreak: printedArguments.some(willBreak$1) || anyArgEmptyLine
|
|
26322
26345
|
});
|
|
26323
26346
|
}
|
|
@@ -26356,12 +26379,37 @@ function printFunctionTypeParameters(path, options, print) {
|
|
|
26356
26379
|
|
|
26357
26380
|
function printFunctionParams(path, print, options, expandArg, printTypeParams) {
|
|
26358
26381
|
var fun = path.getValue();
|
|
26382
|
+
var parent = path.getParentNode();
|
|
26359
26383
|
var paramsField = fun.parameters ? "parameters" : "params";
|
|
26384
|
+
var isParametersInTestCall = isTestCall(parent);
|
|
26385
|
+
var shouldHugParameters = shouldHugArguments(fun);
|
|
26386
|
+
var shouldExpandParameters = expandArg && !(fun[paramsField] && fun[paramsField].some(function (n) {
|
|
26387
|
+
return n.comments;
|
|
26388
|
+
}));
|
|
26360
26389
|
var typeParams = printTypeParams ? printFunctionTypeParameters(path, options, print) : "";
|
|
26361
26390
|
var printed = [];
|
|
26362
26391
|
|
|
26363
26392
|
if (fun[paramsField]) {
|
|
26364
|
-
|
|
26393
|
+
var lastArgIndex = fun[paramsField].length - 1;
|
|
26394
|
+
printed = path.map(function (childPath, index) {
|
|
26395
|
+
var parts = [];
|
|
26396
|
+
var param = childPath.getValue();
|
|
26397
|
+
parts.push(print(childPath));
|
|
26398
|
+
|
|
26399
|
+
if (index === lastArgIndex) {
|
|
26400
|
+
if (fun.rest) {
|
|
26401
|
+
parts.push(",", line$8);
|
|
26402
|
+
}
|
|
26403
|
+
} else if (isParametersInTestCall || shouldHugParameters || shouldExpandParameters) {
|
|
26404
|
+
parts.push(", ");
|
|
26405
|
+
} else if (isNextLineEmpty$4(options.originalText, param, options)) {
|
|
26406
|
+
parts.push(",", hardline$8, hardline$8);
|
|
26407
|
+
} else {
|
|
26408
|
+
parts.push(",", line$8);
|
|
26409
|
+
}
|
|
26410
|
+
|
|
26411
|
+
return concat$11(parts);
|
|
26412
|
+
}, paramsField);
|
|
26365
26413
|
}
|
|
26366
26414
|
|
|
26367
26415
|
if (fun.rest) {
|
|
@@ -26376,7 +26424,7 @@ function printFunctionParams(path, print, options, expandArg, printTypeParams) {
|
|
|
26376
26424
|
}), ")"]);
|
|
26377
26425
|
}
|
|
26378
26426
|
|
|
26379
|
-
var lastParam = getLast$
|
|
26427
|
+
var lastParam = getLast$3(fun[paramsField]); // If the parent is a call with the first/last argument expansion and this is the
|
|
26380
26428
|
// params of the first/last argument, we dont want the arguments to break and instead
|
|
26381
26429
|
// want the whole expression to be on a new line.
|
|
26382
26430
|
//
|
|
@@ -26387,10 +26435,8 @@ function printFunctionParams(path, print, options, expandArg, printTypeParams) {
|
|
|
26387
26435
|
// }) ) => {
|
|
26388
26436
|
// })
|
|
26389
26437
|
|
|
26390
|
-
if (
|
|
26391
|
-
return
|
|
26392
|
-
}))) {
|
|
26393
|
-
return group$10(concat$11([removeLines$2(typeParams), "(", join$7(", ", printed.map(removeLines$2)), ")"]));
|
|
26438
|
+
if (shouldExpandParameters) {
|
|
26439
|
+
return group$10(concat$11([removeLines$2(typeParams), "(", concat$11(printed.map(removeLines$2)), ")"]));
|
|
26394
26440
|
} // Single object destructuring should hug
|
|
26395
26441
|
//
|
|
26396
26442
|
// function({
|
|
@@ -26400,14 +26446,13 @@ function printFunctionParams(path, print, options, expandArg, printTypeParams) {
|
|
|
26400
26446
|
// }) {}
|
|
26401
26447
|
|
|
26402
26448
|
|
|
26403
|
-
if (
|
|
26404
|
-
return concat$11([typeParams, "(",
|
|
26405
|
-
}
|
|
26449
|
+
if (shouldHugParameters) {
|
|
26450
|
+
return concat$11([typeParams, "(", concat$11(printed), ")"]);
|
|
26451
|
+
} // don't break in specs, eg; `it("should maintain parens around done even when long", (done) => {})`
|
|
26406
26452
|
|
|
26407
|
-
var parent = path.getParentNode(); // don't break in specs, eg; `it("should maintain parens around done even when long", (done) => {})`
|
|
26408
26453
|
|
|
26409
|
-
if (
|
|
26410
|
-
return concat$11([typeParams, "(",
|
|
26454
|
+
if (isParametersInTestCall) {
|
|
26455
|
+
return concat$11([typeParams, "(", concat$11(printed), ")"]);
|
|
26411
26456
|
}
|
|
26412
26457
|
|
|
26413
26458
|
var isFlowShorthandWithOneArg = (isObjectTypePropertyAFunction(parent, options) || isTypeAnnotationAFunction(parent, options) || parent.type === "TypeAlias" || parent.type === "UnionTypeAnnotation" || parent.type === "TSUnionType" || parent.type === "IntersectionTypeAnnotation" || parent.type === "FunctionTypeAnnotation" && parent.returnType === fun) && fun[paramsField].length === 1 && fun[paramsField][0].name === null && fun[paramsField][0].typeAnnotation && fun.typeParameters === null && isSimpleFlowType(fun[paramsField][0].typeAnnotation) && !fun.rest;
|
|
@@ -26421,7 +26466,7 @@ function printFunctionParams(path, print, options, expandArg, printTypeParams) {
|
|
|
26421
26466
|
}
|
|
26422
26467
|
|
|
26423
26468
|
var canHaveTrailingComma = !(lastParam && lastParam.type === "RestElement") && !fun.rest;
|
|
26424
|
-
return concat$11([typeParams, "(", indent$6(concat$11([softline$5,
|
|
26469
|
+
return concat$11([typeParams, "(", indent$6(concat$11([softline$5, concat$11(printed)])), ifBreak$6(canHaveTrailingComma && shouldPrintComma$1(options, "all") ? "," : ""), softline$5, ")"]);
|
|
26425
26470
|
}
|
|
26426
26471
|
|
|
26427
26472
|
function shouldPrintParamsWithoutParens(path, options) {
|
|
@@ -26536,7 +26581,7 @@ function printExportDeclaration(path, options, print) {
|
|
|
26536
26581
|
if (decl.declaration) {
|
|
26537
26582
|
parts.push(path.call(print, "declaration"));
|
|
26538
26583
|
|
|
26539
|
-
if (isDefault && decl.declaration.type !== "ClassDeclaration" && decl.declaration.type !== "FunctionDeclaration" && decl.declaration.type !== "
|
|
26584
|
+
if (isDefault && decl.declaration.type !== "ClassDeclaration" && decl.declaration.type !== "FunctionDeclaration" && decl.declaration.type !== "TSInterfaceDeclaration" && decl.declaration.type !== "DeclareClass" && decl.declaration.type !== "DeclareFunction" && decl.declaration.type !== "TSDeclareFunction") {
|
|
26540
26585
|
parts.push(semi);
|
|
26541
26586
|
}
|
|
26542
26587
|
} else {
|
|
@@ -26647,7 +26692,7 @@ function printClass(path, options, print) {
|
|
|
26647
26692
|
var n = path.getValue();
|
|
26648
26693
|
var parts = [];
|
|
26649
26694
|
|
|
26650
|
-
if (n.
|
|
26695
|
+
if (n.abstract) {
|
|
26651
26696
|
parts.push("abstract ");
|
|
26652
26697
|
}
|
|
26653
26698
|
|
|
@@ -26948,27 +26993,23 @@ function printMemberChain(path, options, print) {
|
|
|
26948
26993
|
return firstNode.type === "ThisExpression" || firstNode.type === "Identifier" && (isFactory(firstNode.name) || isExpression && isShort(firstNode.name) || hasComputed);
|
|
26949
26994
|
}
|
|
26950
26995
|
|
|
26951
|
-
var lastNode = getLast$
|
|
26996
|
+
var lastNode = getLast$3(groups[0]).node;
|
|
26952
26997
|
return (lastNode.type === "MemberExpression" || lastNode.type === "OptionalMemberExpression") && lastNode.property.type === "Identifier" && (isFactory(lastNode.property.name) || hasComputed);
|
|
26953
26998
|
}
|
|
26954
26999
|
|
|
26955
27000
|
var shouldMerge = groups.length >= 2 && !groups[1][0].node.comments && shouldNotWrap(groups);
|
|
26956
27001
|
|
|
26957
27002
|
function printGroup(printedGroup) {
|
|
26958
|
-
var
|
|
26959
|
-
|
|
26960
|
-
|
|
26961
|
-
|
|
26962
|
-
|
|
26963
|
-
|
|
26964
|
-
|
|
26965
|
-
_i3++;
|
|
26966
|
-
} else {
|
|
26967
|
-
result.push(printedGroup[_i3].printed);
|
|
26968
|
-
}
|
|
27003
|
+
var printed = printedGroup.map(function (tuple) {
|
|
27004
|
+
return tuple.printed;
|
|
27005
|
+
}); // Checks if the last node (i.e. the parent node) needs parens and print
|
|
27006
|
+
// accordingly
|
|
27007
|
+
|
|
27008
|
+
if (printedGroup.length > 0 && printedGroup[printedGroup.length - 1].needsParens) {
|
|
27009
|
+
return concat$11(["("].concat(_toConsumableArray(printed), [")"]));
|
|
26969
27010
|
}
|
|
26970
27011
|
|
|
26971
|
-
return concat$11(
|
|
27012
|
+
return concat$11(printed);
|
|
26972
27013
|
}
|
|
26973
27014
|
|
|
26974
27015
|
function printIndentedGroup(groups) {
|
|
@@ -26998,7 +27039,7 @@ function printMemberChain(path, options, print) {
|
|
|
26998
27039
|
// empty line after
|
|
26999
27040
|
|
|
27000
27041
|
|
|
27001
|
-
var lastNodeBeforeIndent = getLast$
|
|
27042
|
+
var lastNodeBeforeIndent = getLast$3(shouldMerge ? groups.slice(1, 2)[0] : groups[0]).node;
|
|
27002
27043
|
var shouldHaveEmptyLineBeforeIndent = lastNodeBeforeIndent.type !== "CallExpression" && lastNodeBeforeIndent.type !== "OptionalCallExpression" && shouldInsertEmptyLineAfter(lastNodeBeforeIndent);
|
|
27003
27044
|
var expanded = concat$11([printGroup(groups[0]), shouldMerge ? concat$11(groups.slice(1, 2).map(printGroup)) : "", shouldHaveEmptyLineBeforeIndent ? hardline$8 : "", printIndentedGroup(groups.slice(shouldMerge ? 2 : 1))]);
|
|
27004
27045
|
var callExpressions = printedNodes.map(function (_ref) {
|
|
@@ -27018,7 +27059,7 @@ function printMemberChain(path, options, print) {
|
|
|
27018
27059
|
*/
|
|
27019
27060
|
function (lastGroupDoc, lastGroupNode) {
|
|
27020
27061
|
return isCallOrOptionalCallExpression(lastGroupNode) && willBreak$1(lastGroupDoc);
|
|
27021
|
-
}(getLast$
|
|
27062
|
+
}(getLast$3(printedGroups), getLast$3(getLast$3(groups)).node) && callExpressions.slice(0, -1).some(function (n) {
|
|
27022
27063
|
return n.arguments.some(isFunctionOrArrowExpression);
|
|
27023
27064
|
})) {
|
|
27024
27065
|
return group$10(expanded);
|
|
@@ -27229,7 +27270,7 @@ function printJSXChildren(path, options, print, jsxWhitespace, isFacebookTransla
|
|
|
27229
27270
|
|
|
27230
27271
|
var endWhitespace; // Ends with whitespace
|
|
27231
27272
|
|
|
27232
|
-
if (getLast$
|
|
27273
|
+
if (getLast$3(words) === "") {
|
|
27233
27274
|
words.pop();
|
|
27234
27275
|
endWhitespace = words.pop();
|
|
27235
27276
|
} // This was whitespace only without a new line.
|
|
@@ -27250,13 +27291,13 @@ function printJSXChildren(path, options, print, jsxWhitespace, isFacebookTransla
|
|
|
27250
27291
|
if (endWhitespace !== undefined) {
|
|
27251
27292
|
if (/\n/.test(endWhitespace)) {
|
|
27252
27293
|
var _next = n.children[i + 1];
|
|
27253
|
-
children.push(separatorWithWhitespace(isFacebookTranslationTag, getLast$
|
|
27294
|
+
children.push(separatorWithWhitespace(isFacebookTranslationTag, getLast$3(children), child, _next));
|
|
27254
27295
|
} else {
|
|
27255
27296
|
children.push(jsxWhitespace);
|
|
27256
27297
|
}
|
|
27257
27298
|
} else {
|
|
27258
27299
|
var _next2 = n.children[i + 1];
|
|
27259
|
-
children.push(separatorNoWhitespace(isFacebookTranslationTag, getLast$
|
|
27300
|
+
children.push(separatorNoWhitespace(isFacebookTranslationTag, getLast$3(children), child, _next2));
|
|
27260
27301
|
}
|
|
27261
27302
|
} else if (/\n/.test(text)) {
|
|
27262
27303
|
// Keep (up to one) blank line between tags/expressions/text.
|
|
@@ -27365,7 +27406,7 @@ function printJSXElement(path, options, print) {
|
|
|
27365
27406
|
} // Trim trailing lines (or empty strings)
|
|
27366
27407
|
|
|
27367
27408
|
|
|
27368
|
-
while (children.length && (isLineNext$1(getLast$
|
|
27409
|
+
while (children.length && (isLineNext$1(getLast$3(children)) || isEmpty$1(getLast$3(children)))) {
|
|
27369
27410
|
children.pop();
|
|
27370
27411
|
} // Trim leading lines (or empty strings)
|
|
27371
27412
|
|
|
@@ -27912,7 +27953,7 @@ function needsHardlineAfterDanglingComment(node) {
|
|
|
27912
27953
|
return false;
|
|
27913
27954
|
}
|
|
27914
27955
|
|
|
27915
|
-
var lastDanglingComment = getLast$
|
|
27956
|
+
var lastDanglingComment = getLast$3(node.comments.filter(function (comment) {
|
|
27916
27957
|
return !comment.leading && !comment.trailing;
|
|
27917
27958
|
}));
|
|
27918
27959
|
return lastDanglingComment && !comments$3.isBlockComment(lastDanglingComment);
|
|
@@ -27922,6 +27963,10 @@ function isLiteral(node) {
|
|
|
27922
27963
|
return node.type === "BooleanLiteral" || node.type === "DirectiveLiteral" || node.type === "Literal" || node.type === "NullLiteral" || node.type === "NumericLiteral" || node.type === "RegExpLiteral" || node.type === "StringLiteral" || node.type === "TemplateLiteral" || node.type === "TSTypeLiteral" || node.type === "JSXText";
|
|
27923
27964
|
}
|
|
27924
27965
|
|
|
27966
|
+
function isStringPropSafeToCoerceToIdentifier(node, options) {
|
|
27967
|
+
return isStringLiteral(node.key) && isIdentifierName(node.key.value) && !node.computed && options.parser !== "json" && !(options.parser === "typescript" && node.type === "ClassProperty");
|
|
27968
|
+
}
|
|
27969
|
+
|
|
27925
27970
|
function isNumericLiteral(node) {
|
|
27926
27971
|
return node.type === "NumericLiteral" || node.type === "Literal" && typeof node.value === "number";
|
|
27927
27972
|
}
|
|
@@ -28012,7 +28057,7 @@ function willPrintOwnComments(path) {
|
|
|
28012
28057
|
}
|
|
28013
28058
|
|
|
28014
28059
|
function canAttachComment$1(node) {
|
|
28015
|
-
return node.type && node.type !== "CommentBlock" && node.type !== "CommentLine" && node.type !== "Line" && node.type !== "Block" && node.type !== "EmptyStatement" && node.type !== "TemplateElement" && node.type !== "Import"
|
|
28060
|
+
return node.type && node.type !== "CommentBlock" && node.type !== "CommentLine" && node.type !== "Line" && node.type !== "Block" && node.type !== "EmptyStatement" && node.type !== "TemplateElement" && node.type !== "Import";
|
|
28016
28061
|
}
|
|
28017
28062
|
|
|
28018
28063
|
function printComment$2(commentPath, options) {
|
|
@@ -28210,6 +28255,23 @@ var options$12 = {
|
|
|
28210
28255
|
default: false,
|
|
28211
28256
|
description: "Use single quotes in JSX."
|
|
28212
28257
|
},
|
|
28258
|
+
quoteProps: {
|
|
28259
|
+
since: "1.17.0",
|
|
28260
|
+
category: CATEGORY_JAVASCRIPT,
|
|
28261
|
+
type: "choice",
|
|
28262
|
+
default: "as-needed",
|
|
28263
|
+
description: "Change when properties in objects are quoted.",
|
|
28264
|
+
choices: [{
|
|
28265
|
+
value: "as-needed",
|
|
28266
|
+
description: "Only add quotes around object properties where required."
|
|
28267
|
+
}, {
|
|
28268
|
+
value: "consistent",
|
|
28269
|
+
description: "If at least one property in an object requires quotes, quote all properties."
|
|
28270
|
+
}, {
|
|
28271
|
+
value: "preserve",
|
|
28272
|
+
description: "Respect the input use of quotes in object properties."
|
|
28273
|
+
}]
|
|
28274
|
+
},
|
|
28213
28275
|
trailingComma: {
|
|
28214
28276
|
since: "0.0.0",
|
|
28215
28277
|
category: CATEGORY_JAVASCRIPT,
|
|
@@ -28561,7 +28623,7 @@ var json$9 = {"cjkPattern":"[\\u02ea-\\u02eb\\u1100-\\u11ff\\u2e80-\\u2e99\\u2e9
|
|
|
28561
28623
|
var cjkPattern = json$9.cjkPattern;
|
|
28562
28624
|
var kPattern = json$9.kPattern;
|
|
28563
28625
|
var punctuationPattern$1 = json$9.punctuationPattern;
|
|
28564
|
-
var getLast$
|
|
28626
|
+
var getLast$4 = util.getLast;
|
|
28565
28627
|
var INLINE_NODE_TYPES$1 = ["liquidNode", "inlineCode", "emphasis", "strong", "delete", "link", "linkReference", "image", "imageReference", "footnote", "footnoteReference", "sentence", "whitespace", "word", "break", "inlineMath"];
|
|
28566
28628
|
var INLINE_NODE_WRAPPER_TYPES$1 = INLINE_NODE_TYPES$1.concat(["tableCell", "paragraph", "heading"]);
|
|
28567
28629
|
var kRegex = new RegExp(kPattern);
|
|
@@ -28606,7 +28668,7 @@ function splitText$1(text, options) {
|
|
|
28606
28668
|
value: innerToken,
|
|
28607
28669
|
kind: KIND_NON_CJK,
|
|
28608
28670
|
hasLeadingPunctuation: punctuationRegex.test(innerToken[0]),
|
|
28609
|
-
hasTrailingPunctuation: punctuationRegex.test(getLast$
|
|
28671
|
+
hasTrailingPunctuation: punctuationRegex.test(getLast$4(innerToken))
|
|
28610
28672
|
});
|
|
28611
28673
|
}
|
|
28612
28674
|
|
|
@@ -28632,7 +28694,7 @@ function splitText$1(text, options) {
|
|
|
28632
28694
|
return nodes;
|
|
28633
28695
|
|
|
28634
28696
|
function appendNode(node) {
|
|
28635
|
-
var lastNode = getLast$
|
|
28697
|
+
var lastNode = getLast$4(nodes);
|
|
28636
28698
|
|
|
28637
28699
|
if (lastNode && lastNode.type === "word") {
|
|
28638
28700
|
if (lastNode.kind === KIND_NON_CJK && node.kind === KIND_CJ_LETTER && !lastNode.hasTrailingPunctuation || lastNode.kind === KIND_CJ_LETTER && node.kind === KIND_NON_CJK && !node.hasLeadingPunctuation) {
|
|
@@ -29094,6 +29156,7 @@ function markAlignedList(ast, options) {
|
|
|
29094
29156
|
var preprocess_1$4 = preprocess$4;
|
|
29095
29157
|
|
|
29096
29158
|
var _require$$0$builders$8 = doc.builders;
|
|
29159
|
+
var breakParent$4 = _require$$0$builders$8.breakParent;
|
|
29097
29160
|
var concat$15 = _require$$0$builders$8.concat;
|
|
29098
29161
|
var join$11 = _require$$0$builders$8.join;
|
|
29099
29162
|
var line$10 = _require$$0$builders$8.line;
|
|
@@ -29101,6 +29164,7 @@ var literalline$5 = _require$$0$builders$8.literalline;
|
|
|
29101
29164
|
var markAsRoot$3 = _require$$0$builders$8.markAsRoot;
|
|
29102
29165
|
var hardline$11 = _require$$0$builders$8.hardline;
|
|
29103
29166
|
var softline$7 = _require$$0$builders$8.softline;
|
|
29167
|
+
var ifBreak$7 = _require$$0$builders$8.ifBreak;
|
|
29104
29168
|
var fill$5 = _require$$0$builders$8.fill;
|
|
29105
29169
|
var align$2 = _require$$0$builders$8.align;
|
|
29106
29170
|
var indent$9 = _require$$0$builders$8.indent;
|
|
@@ -29453,6 +29517,7 @@ function printLine(path, value, options) {
|
|
|
29453
29517
|
}
|
|
29454
29518
|
|
|
29455
29519
|
function printTable(path, options, print) {
|
|
29520
|
+
var hardlineWithoutBreakParent = hardline$11.parts[0];
|
|
29456
29521
|
var node = path.getValue();
|
|
29457
29522
|
var contents = []; // { [rowIndex: number]: { [columnIndex: number]: string } }
|
|
29458
29523
|
|
|
@@ -29462,7 +29527,8 @@ function printTable(path, options, print) {
|
|
|
29462
29527
|
rowContents.push(printDocToString$2(cellPath.call(print), options).formatted);
|
|
29463
29528
|
}, "children");
|
|
29464
29529
|
contents.push(rowContents);
|
|
29465
|
-
}, "children");
|
|
29530
|
+
}, "children"); // Get the width of each column
|
|
29531
|
+
|
|
29466
29532
|
var columnMaxWidths = contents.reduce(function (currentWidths, rowContents) {
|
|
29467
29533
|
return currentWidths.map(function (width, columnIndex) {
|
|
29468
29534
|
return Math.max(width, util.getStringWidth(rowContents[columnIndex]));
|
|
@@ -29471,28 +29537,48 @@ function printTable(path, options, print) {
|
|
|
29471
29537
|
return 3;
|
|
29472
29538
|
}) // minimum width = 3 (---, :--, :-:, --:)
|
|
29473
29539
|
);
|
|
29474
|
-
|
|
29475
|
-
|
|
29476
|
-
|
|
29540
|
+
var alignedTable = join$11(hardlineWithoutBreakParent, [printRow(contents[0]), printSeparator(), join$11(hardlineWithoutBreakParent, contents.slice(1).map(function (rowContents) {
|
|
29541
|
+
return printRow(rowContents);
|
|
29542
|
+
}))]);
|
|
29543
|
+
|
|
29544
|
+
if (options.proseWrap !== "never") {
|
|
29545
|
+
return concat$15([breakParent$4, alignedTable]);
|
|
29546
|
+
} // Only if the --prose-wrap never is set and it exceeds the print width.
|
|
29547
|
+
|
|
29548
|
+
|
|
29549
|
+
var compactTable = join$11(hardlineWithoutBreakParent, [printRow(contents[0],
|
|
29550
|
+
/* isCompact */
|
|
29551
|
+
true), printSeparator(
|
|
29552
|
+
/* isCompact */
|
|
29553
|
+
true), join$11(hardlineWithoutBreakParent, contents.slice(1).map(function (rowContents) {
|
|
29554
|
+
return printRow(rowContents,
|
|
29555
|
+
/* isCompact */
|
|
29556
|
+
true);
|
|
29557
|
+
}))]);
|
|
29558
|
+
return concat$15([breakParent$4, group$15(ifBreak$7(compactTable, alignedTable))]);
|
|
29559
|
+
|
|
29560
|
+
function printSeparator(isCompact) {
|
|
29477
29561
|
return concat$15(["| ", join$11(" | ", columnMaxWidths.map(function (width, index) {
|
|
29562
|
+
var spaces = isCompact ? 3 : width;
|
|
29563
|
+
|
|
29478
29564
|
switch (node.align[index]) {
|
|
29479
29565
|
case "left":
|
|
29480
|
-
return ":" + "-".repeat(
|
|
29566
|
+
return ":" + "-".repeat(spaces - 1);
|
|
29481
29567
|
|
|
29482
29568
|
case "right":
|
|
29483
|
-
return "-".repeat(
|
|
29569
|
+
return "-".repeat(spaces - 1) + ":";
|
|
29484
29570
|
|
|
29485
29571
|
case "center":
|
|
29486
|
-
return ":" + "-".repeat(
|
|
29572
|
+
return ":" + "-".repeat(spaces - 2) + ":";
|
|
29487
29573
|
|
|
29488
29574
|
default:
|
|
29489
|
-
return "-".repeat(
|
|
29575
|
+
return "-".repeat(spaces);
|
|
29490
29576
|
}
|
|
29491
29577
|
})), " |"]);
|
|
29492
29578
|
}
|
|
29493
29579
|
|
|
29494
|
-
function printRow(rowContents) {
|
|
29495
|
-
return concat$15(["| ", join$11(" | ", rowContents.map(function (rowContent, columnIndex) {
|
|
29580
|
+
function printRow(rowContents, isCompact) {
|
|
29581
|
+
return concat$15(["| ", join$11(" | ", isCompact ? rowContents : rowContents.map(function (rowContent, columnIndex) {
|
|
29496
29582
|
switch (node.align[columnIndex]) {
|
|
29497
29583
|
case "right":
|
|
29498
29584
|
return alignRight(rowContent, columnMaxWidths[columnIndex]);
|
|
@@ -29507,11 +29593,13 @@ function printTable(path, options, print) {
|
|
|
29507
29593
|
}
|
|
29508
29594
|
|
|
29509
29595
|
function alignLeft(text, width) {
|
|
29510
|
-
|
|
29596
|
+
var spaces = width - util.getStringWidth(text);
|
|
29597
|
+
return concat$15([text, " ".repeat(spaces)]);
|
|
29511
29598
|
}
|
|
29512
29599
|
|
|
29513
29600
|
function alignRight(text, width) {
|
|
29514
|
-
|
|
29601
|
+
var spaces = width - util.getStringWidth(text);
|
|
29602
|
+
return concat$15([" ".repeat(spaces), text]);
|
|
29515
29603
|
}
|
|
29516
29604
|
|
|
29517
29605
|
function alignCenter(text, width) {
|
|
@@ -29896,7 +29984,7 @@ var pragma$11 = {
|
|
|
29896
29984
|
insertPragma: insertPragma$9
|
|
29897
29985
|
};
|
|
29898
29986
|
|
|
29899
|
-
var getLast$
|
|
29987
|
+
var getLast$6 = util.getLast;
|
|
29900
29988
|
|
|
29901
29989
|
function getAncestorCount$1(path, filter) {
|
|
29902
29990
|
var counter = 0;
|
|
@@ -29985,7 +30073,7 @@ function isLastDescendantNode$1(path) {
|
|
|
29985
30073
|
}
|
|
29986
30074
|
|
|
29987
30075
|
function getLastDescendantNode$2(node) {
|
|
29988
|
-
return "children" in node && node.children.length !== 0 ? getLastDescendantNode$2(getLast$
|
|
30076
|
+
return "children" in node && node.children.length !== 0 ? getLastDescendantNode$2(getLast$6(node.children)) : node;
|
|
29989
30077
|
}
|
|
29990
30078
|
|
|
29991
30079
|
function isPrettierIgnore$2(comment) {
|
|
@@ -29997,10 +30085,10 @@ function hasPrettierIgnore$5(path) {
|
|
|
29997
30085
|
|
|
29998
30086
|
if (node.type === "documentBody") {
|
|
29999
30087
|
var document = path.getParentNode();
|
|
30000
|
-
return hasEndComments$1(document.head) && isPrettierIgnore$2(getLast$
|
|
30088
|
+
return hasEndComments$1(document.head) && isPrettierIgnore$2(getLast$6(document.head.endComments));
|
|
30001
30089
|
}
|
|
30002
30090
|
|
|
30003
|
-
return hasLeadingComments$1(node) && isPrettierIgnore$2(getLast$
|
|
30091
|
+
return hasLeadingComments$1(node) && isPrettierIgnore$2(getLast$6(node.leadingComments));
|
|
30004
30092
|
}
|
|
30005
30093
|
|
|
30006
30094
|
function isEmptyNode$1(node) {
|
|
@@ -30100,7 +30188,7 @@ function getFlowScalarLineContents$1(nodeType, content, options) {
|
|
|
30100
30188
|
return lineContent.length === 0 ? [] : splitWithSingleSpace(lineContent);
|
|
30101
30189
|
}).reduce(function (reduced, lineContentWords, index) {
|
|
30102
30190
|
return index !== 0 && rawLineContents[index - 1].length !== 0 && lineContentWords.length !== 0 && !( // trailing backslash in quoteDouble should be preserved
|
|
30103
|
-
nodeType === "quoteDouble" && getLast$
|
|
30191
|
+
nodeType === "quoteDouble" && getLast$6(getLast$6(reduced)).endsWith("\\")) ? reduced.concat([reduced.pop().concat(lineContentWords)]) : reduced.concat([lineContentWords]);
|
|
30104
30192
|
}, []).map(function (lineContentWords) {
|
|
30105
30193
|
return options.proseWrap === "never" ? [lineContentWords.join(" ")] : lineContentWords;
|
|
30106
30194
|
});
|
|
@@ -30128,11 +30216,11 @@ function getBlockValueLineContents$1(node, _ref) {
|
|
|
30128
30216
|
return removeUnnecessaryTrailingNewlines(rawLineContents.map(function (lineContent) {
|
|
30129
30217
|
return lineContent.length === 0 ? [] : splitWithSingleSpace(lineContent);
|
|
30130
30218
|
}).reduce(function (reduced, lineContentWords, index) {
|
|
30131
|
-
return index !== 0 && rawLineContents[index - 1].length !== 0 && lineContentWords.length !== 0 && !/^\s/.test(lineContentWords[0]) && !/^\s|\s$/.test(getLast$
|
|
30219
|
+
return index !== 0 && rawLineContents[index - 1].length !== 0 && lineContentWords.length !== 0 && !/^\s/.test(lineContentWords[0]) && !/^\s|\s$/.test(getLast$6(reduced)) ? reduced.concat([reduced.pop().concat(lineContentWords)]) : reduced.concat([lineContentWords]);
|
|
30132
30220
|
}, []).map(function (lineContentWords) {
|
|
30133
30221
|
return lineContentWords.reduce(function (reduced, word) {
|
|
30134
30222
|
return (// disallow trailing spaces
|
|
30135
|
-
reduced.length !== 0 && /\s$/.test(getLast$
|
|
30223
|
+
reduced.length !== 0 && /\s$/.test(getLast$6(reduced)) ? reduced.concat(reduced.pop() + " " + word) : reduced.concat(word)
|
|
30136
30224
|
);
|
|
30137
30225
|
}, []);
|
|
30138
30226
|
}).map(function (lineContentWords) {
|
|
@@ -30141,7 +30229,7 @@ function getBlockValueLineContents$1(node, _ref) {
|
|
|
30141
30229
|
|
|
30142
30230
|
function removeUnnecessaryTrailingNewlines(lineContents) {
|
|
30143
30231
|
if (node.chomping === "keep") {
|
|
30144
|
-
return getLast$
|
|
30232
|
+
return getLast$6(lineContents).length === 0 ? lineContents.slice(0, -1) : lineContents;
|
|
30145
30233
|
}
|
|
30146
30234
|
|
|
30147
30235
|
var trailingNewlineCount = 0;
|
|
@@ -30160,7 +30248,7 @@ function getBlockValueLineContents$1(node, _ref) {
|
|
|
30160
30248
|
}
|
|
30161
30249
|
|
|
30162
30250
|
var utils$12 = {
|
|
30163
|
-
getLast: getLast$
|
|
30251
|
+
getLast: getLast$6,
|
|
30164
30252
|
getAncestorCount: getAncestorCount$1,
|
|
30165
30253
|
isNode: isNode$1,
|
|
30166
30254
|
isEmptyNode: isEmptyNode$1,
|
|
@@ -30184,7 +30272,7 @@ var isPragma = pragma$11.isPragma;
|
|
|
30184
30272
|
var getAncestorCount = utils$12.getAncestorCount;
|
|
30185
30273
|
var getBlockValueLineContents = utils$12.getBlockValueLineContents;
|
|
30186
30274
|
var getFlowScalarLineContents = utils$12.getFlowScalarLineContents;
|
|
30187
|
-
var getLast$
|
|
30275
|
+
var getLast$5 = utils$12.getLast;
|
|
30188
30276
|
var getLastDescendantNode$1 = utils$12.getLastDescendantNode;
|
|
30189
30277
|
var hasLeadingComments = utils$12.hasLeadingComments;
|
|
30190
30278
|
var hasMiddleComments = utils$12.hasMiddleComments;
|
|
@@ -30200,14 +30288,14 @@ var defineShortcut = utils$12.defineShortcut;
|
|
|
30200
30288
|
var mapNode = utils$12.mapNode;
|
|
30201
30289
|
var docBuilders$3 = doc.builders;
|
|
30202
30290
|
var conditionalGroup$2 = docBuilders$3.conditionalGroup;
|
|
30203
|
-
var breakParent$
|
|
30291
|
+
var breakParent$5 = docBuilders$3.breakParent;
|
|
30204
30292
|
var concat$17 = docBuilders$3.concat;
|
|
30205
30293
|
var dedent$4 = docBuilders$3.dedent;
|
|
30206
30294
|
var dedentToRoot$3 = docBuilders$3.dedentToRoot;
|
|
30207
30295
|
var fill$6 = docBuilders$3.fill;
|
|
30208
30296
|
var group$16 = docBuilders$3.group;
|
|
30209
30297
|
var hardline$13 = docBuilders$3.hardline;
|
|
30210
|
-
var ifBreak$
|
|
30298
|
+
var ifBreak$8 = docBuilders$3.ifBreak;
|
|
30211
30299
|
var join$12 = docBuilders$3.join;
|
|
30212
30300
|
var line$11 = docBuilders$3.line;
|
|
30213
30301
|
var lineSuffix$2 = docBuilders$3.lineSuffix;
|
|
@@ -30261,7 +30349,7 @@ function genericPrint$6(path, options, print) {
|
|
|
30261
30349
|
var tag = !node.tag ? "" : path.call(print, "tag");
|
|
30262
30350
|
var anchor = !node.anchor ? "" : path.call(print, "anchor");
|
|
30263
30351
|
var nextEmptyLine = isNode(node, ["mapping", "sequence", "comment", "directive", "mappingItem", "sequenceItem"]) && !isLastDescendantNode(path) ? printNextEmptyLine(path, options.originalText) : "";
|
|
30264
|
-
return concat$17([node.type !== "mappingValue" && hasLeadingComments(node) ? concat$17([join$12(hardline$13, path.map(print, "leadingComments")), hardline$13]) : "", tag, tag && anchor ? " " : "", anchor, tag || anchor ? isNode(node, ["sequence", "mapping"]) && !hasMiddleComments(node) ? hardline$13 : " " : "", hasMiddleComments(node) ? concat$17([node.middleComments.length === 1 ? "" : hardline$13, join$12(hardline$13, path.map(print, "middleComments")), hardline$13]) : "", hasPrettierIgnore$4(path) ? concat$17(replaceEndOfLineWith$3(options.originalText.slice(node.position.start.offset, node.position.end.offset), literalline$7)) : group$16(_print(node, parentNode, path, options, print)), hasTrailingComment$1(node) && !isNode(node, ["document", "documentHead"]) ? lineSuffix$2(concat$17([node.type === "mappingValue" && !node.content ? "" : " ", parentNode.type === "mappingKey" && path.getParentNode(2).type === "mapping" && isInlineNode(node) ? "" : breakParent$
|
|
30352
|
+
return concat$17([node.type !== "mappingValue" && hasLeadingComments(node) ? concat$17([join$12(hardline$13, path.map(print, "leadingComments")), hardline$13]) : "", tag, tag && anchor ? " " : "", anchor, tag || anchor ? isNode(node, ["sequence", "mapping"]) && !hasMiddleComments(node) ? hardline$13 : " " : "", hasMiddleComments(node) ? concat$17([node.middleComments.length === 1 ? "" : hardline$13, join$12(hardline$13, path.map(print, "middleComments")), hardline$13]) : "", hasPrettierIgnore$4(path) ? concat$17(replaceEndOfLineWith$3(options.originalText.slice(node.position.start.offset, node.position.end.offset), literalline$7)) : group$16(_print(node, parentNode, path, options, print)), hasTrailingComment$1(node) && !isNode(node, ["document", "documentHead"]) ? lineSuffix$2(concat$17([node.type === "mappingValue" && !node.content ? "" : " ", parentNode.type === "mappingKey" && path.getParentNode(2).type === "mapping" && isInlineNode(node) ? "" : breakParent$5, path.call(print, "trailingComment")])) : "", nextEmptyLine, hasEndComments(node) && !isNode(node, ["documentHead", "documentBody"]) ? align$3(node.type === "sequenceItem" ? 2 : 0, concat$17([hardline$13, join$12(hardline$13, path.map(print, "endComments"))])) : ""]);
|
|
30265
30353
|
}
|
|
30266
30354
|
|
|
30267
30355
|
function _print(node, parentNode, path, options, print) {
|
|
@@ -30397,9 +30485,9 @@ function _print(node, parentNode, path, options, print) {
|
|
|
30397
30485
|
return forceExplicitKey ? concat$17(["? ", align$3(2, key), hardline$13, join$12("", path.map(print, "value", "leadingComments").map(function (comment) {
|
|
30398
30486
|
return concat$17([comment, hardline$13]);
|
|
30399
30487
|
})), ": ", align$3(2, value)]) : // force singleline
|
|
30400
|
-
isSingleLineNode(node.key.content) && !hasLeadingComments(node.key.content) && !hasMiddleComments(node.key.content) && !hasTrailingComment$1(node.key.content) && !hasEndComments(node.key) && !hasLeadingComments(node.value.content) && !hasMiddleComments(node.value.content) && !hasEndComments(node.value) && isAbsolutelyPrintedAsSingleLineNode(node.value.content, options) ? concat$17([key, needsSpaceInFrontOfMappingValue(node) ? " " : "", ": ", value]) : conditionalGroup$2([concat$17([group$16(concat$17([ifBreak$
|
|
30488
|
+
isSingleLineNode(node.key.content) && !hasLeadingComments(node.key.content) && !hasMiddleComments(node.key.content) && !hasTrailingComment$1(node.key.content) && !hasEndComments(node.key) && !hasLeadingComments(node.value.content) && !hasMiddleComments(node.value.content) && !hasEndComments(node.value) && isAbsolutelyPrintedAsSingleLineNode(node.value.content, options) ? concat$17([key, needsSpaceInFrontOfMappingValue(node) ? " " : "", ": ", value]) : conditionalGroup$2([concat$17([group$16(concat$17([ifBreak$8("? "), group$16(align$3(2, key), {
|
|
30401
30489
|
id: groupId
|
|
30402
|
-
})])), ifBreak$
|
|
30490
|
+
})])), ifBreak$8(concat$17([hardline$13, ": ", align$3(2, value)]), indent(concat$17([needsSpaceInFrontOfMappingValue(node) ? " " : "", ":", hasLeadingComments(node.value.content) || hasEndComments(node.value) && node.value.content && !isNode(node.value.content, ["mapping", "sequence"]) || parentNode.type === "mapping" && hasTrailingComment$1(node.key.content) && isInlineNode(node.value.content) || isNode(node.value.content, ["mapping", "sequence"]) && node.value.content.tag === null && node.value.content.anchor === null ? hardline$13 : !node.value.content ? "" : line$11, value])), {
|
|
30403
30491
|
groupId: groupId
|
|
30404
30492
|
})])]);
|
|
30405
30493
|
}
|
|
@@ -30413,11 +30501,11 @@ function _print(node, parentNode, path, options, print) {
|
|
|
30413
30501
|
|
|
30414
30502
|
var isLastItemEmptyMappingItem = node.children.length !== 0 && function (lastItem) {
|
|
30415
30503
|
return lastItem.type === "flowMappingItem" && isEmptyNode(lastItem.key) && isEmptyNode(lastItem.value);
|
|
30416
|
-
}(getLast$
|
|
30504
|
+
}(getLast$5(node.children));
|
|
30417
30505
|
|
|
30418
30506
|
return concat$17([openMarker, indent(concat$17([bracketSpacing, concat$17(path.map(function (childPath, index) {
|
|
30419
30507
|
return concat$17([print(childPath), index === node.children.length - 1 ? "" : concat$17([",", line$11, node.children[index].position.start.line !== node.children[index + 1].position.start.line ? printNextEmptyLine(childPath, options.originalText) : ""])]);
|
|
30420
|
-
}, "children")), ifBreak$
|
|
30508
|
+
}, "children")), ifBreak$8(",", "")])), isLastItemEmptyMappingItem ? "" : bracketSpacing, closeMarker]);
|
|
30421
30509
|
}
|
|
30422
30510
|
|
|
30423
30511
|
case "flowSequenceItem":
|