prettier 1.15.3 → 1.16.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +2 -2
- package/README.md +1 -5
- package/bin-prettier.js +1597 -1141
- package/index.js +1682 -1260
- package/package.json +1 -1
- package/parser-babylon.js +1 -1
- package/parser-flow.js +1 -1
- package/parser-html.js +1 -1
- package/parser-markdown.js +1 -1
- package/parser-postcss.js +1 -1
- package/parser-typescript.js +1 -1
- package/parser-yaml.js +1 -1
- package/standalone.js +1973 -1596
- package/third-party.js +353 -133
package/bin-prettier.js
CHANGED
|
@@ -14,7 +14,7 @@ var thirdParty__default = thirdParty['default'];
|
|
|
14
14
|
var readline = _interopDefault(require('readline'));
|
|
15
15
|
|
|
16
16
|
var name = "prettier";
|
|
17
|
-
var version$1 = "1.
|
|
17
|
+
var version$1 = "1.16.3";
|
|
18
18
|
var description = "Prettier is an opinionated code formatter";
|
|
19
19
|
var bin = {
|
|
20
20
|
"prettier": "./bin/prettier.js"
|
|
@@ -30,11 +30,11 @@ var engines = {
|
|
|
30
30
|
var dependencies = {
|
|
31
31
|
"@angular/compiler": "6.1.10",
|
|
32
32
|
"@babel/code-frame": "7.0.0-beta.46",
|
|
33
|
-
"@babel/parser": "7.
|
|
33
|
+
"@babel/parser": "7.2.0",
|
|
34
34
|
"@glimmer/syntax": "0.30.3",
|
|
35
35
|
"@iarna/toml": "2.0.0",
|
|
36
36
|
"angular-estree-parser": "1.1.5",
|
|
37
|
-
"angular-html-parser": "1.
|
|
37
|
+
"angular-html-parser": "1.2.0",
|
|
38
38
|
"camelcase": "4.1.0",
|
|
39
39
|
"chalk": "2.1.0",
|
|
40
40
|
"cjk-regex": "2.0.0",
|
|
@@ -44,7 +44,6 @@ var dependencies = {
|
|
|
44
44
|
"diff": "3.2.0",
|
|
45
45
|
"editorconfig": "0.15.2",
|
|
46
46
|
"editorconfig-to-prettier": "0.1.1",
|
|
47
|
-
"emoji-regex": "6.5.1",
|
|
48
47
|
"escape-string-regexp": "1.0.5",
|
|
49
48
|
"esutils": "2.0.2",
|
|
50
49
|
"find-parent-dir": "0.3.0",
|
|
@@ -57,6 +56,7 @@ var dependencies = {
|
|
|
57
56
|
"html-styles": "1.0.0",
|
|
58
57
|
"html-tag-names": "1.1.2",
|
|
59
58
|
"ignore": "3.3.7",
|
|
59
|
+
"is-ci": "2.0.0",
|
|
60
60
|
"jest-docblock": "23.2.0",
|
|
61
61
|
"json-stable-stringify": "1.0.1",
|
|
62
62
|
"leven": "2.1.0",
|
|
@@ -79,23 +79,23 @@ var dependencies = {
|
|
|
79
79
|
"remark-parse": "5.0.0",
|
|
80
80
|
"resolve": "1.5.0",
|
|
81
81
|
"semver": "5.4.1",
|
|
82
|
-
"string-width": "
|
|
83
|
-
"typescript": "3.2.
|
|
84
|
-
"typescript-estree": "
|
|
82
|
+
"string-width": "3.0.0",
|
|
83
|
+
"typescript": "3.2.2",
|
|
84
|
+
"typescript-estree": "18.0.0",
|
|
85
85
|
"unicode-regex": "2.0.0",
|
|
86
86
|
"unified": "6.1.6",
|
|
87
87
|
"vnopts": "1.0.2",
|
|
88
|
-
"yaml": "1.0.
|
|
89
|
-
"yaml-unist-parser": "1.0.0
|
|
88
|
+
"yaml": "1.0.2",
|
|
89
|
+
"yaml-unist-parser": "1.0.0"
|
|
90
90
|
};
|
|
91
91
|
var devDependencies = {
|
|
92
|
-
"@babel/cli": "7.
|
|
93
|
-
"@babel/core": "7.
|
|
94
|
-
"@babel/preset-env": "7.
|
|
92
|
+
"@babel/cli": "7.2.0",
|
|
93
|
+
"@babel/core": "7.2.0",
|
|
94
|
+
"@babel/preset-env": "7.2.0",
|
|
95
95
|
"babel-loader": "8.0.4",
|
|
96
96
|
"benchmark": "2.1.4",
|
|
97
97
|
"builtin-modules": "2.0.0",
|
|
98
|
-
"codecov": "
|
|
98
|
+
"codecov": "codecov/codecov-node#e427d900309adb50746a39a50aa7d80071a5ddd0",
|
|
99
99
|
"cross-env": "5.0.5",
|
|
100
100
|
"eslint": "4.18.2",
|
|
101
101
|
"eslint-config-prettier": "2.9.0",
|
|
@@ -110,7 +110,7 @@ var devDependencies = {
|
|
|
110
110
|
"jest-snapshot-serializer-raw": "1.1.0",
|
|
111
111
|
"jest-watch-typeahead": "0.1.0",
|
|
112
112
|
"mkdirp": "0.5.1",
|
|
113
|
-
"prettier": "1.
|
|
113
|
+
"prettier": "1.16.2",
|
|
114
114
|
"prettylint": "1.0.0",
|
|
115
115
|
"rimraf": "2.6.2",
|
|
116
116
|
"rollup": "0.47.6",
|
|
@@ -3870,7 +3870,17 @@ var options$2 = {
|
|
|
3870
3870
|
description: "Flow"
|
|
3871
3871
|
}, {
|
|
3872
3872
|
value: "babylon",
|
|
3873
|
+
description: "JavaScript",
|
|
3874
|
+
deprecated: "1.16.0",
|
|
3875
|
+
redirect: "babel"
|
|
3876
|
+
}, {
|
|
3877
|
+
value: "babel",
|
|
3878
|
+
since: "1.16.0",
|
|
3873
3879
|
description: "JavaScript"
|
|
3880
|
+
}, {
|
|
3881
|
+
value: "babel-flow",
|
|
3882
|
+
since: "1.16.0",
|
|
3883
|
+
description: "Flow"
|
|
3874
3884
|
}, {
|
|
3875
3885
|
value: "typescript",
|
|
3876
3886
|
since: "1.4.0",
|
|
@@ -8708,6 +8718,8 @@ function (_vnopts$ChoiceSchema) {
|
|
|
8708
8718
|
return FlagSchema;
|
|
8709
8719
|
}(lib$1.ChoiceSchema);
|
|
8710
8720
|
|
|
8721
|
+
var hasDeprecationWarned;
|
|
8722
|
+
|
|
8711
8723
|
function normalizeOptions$1(options, optionInfos) {
|
|
8712
8724
|
var _ref3 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
8713
8725
|
logger = _ref3.logger,
|
|
@@ -8729,11 +8741,24 @@ function normalizeOptions$1(options, optionInfos) {
|
|
|
8729
8741
|
var schemas = optionInfosToSchemas(optionInfos, {
|
|
8730
8742
|
isCLI
|
|
8731
8743
|
});
|
|
8732
|
-
|
|
8744
|
+
var normalizer = new lib$1.Normalizer(schemas, {
|
|
8733
8745
|
logger,
|
|
8734
8746
|
unknown,
|
|
8735
8747
|
descriptor
|
|
8736
8748
|
});
|
|
8749
|
+
var shouldSuppressDuplicateDeprecationWarnings = logger !== false;
|
|
8750
|
+
|
|
8751
|
+
if (shouldSuppressDuplicateDeprecationWarnings && hasDeprecationWarned) {
|
|
8752
|
+
normalizer._hasDeprecationWarned = hasDeprecationWarned;
|
|
8753
|
+
}
|
|
8754
|
+
|
|
8755
|
+
var normalized = normalizer.normalize(options);
|
|
8756
|
+
|
|
8757
|
+
if (shouldSuppressDuplicateDeprecationWarnings) {
|
|
8758
|
+
hasDeprecationWarned = normalizer._hasDeprecationWarned;
|
|
8759
|
+
}
|
|
8760
|
+
|
|
8761
|
+
return normalized;
|
|
8737
8762
|
}
|
|
8738
8763
|
|
|
8739
8764
|
function optionInfosToSchemas(optionInfos, _ref4) {
|
|
@@ -10561,17 +10586,21 @@ function resolveParser$1(opts, parsers) {
|
|
|
10561
10586
|
if (parsers.hasOwnProperty(opts.parser)) {
|
|
10562
10587
|
return parsers[opts.parser];
|
|
10563
10588
|
}
|
|
10589
|
+
/* istanbul ignore next */
|
|
10564
10590
|
|
|
10565
|
-
|
|
10566
|
-
|
|
10567
|
-
|
|
10568
|
-
|
|
10569
|
-
|
|
10570
|
-
|
|
10571
|
-
|
|
10572
|
-
|
|
10573
|
-
|
|
10574
|
-
|
|
10591
|
+
|
|
10592
|
+
{
|
|
10593
|
+
try {
|
|
10594
|
+
return {
|
|
10595
|
+
parse: require(path.resolve(process.cwd(), opts.parser)),
|
|
10596
|
+
astFormat: "estree",
|
|
10597
|
+
locStart,
|
|
10598
|
+
locEnd
|
|
10599
|
+
};
|
|
10600
|
+
} catch (err) {
|
|
10601
|
+
/* istanbul ignore next */
|
|
10602
|
+
throw new ConfigError$1(`Couldn't resolve parser "${opts.parser}"`);
|
|
10603
|
+
}
|
|
10575
10604
|
}
|
|
10576
10605
|
}
|
|
10577
10606
|
}
|
|
@@ -10652,8 +10681,8 @@ function normalize(options, opts) {
|
|
|
10652
10681
|
if (!rawOptions.parser) {
|
|
10653
10682
|
if (!rawOptions.filepath) {
|
|
10654
10683
|
var logger = opts.logger || console;
|
|
10655
|
-
logger.warn("No parser and no filepath given, using '
|
|
10656
|
-
rawOptions.parser = "
|
|
10684
|
+
logger.warn("No parser and no filepath given, using 'babel' the parser now " + "but this will throw an error in the future. " + "Please specify a parser or a filepath so one can be inferred.");
|
|
10685
|
+
rawOptions.parser = "babel";
|
|
10657
10686
|
} else {
|
|
10658
10687
|
rawOptions.parser = inferParser(rawOptions.filepath, rawOptions.plugins);
|
|
10659
10688
|
|
|
@@ -10995,9 +11024,12 @@ var docBuilders = {
|
|
|
10995
11024
|
var ansiRegex = createCommonjsModule(function (module) {
|
|
10996
11025
|
'use strict';
|
|
10997
11026
|
|
|
10998
|
-
module.exports = function () {
|
|
10999
|
-
|
|
11000
|
-
|
|
11027
|
+
module.exports = function (options) {
|
|
11028
|
+
options = Object.assign({
|
|
11029
|
+
onlyFirst: false
|
|
11030
|
+
}, options);
|
|
11031
|
+
var pattern = ['[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\\u0007)', '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'].join('|');
|
|
11032
|
+
return new RegExp(pattern, options.onlyFirst ? undefined : 'g');
|
|
11001
11033
|
};
|
|
11002
11034
|
});
|
|
11003
11035
|
|
|
@@ -11039,19 +11071,28 @@ var isFullwidthCodePoint = createCommonjsModule(function (module) {
|
|
|
11039
11071
|
};
|
|
11040
11072
|
});
|
|
11041
11073
|
|
|
11074
|
+
var emojiRegex = function emojiRegex() {
|
|
11075
|
+
// https://mths.be/emoji
|
|
11076
|
+
return /\uD83C\uDFF4(?:\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74)\uDB40\uDC7F|\u200D\u2620\uFE0F)|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC68(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDB0-\uDDB3])|(?:\uD83C[\uDFFB-\uDFFF])\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDB0-\uDDB3]))|\uD83D\uDC69\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDB0-\uDDB3])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2695\u2696\u2708]|\uD83D\uDC68(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83D\uDC69\u200D[\u2695\u2696\u2708])\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC68(?:\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDB0-\uDDB3])|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDD1-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDEEB\uDEEC\uDEF4-\uDEF9]|\uD83E[\uDD10-\uDD3A\uDD3C-\uDD3E\uDD40-\uDD45\uDD47-\uDD70\uDD73-\uDD76\uDD7A\uDD7C-\uDDA2\uDDB0-\uDDB9\uDDC0-\uDDC2\uDDD0-\uDDFF])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEF9]|\uD83E[\uDD10-\uDD3A\uDD3C-\uDD3E\uDD40-\uDD45\uDD47-\uDD70\uDD73-\uDD76\uDD7A\uDD7C-\uDDA2\uDDB0-\uDDB9\uDDC0-\uDDC2\uDDD0-\uDDFF])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC69\uDC6E\uDC70-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD18-\uDD1C\uDD1E\uDD1F\uDD26\uDD30-\uDD39\uDD3D\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDD1-\uDDDD])/g;
|
|
11077
|
+
};
|
|
11078
|
+
|
|
11042
11079
|
var stringWidth = createCommonjsModule(function (module) {
|
|
11043
11080
|
'use strict';
|
|
11044
11081
|
|
|
11045
|
-
|
|
11046
|
-
|
|
11082
|
+
var emojiRegex$$1 = emojiRegex();
|
|
11083
|
+
|
|
11084
|
+
module.exports = function (input) {
|
|
11085
|
+
input = input.replace(emojiRegex$$1, ' ');
|
|
11086
|
+
|
|
11087
|
+
if (typeof input !== 'string' || input.length === 0) {
|
|
11047
11088
|
return 0;
|
|
11048
11089
|
}
|
|
11049
11090
|
|
|
11050
|
-
|
|
11091
|
+
input = stripAnsi(input);
|
|
11051
11092
|
var width = 0;
|
|
11052
11093
|
|
|
11053
|
-
for (var i = 0; i <
|
|
11054
|
-
var code =
|
|
11094
|
+
for (var i = 0; i < input.length; i++) {
|
|
11095
|
+
var code = input.codePointAt(i); // Ignore control characters
|
|
11055
11096
|
|
|
11056
11097
|
if (code <= 0x1F || code >= 0x7F && code <= 0x9F) {
|
|
11057
11098
|
continue;
|
|
@@ -11074,13 +11115,6 @@ var stringWidth = createCommonjsModule(function (module) {
|
|
|
11074
11115
|
};
|
|
11075
11116
|
});
|
|
11076
11117
|
|
|
11077
|
-
var emojiRegex$1 = function emojiRegex() {
|
|
11078
|
-
// https://mathiasbynens.be/notes/es-unicode-property-escapes#emoji
|
|
11079
|
-
return /\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74)\uDB40\uDC7F|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC68(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92])|(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2695\u2696\u2708]\uFE0F|(?:\uD83C[\uDFFB-\uDFFF])\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]))|\uD83D\uDC69\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2695\u2696\u2708]|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83D\uDC69\u200D[\u2695\u2696\u2708])\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC68(?:\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92])|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDD1-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC69\uDC6E\uDC70-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD18-\uDD1C\uDD1E\uDD1F\uDD26\uDD30-\uDD39\uDD3D\uDD3E\uDDD1-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])?|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDEEB\uDEEC\uDEF4-\uDEF8]|\uD83E[\uDD10-\uDD3A\uDD3C-\uDD3E\uDD40-\uDD45\uDD47-\uDD4C\uDD50-\uDD6B\uDD80-\uDD97\uDDC0\uDDD0-\uDDE6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u2660\u2663\u2665\u2666\u2668\u267B\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEF8]|\uD83E[\uDD10-\uDD3A\uDD3C-\uDD3E\uDD40-\uDD45\uDD47-\uDD4C\uDD50-\uDD6B\uDD80-\uDD97\uDDC0\uDDD0-\uDDE6])\uFE0F/g;
|
|
11080
|
-
};
|
|
11081
|
-
|
|
11082
|
-
var emojiRegex = emojiRegex$1(); // eslint-disable-next-line no-control-regex
|
|
11083
|
-
|
|
11084
11118
|
var notAsciiRegex = /[^\x20-\x7F]/;
|
|
11085
11119
|
|
|
11086
11120
|
function isExportDeclaration(node) {
|
|
@@ -11602,12 +11636,9 @@ function getStringWidth$1(text) {
|
|
|
11602
11636
|
|
|
11603
11637
|
if (!notAsciiRegex.test(text)) {
|
|
11604
11638
|
return text.length;
|
|
11605
|
-
}
|
|
11606
|
-
// see https://github.com/sindresorhus/string-width/issues/11
|
|
11607
|
-
// for the reason why not implemented in `string-width`
|
|
11608
|
-
|
|
11639
|
+
}
|
|
11609
11640
|
|
|
11610
|
-
return stringWidth(text
|
|
11641
|
+
return stringWidth(text);
|
|
11611
11642
|
}
|
|
11612
11643
|
|
|
11613
11644
|
function hasIgnoreComment(path$$1) {
|
|
@@ -11685,7 +11716,42 @@ function isWithinParentArrayProperty(path$$1, propertyName) {
|
|
|
11685
11716
|
return parent[propertyName][key] === node;
|
|
11686
11717
|
}
|
|
11687
11718
|
|
|
11719
|
+
function replaceEndOfLineWith(text, replacement) {
|
|
11720
|
+
var parts = [];
|
|
11721
|
+
var _iteratorNormalCompletion = true;
|
|
11722
|
+
var _didIteratorError = false;
|
|
11723
|
+
var _iteratorError = undefined;
|
|
11724
|
+
|
|
11725
|
+
try {
|
|
11726
|
+
for (var _iterator = text.split("\n")[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
11727
|
+
var part = _step.value;
|
|
11728
|
+
|
|
11729
|
+
if (parts.length !== 0) {
|
|
11730
|
+
parts.push(replacement);
|
|
11731
|
+
}
|
|
11732
|
+
|
|
11733
|
+
parts.push(part);
|
|
11734
|
+
}
|
|
11735
|
+
} catch (err) {
|
|
11736
|
+
_didIteratorError = true;
|
|
11737
|
+
_iteratorError = err;
|
|
11738
|
+
} finally {
|
|
11739
|
+
try {
|
|
11740
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
11741
|
+
_iterator.return();
|
|
11742
|
+
}
|
|
11743
|
+
} finally {
|
|
11744
|
+
if (_didIteratorError) {
|
|
11745
|
+
throw _iteratorError;
|
|
11746
|
+
}
|
|
11747
|
+
}
|
|
11748
|
+
}
|
|
11749
|
+
|
|
11750
|
+
return parts;
|
|
11751
|
+
}
|
|
11752
|
+
|
|
11688
11753
|
var util$1 = {
|
|
11754
|
+
replaceEndOfLineWith,
|
|
11689
11755
|
getStringWidth: getStringWidth$1,
|
|
11690
11756
|
getMaxContinuousCount,
|
|
11691
11757
|
getPrecedence,
|
|
@@ -12402,23 +12468,23 @@ function traverseDoc(doc, onEnter, onExit, shouldTraverseConditionalGroups) {
|
|
|
12402
12468
|
}
|
|
12403
12469
|
}
|
|
12404
12470
|
|
|
12405
|
-
function mapDoc(doc, cb) {
|
|
12471
|
+
function mapDoc$1(doc, cb) {
|
|
12406
12472
|
if (doc.type === "concat" || doc.type === "fill") {
|
|
12407
12473
|
var parts = doc.parts.map(function (part) {
|
|
12408
|
-
return mapDoc(part, cb);
|
|
12474
|
+
return mapDoc$1(part, cb);
|
|
12409
12475
|
});
|
|
12410
12476
|
return cb(Object.assign({}, doc, {
|
|
12411
12477
|
parts
|
|
12412
12478
|
}));
|
|
12413
12479
|
} else if (doc.type === "if-break") {
|
|
12414
|
-
var breakContents = doc.breakContents && mapDoc(doc.breakContents, cb);
|
|
12415
|
-
var flatContents = doc.flatContents && mapDoc(doc.flatContents, cb);
|
|
12480
|
+
var breakContents = doc.breakContents && mapDoc$1(doc.breakContents, cb);
|
|
12481
|
+
var flatContents = doc.flatContents && mapDoc$1(doc.flatContents, cb);
|
|
12416
12482
|
return cb(Object.assign({}, doc, {
|
|
12417
12483
|
breakContents,
|
|
12418
12484
|
flatContents
|
|
12419
12485
|
}));
|
|
12420
12486
|
} else if (doc.contents) {
|
|
12421
|
-
var contents = mapDoc(doc.contents, cb);
|
|
12487
|
+
var contents = mapDoc$1(doc.contents, cb);
|
|
12422
12488
|
return cb(Object.assign({}, doc, {
|
|
12423
12489
|
contents
|
|
12424
12490
|
}));
|
|
@@ -12547,7 +12613,7 @@ function removeLinesFn(doc) {
|
|
|
12547
12613
|
}
|
|
12548
12614
|
|
|
12549
12615
|
function removeLines(doc) {
|
|
12550
|
-
return mapDoc(doc, removeLinesFn);
|
|
12616
|
+
return mapDoc$1(doc, removeLinesFn);
|
|
12551
12617
|
}
|
|
12552
12618
|
|
|
12553
12619
|
function stripTrailingHardline(doc) {
|
|
@@ -12578,7 +12644,7 @@ var docUtils = {
|
|
|
12578
12644
|
willBreak,
|
|
12579
12645
|
isLineNext,
|
|
12580
12646
|
traverseDoc,
|
|
12581
|
-
mapDoc,
|
|
12647
|
+
mapDoc: mapDoc$1,
|
|
12582
12648
|
propagateBreaks,
|
|
12583
12649
|
removeLines,
|
|
12584
12650
|
stripTrailingHardline
|
|
@@ -12705,7 +12771,7 @@ var doc = {
|
|
|
12705
12771
|
debug: docDebug
|
|
12706
12772
|
};
|
|
12707
12773
|
|
|
12708
|
-
var mapDoc$
|
|
12774
|
+
var mapDoc$2 = doc.utils.mapDoc;
|
|
12709
12775
|
|
|
12710
12776
|
function isNextLineEmpty$1(text, node, options) {
|
|
12711
12777
|
return util$1.isNextLineEmpty(text, node, options.locEnd);
|
|
@@ -12739,7 +12805,7 @@ var utilShared = {
|
|
|
12739
12805
|
isNextLineEmptyAfterIndex: util$1.isNextLineEmptyAfterIndex,
|
|
12740
12806
|
isPreviousLineEmpty: isPreviousLineEmpty$2,
|
|
12741
12807
|
getNextNonSpaceNonCommentCharacterIndex: getNextNonSpaceNonCommentCharacterIndex$1,
|
|
12742
|
-
mapDoc: mapDoc$
|
|
12808
|
+
mapDoc: mapDoc$2,
|
|
12743
12809
|
// TODO: remove in 2.0, we already exposed it in docUtils
|
|
12744
12810
|
makeString: util$1.makeString,
|
|
12745
12811
|
addLeadingComment: util$1.addLeadingComment,
|
|
@@ -13076,7 +13142,7 @@ function findExpressionIndexForComment(quasis, comment, options) {
|
|
|
13076
13142
|
|
|
13077
13143
|
function getQuasiRange(expr) {
|
|
13078
13144
|
if (expr.start !== undefined) {
|
|
13079
|
-
//
|
|
13145
|
+
// Babel
|
|
13080
13146
|
return {
|
|
13081
13147
|
start: expr.start,
|
|
13082
13148
|
end: expr.end
|
|
@@ -13256,17 +13322,20 @@ FastPath.prototype.getValue = function getValue() {
|
|
|
13256
13322
|
};
|
|
13257
13323
|
|
|
13258
13324
|
function getNodeHelper(path$$1, count) {
|
|
13259
|
-
var
|
|
13325
|
+
var stackIndex = getNodeStackIndexHelper(path$$1.stack, count);
|
|
13326
|
+
return stackIndex === -1 ? null : path$$1.stack[stackIndex];
|
|
13327
|
+
}
|
|
13260
13328
|
|
|
13261
|
-
|
|
13262
|
-
|
|
13329
|
+
function getNodeStackIndexHelper(stack, count) {
|
|
13330
|
+
for (var i = stack.length - 1; i >= 0; i -= 2) {
|
|
13331
|
+
var value = stack[i];
|
|
13263
13332
|
|
|
13264
13333
|
if (value && !Array.isArray(value) && --count < 0) {
|
|
13265
|
-
return
|
|
13334
|
+
return i;
|
|
13266
13335
|
}
|
|
13267
13336
|
}
|
|
13268
13337
|
|
|
13269
|
-
return
|
|
13338
|
+
return -1;
|
|
13270
13339
|
}
|
|
13271
13340
|
|
|
13272
13341
|
FastPath.prototype.getNode = function getNode(count) {
|
|
@@ -13299,6 +13368,14 @@ FastPath.prototype.call = function call(callback
|
|
|
13299
13368
|
var result = callback(this);
|
|
13300
13369
|
s.length = origLen;
|
|
13301
13370
|
return result;
|
|
13371
|
+
};
|
|
13372
|
+
|
|
13373
|
+
FastPath.prototype.callParent = function callParent(callback, count) {
|
|
13374
|
+
var stackIndex = getNodeStackIndexHelper(this.stack, ~~count + 1);
|
|
13375
|
+
var parentValues = this.stack.splice(stackIndex + 1);
|
|
13376
|
+
var result = callback(this);
|
|
13377
|
+
Array.prototype.push.apply(this.stack, parentValues);
|
|
13378
|
+
return result;
|
|
13302
13379
|
}; // Similar to FastPath.prototype.call, except that the value obtained by
|
|
13303
13380
|
// accessing this.getValue()[name1][name2]... should be array-like. The
|
|
13304
13381
|
// callback will be called with a reference to this path object for each
|
|
@@ -13467,7 +13544,7 @@ function printAstToDoc(ast, options) {
|
|
|
13467
13544
|
if (alignmentSize > 0) {
|
|
13468
13545
|
// Add a hardline to make the indents take effect
|
|
13469
13546
|
// It should be removed in index.js format()
|
|
13470
|
-
doc$$2 = addAlignmentToDoc$1(
|
|
13547
|
+
doc$$2 = addAlignmentToDoc$1(concat$3([hardline$2, doc$$2]), alignmentSize, options.tabWidth);
|
|
13471
13548
|
}
|
|
13472
13549
|
|
|
13473
13550
|
docUtils$2.propagateBreaks(doc$$2);
|
|
@@ -13650,7 +13727,7 @@ function isSourceElement(opts, node) {
|
|
|
13650
13727
|
|
|
13651
13728
|
switch (opts.parser) {
|
|
13652
13729
|
case "flow":
|
|
13653
|
-
case "
|
|
13730
|
+
case "babel":
|
|
13654
13731
|
case "typescript":
|
|
13655
13732
|
return jsSourceElements.indexOf(node.type) > -1;
|
|
13656
13733
|
|
|
@@ -13713,10 +13790,16 @@ var rangeUtil = {
|
|
|
13713
13790
|
var normalizeOptions = options.normalize;
|
|
13714
13791
|
var guessEndOfLine = endOfLine.guessEndOfLine;
|
|
13715
13792
|
var convertEndOfLineToChars = endOfLine.convertEndOfLineToChars;
|
|
13793
|
+
var mapDoc = doc.utils.mapDoc;
|
|
13716
13794
|
var printDocToString = doc.printer.printDocToString;
|
|
13717
13795
|
var printDocToDebug = doc.debug.printDocToDebug;
|
|
13718
13796
|
var UTF8BOM = 0xfeff;
|
|
13719
13797
|
var CURSOR = Symbol("cursor");
|
|
13798
|
+
var PLACEHOLDERS = {
|
|
13799
|
+
cursorOffset: "<<<PRETTIER_CURSOR>>>",
|
|
13800
|
+
rangeStart: "<<<PRETTIER_RANGE_START>>>",
|
|
13801
|
+
rangeEnd: "<<<PRETTIER_RANGE_END>>>"
|
|
13802
|
+
};
|
|
13720
13803
|
|
|
13721
13804
|
function ensureAllCommentsPrinted(astComments) {
|
|
13722
13805
|
if (!astComments) {
|
|
@@ -13764,7 +13847,6 @@ function coreFormat(text, opts, addAlignmentSize) {
|
|
|
13764
13847
|
addAlignmentSize = addAlignmentSize || 0;
|
|
13765
13848
|
var parsed = parser.parse(text, opts);
|
|
13766
13849
|
var ast = parsed.ast;
|
|
13767
|
-
var originalText = text;
|
|
13768
13850
|
text = parsed.text;
|
|
13769
13851
|
|
|
13770
13852
|
if (opts.cursorOffset >= 0) {
|
|
@@ -13777,12 +13859,10 @@ function coreFormat(text, opts, addAlignmentSize) {
|
|
|
13777
13859
|
|
|
13778
13860
|
var astComments = attachComments(text, ast, opts);
|
|
13779
13861
|
var doc$$1 = astToDoc(ast, opts, addAlignmentSize);
|
|
13780
|
-
|
|
13781
|
-
|
|
13782
|
-
|
|
13783
|
-
}
|
|
13784
|
-
|
|
13785
|
-
var result = printDocToString(doc$$1, opts);
|
|
13862
|
+
var eol = convertEndOfLineToChars(opts.endOfLine);
|
|
13863
|
+
var result = printDocToString(opts.endOfLine === "lf" ? doc$$1 : mapDoc(doc$$1, function (currentDoc) {
|
|
13864
|
+
return typeof currentDoc === "string" && currentDoc.indexOf("\n") !== -1 ? currentDoc.replace(/\n/g, eol) : currentDoc;
|
|
13865
|
+
}), opts);
|
|
13786
13866
|
ensureAllCommentsPrinted(astComments); // Remove extra leading indentation as well as the added indentation after last newline
|
|
13787
13867
|
|
|
13788
13868
|
if (addAlignmentSize > 0) {
|
|
@@ -13896,7 +13976,8 @@ function formatRange(text, opts) {
|
|
|
13896
13976
|
// we need to remove the newline that was inserted by the `format` call.
|
|
13897
13977
|
|
|
13898
13978
|
var rangeTrimmed = rangeResult.formatted.trimRight();
|
|
13899
|
-
var
|
|
13979
|
+
var rangeLeft = text.slice(0, rangeStart);
|
|
13980
|
+
var rangeRight = text.slice(rangeEnd);
|
|
13900
13981
|
var cursorOffset = opts.cursorOffset;
|
|
13901
13982
|
|
|
13902
13983
|
if (opts.cursorOffset >= rangeEnd) {
|
|
@@ -13908,6 +13989,42 @@ function formatRange(text, opts) {
|
|
|
13908
13989
|
} // keep the cursor as it was if it was before the start of the range
|
|
13909
13990
|
|
|
13910
13991
|
|
|
13992
|
+
var formatted;
|
|
13993
|
+
|
|
13994
|
+
if (opts.endOfLine === "lf") {
|
|
13995
|
+
formatted = rangeLeft + rangeTrimmed + rangeRight;
|
|
13996
|
+
} else {
|
|
13997
|
+
var eol = convertEndOfLineToChars(opts.endOfLine);
|
|
13998
|
+
|
|
13999
|
+
if (cursorOffset >= 0) {
|
|
14000
|
+
var parts = [rangeLeft, rangeTrimmed, rangeRight];
|
|
14001
|
+
var partIndex = 0;
|
|
14002
|
+
var partOffset = cursorOffset;
|
|
14003
|
+
|
|
14004
|
+
while (partIndex < parts.length) {
|
|
14005
|
+
var part = parts[partIndex];
|
|
14006
|
+
|
|
14007
|
+
if (partOffset < part.length) {
|
|
14008
|
+
parts[partIndex] = parts[partIndex].slice(0, partOffset) + PLACEHOLDERS.cursorOffset + parts[partIndex].slice(partOffset);
|
|
14009
|
+
break;
|
|
14010
|
+
}
|
|
14011
|
+
|
|
14012
|
+
partIndex++;
|
|
14013
|
+
partOffset -= part.length;
|
|
14014
|
+
}
|
|
14015
|
+
|
|
14016
|
+
var newRangeLeft = parts[0],
|
|
14017
|
+
newRangeTrimmed = parts[1],
|
|
14018
|
+
newRangeRight = parts[2];
|
|
14019
|
+
formatted = (newRangeLeft.replace(/\n/g, eol) + newRangeTrimmed + newRangeRight.replace(/\n/g, eol)).replace(PLACEHOLDERS.cursorOffset, function (_, index) {
|
|
14020
|
+
cursorOffset = index;
|
|
14021
|
+
return "";
|
|
14022
|
+
});
|
|
14023
|
+
} else {
|
|
14024
|
+
formatted = rangeLeft.replace(/\n/g, eol) + rangeTrimmed + rangeRight.replace(/\n/g, eol);
|
|
14025
|
+
}
|
|
14026
|
+
}
|
|
14027
|
+
|
|
13911
14028
|
return {
|
|
13912
14029
|
formatted,
|
|
13913
14030
|
cursorOffset
|
|
@@ -13924,24 +14041,77 @@ function format(text, opts) {
|
|
|
13924
14041
|
};
|
|
13925
14042
|
}
|
|
13926
14043
|
|
|
13927
|
-
if (opts.
|
|
13928
|
-
|
|
14044
|
+
if (opts.endOfLine === "auto") {
|
|
14045
|
+
opts.endOfLine = guessEndOfLine(text);
|
|
14046
|
+
}
|
|
14047
|
+
|
|
14048
|
+
var hasCursor = opts.cursorOffset >= 0;
|
|
14049
|
+
var hasRangeStart = opts.rangeStart > 0;
|
|
14050
|
+
var hasRangeEnd = opts.rangeEnd < text.length; // get rid of CR/CRLF parsing
|
|
14051
|
+
|
|
14052
|
+
if (text.indexOf("\r") !== -1) {
|
|
14053
|
+
var offsetKeys = [hasCursor && "cursorOffset", hasRangeStart && "rangeStart", hasRangeEnd && "rangeEnd"].filter(Boolean).sort(function (aKey, bKey) {
|
|
14054
|
+
return opts[aKey] - opts[bKey];
|
|
14055
|
+
});
|
|
14056
|
+
|
|
14057
|
+
for (var i = offsetKeys.length - 1; i >= 0; i--) {
|
|
14058
|
+
var key = offsetKeys[i];
|
|
14059
|
+
text = text.slice(0, opts[key]) + PLACEHOLDERS[key] + text.slice(opts[key]);
|
|
14060
|
+
}
|
|
14061
|
+
|
|
14062
|
+
text = text.replace(/\r\n?/g, "\n");
|
|
14063
|
+
|
|
14064
|
+
var _loop = function _loop(_i) {
|
|
14065
|
+
var key = offsetKeys[_i];
|
|
14066
|
+
text = text.replace(PLACEHOLDERS[key], function (_, index) {
|
|
14067
|
+
opts[key] = index;
|
|
14068
|
+
return "";
|
|
14069
|
+
});
|
|
14070
|
+
};
|
|
14071
|
+
|
|
14072
|
+
for (var _i = 0; _i < offsetKeys.length; _i++) {
|
|
14073
|
+
_loop(_i);
|
|
14074
|
+
}
|
|
13929
14075
|
}
|
|
13930
14076
|
|
|
13931
14077
|
var hasUnicodeBOM = text.charCodeAt(0) === UTF8BOM;
|
|
13932
14078
|
|
|
13933
14079
|
if (hasUnicodeBOM) {
|
|
13934
14080
|
text = text.substring(1);
|
|
14081
|
+
|
|
14082
|
+
if (hasCursor) {
|
|
14083
|
+
opts.cursorOffset++;
|
|
14084
|
+
}
|
|
14085
|
+
|
|
14086
|
+
if (hasRangeStart) {
|
|
14087
|
+
opts.rangeStart++;
|
|
14088
|
+
}
|
|
14089
|
+
|
|
14090
|
+
if (hasRangeEnd) {
|
|
14091
|
+
opts.rangeEnd++;
|
|
14092
|
+
}
|
|
14093
|
+
}
|
|
14094
|
+
|
|
14095
|
+
if (!hasCursor) {
|
|
14096
|
+
opts.cursorOffset = -1;
|
|
13935
14097
|
}
|
|
13936
14098
|
|
|
13937
|
-
if (opts.
|
|
13938
|
-
|
|
14099
|
+
if (opts.rangeStart < 0) {
|
|
14100
|
+
opts.rangeStart = 0;
|
|
13939
14101
|
}
|
|
13940
14102
|
|
|
13941
|
-
|
|
14103
|
+
if (opts.rangeEnd > text.length) {
|
|
14104
|
+
opts.rangeEnd = text.length;
|
|
14105
|
+
}
|
|
14106
|
+
|
|
14107
|
+
var result = hasRangeStart || hasRangeEnd ? formatRange(text, opts) : coreFormat(opts.insertPragma && opts.printer.insertPragma && !hasPragma ? opts.printer.insertPragma(text) : text, opts);
|
|
13942
14108
|
|
|
13943
14109
|
if (hasUnicodeBOM) {
|
|
13944
14110
|
result.formatted = String.fromCharCode(UTF8BOM) + result.formatted;
|
|
14111
|
+
|
|
14112
|
+
if (hasCursor) {
|
|
14113
|
+
result.cursorOffset++;
|
|
14114
|
+
}
|
|
13945
14115
|
}
|
|
13946
14116
|
|
|
13947
14117
|
return result;
|
|
@@ -13955,6 +14125,11 @@ var core = {
|
|
|
13955
14125
|
|
|
13956
14126
|
parse(text, opts, massage) {
|
|
13957
14127
|
opts = normalizeOptions(opts);
|
|
14128
|
+
|
|
14129
|
+
if (text.indexOf("\r") !== -1) {
|
|
14130
|
+
text = text.replace(/\r\n?/g, "\n");
|
|
14131
|
+
}
|
|
14132
|
+
|
|
13958
14133
|
var parsed = parser.parse(text, opts);
|
|
13959
14134
|
|
|
13960
14135
|
if (massage) {
|
|
@@ -13974,7 +14149,7 @@ var core = {
|
|
|
13974
14149
|
formatDoc(doc$$1, opts) {
|
|
13975
14150
|
var debug = printDocToDebug(doc$$1);
|
|
13976
14151
|
opts = normalizeOptions(Object.assign({}, opts, {
|
|
13977
|
-
parser: "
|
|
14152
|
+
parser: "babel"
|
|
13978
14153
|
}));
|
|
13979
14154
|
return format(debug, opts).formatted;
|
|
13980
14155
|
},
|
|
@@ -21213,294 +21388,793 @@ var resolve$1 = createCommonjsModule(function (module, exports) {
|
|
|
21213
21388
|
module.exports = async;
|
|
21214
21389
|
});
|
|
21215
21390
|
|
|
21216
|
-
var
|
|
21217
|
-
var
|
|
21218
|
-
var
|
|
21219
|
-
var hardline$4 = _require$$0$builders$1.hardline;
|
|
21220
|
-
var softline$2 = _require$$0$builders$1.softline;
|
|
21221
|
-
var literalline$2 = _require$$0$builders$1.literalline;
|
|
21222
|
-
var concat$5 = _require$$0$builders$1.concat;
|
|
21223
|
-
var group$2 = _require$$0$builders$1.group;
|
|
21224
|
-
var dedentToRoot$1 = _require$$0$builders$1.dedentToRoot;
|
|
21225
|
-
var _require$$0$utils = doc.utils;
|
|
21226
|
-
var mapDoc$2 = _require$$0$utils.mapDoc;
|
|
21227
|
-
var stripTrailingHardline$1 = _require$$0$utils.stripTrailingHardline;
|
|
21228
|
-
|
|
21229
|
-
function embed(path$$1, print, textToDoc
|
|
21230
|
-
/*, options */
|
|
21231
|
-
) {
|
|
21232
|
-
var node = path$$1.getValue();
|
|
21233
|
-
var parent = path$$1.getParentNode();
|
|
21234
|
-
var parentParent = path$$1.getParentNode(1);
|
|
21235
|
-
|
|
21236
|
-
switch (node.type) {
|
|
21237
|
-
case "TemplateLiteral":
|
|
21238
|
-
{
|
|
21239
|
-
var isCss = [isStyledJsx, isStyledComponents, isCssProp, isAngularComponentStyles].some(function (isIt) {
|
|
21240
|
-
return isIt(path$$1);
|
|
21241
|
-
});
|
|
21242
|
-
|
|
21243
|
-
if (isCss) {
|
|
21244
|
-
// Get full template literal with expressions replaced by placeholders
|
|
21245
|
-
var rawQuasis = node.quasis.map(function (q) {
|
|
21246
|
-
return q.value.raw;
|
|
21247
|
-
});
|
|
21248
|
-
var placeholderID = 0;
|
|
21249
|
-
var text = rawQuasis.reduce(function (prevVal, currVal, idx) {
|
|
21250
|
-
return idx == 0 ? currVal : prevVal + "@prettier-placeholder-" + placeholderID++ + "-id" + currVal;
|
|
21251
|
-
}, "");
|
|
21252
|
-
var doc$$2 = textToDoc(text, {
|
|
21253
|
-
parser: "css"
|
|
21254
|
-
});
|
|
21255
|
-
return transformCssDoc(doc$$2, path$$1, print);
|
|
21256
|
-
}
|
|
21257
|
-
/*
|
|
21258
|
-
* react-relay and graphql-tag
|
|
21259
|
-
* graphql`...`
|
|
21260
|
-
* graphql.experimental`...`
|
|
21261
|
-
* gql`...`
|
|
21262
|
-
*
|
|
21263
|
-
* This intentionally excludes Relay Classic tags, as Prettier does not
|
|
21264
|
-
* support Relay Classic formatting.
|
|
21265
|
-
*/
|
|
21391
|
+
var addLeadingComment$2 = utilShared.addLeadingComment;
|
|
21392
|
+
var addTrailingComment$2 = utilShared.addTrailingComment;
|
|
21393
|
+
var addDanglingComment$2 = utilShared.addDanglingComment;
|
|
21266
21394
|
|
|
21395
|
+
function handleOwnLineComment(comment, text, options, ast, isLastComment) {
|
|
21396
|
+
var precedingNode = comment.precedingNode,
|
|
21397
|
+
enclosingNode = comment.enclosingNode,
|
|
21398
|
+
followingNode = comment.followingNode;
|
|
21267
21399
|
|
|
21268
|
-
|
|
21269
|
-
|
|
21270
|
-
|
|
21400
|
+
if (handleLastFunctionArgComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleMemberExpressionComments(enclosingNode, followingNode, comment) || handleIfStatementComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleWhileComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleTryStatementComments(enclosingNode, precedingNode, followingNode, comment) || handleClassComments(enclosingNode, precedingNode, followingNode, comment) || handleImportSpecifierComments(enclosingNode, comment) || handleForComments(enclosingNode, precedingNode, comment) || handleUnionTypeComments(precedingNode, enclosingNode, followingNode, comment) || handleOnlyComments(enclosingNode, ast, comment, isLastComment) || handleImportDeclarationComments(text, enclosingNode, precedingNode, comment, options) || handleAssignmentPatternComments(enclosingNode, comment) || handleMethodNameComments(text, enclosingNode, precedingNode, comment, options)) {
|
|
21401
|
+
return true;
|
|
21402
|
+
}
|
|
21271
21403
|
|
|
21272
|
-
|
|
21273
|
-
|
|
21274
|
-
}
|
|
21404
|
+
return false;
|
|
21405
|
+
}
|
|
21275
21406
|
|
|
21276
|
-
|
|
21407
|
+
function handleEndOfLineComment(comment, text, options, ast, isLastComment) {
|
|
21408
|
+
var precedingNode = comment.precedingNode,
|
|
21409
|
+
enclosingNode = comment.enclosingNode,
|
|
21410
|
+
followingNode = comment.followingNode;
|
|
21277
21411
|
|
|
21278
|
-
|
|
21279
|
-
|
|
21280
|
-
|
|
21281
|
-
var isLast = i === numQuasis - 1;
|
|
21282
|
-
var _text = templateElement.value.cooked; // Bail out if any of the quasis have an invalid escape sequence
|
|
21283
|
-
// (which would make the `cooked` value be `null` or `undefined`)
|
|
21412
|
+
if (handleLastFunctionArgComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleConditionalExpressionComments(enclosingNode, precedingNode, followingNode, comment, text, options) || handleImportSpecifierComments(enclosingNode, comment) || handleIfStatementComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleWhileComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleTryStatementComments(enclosingNode, precedingNode, followingNode, comment) || handleClassComments(enclosingNode, precedingNode, followingNode, comment) || handleLabeledStatementComments(enclosingNode, comment) || handleCallExpressionComments(precedingNode, enclosingNode, comment) || handlePropertyComments(enclosingNode, comment) || handleOnlyComments(enclosingNode, ast, comment, isLastComment) || handleTypeAliasComments(enclosingNode, followingNode, comment) || handleVariableDeclaratorComments(enclosingNode, followingNode, comment)) {
|
|
21413
|
+
return true;
|
|
21414
|
+
}
|
|
21284
21415
|
|
|
21285
|
-
|
|
21286
|
-
|
|
21287
|
-
}
|
|
21416
|
+
return false;
|
|
21417
|
+
}
|
|
21288
21418
|
|
|
21289
|
-
|
|
21419
|
+
function handleRemainingComment(comment, text, options, ast, isLastComment) {
|
|
21420
|
+
var precedingNode = comment.precedingNode,
|
|
21421
|
+
enclosingNode = comment.enclosingNode,
|
|
21422
|
+
followingNode = comment.followingNode;
|
|
21290
21423
|
|
|
21291
|
-
|
|
21292
|
-
|
|
21293
|
-
|
|
21294
|
-
var endsWithBlankLine = numLines > 2 && lines[numLines - 1].trim() === "" && lines[numLines - 2].trim() === "";
|
|
21295
|
-
var commentsAndWhitespaceOnly = lines.every(function (line) {
|
|
21296
|
-
return /^\s*(?:#[^\r\n]*)?$/.test(line);
|
|
21297
|
-
}); // Bail out if an interpolation occurs within a comment.
|
|
21424
|
+
if (handleIfStatementComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleWhileComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleObjectPropertyAssignment(enclosingNode, precedingNode, comment) || handleCommentInEmptyParens(text, enclosingNode, comment, options) || handleMethodNameComments(text, enclosingNode, precedingNode, comment, options) || handleOnlyComments(enclosingNode, ast, comment, isLastComment) || handleCommentAfterArrowParams(text, enclosingNode, comment, options) || handleFunctionNameComments(text, enclosingNode, precedingNode, comment, options) || handleTSMappedTypeComments(text, enclosingNode, precedingNode, followingNode, comment) || handleBreakAndContinueStatementComments(enclosingNode, comment)) {
|
|
21425
|
+
return true;
|
|
21426
|
+
}
|
|
21298
21427
|
|
|
21299
|
-
|
|
21300
|
-
|
|
21301
|
-
}
|
|
21428
|
+
return false;
|
|
21429
|
+
}
|
|
21302
21430
|
|
|
21303
|
-
|
|
21431
|
+
function addBlockStatementFirstComment(node, comment) {
|
|
21432
|
+
var body = node.body.filter(function (n) {
|
|
21433
|
+
return n.type !== "EmptyStatement";
|
|
21434
|
+
});
|
|
21304
21435
|
|
|
21305
|
-
|
|
21306
|
-
|
|
21307
|
-
|
|
21308
|
-
|
|
21309
|
-
|
|
21310
|
-
|
|
21311
|
-
}
|
|
21436
|
+
if (body.length === 0) {
|
|
21437
|
+
addDanglingComment$2(node, comment);
|
|
21438
|
+
} else {
|
|
21439
|
+
addLeadingComment$2(body[0], comment);
|
|
21440
|
+
}
|
|
21441
|
+
}
|
|
21312
21442
|
|
|
21313
|
-
|
|
21314
|
-
|
|
21443
|
+
function addBlockOrNotComment(node, comment) {
|
|
21444
|
+
if (node.type === "BlockStatement") {
|
|
21445
|
+
addBlockStatementFirstComment(node, comment);
|
|
21446
|
+
} else {
|
|
21447
|
+
addLeadingComment$2(node, comment);
|
|
21448
|
+
}
|
|
21449
|
+
} // There are often comments before the else clause of if statements like
|
|
21450
|
+
//
|
|
21451
|
+
// if (1) { ... }
|
|
21452
|
+
// // comment
|
|
21453
|
+
// else { ... }
|
|
21454
|
+
//
|
|
21455
|
+
// They are being attached as leading comments of the BlockExpression which
|
|
21456
|
+
// is not well printed. What we want is to instead move the comment inside
|
|
21457
|
+
// of the block and make it leadingComment of the first element of the block
|
|
21458
|
+
// or dangling comment of the block if there is nothing inside
|
|
21459
|
+
//
|
|
21460
|
+
// if (1) { ... }
|
|
21461
|
+
// else {
|
|
21462
|
+
// // comment
|
|
21463
|
+
// ...
|
|
21464
|
+
// }
|
|
21315
21465
|
|
|
21316
|
-
if (!isFirst && startsWithBlankLine) {
|
|
21317
|
-
parts.push("");
|
|
21318
|
-
}
|
|
21319
21466
|
|
|
21320
|
-
|
|
21467
|
+
function handleIfStatementComments(text, precedingNode, enclosingNode, followingNode, comment, options) {
|
|
21468
|
+
if (!enclosingNode || enclosingNode.type !== "IfStatement" || !followingNode) {
|
|
21469
|
+
return false;
|
|
21470
|
+
} // We unfortunately have no way using the AST or location of nodes to know
|
|
21471
|
+
// if the comment is positioned before the condition parenthesis:
|
|
21472
|
+
// if (a /* comment */) {}
|
|
21473
|
+
// The only workaround I found is to look at the next character to see if
|
|
21474
|
+
// it is a ).
|
|
21321
21475
|
|
|
21322
|
-
if (!isLast && endsWithBlankLine) {
|
|
21323
|
-
parts.push("");
|
|
21324
|
-
}
|
|
21325
|
-
} else if (!isFirst && !isLast && startsWithBlankLine) {
|
|
21326
|
-
parts.push("");
|
|
21327
|
-
}
|
|
21328
21476
|
|
|
21329
|
-
|
|
21330
|
-
parts.push(concat$5(["${", expressionDoc, "}"]));
|
|
21331
|
-
}
|
|
21332
|
-
}
|
|
21477
|
+
var nextCharacter = util$1.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd);
|
|
21333
21478
|
|
|
21334
|
-
|
|
21335
|
-
|
|
21479
|
+
if (nextCharacter === ")") {
|
|
21480
|
+
addTrailingComment$2(precedingNode, comment);
|
|
21481
|
+
return true;
|
|
21482
|
+
} // Comments before `else`:
|
|
21483
|
+
// - treat as trailing comments of the consequent, if it's a BlockStatement
|
|
21484
|
+
// - treat as a dangling comment otherwise
|
|
21336
21485
|
|
|
21337
|
-
if (isHtml(path$$1)) {
|
|
21338
|
-
return printHtmlTemplateLiteral(path$$1, print, textToDoc, "html");
|
|
21339
|
-
}
|
|
21340
21486
|
|
|
21341
|
-
|
|
21342
|
-
|
|
21343
|
-
|
|
21487
|
+
if (precedingNode === enclosingNode.consequent && followingNode === enclosingNode.alternate) {
|
|
21488
|
+
if (precedingNode.type === "BlockStatement") {
|
|
21489
|
+
addTrailingComment$2(precedingNode, comment);
|
|
21490
|
+
} else {
|
|
21491
|
+
addDanglingComment$2(enclosingNode, comment);
|
|
21492
|
+
}
|
|
21344
21493
|
|
|
21345
|
-
|
|
21346
|
-
|
|
21494
|
+
return true;
|
|
21495
|
+
}
|
|
21347
21496
|
|
|
21348
|
-
|
|
21349
|
-
|
|
21350
|
-
|
|
21351
|
-
|
|
21352
|
-
* markdown`...`
|
|
21353
|
-
*/
|
|
21354
|
-
if (parentParent && parentParent.type === "TaggedTemplateExpression" && parent.quasis.length === 1 && parentParent.tag.type === "Identifier" && (parentParent.tag.name === "md" || parentParent.tag.name === "markdown")) {
|
|
21355
|
-
var _text2 = parent.quasis[0].value.raw.replace(/((?:\\\\)*)\\`/g, function (_, backslashes) {
|
|
21356
|
-
return "\\".repeat(backslashes.length / 2) + "`";
|
|
21357
|
-
});
|
|
21497
|
+
if (followingNode.type === "BlockStatement") {
|
|
21498
|
+
addBlockStatementFirstComment(followingNode, comment);
|
|
21499
|
+
return true;
|
|
21500
|
+
}
|
|
21358
21501
|
|
|
21359
|
-
|
|
21360
|
-
|
|
21361
|
-
|
|
21362
|
-
|
|
21502
|
+
if (followingNode.type === "IfStatement") {
|
|
21503
|
+
addBlockOrNotComment(followingNode.consequent, comment);
|
|
21504
|
+
return true;
|
|
21505
|
+
} // For comments positioned after the condition parenthesis in an if statement
|
|
21506
|
+
// before the consequent without brackets on, such as
|
|
21507
|
+
// if (a) /* comment */ true,
|
|
21508
|
+
// we look at the next character to see if the following node
|
|
21509
|
+
// is the consequent for the if statement
|
|
21363
21510
|
|
|
21364
|
-
break;
|
|
21365
|
-
}
|
|
21366
|
-
}
|
|
21367
21511
|
|
|
21368
|
-
|
|
21369
|
-
|
|
21370
|
-
|
|
21371
|
-
__inJsTemplate: true
|
|
21372
|
-
});
|
|
21373
|
-
return stripTrailingHardline$1(escapeTemplateCharacters(doc$$2, true));
|
|
21512
|
+
if (enclosingNode.consequent === followingNode) {
|
|
21513
|
+
addLeadingComment$2(followingNode, comment);
|
|
21514
|
+
return true;
|
|
21374
21515
|
}
|
|
21375
|
-
}
|
|
21376
21516
|
|
|
21377
|
-
|
|
21378
|
-
var firstMatchedIndent = str.match(/^([^\S\n]*)\S/m);
|
|
21379
|
-
return firstMatchedIndent === null ? "" : firstMatchedIndent[1];
|
|
21517
|
+
return false;
|
|
21380
21518
|
}
|
|
21381
21519
|
|
|
21382
|
-
function
|
|
21383
|
-
|
|
21384
|
-
|
|
21385
|
-
|
|
21386
|
-
|
|
21520
|
+
function handleWhileComments(text, precedingNode, enclosingNode, followingNode, comment, options) {
|
|
21521
|
+
if (!enclosingNode || enclosingNode.type !== "WhileStatement" || !followingNode) {
|
|
21522
|
+
return false;
|
|
21523
|
+
} // We unfortunately have no way using the AST or location of nodes to know
|
|
21524
|
+
// if the comment is positioned before the condition parenthesis:
|
|
21525
|
+
// while (a /* comment */) {}
|
|
21526
|
+
// The only workaround I found is to look at the next character to see if
|
|
21527
|
+
// it is a ).
|
|
21387
21528
|
|
|
21388
|
-
var parts = [];
|
|
21389
|
-
currentDoc.parts.forEach(function (part) {
|
|
21390
|
-
if (typeof part === "string") {
|
|
21391
|
-
parts.push(raw ? part.replace(/(\\*)`/g, "$1$1\\`") : part.replace(/([\\`]|\$\{)/g, "\\$1"));
|
|
21392
|
-
} else {
|
|
21393
|
-
parts.push(part);
|
|
21394
|
-
}
|
|
21395
|
-
});
|
|
21396
|
-
return Object.assign({}, currentDoc, {
|
|
21397
|
-
parts
|
|
21398
|
-
});
|
|
21399
|
-
});
|
|
21400
|
-
}
|
|
21401
21529
|
|
|
21402
|
-
|
|
21403
|
-
var parentNode = path$$1.getValue();
|
|
21404
|
-
var isEmpty = parentNode.quasis.length === 1 && !parentNode.quasis[0].value.raw.trim();
|
|
21530
|
+
var nextCharacter = util$1.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd);
|
|
21405
21531
|
|
|
21406
|
-
if (
|
|
21407
|
-
|
|
21532
|
+
if (nextCharacter === ")") {
|
|
21533
|
+
addTrailingComment$2(precedingNode, comment);
|
|
21534
|
+
return true;
|
|
21408
21535
|
}
|
|
21409
21536
|
|
|
21410
|
-
|
|
21411
|
-
|
|
21412
|
-
|
|
21413
|
-
|
|
21414
|
-
if (!newDoc) {
|
|
21415
|
-
throw new Error("Couldn't insert all the expressions");
|
|
21537
|
+
if (followingNode.type === "BlockStatement") {
|
|
21538
|
+
addBlockStatementFirstComment(followingNode, comment);
|
|
21539
|
+
return true;
|
|
21416
21540
|
}
|
|
21417
21541
|
|
|
21418
|
-
return
|
|
21419
|
-
} //
|
|
21420
|
-
// and replace them with the expression docs one by one
|
|
21421
|
-
// returns a new doc with all the placeholders replaced,
|
|
21422
|
-
// or null if it couldn't replace any expression
|
|
21542
|
+
return false;
|
|
21543
|
+
} // Same as IfStatement but for TryStatement
|
|
21423
21544
|
|
|
21424
21545
|
|
|
21425
|
-
function
|
|
21426
|
-
if (!
|
|
21427
|
-
return
|
|
21546
|
+
function handleTryStatementComments(enclosingNode, precedingNode, followingNode, comment) {
|
|
21547
|
+
if (!enclosingNode || enclosingNode.type !== "TryStatement" && enclosingNode.type !== "CatchClause" || !followingNode) {
|
|
21548
|
+
return false;
|
|
21428
21549
|
}
|
|
21429
21550
|
|
|
21430
|
-
|
|
21431
|
-
|
|
21432
|
-
|
|
21433
|
-
|
|
21434
|
-
return doc$$2;
|
|
21435
|
-
}
|
|
21551
|
+
if (enclosingNode.type === "CatchClause" && precedingNode) {
|
|
21552
|
+
addTrailingComment$2(precedingNode, comment);
|
|
21553
|
+
return true;
|
|
21554
|
+
}
|
|
21436
21555
|
|
|
21437
|
-
|
|
21438
|
-
|
|
21439
|
-
|
|
21556
|
+
if (followingNode.type === "BlockStatement") {
|
|
21557
|
+
addBlockStatementFirstComment(followingNode, comment);
|
|
21558
|
+
return true;
|
|
21559
|
+
}
|
|
21440
21560
|
|
|
21441
|
-
|
|
21442
|
-
|
|
21443
|
-
|
|
21444
|
-
|
|
21445
|
-
var rest = parts.slice(placeholderIndex + 1);
|
|
21446
|
-
parts = parts.slice(0, atIndex).concat([at + placeholder]).concat(rest);
|
|
21447
|
-
}
|
|
21561
|
+
if (followingNode.type === "TryStatement") {
|
|
21562
|
+
addBlockOrNotComment(followingNode.finalizer, comment);
|
|
21563
|
+
return true;
|
|
21564
|
+
}
|
|
21448
21565
|
|
|
21449
|
-
|
|
21450
|
-
|
|
21451
|
-
|
|
21566
|
+
if (followingNode.type === "CatchClause") {
|
|
21567
|
+
addBlockOrNotComment(followingNode.body, comment);
|
|
21568
|
+
return true;
|
|
21569
|
+
}
|
|
21452
21570
|
|
|
21453
|
-
|
|
21454
|
-
|
|
21571
|
+
return false;
|
|
21572
|
+
}
|
|
21455
21573
|
|
|
21456
|
-
|
|
21574
|
+
function handleMemberExpressionComments(enclosingNode, followingNode, comment) {
|
|
21575
|
+
if (enclosingNode && enclosingNode.type === "MemberExpression" && followingNode && followingNode.type === "Identifier") {
|
|
21576
|
+
addLeadingComment$2(enclosingNode, comment);
|
|
21577
|
+
return true;
|
|
21578
|
+
}
|
|
21457
21579
|
|
|
21458
|
-
|
|
21580
|
+
return false;
|
|
21581
|
+
}
|
|
21459
21582
|
|
|
21460
|
-
|
|
21461
|
-
|
|
21583
|
+
function handleConditionalExpressionComments(enclosingNode, precedingNode, followingNode, comment, text, options) {
|
|
21584
|
+
var isSameLineAsPrecedingNode = precedingNode && !util$1.hasNewlineInRange(text, options.locEnd(precedingNode), options.locStart(comment));
|
|
21462
21585
|
|
|
21463
|
-
|
|
21464
|
-
|
|
21465
|
-
|
|
21466
|
-
|
|
21467
|
-
}
|
|
21586
|
+
if ((!precedingNode || !isSameLineAsPrecedingNode) && enclosingNode && enclosingNode.type === "ConditionalExpression" && followingNode) {
|
|
21587
|
+
addLeadingComment$2(followingNode, comment);
|
|
21588
|
+
return true;
|
|
21589
|
+
}
|
|
21468
21590
|
|
|
21469
|
-
|
|
21470
|
-
parts: parts
|
|
21471
|
-
});
|
|
21472
|
-
});
|
|
21473
|
-
return expressions.length === replaceCounter ? newDoc : null;
|
|
21591
|
+
return false;
|
|
21474
21592
|
}
|
|
21475
21593
|
|
|
21476
|
-
function
|
|
21477
|
-
|
|
21478
|
-
|
|
21479
|
-
|
|
21480
|
-
|
|
21481
|
-
}).forEach(function (textLine, i, array) {
|
|
21482
|
-
// Lines are either whitespace only, or a comment (with poential whitespace
|
|
21483
|
-
// around it). Drop whitespace-only lines.
|
|
21484
|
-
if (textLine === "") {
|
|
21485
|
-
return;
|
|
21486
|
-
}
|
|
21594
|
+
function handleObjectPropertyAssignment(enclosingNode, precedingNode, comment) {
|
|
21595
|
+
if (enclosingNode && (enclosingNode.type === "ObjectProperty" || enclosingNode.type === "Property") && enclosingNode.shorthand && enclosingNode.key === precedingNode && enclosingNode.value.type === "AssignmentPattern") {
|
|
21596
|
+
addTrailingComment$2(enclosingNode.value.left, comment);
|
|
21597
|
+
return true;
|
|
21598
|
+
}
|
|
21487
21599
|
|
|
21488
|
-
|
|
21489
|
-
|
|
21490
|
-
|
|
21491
|
-
|
|
21600
|
+
return false;
|
|
21601
|
+
}
|
|
21602
|
+
|
|
21603
|
+
function handleClassComments(enclosingNode, precedingNode, followingNode, comment) {
|
|
21604
|
+
if (enclosingNode && (enclosingNode.type === "ClassDeclaration" || enclosingNode.type === "ClassExpression") && enclosingNode.decorators && enclosingNode.decorators.length > 0 && !(followingNode && followingNode.type === "Decorator")) {
|
|
21605
|
+
if (!enclosingNode.decorators || enclosingNode.decorators.length === 0) {
|
|
21606
|
+
addLeadingComment$2(enclosingNode, comment);
|
|
21492
21607
|
} else {
|
|
21493
|
-
|
|
21608
|
+
addTrailingComment$2(enclosingNode.decorators[enclosingNode.decorators.length - 1], comment);
|
|
21494
21609
|
}
|
|
21495
21610
|
|
|
21496
|
-
|
|
21497
|
-
}
|
|
21611
|
+
return true;
|
|
21612
|
+
}
|
|
21498
21613
|
|
|
21499
|
-
return
|
|
21614
|
+
return false;
|
|
21500
21615
|
}
|
|
21501
|
-
|
|
21502
|
-
|
|
21503
|
-
|
|
21616
|
+
|
|
21617
|
+
function handleMethodNameComments(text, enclosingNode, precedingNode, comment, options) {
|
|
21618
|
+
// This is only needed for estree parsers (flow, typescript) to attach
|
|
21619
|
+
// after a method name:
|
|
21620
|
+
// obj = { fn /*comment*/() {} };
|
|
21621
|
+
if (enclosingNode && precedingNode && (enclosingNode.type === "Property" || enclosingNode.type === "MethodDefinition") && precedingNode.type === "Identifier" && enclosingNode.key === precedingNode && // special Property case: { key: /*comment*/(value) };
|
|
21622
|
+
// comment should be attached to value instead of key
|
|
21623
|
+
util$1.getNextNonSpaceNonCommentCharacter(text, precedingNode, options.locEnd) !== ":") {
|
|
21624
|
+
addTrailingComment$2(precedingNode, comment);
|
|
21625
|
+
return true;
|
|
21626
|
+
} // Print comments between decorators and class methods as a trailing comment
|
|
21627
|
+
// on the decorator node instead of the method node
|
|
21628
|
+
|
|
21629
|
+
|
|
21630
|
+
if (precedingNode && enclosingNode && precedingNode.type === "Decorator" && (enclosingNode.type === "ClassMethod" || enclosingNode.type === "ClassProperty" || enclosingNode.type === "TSAbstractClassProperty" || enclosingNode.type === "TSAbstractMethodDefinition" || enclosingNode.type === "MethodDefinition")) {
|
|
21631
|
+
addTrailingComment$2(precedingNode, comment);
|
|
21632
|
+
return true;
|
|
21633
|
+
}
|
|
21634
|
+
|
|
21635
|
+
return false;
|
|
21636
|
+
}
|
|
21637
|
+
|
|
21638
|
+
function handleFunctionNameComments(text, enclosingNode, precedingNode, comment, options) {
|
|
21639
|
+
if (util$1.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd) !== "(") {
|
|
21640
|
+
return false;
|
|
21641
|
+
}
|
|
21642
|
+
|
|
21643
|
+
if (precedingNode && enclosingNode && (enclosingNode.type === "FunctionDeclaration" || enclosingNode.type === "FunctionExpression" || enclosingNode.type === "ClassMethod" || enclosingNode.type === "MethodDefinition" || enclosingNode.type === "ObjectMethod")) {
|
|
21644
|
+
addTrailingComment$2(precedingNode, comment);
|
|
21645
|
+
return true;
|
|
21646
|
+
}
|
|
21647
|
+
|
|
21648
|
+
return false;
|
|
21649
|
+
}
|
|
21650
|
+
|
|
21651
|
+
function handleCommentAfterArrowParams(text, enclosingNode, comment, options) {
|
|
21652
|
+
if (!(enclosingNode && enclosingNode.type === "ArrowFunctionExpression")) {
|
|
21653
|
+
return false;
|
|
21654
|
+
}
|
|
21655
|
+
|
|
21656
|
+
var index = utilShared.getNextNonSpaceNonCommentCharacterIndex(text, comment, options);
|
|
21657
|
+
|
|
21658
|
+
if (text.substr(index, 2) === "=>") {
|
|
21659
|
+
addDanglingComment$2(enclosingNode, comment);
|
|
21660
|
+
return true;
|
|
21661
|
+
}
|
|
21662
|
+
|
|
21663
|
+
return false;
|
|
21664
|
+
}
|
|
21665
|
+
|
|
21666
|
+
function handleCommentInEmptyParens(text, enclosingNode, comment, options) {
|
|
21667
|
+
if (util$1.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd) !== ")") {
|
|
21668
|
+
return false;
|
|
21669
|
+
} // Only add dangling comments to fix the case when no params are present,
|
|
21670
|
+
// i.e. a function without any argument.
|
|
21671
|
+
|
|
21672
|
+
|
|
21673
|
+
if (enclosingNode && ((enclosingNode.type === "FunctionDeclaration" || enclosingNode.type === "FunctionExpression" || enclosingNode.type === "ArrowFunctionExpression" && (enclosingNode.body.type !== "CallExpression" || enclosingNode.body.arguments.length === 0) || enclosingNode.type === "ClassMethod" || enclosingNode.type === "ObjectMethod") && enclosingNode.params.length === 0 || (enclosingNode.type === "CallExpression" || enclosingNode.type === "NewExpression") && enclosingNode.arguments.length === 0)) {
|
|
21674
|
+
addDanglingComment$2(enclosingNode, comment);
|
|
21675
|
+
return true;
|
|
21676
|
+
}
|
|
21677
|
+
|
|
21678
|
+
if (enclosingNode && enclosingNode.type === "MethodDefinition" && enclosingNode.value.params.length === 0) {
|
|
21679
|
+
addDanglingComment$2(enclosingNode.value, comment);
|
|
21680
|
+
return true;
|
|
21681
|
+
}
|
|
21682
|
+
|
|
21683
|
+
return false;
|
|
21684
|
+
}
|
|
21685
|
+
|
|
21686
|
+
function handleLastFunctionArgComments(text, precedingNode, enclosingNode, followingNode, comment, options) {
|
|
21687
|
+
// Type definitions functions
|
|
21688
|
+
if (precedingNode && precedingNode.type === "FunctionTypeParam" && enclosingNode && enclosingNode.type === "FunctionTypeAnnotation" && followingNode && followingNode.type !== "FunctionTypeParam") {
|
|
21689
|
+
addTrailingComment$2(precedingNode, comment);
|
|
21690
|
+
return true;
|
|
21691
|
+
} // Real functions
|
|
21692
|
+
|
|
21693
|
+
|
|
21694
|
+
if (precedingNode && (precedingNode.type === "Identifier" || precedingNode.type === "AssignmentPattern") && enclosingNode && (enclosingNode.type === "ArrowFunctionExpression" || enclosingNode.type === "FunctionExpression" || enclosingNode.type === "FunctionDeclaration" || enclosingNode.type === "ObjectMethod" || enclosingNode.type === "ClassMethod") && util$1.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd) === ")") {
|
|
21695
|
+
addTrailingComment$2(precedingNode, comment);
|
|
21696
|
+
return true;
|
|
21697
|
+
}
|
|
21698
|
+
|
|
21699
|
+
if (enclosingNode && enclosingNode.type === "FunctionDeclaration" && followingNode && followingNode.type === "BlockStatement") {
|
|
21700
|
+
var functionParamRightParenIndex = function () {
|
|
21701
|
+
if (enclosingNode.params.length !== 0) {
|
|
21702
|
+
return util$1.getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, options.locEnd(util$1.getLast(enclosingNode.params)));
|
|
21703
|
+
}
|
|
21704
|
+
|
|
21705
|
+
var functionParamLeftParenIndex = util$1.getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, options.locEnd(enclosingNode.id));
|
|
21706
|
+
return util$1.getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, functionParamLeftParenIndex + 1);
|
|
21707
|
+
}();
|
|
21708
|
+
|
|
21709
|
+
if (options.locStart(comment) > functionParamRightParenIndex) {
|
|
21710
|
+
addBlockStatementFirstComment(followingNode, comment);
|
|
21711
|
+
return true;
|
|
21712
|
+
}
|
|
21713
|
+
}
|
|
21714
|
+
|
|
21715
|
+
return false;
|
|
21716
|
+
}
|
|
21717
|
+
|
|
21718
|
+
function handleImportSpecifierComments(enclosingNode, comment) {
|
|
21719
|
+
if (enclosingNode && enclosingNode.type === "ImportSpecifier") {
|
|
21720
|
+
addLeadingComment$2(enclosingNode, comment);
|
|
21721
|
+
return true;
|
|
21722
|
+
}
|
|
21723
|
+
|
|
21724
|
+
return false;
|
|
21725
|
+
}
|
|
21726
|
+
|
|
21727
|
+
function handleLabeledStatementComments(enclosingNode, comment) {
|
|
21728
|
+
if (enclosingNode && enclosingNode.type === "LabeledStatement") {
|
|
21729
|
+
addLeadingComment$2(enclosingNode, comment);
|
|
21730
|
+
return true;
|
|
21731
|
+
}
|
|
21732
|
+
|
|
21733
|
+
return false;
|
|
21734
|
+
}
|
|
21735
|
+
|
|
21736
|
+
function handleBreakAndContinueStatementComments(enclosingNode, comment) {
|
|
21737
|
+
if (enclosingNode && (enclosingNode.type === "ContinueStatement" || enclosingNode.type === "BreakStatement") && !enclosingNode.label) {
|
|
21738
|
+
addTrailingComment$2(enclosingNode, comment);
|
|
21739
|
+
return true;
|
|
21740
|
+
}
|
|
21741
|
+
|
|
21742
|
+
return false;
|
|
21743
|
+
}
|
|
21744
|
+
|
|
21745
|
+
function handleCallExpressionComments(precedingNode, enclosingNode, comment) {
|
|
21746
|
+
if (enclosingNode && enclosingNode.type === "CallExpression" && precedingNode && enclosingNode.callee === precedingNode && enclosingNode.arguments.length > 0) {
|
|
21747
|
+
addLeadingComment$2(enclosingNode.arguments[0], comment);
|
|
21748
|
+
return true;
|
|
21749
|
+
}
|
|
21750
|
+
|
|
21751
|
+
return false;
|
|
21752
|
+
}
|
|
21753
|
+
|
|
21754
|
+
function handleUnionTypeComments(precedingNode, enclosingNode, followingNode, comment) {
|
|
21755
|
+
if (enclosingNode && (enclosingNode.type === "UnionTypeAnnotation" || enclosingNode.type === "TSUnionType")) {
|
|
21756
|
+
addTrailingComment$2(precedingNode, comment);
|
|
21757
|
+
return true;
|
|
21758
|
+
}
|
|
21759
|
+
|
|
21760
|
+
return false;
|
|
21761
|
+
}
|
|
21762
|
+
|
|
21763
|
+
function handlePropertyComments(enclosingNode, comment) {
|
|
21764
|
+
if (enclosingNode && (enclosingNode.type === "Property" || enclosingNode.type === "ObjectProperty")) {
|
|
21765
|
+
addLeadingComment$2(enclosingNode, comment);
|
|
21766
|
+
return true;
|
|
21767
|
+
}
|
|
21768
|
+
|
|
21769
|
+
return false;
|
|
21770
|
+
}
|
|
21771
|
+
|
|
21772
|
+
function handleOnlyComments(enclosingNode, ast, comment, isLastComment) {
|
|
21773
|
+
// With Flow the enclosingNode is undefined so use the AST instead.
|
|
21774
|
+
if (ast && ast.body && ast.body.length === 0) {
|
|
21775
|
+
if (isLastComment) {
|
|
21776
|
+
addDanglingComment$2(ast, comment);
|
|
21777
|
+
} else {
|
|
21778
|
+
addLeadingComment$2(ast, comment);
|
|
21779
|
+
}
|
|
21780
|
+
|
|
21781
|
+
return true;
|
|
21782
|
+
} else if (enclosingNode && enclosingNode.type === "Program" && enclosingNode.body.length === 0 && enclosingNode.directives && enclosingNode.directives.length === 0) {
|
|
21783
|
+
if (isLastComment) {
|
|
21784
|
+
addDanglingComment$2(enclosingNode, comment);
|
|
21785
|
+
} else {
|
|
21786
|
+
addLeadingComment$2(enclosingNode, comment);
|
|
21787
|
+
}
|
|
21788
|
+
|
|
21789
|
+
return true;
|
|
21790
|
+
}
|
|
21791
|
+
|
|
21792
|
+
return false;
|
|
21793
|
+
}
|
|
21794
|
+
|
|
21795
|
+
function handleForComments(enclosingNode, precedingNode, comment) {
|
|
21796
|
+
if (enclosingNode && (enclosingNode.type === "ForInStatement" || enclosingNode.type === "ForOfStatement")) {
|
|
21797
|
+
addLeadingComment$2(enclosingNode, comment);
|
|
21798
|
+
return true;
|
|
21799
|
+
}
|
|
21800
|
+
|
|
21801
|
+
return false;
|
|
21802
|
+
}
|
|
21803
|
+
|
|
21804
|
+
function handleImportDeclarationComments(text, enclosingNode, precedingNode, comment, options) {
|
|
21805
|
+
if (precedingNode && precedingNode.type === "ImportSpecifier" && enclosingNode && enclosingNode.type === "ImportDeclaration" && util$1.hasNewline(text, options.locEnd(comment))) {
|
|
21806
|
+
addTrailingComment$2(precedingNode, comment);
|
|
21807
|
+
return true;
|
|
21808
|
+
}
|
|
21809
|
+
|
|
21810
|
+
return false;
|
|
21811
|
+
}
|
|
21812
|
+
|
|
21813
|
+
function handleAssignmentPatternComments(enclosingNode, comment) {
|
|
21814
|
+
if (enclosingNode && enclosingNode.type === "AssignmentPattern") {
|
|
21815
|
+
addLeadingComment$2(enclosingNode, comment);
|
|
21816
|
+
return true;
|
|
21817
|
+
}
|
|
21818
|
+
|
|
21819
|
+
return false;
|
|
21820
|
+
}
|
|
21821
|
+
|
|
21822
|
+
function handleTypeAliasComments(enclosingNode, followingNode, comment) {
|
|
21823
|
+
if (enclosingNode && enclosingNode.type === "TypeAlias") {
|
|
21824
|
+
addLeadingComment$2(enclosingNode, comment);
|
|
21825
|
+
return true;
|
|
21826
|
+
}
|
|
21827
|
+
|
|
21828
|
+
return false;
|
|
21829
|
+
}
|
|
21830
|
+
|
|
21831
|
+
function handleVariableDeclaratorComments(enclosingNode, followingNode, comment) {
|
|
21832
|
+
if (enclosingNode && (enclosingNode.type === "VariableDeclarator" || enclosingNode.type === "AssignmentExpression") && followingNode && (followingNode.type === "ObjectExpression" || followingNode.type === "ArrayExpression" || followingNode.type === "TemplateLiteral" || followingNode.type === "TaggedTemplateExpression")) {
|
|
21833
|
+
addLeadingComment$2(followingNode, comment);
|
|
21834
|
+
return true;
|
|
21835
|
+
}
|
|
21836
|
+
|
|
21837
|
+
return false;
|
|
21838
|
+
}
|
|
21839
|
+
|
|
21840
|
+
function handleTSMappedTypeComments(text, enclosingNode, precedingNode, followingNode, comment) {
|
|
21841
|
+
if (!enclosingNode || enclosingNode.type !== "TSMappedType") {
|
|
21842
|
+
return false;
|
|
21843
|
+
}
|
|
21844
|
+
|
|
21845
|
+
if (followingNode && followingNode.type === "TSTypeParameter" && followingNode.name) {
|
|
21846
|
+
addLeadingComment$2(followingNode.name, comment);
|
|
21847
|
+
return true;
|
|
21848
|
+
}
|
|
21849
|
+
|
|
21850
|
+
if (precedingNode && precedingNode.type === "TSTypeParameter" && precedingNode.constraint) {
|
|
21851
|
+
addTrailingComment$2(precedingNode.constraint, comment);
|
|
21852
|
+
return true;
|
|
21853
|
+
}
|
|
21854
|
+
|
|
21855
|
+
return false;
|
|
21856
|
+
}
|
|
21857
|
+
|
|
21858
|
+
function isBlockComment$1(comment) {
|
|
21859
|
+
return comment.type === "Block" || comment.type === "CommentBlock";
|
|
21860
|
+
}
|
|
21861
|
+
|
|
21862
|
+
function hasLeadingComment$2(node) {
|
|
21863
|
+
var fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {
|
|
21864
|
+
return true;
|
|
21865
|
+
};
|
|
21866
|
+
|
|
21867
|
+
if (node.leadingComments) {
|
|
21868
|
+
return node.leadingComments.some(fn);
|
|
21869
|
+
}
|
|
21870
|
+
|
|
21871
|
+
if (node.comments) {
|
|
21872
|
+
return node.comments.some(function (comment) {
|
|
21873
|
+
return comment.leading && fn(comment);
|
|
21874
|
+
});
|
|
21875
|
+
}
|
|
21876
|
+
|
|
21877
|
+
return false;
|
|
21878
|
+
}
|
|
21879
|
+
|
|
21880
|
+
var comments$3 = {
|
|
21881
|
+
handleOwnLineComment,
|
|
21882
|
+
handleEndOfLineComment,
|
|
21883
|
+
handleRemainingComment,
|
|
21884
|
+
hasLeadingComment: hasLeadingComment$2,
|
|
21885
|
+
isBlockComment: isBlockComment$1
|
|
21886
|
+
};
|
|
21887
|
+
|
|
21888
|
+
var isBlockComment = comments$3.isBlockComment;
|
|
21889
|
+
var hasLeadingComment$1 = comments$3.hasLeadingComment;
|
|
21890
|
+
var _require$$1$builders = doc.builders;
|
|
21891
|
+
var indent$3 = _require$$1$builders.indent;
|
|
21892
|
+
var join$3 = _require$$1$builders.join;
|
|
21893
|
+
var hardline$4 = _require$$1$builders.hardline;
|
|
21894
|
+
var softline$2 = _require$$1$builders.softline;
|
|
21895
|
+
var literalline$2 = _require$$1$builders.literalline;
|
|
21896
|
+
var concat$5 = _require$$1$builders.concat;
|
|
21897
|
+
var group$2 = _require$$1$builders.group;
|
|
21898
|
+
var dedentToRoot$1 = _require$$1$builders.dedentToRoot;
|
|
21899
|
+
var _require$$1$utils = doc.utils;
|
|
21900
|
+
var mapDoc$3 = _require$$1$utils.mapDoc;
|
|
21901
|
+
var stripTrailingHardline$1 = _require$$1$utils.stripTrailingHardline;
|
|
21902
|
+
|
|
21903
|
+
function embed(path$$1, print, textToDoc
|
|
21904
|
+
/*, options */
|
|
21905
|
+
) {
|
|
21906
|
+
var node = path$$1.getValue();
|
|
21907
|
+
var parent = path$$1.getParentNode();
|
|
21908
|
+
var parentParent = path$$1.getParentNode(1);
|
|
21909
|
+
|
|
21910
|
+
switch (node.type) {
|
|
21911
|
+
case "TemplateLiteral":
|
|
21912
|
+
{
|
|
21913
|
+
var isCss = [isStyledJsx, isStyledComponents, isCssProp, isAngularComponentStyles].some(function (isIt) {
|
|
21914
|
+
return isIt(path$$1);
|
|
21915
|
+
});
|
|
21916
|
+
|
|
21917
|
+
if (isCss) {
|
|
21918
|
+
// Get full template literal with expressions replaced by placeholders
|
|
21919
|
+
var rawQuasis = node.quasis.map(function (q) {
|
|
21920
|
+
return q.value.raw;
|
|
21921
|
+
});
|
|
21922
|
+
var placeholderID = 0;
|
|
21923
|
+
var text = rawQuasis.reduce(function (prevVal, currVal, idx) {
|
|
21924
|
+
return idx == 0 ? currVal : prevVal + "@prettier-placeholder-" + placeholderID++ + "-id" + currVal;
|
|
21925
|
+
}, "");
|
|
21926
|
+
var doc$$2 = textToDoc(text, {
|
|
21927
|
+
parser: "css"
|
|
21928
|
+
});
|
|
21929
|
+
return transformCssDoc(doc$$2, path$$1, print);
|
|
21930
|
+
}
|
|
21931
|
+
/*
|
|
21932
|
+
* react-relay and graphql-tag
|
|
21933
|
+
* graphql`...`
|
|
21934
|
+
* graphql.experimental`...`
|
|
21935
|
+
* gql`...`
|
|
21936
|
+
*
|
|
21937
|
+
* This intentionally excludes Relay Classic tags, as Prettier does not
|
|
21938
|
+
* support Relay Classic formatting.
|
|
21939
|
+
*/
|
|
21940
|
+
|
|
21941
|
+
|
|
21942
|
+
if (isGraphQL(path$$1)) {
|
|
21943
|
+
var expressionDocs = node.expressions ? path$$1.map(print, "expressions") : [];
|
|
21944
|
+
var numQuasis = node.quasis.length;
|
|
21945
|
+
|
|
21946
|
+
if (numQuasis === 1 && node.quasis[0].value.raw.trim() === "") {
|
|
21947
|
+
return "``";
|
|
21948
|
+
}
|
|
21949
|
+
|
|
21950
|
+
var parts = [];
|
|
21951
|
+
|
|
21952
|
+
for (var i = 0; i < numQuasis; i++) {
|
|
21953
|
+
var templateElement = node.quasis[i];
|
|
21954
|
+
var isFirst = i === 0;
|
|
21955
|
+
var isLast = i === numQuasis - 1;
|
|
21956
|
+
var _text = templateElement.value.cooked; // Bail out if any of the quasis have an invalid escape sequence
|
|
21957
|
+
// (which would make the `cooked` value be `null` or `undefined`)
|
|
21958
|
+
|
|
21959
|
+
if (typeof _text !== "string") {
|
|
21960
|
+
return null;
|
|
21961
|
+
}
|
|
21962
|
+
|
|
21963
|
+
var lines = _text.split("\n");
|
|
21964
|
+
|
|
21965
|
+
var numLines = lines.length;
|
|
21966
|
+
var expressionDoc = expressionDocs[i];
|
|
21967
|
+
var startsWithBlankLine = numLines > 2 && lines[0].trim() === "" && lines[1].trim() === "";
|
|
21968
|
+
var endsWithBlankLine = numLines > 2 && lines[numLines - 1].trim() === "" && lines[numLines - 2].trim() === "";
|
|
21969
|
+
var commentsAndWhitespaceOnly = lines.every(function (line) {
|
|
21970
|
+
return /^\s*(?:#[^\r\n]*)?$/.test(line);
|
|
21971
|
+
}); // Bail out if an interpolation occurs within a comment.
|
|
21972
|
+
|
|
21973
|
+
if (!isLast && /#[^\r\n]*$/.test(lines[numLines - 1])) {
|
|
21974
|
+
return null;
|
|
21975
|
+
}
|
|
21976
|
+
|
|
21977
|
+
var _doc = null;
|
|
21978
|
+
|
|
21979
|
+
if (commentsAndWhitespaceOnly) {
|
|
21980
|
+
_doc = printGraphqlComments(lines);
|
|
21981
|
+
} else {
|
|
21982
|
+
_doc = stripTrailingHardline$1(textToDoc(_text, {
|
|
21983
|
+
parser: "graphql"
|
|
21984
|
+
}));
|
|
21985
|
+
}
|
|
21986
|
+
|
|
21987
|
+
if (_doc) {
|
|
21988
|
+
_doc = escapeTemplateCharacters(_doc, false);
|
|
21989
|
+
|
|
21990
|
+
if (!isFirst && startsWithBlankLine) {
|
|
21991
|
+
parts.push("");
|
|
21992
|
+
}
|
|
21993
|
+
|
|
21994
|
+
parts.push(_doc);
|
|
21995
|
+
|
|
21996
|
+
if (!isLast && endsWithBlankLine) {
|
|
21997
|
+
parts.push("");
|
|
21998
|
+
}
|
|
21999
|
+
} else if (!isFirst && !isLast && startsWithBlankLine) {
|
|
22000
|
+
parts.push("");
|
|
22001
|
+
}
|
|
22002
|
+
|
|
22003
|
+
if (expressionDoc) {
|
|
22004
|
+
parts.push(concat$5(["${", expressionDoc, "}"]));
|
|
22005
|
+
}
|
|
22006
|
+
}
|
|
22007
|
+
|
|
22008
|
+
return concat$5(["`", indent$3(concat$5([hardline$4, join$3(hardline$4, parts)])), hardline$4, "`"]);
|
|
22009
|
+
}
|
|
22010
|
+
|
|
22011
|
+
if (isHtml(path$$1)) {
|
|
22012
|
+
return printHtmlTemplateLiteral(path$$1, print, textToDoc, "html");
|
|
22013
|
+
}
|
|
22014
|
+
|
|
22015
|
+
if (isAngularComponentTemplate(path$$1)) {
|
|
22016
|
+
return printHtmlTemplateLiteral(path$$1, print, textToDoc, "angular");
|
|
22017
|
+
}
|
|
22018
|
+
|
|
22019
|
+
break;
|
|
22020
|
+
}
|
|
22021
|
+
|
|
22022
|
+
case "TemplateElement":
|
|
22023
|
+
{
|
|
22024
|
+
/**
|
|
22025
|
+
* md`...`
|
|
22026
|
+
* markdown`...`
|
|
22027
|
+
*/
|
|
22028
|
+
if (parentParent && parentParent.type === "TaggedTemplateExpression" && parent.quasis.length === 1 && parentParent.tag.type === "Identifier" && (parentParent.tag.name === "md" || parentParent.tag.name === "markdown")) {
|
|
22029
|
+
var _text2 = parent.quasis[0].value.raw.replace(/((?:\\\\)*)\\`/g, function (_, backslashes) {
|
|
22030
|
+
return "\\".repeat(backslashes.length / 2) + "`";
|
|
22031
|
+
});
|
|
22032
|
+
|
|
22033
|
+
var indentation = getIndentation(_text2);
|
|
22034
|
+
var hasIndent = indentation !== "";
|
|
22035
|
+
return concat$5([hasIndent ? indent$3(concat$5([softline$2, printMarkdown(_text2.replace(new RegExp(`^${indentation}`, "gm"), ""))])) : concat$5([literalline$2, dedentToRoot$1(printMarkdown(_text2))]), softline$2]);
|
|
22036
|
+
}
|
|
22037
|
+
|
|
22038
|
+
break;
|
|
22039
|
+
}
|
|
22040
|
+
}
|
|
22041
|
+
|
|
22042
|
+
function printMarkdown(text) {
|
|
22043
|
+
var doc$$2 = textToDoc(text, {
|
|
22044
|
+
parser: "markdown",
|
|
22045
|
+
__inJsTemplate: true
|
|
22046
|
+
});
|
|
22047
|
+
return stripTrailingHardline$1(escapeTemplateCharacters(doc$$2, true));
|
|
22048
|
+
}
|
|
22049
|
+
}
|
|
22050
|
+
|
|
22051
|
+
function getIndentation(str) {
|
|
22052
|
+
var firstMatchedIndent = str.match(/^([^\S\n]*)\S/m);
|
|
22053
|
+
return firstMatchedIndent === null ? "" : firstMatchedIndent[1];
|
|
22054
|
+
}
|
|
22055
|
+
|
|
22056
|
+
function escapeTemplateCharacters(doc$$2, raw) {
|
|
22057
|
+
return mapDoc$3(doc$$2, function (currentDoc) {
|
|
22058
|
+
if (!currentDoc.parts) {
|
|
22059
|
+
return currentDoc;
|
|
22060
|
+
}
|
|
22061
|
+
|
|
22062
|
+
var parts = [];
|
|
22063
|
+
currentDoc.parts.forEach(function (part) {
|
|
22064
|
+
if (typeof part === "string") {
|
|
22065
|
+
parts.push(raw ? part.replace(/(\\*)`/g, "$1$1\\`") : part.replace(/([\\`]|\$\{)/g, "\\$1"));
|
|
22066
|
+
} else {
|
|
22067
|
+
parts.push(part);
|
|
22068
|
+
}
|
|
22069
|
+
});
|
|
22070
|
+
return Object.assign({}, currentDoc, {
|
|
22071
|
+
parts
|
|
22072
|
+
});
|
|
22073
|
+
});
|
|
22074
|
+
}
|
|
22075
|
+
|
|
22076
|
+
function transformCssDoc(quasisDoc, path$$1, print) {
|
|
22077
|
+
var parentNode = path$$1.getValue();
|
|
22078
|
+
var isEmpty = parentNode.quasis.length === 1 && !parentNode.quasis[0].value.raw.trim();
|
|
22079
|
+
|
|
22080
|
+
if (isEmpty) {
|
|
22081
|
+
return "``";
|
|
22082
|
+
}
|
|
22083
|
+
|
|
22084
|
+
var expressionDocs = parentNode.expressions ? path$$1.map(print, "expressions") : [];
|
|
22085
|
+
var newDoc = replacePlaceholders(quasisDoc, expressionDocs);
|
|
22086
|
+
/* istanbul ignore if */
|
|
22087
|
+
|
|
22088
|
+
if (!newDoc) {
|
|
22089
|
+
throw new Error("Couldn't insert all the expressions");
|
|
22090
|
+
}
|
|
22091
|
+
|
|
22092
|
+
return concat$5(["`", indent$3(concat$5([hardline$4, stripTrailingHardline$1(newDoc)])), softline$2, "`"]);
|
|
22093
|
+
} // Search all the placeholders in the quasisDoc tree
|
|
22094
|
+
// and replace them with the expression docs one by one
|
|
22095
|
+
// returns a new doc with all the placeholders replaced,
|
|
22096
|
+
// or null if it couldn't replace any expression
|
|
22097
|
+
|
|
22098
|
+
|
|
22099
|
+
function replacePlaceholders(quasisDoc, expressionDocs) {
|
|
22100
|
+
if (!expressionDocs || !expressionDocs.length) {
|
|
22101
|
+
return quasisDoc;
|
|
22102
|
+
}
|
|
22103
|
+
|
|
22104
|
+
var expressions = expressionDocs.slice();
|
|
22105
|
+
var replaceCounter = 0;
|
|
22106
|
+
var newDoc = mapDoc$3(quasisDoc, function (doc$$2) {
|
|
22107
|
+
if (!doc$$2 || !doc$$2.parts || !doc$$2.parts.length) {
|
|
22108
|
+
return doc$$2;
|
|
22109
|
+
}
|
|
22110
|
+
|
|
22111
|
+
var parts = doc$$2.parts;
|
|
22112
|
+
var atIndex = parts.indexOf("@");
|
|
22113
|
+
var placeholderIndex = atIndex + 1;
|
|
22114
|
+
|
|
22115
|
+
if (atIndex > -1 && typeof parts[placeholderIndex] === "string" && parts[placeholderIndex].startsWith("prettier-placeholder")) {
|
|
22116
|
+
// If placeholder is split, join it
|
|
22117
|
+
var at = parts[atIndex];
|
|
22118
|
+
var placeholder = parts[placeholderIndex];
|
|
22119
|
+
var rest = parts.slice(placeholderIndex + 1);
|
|
22120
|
+
parts = parts.slice(0, atIndex).concat([at + placeholder]).concat(rest);
|
|
22121
|
+
}
|
|
22122
|
+
|
|
22123
|
+
var atPlaceholderIndex = parts.findIndex(function (part) {
|
|
22124
|
+
return typeof part === "string" && part.startsWith("@prettier-placeholder");
|
|
22125
|
+
});
|
|
22126
|
+
|
|
22127
|
+
if (atPlaceholderIndex > -1) {
|
|
22128
|
+
var _placeholder = parts[atPlaceholderIndex];
|
|
22129
|
+
|
|
22130
|
+
var _rest = parts.slice(atPlaceholderIndex + 1);
|
|
22131
|
+
|
|
22132
|
+
var placeholderMatch = _placeholder.match(/@prettier-placeholder-(.+)-id([\s\S]*)/);
|
|
22133
|
+
|
|
22134
|
+
var placeholderID = placeholderMatch[1]; // When the expression has a suffix appended, like:
|
|
22135
|
+
// animation: linear ${time}s ease-out;
|
|
22136
|
+
|
|
22137
|
+
var suffix = placeholderMatch[2];
|
|
22138
|
+
var expression = expressions[placeholderID];
|
|
22139
|
+
replaceCounter++;
|
|
22140
|
+
parts = parts.slice(0, atPlaceholderIndex).concat(["${", expression, "}" + suffix]).concat(_rest);
|
|
22141
|
+
}
|
|
22142
|
+
|
|
22143
|
+
return Object.assign({}, doc$$2, {
|
|
22144
|
+
parts: parts
|
|
22145
|
+
});
|
|
22146
|
+
});
|
|
22147
|
+
return expressions.length === replaceCounter ? newDoc : null;
|
|
22148
|
+
}
|
|
22149
|
+
|
|
22150
|
+
function printGraphqlComments(lines) {
|
|
22151
|
+
var parts = [];
|
|
22152
|
+
var seenComment = false;
|
|
22153
|
+
lines.map(function (textLine) {
|
|
22154
|
+
return textLine.trim();
|
|
22155
|
+
}).forEach(function (textLine, i, array) {
|
|
22156
|
+
// Lines are either whitespace only, or a comment (with poential whitespace
|
|
22157
|
+
// around it). Drop whitespace-only lines.
|
|
22158
|
+
if (textLine === "") {
|
|
22159
|
+
return;
|
|
22160
|
+
}
|
|
22161
|
+
|
|
22162
|
+
if (array[i - 1] === "" && seenComment) {
|
|
22163
|
+
// If a non-first comment is preceded by a blank (whitespace only) line,
|
|
22164
|
+
// add in a blank line.
|
|
22165
|
+
parts.push(concat$5([hardline$4, textLine]));
|
|
22166
|
+
} else {
|
|
22167
|
+
parts.push(textLine);
|
|
22168
|
+
}
|
|
22169
|
+
|
|
22170
|
+
seenComment = true;
|
|
22171
|
+
}); // If `lines` was whitespace only, return `null`.
|
|
22172
|
+
|
|
22173
|
+
return parts.length === 0 ? null : join$3(hardline$4, parts);
|
|
22174
|
+
}
|
|
22175
|
+
/**
|
|
22176
|
+
* Template literal in this context:
|
|
22177
|
+
* <style jsx>{`div{color:red}`}</style>
|
|
21504
22178
|
*/
|
|
21505
22179
|
|
|
21506
22180
|
|
|
@@ -21634,8 +22308,8 @@ function hasLanguageComment(node, languageName) {
|
|
|
21634
22308
|
// we will not trim the comment value and we will expect exactly one space on
|
|
21635
22309
|
// either side of the GraphQL string
|
|
21636
22310
|
// Also see ./clean.js
|
|
21637
|
-
return node
|
|
21638
|
-
return comment
|
|
22311
|
+
return hasLeadingComment$1(node, function (comment) {
|
|
22312
|
+
return isBlockComment(comment) && comment.value === ` ${languageName} `;
|
|
21639
22313
|
});
|
|
21640
22314
|
}
|
|
21641
22315
|
|
|
@@ -21715,7 +22389,7 @@ function printHtmlTemplateLiteral(path$$1, print, textToDoc, parser) {
|
|
|
21715
22389
|
return "``";
|
|
21716
22390
|
}
|
|
21717
22391
|
|
|
21718
|
-
var contentDoc = mapDoc$
|
|
22392
|
+
var contentDoc = mapDoc$3(stripTrailingHardline$1(textToDoc(text, {
|
|
21719
22393
|
parser
|
|
21720
22394
|
})), function (doc$$2) {
|
|
21721
22395
|
var placeholderRegex = new RegExp(placeholderPattern, "g");
|
|
@@ -21740,7 +22414,7 @@ function printHtmlTemplateLiteral(path$$1, print, textToDoc, parser) {
|
|
|
21740
22414
|
}
|
|
21741
22415
|
|
|
21742
22416
|
var placeholderIndex = +component;
|
|
21743
|
-
parts.push(concat$5(["${", group$2(
|
|
22417
|
+
parts.push(concat$5(["${", group$2(expressionDocs[placeholderIndex]), "}"]));
|
|
21744
22418
|
}
|
|
21745
22419
|
|
|
21746
22420
|
return concat$5(parts);
|
|
@@ -21790,8 +22464,8 @@ function clean(ast, newObj, parent) {
|
|
|
21790
22464
|
} // (TypeScript) bypass TSParenthesizedType
|
|
21791
22465
|
|
|
21792
22466
|
|
|
21793
|
-
if (ast.type === "TSParenthesizedType"
|
|
21794
|
-
return newObj.typeAnnotation
|
|
22467
|
+
if (ast.type === "TSParenthesizedType") {
|
|
22468
|
+
return newObj.typeAnnotation;
|
|
21795
22469
|
} // We convert <div></div> to <div />
|
|
21796
22470
|
|
|
21797
22471
|
|
|
@@ -22092,484 +22766,6 @@ var pragma = {
|
|
|
22092
22766
|
insertPragma: insertPragma$1
|
|
22093
22767
|
};
|
|
22094
22768
|
|
|
22095
|
-
var addLeadingComment$2 = utilShared.addLeadingComment;
|
|
22096
|
-
var addTrailingComment$2 = utilShared.addTrailingComment;
|
|
22097
|
-
var addDanglingComment$2 = utilShared.addDanglingComment;
|
|
22098
|
-
|
|
22099
|
-
function handleOwnLineComment(comment, text, options, ast, isLastComment) {
|
|
22100
|
-
var precedingNode = comment.precedingNode,
|
|
22101
|
-
enclosingNode = comment.enclosingNode,
|
|
22102
|
-
followingNode = comment.followingNode;
|
|
22103
|
-
|
|
22104
|
-
if (handleLastFunctionArgComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleMemberExpressionComments(enclosingNode, followingNode, comment) || handleIfStatementComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleWhileComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleTryStatementComments(enclosingNode, precedingNode, followingNode, comment) || handleClassComments(enclosingNode, precedingNode, followingNode, comment) || handleImportSpecifierComments(enclosingNode, comment) || handleForComments(enclosingNode, precedingNode, comment) || handleUnionTypeComments(precedingNode, enclosingNode, followingNode, comment) || handleOnlyComments(enclosingNode, ast, comment, isLastComment) || handleImportDeclarationComments(text, enclosingNode, precedingNode, comment, options) || handleAssignmentPatternComments(enclosingNode, comment) || handleMethodNameComments(text, enclosingNode, precedingNode, comment, options)) {
|
|
22105
|
-
return true;
|
|
22106
|
-
}
|
|
22107
|
-
|
|
22108
|
-
return false;
|
|
22109
|
-
}
|
|
22110
|
-
|
|
22111
|
-
function handleEndOfLineComment(comment, text, options, ast, isLastComment) {
|
|
22112
|
-
var precedingNode = comment.precedingNode,
|
|
22113
|
-
enclosingNode = comment.enclosingNode,
|
|
22114
|
-
followingNode = comment.followingNode;
|
|
22115
|
-
|
|
22116
|
-
if (handleLastFunctionArgComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleConditionalExpressionComments(enclosingNode, precedingNode, followingNode, comment, text, options) || handleImportSpecifierComments(enclosingNode, comment) || handleIfStatementComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleWhileComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleTryStatementComments(enclosingNode, precedingNode, followingNode, comment) || handleClassComments(enclosingNode, precedingNode, followingNode, comment) || handleLabeledStatementComments(enclosingNode, comment) || handleCallExpressionComments(precedingNode, enclosingNode, comment) || handlePropertyComments(enclosingNode, comment) || handleOnlyComments(enclosingNode, ast, comment, isLastComment) || handleTypeAliasComments(enclosingNode, followingNode, comment) || handleVariableDeclaratorComments(enclosingNode, followingNode, comment)) {
|
|
22117
|
-
return true;
|
|
22118
|
-
}
|
|
22119
|
-
|
|
22120
|
-
return false;
|
|
22121
|
-
}
|
|
22122
|
-
|
|
22123
|
-
function handleRemainingComment(comment, text, options, ast, isLastComment) {
|
|
22124
|
-
var precedingNode = comment.precedingNode,
|
|
22125
|
-
enclosingNode = comment.enclosingNode,
|
|
22126
|
-
followingNode = comment.followingNode;
|
|
22127
|
-
|
|
22128
|
-
if (handleIfStatementComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleWhileComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleObjectPropertyAssignment(enclosingNode, precedingNode, comment) || handleCommentInEmptyParens(text, enclosingNode, comment, options) || handleMethodNameComments(text, enclosingNode, precedingNode, comment, options) || handleOnlyComments(enclosingNode, ast, comment, isLastComment) || handleCommentAfterArrowParams(text, enclosingNode, comment, options) || handleFunctionNameComments(text, enclosingNode, precedingNode, comment, options) || handleTSMappedTypeComments(text, enclosingNode, precedingNode, followingNode, comment) || handleBreakAndContinueStatementComments(enclosingNode, comment)) {
|
|
22129
|
-
return true;
|
|
22130
|
-
}
|
|
22131
|
-
|
|
22132
|
-
return false;
|
|
22133
|
-
}
|
|
22134
|
-
|
|
22135
|
-
function addBlockStatementFirstComment(node, comment) {
|
|
22136
|
-
var body = node.body.filter(function (n) {
|
|
22137
|
-
return n.type !== "EmptyStatement";
|
|
22138
|
-
});
|
|
22139
|
-
|
|
22140
|
-
if (body.length === 0) {
|
|
22141
|
-
addDanglingComment$2(node, comment);
|
|
22142
|
-
} else {
|
|
22143
|
-
addLeadingComment$2(body[0], comment);
|
|
22144
|
-
}
|
|
22145
|
-
}
|
|
22146
|
-
|
|
22147
|
-
function addBlockOrNotComment(node, comment) {
|
|
22148
|
-
if (node.type === "BlockStatement") {
|
|
22149
|
-
addBlockStatementFirstComment(node, comment);
|
|
22150
|
-
} else {
|
|
22151
|
-
addLeadingComment$2(node, comment);
|
|
22152
|
-
}
|
|
22153
|
-
} // There are often comments before the else clause of if statements like
|
|
22154
|
-
//
|
|
22155
|
-
// if (1) { ... }
|
|
22156
|
-
// // comment
|
|
22157
|
-
// else { ... }
|
|
22158
|
-
//
|
|
22159
|
-
// They are being attached as leading comments of the BlockExpression which
|
|
22160
|
-
// is not well printed. What we want is to instead move the comment inside
|
|
22161
|
-
// of the block and make it leadingComment of the first element of the block
|
|
22162
|
-
// or dangling comment of the block if there is nothing inside
|
|
22163
|
-
//
|
|
22164
|
-
// if (1) { ... }
|
|
22165
|
-
// else {
|
|
22166
|
-
// // comment
|
|
22167
|
-
// ...
|
|
22168
|
-
// }
|
|
22169
|
-
|
|
22170
|
-
|
|
22171
|
-
function handleIfStatementComments(text, precedingNode, enclosingNode, followingNode, comment, options) {
|
|
22172
|
-
if (!enclosingNode || enclosingNode.type !== "IfStatement" || !followingNode) {
|
|
22173
|
-
return false;
|
|
22174
|
-
} // We unfortunately have no way using the AST or location of nodes to know
|
|
22175
|
-
// if the comment is positioned before the condition parenthesis:
|
|
22176
|
-
// if (a /* comment */) {}
|
|
22177
|
-
// The only workaround I found is to look at the next character to see if
|
|
22178
|
-
// it is a ).
|
|
22179
|
-
|
|
22180
|
-
|
|
22181
|
-
var nextCharacter = util$1.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd);
|
|
22182
|
-
|
|
22183
|
-
if (nextCharacter === ")") {
|
|
22184
|
-
addTrailingComment$2(precedingNode, comment);
|
|
22185
|
-
return true;
|
|
22186
|
-
} // Comments before `else`:
|
|
22187
|
-
// - treat as trailing comments of the consequent, if it's a BlockStatement
|
|
22188
|
-
// - treat as a dangling comment otherwise
|
|
22189
|
-
|
|
22190
|
-
|
|
22191
|
-
if (precedingNode === enclosingNode.consequent && followingNode === enclosingNode.alternate) {
|
|
22192
|
-
if (precedingNode.type === "BlockStatement") {
|
|
22193
|
-
addTrailingComment$2(precedingNode, comment);
|
|
22194
|
-
} else {
|
|
22195
|
-
addDanglingComment$2(enclosingNode, comment);
|
|
22196
|
-
}
|
|
22197
|
-
|
|
22198
|
-
return true;
|
|
22199
|
-
}
|
|
22200
|
-
|
|
22201
|
-
if (followingNode.type === "BlockStatement") {
|
|
22202
|
-
addBlockStatementFirstComment(followingNode, comment);
|
|
22203
|
-
return true;
|
|
22204
|
-
}
|
|
22205
|
-
|
|
22206
|
-
if (followingNode.type === "IfStatement") {
|
|
22207
|
-
addBlockOrNotComment(followingNode.consequent, comment);
|
|
22208
|
-
return true;
|
|
22209
|
-
} // For comments positioned after the condition parenthesis in an if statement
|
|
22210
|
-
// before the consequent without brackets on, such as
|
|
22211
|
-
// if (a) /* comment */ true,
|
|
22212
|
-
// we look at the next character to see if the following node
|
|
22213
|
-
// is the consequent for the if statement
|
|
22214
|
-
|
|
22215
|
-
|
|
22216
|
-
if (enclosingNode.consequent === followingNode) {
|
|
22217
|
-
addLeadingComment$2(followingNode, comment);
|
|
22218
|
-
return true;
|
|
22219
|
-
}
|
|
22220
|
-
|
|
22221
|
-
return false;
|
|
22222
|
-
}
|
|
22223
|
-
|
|
22224
|
-
function handleWhileComments(text, precedingNode, enclosingNode, followingNode, comment, options) {
|
|
22225
|
-
if (!enclosingNode || enclosingNode.type !== "WhileStatement" || !followingNode) {
|
|
22226
|
-
return false;
|
|
22227
|
-
} // We unfortunately have no way using the AST or location of nodes to know
|
|
22228
|
-
// if the comment is positioned before the condition parenthesis:
|
|
22229
|
-
// while (a /* comment */) {}
|
|
22230
|
-
// The only workaround I found is to look at the next character to see if
|
|
22231
|
-
// it is a ).
|
|
22232
|
-
|
|
22233
|
-
|
|
22234
|
-
var nextCharacter = util$1.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd);
|
|
22235
|
-
|
|
22236
|
-
if (nextCharacter === ")") {
|
|
22237
|
-
addTrailingComment$2(precedingNode, comment);
|
|
22238
|
-
return true;
|
|
22239
|
-
}
|
|
22240
|
-
|
|
22241
|
-
if (followingNode.type === "BlockStatement") {
|
|
22242
|
-
addBlockStatementFirstComment(followingNode, comment);
|
|
22243
|
-
return true;
|
|
22244
|
-
}
|
|
22245
|
-
|
|
22246
|
-
return false;
|
|
22247
|
-
} // Same as IfStatement but for TryStatement
|
|
22248
|
-
|
|
22249
|
-
|
|
22250
|
-
function handleTryStatementComments(enclosingNode, precedingNode, followingNode, comment) {
|
|
22251
|
-
if (!enclosingNode || enclosingNode.type !== "TryStatement" && enclosingNode.type !== "CatchClause" || !followingNode) {
|
|
22252
|
-
return false;
|
|
22253
|
-
}
|
|
22254
|
-
|
|
22255
|
-
if (enclosingNode.type === "CatchClause" && precedingNode) {
|
|
22256
|
-
addTrailingComment$2(precedingNode, comment);
|
|
22257
|
-
return true;
|
|
22258
|
-
}
|
|
22259
|
-
|
|
22260
|
-
if (followingNode.type === "BlockStatement") {
|
|
22261
|
-
addBlockStatementFirstComment(followingNode, comment);
|
|
22262
|
-
return true;
|
|
22263
|
-
}
|
|
22264
|
-
|
|
22265
|
-
if (followingNode.type === "TryStatement") {
|
|
22266
|
-
addBlockOrNotComment(followingNode.finalizer, comment);
|
|
22267
|
-
return true;
|
|
22268
|
-
}
|
|
22269
|
-
|
|
22270
|
-
if (followingNode.type === "CatchClause") {
|
|
22271
|
-
addBlockOrNotComment(followingNode.body, comment);
|
|
22272
|
-
return true;
|
|
22273
|
-
}
|
|
22274
|
-
|
|
22275
|
-
return false;
|
|
22276
|
-
}
|
|
22277
|
-
|
|
22278
|
-
function handleMemberExpressionComments(enclosingNode, followingNode, comment) {
|
|
22279
|
-
if (enclosingNode && enclosingNode.type === "MemberExpression" && followingNode && followingNode.type === "Identifier") {
|
|
22280
|
-
addLeadingComment$2(enclosingNode, comment);
|
|
22281
|
-
return true;
|
|
22282
|
-
}
|
|
22283
|
-
|
|
22284
|
-
return false;
|
|
22285
|
-
}
|
|
22286
|
-
|
|
22287
|
-
function handleConditionalExpressionComments(enclosingNode, precedingNode, followingNode, comment, text, options) {
|
|
22288
|
-
var isSameLineAsPrecedingNode = precedingNode && !util$1.hasNewlineInRange(text, options.locEnd(precedingNode), options.locStart(comment));
|
|
22289
|
-
|
|
22290
|
-
if ((!precedingNode || !isSameLineAsPrecedingNode) && enclosingNode && enclosingNode.type === "ConditionalExpression" && followingNode) {
|
|
22291
|
-
addLeadingComment$2(followingNode, comment);
|
|
22292
|
-
return true;
|
|
22293
|
-
}
|
|
22294
|
-
|
|
22295
|
-
return false;
|
|
22296
|
-
}
|
|
22297
|
-
|
|
22298
|
-
function handleObjectPropertyAssignment(enclosingNode, precedingNode, comment) {
|
|
22299
|
-
if (enclosingNode && (enclosingNode.type === "ObjectProperty" || enclosingNode.type === "Property") && enclosingNode.shorthand && enclosingNode.key === precedingNode && enclosingNode.value.type === "AssignmentPattern") {
|
|
22300
|
-
addTrailingComment$2(enclosingNode.value.left, comment);
|
|
22301
|
-
return true;
|
|
22302
|
-
}
|
|
22303
|
-
|
|
22304
|
-
return false;
|
|
22305
|
-
}
|
|
22306
|
-
|
|
22307
|
-
function handleClassComments(enclosingNode, precedingNode, followingNode, comment) {
|
|
22308
|
-
if (enclosingNode && (enclosingNode.type === "ClassDeclaration" || enclosingNode.type === "ClassExpression") && enclosingNode.decorators && enclosingNode.decorators.length > 0 && !(followingNode && followingNode.type === "Decorator")) {
|
|
22309
|
-
if (!enclosingNode.decorators || enclosingNode.decorators.length === 0) {
|
|
22310
|
-
addLeadingComment$2(enclosingNode, comment);
|
|
22311
|
-
} else {
|
|
22312
|
-
addTrailingComment$2(enclosingNode.decorators[enclosingNode.decorators.length - 1], comment);
|
|
22313
|
-
}
|
|
22314
|
-
|
|
22315
|
-
return true;
|
|
22316
|
-
}
|
|
22317
|
-
|
|
22318
|
-
return false;
|
|
22319
|
-
}
|
|
22320
|
-
|
|
22321
|
-
function handleMethodNameComments(text, enclosingNode, precedingNode, comment, options) {
|
|
22322
|
-
// This is only needed for estree parsers (flow, typescript) to attach
|
|
22323
|
-
// after a method name:
|
|
22324
|
-
// obj = { fn /*comment*/() {} };
|
|
22325
|
-
if (enclosingNode && precedingNode && (enclosingNode.type === "Property" || enclosingNode.type === "MethodDefinition") && precedingNode.type === "Identifier" && enclosingNode.key === precedingNode && // special Property case: { key: /*comment*/(value) };
|
|
22326
|
-
// comment should be attached to value instead of key
|
|
22327
|
-
util$1.getNextNonSpaceNonCommentCharacter(text, precedingNode, options.locEnd) !== ":") {
|
|
22328
|
-
addTrailingComment$2(precedingNode, comment);
|
|
22329
|
-
return true;
|
|
22330
|
-
} // Print comments between decorators and class methods as a trailing comment
|
|
22331
|
-
// on the decorator node instead of the method node
|
|
22332
|
-
|
|
22333
|
-
|
|
22334
|
-
if (precedingNode && enclosingNode && precedingNode.type === "Decorator" && (enclosingNode.type === "ClassMethod" || enclosingNode.type === "ClassProperty" || enclosingNode.type === "TSAbstractClassProperty" || enclosingNode.type === "TSAbstractMethodDefinition" || enclosingNode.type === "MethodDefinition")) {
|
|
22335
|
-
addTrailingComment$2(precedingNode, comment);
|
|
22336
|
-
return true;
|
|
22337
|
-
}
|
|
22338
|
-
|
|
22339
|
-
return false;
|
|
22340
|
-
}
|
|
22341
|
-
|
|
22342
|
-
function handleFunctionNameComments(text, enclosingNode, precedingNode, comment, options) {
|
|
22343
|
-
if (util$1.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd) !== "(") {
|
|
22344
|
-
return false;
|
|
22345
|
-
}
|
|
22346
|
-
|
|
22347
|
-
if (precedingNode && enclosingNode && (enclosingNode.type === "FunctionDeclaration" || enclosingNode.type === "FunctionExpression" || enclosingNode.type === "ClassMethod" || enclosingNode.type === "MethodDefinition" || enclosingNode.type === "ObjectMethod")) {
|
|
22348
|
-
addTrailingComment$2(precedingNode, comment);
|
|
22349
|
-
return true;
|
|
22350
|
-
}
|
|
22351
|
-
|
|
22352
|
-
return false;
|
|
22353
|
-
}
|
|
22354
|
-
|
|
22355
|
-
function handleCommentAfterArrowParams(text, enclosingNode, comment, options) {
|
|
22356
|
-
if (!(enclosingNode && enclosingNode.type === "ArrowFunctionExpression")) {
|
|
22357
|
-
return false;
|
|
22358
|
-
}
|
|
22359
|
-
|
|
22360
|
-
var index = utilShared.getNextNonSpaceNonCommentCharacterIndex(text, comment, options);
|
|
22361
|
-
|
|
22362
|
-
if (text.substr(index, 2) === "=>") {
|
|
22363
|
-
addDanglingComment$2(enclosingNode, comment);
|
|
22364
|
-
return true;
|
|
22365
|
-
}
|
|
22366
|
-
|
|
22367
|
-
return false;
|
|
22368
|
-
}
|
|
22369
|
-
|
|
22370
|
-
function handleCommentInEmptyParens(text, enclosingNode, comment, options) {
|
|
22371
|
-
if (util$1.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd) !== ")") {
|
|
22372
|
-
return false;
|
|
22373
|
-
} // Only add dangling comments to fix the case when no params are present,
|
|
22374
|
-
// i.e. a function without any argument.
|
|
22375
|
-
|
|
22376
|
-
|
|
22377
|
-
if (enclosingNode && ((enclosingNode.type === "FunctionDeclaration" || enclosingNode.type === "FunctionExpression" || enclosingNode.type === "ArrowFunctionExpression" && (enclosingNode.body.type !== "CallExpression" || enclosingNode.body.arguments.length === 0) || enclosingNode.type === "ClassMethod" || enclosingNode.type === "ObjectMethod") && enclosingNode.params.length === 0 || (enclosingNode.type === "CallExpression" || enclosingNode.type === "NewExpression") && enclosingNode.arguments.length === 0)) {
|
|
22378
|
-
addDanglingComment$2(enclosingNode, comment);
|
|
22379
|
-
return true;
|
|
22380
|
-
}
|
|
22381
|
-
|
|
22382
|
-
if (enclosingNode && enclosingNode.type === "MethodDefinition" && enclosingNode.value.params.length === 0) {
|
|
22383
|
-
addDanglingComment$2(enclosingNode.value, comment);
|
|
22384
|
-
return true;
|
|
22385
|
-
}
|
|
22386
|
-
|
|
22387
|
-
return false;
|
|
22388
|
-
}
|
|
22389
|
-
|
|
22390
|
-
function handleLastFunctionArgComments(text, precedingNode, enclosingNode, followingNode, comment, options) {
|
|
22391
|
-
// Type definitions functions
|
|
22392
|
-
if (precedingNode && precedingNode.type === "FunctionTypeParam" && enclosingNode && enclosingNode.type === "FunctionTypeAnnotation" && followingNode && followingNode.type !== "FunctionTypeParam") {
|
|
22393
|
-
addTrailingComment$2(precedingNode, comment);
|
|
22394
|
-
return true;
|
|
22395
|
-
} // Real functions
|
|
22396
|
-
|
|
22397
|
-
|
|
22398
|
-
if (precedingNode && (precedingNode.type === "Identifier" || precedingNode.type === "AssignmentPattern") && enclosingNode && (enclosingNode.type === "ArrowFunctionExpression" || enclosingNode.type === "FunctionExpression" || enclosingNode.type === "FunctionDeclaration" || enclosingNode.type === "ObjectMethod" || enclosingNode.type === "ClassMethod") && util$1.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd) === ")") {
|
|
22399
|
-
addTrailingComment$2(precedingNode, comment);
|
|
22400
|
-
return true;
|
|
22401
|
-
}
|
|
22402
|
-
|
|
22403
|
-
if (enclosingNode && enclosingNode.type === "FunctionDeclaration" && followingNode && followingNode.type === "BlockStatement") {
|
|
22404
|
-
var functionParamRightParenIndex = function () {
|
|
22405
|
-
if (enclosingNode.params.length !== 0) {
|
|
22406
|
-
return util$1.getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, options.locEnd(util$1.getLast(enclosingNode.params)));
|
|
22407
|
-
}
|
|
22408
|
-
|
|
22409
|
-
var functionParamLeftParenIndex = util$1.getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, options.locEnd(enclosingNode.id));
|
|
22410
|
-
return util$1.getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, functionParamLeftParenIndex + 1);
|
|
22411
|
-
}();
|
|
22412
|
-
|
|
22413
|
-
if (options.locStart(comment) > functionParamRightParenIndex) {
|
|
22414
|
-
addBlockStatementFirstComment(followingNode, comment);
|
|
22415
|
-
return true;
|
|
22416
|
-
}
|
|
22417
|
-
}
|
|
22418
|
-
|
|
22419
|
-
return false;
|
|
22420
|
-
}
|
|
22421
|
-
|
|
22422
|
-
function handleImportSpecifierComments(enclosingNode, comment) {
|
|
22423
|
-
if (enclosingNode && enclosingNode.type === "ImportSpecifier") {
|
|
22424
|
-
addLeadingComment$2(enclosingNode, comment);
|
|
22425
|
-
return true;
|
|
22426
|
-
}
|
|
22427
|
-
|
|
22428
|
-
return false;
|
|
22429
|
-
}
|
|
22430
|
-
|
|
22431
|
-
function handleLabeledStatementComments(enclosingNode, comment) {
|
|
22432
|
-
if (enclosingNode && enclosingNode.type === "LabeledStatement") {
|
|
22433
|
-
addLeadingComment$2(enclosingNode, comment);
|
|
22434
|
-
return true;
|
|
22435
|
-
}
|
|
22436
|
-
|
|
22437
|
-
return false;
|
|
22438
|
-
}
|
|
22439
|
-
|
|
22440
|
-
function handleBreakAndContinueStatementComments(enclosingNode, comment) {
|
|
22441
|
-
if (enclosingNode && (enclosingNode.type === "ContinueStatement" || enclosingNode.type === "BreakStatement") && !enclosingNode.label) {
|
|
22442
|
-
addTrailingComment$2(enclosingNode, comment);
|
|
22443
|
-
return true;
|
|
22444
|
-
}
|
|
22445
|
-
|
|
22446
|
-
return false;
|
|
22447
|
-
}
|
|
22448
|
-
|
|
22449
|
-
function handleCallExpressionComments(precedingNode, enclosingNode, comment) {
|
|
22450
|
-
if (enclosingNode && enclosingNode.type === "CallExpression" && precedingNode && enclosingNode.callee === precedingNode && enclosingNode.arguments.length > 0) {
|
|
22451
|
-
addLeadingComment$2(enclosingNode.arguments[0], comment);
|
|
22452
|
-
return true;
|
|
22453
|
-
}
|
|
22454
|
-
|
|
22455
|
-
return false;
|
|
22456
|
-
}
|
|
22457
|
-
|
|
22458
|
-
function handleUnionTypeComments(precedingNode, enclosingNode, followingNode, comment) {
|
|
22459
|
-
if (enclosingNode && (enclosingNode.type === "UnionTypeAnnotation" || enclosingNode.type === "TSUnionType")) {
|
|
22460
|
-
addTrailingComment$2(precedingNode, comment);
|
|
22461
|
-
return true;
|
|
22462
|
-
}
|
|
22463
|
-
|
|
22464
|
-
return false;
|
|
22465
|
-
}
|
|
22466
|
-
|
|
22467
|
-
function handlePropertyComments(enclosingNode, comment) {
|
|
22468
|
-
if (enclosingNode && (enclosingNode.type === "Property" || enclosingNode.type === "ObjectProperty")) {
|
|
22469
|
-
addLeadingComment$2(enclosingNode, comment);
|
|
22470
|
-
return true;
|
|
22471
|
-
}
|
|
22472
|
-
|
|
22473
|
-
return false;
|
|
22474
|
-
}
|
|
22475
|
-
|
|
22476
|
-
function handleOnlyComments(enclosingNode, ast, comment, isLastComment) {
|
|
22477
|
-
// With Flow the enclosingNode is undefined so use the AST instead.
|
|
22478
|
-
if (ast && ast.body && ast.body.length === 0) {
|
|
22479
|
-
if (isLastComment) {
|
|
22480
|
-
addDanglingComment$2(ast, comment);
|
|
22481
|
-
} else {
|
|
22482
|
-
addLeadingComment$2(ast, comment);
|
|
22483
|
-
}
|
|
22484
|
-
|
|
22485
|
-
return true;
|
|
22486
|
-
} else if (enclosingNode && enclosingNode.type === "Program" && enclosingNode.body.length === 0 && enclosingNode.directives && enclosingNode.directives.length === 0) {
|
|
22487
|
-
if (isLastComment) {
|
|
22488
|
-
addDanglingComment$2(enclosingNode, comment);
|
|
22489
|
-
} else {
|
|
22490
|
-
addLeadingComment$2(enclosingNode, comment);
|
|
22491
|
-
}
|
|
22492
|
-
|
|
22493
|
-
return true;
|
|
22494
|
-
}
|
|
22495
|
-
|
|
22496
|
-
return false;
|
|
22497
|
-
}
|
|
22498
|
-
|
|
22499
|
-
function handleForComments(enclosingNode, precedingNode, comment) {
|
|
22500
|
-
if (enclosingNode && (enclosingNode.type === "ForInStatement" || enclosingNode.type === "ForOfStatement")) {
|
|
22501
|
-
addLeadingComment$2(enclosingNode, comment);
|
|
22502
|
-
return true;
|
|
22503
|
-
}
|
|
22504
|
-
|
|
22505
|
-
return false;
|
|
22506
|
-
}
|
|
22507
|
-
|
|
22508
|
-
function handleImportDeclarationComments(text, enclosingNode, precedingNode, comment, options) {
|
|
22509
|
-
if (precedingNode && precedingNode.type === "ImportSpecifier" && enclosingNode && enclosingNode.type === "ImportDeclaration" && util$1.hasNewline(text, options.locEnd(comment))) {
|
|
22510
|
-
addTrailingComment$2(precedingNode, comment);
|
|
22511
|
-
return true;
|
|
22512
|
-
}
|
|
22513
|
-
|
|
22514
|
-
return false;
|
|
22515
|
-
}
|
|
22516
|
-
|
|
22517
|
-
function handleAssignmentPatternComments(enclosingNode, comment) {
|
|
22518
|
-
if (enclosingNode && enclosingNode.type === "AssignmentPattern") {
|
|
22519
|
-
addLeadingComment$2(enclosingNode, comment);
|
|
22520
|
-
return true;
|
|
22521
|
-
}
|
|
22522
|
-
|
|
22523
|
-
return false;
|
|
22524
|
-
}
|
|
22525
|
-
|
|
22526
|
-
function handleTypeAliasComments(enclosingNode, followingNode, comment) {
|
|
22527
|
-
if (enclosingNode && enclosingNode.type === "TypeAlias") {
|
|
22528
|
-
addLeadingComment$2(enclosingNode, comment);
|
|
22529
|
-
return true;
|
|
22530
|
-
}
|
|
22531
|
-
|
|
22532
|
-
return false;
|
|
22533
|
-
}
|
|
22534
|
-
|
|
22535
|
-
function handleVariableDeclaratorComments(enclosingNode, followingNode, comment) {
|
|
22536
|
-
if (enclosingNode && (enclosingNode.type === "VariableDeclarator" || enclosingNode.type === "AssignmentExpression") && followingNode && (followingNode.type === "ObjectExpression" || followingNode.type === "ArrayExpression" || followingNode.type === "TemplateLiteral" || followingNode.type === "TaggedTemplateExpression")) {
|
|
22537
|
-
addLeadingComment$2(followingNode, comment);
|
|
22538
|
-
return true;
|
|
22539
|
-
}
|
|
22540
|
-
|
|
22541
|
-
return false;
|
|
22542
|
-
}
|
|
22543
|
-
|
|
22544
|
-
function handleTSMappedTypeComments(text, enclosingNode, precedingNode, followingNode, comment) {
|
|
22545
|
-
if (!enclosingNode || enclosingNode.type !== "TSMappedType") {
|
|
22546
|
-
return false;
|
|
22547
|
-
}
|
|
22548
|
-
|
|
22549
|
-
if (followingNode && followingNode.type === "TSTypeParameter" && followingNode.name) {
|
|
22550
|
-
addLeadingComment$2(followingNode.name, comment);
|
|
22551
|
-
return true;
|
|
22552
|
-
}
|
|
22553
|
-
|
|
22554
|
-
if (precedingNode && precedingNode.type === "TSTypeParameter" && precedingNode.constraint) {
|
|
22555
|
-
addTrailingComment$2(precedingNode.constraint, comment);
|
|
22556
|
-
return true;
|
|
22557
|
-
}
|
|
22558
|
-
|
|
22559
|
-
return false;
|
|
22560
|
-
}
|
|
22561
|
-
|
|
22562
|
-
function isBlockComment(comment) {
|
|
22563
|
-
return comment.type === "Block" || comment.type === "CommentBlock";
|
|
22564
|
-
}
|
|
22565
|
-
|
|
22566
|
-
var comments$3 = {
|
|
22567
|
-
handleOwnLineComment,
|
|
22568
|
-
handleEndOfLineComment,
|
|
22569
|
-
handleRemainingComment,
|
|
22570
|
-
isBlockComment
|
|
22571
|
-
};
|
|
22572
|
-
|
|
22573
22769
|
// Flow annotation comments cannot be split across lines. For example:
|
|
22574
22770
|
//
|
|
22575
22771
|
// (this /*
|
|
@@ -22631,9 +22827,62 @@ function hasClosureCompilerTypeCastComment(text, path$$1, locStart, locEnd) {
|
|
|
22631
22827
|
|
|
22632
22828
|
function hasTypeCastComment(node) {
|
|
22633
22829
|
return node.comments && node.comments.some(function (comment) {
|
|
22634
|
-
return comment.leading && comments$3.isBlockComment(comment) && comment.value
|
|
22830
|
+
return comment.leading && comments$3.isBlockComment(comment) && isTypeCastComment(comment.value) && util$1.getNextNonSpaceNonCommentCharacter(text, comment, locEnd) === "(";
|
|
22635
22831
|
});
|
|
22636
22832
|
}
|
|
22833
|
+
|
|
22834
|
+
function isTypeCastComment(comment) {
|
|
22835
|
+
var trimmed = comment.trim();
|
|
22836
|
+
|
|
22837
|
+
if (!/^\*\s*@type\s*\{[^]+\}$/.test(trimmed)) {
|
|
22838
|
+
return false;
|
|
22839
|
+
}
|
|
22840
|
+
|
|
22841
|
+
var isCompletelyClosed = false;
|
|
22842
|
+
var unpairedBracketCount = 0;
|
|
22843
|
+
var _iteratorNormalCompletion = true;
|
|
22844
|
+
var _didIteratorError = false;
|
|
22845
|
+
var _iteratorError = undefined;
|
|
22846
|
+
|
|
22847
|
+
try {
|
|
22848
|
+
for (var _iterator = trimmed[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
22849
|
+
var char = _step.value;
|
|
22850
|
+
|
|
22851
|
+
if (char === "{") {
|
|
22852
|
+
if (isCompletelyClosed) {
|
|
22853
|
+
return false;
|
|
22854
|
+
}
|
|
22855
|
+
|
|
22856
|
+
unpairedBracketCount++;
|
|
22857
|
+
} else if (char === "}") {
|
|
22858
|
+
if (unpairedBracketCount === 0) {
|
|
22859
|
+
return false;
|
|
22860
|
+
}
|
|
22861
|
+
|
|
22862
|
+
unpairedBracketCount--;
|
|
22863
|
+
|
|
22864
|
+
if (unpairedBracketCount === 0) {
|
|
22865
|
+
isCompletelyClosed = true;
|
|
22866
|
+
}
|
|
22867
|
+
}
|
|
22868
|
+
}
|
|
22869
|
+
} catch (err) {
|
|
22870
|
+
_didIteratorError = true;
|
|
22871
|
+
_iteratorError = err;
|
|
22872
|
+
} finally {
|
|
22873
|
+
try {
|
|
22874
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
22875
|
+
_iterator.return();
|
|
22876
|
+
}
|
|
22877
|
+
} finally {
|
|
22878
|
+
if (_didIteratorError) {
|
|
22879
|
+
throw _iteratorError;
|
|
22880
|
+
}
|
|
22881
|
+
}
|
|
22882
|
+
}
|
|
22883
|
+
|
|
22884
|
+
return unpairedBracketCount === 0;
|
|
22885
|
+
}
|
|
22637
22886
|
}
|
|
22638
22887
|
|
|
22639
22888
|
function needsParens(path$$1, options) {
|
|
@@ -22650,6 +22899,11 @@ function needsParens(path$$1, options) {
|
|
|
22650
22899
|
|
|
22651
22900
|
if (path$$1.getValue() !== node) {
|
|
22652
22901
|
return false;
|
|
22902
|
+
} // to avoid unexpected `}}` in HTML interpolations
|
|
22903
|
+
|
|
22904
|
+
|
|
22905
|
+
if (options.__isInHtmlInterpolation && !options.bracketSpacing && endsWithRightBracket(node) && isFollowedByRightBracket(path$$1)) {
|
|
22906
|
+
return true;
|
|
22653
22907
|
} // Only statements don't need parentheses.
|
|
22654
22908
|
|
|
22655
22909
|
|
|
@@ -22685,6 +22939,42 @@ function needsParens(path$$1, options) {
|
|
|
22685
22939
|
return true;
|
|
22686
22940
|
}
|
|
22687
22941
|
|
|
22942
|
+
if (parent.type === "Decorator" && parent.expression === node) {
|
|
22943
|
+
var hasCallExpression = false;
|
|
22944
|
+
var hasMemberExpression = false;
|
|
22945
|
+
var current = node;
|
|
22946
|
+
|
|
22947
|
+
while (current) {
|
|
22948
|
+
switch (current.type) {
|
|
22949
|
+
case "MemberExpression":
|
|
22950
|
+
hasMemberExpression = true;
|
|
22951
|
+
current = current.object;
|
|
22952
|
+
break;
|
|
22953
|
+
|
|
22954
|
+
case "CallExpression":
|
|
22955
|
+
if (
|
|
22956
|
+
/** @(x().y) */
|
|
22957
|
+
hasMemberExpression ||
|
|
22958
|
+
/** @(x().y()) */
|
|
22959
|
+
hasCallExpression) {
|
|
22960
|
+
return true;
|
|
22961
|
+
}
|
|
22962
|
+
|
|
22963
|
+
hasCallExpression = true;
|
|
22964
|
+
current = current.callee;
|
|
22965
|
+
break;
|
|
22966
|
+
|
|
22967
|
+
case "Identifier":
|
|
22968
|
+
return false;
|
|
22969
|
+
|
|
22970
|
+
default:
|
|
22971
|
+
return true;
|
|
22972
|
+
}
|
|
22973
|
+
}
|
|
22974
|
+
|
|
22975
|
+
return true;
|
|
22976
|
+
}
|
|
22977
|
+
|
|
22688
22978
|
if (parent.type === "ArrowFunctionExpression" && parent.body === node && node.type !== "SequenceExpression" && // these have parens added anyway
|
|
22689
22979
|
util$1.startsWithNoLookaheadToken(node,
|
|
22690
22980
|
/* forbidFunctionClassAndDoExpr */
|
|
@@ -22786,7 +23076,7 @@ function needsParens(path$$1, options) {
|
|
|
22786
23076
|
}
|
|
22787
23077
|
// fallthrough
|
|
22788
23078
|
|
|
22789
|
-
case "
|
|
23079
|
+
case "TSTypeAssertion":
|
|
22790
23080
|
case "TSAsExpression":
|
|
22791
23081
|
case "LogicalExpression":
|
|
22792
23082
|
switch (parent.type) {
|
|
@@ -22802,7 +23092,7 @@ function needsParens(path$$1, options) {
|
|
|
22802
23092
|
case "TSAbstractClassDeclaration":
|
|
22803
23093
|
return name === "superClass" && parent.superClass === node;
|
|
22804
23094
|
|
|
22805
|
-
case "
|
|
23095
|
+
case "TSTypeAssertion":
|
|
22806
23096
|
case "TaggedTemplateExpression":
|
|
22807
23097
|
case "UnaryExpression":
|
|
22808
23098
|
case "SpreadElement":
|
|
@@ -22819,15 +23109,12 @@ function needsParens(path$$1, options) {
|
|
|
22819
23109
|
return name === "object" && parent.object === node;
|
|
22820
23110
|
|
|
22821
23111
|
case "AssignmentExpression":
|
|
22822
|
-
return parent.left === node && (node.type === "
|
|
22823
|
-
|
|
22824
|
-
case "Decorator":
|
|
22825
|
-
return parent.expression === node && (node.type === "TSTypeAssertionExpression" || node.type === "TSAsExpression");
|
|
23112
|
+
return parent.left === node && (node.type === "TSTypeAssertion" || node.type === "TSAsExpression");
|
|
22826
23113
|
|
|
22827
23114
|
case "BinaryExpression":
|
|
22828
23115
|
case "LogicalExpression":
|
|
22829
23116
|
{
|
|
22830
|
-
if (!node.operator && node.type !== "
|
|
23117
|
+
if (!node.operator && node.type !== "TSTypeAssertion") {
|
|
22831
23118
|
return true;
|
|
22832
23119
|
}
|
|
22833
23120
|
|
|
@@ -22873,8 +23160,16 @@ function needsParens(path$$1, options) {
|
|
|
22873
23160
|
case "TSParenthesizedType":
|
|
22874
23161
|
{
|
|
22875
23162
|
var grandParent = path$$1.getParentNode(1);
|
|
23163
|
+
/**
|
|
23164
|
+
* const foo = (): (() => void) => (): void => null;
|
|
23165
|
+
* ^ ^
|
|
23166
|
+
*/
|
|
23167
|
+
|
|
23168
|
+
if (getUnparenthesizedNode(node).type === "TSFunctionType" && parent.type === "TSTypeAnnotation" && grandParent.type === "ArrowFunctionExpression" && grandParent.returnType === parent) {
|
|
23169
|
+
return true;
|
|
23170
|
+
}
|
|
22876
23171
|
|
|
22877
|
-
if ((parent.type === "TSTypeParameter" || parent.type === "TypeParameter" || parent.type === "
|
|
23172
|
+
if ((parent.type === "TSTypeParameter" || parent.type === "TypeParameter" || parent.type === "TSTypeAliasDeclaration" || parent.type === "TSTypeAnnotation" || parent.type === "TSParenthesizedType" || parent.type === "TSTypeParameterInstantiation") && grandParent.type !== "TSTypeOperator" && grandParent.type !== "TSOptionalType") {
|
|
22878
23173
|
return false;
|
|
22879
23174
|
} // Delegate to inner TSParenthesizedType
|
|
22880
23175
|
|
|
@@ -23020,7 +23315,7 @@ function needsParens(path$$1, options) {
|
|
|
23020
23315
|
case "ExportDefaultDeclaration":
|
|
23021
23316
|
case "AwaitExpression":
|
|
23022
23317
|
case "JSXSpreadAttribute":
|
|
23023
|
-
case "
|
|
23318
|
+
case "TSTypeAssertion":
|
|
23024
23319
|
case "TypeCastExpression":
|
|
23025
23320
|
case "TSAsExpression":
|
|
23026
23321
|
case "TSNonNullExpression":
|
|
@@ -23076,7 +23371,7 @@ function needsParens(path$$1, options) {
|
|
|
23076
23371
|
case "LogicalExpression":
|
|
23077
23372
|
case "BinaryExpression":
|
|
23078
23373
|
case "AwaitExpression":
|
|
23079
|
-
case "
|
|
23374
|
+
case "TSTypeAssertion":
|
|
23080
23375
|
return true;
|
|
23081
23376
|
|
|
23082
23377
|
case "ConditionalExpression":
|
|
@@ -23130,15 +23425,76 @@ function needsParens(path$$1, options) {
|
|
|
23130
23425
|
}
|
|
23131
23426
|
|
|
23132
23427
|
function isStatement(node) {
|
|
23133
|
-
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 === "TSAbstractClassDeclaration" || 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";
|
|
23428
|
+
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 === "TSAbstractClassDeclaration" || 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";
|
|
23429
|
+
}
|
|
23430
|
+
|
|
23431
|
+
function getUnparenthesizedNode(node) {
|
|
23432
|
+
return node.type === "TSParenthesizedType" ? getUnparenthesizedNode(node.typeAnnotation) : node;
|
|
23433
|
+
}
|
|
23434
|
+
|
|
23435
|
+
function endsWithRightBracket(node) {
|
|
23436
|
+
switch (node.type) {
|
|
23437
|
+
case "ObjectExpression":
|
|
23438
|
+
return true;
|
|
23439
|
+
|
|
23440
|
+
default:
|
|
23441
|
+
return false;
|
|
23442
|
+
}
|
|
23443
|
+
}
|
|
23444
|
+
|
|
23445
|
+
function isFollowedByRightBracket(path$$1) {
|
|
23446
|
+
var node = path$$1.getValue();
|
|
23447
|
+
var parent = path$$1.getParentNode();
|
|
23448
|
+
var name = path$$1.getName();
|
|
23449
|
+
|
|
23450
|
+
switch (parent.type) {
|
|
23451
|
+
case "NGPipeExpression":
|
|
23452
|
+
if (typeof name === "number" && parent.arguments[name] === node && parent.arguments.length - 1 === name) {
|
|
23453
|
+
return path$$1.callParent(isFollowedByRightBracket);
|
|
23454
|
+
}
|
|
23455
|
+
|
|
23456
|
+
break;
|
|
23457
|
+
|
|
23458
|
+
case "ObjectProperty":
|
|
23459
|
+
if (name === "value") {
|
|
23460
|
+
var parentParent = path$$1.getParentNode(1);
|
|
23461
|
+
return parentParent.properties[parentParent.properties.length - 1] === parent;
|
|
23462
|
+
}
|
|
23463
|
+
|
|
23464
|
+
break;
|
|
23465
|
+
|
|
23466
|
+
case "BinaryExpression":
|
|
23467
|
+
case "LogicalExpression":
|
|
23468
|
+
if (name === "right") {
|
|
23469
|
+
return path$$1.callParent(isFollowedByRightBracket);
|
|
23470
|
+
}
|
|
23471
|
+
|
|
23472
|
+
break;
|
|
23473
|
+
|
|
23474
|
+
case "ConditionalExpression":
|
|
23475
|
+
if (name === "alternate") {
|
|
23476
|
+
return path$$1.callParent(isFollowedByRightBracket);
|
|
23477
|
+
}
|
|
23478
|
+
|
|
23479
|
+
break;
|
|
23480
|
+
|
|
23481
|
+
case "UnaryExpression":
|
|
23482
|
+
if (parent.prefix) {
|
|
23483
|
+
return path$$1.callParent(isFollowedByRightBracket);
|
|
23484
|
+
}
|
|
23485
|
+
|
|
23486
|
+
break;
|
|
23487
|
+
}
|
|
23488
|
+
|
|
23489
|
+
return false;
|
|
23134
23490
|
}
|
|
23135
23491
|
|
|
23136
23492
|
var needsParens_1 = needsParens;
|
|
23137
23493
|
|
|
23138
|
-
var _require$$0$builders$
|
|
23139
|
-
var concat$6 = _require$$0$builders$
|
|
23140
|
-
var join$4 = _require$$0$builders$
|
|
23141
|
-
var line$4 = _require$$0$builders$
|
|
23494
|
+
var _require$$0$builders$1 = doc.builders;
|
|
23495
|
+
var concat$6 = _require$$0$builders$1.concat;
|
|
23496
|
+
var join$4 = _require$$0$builders$1.join;
|
|
23497
|
+
var line$4 = _require$$0$builders$1.line;
|
|
23142
23498
|
|
|
23143
23499
|
function printHtmlBinding$1(path$$1, options, print) {
|
|
23144
23500
|
var node = path$$1.getValue();
|
|
@@ -23302,7 +23658,7 @@ function genericPrint(path$$1, options, printPath, args) {
|
|
|
23302
23658
|
var parentExportDecl = getParentExportDeclaration$1(path$$1);
|
|
23303
23659
|
var decorators = [];
|
|
23304
23660
|
|
|
23305
|
-
if (node.type === "ClassMethod" || node.type === "ClassProperty" || node.type === "TSAbstractClassProperty" || node.type === "ClassPrivateProperty" || node.type === "MethodDefinition" || node.type === "TSAbstractMethodDefinition") {// their decorators are handled themselves
|
|
23661
|
+
if (node.type === "ClassMethod" || node.type === "ClassPrivateMethod" || node.type === "ClassProperty" || node.type === "TSAbstractClassProperty" || node.type === "ClassPrivateProperty" || node.type === "MethodDefinition" || node.type === "TSAbstractMethodDefinition") {// their decorators are handled themselves
|
|
23306
23662
|
} else if (node.decorators && node.decorators.length > 0 && // If the parent node is an export declaration and the decorator
|
|
23307
23663
|
// was written before the export, the export will be responsible
|
|
23308
23664
|
// for printing the decorators.
|
|
@@ -23515,9 +23871,9 @@ function printTernaryOperator(path$$1, options, print, operatorOptions) {
|
|
|
23515
23871
|
}
|
|
23516
23872
|
|
|
23517
23873
|
function getTypeScriptMappedTypeModifier(tokenNode, keyword) {
|
|
23518
|
-
if (tokenNode
|
|
23874
|
+
if (tokenNode === "+") {
|
|
23519
23875
|
return "+" + keyword;
|
|
23520
|
-
} else if (tokenNode
|
|
23876
|
+
} else if (tokenNode === "-") {
|
|
23521
23877
|
return "-" + keyword;
|
|
23522
23878
|
}
|
|
23523
23879
|
|
|
@@ -23699,7 +24055,7 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
23699
24055
|
case "AssignmentPattern":
|
|
23700
24056
|
return concat$4([path$$1.call(print, "left"), " = ", path$$1.call(print, "right")]);
|
|
23701
24057
|
|
|
23702
|
-
case "
|
|
24058
|
+
case "TSTypeAssertion":
|
|
23703
24059
|
{
|
|
23704
24060
|
var shouldBreakAfterCast = !(n.expression.type === "ArrayExpression" || n.expression.type === "ObjectExpression");
|
|
23705
24061
|
var castGroup = group$1(concat$4(["<", indent$2(concat$4([softline$1, path$$1.call(print, "typeAnnotation")])), softline$1, ">"]));
|
|
@@ -23758,10 +24114,6 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
23758
24114
|
|
|
23759
24115
|
case "FunctionDeclaration":
|
|
23760
24116
|
case "FunctionExpression":
|
|
23761
|
-
if (isNodeStartingWithDeclare(n, options)) {
|
|
23762
|
-
parts.push("declare ");
|
|
23763
|
-
}
|
|
23764
|
-
|
|
23765
24117
|
parts.push(printFunctionDeclaration(path$$1, print, options));
|
|
23766
24118
|
|
|
23767
24119
|
if (!n.body) {
|
|
@@ -23889,21 +24241,11 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
23889
24241
|
|
|
23890
24242
|
case "ImportNamespaceSpecifier":
|
|
23891
24243
|
parts.push("* as ");
|
|
23892
|
-
|
|
23893
|
-
if (n.local) {
|
|
23894
|
-
parts.push(path$$1.call(print, "local"));
|
|
23895
|
-
} else if (n.id) {
|
|
23896
|
-
parts.push(path$$1.call(print, "id"));
|
|
23897
|
-
}
|
|
23898
|
-
|
|
24244
|
+
parts.push(path$$1.call(print, "local"));
|
|
23899
24245
|
return concat$4(parts);
|
|
23900
24246
|
|
|
23901
24247
|
case "ImportDefaultSpecifier":
|
|
23902
|
-
|
|
23903
|
-
return path$$1.call(print, "local");
|
|
23904
|
-
}
|
|
23905
|
-
|
|
23906
|
-
return path$$1.call(print, "id");
|
|
24248
|
+
return path$$1.call(print, "local");
|
|
23907
24249
|
|
|
23908
24250
|
case "TSExportAssignment":
|
|
23909
24251
|
return concat$4(["export = ", path$$1.call(print, "expression"), semi]);
|
|
@@ -23992,7 +24334,7 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
23992
24334
|
|
|
23993
24335
|
var _parentParent = path$$1.getParentNode(1);
|
|
23994
24336
|
|
|
23995
|
-
if (!hasContent && !hasDirectives && !hasDanglingComments(n) && (_parent3.type === "ArrowFunctionExpression" || _parent3.type === "FunctionExpression" || _parent3.type === "FunctionDeclaration" || _parent3.type === "ObjectMethod" || _parent3.type === "ClassMethod" || _parent3.type === "ForStatement" || _parent3.type === "WhileStatement" || _parent3.type === "DoWhileStatement" || _parent3.type === "DoExpression" || _parent3.type === "CatchClause" && !_parentParent.finalizer || _parent3.type === "TSModuleDeclaration")) {
|
|
24337
|
+
if (!hasContent && !hasDirectives && !hasDanglingComments(n) && (_parent3.type === "ArrowFunctionExpression" || _parent3.type === "FunctionExpression" || _parent3.type === "FunctionDeclaration" || _parent3.type === "ObjectMethod" || _parent3.type === "ClassMethod" || _parent3.type === "ClassPrivateMethod" || _parent3.type === "ForStatement" || _parent3.type === "WhileStatement" || _parent3.type === "DoWhileStatement" || _parent3.type === "DoExpression" || _parent3.type === "CatchClause" && !_parentParent.finalizer || _parent3.type === "TSModuleDeclaration")) {
|
|
23996
24338
|
return "{}";
|
|
23997
24339
|
}
|
|
23998
24340
|
|
|
@@ -24084,8 +24426,8 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
24084
24426
|
|
|
24085
24427
|
parts.push(n.abstract ? "abstract " : "", printTypeScriptModifiers(path$$1, options, print), "interface ", path$$1.call(print, "id"), n.typeParameters ? path$$1.call(print, "typeParameters") : "", " ");
|
|
24086
24428
|
|
|
24087
|
-
if (n.
|
|
24088
|
-
parts.push(group$1(indent$2(concat$4([softline$1, "extends ", (n.
|
|
24429
|
+
if (n.extends && n.extends.length) {
|
|
24430
|
+
parts.push(group$1(indent$2(concat$4([softline$1, "extends ", (n.extends.length === 1 ? identity$1 : indent$2)(join$2(concat$4([",", line$3]), path$$1.map(print, "extends"))), " "]))));
|
|
24089
24431
|
}
|
|
24090
24432
|
|
|
24091
24433
|
parts.push(path$$1.call(print, "body"));
|
|
@@ -24154,7 +24496,7 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
24154
24496
|
var result = concat$4(separatorParts.concat(group$1(prop.printed)));
|
|
24155
24497
|
separatorParts = [separator, line$3];
|
|
24156
24498
|
|
|
24157
|
-
if ((prop.node.type === "TSPropertySignature" || prop.node.type === "TSMethodSignature" || prop.node.type === "
|
|
24499
|
+
if ((prop.node.type === "TSPropertySignature" || prop.node.type === "TSMethodSignature" || prop.node.type === "TSConstructSignatureDeclaration") && hasNodeIgnoreComment$1(prop.node)) {
|
|
24158
24500
|
separatorParts.shift();
|
|
24159
24501
|
}
|
|
24160
24502
|
|
|
@@ -24223,6 +24565,7 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
24223
24565
|
// Babel 6
|
|
24224
24566
|
|
|
24225
24567
|
case "ClassMethod":
|
|
24568
|
+
case "ClassPrivateMethod":
|
|
24226
24569
|
if (n.decorators && n.decorators.length !== 0) {
|
|
24227
24570
|
parts.push(printDecorators(path$$1, options, print));
|
|
24228
24571
|
}
|
|
@@ -24415,8 +24758,20 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
24415
24758
|
return group$1(concat$4(parts));
|
|
24416
24759
|
}
|
|
24417
24760
|
|
|
24761
|
+
case "TSTypeAliasDeclaration":
|
|
24762
|
+
{
|
|
24763
|
+
if (n.declare) {
|
|
24764
|
+
parts.push("declare ");
|
|
24765
|
+
}
|
|
24766
|
+
|
|
24767
|
+
var _printed = printAssignmentRight(n.id, n.typeAnnotation, n.typeAnnotation && path$$1.call(print, "typeAnnotation"), options);
|
|
24768
|
+
|
|
24769
|
+
parts.push("type ", path$$1.call(print, "id"), path$$1.call(print, "typeParameters"), " =", _printed, semi);
|
|
24770
|
+
return group$1(concat$4(parts));
|
|
24771
|
+
}
|
|
24772
|
+
|
|
24418
24773
|
case "VariableDeclarator":
|
|
24419
|
-
return printAssignment(n.id,
|
|
24774
|
+
return printAssignment(n.id, path$$1.call(print, "id"), " =", n.init, n.init && path$$1.call(print, "init"), options);
|
|
24420
24775
|
|
|
24421
24776
|
case "WithStatement":
|
|
24422
24777
|
return group$1(concat$4(["with (", path$$1.call(print, "object"), ")", adjustClause(n.body, path$$1.call(print, "body"))]));
|
|
@@ -24474,7 +24829,7 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
24474
24829
|
case "ForOfStatement":
|
|
24475
24830
|
case "ForAwaitStatement":
|
|
24476
24831
|
{
|
|
24477
|
-
//
|
|
24832
|
+
// Babel 7 removed ForAwaitStatement in favor of ForOfStatement
|
|
24478
24833
|
// with `"await": true`:
|
|
24479
24834
|
// https://github.com/estree/estree/pull/138
|
|
24480
24835
|
var isAwait = n.type === "ForAwaitStatement" || n.await;
|
|
@@ -24797,7 +25152,7 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
24797
25152
|
return concat$4(parts);
|
|
24798
25153
|
|
|
24799
25154
|
case "TSInterfaceHeritage":
|
|
24800
|
-
parts.push(path$$1.call(print, "
|
|
25155
|
+
parts.push(path$$1.call(print, "expression"));
|
|
24801
25156
|
|
|
24802
25157
|
if (n.typeParameters) {
|
|
24803
25158
|
parts.push(path$$1.call(print, "typeParameters"));
|
|
@@ -24841,7 +25196,8 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
24841
25196
|
})) {
|
|
24842
25197
|
var stringifiedExpressions = expressions.map(function (doc$$2) {
|
|
24843
25198
|
return "${" + printDocToString$2(doc$$2, Object.assign({}, options, {
|
|
24844
|
-
printWidth: Infinity
|
|
25199
|
+
printWidth: Infinity,
|
|
25200
|
+
endOfLine: "lf"
|
|
24845
25201
|
})).formatted + "}";
|
|
24846
25202
|
});
|
|
24847
25203
|
var tableBody = [{
|
|
@@ -24911,14 +25267,15 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
24911
25267
|
// expression inside at the beginning of ${ instead of the beginning
|
|
24912
25268
|
// of the `.
|
|
24913
25269
|
var tabWidth = options.tabWidth;
|
|
24914
|
-
var
|
|
24915
|
-
var
|
|
25270
|
+
var quasi = childPath.getValue();
|
|
25271
|
+
var indentSize = getIndentSize$1(quasi.value.raw, tabWidth);
|
|
25272
|
+
var _printed2 = expressions[i];
|
|
24916
25273
|
|
|
24917
25274
|
if (n.expressions[i].comments && n.expressions[i].comments.length || n.expressions[i].type === "MemberExpression" || n.expressions[i].type === "OptionalMemberExpression" || n.expressions[i].type === "ConditionalExpression") {
|
|
24918
|
-
|
|
25275
|
+
_printed2 = concat$4([indent$2(concat$4([softline$1, _printed2])), softline$1]);
|
|
24919
25276
|
}
|
|
24920
25277
|
|
|
24921
|
-
var aligned = addAlignmentToDoc$2(
|
|
25278
|
+
var aligned = indentSize === 0 && quasi.value.raw.endsWith("\n") ? align$1(-Infinity, _printed2) : addAlignmentToDoc$2(_printed2, indentSize, tabWidth);
|
|
24922
25279
|
parts.push(group$1(concat$4(["${", aligned, lineSuffixBoundary$1, "}"])));
|
|
24923
25280
|
}
|
|
24924
25281
|
}, "quasis");
|
|
@@ -24995,13 +25352,12 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
24995
25352
|
case "DeclareClass":
|
|
24996
25353
|
return printFlowDeclaration(path$$1, printClass(path$$1, options, print));
|
|
24997
25354
|
|
|
24998
|
-
case "
|
|
24999
|
-
// For TypeScript the
|
|
25355
|
+
case "TSDeclareFunction":
|
|
25356
|
+
// For TypeScript the TSDeclareFunction node shares the AST
|
|
25000
25357
|
// structure with FunctionDeclaration
|
|
25001
|
-
|
|
25002
|
-
return concat$4(["declare ", printFunctionDeclaration(path$$1, print, options), semi]);
|
|
25003
|
-
}
|
|
25358
|
+
return concat$4([n.declare ? "declare " : "", printFunctionDeclaration(path$$1, print, options), semi]);
|
|
25004
25359
|
|
|
25360
|
+
case "DeclareFunction":
|
|
25005
25361
|
return printFlowDeclaration(path$$1, ["function ", path$$1.call(print, "id"), n.predicate ? " " : "", path$$1.call(print, "predicate"), semi]);
|
|
25006
25362
|
|
|
25007
25363
|
case "DeclareModule":
|
|
@@ -25125,6 +25481,9 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
25125
25481
|
case "InterfaceExtends":
|
|
25126
25482
|
return concat$4([path$$1.call(print, "id"), path$$1.call(print, "typeParameters")]);
|
|
25127
25483
|
|
|
25484
|
+
case "TSClassImplements":
|
|
25485
|
+
return concat$4([path$$1.call(print, "expression"), path$$1.call(print, "typeParameters")]);
|
|
25486
|
+
|
|
25128
25487
|
case "TSIntersectionType":
|
|
25129
25488
|
case "IntersectionTypeAnnotation":
|
|
25130
25489
|
{
|
|
@@ -25163,12 +25522,10 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
25163
25522
|
// | A
|
|
25164
25523
|
// | B
|
|
25165
25524
|
// | C
|
|
25166
|
-
var _parent8 = path$$1.getParentNode();
|
|
25167
|
-
|
|
25168
|
-
var _parentParent3 = path$$1.getParentNode(1); // If there's a leading comment, the parent is doing the indentation
|
|
25525
|
+
var _parent8 = path$$1.getParentNode(); // If there's a leading comment, the parent is doing the indentation
|
|
25169
25526
|
|
|
25170
25527
|
|
|
25171
|
-
var shouldIndent = _parent8.type !== "TypeParameterInstantiation" && _parent8.type !== "TSTypeParameterInstantiation" && _parent8.type !== "GenericTypeAnnotation" && _parent8.type !== "TSTypeReference" && !(_parent8.type === "FunctionTypeParam" && !_parent8.name) &&
|
|
25528
|
+
var shouldIndent = _parent8.type !== "TypeParameterInstantiation" && _parent8.type !== "TSTypeParameterInstantiation" && _parent8.type !== "GenericTypeAnnotation" && _parent8.type !== "TSTypeReference" && _parent8.type !== "TSTypeAssertion" && !(_parent8.type === "FunctionTypeParam" && !_parent8.name) && !((_parent8.type === "TypeAlias" || _parent8.type === "VariableDeclarator" || _parent8.type === "TSTypeAliasDeclaration") && hasLeadingOwnLineComment(options.originalText, n, options)); // {
|
|
25172
25529
|
// a: string
|
|
25173
25530
|
// } | null | void
|
|
25174
25531
|
// should be inlined and not be printed in the multi-line variant
|
|
@@ -25178,7 +25535,7 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
25178
25535
|
// // comment
|
|
25179
25536
|
// | child2
|
|
25180
25537
|
|
|
25181
|
-
var
|
|
25538
|
+
var _printed3 = path$$1.map(function (typePath) {
|
|
25182
25539
|
var printedType = typePath.call(print);
|
|
25183
25540
|
|
|
25184
25541
|
if (!shouldHug) {
|
|
@@ -25191,11 +25548,11 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
25191
25548
|
}, "types");
|
|
25192
25549
|
|
|
25193
25550
|
if (shouldHug) {
|
|
25194
|
-
return join$2(" | ",
|
|
25551
|
+
return join$2(" | ", _printed3);
|
|
25195
25552
|
}
|
|
25196
25553
|
|
|
25197
25554
|
var shouldAddStartLine = shouldIndent && !hasLeadingOwnLineComment(options.originalText, n, options);
|
|
25198
|
-
var code = concat$4([ifBreak$1(concat$4([shouldAddStartLine ? line$3 : "", "| "])), join$2(concat$4([line$3, "| "]),
|
|
25555
|
+
var code = concat$4([ifBreak$1(concat$4([shouldAddStartLine ? line$3 : "", "| "])), join$2(concat$4([line$3, "| "]), _printed3)]);
|
|
25199
25556
|
var hasParens;
|
|
25200
25557
|
|
|
25201
25558
|
if (n.type === "TSUnionType") {
|
|
@@ -25281,9 +25638,9 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
25281
25638
|
parts.push("declare ");
|
|
25282
25639
|
}
|
|
25283
25640
|
|
|
25284
|
-
var
|
|
25641
|
+
var _printed4 = printAssignmentRight(n.id, n.right, path$$1.call(print, "right"), options);
|
|
25285
25642
|
|
|
25286
|
-
parts.push("type ", path$$1.call(print, "id"), path$$1.call(print, "typeParameters"), " =",
|
|
25643
|
+
parts.push("type ", path$$1.call(print, "id"), path$$1.call(print, "typeParameters"), " =", _printed4, semi);
|
|
25287
25644
|
return group$1(concat$4(parts));
|
|
25288
25645
|
}
|
|
25289
25646
|
|
|
@@ -25296,7 +25653,7 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
25296
25653
|
// a type annotation comment.
|
|
25297
25654
|
//
|
|
25298
25655
|
// Note that we're able to use the normal whitespace regex here because the Flow parser has
|
|
25299
|
-
// already deemed this AST node to be a type cast. Only the
|
|
25656
|
+
// already deemed this AST node to be a type cast. Only the Babel parser needs the
|
|
25300
25657
|
// non-line-break whitespace regex, which is why hasFlowShorthandAnnotationComment() is
|
|
25301
25658
|
// implemented differently.
|
|
25302
25659
|
|
|
@@ -25527,7 +25884,7 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
25527
25884
|
{
|
|
25528
25885
|
var _parent10 = path$$1.getParentNode();
|
|
25529
25886
|
|
|
25530
|
-
return concat$4([n.export ? "export " : "", n.accessibility ? concat$4([n.accessibility, " "]) : "", n.static ? "static " : "", n.readonly ? "readonly " : "", "[", path$$1.
|
|
25887
|
+
return concat$4([n.export ? "export " : "", n.accessibility ? concat$4([n.accessibility, " "]) : "", n.static ? "static " : "", n.readonly ? "readonly " : "", "[", n.parameters ? concat$4(path$$1.map(print, "parameters")) : "", "]: ", path$$1.call(print, "typeAnnotation"), _parent10.type === "ClassBody" ? semi : ""]);
|
|
25531
25888
|
}
|
|
25532
25889
|
|
|
25533
25890
|
case "TSTypePredicate":
|
|
@@ -25548,11 +25905,11 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
25548
25905
|
case "TSIndexedAccessType":
|
|
25549
25906
|
return concat$4([path$$1.call(print, "objectType"), "[", path$$1.call(print, "indexType"), "]"]);
|
|
25550
25907
|
|
|
25551
|
-
case "
|
|
25908
|
+
case "TSConstructSignatureDeclaration":
|
|
25909
|
+
case "TSCallSignatureDeclaration":
|
|
25552
25910
|
case "TSConstructorType":
|
|
25553
|
-
case "TSCallSignature":
|
|
25554
25911
|
{
|
|
25555
|
-
if (n.type !== "
|
|
25912
|
+
if (n.type !== "TSCallSignatureDeclaration") {
|
|
25556
25913
|
parts.push("new ");
|
|
25557
25914
|
}
|
|
25558
25915
|
|
|
@@ -25562,9 +25919,9 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
25562
25919
|
/* printTypeParams */
|
|
25563
25920
|
true)));
|
|
25564
25921
|
|
|
25565
|
-
if (n.
|
|
25922
|
+
if (n.returnType) {
|
|
25566
25923
|
var isType = n.type === "TSConstructorType";
|
|
25567
|
-
parts.push(isType ? " => " : ": ", path$$1.call(print, "
|
|
25924
|
+
parts.push(isType ? " => " : ": ", path$$1.call(print, "returnType"));
|
|
25568
25925
|
}
|
|
25569
25926
|
|
|
25570
25927
|
return concat$4(parts);
|
|
@@ -25574,7 +25931,7 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
25574
25931
|
return concat$4([n.operator, " ", path$$1.call(print, "typeAnnotation")]);
|
|
25575
25932
|
|
|
25576
25933
|
case "TSMappedType":
|
|
25577
|
-
return group$1(concat$4(["{", indent$2(concat$4([options.bracketSpacing ? line$3 : softline$1, n.
|
|
25934
|
+
return group$1(concat$4(["{", indent$2(concat$4([options.bracketSpacing ? line$3 : softline$1, n.readonly ? concat$4([getTypeScriptMappedTypeModifier(n.readonly, "readonly"), " "]) : "", printTypeScriptModifiers(path$$1, options, print), path$$1.call(print, "typeParameter"), n.optional ? getTypeScriptMappedTypeModifier(n.optional, "?") : "", ": ", path$$1.call(print, "typeAnnotation")])), comments.printDanglingComments(path$$1, options,
|
|
25578
25935
|
/* sameIndent */
|
|
25579
25936
|
true), options.bracketSpacing ? line$3 : softline$1, "}"]));
|
|
25580
25937
|
|
|
@@ -25585,14 +25942,14 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
25585
25942
|
/* printTypeParams */
|
|
25586
25943
|
true));
|
|
25587
25944
|
|
|
25588
|
-
if (n.
|
|
25589
|
-
parts.push(": ", path$$1.call(print, "
|
|
25945
|
+
if (n.returnType) {
|
|
25946
|
+
parts.push(": ", path$$1.call(print, "returnType"));
|
|
25590
25947
|
}
|
|
25591
25948
|
|
|
25592
25949
|
return group$1(concat$4(parts));
|
|
25593
25950
|
|
|
25594
25951
|
case "TSNamespaceExportDeclaration":
|
|
25595
|
-
parts.push("export as namespace ", path$$1.call(print, "
|
|
25952
|
+
parts.push("export as namespace ", path$$1.call(print, "id"));
|
|
25596
25953
|
|
|
25597
25954
|
if (options.semi) {
|
|
25598
25955
|
parts.push(";");
|
|
@@ -25635,7 +25992,11 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
25635
25992
|
return concat$4(parts);
|
|
25636
25993
|
|
|
25637
25994
|
case "TSImportEqualsDeclaration":
|
|
25638
|
-
|
|
25995
|
+
if (n.isExport) {
|
|
25996
|
+
parts.push("export ");
|
|
25997
|
+
}
|
|
25998
|
+
|
|
25999
|
+
parts.push("import ", path$$1.call(print, "id"), " = ", path$$1.call(print, "moduleReference"));
|
|
25639
26000
|
|
|
25640
26001
|
if (options.semi) {
|
|
25641
26002
|
parts.push(";");
|
|
@@ -25874,7 +26235,7 @@ function printMethod(path$$1, options, print) {
|
|
|
25874
26235
|
var kind = node.kind;
|
|
25875
26236
|
var parts = [];
|
|
25876
26237
|
|
|
25877
|
-
if (node.type === "ObjectMethod" || node.type === "ClassMethod") {
|
|
26238
|
+
if (node.type === "ObjectMethod" || node.type === "ClassMethod" || node.type === "ClassPrivateMethod") {
|
|
25878
26239
|
node.value = node;
|
|
25879
26240
|
}
|
|
25880
26241
|
|
|
@@ -25911,7 +26272,7 @@ function printMethod(path$$1, options, print) {
|
|
|
25911
26272
|
}
|
|
25912
26273
|
|
|
25913
26274
|
function couldGroupArg(arg) {
|
|
25914
|
-
return arg.type === "ObjectExpression" && (arg.properties.length > 0 || arg.comments) || arg.type === "ArrayExpression" && (arg.elements.length > 0 || arg.comments) || arg.type === "
|
|
26275
|
+
return arg.type === "ObjectExpression" && (arg.properties.length > 0 || arg.comments) || arg.type === "ArrayExpression" && (arg.elements.length > 0 || arg.comments) || arg.type === "TSTypeAssertion" || arg.type === "TSAsExpression" || arg.type === "FunctionExpression" || arg.type === "ArrowFunctionExpression" && !arg.returnType && (arg.body.type === "BlockStatement" || arg.body.type === "ArrowFunctionExpression" || arg.body.type === "ObjectExpression" || arg.body.type === "ArrayExpression" || arg.body.type === "CallExpression" || arg.body.type === "OptionalCallExpression" || arg.body.type === "ConditionalExpression" || isJSXNode(arg.body));
|
|
25915
26276
|
}
|
|
25916
26277
|
|
|
25917
26278
|
function shouldGroupLastArg(args) {
|
|
@@ -25949,13 +26310,15 @@ var functionCompositionFunctionNames = new Set(["pipe", // RxJS, Ramda
|
|
|
25949
26310
|
"connect", // Redux
|
|
25950
26311
|
"createSelector" // Reselect
|
|
25951
26312
|
]);
|
|
26313
|
+
var ordinaryMethodNames = new Set(["connect" // GObject, MongoDB
|
|
26314
|
+
]);
|
|
25952
26315
|
|
|
25953
26316
|
function isFunctionCompositionFunction(node) {
|
|
25954
26317
|
switch (node.type) {
|
|
25955
26318
|
case "OptionalMemberExpression":
|
|
25956
26319
|
case "MemberExpression":
|
|
25957
26320
|
{
|
|
25958
|
-
return isFunctionCompositionFunction(node.property);
|
|
26321
|
+
return isFunctionCompositionFunction(node.property) && !ordinaryMethodNames.has(node.property.name);
|
|
25959
26322
|
}
|
|
25960
26323
|
|
|
25961
26324
|
case "Identifier":
|
|
@@ -25979,6 +26342,13 @@ function printArgumentsList(path$$1, options, print) {
|
|
|
25979
26342
|
return concat$4(["(", comments.printDanglingComments(path$$1, options,
|
|
25980
26343
|
/* sameIndent */
|
|
25981
26344
|
true), ")"]);
|
|
26345
|
+
} // useEffect(() => { ... }, [foo, bar, baz])
|
|
26346
|
+
|
|
26347
|
+
|
|
26348
|
+
if (args.length === 2 && args[0].type === "ArrowFunctionExpression" && args[0].params.length === 0 && args[0].body.type === "BlockStatement" && args[1].type === "ArrayExpression" && !args.find(function (arg) {
|
|
26349
|
+
return arg.leadingComments || arg.trailingComments;
|
|
26350
|
+
})) {
|
|
26351
|
+
return concat$4(["(", path$$1.call(print, "arguments", 0), ", ", path$$1.call(print, "arguments", 1), ")"]);
|
|
25982
26352
|
}
|
|
25983
26353
|
|
|
25984
26354
|
var anyArgEmptyLine = false;
|
|
@@ -26277,7 +26647,7 @@ function printExportDeclaration(path$$1, options, print) {
|
|
|
26277
26647
|
if (decl.declaration) {
|
|
26278
26648
|
parts.push(path$$1.call(print, "declaration"));
|
|
26279
26649
|
|
|
26280
|
-
if (isDefault && decl.declaration.type !== "ClassDeclaration" && decl.declaration.type !== "FunctionDeclaration" && decl.declaration.type !== "TSAbstractClassDeclaration" && decl.declaration.type !== "TSInterfaceDeclaration" && decl.declaration.type !== "DeclareClass" && decl.declaration.type !== "DeclareFunction") {
|
|
26650
|
+
if (isDefault && decl.declaration.type !== "ClassDeclaration" && decl.declaration.type !== "FunctionDeclaration" && decl.declaration.type !== "TSAbstractClassDeclaration" && decl.declaration.type !== "TSInterfaceDeclaration" && decl.declaration.type !== "DeclareClass" && decl.declaration.type !== "DeclareFunction" && decl.declaration.type !== "TSDeclareFunction") {
|
|
26281
26651
|
parts.push(semi);
|
|
26282
26652
|
}
|
|
26283
26653
|
} else {
|
|
@@ -26331,7 +26701,7 @@ function printFlowDeclaration(path$$1, parts) {
|
|
|
26331
26701
|
function getFlowVariance(path$$1) {
|
|
26332
26702
|
if (!path$$1.variance) {
|
|
26333
26703
|
return null;
|
|
26334
|
-
} //
|
|
26704
|
+
} // Babel 7.0 currently uses variance node type, and flow should
|
|
26335
26705
|
// follow suit soon:
|
|
26336
26706
|
// https://github.com/babel/babel/issues/4722
|
|
26337
26707
|
|
|
@@ -27494,8 +27864,9 @@ function classChildNeedsASIProtection(node) {
|
|
|
27494
27864
|
case "TSAbstractMethodDefinition": // TypeScript
|
|
27495
27865
|
|
|
27496
27866
|
case "ClassMethod":
|
|
27867
|
+
case "ClassPrivateMethod":
|
|
27497
27868
|
{
|
|
27498
|
-
//
|
|
27869
|
+
// Babel
|
|
27499
27870
|
var isAsync = node.value ? node.value.async : node.async;
|
|
27500
27871
|
var isGenerator = node.value ? node.value.generator : node.generator;
|
|
27501
27872
|
|
|
@@ -27838,11 +28209,11 @@ var printerEstree = {
|
|
|
27838
28209
|
}
|
|
27839
28210
|
};
|
|
27840
28211
|
|
|
27841
|
-
var _require$$0$builders$
|
|
27842
|
-
var concat$7 = _require$$0$builders$
|
|
27843
|
-
var hardline$5 = _require$$0$builders$
|
|
27844
|
-
var indent$4 = _require$$0$builders$
|
|
27845
|
-
var join$5 = _require$$0$builders$
|
|
28212
|
+
var _require$$0$builders$2 = doc.builders;
|
|
28213
|
+
var concat$7 = _require$$0$builders$2.concat;
|
|
28214
|
+
var hardline$5 = _require$$0$builders$2.hardline;
|
|
28215
|
+
var indent$4 = _require$$0$builders$2.indent;
|
|
28216
|
+
var join$5 = _require$$0$builders$2.join;
|
|
27846
28217
|
|
|
27847
28218
|
function genericPrint$1(path$$1, options, print) {
|
|
27848
28219
|
var node = path$$1.getValue();
|
|
@@ -28285,9 +28656,9 @@ var json5$1 = Object.freeze({
|
|
|
28285
28656
|
default: json5
|
|
28286
28657
|
});
|
|
28287
28658
|
|
|
28288
|
-
var require$$0$
|
|
28659
|
+
var require$$0$21 = ( javascript$1 && javascript ) || javascript$1;
|
|
28289
28660
|
|
|
28290
|
-
var require$$1$
|
|
28661
|
+
var require$$1$8 = ( jsx$1 && jsx ) || jsx$1;
|
|
28291
28662
|
|
|
28292
28663
|
var require$$2$10 = ( typescript$1 && typescript ) || typescript$1;
|
|
28293
28664
|
|
|
@@ -28297,29 +28668,29 @@ var require$$4$2 = ( jsonWithComments$1 && jsonWithComments ) || jsonWithComment
|
|
|
28297
28668
|
|
|
28298
28669
|
var require$$5$1 = ( json5$1 && json5 ) || json5$1;
|
|
28299
28670
|
|
|
28300
|
-
var languages = [createLanguage(require$$0$
|
|
28671
|
+
var languages = [createLanguage(require$$0$21, {
|
|
28301
28672
|
override: {
|
|
28302
28673
|
since: "0.0.0",
|
|
28303
|
-
parsers: ["
|
|
28674
|
+
parsers: ["babel", "flow"],
|
|
28304
28675
|
vscodeLanguageIds: ["javascript"]
|
|
28305
28676
|
},
|
|
28306
28677
|
extend: {
|
|
28307
28678
|
interpreters: ["nodejs"]
|
|
28308
28679
|
}
|
|
28309
|
-
}), createLanguage(require$$0$
|
|
28680
|
+
}), createLanguage(require$$0$21, {
|
|
28310
28681
|
override: {
|
|
28311
28682
|
name: "Flow",
|
|
28312
28683
|
since: "0.0.0",
|
|
28313
|
-
parsers: ["
|
|
28684
|
+
parsers: ["babel", "flow"],
|
|
28314
28685
|
vscodeLanguageIds: ["javascript"],
|
|
28315
28686
|
aliases: [],
|
|
28316
28687
|
filenames: [],
|
|
28317
28688
|
extensions: [".js.flow"]
|
|
28318
28689
|
}
|
|
28319
|
-
}), createLanguage(require$$1$
|
|
28690
|
+
}), createLanguage(require$$1$8, {
|
|
28320
28691
|
override: {
|
|
28321
28692
|
since: "0.0.0",
|
|
28322
|
-
parsers: ["
|
|
28693
|
+
parsers: ["babel", "flow"],
|
|
28323
28694
|
vscodeLanguageIds: ["javascriptreact"]
|
|
28324
28695
|
}
|
|
28325
28696
|
}), createLanguage(require$$2$10, {
|
|
@@ -28497,12 +28868,12 @@ function cleanCSSStrings(value) {
|
|
|
28497
28868
|
|
|
28498
28869
|
var clean_1$2 = clean$3;
|
|
28499
28870
|
|
|
28500
|
-
var _require$$0$builders$
|
|
28501
|
-
var hardline$7 = _require$$0$builders$
|
|
28502
|
-
var literalline$3 = _require$$0$builders$
|
|
28503
|
-
var concat$9 = _require$$0$builders$
|
|
28504
|
-
var markAsRoot$1 = _require$$0$builders$
|
|
28505
|
-
var mapDoc$
|
|
28871
|
+
var _require$$0$builders$3 = doc.builders;
|
|
28872
|
+
var hardline$7 = _require$$0$builders$3.hardline;
|
|
28873
|
+
var literalline$3 = _require$$0$builders$3.literalline;
|
|
28874
|
+
var concat$9 = _require$$0$builders$3.concat;
|
|
28875
|
+
var markAsRoot$1 = _require$$0$builders$3.markAsRoot;
|
|
28876
|
+
var mapDoc$4 = doc.utils.mapDoc;
|
|
28506
28877
|
|
|
28507
28878
|
function embed$2(path$$1, print, textToDoc
|
|
28508
28879
|
/*, options */
|
|
@@ -28518,7 +28889,7 @@ function embed$2(path$$1, print, textToDoc
|
|
|
28518
28889
|
return null;
|
|
28519
28890
|
|
|
28520
28891
|
function replaceNewlinesWithLiterallines(doc$$2) {
|
|
28521
|
-
return mapDoc$
|
|
28892
|
+
return mapDoc$4(doc$$2, function (currentDoc) {
|
|
28522
28893
|
return typeof currentDoc === "string" && currentDoc.includes("\n") ? concat$9(currentDoc.split(/(\n)/g).map(function (v, i) {
|
|
28523
28894
|
return i % 2 === 0 ? v : literalline$3;
|
|
28524
28895
|
})) : currentDoc;
|
|
@@ -28987,8 +29358,7 @@ function genericPrint$2(path$$1, options, print) {
|
|
|
28987
29358
|
case "css-comment":
|
|
28988
29359
|
{
|
|
28989
29360
|
if (node.raws.content) {
|
|
28990
|
-
return node.raws.content
|
|
28991
|
-
.replace(/^(\/\/[^]+)\r+$/, "$1");
|
|
29361
|
+
return node.raws.content;
|
|
28992
29362
|
}
|
|
28993
29363
|
|
|
28994
29364
|
var text = options.originalText.slice(options.locStart(node), options.locEnd(node));
|
|
@@ -29249,6 +29619,16 @@ function genericPrint$2(path$$1, options, print) {
|
|
|
29249
29619
|
|
|
29250
29620
|
if (iNode.value === "~") {
|
|
29251
29621
|
continue;
|
|
29622
|
+
} // Ignore escape `\`
|
|
29623
|
+
|
|
29624
|
+
|
|
29625
|
+
if (iNode.value && iNode.value.indexOf("\\") !== -1 && iNextNode && iNextNode.type !== "value-comment") {
|
|
29626
|
+
continue;
|
|
29627
|
+
} // Ignore escaped `/`
|
|
29628
|
+
|
|
29629
|
+
|
|
29630
|
+
if (iPrevNode && iPrevNode.value && iPrevNode.value.indexOf("\\") === iPrevNode.value.length - 1 && iNode.type === "value-operator" && iNode.value === "/") {
|
|
29631
|
+
continue;
|
|
29252
29632
|
} // Ignore `\` (i.e. `$variable: \@small;`)
|
|
29253
29633
|
|
|
29254
29634
|
|
|
@@ -29296,16 +29676,11 @@ function genericPrint$2(path$$1, options, print) {
|
|
|
29296
29676
|
|
|
29297
29677
|
if (!(isMultiplicationNode(iNextNode) || isMultiplicationNode(iNode)) && !insideValueFunctionNode(path$$1, "calc") && !isColorAdjusterNode && (isDivisionNode(iNextNode) && !requireSpaceBeforeOperator || isDivisionNode(iNode) && !requireSpaceAfterOperator || isAdditionNode(iNextNode) && !requireSpaceBeforeOperator || isAdditionNode(iNode) && !requireSpaceAfterOperator || isSubtractionNode(iNextNode) || isSubtractionNode(iNode)) && (hasEmptyRawBefore(iNextNode) || isMathOperator && (!iPrevNode || iPrevNode && isMathOperatorNode(iPrevNode)))) {
|
|
29298
29678
|
continue;
|
|
29299
|
-
} //
|
|
29300
|
-
// Add `hardline` after inline comment (i.e. `// comment\n foo: bar;`)
|
|
29679
|
+
} // Add `hardline` after inline comment (i.e. `// comment\n foo: bar;`)
|
|
29301
29680
|
|
|
29302
29681
|
|
|
29303
|
-
|
|
29304
|
-
|
|
29305
|
-
if (iPrevNode && isInlineValueCommentNode(iPrevNode) || isInlineComment || isInlineValueCommentNode(iNextNode)) {
|
|
29306
|
-
if (isInlineComment) {
|
|
29307
|
-
_parts.push(hardline$6);
|
|
29308
|
-
}
|
|
29682
|
+
if (isInlineValueCommentNode(iNode)) {
|
|
29683
|
+
_parts.push(hardline$6);
|
|
29309
29684
|
|
|
29310
29685
|
continue;
|
|
29311
29686
|
} // Handle keywords in SCSS control directive
|
|
@@ -29678,21 +30053,21 @@ var scss$1 = Object.freeze({
|
|
|
29678
30053
|
default: scss
|
|
29679
30054
|
});
|
|
29680
30055
|
|
|
29681
|
-
var require$$0$
|
|
30056
|
+
var require$$0$23 = ( css$3 && css$2 ) || css$3;
|
|
29682
30057
|
|
|
29683
|
-
var require$$1$
|
|
30058
|
+
var require$$1$9 = ( postcss$1 && postcss ) || postcss$1;
|
|
29684
30059
|
|
|
29685
30060
|
var require$$2$11 = ( less$1 && less ) || less$1;
|
|
29686
30061
|
|
|
29687
30062
|
var require$$3$4 = ( scss$1 && scss ) || scss$1;
|
|
29688
30063
|
|
|
29689
|
-
var languages$1 = [createLanguage(require$$0$
|
|
30064
|
+
var languages$1 = [createLanguage(require$$0$23, {
|
|
29690
30065
|
override: {
|
|
29691
30066
|
since: "1.4.0",
|
|
29692
30067
|
parsers: ["css"],
|
|
29693
30068
|
vscodeLanguageIds: ["css"]
|
|
29694
30069
|
}
|
|
29695
|
-
}), createLanguage(require$$1$
|
|
30070
|
+
}), createLanguage(require$$1$9, {
|
|
29696
30071
|
override: {
|
|
29697
30072
|
since: "1.4.0",
|
|
29698
30073
|
parsers: ["css"],
|
|
@@ -29723,15 +30098,15 @@ var languageCss = {
|
|
|
29723
30098
|
printers: printers$1
|
|
29724
30099
|
};
|
|
29725
30100
|
|
|
29726
|
-
var _require$$0$builders$
|
|
29727
|
-
var concat$10 = _require$$0$builders$
|
|
29728
|
-
var join$7 = _require$$0$builders$
|
|
29729
|
-
var softline$4 = _require$$0$builders$
|
|
29730
|
-
var hardline$8 = _require$$0$builders$
|
|
29731
|
-
var line$6 = _require$$0$builders$
|
|
29732
|
-
var group$10 = _require$$0$builders$
|
|
29733
|
-
var indent$6 = _require$$0$builders$
|
|
29734
|
-
var ifBreak$3 = _require$$0$builders$
|
|
30101
|
+
var _require$$0$builders$4 = doc.builders;
|
|
30102
|
+
var concat$10 = _require$$0$builders$4.concat;
|
|
30103
|
+
var join$7 = _require$$0$builders$4.join;
|
|
30104
|
+
var softline$4 = _require$$0$builders$4.softline;
|
|
30105
|
+
var hardline$8 = _require$$0$builders$4.hardline;
|
|
30106
|
+
var line$6 = _require$$0$builders$4.line;
|
|
30107
|
+
var group$10 = _require$$0$builders$4.group;
|
|
30108
|
+
var indent$6 = _require$$0$builders$4.indent;
|
|
30109
|
+
var ifBreak$3 = _require$$0$builders$4.ifBreak; // http://w3c.github.io/html/single-page.html#void-elements
|
|
29735
30110
|
|
|
29736
30111
|
var voidTags = ["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]; // Formatter based on @glimmerjs/syntax's built-in test formatter:
|
|
29737
30112
|
// https://github.com/glimmerjs/glimmer-vm/blob/master/packages/%40glimmer/syntax/lib/generation/print.ts
|
|
@@ -30071,9 +30446,9 @@ var handlebars$1 = Object.freeze({
|
|
|
30071
30446
|
default: handlebars
|
|
30072
30447
|
});
|
|
30073
30448
|
|
|
30074
|
-
var require$$0$
|
|
30449
|
+
var require$$0$24 = ( handlebars$1 && handlebars ) || handlebars$1;
|
|
30075
30450
|
|
|
30076
|
-
var languages$2 = [createLanguage(require$$0$
|
|
30451
|
+
var languages$2 = [createLanguage(require$$0$24, {
|
|
30077
30452
|
override: {
|
|
30078
30453
|
since: null,
|
|
30079
30454
|
// unreleased
|
|
@@ -30102,15 +30477,15 @@ var pragma$4 = {
|
|
|
30102
30477
|
insertPragma: insertPragma$5
|
|
30103
30478
|
};
|
|
30104
30479
|
|
|
30105
|
-
var _require$$0$builders$
|
|
30106
|
-
var concat$11 = _require$$0$builders$
|
|
30107
|
-
var join$8 = _require$$0$builders$
|
|
30108
|
-
var hardline$9 = _require$$0$builders$
|
|
30109
|
-
var line$7 = _require$$0$builders$
|
|
30110
|
-
var softline$5 = _require$$0$builders$
|
|
30111
|
-
var group$12 = _require$$0$builders$
|
|
30112
|
-
var indent$7 = _require$$0$builders$
|
|
30113
|
-
var ifBreak$4 = _require$$0$builders$
|
|
30480
|
+
var _require$$0$builders$5 = doc.builders;
|
|
30481
|
+
var concat$11 = _require$$0$builders$5.concat;
|
|
30482
|
+
var join$8 = _require$$0$builders$5.join;
|
|
30483
|
+
var hardline$9 = _require$$0$builders$5.hardline;
|
|
30484
|
+
var line$7 = _require$$0$builders$5.line;
|
|
30485
|
+
var softline$5 = _require$$0$builders$5.softline;
|
|
30486
|
+
var group$12 = _require$$0$builders$5.group;
|
|
30487
|
+
var indent$7 = _require$$0$builders$5.indent;
|
|
30488
|
+
var ifBreak$4 = _require$$0$builders$5.ifBreak;
|
|
30114
30489
|
var hasIgnoreComment$3 = util$1.hasIgnoreComment;
|
|
30115
30490
|
var isNextLineEmpty$4 = utilShared.isNextLineEmpty;
|
|
30116
30491
|
var insertPragma$4 = pragma$4.insertPragma;
|
|
@@ -30446,9 +30821,9 @@ var graphql$1 = Object.freeze({
|
|
|
30446
30821
|
default: graphql
|
|
30447
30822
|
});
|
|
30448
30823
|
|
|
30449
|
-
var require$$0$
|
|
30824
|
+
var require$$0$25 = ( graphql$1 && graphql ) || graphql$1;
|
|
30450
30825
|
|
|
30451
|
-
var languages$3 = [createLanguage(require$$0$
|
|
30826
|
+
var languages$3 = [createLanguage(require$$0$25, {
|
|
30452
30827
|
override: {
|
|
30453
30828
|
since: "1.5.0",
|
|
30454
30829
|
parsers: ["graphql"],
|
|
@@ -30470,6 +30845,8 @@ var cjkPattern = json$6.cjkPattern;
|
|
|
30470
30845
|
var kPattern = json$6.kPattern;
|
|
30471
30846
|
var punctuationPattern$1 = json$6.punctuationPattern;
|
|
30472
30847
|
var getLast$5 = util$1.getLast;
|
|
30848
|
+
var INLINE_NODE_TYPES$1 = ["liquidNode", "inlineCode", "emphasis", "strong", "delete", "link", "linkReference", "image", "imageReference", "footnote", "footnoteReference", "sentence", "whitespace", "word", "break", "inlineMath"];
|
|
30849
|
+
var INLINE_NODE_WRAPPER_TYPES$1 = INLINE_NODE_TYPES$1.concat(["tableCell", "paragraph", "heading"]);
|
|
30473
30850
|
var kRegex = new RegExp(kPattern);
|
|
30474
30851
|
var punctuationRegex = new RegExp(punctuationPattern$1);
|
|
30475
30852
|
/**
|
|
@@ -30585,7 +30962,7 @@ function getFencedCodeBlockValue$2(node, originalText) {
|
|
|
30585
30962
|
var text = originalText.slice(node.position.start.offset, node.position.end.offset);
|
|
30586
30963
|
var leadingSpaceCount = text.match(/^\s*/)[0].length;
|
|
30587
30964
|
var replaceRegex = new RegExp(`^\\s{0,${leadingSpaceCount}}`);
|
|
30588
|
-
var lineContents = text.
|
|
30965
|
+
var lineContents = text.split("\n");
|
|
30589
30966
|
var markerStyle = text[leadingSpaceCount]; // ` or ~
|
|
30590
30967
|
|
|
30591
30968
|
var marker = text.slice(leadingSpaceCount).match(new RegExp(`^[${markerStyle}]+`))[0]; // https://spec.commonmark.org/0.28/#example-104: Closing fences may be indented by 0-3 spaces
|
|
@@ -30621,15 +30998,17 @@ var utils$8 = {
|
|
|
30621
30998
|
splitText: splitText$1,
|
|
30622
30999
|
punctuationPattern: punctuationPattern$1,
|
|
30623
31000
|
getFencedCodeBlockValue: getFencedCodeBlockValue$2,
|
|
30624
|
-
getOrderedListItemInfo: getOrderedListItemInfo$1
|
|
31001
|
+
getOrderedListItemInfo: getOrderedListItemInfo$1,
|
|
31002
|
+
INLINE_NODE_TYPES: INLINE_NODE_TYPES$1,
|
|
31003
|
+
INLINE_NODE_WRAPPER_TYPES: INLINE_NODE_WRAPPER_TYPES$1
|
|
30625
31004
|
};
|
|
30626
31005
|
|
|
30627
|
-
var _require$$0$builders$
|
|
30628
|
-
var hardline$11 = _require$$0$builders$
|
|
30629
|
-
var literalline$5 = _require$$0$builders$
|
|
30630
|
-
var concat$13 = _require$$0$builders$
|
|
30631
|
-
var markAsRoot$3 = _require$$0$builders$
|
|
30632
|
-
var mapDoc$
|
|
31006
|
+
var _require$$0$builders$7 = doc.builders;
|
|
31007
|
+
var hardline$11 = _require$$0$builders$7.hardline;
|
|
31008
|
+
var literalline$5 = _require$$0$builders$7.literalline;
|
|
31009
|
+
var concat$13 = _require$$0$builders$7.concat;
|
|
31010
|
+
var markAsRoot$3 = _require$$0$builders$7.markAsRoot;
|
|
31011
|
+
var mapDoc$6 = doc.utils.mapDoc;
|
|
30633
31012
|
var getFencedCodeBlockValue$1 = utils$8.getFencedCodeBlockValue;
|
|
30634
31013
|
|
|
30635
31014
|
function embed$4(path$$1, print, textToDoc, options) {
|
|
@@ -30652,7 +31031,7 @@ function embed$4(path$$1, print, textToDoc, options) {
|
|
|
30652
31031
|
}
|
|
30653
31032
|
|
|
30654
31033
|
if (node.type === "yaml") {
|
|
30655
|
-
return markAsRoot$3(concat$13(["---", hardline$11, node.value.trim() ? replaceNewlinesWithLiterallines(textToDoc(node.value, {
|
|
31034
|
+
return markAsRoot$3(concat$13(["---", hardline$11, node.value && node.value.trim() ? replaceNewlinesWithLiterallines(textToDoc(node.value, {
|
|
30656
31035
|
parser: "yaml"
|
|
30657
31036
|
})) : "", "---"]));
|
|
30658
31037
|
} // MDX
|
|
@@ -30661,7 +31040,7 @@ function embed$4(path$$1, print, textToDoc, options) {
|
|
|
30661
31040
|
switch (node.type) {
|
|
30662
31041
|
case "importExport":
|
|
30663
31042
|
return textToDoc(node.value, {
|
|
30664
|
-
parser: "
|
|
31043
|
+
parser: "babel"
|
|
30665
31044
|
});
|
|
30666
31045
|
|
|
30667
31046
|
case "jsx":
|
|
@@ -30690,7 +31069,7 @@ function embed$4(path$$1, print, textToDoc, options) {
|
|
|
30690
31069
|
}
|
|
30691
31070
|
|
|
30692
31071
|
function replaceNewlinesWithLiterallines(doc$$2) {
|
|
30693
|
-
return mapDoc$
|
|
31072
|
+
return mapDoc$6(doc$$2, function (currentDoc) {
|
|
30694
31073
|
return typeof currentDoc === "string" && currentDoc.includes("\n") ? concat$13(currentDoc.split(/(\n)/g).map(function (v, i) {
|
|
30695
31074
|
return i % 2 === 0 ? v : literalline$5;
|
|
30696
31075
|
})) : currentDoc;
|
|
@@ -30707,7 +31086,7 @@ var pragma$6 = createCommonjsModule(function (module) {
|
|
|
30707
31086
|
|
|
30708
31087
|
function startWithPragma(text) {
|
|
30709
31088
|
var pragma = `@(${pragmas.join("|")})`;
|
|
30710
|
-
var regex = new RegExp([`<!--\\s*${pragma}\\s*-->`, `<!--.*\n[\\s\\S]*(^|\n)[^\\S\n]*${pragma}[^\\S\n]*($|\n)[\\s\\S]*\n.*-->`].join("|"), "m");
|
|
31089
|
+
var regex = new RegExp([`<!--\\s*${pragma}\\s*-->`, `<!--.*\r?\n[\\s\\S]*(^|\n)[^\\S\n]*${pragma}[^\\S\n]*($|\n)[\\s\\S]*\n.*-->`].join("|"), "m");
|
|
30711
31090
|
var matched = text.match(regex);
|
|
30712
31091
|
return matched && matched.index === 0;
|
|
30713
31092
|
}
|
|
@@ -30997,29 +31376,30 @@ function markAlignedList(ast, options) {
|
|
|
30997
31376
|
|
|
30998
31377
|
var preprocess_1$2 = preprocess$2;
|
|
30999
31378
|
|
|
31000
|
-
var _require$$0$builders$
|
|
31001
|
-
var concat$12 = _require$$0$builders$
|
|
31002
|
-
var join$9 = _require$$0$builders$
|
|
31003
|
-
var line$8 = _require$$0$builders$
|
|
31004
|
-
var literalline$4 = _require$$0$builders$
|
|
31005
|
-
var markAsRoot$2 = _require$$0$builders$
|
|
31006
|
-
var hardline$10 = _require$$0$builders$
|
|
31007
|
-
var softline$6 = _require$$0$builders$
|
|
31008
|
-
var fill$4 = _require$$0$builders$
|
|
31009
|
-
var align$2 = _require$$0$builders$
|
|
31010
|
-
var indent$8 = _require$$0$builders$
|
|
31011
|
-
var group$13 = _require$$0$builders$
|
|
31012
|
-
var mapDoc$
|
|
31379
|
+
var _require$$0$builders$6 = doc.builders;
|
|
31380
|
+
var concat$12 = _require$$0$builders$6.concat;
|
|
31381
|
+
var join$9 = _require$$0$builders$6.join;
|
|
31382
|
+
var line$8 = _require$$0$builders$6.line;
|
|
31383
|
+
var literalline$4 = _require$$0$builders$6.literalline;
|
|
31384
|
+
var markAsRoot$2 = _require$$0$builders$6.markAsRoot;
|
|
31385
|
+
var hardline$10 = _require$$0$builders$6.hardline;
|
|
31386
|
+
var softline$6 = _require$$0$builders$6.softline;
|
|
31387
|
+
var fill$4 = _require$$0$builders$6.fill;
|
|
31388
|
+
var align$2 = _require$$0$builders$6.align;
|
|
31389
|
+
var indent$8 = _require$$0$builders$6.indent;
|
|
31390
|
+
var group$13 = _require$$0$builders$6.group;
|
|
31391
|
+
var mapDoc$5 = doc.utils.mapDoc;
|
|
31013
31392
|
var printDocToString$3 = doc.printer.printDocToString;
|
|
31014
31393
|
var getFencedCodeBlockValue = utils$8.getFencedCodeBlockValue;
|
|
31015
31394
|
var getOrderedListItemInfo = utils$8.getOrderedListItemInfo;
|
|
31016
31395
|
var splitText = utils$8.splitText;
|
|
31017
31396
|
var punctuationPattern = utils$8.punctuationPattern;
|
|
31397
|
+
var INLINE_NODE_TYPES = utils$8.INLINE_NODE_TYPES;
|
|
31398
|
+
var INLINE_NODE_WRAPPER_TYPES = utils$8.INLINE_NODE_WRAPPER_TYPES;
|
|
31399
|
+
var replaceEndOfLineWith$1 = util$1.replaceEndOfLineWith;
|
|
31018
31400
|
var TRAILING_HARDLINE_NODES = ["importExport"];
|
|
31019
31401
|
var SINGLE_LINE_NODE_TYPES = ["heading", "tableCell", "link"];
|
|
31020
31402
|
var SIBLING_NODE_TYPES = ["listItem", "definition", "footnoteDefinition"];
|
|
31021
|
-
var INLINE_NODE_TYPES = ["liquidNode", "inlineCode", "emphasis", "strong", "delete", "link", "linkReference", "image", "imageReference", "footnote", "footnoteReference", "sentence", "whitespace", "word", "break", "inlineMath"];
|
|
31022
|
-
var INLINE_NODE_WRAPPER_TYPES = INLINE_NODE_TYPES.concat(["tableCell", "paragraph", "heading"]);
|
|
31023
31403
|
|
|
31024
31404
|
function genericPrint$4(path$$1, options, print) {
|
|
31025
31405
|
var node = path$$1.getValue();
|
|
@@ -31126,7 +31506,7 @@ function genericPrint$4(path$$1, options, print) {
|
|
|
31126
31506
|
if (node.isIndented) {
|
|
31127
31507
|
// indented code block
|
|
31128
31508
|
var alignment = " ".repeat(4);
|
|
31129
|
-
return align$2(alignment, concat$12([alignment,
|
|
31509
|
+
return align$2(alignment, concat$12([alignment, concat$12(replaceEndOfLineWith$1(node.value, hardline$10))]));
|
|
31130
31510
|
} // fenced code block
|
|
31131
31511
|
|
|
31132
31512
|
|
|
@@ -31134,7 +31514,7 @@ function genericPrint$4(path$$1, options, print) {
|
|
|
31134
31514
|
|
|
31135
31515
|
var _style2 = styleUnit.repeat(Math.max(3, util$1.getMaxContinuousCount(node.value, styleUnit) + 1));
|
|
31136
31516
|
|
|
31137
|
-
return concat$12([_style2, node.lang || "", hardline$10,
|
|
31517
|
+
return concat$12([_style2, node.lang || "", hardline$10, concat$12(replaceEndOfLineWith$1(getFencedCodeBlockValue(node, options.originalText), hardline$10)), hardline$10, _style2]);
|
|
31138
31518
|
}
|
|
31139
31519
|
|
|
31140
31520
|
case "yaml":
|
|
@@ -31147,7 +31527,7 @@ function genericPrint$4(path$$1, options, print) {
|
|
|
31147
31527
|
|
|
31148
31528
|
var value = _parentNode2.type === "root" && util$1.getLast(_parentNode2.children) === node ? node.value.trimRight() : node.value;
|
|
31149
31529
|
var isHtmlComment = /^<!--[\s\S]*-->$/.test(value);
|
|
31150
|
-
return
|
|
31530
|
+
return concat$12(replaceEndOfLineWith$1(value, isHtmlComment ? hardline$10 : markAsRoot$2(literalline$4)));
|
|
31151
31531
|
}
|
|
31152
31532
|
|
|
31153
31533
|
case "list":
|
|
@@ -31227,7 +31607,7 @@ function genericPrint$4(path$$1, options, print) {
|
|
|
31227
31607
|
return /\s/.test(options.originalText[node.position.start.offset]) ? concat$12([" ", markAsRoot$2(literalline$4)]) : concat$12(["\\", hardline$10]);
|
|
31228
31608
|
|
|
31229
31609
|
case "liquidNode":
|
|
31230
|
-
return
|
|
31610
|
+
return concat$12(replaceEndOfLineWith$1(node.value, hardline$10));
|
|
31231
31611
|
// MDX
|
|
31232
31612
|
|
|
31233
31613
|
case "importExport":
|
|
@@ -31236,7 +31616,7 @@ function genericPrint$4(path$$1, options, print) {
|
|
|
31236
31616
|
// fallback to the original text if multiparser failed
|
|
31237
31617
|
|
|
31238
31618
|
case "math":
|
|
31239
|
-
return concat$12(["$$", hardline$10, node.value ? concat$12([
|
|
31619
|
+
return concat$12(["$$", hardline$10, node.value ? concat$12([concat$12(replaceEndOfLineWith$1(node.value, hardline$10)), hardline$10]) : "", "$$"]);
|
|
31240
31620
|
|
|
31241
31621
|
case "inlineMath":
|
|
31242
31622
|
{
|
|
@@ -31287,10 +31667,6 @@ function getNthListSiblingIndex(node, parentNode) {
|
|
|
31287
31667
|
});
|
|
31288
31668
|
}
|
|
31289
31669
|
|
|
31290
|
-
function replaceNewlinesWith(str, doc$$2) {
|
|
31291
|
-
return join$9(doc$$2, str.replace(/\r\n?/g, "\n").split("\n"));
|
|
31292
|
-
}
|
|
31293
|
-
|
|
31294
31670
|
function getNthSiblingIndex(node, parentNode, condition) {
|
|
31295
31671
|
condition = condition || function () {
|
|
31296
31672
|
return true;
|
|
@@ -31591,7 +31967,7 @@ function shouldRemainTheSameContent(path$$1) {
|
|
|
31591
31967
|
}
|
|
31592
31968
|
|
|
31593
31969
|
function normalizeDoc(doc$$2) {
|
|
31594
|
-
return mapDoc$
|
|
31970
|
+
return mapDoc$5(doc$$2, function (currentDoc) {
|
|
31595
31971
|
if (!currentDoc.parts) {
|
|
31596
31972
|
return currentDoc;
|
|
31597
31973
|
}
|
|
@@ -31754,9 +32130,9 @@ var markdown$1 = Object.freeze({
|
|
|
31754
32130
|
default: markdown
|
|
31755
32131
|
});
|
|
31756
32132
|
|
|
31757
|
-
var require$$0$
|
|
32133
|
+
var require$$0$28 = ( markdown$1 && markdown ) || markdown$1;
|
|
31758
32134
|
|
|
31759
|
-
var languages$4 = [createLanguage(require$$0$
|
|
32135
|
+
var languages$4 = [createLanguage(require$$0$28, {
|
|
31760
32136
|
override: {
|
|
31761
32137
|
since: "1.8.0",
|
|
31762
32138
|
parsers: ["remark"],
|
|
@@ -32059,8 +32435,6 @@ var json$9 = {"CSS_DISPLAY_TAGS":{"area":"none","base":"none","basefont":"none",
|
|
|
32059
32435
|
|
|
32060
32436
|
var htmlElementAttributes$1 = ( htmlElementAttributes && index$13 ) || htmlElementAttributes;
|
|
32061
32437
|
|
|
32062
|
-
var concat$15 = doc.builders.concat;
|
|
32063
|
-
var mapDoc$7 = doc.utils.mapDoc;
|
|
32064
32438
|
var CSS_DISPLAY_TAGS = json$9.CSS_DISPLAY_TAGS;
|
|
32065
32439
|
var CSS_DISPLAY_DEFAULT = json$9.CSS_DISPLAY_DEFAULT;
|
|
32066
32440
|
var CSS_WHITE_SPACE_TAGS = json$9.CSS_WHITE_SPACE_TAGS;
|
|
@@ -32275,18 +32649,6 @@ function isDanglingSpaceSensitiveNode(node) {
|
|
|
32275
32649
|
return isDanglingSpaceSensitiveCssDisplay(node.cssDisplay) && !isScriptLikeTag$1(node);
|
|
32276
32650
|
}
|
|
32277
32651
|
|
|
32278
|
-
function replaceNewlines$1(text, replacement) {
|
|
32279
|
-
return text.split(/(\n)/g).map(function (data, index) {
|
|
32280
|
-
return index % 2 === 1 ? replacement : data;
|
|
32281
|
-
});
|
|
32282
|
-
}
|
|
32283
|
-
|
|
32284
|
-
function replaceDocNewlines$1(doc$$2, replacement) {
|
|
32285
|
-
return mapDoc$7(doc$$2, function (currentDoc) {
|
|
32286
|
-
return typeof currentDoc === "string" && currentDoc.includes("\n") ? concat$15(replaceNewlines$1(currentDoc, replacement)) : currentDoc;
|
|
32287
|
-
});
|
|
32288
|
-
}
|
|
32289
|
-
|
|
32290
32652
|
function forceNextEmptyLine$1(node) {
|
|
32291
32653
|
return isFrontMatterNode(node) || node.next && node.sourceSpan.end.line + 1 < node.next.sourceSpan.start.line;
|
|
32292
32654
|
}
|
|
@@ -32296,7 +32658,7 @@ function forceNextEmptyLine$1(node) {
|
|
|
32296
32658
|
function forceBreakContent$1(node) {
|
|
32297
32659
|
return forceBreakChildren$1(node) || node.type === "element" && node.children.length !== 0 && (["body", "template", "script", "style"].indexOf(node.name) !== -1 || node.children.some(function (child) {
|
|
32298
32660
|
return hasNonTextChild(child);
|
|
32299
|
-
}));
|
|
32661
|
+
})) || node.firstChild && node.firstChild === node.lastChild && hasLeadingLineBreak(node.firstChild) && (!node.lastChild.isTrailingSpaceSensitive || hasTrailingLineBreak(node.lastChild));
|
|
32300
32662
|
}
|
|
32301
32663
|
/** spaces between children */
|
|
32302
32664
|
|
|
@@ -32306,19 +32668,11 @@ function forceBreakChildren$1(node) {
|
|
|
32306
32668
|
}
|
|
32307
32669
|
|
|
32308
32670
|
function preferHardlineAsLeadingSpaces$1(node) {
|
|
32309
|
-
return preferHardlineAsSurroundingSpaces(node) || node.prev && preferHardlineAsTrailingSpaces(node.prev) ||
|
|
32671
|
+
return preferHardlineAsSurroundingSpaces(node) || node.prev && preferHardlineAsTrailingSpaces(node.prev) || hasSurroundingLineBreak(node);
|
|
32310
32672
|
}
|
|
32311
32673
|
|
|
32312
32674
|
function preferHardlineAsTrailingSpaces(node) {
|
|
32313
|
-
return preferHardlineAsSurroundingSpaces(node) || node.type === "element" && node.fullName === "br" ||
|
|
32314
|
-
}
|
|
32315
|
-
|
|
32316
|
-
function isCustomElementWithSurroundingLineBreak(node) {
|
|
32317
|
-
return isCustomElement(node) && hasSurroundingLineBreak(node);
|
|
32318
|
-
}
|
|
32319
|
-
|
|
32320
|
-
function isCustomElement(node) {
|
|
32321
|
-
return node.type === "element" && !node.namespace && (node.name.includes("-") || /[A-Z]/.test(node.name[0]));
|
|
32675
|
+
return preferHardlineAsSurroundingSpaces(node) || node.type === "element" && node.fullName === "br" || hasSurroundingLineBreak(node);
|
|
32322
32676
|
}
|
|
32323
32677
|
|
|
32324
32678
|
function hasSurroundingLineBreak(node) {
|
|
@@ -32360,7 +32714,7 @@ function hasNonTextChild(node) {
|
|
|
32360
32714
|
function inferScriptParser$1(node) {
|
|
32361
32715
|
if (node.name === "script" && !node.attrMap.src) {
|
|
32362
32716
|
if (!node.attrMap.lang && !node.attrMap.type || node.attrMap.type === "module" || node.attrMap.type === "text/javascript" || node.attrMap.type === "text/babel" || node.attrMap.type === "application/javascript") {
|
|
32363
|
-
return "
|
|
32717
|
+
return "babel";
|
|
32364
32718
|
}
|
|
32365
32719
|
|
|
32366
32720
|
if (node.attrMap.type === "application/x-typescript" || node.attrMap.lang === "ts" || node.attrMap.lang === "tsx") {
|
|
@@ -32370,6 +32724,10 @@ function inferScriptParser$1(node) {
|
|
|
32370
32724
|
if (node.attrMap.type === "text/markdown") {
|
|
32371
32725
|
return "markdown";
|
|
32372
32726
|
}
|
|
32727
|
+
|
|
32728
|
+
if (node.attrMap.type === "application/ld+json") {
|
|
32729
|
+
return "json";
|
|
32730
|
+
}
|
|
32373
32731
|
}
|
|
32374
32732
|
|
|
32375
32733
|
if (node.name === "style") {
|
|
@@ -32574,10 +32932,27 @@ function shouldNotPrintClosingTag$1(node, options) {
|
|
|
32574
32932
|
return !node.isSelfClosing && !node.endSourceSpan && (hasPrettierIgnore$3(node) || shouldPreserveContent$1(node.parent, options));
|
|
32575
32933
|
}
|
|
32576
32934
|
|
|
32577
|
-
|
|
32935
|
+
function countChars$1(text, char) {
|
|
32936
|
+
var counter = 0;
|
|
32937
|
+
|
|
32938
|
+
for (var i = 0; i < text.length; i++) {
|
|
32939
|
+
if (text[i] === char) {
|
|
32940
|
+
counter++;
|
|
32941
|
+
}
|
|
32942
|
+
}
|
|
32943
|
+
|
|
32944
|
+
return counter;
|
|
32945
|
+
}
|
|
32946
|
+
|
|
32947
|
+
function unescapeQuoteEntities$1(text) {
|
|
32948
|
+
return text.replace(/'/g, "'").replace(/"/g, '"');
|
|
32949
|
+
}
|
|
32950
|
+
|
|
32951
|
+
var utils$10 = {
|
|
32578
32952
|
HTML_ELEMENT_ATTRIBUTES,
|
|
32579
32953
|
HTML_TAGS,
|
|
32580
32954
|
canHaveInterpolation,
|
|
32955
|
+
countChars: countChars$1,
|
|
32581
32956
|
countParents: countParents$1,
|
|
32582
32957
|
dedentString: dedentString$1,
|
|
32583
32958
|
forceBreakChildren: forceBreakChildren$1,
|
|
@@ -32602,19 +32977,18 @@ var utils_1$3 = {
|
|
|
32602
32977
|
normalizeParts: normalizeParts$2,
|
|
32603
32978
|
preferHardlineAsLeadingSpaces: preferHardlineAsLeadingSpaces$1,
|
|
32604
32979
|
preferHardlineAsTrailingSpaces,
|
|
32605
|
-
replaceDocNewlines: replaceDocNewlines$1,
|
|
32606
|
-
replaceNewlines: replaceNewlines$1,
|
|
32607
32980
|
shouldNotPrintClosingTag: shouldNotPrintClosingTag$1,
|
|
32608
|
-
shouldPreserveContent: shouldPreserveContent$1
|
|
32981
|
+
shouldPreserveContent: shouldPreserveContent$1,
|
|
32982
|
+
unescapeQuoteEntities: unescapeQuoteEntities$1
|
|
32609
32983
|
};
|
|
32610
32984
|
|
|
32611
|
-
var canHaveInterpolation$1 =
|
|
32612
|
-
var getNodeCssStyleDisplay$1 =
|
|
32613
|
-
var isDanglingSpaceSensitiveNode$1 =
|
|
32614
|
-
var isIndentationSensitiveNode$1 =
|
|
32615
|
-
var isLeadingSpaceSensitiveNode$1 =
|
|
32616
|
-
var isTrailingSpaceSensitiveNode$1 =
|
|
32617
|
-
var isWhitespaceSensitiveNode$1 =
|
|
32985
|
+
var canHaveInterpolation$1 = utils$10.canHaveInterpolation;
|
|
32986
|
+
var getNodeCssStyleDisplay$1 = utils$10.getNodeCssStyleDisplay;
|
|
32987
|
+
var isDanglingSpaceSensitiveNode$1 = utils$10.isDanglingSpaceSensitiveNode;
|
|
32988
|
+
var isIndentationSensitiveNode$1 = utils$10.isIndentationSensitiveNode;
|
|
32989
|
+
var isLeadingSpaceSensitiveNode$1 = utils$10.isLeadingSpaceSensitiveNode;
|
|
32990
|
+
var isTrailingSpaceSensitiveNode$1 = utils$10.isTrailingSpaceSensitiveNode;
|
|
32991
|
+
var isWhitespaceSensitiveNode$1 = utils$10.isWhitespaceSensitiveNode;
|
|
32618
32992
|
var PREPROCESS_PIPELINE = [removeIgnorableFirstLf, mergeIeConditonalStartEndCommentIntoElementOpeningTag, mergeCdataIntoText, extractInterpolation, extractWhitespaces, addCssDisplay, addIsSelfClosing, addHasHtmComponentClosingTag, addIsSpaceSensitive, mergeSimpleElementIntoText];
|
|
32619
32993
|
|
|
32620
32994
|
function preprocess$4(ast, options) {
|
|
@@ -33037,9 +33411,9 @@ var pragma$9 = {
|
|
|
33037
33411
|
insertPragma: insertPragma$7
|
|
33038
33412
|
};
|
|
33039
33413
|
|
|
33040
|
-
var _require$$0$builders$
|
|
33041
|
-
var concat$
|
|
33042
|
-
var group$15 = _require$$0$builders$
|
|
33414
|
+
var _require$$0$builders$8 = doc.builders;
|
|
33415
|
+
var concat$15 = _require$$0$builders$8.concat;
|
|
33416
|
+
var group$15 = _require$$0$builders$8.group;
|
|
33043
33417
|
/**
|
|
33044
33418
|
* v-for="... in ..."
|
|
33045
33419
|
* v-for="... of ..."
|
|
@@ -33053,8 +33427,8 @@ function printVueFor$1(value, textToDoc) {
|
|
|
33053
33427
|
operator = _parseVueFor.operator,
|
|
33054
33428
|
right = _parseVueFor.right;
|
|
33055
33429
|
|
|
33056
|
-
return concat$
|
|
33057
|
-
parser: "
|
|
33430
|
+
return concat$15([group$15(textToDoc(`function _(${left}) {}`, {
|
|
33431
|
+
parser: "babel",
|
|
33058
33432
|
__isVueForBindingLeft: true
|
|
33059
33433
|
})), " ", operator, " ", textToDoc(right, {
|
|
33060
33434
|
parser: "__js_expression"
|
|
@@ -33097,7 +33471,7 @@ function parseVueFor(value) {
|
|
|
33097
33471
|
|
|
33098
33472
|
function printVueSlotScope$1(value, textToDoc) {
|
|
33099
33473
|
return textToDoc(`function _(${value}) {}`, {
|
|
33100
|
-
parser: "
|
|
33474
|
+
parser: "babel",
|
|
33101
33475
|
__isVueSlotScope: true
|
|
33102
33476
|
});
|
|
33103
33477
|
}
|
|
@@ -33443,11 +33817,11 @@ var parseSrcset = createCommonjsModule(function (module) {
|
|
|
33443
33817
|
});
|
|
33444
33818
|
});
|
|
33445
33819
|
|
|
33446
|
-
var _require$$0$builders$
|
|
33447
|
-
var concat$
|
|
33448
|
-
var ifBreak$6 = _require$$0$builders$
|
|
33449
|
-
var join$11 = _require$$0$builders$
|
|
33450
|
-
var line$10 = _require$$0$builders$
|
|
33820
|
+
var _require$$0$builders$9 = doc.builders;
|
|
33821
|
+
var concat$16 = _require$$0$builders$9.concat;
|
|
33822
|
+
var ifBreak$6 = _require$$0$builders$9.ifBreak;
|
|
33823
|
+
var join$11 = _require$$0$builders$9.join;
|
|
33824
|
+
var line$10 = _require$$0$builders$9.line;
|
|
33451
33825
|
|
|
33452
33826
|
function printImgSrcset$1(value) {
|
|
33453
33827
|
var srcset = parseSrcset(value, {
|
|
@@ -33495,7 +33869,7 @@ function printImgSrcset$1(value) {
|
|
|
33495
33869
|
return index === -1 ? descriptor.length : index;
|
|
33496
33870
|
});
|
|
33497
33871
|
var maxDescriptorLeftLength = getMax(descriptorLeftLengths);
|
|
33498
|
-
return join$11(concat$
|
|
33872
|
+
return join$11(concat$16([",", line$10]), urls.map(function (url, index) {
|
|
33499
33873
|
var parts = [url];
|
|
33500
33874
|
var descriptor = descriptors[index];
|
|
33501
33875
|
|
|
@@ -33506,7 +33880,7 @@ function printImgSrcset$1(value) {
|
|
|
33506
33880
|
parts.push(ifBreak$6(alignment, " "), descriptor + unit);
|
|
33507
33881
|
}
|
|
33508
33882
|
|
|
33509
|
-
return concat$
|
|
33883
|
+
return concat$16(parts);
|
|
33510
33884
|
}));
|
|
33511
33885
|
}
|
|
33512
33886
|
|
|
@@ -33515,9 +33889,9 @@ var syntaxAttribute = {
|
|
|
33515
33889
|
};
|
|
33516
33890
|
|
|
33517
33891
|
var builders = doc.builders;
|
|
33518
|
-
var _require$$0$utils
|
|
33519
|
-
var stripTrailingHardline$2 = _require$$0$utils
|
|
33520
|
-
var mapDoc$
|
|
33892
|
+
var _require$$0$utils = doc.utils;
|
|
33893
|
+
var stripTrailingHardline$2 = _require$$0$utils.stripTrailingHardline;
|
|
33894
|
+
var mapDoc$7 = _require$$0$utils.mapDoc;
|
|
33521
33895
|
var breakParent$3 = builders.breakParent;
|
|
33522
33896
|
var dedentToRoot$2 = builders.dedentToRoot;
|
|
33523
33897
|
var fill$5 = builders.fill;
|
|
@@ -33530,23 +33904,24 @@ var line$9 = builders.line;
|
|
|
33530
33904
|
var literalline$6 = builders.literalline;
|
|
33531
33905
|
var markAsRoot$4 = builders.markAsRoot;
|
|
33532
33906
|
var softline$7 = builders.softline;
|
|
33533
|
-
var
|
|
33534
|
-
var
|
|
33535
|
-
var
|
|
33536
|
-
var
|
|
33537
|
-
var
|
|
33538
|
-
var
|
|
33539
|
-
var
|
|
33540
|
-
var
|
|
33541
|
-
var
|
|
33542
|
-
var
|
|
33543
|
-
var
|
|
33544
|
-
var
|
|
33545
|
-
var
|
|
33546
|
-
var
|
|
33547
|
-
var
|
|
33548
|
-
var
|
|
33549
|
-
var
|
|
33907
|
+
var countChars = utils$10.countChars;
|
|
33908
|
+
var countParents = utils$10.countParents;
|
|
33909
|
+
var dedentString = utils$10.dedentString;
|
|
33910
|
+
var forceBreakChildren = utils$10.forceBreakChildren;
|
|
33911
|
+
var forceBreakContent = utils$10.forceBreakContent;
|
|
33912
|
+
var forceNextEmptyLine = utils$10.forceNextEmptyLine;
|
|
33913
|
+
var getLastDescendant = utils$10.getLastDescendant;
|
|
33914
|
+
var getPrettierIgnoreAttributeCommentData = utils$10.getPrettierIgnoreAttributeCommentData;
|
|
33915
|
+
var hasPrettierIgnore$2 = utils$10.hasPrettierIgnore;
|
|
33916
|
+
var inferScriptParser = utils$10.inferScriptParser;
|
|
33917
|
+
var isScriptLikeTag = utils$10.isScriptLikeTag;
|
|
33918
|
+
var isTextLikeNode = utils$10.isTextLikeNode;
|
|
33919
|
+
var normalizeParts$1 = utils$10.normalizeParts;
|
|
33920
|
+
var preferHardlineAsLeadingSpaces = utils$10.preferHardlineAsLeadingSpaces;
|
|
33921
|
+
var shouldNotPrintClosingTag = utils$10.shouldNotPrintClosingTag;
|
|
33922
|
+
var shouldPreserveContent = utils$10.shouldPreserveContent;
|
|
33923
|
+
var unescapeQuoteEntities = utils$10.unescapeQuoteEntities;
|
|
33924
|
+
var replaceEndOfLineWith$2 = util$1.replaceEndOfLineWith;
|
|
33550
33925
|
var insertPragma$6 = pragma$9.insertPragma;
|
|
33551
33926
|
var printVueFor = syntaxVue.printVueFor;
|
|
33552
33927
|
var printVueSlotScope = syntaxVue.printVueSlotScope;
|
|
@@ -33574,14 +33949,17 @@ function embed$6(path$$1, print, textToDoc, options) {
|
|
|
33574
33949
|
})), printClosingTagSuffix(node, options)])]);
|
|
33575
33950
|
}
|
|
33576
33951
|
} else if (node.parent.type === "interpolation") {
|
|
33577
|
-
return concat$14([indent$9(concat$14([line$9, textToDoc(node.value,
|
|
33952
|
+
return concat$14([indent$9(concat$14([line$9, textToDoc(node.value, Object.assign({
|
|
33953
|
+
__isInHtmlInterpolation: true // to avoid unexpected `}}`
|
|
33954
|
+
|
|
33955
|
+
}, options.parser === "angular" ? {
|
|
33578
33956
|
parser: "__ng_interpolation",
|
|
33579
33957
|
trailingComma: "none"
|
|
33580
33958
|
} : options.parser === "vue" ? {
|
|
33581
33959
|
parser: "__vue_expression"
|
|
33582
33960
|
} : {
|
|
33583
33961
|
parser: "__js_expression"
|
|
33584
|
-
})])), node.parent.next && needsToBorrowPrevClosingTagEndMarker(node.parent.next) ? " " : line$9]);
|
|
33962
|
+
}))])), node.parent.next && needsToBorrowPrevClosingTagEndMarker(node.parent.next) ? " " : line$9]);
|
|
33585
33963
|
}
|
|
33586
33964
|
|
|
33587
33965
|
break;
|
|
@@ -33607,7 +33985,7 @@ function embed$6(path$$1, print, textToDoc, options) {
|
|
|
33607
33985
|
}, options);
|
|
33608
33986
|
|
|
33609
33987
|
if (embeddedAttributeValueDoc) {
|
|
33610
|
-
return concat$14([node.rawName, '="', group$14(mapDoc$
|
|
33988
|
+
return concat$14([node.rawName, '="', group$14(mapDoc$7(embeddedAttributeValueDoc, function (doc$$2) {
|
|
33611
33989
|
return typeof doc$$2 === "string" ? doc$$2.replace(/"/g, """) : doc$$2;
|
|
33612
33990
|
})), '"']);
|
|
33613
33991
|
}
|
|
@@ -33616,9 +33994,9 @@ function embed$6(path$$1, print, textToDoc, options) {
|
|
|
33616
33994
|
}
|
|
33617
33995
|
|
|
33618
33996
|
case "yaml":
|
|
33619
|
-
return markAsRoot$4(concat$14(["---", hardline$12, node.value.trim().length === 0 ? "" :
|
|
33997
|
+
return markAsRoot$4(concat$14(["---", hardline$12, node.value.trim().length === 0 ? "" : textToDoc(node.value, {
|
|
33620
33998
|
parser: "yaml"
|
|
33621
|
-
}),
|
|
33999
|
+
}), "---"]));
|
|
33622
34000
|
}
|
|
33623
34001
|
}
|
|
33624
34002
|
|
|
@@ -33693,7 +34071,7 @@ function genericPrint$5(path$$1, options, print) {
|
|
|
33693
34071
|
var trailingNewlineRegex = /\n[^\S\n]*?$/;
|
|
33694
34072
|
var hasTrailingNewline = trailingNewlineRegex.test(node.value);
|
|
33695
34073
|
var value = hasTrailingNewline ? node.value.replace(trailingNewlineRegex, "") : node.value;
|
|
33696
|
-
return concat$14([concat$14(
|
|
34074
|
+
return concat$14([concat$14(replaceEndOfLineWith$2(value, literalline$6)), hasTrailingNewline ? hardline$12 : ""]);
|
|
33697
34075
|
}
|
|
33698
34076
|
|
|
33699
34077
|
return fill$5(normalizeParts$1([].concat(printOpeningTagPrefix(node, options), getTextValueParts(node), printClosingTagSuffix(node, options))));
|
|
@@ -33704,15 +34082,26 @@ function genericPrint$5(path$$1, options, print) {
|
|
|
33704
34082
|
|
|
33705
34083
|
case "comment":
|
|
33706
34084
|
{
|
|
33707
|
-
return concat$14([printOpeningTagPrefix(node, options), concat$14(
|
|
34085
|
+
return concat$14([printOpeningTagPrefix(node, options), concat$14(replaceEndOfLineWith$2(options.originalText.slice(options.locStart(node), options.locEnd(node)), literalline$6)), printClosingTagSuffix(node, options)]);
|
|
33708
34086
|
}
|
|
33709
34087
|
|
|
33710
34088
|
case "attribute":
|
|
33711
|
-
|
|
34089
|
+
{
|
|
34090
|
+
if (node.value === null) {
|
|
34091
|
+
return node.rawName;
|
|
34092
|
+
}
|
|
34093
|
+
|
|
34094
|
+
var _value = unescapeQuoteEntities(node.value);
|
|
34095
|
+
|
|
34096
|
+
var singleQuoteCount = countChars(_value, "'");
|
|
34097
|
+
var doubleQuoteCount = countChars(_value, '"');
|
|
34098
|
+
var quote = singleQuoteCount < doubleQuoteCount ? "'" : '"';
|
|
34099
|
+
return concat$14([node.rawName, concat$14(["=", quote, concat$14(replaceEndOfLineWith$2(quote === '"' ? _value.replace(/"/g, """) : _value.replace(/'/g, "'"), literalline$6)), quote])]);
|
|
34100
|
+
}
|
|
33712
34101
|
|
|
33713
34102
|
case "yaml":
|
|
33714
34103
|
case "toml":
|
|
33715
|
-
return node.raw;
|
|
34104
|
+
return concat$14(replaceEndOfLineWith$2(node.raw, literalline$6));
|
|
33716
34105
|
|
|
33717
34106
|
default:
|
|
33718
34107
|
throw new Error(`Unexpected node type ${node.type}`);
|
|
@@ -33798,11 +34187,11 @@ function printChildren$1(path$$1, options, print) {
|
|
|
33798
34187
|
var child = childPath.getValue();
|
|
33799
34188
|
|
|
33800
34189
|
if (hasPrettierIgnore$2(child)) {
|
|
33801
|
-
return concat$14([].concat(printOpeningTagPrefix(child, options),
|
|
34190
|
+
return concat$14([].concat(printOpeningTagPrefix(child, options), replaceEndOfLineWith$2(options.originalText.slice(options.locStart(child) + (child.prev && needsToBorrowNextOpeningTagStartMarker(child.prev) ? printOpeningTagStartMarker(child).length : 0), options.locEnd(child) - (child.next && needsToBorrowPrevClosingTagEndMarker(child.next) ? printClosingTagEndMarker(child, options).length : 0)), literalline$6), printClosingTagSuffix(child, options)));
|
|
33802
34191
|
}
|
|
33803
34192
|
|
|
33804
34193
|
if (shouldPreserveContent(child, options)) {
|
|
33805
|
-
return concat$14([].concat(printOpeningTagPrefix(child, options), group$14(printOpeningTag(childPath, options, print)),
|
|
34194
|
+
return concat$14([].concat(printOpeningTagPrefix(child, options), group$14(printOpeningTag(childPath, options, print)), replaceEndOfLineWith$2(options.originalText.slice(child.startSourceSpan.end.offset + (child.firstChild && needsToBorrowParentOpeningTagEndMarker(child.firstChild) ? -printOpeningTagEndMarker(child).length : 0), child.endSourceSpan.start.offset + (child.lastChild && needsToBorrowParentClosingTagStartMarker(child.lastChild) ? printClosingTagStartMarker(child, options).length : needsToBorrowLastChildClosingTagEndMarker(child) ? -printClosingTagEndMarker(child.lastChild, options).length : 0)), literalline$6), printClosingTag(child, options), printClosingTagSuffix(child, options)));
|
|
33806
34195
|
}
|
|
33807
34196
|
|
|
33808
34197
|
return print(childPath);
|
|
@@ -33863,7 +34252,7 @@ function printOpeningTag(path$$1, options, print) {
|
|
|
33863
34252
|
};
|
|
33864
34253
|
return path$$1.map(function (attrPath) {
|
|
33865
34254
|
var attr = attrPath.getValue();
|
|
33866
|
-
return hasPrettierIgnoreAttribute(attr) ? concat$14(
|
|
34255
|
+
return hasPrettierIgnoreAttribute(attr) ? concat$14(replaceEndOfLineWith$2(options.originalText.slice(options.locStart(attr), options.locEnd(attr)), literalline$6)) : print(attrPath);
|
|
33867
34256
|
}, "attrs");
|
|
33868
34257
|
}(node.prev && node.prev.type === "comment" && getPrettierIgnoreAttributeCommentData(node.prev.value)))])),
|
|
33869
34258
|
/**
|
|
@@ -34074,8 +34463,8 @@ function printClosingTagEndMarker(node, options) {
|
|
|
34074
34463
|
|
|
34075
34464
|
function getTextValueParts(node) {
|
|
34076
34465
|
var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : node.value;
|
|
34077
|
-
return node.parent.isWhitespaceSensitive ? node.parent.isIndentationSensitive ?
|
|
34078
|
-
join$10(line$9, value.split(/[
|
|
34466
|
+
return node.parent.isWhitespaceSensitive ? node.parent.isIndentationSensitive ? replaceEndOfLineWith$2(value, literalline$6) : replaceEndOfLineWith$2(dedentString(value.replace(/^\s*?\n|\n\s*?$/g, "")), hardline$12) : // https://infra.spec.whatwg.org/#ascii-whitespace
|
|
34467
|
+
join$10(line$9, value.split(/[\t\n\f\r ]+/)).parts;
|
|
34079
34468
|
}
|
|
34080
34469
|
|
|
34081
34470
|
function printEmbeddedAttributeValue(node, originalTextToDoc, options) {
|
|
@@ -34084,7 +34473,7 @@ function printEmbeddedAttributeValue(node, originalTextToDoc, options) {
|
|
|
34084
34473
|
};
|
|
34085
34474
|
|
|
34086
34475
|
var getValue = function getValue() {
|
|
34087
|
-
return node.value
|
|
34476
|
+
return unescapeQuoteEntities(node.value);
|
|
34088
34477
|
};
|
|
34089
34478
|
|
|
34090
34479
|
var shouldHug = false;
|
|
@@ -34219,21 +34608,23 @@ function printEmbeddedAttributeValue(node, originalTextToDoc, options) {
|
|
|
34219
34608
|
|
|
34220
34609
|
var interpolationRegex = /\{\{([\s\S]+?)\}\}/g;
|
|
34221
34610
|
|
|
34222
|
-
var
|
|
34611
|
+
var _value2 = getValue();
|
|
34223
34612
|
|
|
34224
|
-
if (interpolationRegex.test(
|
|
34613
|
+
if (interpolationRegex.test(_value2)) {
|
|
34225
34614
|
var parts = [];
|
|
34226
34615
|
|
|
34227
|
-
|
|
34616
|
+
_value2.split(interpolationRegex).forEach(function (part, index) {
|
|
34228
34617
|
if (index % 2 === 0) {
|
|
34229
|
-
parts.push(concat$14(
|
|
34618
|
+
parts.push(concat$14(replaceEndOfLineWith$2(part, literalline$6)));
|
|
34230
34619
|
} else {
|
|
34231
34620
|
try {
|
|
34232
34621
|
parts.push(group$14(concat$14(["{{", indent$9(concat$14([line$9, ngTextToDoc(part, {
|
|
34233
|
-
parser: "__ng_interpolation"
|
|
34622
|
+
parser: "__ng_interpolation",
|
|
34623
|
+
__isInHtmlInterpolation: true // to avoid unexpected `}}`
|
|
34624
|
+
|
|
34234
34625
|
})])), line$9, "}}"])));
|
|
34235
34626
|
} catch (e) {
|
|
34236
|
-
parts.push("{{", concat$14(
|
|
34627
|
+
parts.push("{{", concat$14(replaceEndOfLineWith$2(part, literalline$6)), "}}");
|
|
34237
34628
|
}
|
|
34238
34629
|
}
|
|
34239
34630
|
});
|
|
@@ -34340,11 +34731,11 @@ var vue$1 = Object.freeze({
|
|
|
34340
34731
|
default: vue
|
|
34341
34732
|
});
|
|
34342
34733
|
|
|
34343
|
-
var require$$0$
|
|
34734
|
+
var require$$0$31 = ( html$2 && html$1 ) || html$2;
|
|
34344
34735
|
|
|
34345
|
-
var require$$1$
|
|
34736
|
+
var require$$1$10 = ( vue$1 && vue ) || vue$1;
|
|
34346
34737
|
|
|
34347
|
-
var languages$5 = [createLanguage(require$$0$
|
|
34738
|
+
var languages$5 = [createLanguage(require$$0$31, {
|
|
34348
34739
|
override: {
|
|
34349
34740
|
name: "Angular",
|
|
34350
34741
|
since: "1.15.0",
|
|
@@ -34353,13 +34744,17 @@ var languages$5 = [createLanguage(require$$0$29, {
|
|
|
34353
34744
|
extensions: [".component.html"],
|
|
34354
34745
|
filenames: []
|
|
34355
34746
|
}
|
|
34356
|
-
}), createLanguage(require$$0$
|
|
34747
|
+
}), createLanguage(require$$0$31, {
|
|
34357
34748
|
override: {
|
|
34358
34749
|
since: "1.15.0",
|
|
34359
34750
|
parsers: ["html"],
|
|
34360
34751
|
vscodeLanguageIds: ["html"]
|
|
34752
|
+
},
|
|
34753
|
+
extend: {
|
|
34754
|
+
extensions: [".mjml" // MJML is considered XML in Linguist but it should be formatted as HTML
|
|
34755
|
+
]
|
|
34361
34756
|
}
|
|
34362
|
-
}), createLanguage(require$$1$
|
|
34757
|
+
}), createLanguage(require$$1$10, {
|
|
34363
34758
|
override: {
|
|
34364
34759
|
since: "1.10.0",
|
|
34365
34760
|
parsers: ["vue"],
|
|
@@ -34393,9 +34788,7 @@ var pragma$11 = {
|
|
|
34393
34788
|
insertPragma: insertPragma$9
|
|
34394
34789
|
};
|
|
34395
34790
|
|
|
34396
|
-
|
|
34397
|
-
return array[array.length - 1];
|
|
34398
|
-
}
|
|
34791
|
+
var getLast$7 = util$1.getLast;
|
|
34399
34792
|
|
|
34400
34793
|
function getAncestorCount$1(path$$1, filter) {
|
|
34401
34794
|
var counter = 0;
|
|
@@ -34658,7 +35051,7 @@ function getBlockValueLineContents$1(node, _ref) {
|
|
|
34658
35051
|
}
|
|
34659
35052
|
}
|
|
34660
35053
|
|
|
34661
|
-
var utils$
|
|
35054
|
+
var utils$12 = {
|
|
34662
35055
|
getLast: getLast$7,
|
|
34663
35056
|
getAncestorCount: getAncestorCount$1,
|
|
34664
35057
|
isNode: isNode$2,
|
|
@@ -34680,27 +35073,27 @@ var utils$10 = {
|
|
|
34680
35073
|
|
|
34681
35074
|
var insertPragma$8 = pragma$11.insertPragma;
|
|
34682
35075
|
var isPragma = pragma$11.isPragma;
|
|
34683
|
-
var getAncestorCount = utils$
|
|
34684
|
-
var getBlockValueLineContents = utils$
|
|
34685
|
-
var getFlowScalarLineContents = utils$
|
|
34686
|
-
var getLast$6 = utils$
|
|
34687
|
-
var getLastDescendantNode$1 = utils$
|
|
34688
|
-
var hasLeadingComments = utils$
|
|
34689
|
-
var hasMiddleComments = utils$
|
|
34690
|
-
var hasIndicatorComment = utils$
|
|
34691
|
-
var hasTrailingComment$1 = utils$
|
|
34692
|
-
var hasEndComments = utils$
|
|
34693
|
-
var hasPrettierIgnore$4 = utils$
|
|
34694
|
-
var isLastDescendantNode = utils$
|
|
34695
|
-
var isNextLineEmpty$5 = utils$
|
|
34696
|
-
var isNode$1 = utils$
|
|
34697
|
-
var isEmptyNode = utils$
|
|
34698
|
-
var defineShortcut = utils$
|
|
34699
|
-
var mapNode = utils$
|
|
35076
|
+
var getAncestorCount = utils$12.getAncestorCount;
|
|
35077
|
+
var getBlockValueLineContents = utils$12.getBlockValueLineContents;
|
|
35078
|
+
var getFlowScalarLineContents = utils$12.getFlowScalarLineContents;
|
|
35079
|
+
var getLast$6 = utils$12.getLast;
|
|
35080
|
+
var getLastDescendantNode$1 = utils$12.getLastDescendantNode;
|
|
35081
|
+
var hasLeadingComments = utils$12.hasLeadingComments;
|
|
35082
|
+
var hasMiddleComments = utils$12.hasMiddleComments;
|
|
35083
|
+
var hasIndicatorComment = utils$12.hasIndicatorComment;
|
|
35084
|
+
var hasTrailingComment$1 = utils$12.hasTrailingComment;
|
|
35085
|
+
var hasEndComments = utils$12.hasEndComments;
|
|
35086
|
+
var hasPrettierIgnore$4 = utils$12.hasPrettierIgnore;
|
|
35087
|
+
var isLastDescendantNode = utils$12.isLastDescendantNode;
|
|
35088
|
+
var isNextLineEmpty$5 = utils$12.isNextLineEmpty;
|
|
35089
|
+
var isNode$1 = utils$12.isNode;
|
|
35090
|
+
var isEmptyNode = utils$12.isEmptyNode;
|
|
35091
|
+
var defineShortcut = utils$12.defineShortcut;
|
|
35092
|
+
var mapNode = utils$12.mapNode;
|
|
34700
35093
|
var docBuilders$3 = doc.builders;
|
|
34701
35094
|
var conditionalGroup$2 = docBuilders$3.conditionalGroup;
|
|
34702
35095
|
var breakParent$4 = docBuilders$3.breakParent;
|
|
34703
|
-
var concat$
|
|
35096
|
+
var concat$17 = docBuilders$3.concat;
|
|
34704
35097
|
var dedent$4 = docBuilders$3.dedent;
|
|
34705
35098
|
var dedentToRoot$3 = docBuilders$3.dedentToRoot;
|
|
34706
35099
|
var fill$6 = docBuilders$3.fill;
|
|
@@ -34713,6 +35106,7 @@ var lineSuffix$2 = docBuilders$3.lineSuffix;
|
|
|
34713
35106
|
var literalline$7 = docBuilders$3.literalline;
|
|
34714
35107
|
var markAsRoot$5 = docBuilders$3.markAsRoot;
|
|
34715
35108
|
var softline$8 = docBuilders$3.softline;
|
|
35109
|
+
var replaceEndOfLineWith$3 = util$1.replaceEndOfLineWith;
|
|
34716
35110
|
|
|
34717
35111
|
function preprocess$6(ast) {
|
|
34718
35112
|
return mapNode(ast, defineShortcuts);
|
|
@@ -34759,16 +35153,16 @@ function genericPrint$6(path$$1, options, print) {
|
|
|
34759
35153
|
var tag = !node.tag ? "" : path$$1.call(print, "tag");
|
|
34760
35154
|
var anchor = !node.anchor ? "" : path$$1.call(print, "anchor");
|
|
34761
35155
|
var nextEmptyLine = isNode$1(node, ["mapping", "sequence", "comment", "directive", "mappingItem", "sequenceItem"]) && !isLastDescendantNode(path$$1) ? printNextEmptyLine(path$$1, options.originalText) : "";
|
|
34762
|
-
return concat$
|
|
35156
|
+
return concat$17([node.type !== "mappingValue" && hasLeadingComments(node) ? concat$17([join$12(hardline$13, path$$1.map(print, "leadingComments")), hardline$13]) : "", tag, tag && anchor ? " " : "", anchor, tag || anchor ? isNode$1(node, ["sequence", "mapping"]) && !hasMiddleComments(node) ? hardline$13 : " " : "", hasMiddleComments(node) ? concat$17([node.middleComments.length === 1 ? "" : hardline$13, join$12(hardline$13, path$$1.map(print, "middleComments")), hardline$13]) : "", hasPrettierIgnore$4(path$$1) ? concat$17(replaceEndOfLineWith$3(options.originalText.slice(node.position.start.offset, node.position.end.offset), literalline$7)) : group$16(_print(node, parentNode, path$$1, options, print)), hasTrailingComment$1(node) && !isNode$1(node, ["document", "documentHead"]) ? lineSuffix$2(concat$17([node.type === "mappingValue" && !node.content ? "" : " ", parentNode.type === "mappingKey" && path$$1.getParentNode(2).type === "mapping" && isInlineNode(node) ? "" : breakParent$4, path$$1.call(print, "trailingComment")])) : "", nextEmptyLine, hasEndComments(node) && !isNode$1(node, ["documentHead", "documentBody"]) ? align$3(node.type === "sequenceItem" ? 2 : 0, concat$17([hardline$13, join$12(hardline$13, path$$1.map(print, "endComments"))])) : ""]);
|
|
34763
35157
|
}
|
|
34764
35158
|
|
|
34765
35159
|
function _print(node, parentNode, path$$1, options, print) {
|
|
34766
35160
|
switch (node.type) {
|
|
34767
35161
|
case "root":
|
|
34768
|
-
return concat$
|
|
35162
|
+
return concat$17([join$12(hardline$13, path$$1.map(function (childPath, index) {
|
|
34769
35163
|
var document = node.children[index];
|
|
34770
35164
|
var nextDocument = node.children[index + 1];
|
|
34771
|
-
return concat$
|
|
35165
|
+
return concat$17([print(childPath), shouldPrintDocumentEndMarker(document, nextDocument) ? concat$17([hardline$13, "...", hasTrailingComment$1(document) ? concat$17([" ", path$$1.call(print, "trailingComment")]) : ""]) : !nextDocument || hasTrailingComment$1(nextDocument.head) ? "" : concat$17([hardline$13, "---"])]);
|
|
34772
35166
|
}, "children")), node.children.length === 0 || function (lastDescendantNode) {
|
|
34773
35167
|
return isNode$1(lastDescendantNode, ["blockLiteral", "blockFolded"]) && lastDescendantNode.chomping === "keep";
|
|
34774
35168
|
}(getLastDescendantNode$1(node)) ? "" : hardline$13]);
|
|
@@ -34776,7 +35170,7 @@ function _print(node, parentNode, path$$1, options, print) {
|
|
|
34776
35170
|
case "document":
|
|
34777
35171
|
{
|
|
34778
35172
|
var nextDocument = parentNode.children[path$$1.getName() + 1];
|
|
34779
|
-
return join$12(hardline$13, [shouldPrintDocumentHeadEndMarker(node, nextDocument, parentNode, options) === "head" ? join$12(hardline$13, [node.head.children.length === 0 && node.head.endComments.length === 0 ? "" : path$$1.call(print, "head"), concat$
|
|
35173
|
+
return join$12(hardline$13, [shouldPrintDocumentHeadEndMarker(node, nextDocument, parentNode, options) === "head" ? join$12(hardline$13, [node.head.children.length === 0 && node.head.endComments.length === 0 ? "" : path$$1.call(print, "head"), concat$17(["---", hasTrailingComment$1(node.head) ? concat$17([" ", path$$1.call(print, "head", "trailingComment")]) : ""])].filter(Boolean)) : "", shouldPrintDocumentBody(node) ? path$$1.call(print, "body") : ""].filter(Boolean));
|
|
34780
35174
|
}
|
|
34781
35175
|
|
|
34782
35176
|
case "documentHead":
|
|
@@ -34789,25 +35183,25 @@ function _print(node, parentNode, path$$1, options, print) {
|
|
|
34789
35183
|
var separator = children.length === 0 || endComments.length === 0 ? "" : function (lastDescendantNode) {
|
|
34790
35184
|
return isNode$1(lastDescendantNode, ["blockFolded", "blockLiteral"]) ? lastDescendantNode.chomping === "keep" ? // there's already a newline printed at the end of blockValue (chomping=keep, lastDescendant=true)
|
|
34791
35185
|
"" : // an extra newline for better readability
|
|
34792
|
-
concat$
|
|
35186
|
+
concat$17([hardline$13, hardline$13]) : hardline$13;
|
|
34793
35187
|
}(getLastDescendantNode$1(node));
|
|
34794
|
-
return concat$
|
|
35188
|
+
return concat$17([].concat(children, separator, endComments));
|
|
34795
35189
|
}
|
|
34796
35190
|
|
|
34797
35191
|
case "directive":
|
|
34798
|
-
return concat$
|
|
35192
|
+
return concat$17(["%", join$12(" ", [node.name].concat(node.parameters))]);
|
|
34799
35193
|
|
|
34800
35194
|
case "comment":
|
|
34801
|
-
return concat$
|
|
35195
|
+
return concat$17(["#", node.value]);
|
|
34802
35196
|
|
|
34803
35197
|
case "alias":
|
|
34804
|
-
return concat$
|
|
35198
|
+
return concat$17(["*", node.value]);
|
|
34805
35199
|
|
|
34806
35200
|
case "tag":
|
|
34807
35201
|
return options.originalText.slice(node.position.start.offset, node.position.end.offset);
|
|
34808
35202
|
|
|
34809
35203
|
case "anchor":
|
|
34810
|
-
return concat$
|
|
35204
|
+
return concat$17(["&", node.value]);
|
|
34811
35205
|
|
|
34812
35206
|
case "plain":
|
|
34813
35207
|
return printFlowScalarContent(node.type, options.originalText.slice(node.position.start.offset, node.position.end.offset), options);
|
|
@@ -34823,19 +35217,19 @@ function _print(node, parentNode, path$$1, options, print) {
|
|
|
34823
35217
|
// only quoteDouble can use escape chars
|
|
34824
35218
|
// and quoteSingle do not need to escape backslashes
|
|
34825
35219
|
var originalQuote = node.type === "quoteDouble" ? doubleQuote : singleQuote;
|
|
34826
|
-
return concat$
|
|
35220
|
+
return concat$17([originalQuote, printFlowScalarContent(node.type, raw, options), originalQuote]);
|
|
34827
35221
|
} else if (raw.includes(doubleQuote)) {
|
|
34828
|
-
return concat$
|
|
35222
|
+
return concat$17([singleQuote, printFlowScalarContent(node.type, node.type === "quoteDouble" ? raw // double quote needs to be escaped by backslash in quoteDouble
|
|
34829
35223
|
.replace(/\\"/g, doubleQuote).replace(/'/g, singleQuote.repeat(2)) : raw, options), singleQuote]);
|
|
34830
35224
|
}
|
|
34831
35225
|
|
|
34832
35226
|
if (raw.includes(singleQuote)) {
|
|
34833
|
-
return concat$
|
|
35227
|
+
return concat$17([doubleQuote, printFlowScalarContent(node.type, node.type === "quoteSingle" ? // single quote needs to be escaped by 2 single quotes in quoteSingle
|
|
34834
35228
|
raw.replace(/''/g, singleQuote) : raw, options), doubleQuote]);
|
|
34835
35229
|
}
|
|
34836
35230
|
|
|
34837
35231
|
var quote = options.singleQuote ? singleQuote : doubleQuote;
|
|
34838
|
-
return concat$
|
|
35232
|
+
return concat$17([quote, printFlowScalarContent(node.type, raw, options), quote]);
|
|
34839
35233
|
}
|
|
34840
35234
|
|
|
34841
35235
|
case "blockFolded":
|
|
@@ -34845,7 +35239,7 @@ function _print(node, parentNode, path$$1, options, print) {
|
|
|
34845
35239
|
return isNode$1(ancestorNode, ["sequence", "mapping"]);
|
|
34846
35240
|
});
|
|
34847
35241
|
var isLastDescendant = isLastDescendantNode(path$$1);
|
|
34848
|
-
return concat$
|
|
35242
|
+
return concat$17([node.type === "blockFolded" ? ">" : "|", node.indent === null ? "" : node.indent.toString(), node.chomping === "clip" ? "" : node.chomping === "keep" ? "+" : "-", hasIndicatorComment(node) ? concat$17([" ", path$$1.call(print, "indicatorComment")]) : "", (node.indent === null ? dedent$4 : dedentToRoot$3)(align$3(node.indent === null ? options.tabWidth : node.indent - 1 + parentIndent, concat$17(getBlockValueLineContents(node, {
|
|
34849
35243
|
parentIndent,
|
|
34850
35244
|
isLastDescendant,
|
|
34851
35245
|
options
|
|
@@ -34858,7 +35252,7 @@ function _print(node, parentNode, path$$1, options, print) {
|
|
|
34858
35252
|
return join$12(hardline$13, path$$1.map(print, "children"));
|
|
34859
35253
|
|
|
34860
35254
|
case "sequenceItem":
|
|
34861
|
-
return concat$
|
|
35255
|
+
return concat$17(["- ", align$3(2, !node.content ? "" : path$$1.call(print, "content"))]);
|
|
34862
35256
|
|
|
34863
35257
|
case "mappingKey":
|
|
34864
35258
|
return !node.content ? "" : path$$1.call(print, "content");
|
|
@@ -34876,28 +35270,28 @@ function _print(node, parentNode, path$$1, options, print) {
|
|
|
34876
35270
|
var isEmptyMappingValue = isEmptyNode(node.value);
|
|
34877
35271
|
|
|
34878
35272
|
if (isEmptyMappingKey && isEmptyMappingValue) {
|
|
34879
|
-
return concat$
|
|
35273
|
+
return concat$17([": "]);
|
|
34880
35274
|
}
|
|
34881
35275
|
|
|
34882
35276
|
var key = path$$1.call(print, "key");
|
|
34883
35277
|
var value = path$$1.call(print, "value");
|
|
34884
35278
|
|
|
34885
35279
|
if (isEmptyMappingValue) {
|
|
34886
|
-
return node.type === "flowMappingItem" && parentNode.type === "flowMapping" ? key : node.type === "mappingItem" && isAbsolutelyPrintedAsSingleLineNode(node.key.content, options) && !hasTrailingComment$1(node.key.content) && (!parentNode.tag || parentNode.tag.value !== "tag:yaml.org,2002:set") ? concat$
|
|
35280
|
+
return node.type === "flowMappingItem" && parentNode.type === "flowMapping" ? key : node.type === "mappingItem" && isAbsolutelyPrintedAsSingleLineNode(node.key.content, options) && !hasTrailingComment$1(node.key.content) && (!parentNode.tag || parentNode.tag.value !== "tag:yaml.org,2002:set") ? concat$17([key, needsSpaceInFrontOfMappingValue(node) ? " " : "", ":"]) : concat$17(["? ", align$3(2, key)]);
|
|
34887
35281
|
}
|
|
34888
35282
|
|
|
34889
35283
|
if (isEmptyMappingKey) {
|
|
34890
|
-
return concat$
|
|
35284
|
+
return concat$17([": ", align$3(2, value)]);
|
|
34891
35285
|
}
|
|
34892
35286
|
|
|
34893
35287
|
var groupId = Symbol("mappingKey");
|
|
34894
35288
|
var forceExplicitKey = hasLeadingComments(node.value) || !isInlineNode(node.key.content);
|
|
34895
|
-
return forceExplicitKey ? concat$
|
|
34896
|
-
return concat$
|
|
35289
|
+
return forceExplicitKey ? concat$17(["? ", align$3(2, key), hardline$13, join$12("", path$$1.map(print, "value", "leadingComments").map(function (comment) {
|
|
35290
|
+
return concat$17([comment, hardline$13]);
|
|
34897
35291
|
})), ": ", align$3(2, value)]) : // force singleline
|
|
34898
|
-
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$
|
|
35292
|
+
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$7("? "), group$16(align$3(2, key), {
|
|
34899
35293
|
id: groupId
|
|
34900
|
-
})])), ifBreak$7(concat$
|
|
35294
|
+
})])), ifBreak$7(concat$17([hardline$13, ": ", align$3(2, value)]), indent(concat$17([needsSpaceInFrontOfMappingValue(node) ? " " : "", ":", hasLeadingComments(node.value.content) || hasEndComments(node.value) && node.value.content && !isNode$1(node.value.content, ["mapping", "sequence"]) || parentNode.type === "mapping" && hasTrailingComment$1(node.key.content) && isInlineNode(node.value.content) || isNode$1(node.value.content, ["mapping", "sequence"]) && node.value.content.tag === null && node.value.content.anchor === null ? hardline$13 : !node.value.content ? "" : line$11, value])), {
|
|
34901
35295
|
groupId
|
|
34902
35296
|
})])]);
|
|
34903
35297
|
}
|
|
@@ -34913,8 +35307,8 @@ function _print(node, parentNode, path$$1, options, print) {
|
|
|
34913
35307
|
return lastItem.type === "flowMappingItem" && isEmptyNode(lastItem.key) && isEmptyNode(lastItem.value);
|
|
34914
35308
|
}(getLast$6(node.children));
|
|
34915
35309
|
|
|
34916
|
-
return concat$
|
|
34917
|
-
return concat$
|
|
35310
|
+
return concat$17([openMarker, indent(concat$17([bracketSpacing, concat$17(path$$1.map(function (childPath, index) {
|
|
35311
|
+
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) : ""])]);
|
|
34918
35312
|
}, "children")), ifBreak$7(",", "")])), isLastItemEmptyMappingItem ? "" : bracketSpacing, closeMarker]);
|
|
34919
35313
|
}
|
|
34920
35314
|
|
|
@@ -35168,9 +35562,9 @@ var yaml$1 = Object.freeze({
|
|
|
35168
35562
|
default: yaml
|
|
35169
35563
|
});
|
|
35170
35564
|
|
|
35171
|
-
var require$$0$
|
|
35565
|
+
var require$$0$33 = ( yaml$1 && yaml ) || yaml$1;
|
|
35172
35566
|
|
|
35173
|
-
var languages$6 = [createLanguage(require$$0$
|
|
35567
|
+
var languages$6 = [createLanguage(require$$0$33, {
|
|
35174
35568
|
override: {
|
|
35175
35569
|
since: "1.14.0",
|
|
35176
35570
|
parsers: ["yaml"],
|
|
@@ -35193,9 +35587,17 @@ var languageYaml = {
|
|
|
35193
35587
|
var internalPlugins = [// JS
|
|
35194
35588
|
languageJs, {
|
|
35195
35589
|
parsers: {
|
|
35196
|
-
// JS -
|
|
35590
|
+
// JS - Babel
|
|
35591
|
+
get babel() {
|
|
35592
|
+
return require("./parser-babylon").parsers.babel;
|
|
35593
|
+
},
|
|
35594
|
+
|
|
35595
|
+
get "babel-flow"() {
|
|
35596
|
+
return require("./parser-babylon").parsers["babel-flow"];
|
|
35597
|
+
},
|
|
35598
|
+
|
|
35197
35599
|
get babylon() {
|
|
35198
|
-
return require("./parser-babylon").parsers.
|
|
35600
|
+
return require("./parser-babylon").parsers.babel;
|
|
35199
35601
|
},
|
|
35200
35602
|
|
|
35201
35603
|
get json() {
|
|
@@ -35338,6 +35740,19 @@ languageYaml, {
|
|
|
35338
35740
|
}
|
|
35339
35741
|
}];
|
|
35340
35742
|
|
|
35743
|
+
var partition = function partition(array, fn) {
|
|
35744
|
+
var a = [];
|
|
35745
|
+
var b = [];
|
|
35746
|
+
array.forEach(function (item) {
|
|
35747
|
+
if (fn(item)) {
|
|
35748
|
+
a.push(item);
|
|
35749
|
+
} else {
|
|
35750
|
+
b.push(item);
|
|
35751
|
+
}
|
|
35752
|
+
});
|
|
35753
|
+
return [a, b];
|
|
35754
|
+
};
|
|
35755
|
+
|
|
35341
35756
|
var thirdParty$1 = ( thirdParty && thirdParty__default ) || thirdParty;
|
|
35342
35757
|
|
|
35343
35758
|
function loadPlugins(plugins, pluginSearchDirs) {
|
|
@@ -35358,7 +35773,14 @@ function loadPlugins(plugins, pluginSearchDirs) {
|
|
|
35358
35773
|
}
|
|
35359
35774
|
}
|
|
35360
35775
|
|
|
35361
|
-
var
|
|
35776
|
+
var _partition = partition(plugins, function (plugin) {
|
|
35777
|
+
return typeof plugin === "string";
|
|
35778
|
+
}),
|
|
35779
|
+
_partition2 = _slicedToArray(_partition, 2),
|
|
35780
|
+
externalPluginNames = _partition2[0],
|
|
35781
|
+
externalPluginInstances = _partition2[1];
|
|
35782
|
+
|
|
35783
|
+
var externalManualLoadPluginInfos = externalPluginNames.map(function (pluginName) {
|
|
35362
35784
|
var requirePath;
|
|
35363
35785
|
|
|
35364
35786
|
try {
|
|
@@ -35399,7 +35821,7 @@ function loadPlugins(plugins, pluginSearchDirs) {
|
|
|
35399
35821
|
return Object.assign({
|
|
35400
35822
|
name: externalPluginInfo.name
|
|
35401
35823
|
}, require(externalPluginInfo.requirePath));
|
|
35402
|
-
});
|
|
35824
|
+
}).concat(externalPluginInstances);
|
|
35403
35825
|
return internalPlugins.concat(externalPlugins);
|
|
35404
35826
|
}
|
|
35405
35827
|
|
|
@@ -42954,6 +43376,15 @@ var categoryOrder = [coreOptions$1.CATEGORY_OUTPUT, coreOptions$1.CATEGORY_FORMA
|
|
|
42954
43376
|
*/
|
|
42955
43377
|
|
|
42956
43378
|
var options$21 = {
|
|
43379
|
+
check: {
|
|
43380
|
+
type: "boolean",
|
|
43381
|
+
category: coreOptions$1.CATEGORY_OUTPUT,
|
|
43382
|
+
alias: "c",
|
|
43383
|
+
description: dedent_1`
|
|
43384
|
+
Check if the given files are formatted, print a human-friendly summary
|
|
43385
|
+
message and paths to unformatted files (see also --list-different).
|
|
43386
|
+
`
|
|
43387
|
+
},
|
|
42957
43388
|
color: {
|
|
42958
43389
|
// The supports-color package (a sub sub dependency) looks directly at
|
|
42959
43390
|
// `process.argv` for `--no-color` and such-like options. The reason it is
|
|
@@ -43049,7 +43480,7 @@ var options$21 = {
|
|
|
43049
43480
|
type: "boolean",
|
|
43050
43481
|
category: coreOptions$1.CATEGORY_OUTPUT,
|
|
43051
43482
|
alias: "l",
|
|
43052
|
-
description: "Print the names of files that are different from Prettier's formatting."
|
|
43483
|
+
description: "Print the names of files that are different from Prettier's formatting (see also --check)."
|
|
43053
43484
|
},
|
|
43054
43485
|
loglevel: {
|
|
43055
43486
|
type: "choice",
|
|
@@ -43093,6 +43524,14 @@ var constant = {
|
|
|
43093
43524
|
usageSummary
|
|
43094
43525
|
};
|
|
43095
43526
|
|
|
43527
|
+
// which causes unwanted lines in the output. An additional check for isCI() helps.
|
|
43528
|
+
// See https://github.com/prettier/prettier/issues/5801
|
|
43529
|
+
|
|
43530
|
+
|
|
43531
|
+
var isTty = function isTTY() {
|
|
43532
|
+
return process.stdout.isTTY && !thirdParty$1.isCI();
|
|
43533
|
+
};
|
|
43534
|
+
|
|
43096
43535
|
var OPTION_USAGE_THRESHOLD = 25;
|
|
43097
43536
|
var CHOICE_USAGE_MARGIN = 3;
|
|
43098
43537
|
var CHOICE_USAGE_INDENTATION = 2;
|
|
@@ -43124,12 +43563,12 @@ function diff(a, b) {
|
|
|
43124
43563
|
|
|
43125
43564
|
function handleError(context, filename, error) {
|
|
43126
43565
|
if (error instanceof errors.UndefinedParserError) {
|
|
43127
|
-
if (context.argv["write"] &&
|
|
43566
|
+
if (context.argv["write"] && isTty()) {
|
|
43128
43567
|
readline.clearLine(process.stdout, 0);
|
|
43129
43568
|
readline.cursorTo(process.stdout, 0, null);
|
|
43130
43569
|
}
|
|
43131
43570
|
|
|
43132
|
-
if (!context.argv["list-different"]) {
|
|
43571
|
+
if (!context.argv["check"] && !context.argv["list-different"]) {
|
|
43133
43572
|
process.exitCode = 2;
|
|
43134
43573
|
}
|
|
43135
43574
|
|
|
@@ -43198,7 +43637,7 @@ function writeOutput(context, result, options$$2) {
|
|
|
43198
43637
|
}
|
|
43199
43638
|
|
|
43200
43639
|
function listDifferent(context, input, options$$2, filename) {
|
|
43201
|
-
if (!context.argv["list-different"]) {
|
|
43640
|
+
if (!context.argv["check"] && !context.argv["list-different"]) {
|
|
43202
43641
|
return;
|
|
43203
43642
|
}
|
|
43204
43643
|
|
|
@@ -43468,14 +43907,20 @@ function formatFiles(context) {
|
|
|
43468
43907
|
// The ignorer will be used to filter file paths after the glob is checked,
|
|
43469
43908
|
// before any files are actually written
|
|
43470
43909
|
var ignorer = createIgnorerFromContextOrDie(context);
|
|
43910
|
+
var numberOfUnformattedFilesFound = 0;
|
|
43911
|
+
|
|
43912
|
+
if (context.argv["check"]) {
|
|
43913
|
+
context.logger.log("Checking formatting...");
|
|
43914
|
+
}
|
|
43915
|
+
|
|
43471
43916
|
eachFilename(context, context.filePatterns, function (filename, options$$2) {
|
|
43472
43917
|
var fileIgnored = ignorer.filter([filename]).length === 0;
|
|
43473
43918
|
|
|
43474
|
-
if (fileIgnored && (context.argv["debug-check"] || context.argv["write"] || context.argv["list-different"])) {
|
|
43919
|
+
if (fileIgnored && (context.argv["debug-check"] || context.argv["write"] || context.argv["check"] || context.argv["list-different"])) {
|
|
43475
43920
|
return;
|
|
43476
43921
|
}
|
|
43477
43922
|
|
|
43478
|
-
if (
|
|
43923
|
+
if (isTty()) {
|
|
43479
43924
|
// Don't use `console.log` here since we need to replace this line.
|
|
43480
43925
|
context.logger.log(filename, {
|
|
43481
43926
|
newline: false
|
|
@@ -43518,25 +43963,17 @@ function formatFiles(context) {
|
|
|
43518
43963
|
|
|
43519
43964
|
var isDifferent = output !== input;
|
|
43520
43965
|
|
|
43521
|
-
if (
|
|
43522
|
-
|
|
43523
|
-
|
|
43524
|
-
|
|
43525
|
-
process.exitCode = 1;
|
|
43526
|
-
}
|
|
43966
|
+
if (isTty()) {
|
|
43967
|
+
// Remove previously printed filename to log it with duration.
|
|
43968
|
+
readline.clearLine(process.stdout, 0);
|
|
43969
|
+
readline.cursorTo(process.stdout, 0, null);
|
|
43527
43970
|
}
|
|
43528
43971
|
|
|
43529
43972
|
if (context.argv["write"]) {
|
|
43530
|
-
if
|
|
43531
|
-
// Remove previously printed filename to log it with duration.
|
|
43532
|
-
readline.clearLine(process.stdout, 0);
|
|
43533
|
-
readline.cursorTo(process.stdout, 0, null);
|
|
43534
|
-
} // Don't write the file if it won't change in order not to invalidate
|
|
43973
|
+
// Don't write the file if it won't change in order not to invalidate
|
|
43535
43974
|
// mtime based caches.
|
|
43536
|
-
|
|
43537
|
-
|
|
43538
43975
|
if (isDifferent) {
|
|
43539
|
-
if (!context.argv["list-different"]) {
|
|
43976
|
+
if (!context.argv["check"] && !context.argv["list-different"]) {
|
|
43540
43977
|
context.logger.log(`${filename} ${Date.now() - start}ms`);
|
|
43541
43978
|
}
|
|
43542
43979
|
|
|
@@ -43547,7 +43984,7 @@ function formatFiles(context) {
|
|
|
43547
43984
|
|
|
43548
43985
|
process.exitCode = 2;
|
|
43549
43986
|
}
|
|
43550
|
-
} else if (!context.argv["list-different"]) {
|
|
43987
|
+
} else if (!context.argv["check"] && !context.argv["list-different"]) {
|
|
43551
43988
|
context.logger.log(`${chalk$2.grey(filename)} ${Date.now() - start}ms`);
|
|
43552
43989
|
}
|
|
43553
43990
|
} else if (context.argv["debug-check"]) {
|
|
@@ -43556,10 +43993,24 @@ function formatFiles(context) {
|
|
|
43556
43993
|
} else {
|
|
43557
43994
|
process.exitCode = 2;
|
|
43558
43995
|
}
|
|
43559
|
-
} else if (!context.argv["list-different"]) {
|
|
43996
|
+
} else if (!context.argv["check"] && !context.argv["list-different"]) {
|
|
43560
43997
|
writeOutput(context, result, options$$2);
|
|
43561
43998
|
}
|
|
43562
|
-
|
|
43999
|
+
|
|
44000
|
+
if ((context.argv["check"] || context.argv["list-different"]) && isDifferent) {
|
|
44001
|
+
context.logger.log(filename);
|
|
44002
|
+
numberOfUnformattedFilesFound += 1;
|
|
44003
|
+
}
|
|
44004
|
+
}); // Print check summary based on expected exit code
|
|
44005
|
+
|
|
44006
|
+
if (context.argv["check"]) {
|
|
44007
|
+
context.logger.log(numberOfUnformattedFilesFound === 0 ? "All matched files use Prettier code style!" : context.argv["write"] ? "Code style issues fixed in the above file(s)." : "Code style issues found in the above file(s). Forgot to run Prettier?");
|
|
44008
|
+
} // Ensure non-zero exitCode when using --check/list-different is not combined with --write
|
|
44009
|
+
|
|
44010
|
+
|
|
44011
|
+
if ((context.argv["check"] || context.argv["list-different"]) && numberOfUnformattedFilesFound > 0 && !process.exitCode && !context.argv["write"]) {
|
|
44012
|
+
process.exitCode = 1;
|
|
44013
|
+
}
|
|
43563
44014
|
}
|
|
43564
44015
|
|
|
43565
44016
|
function getOptionsWithOpposites(options$$2) {
|
|
@@ -43972,6 +44423,11 @@ function run(args) {
|
|
|
43972
44423
|
util$5.initContext(context);
|
|
43973
44424
|
context.logger.debug(`normalized argv: ${JSON.stringify(context.argv)}`);
|
|
43974
44425
|
|
|
44426
|
+
if (context.argv["check"] && context.argv["list-different"]) {
|
|
44427
|
+
context.logger.error("Cannot use --check and --list-different together.");
|
|
44428
|
+
process.exit(1);
|
|
44429
|
+
}
|
|
44430
|
+
|
|
43975
44431
|
if (context.argv["write"] && context.argv["debug-check"]) {
|
|
43976
44432
|
context.logger.error("Cannot use --write and --debug-check together.");
|
|
43977
44433
|
process.exit(1);
|