prettier 1.16.1 → 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 +680 -489
- package/doc.js +1935 -0
- package/index.js +668 -485
- 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 +296 -144
- package/third-party.js +353 -133
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,12 @@ 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",
|
|
51
|
+
"is-ci": "2.0.0",
|
|
50
52
|
"jest-docblock": "23.2.0",
|
|
51
53
|
"json-stable-stringify": "1.0.1",
|
|
52
54
|
"leven": "2.1.0",
|
|
@@ -70,8 +72,7 @@ var dependencies = {
|
|
|
70
72
|
"resolve": "1.5.0",
|
|
71
73
|
"semver": "5.4.1",
|
|
72
74
|
"string-width": "3.0.0",
|
|
73
|
-
"typescript": "3.
|
|
74
|
-
"typescript-estree": "18.0.0",
|
|
75
|
+
"typescript": "3.4.1",
|
|
75
76
|
"unicode-regex": "2.0.0",
|
|
76
77
|
"unified": "6.1.6",
|
|
77
78
|
"vnopts": "1.0.2",
|
|
@@ -100,7 +101,7 @@ var devDependencies = {
|
|
|
100
101
|
"jest-snapshot-serializer-raw": "1.1.0",
|
|
101
102
|
"jest-watch-typeahead": "0.1.0",
|
|
102
103
|
"mkdirp": "0.5.1",
|
|
103
|
-
"prettier": "1.16.
|
|
104
|
+
"prettier": "1.16.4",
|
|
104
105
|
"prettylint": "1.0.0",
|
|
105
106
|
"rimraf": "2.6.2",
|
|
106
107
|
"rollup": "0.47.6",
|
|
@@ -119,9 +120,6 @@ var devDependencies = {
|
|
|
119
120
|
"tempy": "0.2.1",
|
|
120
121
|
"webpack": "3.12.0"
|
|
121
122
|
};
|
|
122
|
-
var resolutions = {
|
|
123
|
-
"@babel/code-frame": "7.0.0-beta.46"
|
|
124
|
-
};
|
|
125
123
|
var scripts = {
|
|
126
124
|
"prepublishOnly": "echo \"Error: must publish from dist/\" && exit 1",
|
|
127
125
|
"prepare-release": "yarn && yarn build && yarn test:dist",
|
|
@@ -151,7 +149,6 @@ var _package = {
|
|
|
151
149
|
engines: engines,
|
|
152
150
|
dependencies: dependencies,
|
|
153
151
|
devDependencies: devDependencies,
|
|
154
|
-
resolutions: resolutions,
|
|
155
152
|
scripts: scripts
|
|
156
153
|
};
|
|
157
154
|
|
|
@@ -168,7 +165,6 @@ var _package$1 = Object.freeze({
|
|
|
168
165
|
engines: engines,
|
|
169
166
|
dependencies: dependencies,
|
|
170
167
|
devDependencies: devDependencies,
|
|
171
|
-
resolutions: resolutions,
|
|
172
168
|
scripts: scripts,
|
|
173
169
|
default: _package
|
|
174
170
|
});
|
|
@@ -6317,6 +6313,10 @@ var options$2 = {
|
|
|
6317
6313
|
value: "angular",
|
|
6318
6314
|
since: "1.15.0",
|
|
6319
6315
|
description: "Angular"
|
|
6316
|
+
}, {
|
|
6317
|
+
value: "lwc",
|
|
6318
|
+
since: "1.17.0",
|
|
6319
|
+
description: "Lightning Web Components"
|
|
6320
6320
|
}]
|
|
6321
6321
|
},
|
|
6322
6322
|
plugins: {
|
|
@@ -6495,6 +6495,7 @@ function getSupportInfo$2(version, opts) {
|
|
|
6495
6495
|
});
|
|
6496
6496
|
});
|
|
6497
6497
|
var usePostCssParser = semver.lt(version, "1.7.1");
|
|
6498
|
+
var useBabylonParser = semver.lt(version, "1.16.0");
|
|
6498
6499
|
var languages = plugins.reduce(function (all, plugin) {
|
|
6499
6500
|
return all.concat(plugin.languages || []);
|
|
6500
6501
|
}, []).filter(filterSince).map(function (language) {
|
|
@@ -6509,6 +6510,15 @@ function getSupportInfo$2(version, opts) {
|
|
|
6509
6510
|
return Object.assign({}, language, {
|
|
6510
6511
|
parsers: ["typescript"]
|
|
6511
6512
|
});
|
|
6513
|
+
} // "babylon" was renamed to "babel" in 1.16.0
|
|
6514
|
+
|
|
6515
|
+
|
|
6516
|
+
if (useBabylonParser && language.parsers.indexOf("babel") !== -1) {
|
|
6517
|
+
return Object.assign({}, language, {
|
|
6518
|
+
parsers: language.parsers.map(function (parser) {
|
|
6519
|
+
return parser === "babel" ? "babylon" : parser;
|
|
6520
|
+
})
|
|
6521
|
+
});
|
|
6512
6522
|
}
|
|
6513
6523
|
|
|
6514
6524
|
if (usePostCssParser && (language.name === "CSS" || language.group === "CSS")) {
|
|
@@ -11321,19 +11331,20 @@ var loc = {
|
|
|
11321
11331
|
};
|
|
11322
11332
|
|
|
11323
11333
|
var jsTokens = createCommonjsModule(function (module, exports) {
|
|
11324
|
-
// Copyright 2014, 2015, 2016, 2017 Simon Lydell
|
|
11334
|
+
// Copyright 2014, 2015, 2016, 2017, 2018 Simon Lydell
|
|
11325
11335
|
// License: MIT. (See LICENSE.)
|
|
11326
11336
|
Object.defineProperty(exports, "__esModule", {
|
|
11327
11337
|
value: true
|
|
11328
11338
|
}); // This regex comes from regex.coffee, and is inserted here by generate-index.js
|
|
11329
11339
|
// (run `npm run build`).
|
|
11330
11340
|
|
|
11331
|
-
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;
|
|
11332
11342
|
|
|
11333
11343
|
exports.matchToToken = function (match) {
|
|
11334
11344
|
var token = {
|
|
11335
11345
|
type: "invalid",
|
|
11336
|
-
value: match[0]
|
|
11346
|
+
value: match[0],
|
|
11347
|
+
closed: undefined
|
|
11337
11348
|
};
|
|
11338
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";
|
|
11339
11350
|
return token;
|
|
@@ -12454,7 +12465,7 @@ var lib$3 = createCommonjsModule(function (module, exports) {
|
|
|
12454
12465
|
exports.default = highlight;
|
|
12455
12466
|
|
|
12456
12467
|
function _jsTokens() {
|
|
12457
|
-
var data = _interopRequireWildcard(jsTokens);
|
|
12468
|
+
var data = _interopRequireWildcard$$1(jsTokens);
|
|
12458
12469
|
|
|
12459
12470
|
_jsTokens = function _jsTokens() {
|
|
12460
12471
|
return data;
|
|
@@ -12464,7 +12475,7 @@ var lib$3 = createCommonjsModule(function (module, exports) {
|
|
|
12464
12475
|
}
|
|
12465
12476
|
|
|
12466
12477
|
function _esutils() {
|
|
12467
|
-
var data = _interopRequireDefault(utils$2);
|
|
12478
|
+
var data = _interopRequireDefault$$1(utils$2);
|
|
12468
12479
|
|
|
12469
12480
|
_esutils = function _esutils() {
|
|
12470
12481
|
return data;
|
|
@@ -12474,7 +12485,7 @@ var lib$3 = createCommonjsModule(function (module, exports) {
|
|
|
12474
12485
|
}
|
|
12475
12486
|
|
|
12476
12487
|
function _chalk() {
|
|
12477
|
-
var data = _interopRequireDefault(chalk$5);
|
|
12488
|
+
var data = _interopRequireDefault$$1(chalk$5);
|
|
12478
12489
|
|
|
12479
12490
|
_chalk = function _chalk() {
|
|
12480
12491
|
return data;
|
|
@@ -12483,13 +12494,13 @@ var lib$3 = createCommonjsModule(function (module, exports) {
|
|
|
12483
12494
|
return data;
|
|
12484
12495
|
}
|
|
12485
12496
|
|
|
12486
|
-
function _interopRequireDefault(obj) {
|
|
12497
|
+
function _interopRequireDefault$$1(obj) {
|
|
12487
12498
|
return obj && obj.__esModule ? obj : {
|
|
12488
12499
|
default: obj
|
|
12489
12500
|
};
|
|
12490
12501
|
}
|
|
12491
12502
|
|
|
12492
|
-
function _interopRequireWildcard(obj) {
|
|
12503
|
+
function _interopRequireWildcard$$1(obj) {
|
|
12493
12504
|
if (obj && obj.__esModule) {
|
|
12494
12505
|
return obj;
|
|
12495
12506
|
} else {
|
|
@@ -12534,8 +12545,9 @@ var lib$3 = createCommonjsModule(function (module, exports) {
|
|
|
12534
12545
|
|
|
12535
12546
|
function getTokenType(match) {
|
|
12536
12547
|
var _match$slice = match.slice(-2),
|
|
12537
|
-
|
|
12538
|
-
|
|
12548
|
+
_match$slice2 = _slicedToArray(_match$slice, 2),
|
|
12549
|
+
offset = _match$slice2[0],
|
|
12550
|
+
text = _match$slice2[1];
|
|
12539
12551
|
|
|
12540
12552
|
var token = (0, _jsTokens().matchToToken)(match);
|
|
12541
12553
|
|
|
@@ -12600,10 +12612,8 @@ var lib$3 = createCommonjsModule(function (module, exports) {
|
|
|
12600
12612
|
return chalk;
|
|
12601
12613
|
}
|
|
12602
12614
|
|
|
12603
|
-
function highlight(code
|
|
12604
|
-
|
|
12605
|
-
options = {};
|
|
12606
|
-
}
|
|
12615
|
+
function highlight(code) {
|
|
12616
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
12607
12617
|
|
|
12608
12618
|
if (shouldHighlight(options)) {
|
|
12609
12619
|
var chalk = getChalk(options);
|
|
@@ -12673,7 +12683,7 @@ var lib$2 = createCommonjsModule(function (module, exports) {
|
|
|
12673
12683
|
var NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
|
|
12674
12684
|
|
|
12675
12685
|
function getMarkerLines(loc, source, opts) {
|
|
12676
|
-
var startLoc = Object.assign({
|
|
12686
|
+
var startLoc = Object.assign({
|
|
12677
12687
|
column: 0,
|
|
12678
12688
|
line: -1
|
|
12679
12689
|
}, loc.start);
|
|
@@ -12738,11 +12748,8 @@ var lib$2 = createCommonjsModule(function (module, exports) {
|
|
|
12738
12748
|
};
|
|
12739
12749
|
}
|
|
12740
12750
|
|
|
12741
|
-
function codeFrameColumns(rawLines, loc
|
|
12742
|
-
|
|
12743
|
-
opts = {};
|
|
12744
|
-
}
|
|
12745
|
-
|
|
12751
|
+
function codeFrameColumns(rawLines, loc) {
|
|
12752
|
+
var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
12746
12753
|
var highlighted = (opts.highlightCode || opts.forceColor) && (0, _highlight().shouldHighlight)(opts);
|
|
12747
12754
|
var chalk = (0, _highlight().getChalk)(opts);
|
|
12748
12755
|
var defs = getDefs(chalk);
|
|
@@ -12763,8 +12770,8 @@ var lib$2 = createCommonjsModule(function (module, exports) {
|
|
|
12763
12770
|
var numberMaxWidth = String(end).length;
|
|
12764
12771
|
var frame = lines.slice(start, end).map(function (line, index) {
|
|
12765
12772
|
var number = start + 1 + index;
|
|
12766
|
-
var paddedNumber =
|
|
12767
|
-
var gutter = " "
|
|
12773
|
+
var paddedNumber = " ".concat(number).slice(-numberMaxWidth);
|
|
12774
|
+
var gutter = " ".concat(paddedNumber, " | ");
|
|
12768
12775
|
var hasMarker = markerLines[number];
|
|
12769
12776
|
var lastMarkerLine = !markerLines[number + 1];
|
|
12770
12777
|
|
|
@@ -12783,12 +12790,12 @@ var lib$2 = createCommonjsModule(function (module, exports) {
|
|
|
12783
12790
|
|
|
12784
12791
|
return [maybeHighlight(defs.marker, ">"), maybeHighlight(defs.gutter, gutter), line, markerLine].join("");
|
|
12785
12792
|
} else {
|
|
12786
|
-
return " "
|
|
12793
|
+
return " ".concat(maybeHighlight(defs.gutter, gutter)).concat(line);
|
|
12787
12794
|
}
|
|
12788
12795
|
}).join("\n");
|
|
12789
12796
|
|
|
12790
12797
|
if (opts.message && !hasColumns) {
|
|
12791
|
-
frame = ""
|
|
12798
|
+
frame = "".concat(" ".repeat(numberMaxWidth + 1)).concat(opts.message, "\n").concat(frame);
|
|
12792
12799
|
}
|
|
12793
12800
|
|
|
12794
12801
|
if (highlighted) {
|
|
@@ -12798,10 +12805,8 @@ var lib$2 = createCommonjsModule(function (module, exports) {
|
|
|
12798
12805
|
}
|
|
12799
12806
|
}
|
|
12800
12807
|
|
|
12801
|
-
function _default(rawLines, lineNumber, colNumber
|
|
12802
|
-
|
|
12803
|
-
opts = {};
|
|
12804
|
-
}
|
|
12808
|
+
function _default(rawLines, lineNumber, colNumber) {
|
|
12809
|
+
var opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
12805
12810
|
|
|
12806
12811
|
if (!deprecationWarningShown) {
|
|
12807
12812
|
deprecationWarningShown = true;
|
|
@@ -13469,14 +13474,6 @@ function getPenultimate(arr) {
|
|
|
13469
13474
|
return null;
|
|
13470
13475
|
}
|
|
13471
13476
|
|
|
13472
|
-
function getLast$3(arr) {
|
|
13473
|
-
if (arr.length > 0) {
|
|
13474
|
-
return arr[arr.length - 1];
|
|
13475
|
-
}
|
|
13476
|
-
|
|
13477
|
-
return null;
|
|
13478
|
-
}
|
|
13479
|
-
|
|
13480
13477
|
function skip(chars) {
|
|
13481
13478
|
return function (text, index, opts) {
|
|
13482
13479
|
var backwards = opts && opts.backwards; // Allow `skip` functions to be threaded together without having
|
|
@@ -13891,7 +13888,7 @@ function printString(raw, options, isDirectiveLiteral) {
|
|
|
13891
13888
|
// sure that we consistently output the minimum amount of escaped quotes.
|
|
13892
13889
|
|
|
13893
13890
|
|
|
13894
|
-
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"));
|
|
13895
13892
|
}
|
|
13896
13893
|
|
|
13897
13894
|
function makeString(rawContent, enclosingQuote, unescapeUnnecessaryEscapes) {
|
|
@@ -14079,7 +14076,7 @@ var util = {
|
|
|
14079
14076
|
isExportDeclaration: isExportDeclaration,
|
|
14080
14077
|
getParentExportDeclaration: getParentExportDeclaration,
|
|
14081
14078
|
getPenultimate: getPenultimate,
|
|
14082
|
-
getLast: getLast
|
|
14079
|
+
getLast: getLast,
|
|
14083
14080
|
getNextNonSpaceNonCommentCharacterIndexWithStartIndex: getNextNonSpaceNonCommentCharacterIndexWithStartIndex,
|
|
14084
14081
|
getNextNonSpaceNonCommentCharacterIndex: getNextNonSpaceNonCommentCharacterIndex,
|
|
14085
14082
|
getNextNonSpaceNonCommentCharacter: getNextNonSpaceNonCommentCharacter,
|
|
@@ -15532,7 +15529,7 @@ function printTrailingComment(commentPath, print, options) {
|
|
|
15532
15529
|
return concat([" ", contents]);
|
|
15533
15530
|
}
|
|
15534
15531
|
|
|
15535
|
-
return concat([lineSuffix(" "
|
|
15532
|
+
return concat([lineSuffix(concat([" ", contents])), !isBlock ? breakParent : ""]);
|
|
15536
15533
|
}
|
|
15537
15534
|
|
|
15538
15535
|
function printDanglingComments(path, options, sameIndent, filter) {
|
|
@@ -18174,7 +18171,7 @@ function genericPrint$1(path, options, print) {
|
|
|
18174
18171
|
|
|
18175
18172
|
case "FragmentDefinition":
|
|
18176
18173
|
{
|
|
18177
|
-
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")]);
|
|
18178
18175
|
}
|
|
18179
18176
|
|
|
18180
18177
|
case "SelectionSet":
|
|
@@ -18257,7 +18254,7 @@ function genericPrint$1(path, options, print) {
|
|
|
18257
18254
|
|
|
18258
18255
|
case "VariableDefinition":
|
|
18259
18256
|
{
|
|
18260
|
-
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)]);
|
|
18261
18258
|
}
|
|
18262
18259
|
|
|
18263
18260
|
case "TypeExtensionDefinition":
|
|
@@ -20663,6 +20660,15 @@ function embed$2(path, print, textToDoc, options) {
|
|
|
20663
20660
|
|
|
20664
20661
|
if (/^PRETTIER_HTML_PLACEHOLDER_\d+_IN_JS$/.test(options.originalText.slice(node.valueSpan.start.offset, node.valueSpan.end.offset))) {
|
|
20665
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
|
+
}
|
|
20666
20672
|
}
|
|
20667
20673
|
|
|
20668
20674
|
var embeddedAttributeValueDoc = printEmbeddedAttributeValue(node, function (code, opts) {
|
|
@@ -21152,8 +21158,8 @@ function printClosingTagEndMarker(node, options) {
|
|
|
21152
21158
|
|
|
21153
21159
|
function getTextValueParts(node) {
|
|
21154
21160
|
var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : node.value;
|
|
21155
|
-
return node.parent.isWhitespaceSensitive ? node.parent.isIndentationSensitive ? replaceEndOfLineWith$1(value, literalline$2) : replaceEndOfLineWith$1(dedentString(value.replace(/^\s*?\n|\n\s*?$/g, "")), hardline$7) : //
|
|
21156
|
-
join$5(line$6, value.split(/[
|
|
21161
|
+
return node.parent.isWhitespaceSensitive ? node.parent.isIndentationSensitive ? replaceEndOfLineWith$1(value, literalline$2) : replaceEndOfLineWith$1(dedentString(value.replace(/^\s*?\n|\n\s*?$/g, "")), hardline$7) : // https://infra.spec.whatwg.org/#ascii-whitespace
|
|
21162
|
+
join$5(line$6, value.split(/[\t\n\f\r ]+/)).parts;
|
|
21157
21163
|
}
|
|
21158
21164
|
|
|
21159
21165
|
function printEmbeddedAttributeValue(node, originalTextToDoc, options) {
|
|
@@ -21443,6 +21449,15 @@ var languages$3 = [createLanguage(require$$0$22, {
|
|
|
21443
21449
|
extensions: [".mjml" // MJML is considered XML in Linguist but it should be formatted as HTML
|
|
21444
21450
|
]
|
|
21445
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
|
+
}
|
|
21446
21461
|
}), createLanguage(require$$1$9, {
|
|
21447
21462
|
override: {
|
|
21448
21463
|
since: "1.10.0",
|
|
@@ -22705,9 +22720,62 @@ function hasClosureCompilerTypeCastComment(text, path, locStart, locEnd) {
|
|
|
22705
22720
|
|
|
22706
22721
|
function hasTypeCastComment(node) {
|
|
22707
22722
|
return node.comments && node.comments.some(function (comment) {
|
|
22708
|
-
return comment.leading && comments$3.isBlockComment(comment) && comment.value
|
|
22723
|
+
return comment.leading && comments$3.isBlockComment(comment) && isTypeCastComment(comment.value) && util.getNextNonSpaceNonCommentCharacter(text, comment, locEnd) === "(";
|
|
22709
22724
|
});
|
|
22710
22725
|
}
|
|
22726
|
+
|
|
22727
|
+
function isTypeCastComment(comment) {
|
|
22728
|
+
var trimmed = comment.trim();
|
|
22729
|
+
|
|
22730
|
+
if (!/^\*\s*@type\s*\{[^]+\}$/.test(trimmed)) {
|
|
22731
|
+
return false;
|
|
22732
|
+
}
|
|
22733
|
+
|
|
22734
|
+
var isCompletelyClosed = false;
|
|
22735
|
+
var unpairedBracketCount = 0;
|
|
22736
|
+
var _iteratorNormalCompletion = true;
|
|
22737
|
+
var _didIteratorError = false;
|
|
22738
|
+
var _iteratorError = undefined;
|
|
22739
|
+
|
|
22740
|
+
try {
|
|
22741
|
+
for (var _iterator = trimmed[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
22742
|
+
var char = _step.value;
|
|
22743
|
+
|
|
22744
|
+
if (char === "{") {
|
|
22745
|
+
if (isCompletelyClosed) {
|
|
22746
|
+
return false;
|
|
22747
|
+
}
|
|
22748
|
+
|
|
22749
|
+
unpairedBracketCount++;
|
|
22750
|
+
} else if (char === "}") {
|
|
22751
|
+
if (unpairedBracketCount === 0) {
|
|
22752
|
+
return false;
|
|
22753
|
+
}
|
|
22754
|
+
|
|
22755
|
+
unpairedBracketCount--;
|
|
22756
|
+
|
|
22757
|
+
if (unpairedBracketCount === 0) {
|
|
22758
|
+
isCompletelyClosed = true;
|
|
22759
|
+
}
|
|
22760
|
+
}
|
|
22761
|
+
}
|
|
22762
|
+
} catch (err) {
|
|
22763
|
+
_didIteratorError = true;
|
|
22764
|
+
_iteratorError = err;
|
|
22765
|
+
} finally {
|
|
22766
|
+
try {
|
|
22767
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
22768
|
+
_iterator.return();
|
|
22769
|
+
}
|
|
22770
|
+
} finally {
|
|
22771
|
+
if (_didIteratorError) {
|
|
22772
|
+
throw _iteratorError;
|
|
22773
|
+
}
|
|
22774
|
+
}
|
|
22775
|
+
}
|
|
22776
|
+
|
|
22777
|
+
return unpairedBracketCount === 0;
|
|
22778
|
+
}
|
|
22711
22779
|
}
|
|
22712
22780
|
|
|
22713
22781
|
function needsParens(path, options) {
|
|
@@ -22914,7 +22982,6 @@ function needsParens(path, options) {
|
|
|
22914
22982
|
|
|
22915
22983
|
case "ClassExpression":
|
|
22916
22984
|
case "ClassDeclaration":
|
|
22917
|
-
case "TSAbstractClassDeclaration":
|
|
22918
22985
|
return name === "superClass" && parent.superClass === node;
|
|
22919
22986
|
|
|
22920
22987
|
case "TSTypeAssertion":
|
|
@@ -23163,6 +23230,7 @@ function needsParens(path, options) {
|
|
|
23163
23230
|
|
|
23164
23231
|
case "FunctionExpression":
|
|
23165
23232
|
switch (parent.type) {
|
|
23233
|
+
case "NewExpression":
|
|
23166
23234
|
case "CallExpression":
|
|
23167
23235
|
return name === "callee";
|
|
23168
23236
|
// Not strictly necessary, but it's clearer to the reader if IIFEs are wrapped in parentheses.
|
|
@@ -23207,7 +23275,16 @@ function needsParens(path, options) {
|
|
|
23207
23275
|
}
|
|
23208
23276
|
|
|
23209
23277
|
case "ClassExpression":
|
|
23210
|
-
|
|
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
|
+
}
|
|
23211
23288
|
|
|
23212
23289
|
case "OptionalMemberExpression":
|
|
23213
23290
|
return parent.type === "MemberExpression";
|
|
@@ -23239,7 +23316,7 @@ function needsParens(path, options) {
|
|
|
23239
23316
|
return false;
|
|
23240
23317
|
|
|
23241
23318
|
case "NGPipeExpression":
|
|
23242
|
-
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") {
|
|
23243
23320
|
return false;
|
|
23244
23321
|
}
|
|
23245
23322
|
|
|
@@ -23250,7 +23327,7 @@ function needsParens(path, options) {
|
|
|
23250
23327
|
}
|
|
23251
23328
|
|
|
23252
23329
|
function isStatement(node) {
|
|
23253
|
-
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";
|
|
23254
23331
|
}
|
|
23255
23332
|
|
|
23256
23333
|
function getUnparenthesizedNode(node) {
|
|
@@ -23400,7 +23477,7 @@ var shouldFlatten$1 = util.shouldFlatten;
|
|
|
23400
23477
|
var getNextNonSpaceNonCommentCharacter$1 = util.getNextNonSpaceNonCommentCharacter;
|
|
23401
23478
|
var hasNewline$3 = util.hasNewline;
|
|
23402
23479
|
var hasNewlineInRange$1 = util.hasNewlineInRange;
|
|
23403
|
-
var getLast$
|
|
23480
|
+
var getLast$3 = util.getLast;
|
|
23404
23481
|
var getStringWidth$2 = util.getStringWidth;
|
|
23405
23482
|
var printString$2 = util.printString;
|
|
23406
23483
|
var printNumber$2 = util.printNumber;
|
|
@@ -23422,6 +23499,7 @@ var isVueEventBindingExpression$2 = htmlBinding.isVueEventBindingExpression;
|
|
|
23422
23499
|
var hasNode = utils$8.hasNode;
|
|
23423
23500
|
var hasFlowAnnotationComment = utils$8.hasFlowAnnotationComment;
|
|
23424
23501
|
var hasFlowShorthandAnnotationComment = utils$8.hasFlowShorthandAnnotationComment;
|
|
23502
|
+
var needsQuoteProps = new WeakMap();
|
|
23425
23503
|
var _require$$6$builders = doc.builders;
|
|
23426
23504
|
var concat$11 = _require$$6$builders.concat;
|
|
23427
23505
|
var join$7 = _require$$6$builders.join;
|
|
@@ -23554,7 +23632,7 @@ function genericPrint$3(path, options, printPath, args) {
|
|
|
23554
23632
|
}
|
|
23555
23633
|
|
|
23556
23634
|
function hasNewlineBetweenOrAfterDecorators(node, options) {
|
|
23557
|
-
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)));
|
|
23558
23636
|
}
|
|
23559
23637
|
|
|
23560
23638
|
function printDecorators(path, options, print) {
|
|
@@ -23871,7 +23949,7 @@ function printPathNoParens(path, options, print, args) {
|
|
|
23871
23949
|
return chain;
|
|
23872
23950
|
}
|
|
23873
23951
|
|
|
23874
|
-
var jsxPart = getLast$
|
|
23952
|
+
var jsxPart = getLast$3(_parts);
|
|
23875
23953
|
return group$10(concat$11([chain, ifBreak$6(indent$6(jsxPart), jsxPart, {
|
|
23876
23954
|
groupId: groupId
|
|
23877
23955
|
})]));
|
|
@@ -24216,7 +24294,7 @@ function printPathNoParens(path, options, print, args) {
|
|
|
24216
24294
|
if ( // We want to keep CommonJS- and AMD-style require calls, and AMD-style
|
|
24217
24295
|
// define calls, as a unit.
|
|
24218
24296
|
// e.g. `define(["some/lib", (lib) => {`
|
|
24219
|
-
!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
|
|
24220
24298
|
n.arguments.length === 1 && isTemplateOnItsOwnLine(n.arguments[0], options.originalText, options) || // Keep test declarations on a single line
|
|
24221
24299
|
// e.g. `it('long name', () => {`
|
|
24222
24300
|
!isNew && isTestCall(n, path.getParentNode())) {
|
|
@@ -24336,7 +24414,7 @@ function printPathNoParens(path, options, print, args) {
|
|
|
24336
24414
|
props.push(concat$11(separatorParts.concat(group$10("..."))));
|
|
24337
24415
|
}
|
|
24338
24416
|
|
|
24339
|
-
var lastElem = getLast$
|
|
24417
|
+
var lastElem = getLast$3(n[propertiesField]);
|
|
24340
24418
|
var canHaveTrailingSeparator = !(lastElem && (lastElem.type === "RestProperty" || lastElem.type === "RestElement" || hasNodeIgnoreComment$1(lastElem) || n.inexact));
|
|
24341
24419
|
var content;
|
|
24342
24420
|
|
|
@@ -24418,7 +24496,7 @@ function printPathNoParens(path, options, print, args) {
|
|
|
24418
24496
|
parts.push(group$10(concat$11(["[", comments.printDanglingComments(path, options), softline$5, "]"])));
|
|
24419
24497
|
}
|
|
24420
24498
|
} else {
|
|
24421
|
-
var _lastElem = getLast$
|
|
24499
|
+
var _lastElem = getLast$3(n.elements);
|
|
24422
24500
|
|
|
24423
24501
|
var canHaveTrailingComma = !(_lastElem && _lastElem.type === "RestElement"); // JavaScript allows you to have empty elements in an array which
|
|
24424
24502
|
// changes its length based on the number of commas. The algorithm
|
|
@@ -24862,7 +24940,7 @@ function printPathNoParens(path, options, print, args) {
|
|
|
24862
24940
|
return group$10(concat$11(["<", path.call(print, "name"), path.call(print, "typeParameters"), " ", concat$11(path.map(print, "attributes")), _n.selfClosing ? " />" : ">"]));
|
|
24863
24941
|
}
|
|
24864
24942
|
|
|
24865
|
-
var lastAttrHasTrailingComments = _n.attributes.length && hasTrailingComment(getLast$
|
|
24943
|
+
var lastAttrHasTrailingComments = _n.attributes.length && hasTrailingComment(getLast$3(_n.attributes));
|
|
24866
24944
|
var bracketSameLine = // Simple tags (no attributes and no comment in tag name) should be
|
|
24867
24945
|
// kept unbroken regardless of `jsxBracketSameLine`
|
|
24868
24946
|
!_n.attributes.length && !nameHasComments || options.jsxBracketSameLine && ( // We should print the bracket in a new line for the following cases:
|
|
@@ -24968,7 +25046,6 @@ function printPathNoParens(path, options, print, args) {
|
|
|
24968
25046
|
|
|
24969
25047
|
case "ClassDeclaration":
|
|
24970
25048
|
case "ClassExpression":
|
|
24971
|
-
case "TSAbstractClassDeclaration":
|
|
24972
25049
|
if (isNodeStartingWithDeclare(n, options)) {
|
|
24973
25050
|
parts.push("declare ");
|
|
24974
25051
|
}
|
|
@@ -26031,18 +26108,27 @@ function printStatementSequence(path, options, print) {
|
|
|
26031
26108
|
|
|
26032
26109
|
function printPropertyKey(path, options, print) {
|
|
26033
26110
|
var node = path.getNode();
|
|
26111
|
+
var parent = path.getParentNode();
|
|
26034
26112
|
var key = node.key;
|
|
26035
26113
|
|
|
26036
|
-
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))) {
|
|
26037
26122
|
// a -> "a"
|
|
26123
|
+
var prop = printString$2(JSON.stringify(key.name), options);
|
|
26038
26124
|
return path.call(function (keyPath) {
|
|
26039
26125
|
return comments.printComments(keyPath, function () {
|
|
26040
|
-
return
|
|
26126
|
+
return prop;
|
|
26041
26127
|
}, options);
|
|
26042
26128
|
}, "key");
|
|
26043
26129
|
}
|
|
26044
26130
|
|
|
26045
|
-
if (
|
|
26131
|
+
if (isStringPropSafeToCoerceToIdentifier(node, options) && (options.quoteProps === "as-needed" || options.quoteProps === "consistent" && !needsQuoteProps.get(parent))) {
|
|
26046
26132
|
// 'a' -> a
|
|
26047
26133
|
return path.call(function (keyPath) {
|
|
26048
26134
|
return comments.printComments(keyPath, function () {
|
|
@@ -26101,7 +26187,7 @@ function couldGroupArg(arg) {
|
|
|
26101
26187
|
}
|
|
26102
26188
|
|
|
26103
26189
|
function shouldGroupLastArg(args) {
|
|
26104
|
-
var lastArg = getLast$
|
|
26190
|
+
var lastArg = getLast$3(args);
|
|
26105
26191
|
var penultimateArg = getPenultimate$1(args);
|
|
26106
26192
|
return !hasLeadingComment(lastArg) && !hasTrailingComment(lastArg) && couldGroupArg(lastArg) && ( // If the last two arguments are of the same type,
|
|
26107
26193
|
// disable last element expansion.
|
|
@@ -26197,7 +26283,8 @@ function printArgumentsList(path, options, print) {
|
|
|
26197
26283
|
|
|
26198
26284
|
return concat$11(parts);
|
|
26199
26285
|
}, "arguments");
|
|
26200
|
-
var maybeTrailingComma =
|
|
26286
|
+
var maybeTrailingComma = // Dynamic imports cannot have trailing commas
|
|
26287
|
+
!(node.callee && node.callee.type === "Import") && shouldPrintComma$1(options, "all") ? "," : "";
|
|
26201
26288
|
|
|
26202
26289
|
function allArgsBrokenOut() {
|
|
26203
26290
|
return group$10(concat$11(["(", indent$6(concat$11([line$8, concat$11(printedArguments)])), maybeTrailingComma, line$8, ")"]), {
|
|
@@ -26246,14 +26333,14 @@ function printArgumentsList(path, options, print) {
|
|
|
26246
26333
|
var somePrintedArgumentsWillBreak = printedArguments.some(willBreak$1);
|
|
26247
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], {
|
|
26248
26335
|
shouldBreak: true
|
|
26249
|
-
}), 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), {
|
|
26250
26337
|
shouldBreak: true
|
|
26251
26338
|
}), ")"]), allArgsBrokenOut()], {
|
|
26252
26339
|
shouldBreak: shouldBreak
|
|
26253
26340
|
})]);
|
|
26254
26341
|
}
|
|
26255
26342
|
|
|
26256
|
-
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, ")"]), {
|
|
26257
26344
|
shouldBreak: printedArguments.some(willBreak$1) || anyArgEmptyLine
|
|
26258
26345
|
});
|
|
26259
26346
|
}
|
|
@@ -26292,12 +26379,37 @@ function printFunctionTypeParameters(path, options, print) {
|
|
|
26292
26379
|
|
|
26293
26380
|
function printFunctionParams(path, print, options, expandArg, printTypeParams) {
|
|
26294
26381
|
var fun = path.getValue();
|
|
26382
|
+
var parent = path.getParentNode();
|
|
26295
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
|
+
}));
|
|
26296
26389
|
var typeParams = printTypeParams ? printFunctionTypeParameters(path, options, print) : "";
|
|
26297
26390
|
var printed = [];
|
|
26298
26391
|
|
|
26299
26392
|
if (fun[paramsField]) {
|
|
26300
|
-
|
|
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);
|
|
26301
26413
|
}
|
|
26302
26414
|
|
|
26303
26415
|
if (fun.rest) {
|
|
@@ -26312,7 +26424,7 @@ function printFunctionParams(path, print, options, expandArg, printTypeParams) {
|
|
|
26312
26424
|
}), ")"]);
|
|
26313
26425
|
}
|
|
26314
26426
|
|
|
26315
|
-
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
|
|
26316
26428
|
// params of the first/last argument, we dont want the arguments to break and instead
|
|
26317
26429
|
// want the whole expression to be on a new line.
|
|
26318
26430
|
//
|
|
@@ -26323,10 +26435,8 @@ function printFunctionParams(path, print, options, expandArg, printTypeParams) {
|
|
|
26323
26435
|
// }) ) => {
|
|
26324
26436
|
// })
|
|
26325
26437
|
|
|
26326
|
-
if (
|
|
26327
|
-
return
|
|
26328
|
-
}))) {
|
|
26329
|
-
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)), ")"]));
|
|
26330
26440
|
} // Single object destructuring should hug
|
|
26331
26441
|
//
|
|
26332
26442
|
// function({
|
|
@@ -26336,14 +26446,13 @@ function printFunctionParams(path, print, options, expandArg, printTypeParams) {
|
|
|
26336
26446
|
// }) {}
|
|
26337
26447
|
|
|
26338
26448
|
|
|
26339
|
-
if (
|
|
26340
|
-
return concat$11([typeParams, "(",
|
|
26341
|
-
}
|
|
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) => {})`
|
|
26342
26452
|
|
|
26343
|
-
var parent = path.getParentNode(); // don't break in specs, eg; `it("should maintain parens around done even when long", (done) => {})`
|
|
26344
26453
|
|
|
26345
|
-
if (
|
|
26346
|
-
return concat$11([typeParams, "(",
|
|
26454
|
+
if (isParametersInTestCall) {
|
|
26455
|
+
return concat$11([typeParams, "(", concat$11(printed), ")"]);
|
|
26347
26456
|
}
|
|
26348
26457
|
|
|
26349
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;
|
|
@@ -26357,7 +26466,7 @@ function printFunctionParams(path, print, options, expandArg, printTypeParams) {
|
|
|
26357
26466
|
}
|
|
26358
26467
|
|
|
26359
26468
|
var canHaveTrailingComma = !(lastParam && lastParam.type === "RestElement") && !fun.rest;
|
|
26360
|
-
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, ")"]);
|
|
26361
26470
|
}
|
|
26362
26471
|
|
|
26363
26472
|
function shouldPrintParamsWithoutParens(path, options) {
|
|
@@ -26472,7 +26581,7 @@ function printExportDeclaration(path, options, print) {
|
|
|
26472
26581
|
if (decl.declaration) {
|
|
26473
26582
|
parts.push(path.call(print, "declaration"));
|
|
26474
26583
|
|
|
26475
|
-
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") {
|
|
26476
26585
|
parts.push(semi);
|
|
26477
26586
|
}
|
|
26478
26587
|
} else {
|
|
@@ -26583,7 +26692,7 @@ function printClass(path, options, print) {
|
|
|
26583
26692
|
var n = path.getValue();
|
|
26584
26693
|
var parts = [];
|
|
26585
26694
|
|
|
26586
|
-
if (n.
|
|
26695
|
+
if (n.abstract) {
|
|
26587
26696
|
parts.push("abstract ");
|
|
26588
26697
|
}
|
|
26589
26698
|
|
|
@@ -26884,27 +26993,23 @@ function printMemberChain(path, options, print) {
|
|
|
26884
26993
|
return firstNode.type === "ThisExpression" || firstNode.type === "Identifier" && (isFactory(firstNode.name) || isExpression && isShort(firstNode.name) || hasComputed);
|
|
26885
26994
|
}
|
|
26886
26995
|
|
|
26887
|
-
var lastNode = getLast$
|
|
26996
|
+
var lastNode = getLast$3(groups[0]).node;
|
|
26888
26997
|
return (lastNode.type === "MemberExpression" || lastNode.type === "OptionalMemberExpression") && lastNode.property.type === "Identifier" && (isFactory(lastNode.property.name) || hasComputed);
|
|
26889
26998
|
}
|
|
26890
26999
|
|
|
26891
27000
|
var shouldMerge = groups.length >= 2 && !groups[1][0].node.comments && shouldNotWrap(groups);
|
|
26892
27001
|
|
|
26893
27002
|
function printGroup(printedGroup) {
|
|
26894
|
-
var
|
|
26895
|
-
|
|
26896
|
-
|
|
26897
|
-
|
|
26898
|
-
|
|
26899
|
-
|
|
26900
|
-
|
|
26901
|
-
_i3++;
|
|
26902
|
-
} else {
|
|
26903
|
-
result.push(printedGroup[_i3].printed);
|
|
26904
|
-
}
|
|
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), [")"]));
|
|
26905
27010
|
}
|
|
26906
27011
|
|
|
26907
|
-
return concat$11(
|
|
27012
|
+
return concat$11(printed);
|
|
26908
27013
|
}
|
|
26909
27014
|
|
|
26910
27015
|
function printIndentedGroup(groups) {
|
|
@@ -26934,7 +27039,7 @@ function printMemberChain(path, options, print) {
|
|
|
26934
27039
|
// empty line after
|
|
26935
27040
|
|
|
26936
27041
|
|
|
26937
|
-
var lastNodeBeforeIndent = getLast$
|
|
27042
|
+
var lastNodeBeforeIndent = getLast$3(shouldMerge ? groups.slice(1, 2)[0] : groups[0]).node;
|
|
26938
27043
|
var shouldHaveEmptyLineBeforeIndent = lastNodeBeforeIndent.type !== "CallExpression" && lastNodeBeforeIndent.type !== "OptionalCallExpression" && shouldInsertEmptyLineAfter(lastNodeBeforeIndent);
|
|
26939
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))]);
|
|
26940
27045
|
var callExpressions = printedNodes.map(function (_ref) {
|
|
@@ -26954,7 +27059,7 @@ function printMemberChain(path, options, print) {
|
|
|
26954
27059
|
*/
|
|
26955
27060
|
function (lastGroupDoc, lastGroupNode) {
|
|
26956
27061
|
return isCallOrOptionalCallExpression(lastGroupNode) && willBreak$1(lastGroupDoc);
|
|
26957
|
-
}(getLast$
|
|
27062
|
+
}(getLast$3(printedGroups), getLast$3(getLast$3(groups)).node) && callExpressions.slice(0, -1).some(function (n) {
|
|
26958
27063
|
return n.arguments.some(isFunctionOrArrowExpression);
|
|
26959
27064
|
})) {
|
|
26960
27065
|
return group$10(expanded);
|
|
@@ -27165,7 +27270,7 @@ function printJSXChildren(path, options, print, jsxWhitespace, isFacebookTransla
|
|
|
27165
27270
|
|
|
27166
27271
|
var endWhitespace; // Ends with whitespace
|
|
27167
27272
|
|
|
27168
|
-
if (getLast$
|
|
27273
|
+
if (getLast$3(words) === "") {
|
|
27169
27274
|
words.pop();
|
|
27170
27275
|
endWhitespace = words.pop();
|
|
27171
27276
|
} // This was whitespace only without a new line.
|
|
@@ -27186,13 +27291,13 @@ function printJSXChildren(path, options, print, jsxWhitespace, isFacebookTransla
|
|
|
27186
27291
|
if (endWhitespace !== undefined) {
|
|
27187
27292
|
if (/\n/.test(endWhitespace)) {
|
|
27188
27293
|
var _next = n.children[i + 1];
|
|
27189
|
-
children.push(separatorWithWhitespace(isFacebookTranslationTag, getLast$
|
|
27294
|
+
children.push(separatorWithWhitespace(isFacebookTranslationTag, getLast$3(children), child, _next));
|
|
27190
27295
|
} else {
|
|
27191
27296
|
children.push(jsxWhitespace);
|
|
27192
27297
|
}
|
|
27193
27298
|
} else {
|
|
27194
27299
|
var _next2 = n.children[i + 1];
|
|
27195
|
-
children.push(separatorNoWhitespace(isFacebookTranslationTag, getLast$
|
|
27300
|
+
children.push(separatorNoWhitespace(isFacebookTranslationTag, getLast$3(children), child, _next2));
|
|
27196
27301
|
}
|
|
27197
27302
|
} else if (/\n/.test(text)) {
|
|
27198
27303
|
// Keep (up to one) blank line between tags/expressions/text.
|
|
@@ -27301,7 +27406,7 @@ function printJSXElement(path, options, print) {
|
|
|
27301
27406
|
} // Trim trailing lines (or empty strings)
|
|
27302
27407
|
|
|
27303
27408
|
|
|
27304
|
-
while (children.length && (isLineNext$1(getLast$
|
|
27409
|
+
while (children.length && (isLineNext$1(getLast$3(children)) || isEmpty$1(getLast$3(children)))) {
|
|
27305
27410
|
children.pop();
|
|
27306
27411
|
} // Trim leading lines (or empty strings)
|
|
27307
27412
|
|
|
@@ -27848,7 +27953,7 @@ function needsHardlineAfterDanglingComment(node) {
|
|
|
27848
27953
|
return false;
|
|
27849
27954
|
}
|
|
27850
27955
|
|
|
27851
|
-
var lastDanglingComment = getLast$
|
|
27956
|
+
var lastDanglingComment = getLast$3(node.comments.filter(function (comment) {
|
|
27852
27957
|
return !comment.leading && !comment.trailing;
|
|
27853
27958
|
}));
|
|
27854
27959
|
return lastDanglingComment && !comments$3.isBlockComment(lastDanglingComment);
|
|
@@ -27858,6 +27963,10 @@ function isLiteral(node) {
|
|
|
27858
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";
|
|
27859
27964
|
}
|
|
27860
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
|
+
|
|
27861
27970
|
function isNumericLiteral(node) {
|
|
27862
27971
|
return node.type === "NumericLiteral" || node.type === "Literal" && typeof node.value === "number";
|
|
27863
27972
|
}
|
|
@@ -27948,7 +28057,7 @@ function willPrintOwnComments(path) {
|
|
|
27948
28057
|
}
|
|
27949
28058
|
|
|
27950
28059
|
function canAttachComment$1(node) {
|
|
27951
|
-
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";
|
|
27952
28061
|
}
|
|
27953
28062
|
|
|
27954
28063
|
function printComment$2(commentPath, options) {
|
|
@@ -28146,6 +28255,23 @@ var options$12 = {
|
|
|
28146
28255
|
default: false,
|
|
28147
28256
|
description: "Use single quotes in JSX."
|
|
28148
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
|
+
},
|
|
28149
28275
|
trailingComma: {
|
|
28150
28276
|
since: "0.0.0",
|
|
28151
28277
|
category: CATEGORY_JAVASCRIPT,
|
|
@@ -28497,7 +28623,7 @@ var json$9 = {"cjkPattern":"[\\u02ea-\\u02eb\\u1100-\\u11ff\\u2e80-\\u2e99\\u2e9
|
|
|
28497
28623
|
var cjkPattern = json$9.cjkPattern;
|
|
28498
28624
|
var kPattern = json$9.kPattern;
|
|
28499
28625
|
var punctuationPattern$1 = json$9.punctuationPattern;
|
|
28500
|
-
var getLast$
|
|
28626
|
+
var getLast$4 = util.getLast;
|
|
28501
28627
|
var INLINE_NODE_TYPES$1 = ["liquidNode", "inlineCode", "emphasis", "strong", "delete", "link", "linkReference", "image", "imageReference", "footnote", "footnoteReference", "sentence", "whitespace", "word", "break", "inlineMath"];
|
|
28502
28628
|
var INLINE_NODE_WRAPPER_TYPES$1 = INLINE_NODE_TYPES$1.concat(["tableCell", "paragraph", "heading"]);
|
|
28503
28629
|
var kRegex = new RegExp(kPattern);
|
|
@@ -28542,7 +28668,7 @@ function splitText$1(text, options) {
|
|
|
28542
28668
|
value: innerToken,
|
|
28543
28669
|
kind: KIND_NON_CJK,
|
|
28544
28670
|
hasLeadingPunctuation: punctuationRegex.test(innerToken[0]),
|
|
28545
|
-
hasTrailingPunctuation: punctuationRegex.test(getLast$
|
|
28671
|
+
hasTrailingPunctuation: punctuationRegex.test(getLast$4(innerToken))
|
|
28546
28672
|
});
|
|
28547
28673
|
}
|
|
28548
28674
|
|
|
@@ -28568,7 +28694,7 @@ function splitText$1(text, options) {
|
|
|
28568
28694
|
return nodes;
|
|
28569
28695
|
|
|
28570
28696
|
function appendNode(node) {
|
|
28571
|
-
var lastNode = getLast$
|
|
28697
|
+
var lastNode = getLast$4(nodes);
|
|
28572
28698
|
|
|
28573
28699
|
if (lastNode && lastNode.type === "word") {
|
|
28574
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) {
|
|
@@ -29030,6 +29156,7 @@ function markAlignedList(ast, options) {
|
|
|
29030
29156
|
var preprocess_1$4 = preprocess$4;
|
|
29031
29157
|
|
|
29032
29158
|
var _require$$0$builders$8 = doc.builders;
|
|
29159
|
+
var breakParent$4 = _require$$0$builders$8.breakParent;
|
|
29033
29160
|
var concat$15 = _require$$0$builders$8.concat;
|
|
29034
29161
|
var join$11 = _require$$0$builders$8.join;
|
|
29035
29162
|
var line$10 = _require$$0$builders$8.line;
|
|
@@ -29037,6 +29164,7 @@ var literalline$5 = _require$$0$builders$8.literalline;
|
|
|
29037
29164
|
var markAsRoot$3 = _require$$0$builders$8.markAsRoot;
|
|
29038
29165
|
var hardline$11 = _require$$0$builders$8.hardline;
|
|
29039
29166
|
var softline$7 = _require$$0$builders$8.softline;
|
|
29167
|
+
var ifBreak$7 = _require$$0$builders$8.ifBreak;
|
|
29040
29168
|
var fill$5 = _require$$0$builders$8.fill;
|
|
29041
29169
|
var align$2 = _require$$0$builders$8.align;
|
|
29042
29170
|
var indent$9 = _require$$0$builders$8.indent;
|
|
@@ -29389,6 +29517,7 @@ function printLine(path, value, options) {
|
|
|
29389
29517
|
}
|
|
29390
29518
|
|
|
29391
29519
|
function printTable(path, options, print) {
|
|
29520
|
+
var hardlineWithoutBreakParent = hardline$11.parts[0];
|
|
29392
29521
|
var node = path.getValue();
|
|
29393
29522
|
var contents = []; // { [rowIndex: number]: { [columnIndex: number]: string } }
|
|
29394
29523
|
|
|
@@ -29398,7 +29527,8 @@ function printTable(path, options, print) {
|
|
|
29398
29527
|
rowContents.push(printDocToString$2(cellPath.call(print), options).formatted);
|
|
29399
29528
|
}, "children");
|
|
29400
29529
|
contents.push(rowContents);
|
|
29401
|
-
}, "children");
|
|
29530
|
+
}, "children"); // Get the width of each column
|
|
29531
|
+
|
|
29402
29532
|
var columnMaxWidths = contents.reduce(function (currentWidths, rowContents) {
|
|
29403
29533
|
return currentWidths.map(function (width, columnIndex) {
|
|
29404
29534
|
return Math.max(width, util.getStringWidth(rowContents[columnIndex]));
|
|
@@ -29407,28 +29537,48 @@ function printTable(path, options, print) {
|
|
|
29407
29537
|
return 3;
|
|
29408
29538
|
}) // minimum width = 3 (---, :--, :-:, --:)
|
|
29409
29539
|
);
|
|
29410
|
-
|
|
29411
|
-
|
|
29412
|
-
|
|
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) {
|
|
29413
29561
|
return concat$15(["| ", join$11(" | ", columnMaxWidths.map(function (width, index) {
|
|
29562
|
+
var spaces = isCompact ? 3 : width;
|
|
29563
|
+
|
|
29414
29564
|
switch (node.align[index]) {
|
|
29415
29565
|
case "left":
|
|
29416
|
-
return ":" + "-".repeat(
|
|
29566
|
+
return ":" + "-".repeat(spaces - 1);
|
|
29417
29567
|
|
|
29418
29568
|
case "right":
|
|
29419
|
-
return "-".repeat(
|
|
29569
|
+
return "-".repeat(spaces - 1) + ":";
|
|
29420
29570
|
|
|
29421
29571
|
case "center":
|
|
29422
|
-
return ":" + "-".repeat(
|
|
29572
|
+
return ":" + "-".repeat(spaces - 2) + ":";
|
|
29423
29573
|
|
|
29424
29574
|
default:
|
|
29425
|
-
return "-".repeat(
|
|
29575
|
+
return "-".repeat(spaces);
|
|
29426
29576
|
}
|
|
29427
29577
|
})), " |"]);
|
|
29428
29578
|
}
|
|
29429
29579
|
|
|
29430
|
-
function printRow(rowContents) {
|
|
29431
|
-
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) {
|
|
29432
29582
|
switch (node.align[columnIndex]) {
|
|
29433
29583
|
case "right":
|
|
29434
29584
|
return alignRight(rowContent, columnMaxWidths[columnIndex]);
|
|
@@ -29443,11 +29593,13 @@ function printTable(path, options, print) {
|
|
|
29443
29593
|
}
|
|
29444
29594
|
|
|
29445
29595
|
function alignLeft(text, width) {
|
|
29446
|
-
|
|
29596
|
+
var spaces = width - util.getStringWidth(text);
|
|
29597
|
+
return concat$15([text, " ".repeat(spaces)]);
|
|
29447
29598
|
}
|
|
29448
29599
|
|
|
29449
29600
|
function alignRight(text, width) {
|
|
29450
|
-
|
|
29601
|
+
var spaces = width - util.getStringWidth(text);
|
|
29602
|
+
return concat$15([" ".repeat(spaces), text]);
|
|
29451
29603
|
}
|
|
29452
29604
|
|
|
29453
29605
|
function alignCenter(text, width) {
|
|
@@ -29832,7 +29984,7 @@ var pragma$11 = {
|
|
|
29832
29984
|
insertPragma: insertPragma$9
|
|
29833
29985
|
};
|
|
29834
29986
|
|
|
29835
|
-
var getLast$
|
|
29987
|
+
var getLast$6 = util.getLast;
|
|
29836
29988
|
|
|
29837
29989
|
function getAncestorCount$1(path, filter) {
|
|
29838
29990
|
var counter = 0;
|
|
@@ -29921,7 +30073,7 @@ function isLastDescendantNode$1(path) {
|
|
|
29921
30073
|
}
|
|
29922
30074
|
|
|
29923
30075
|
function getLastDescendantNode$2(node) {
|
|
29924
|
-
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;
|
|
29925
30077
|
}
|
|
29926
30078
|
|
|
29927
30079
|
function isPrettierIgnore$2(comment) {
|
|
@@ -29933,10 +30085,10 @@ function hasPrettierIgnore$5(path) {
|
|
|
29933
30085
|
|
|
29934
30086
|
if (node.type === "documentBody") {
|
|
29935
30087
|
var document = path.getParentNode();
|
|
29936
|
-
return hasEndComments$1(document.head) && isPrettierIgnore$2(getLast$
|
|
30088
|
+
return hasEndComments$1(document.head) && isPrettierIgnore$2(getLast$6(document.head.endComments));
|
|
29937
30089
|
}
|
|
29938
30090
|
|
|
29939
|
-
return hasLeadingComments$1(node) && isPrettierIgnore$2(getLast$
|
|
30091
|
+
return hasLeadingComments$1(node) && isPrettierIgnore$2(getLast$6(node.leadingComments));
|
|
29940
30092
|
}
|
|
29941
30093
|
|
|
29942
30094
|
function isEmptyNode$1(node) {
|
|
@@ -30036,7 +30188,7 @@ function getFlowScalarLineContents$1(nodeType, content, options) {
|
|
|
30036
30188
|
return lineContent.length === 0 ? [] : splitWithSingleSpace(lineContent);
|
|
30037
30189
|
}).reduce(function (reduced, lineContentWords, index) {
|
|
30038
30190
|
return index !== 0 && rawLineContents[index - 1].length !== 0 && lineContentWords.length !== 0 && !( // trailing backslash in quoteDouble should be preserved
|
|
30039
|
-
nodeType === "quoteDouble" && getLast$
|
|
30191
|
+
nodeType === "quoteDouble" && getLast$6(getLast$6(reduced)).endsWith("\\")) ? reduced.concat([reduced.pop().concat(lineContentWords)]) : reduced.concat([lineContentWords]);
|
|
30040
30192
|
}, []).map(function (lineContentWords) {
|
|
30041
30193
|
return options.proseWrap === "never" ? [lineContentWords.join(" ")] : lineContentWords;
|
|
30042
30194
|
});
|
|
@@ -30064,11 +30216,11 @@ function getBlockValueLineContents$1(node, _ref) {
|
|
|
30064
30216
|
return removeUnnecessaryTrailingNewlines(rawLineContents.map(function (lineContent) {
|
|
30065
30217
|
return lineContent.length === 0 ? [] : splitWithSingleSpace(lineContent);
|
|
30066
30218
|
}).reduce(function (reduced, lineContentWords, index) {
|
|
30067
|
-
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]);
|
|
30068
30220
|
}, []).map(function (lineContentWords) {
|
|
30069
30221
|
return lineContentWords.reduce(function (reduced, word) {
|
|
30070
30222
|
return (// disallow trailing spaces
|
|
30071
|
-
reduced.length !== 0 && /\s$/.test(getLast$
|
|
30223
|
+
reduced.length !== 0 && /\s$/.test(getLast$6(reduced)) ? reduced.concat(reduced.pop() + " " + word) : reduced.concat(word)
|
|
30072
30224
|
);
|
|
30073
30225
|
}, []);
|
|
30074
30226
|
}).map(function (lineContentWords) {
|
|
@@ -30077,7 +30229,7 @@ function getBlockValueLineContents$1(node, _ref) {
|
|
|
30077
30229
|
|
|
30078
30230
|
function removeUnnecessaryTrailingNewlines(lineContents) {
|
|
30079
30231
|
if (node.chomping === "keep") {
|
|
30080
|
-
return getLast$
|
|
30232
|
+
return getLast$6(lineContents).length === 0 ? lineContents.slice(0, -1) : lineContents;
|
|
30081
30233
|
}
|
|
30082
30234
|
|
|
30083
30235
|
var trailingNewlineCount = 0;
|
|
@@ -30096,7 +30248,7 @@ function getBlockValueLineContents$1(node, _ref) {
|
|
|
30096
30248
|
}
|
|
30097
30249
|
|
|
30098
30250
|
var utils$12 = {
|
|
30099
|
-
getLast: getLast$
|
|
30251
|
+
getLast: getLast$6,
|
|
30100
30252
|
getAncestorCount: getAncestorCount$1,
|
|
30101
30253
|
isNode: isNode$1,
|
|
30102
30254
|
isEmptyNode: isEmptyNode$1,
|
|
@@ -30120,7 +30272,7 @@ var isPragma = pragma$11.isPragma;
|
|
|
30120
30272
|
var getAncestorCount = utils$12.getAncestorCount;
|
|
30121
30273
|
var getBlockValueLineContents = utils$12.getBlockValueLineContents;
|
|
30122
30274
|
var getFlowScalarLineContents = utils$12.getFlowScalarLineContents;
|
|
30123
|
-
var getLast$
|
|
30275
|
+
var getLast$5 = utils$12.getLast;
|
|
30124
30276
|
var getLastDescendantNode$1 = utils$12.getLastDescendantNode;
|
|
30125
30277
|
var hasLeadingComments = utils$12.hasLeadingComments;
|
|
30126
30278
|
var hasMiddleComments = utils$12.hasMiddleComments;
|
|
@@ -30136,14 +30288,14 @@ var defineShortcut = utils$12.defineShortcut;
|
|
|
30136
30288
|
var mapNode = utils$12.mapNode;
|
|
30137
30289
|
var docBuilders$3 = doc.builders;
|
|
30138
30290
|
var conditionalGroup$2 = docBuilders$3.conditionalGroup;
|
|
30139
|
-
var breakParent$
|
|
30291
|
+
var breakParent$5 = docBuilders$3.breakParent;
|
|
30140
30292
|
var concat$17 = docBuilders$3.concat;
|
|
30141
30293
|
var dedent$4 = docBuilders$3.dedent;
|
|
30142
30294
|
var dedentToRoot$3 = docBuilders$3.dedentToRoot;
|
|
30143
30295
|
var fill$6 = docBuilders$3.fill;
|
|
30144
30296
|
var group$16 = docBuilders$3.group;
|
|
30145
30297
|
var hardline$13 = docBuilders$3.hardline;
|
|
30146
|
-
var ifBreak$
|
|
30298
|
+
var ifBreak$8 = docBuilders$3.ifBreak;
|
|
30147
30299
|
var join$12 = docBuilders$3.join;
|
|
30148
30300
|
var line$11 = docBuilders$3.line;
|
|
30149
30301
|
var lineSuffix$2 = docBuilders$3.lineSuffix;
|
|
@@ -30197,7 +30349,7 @@ function genericPrint$6(path, options, print) {
|
|
|
30197
30349
|
var tag = !node.tag ? "" : path.call(print, "tag");
|
|
30198
30350
|
var anchor = !node.anchor ? "" : path.call(print, "anchor");
|
|
30199
30351
|
var nextEmptyLine = isNode(node, ["mapping", "sequence", "comment", "directive", "mappingItem", "sequenceItem"]) && !isLastDescendantNode(path) ? printNextEmptyLine(path, options.originalText) : "";
|
|
30200
|
-
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"))])) : ""]);
|
|
30201
30353
|
}
|
|
30202
30354
|
|
|
30203
30355
|
function _print(node, parentNode, path, options, print) {
|
|
@@ -30333,9 +30485,9 @@ function _print(node, parentNode, path, options, print) {
|
|
|
30333
30485
|
return forceExplicitKey ? concat$17(["? ", align$3(2, key), hardline$13, join$12("", path.map(print, "value", "leadingComments").map(function (comment) {
|
|
30334
30486
|
return concat$17([comment, hardline$13]);
|
|
30335
30487
|
})), ": ", align$3(2, value)]) : // force singleline
|
|
30336
|
-
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), {
|
|
30337
30489
|
id: groupId
|
|
30338
|
-
})])), 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])), {
|
|
30339
30491
|
groupId: groupId
|
|
30340
30492
|
})])]);
|
|
30341
30493
|
}
|
|
@@ -30349,11 +30501,11 @@ function _print(node, parentNode, path, options, print) {
|
|
|
30349
30501
|
|
|
30350
30502
|
var isLastItemEmptyMappingItem = node.children.length !== 0 && function (lastItem) {
|
|
30351
30503
|
return lastItem.type === "flowMappingItem" && isEmptyNode(lastItem.key) && isEmptyNode(lastItem.value);
|
|
30352
|
-
}(getLast$
|
|
30504
|
+
}(getLast$5(node.children));
|
|
30353
30505
|
|
|
30354
30506
|
return concat$17([openMarker, indent(concat$17([bracketSpacing, concat$17(path.map(function (childPath, index) {
|
|
30355
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) : ""])]);
|
|
30356
|
-
}, "children")), ifBreak$
|
|
30508
|
+
}, "children")), ifBreak$8(",", "")])), isLastItemEmptyMappingItem ? "" : bracketSpacing, closeMarker]);
|
|
30357
30509
|
}
|
|
30358
30510
|
|
|
30359
30511
|
case "flowSequenceItem":
|