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/index.js
CHANGED
|
@@ -12,7 +12,7 @@ var thirdParty = require('./third-party');
|
|
|
12
12
|
var thirdParty__default = thirdParty['default'];
|
|
13
13
|
|
|
14
14
|
var name = "prettier";
|
|
15
|
-
var version$1 = "1.
|
|
15
|
+
var version$1 = "1.16.3";
|
|
16
16
|
var description = "Prettier is an opinionated code formatter";
|
|
17
17
|
var bin = {
|
|
18
18
|
"prettier": "./bin/prettier.js"
|
|
@@ -28,11 +28,11 @@ var engines = {
|
|
|
28
28
|
var dependencies = {
|
|
29
29
|
"@angular/compiler": "6.1.10",
|
|
30
30
|
"@babel/code-frame": "7.0.0-beta.46",
|
|
31
|
-
"@babel/parser": "7.
|
|
31
|
+
"@babel/parser": "7.2.0",
|
|
32
32
|
"@glimmer/syntax": "0.30.3",
|
|
33
33
|
"@iarna/toml": "2.0.0",
|
|
34
34
|
"angular-estree-parser": "1.1.5",
|
|
35
|
-
"angular-html-parser": "1.
|
|
35
|
+
"angular-html-parser": "1.2.0",
|
|
36
36
|
"camelcase": "4.1.0",
|
|
37
37
|
"chalk": "2.1.0",
|
|
38
38
|
"cjk-regex": "2.0.0",
|
|
@@ -42,7 +42,6 @@ var dependencies = {
|
|
|
42
42
|
"diff": "3.2.0",
|
|
43
43
|
"editorconfig": "0.15.2",
|
|
44
44
|
"editorconfig-to-prettier": "0.1.1",
|
|
45
|
-
"emoji-regex": "6.5.1",
|
|
46
45
|
"escape-string-regexp": "1.0.5",
|
|
47
46
|
"esutils": "2.0.2",
|
|
48
47
|
"find-parent-dir": "0.3.0",
|
|
@@ -55,6 +54,7 @@ var dependencies = {
|
|
|
55
54
|
"html-styles": "1.0.0",
|
|
56
55
|
"html-tag-names": "1.1.2",
|
|
57
56
|
"ignore": "3.3.7",
|
|
57
|
+
"is-ci": "2.0.0",
|
|
58
58
|
"jest-docblock": "23.2.0",
|
|
59
59
|
"json-stable-stringify": "1.0.1",
|
|
60
60
|
"leven": "2.1.0",
|
|
@@ -77,23 +77,23 @@ var dependencies = {
|
|
|
77
77
|
"remark-parse": "5.0.0",
|
|
78
78
|
"resolve": "1.5.0",
|
|
79
79
|
"semver": "5.4.1",
|
|
80
|
-
"string-width": "
|
|
81
|
-
"typescript": "3.2.
|
|
82
|
-
"typescript-estree": "
|
|
80
|
+
"string-width": "3.0.0",
|
|
81
|
+
"typescript": "3.2.2",
|
|
82
|
+
"typescript-estree": "18.0.0",
|
|
83
83
|
"unicode-regex": "2.0.0",
|
|
84
84
|
"unified": "6.1.6",
|
|
85
85
|
"vnopts": "1.0.2",
|
|
86
|
-
"yaml": "1.0.
|
|
87
|
-
"yaml-unist-parser": "1.0.0
|
|
86
|
+
"yaml": "1.0.2",
|
|
87
|
+
"yaml-unist-parser": "1.0.0"
|
|
88
88
|
};
|
|
89
89
|
var devDependencies = {
|
|
90
|
-
"@babel/cli": "7.
|
|
91
|
-
"@babel/core": "7.
|
|
92
|
-
"@babel/preset-env": "7.
|
|
90
|
+
"@babel/cli": "7.2.0",
|
|
91
|
+
"@babel/core": "7.2.0",
|
|
92
|
+
"@babel/preset-env": "7.2.0",
|
|
93
93
|
"babel-loader": "8.0.4",
|
|
94
94
|
"benchmark": "2.1.4",
|
|
95
95
|
"builtin-modules": "2.0.0",
|
|
96
|
-
"codecov": "
|
|
96
|
+
"codecov": "codecov/codecov-node#e427d900309adb50746a39a50aa7d80071a5ddd0",
|
|
97
97
|
"cross-env": "5.0.5",
|
|
98
98
|
"eslint": "4.18.2",
|
|
99
99
|
"eslint-config-prettier": "2.9.0",
|
|
@@ -108,7 +108,7 @@ var devDependencies = {
|
|
|
108
108
|
"jest-snapshot-serializer-raw": "1.1.0",
|
|
109
109
|
"jest-watch-typeahead": "0.1.0",
|
|
110
110
|
"mkdirp": "0.5.1",
|
|
111
|
-
"prettier": "1.
|
|
111
|
+
"prettier": "1.16.2",
|
|
112
112
|
"prettylint": "1.0.0",
|
|
113
113
|
"rimraf": "2.6.2",
|
|
114
114
|
"rollup": "0.47.6",
|
|
@@ -3868,7 +3868,17 @@ var options$2 = {
|
|
|
3868
3868
|
description: "Flow"
|
|
3869
3869
|
}, {
|
|
3870
3870
|
value: "babylon",
|
|
3871
|
+
description: "JavaScript",
|
|
3872
|
+
deprecated: "1.16.0",
|
|
3873
|
+
redirect: "babel"
|
|
3874
|
+
}, {
|
|
3875
|
+
value: "babel",
|
|
3876
|
+
since: "1.16.0",
|
|
3871
3877
|
description: "JavaScript"
|
|
3878
|
+
}, {
|
|
3879
|
+
value: "babel-flow",
|
|
3880
|
+
since: "1.16.0",
|
|
3881
|
+
description: "Flow"
|
|
3872
3882
|
}, {
|
|
3873
3883
|
value: "typescript",
|
|
3874
3884
|
since: "1.4.0",
|
|
@@ -8706,6 +8716,8 @@ function (_vnopts$ChoiceSchema) {
|
|
|
8706
8716
|
return FlagSchema;
|
|
8707
8717
|
}(lib$1.ChoiceSchema);
|
|
8708
8718
|
|
|
8719
|
+
var hasDeprecationWarned;
|
|
8720
|
+
|
|
8709
8721
|
function normalizeOptions$1(options, optionInfos) {
|
|
8710
8722
|
var _ref3 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
8711
8723
|
logger = _ref3.logger,
|
|
@@ -8727,11 +8739,24 @@ function normalizeOptions$1(options, optionInfos) {
|
|
|
8727
8739
|
var schemas = optionInfosToSchemas(optionInfos, {
|
|
8728
8740
|
isCLI
|
|
8729
8741
|
});
|
|
8730
|
-
|
|
8742
|
+
var normalizer = new lib$1.Normalizer(schemas, {
|
|
8731
8743
|
logger,
|
|
8732
8744
|
unknown,
|
|
8733
8745
|
descriptor
|
|
8734
8746
|
});
|
|
8747
|
+
var shouldSuppressDuplicateDeprecationWarnings = logger !== false;
|
|
8748
|
+
|
|
8749
|
+
if (shouldSuppressDuplicateDeprecationWarnings && hasDeprecationWarned) {
|
|
8750
|
+
normalizer._hasDeprecationWarned = hasDeprecationWarned;
|
|
8751
|
+
}
|
|
8752
|
+
|
|
8753
|
+
var normalized = normalizer.normalize(options);
|
|
8754
|
+
|
|
8755
|
+
if (shouldSuppressDuplicateDeprecationWarnings) {
|
|
8756
|
+
hasDeprecationWarned = normalizer._hasDeprecationWarned;
|
|
8757
|
+
}
|
|
8758
|
+
|
|
8759
|
+
return normalized;
|
|
8735
8760
|
}
|
|
8736
8761
|
|
|
8737
8762
|
function optionInfosToSchemas(optionInfos, _ref4) {
|
|
@@ -10559,17 +10584,21 @@ function resolveParser$1(opts, parsers) {
|
|
|
10559
10584
|
if (parsers.hasOwnProperty(opts.parser)) {
|
|
10560
10585
|
return parsers[opts.parser];
|
|
10561
10586
|
}
|
|
10587
|
+
/* istanbul ignore next */
|
|
10562
10588
|
|
|
10563
|
-
|
|
10564
|
-
|
|
10565
|
-
|
|
10566
|
-
|
|
10567
|
-
|
|
10568
|
-
|
|
10569
|
-
|
|
10570
|
-
|
|
10571
|
-
|
|
10572
|
-
|
|
10589
|
+
|
|
10590
|
+
{
|
|
10591
|
+
try {
|
|
10592
|
+
return {
|
|
10593
|
+
parse: require(path.resolve(process.cwd(), opts.parser)),
|
|
10594
|
+
astFormat: "estree",
|
|
10595
|
+
locStart,
|
|
10596
|
+
locEnd
|
|
10597
|
+
};
|
|
10598
|
+
} catch (err) {
|
|
10599
|
+
/* istanbul ignore next */
|
|
10600
|
+
throw new ConfigError$1(`Couldn't resolve parser "${opts.parser}"`);
|
|
10601
|
+
}
|
|
10573
10602
|
}
|
|
10574
10603
|
}
|
|
10575
10604
|
}
|
|
@@ -10650,8 +10679,8 @@ function normalize(options, opts) {
|
|
|
10650
10679
|
if (!rawOptions.parser) {
|
|
10651
10680
|
if (!rawOptions.filepath) {
|
|
10652
10681
|
var logger = opts.logger || console;
|
|
10653
|
-
logger.warn("No parser and no filepath given, using '
|
|
10654
|
-
rawOptions.parser = "
|
|
10682
|
+
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.");
|
|
10683
|
+
rawOptions.parser = "babel";
|
|
10655
10684
|
} else {
|
|
10656
10685
|
rawOptions.parser = inferParser(rawOptions.filepath, rawOptions.plugins);
|
|
10657
10686
|
|
|
@@ -10993,9 +11022,12 @@ var docBuilders = {
|
|
|
10993
11022
|
var ansiRegex = createCommonjsModule(function (module) {
|
|
10994
11023
|
'use strict';
|
|
10995
11024
|
|
|
10996
|
-
module.exports = function () {
|
|
10997
|
-
|
|
10998
|
-
|
|
11025
|
+
module.exports = function (options) {
|
|
11026
|
+
options = Object.assign({
|
|
11027
|
+
onlyFirst: false
|
|
11028
|
+
}, options);
|
|
11029
|
+
var pattern = ['[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\\u0007)', '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'].join('|');
|
|
11030
|
+
return new RegExp(pattern, options.onlyFirst ? undefined : 'g');
|
|
10999
11031
|
};
|
|
11000
11032
|
});
|
|
11001
11033
|
|
|
@@ -11037,19 +11069,28 @@ var isFullwidthCodePoint = createCommonjsModule(function (module) {
|
|
|
11037
11069
|
};
|
|
11038
11070
|
});
|
|
11039
11071
|
|
|
11072
|
+
var emojiRegex = function emojiRegex() {
|
|
11073
|
+
// https://mths.be/emoji
|
|
11074
|
+
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;
|
|
11075
|
+
};
|
|
11076
|
+
|
|
11040
11077
|
var stringWidth = createCommonjsModule(function (module) {
|
|
11041
11078
|
'use strict';
|
|
11042
11079
|
|
|
11043
|
-
|
|
11044
|
-
|
|
11080
|
+
var emojiRegex$$1 = emojiRegex();
|
|
11081
|
+
|
|
11082
|
+
module.exports = function (input) {
|
|
11083
|
+
input = input.replace(emojiRegex$$1, ' ');
|
|
11084
|
+
|
|
11085
|
+
if (typeof input !== 'string' || input.length === 0) {
|
|
11045
11086
|
return 0;
|
|
11046
11087
|
}
|
|
11047
11088
|
|
|
11048
|
-
|
|
11089
|
+
input = stripAnsi(input);
|
|
11049
11090
|
var width = 0;
|
|
11050
11091
|
|
|
11051
|
-
for (var i = 0; i <
|
|
11052
|
-
var code =
|
|
11092
|
+
for (var i = 0; i < input.length; i++) {
|
|
11093
|
+
var code = input.codePointAt(i); // Ignore control characters
|
|
11053
11094
|
|
|
11054
11095
|
if (code <= 0x1F || code >= 0x7F && code <= 0x9F) {
|
|
11055
11096
|
continue;
|
|
@@ -11072,13 +11113,6 @@ var stringWidth = createCommonjsModule(function (module) {
|
|
|
11072
11113
|
};
|
|
11073
11114
|
});
|
|
11074
11115
|
|
|
11075
|
-
var emojiRegex$1 = function emojiRegex() {
|
|
11076
|
-
// https://mathiasbynens.be/notes/es-unicode-property-escapes#emoji
|
|
11077
|
-
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;
|
|
11078
|
-
};
|
|
11079
|
-
|
|
11080
|
-
var emojiRegex = emojiRegex$1(); // eslint-disable-next-line no-control-regex
|
|
11081
|
-
|
|
11082
11116
|
var notAsciiRegex = /[^\x20-\x7F]/;
|
|
11083
11117
|
|
|
11084
11118
|
function isExportDeclaration(node) {
|
|
@@ -11600,12 +11634,9 @@ function getStringWidth$1(text) {
|
|
|
11600
11634
|
|
|
11601
11635
|
if (!notAsciiRegex.test(text)) {
|
|
11602
11636
|
return text.length;
|
|
11603
|
-
}
|
|
11604
|
-
// see https://github.com/sindresorhus/string-width/issues/11
|
|
11605
|
-
// for the reason why not implemented in `string-width`
|
|
11606
|
-
|
|
11637
|
+
}
|
|
11607
11638
|
|
|
11608
|
-
return stringWidth(text
|
|
11639
|
+
return stringWidth(text);
|
|
11609
11640
|
}
|
|
11610
11641
|
|
|
11611
11642
|
function hasIgnoreComment(path$$1) {
|
|
@@ -11683,7 +11714,42 @@ function isWithinParentArrayProperty(path$$1, propertyName) {
|
|
|
11683
11714
|
return parent[propertyName][key] === node;
|
|
11684
11715
|
}
|
|
11685
11716
|
|
|
11717
|
+
function replaceEndOfLineWith(text, replacement) {
|
|
11718
|
+
var parts = [];
|
|
11719
|
+
var _iteratorNormalCompletion = true;
|
|
11720
|
+
var _didIteratorError = false;
|
|
11721
|
+
var _iteratorError = undefined;
|
|
11722
|
+
|
|
11723
|
+
try {
|
|
11724
|
+
for (var _iterator = text.split("\n")[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
11725
|
+
var part = _step.value;
|
|
11726
|
+
|
|
11727
|
+
if (parts.length !== 0) {
|
|
11728
|
+
parts.push(replacement);
|
|
11729
|
+
}
|
|
11730
|
+
|
|
11731
|
+
parts.push(part);
|
|
11732
|
+
}
|
|
11733
|
+
} catch (err) {
|
|
11734
|
+
_didIteratorError = true;
|
|
11735
|
+
_iteratorError = err;
|
|
11736
|
+
} finally {
|
|
11737
|
+
try {
|
|
11738
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
11739
|
+
_iterator.return();
|
|
11740
|
+
}
|
|
11741
|
+
} finally {
|
|
11742
|
+
if (_didIteratorError) {
|
|
11743
|
+
throw _iteratorError;
|
|
11744
|
+
}
|
|
11745
|
+
}
|
|
11746
|
+
}
|
|
11747
|
+
|
|
11748
|
+
return parts;
|
|
11749
|
+
}
|
|
11750
|
+
|
|
11686
11751
|
var util$1 = {
|
|
11752
|
+
replaceEndOfLineWith,
|
|
11687
11753
|
getStringWidth: getStringWidth$1,
|
|
11688
11754
|
getMaxContinuousCount,
|
|
11689
11755
|
getPrecedence,
|
|
@@ -12400,23 +12466,23 @@ function traverseDoc(doc, onEnter, onExit, shouldTraverseConditionalGroups) {
|
|
|
12400
12466
|
}
|
|
12401
12467
|
}
|
|
12402
12468
|
|
|
12403
|
-
function mapDoc(doc, cb) {
|
|
12469
|
+
function mapDoc$1(doc, cb) {
|
|
12404
12470
|
if (doc.type === "concat" || doc.type === "fill") {
|
|
12405
12471
|
var parts = doc.parts.map(function (part) {
|
|
12406
|
-
return mapDoc(part, cb);
|
|
12472
|
+
return mapDoc$1(part, cb);
|
|
12407
12473
|
});
|
|
12408
12474
|
return cb(Object.assign({}, doc, {
|
|
12409
12475
|
parts
|
|
12410
12476
|
}));
|
|
12411
12477
|
} else if (doc.type === "if-break") {
|
|
12412
|
-
var breakContents = doc.breakContents && mapDoc(doc.breakContents, cb);
|
|
12413
|
-
var flatContents = doc.flatContents && mapDoc(doc.flatContents, cb);
|
|
12478
|
+
var breakContents = doc.breakContents && mapDoc$1(doc.breakContents, cb);
|
|
12479
|
+
var flatContents = doc.flatContents && mapDoc$1(doc.flatContents, cb);
|
|
12414
12480
|
return cb(Object.assign({}, doc, {
|
|
12415
12481
|
breakContents,
|
|
12416
12482
|
flatContents
|
|
12417
12483
|
}));
|
|
12418
12484
|
} else if (doc.contents) {
|
|
12419
|
-
var contents = mapDoc(doc.contents, cb);
|
|
12485
|
+
var contents = mapDoc$1(doc.contents, cb);
|
|
12420
12486
|
return cb(Object.assign({}, doc, {
|
|
12421
12487
|
contents
|
|
12422
12488
|
}));
|
|
@@ -12545,7 +12611,7 @@ function removeLinesFn(doc) {
|
|
|
12545
12611
|
}
|
|
12546
12612
|
|
|
12547
12613
|
function removeLines(doc) {
|
|
12548
|
-
return mapDoc(doc, removeLinesFn);
|
|
12614
|
+
return mapDoc$1(doc, removeLinesFn);
|
|
12549
12615
|
}
|
|
12550
12616
|
|
|
12551
12617
|
function stripTrailingHardline(doc) {
|
|
@@ -12576,7 +12642,7 @@ var docUtils = {
|
|
|
12576
12642
|
willBreak,
|
|
12577
12643
|
isLineNext,
|
|
12578
12644
|
traverseDoc,
|
|
12579
|
-
mapDoc,
|
|
12645
|
+
mapDoc: mapDoc$1,
|
|
12580
12646
|
propagateBreaks,
|
|
12581
12647
|
removeLines,
|
|
12582
12648
|
stripTrailingHardline
|
|
@@ -12703,7 +12769,7 @@ var doc = {
|
|
|
12703
12769
|
debug: docDebug
|
|
12704
12770
|
};
|
|
12705
12771
|
|
|
12706
|
-
var mapDoc$
|
|
12772
|
+
var mapDoc$2 = doc.utils.mapDoc;
|
|
12707
12773
|
|
|
12708
12774
|
function isNextLineEmpty$1(text, node, options) {
|
|
12709
12775
|
return util$1.isNextLineEmpty(text, node, options.locEnd);
|
|
@@ -12737,7 +12803,7 @@ var utilShared = {
|
|
|
12737
12803
|
isNextLineEmptyAfterIndex: util$1.isNextLineEmptyAfterIndex,
|
|
12738
12804
|
isPreviousLineEmpty: isPreviousLineEmpty$2,
|
|
12739
12805
|
getNextNonSpaceNonCommentCharacterIndex: getNextNonSpaceNonCommentCharacterIndex$1,
|
|
12740
|
-
mapDoc: mapDoc$
|
|
12806
|
+
mapDoc: mapDoc$2,
|
|
12741
12807
|
// TODO: remove in 2.0, we already exposed it in docUtils
|
|
12742
12808
|
makeString: util$1.makeString,
|
|
12743
12809
|
addLeadingComment: util$1.addLeadingComment,
|
|
@@ -13074,7 +13140,7 @@ function findExpressionIndexForComment(quasis, comment, options) {
|
|
|
13074
13140
|
|
|
13075
13141
|
function getQuasiRange(expr) {
|
|
13076
13142
|
if (expr.start !== undefined) {
|
|
13077
|
-
//
|
|
13143
|
+
// Babel
|
|
13078
13144
|
return {
|
|
13079
13145
|
start: expr.start,
|
|
13080
13146
|
end: expr.end
|
|
@@ -13254,17 +13320,20 @@ FastPath.prototype.getValue = function getValue() {
|
|
|
13254
13320
|
};
|
|
13255
13321
|
|
|
13256
13322
|
function getNodeHelper(path$$1, count) {
|
|
13257
|
-
var
|
|
13323
|
+
var stackIndex = getNodeStackIndexHelper(path$$1.stack, count);
|
|
13324
|
+
return stackIndex === -1 ? null : path$$1.stack[stackIndex];
|
|
13325
|
+
}
|
|
13258
13326
|
|
|
13259
|
-
|
|
13260
|
-
|
|
13327
|
+
function getNodeStackIndexHelper(stack, count) {
|
|
13328
|
+
for (var i = stack.length - 1; i >= 0; i -= 2) {
|
|
13329
|
+
var value = stack[i];
|
|
13261
13330
|
|
|
13262
13331
|
if (value && !Array.isArray(value) && --count < 0) {
|
|
13263
|
-
return
|
|
13332
|
+
return i;
|
|
13264
13333
|
}
|
|
13265
13334
|
}
|
|
13266
13335
|
|
|
13267
|
-
return
|
|
13336
|
+
return -1;
|
|
13268
13337
|
}
|
|
13269
13338
|
|
|
13270
13339
|
FastPath.prototype.getNode = function getNode(count) {
|
|
@@ -13297,6 +13366,14 @@ FastPath.prototype.call = function call(callback
|
|
|
13297
13366
|
var result = callback(this);
|
|
13298
13367
|
s.length = origLen;
|
|
13299
13368
|
return result;
|
|
13369
|
+
};
|
|
13370
|
+
|
|
13371
|
+
FastPath.prototype.callParent = function callParent(callback, count) {
|
|
13372
|
+
var stackIndex = getNodeStackIndexHelper(this.stack, ~~count + 1);
|
|
13373
|
+
var parentValues = this.stack.splice(stackIndex + 1);
|
|
13374
|
+
var result = callback(this);
|
|
13375
|
+
Array.prototype.push.apply(this.stack, parentValues);
|
|
13376
|
+
return result;
|
|
13300
13377
|
}; // Similar to FastPath.prototype.call, except that the value obtained by
|
|
13301
13378
|
// accessing this.getValue()[name1][name2]... should be array-like. The
|
|
13302
13379
|
// callback will be called with a reference to this path object for each
|
|
@@ -13465,7 +13542,7 @@ function printAstToDoc(ast, options) {
|
|
|
13465
13542
|
if (alignmentSize > 0) {
|
|
13466
13543
|
// Add a hardline to make the indents take effect
|
|
13467
13544
|
// It should be removed in index.js format()
|
|
13468
|
-
doc$$2 = addAlignmentToDoc$1(
|
|
13545
|
+
doc$$2 = addAlignmentToDoc$1(concat$3([hardline$2, doc$$2]), alignmentSize, options.tabWidth);
|
|
13469
13546
|
}
|
|
13470
13547
|
|
|
13471
13548
|
docUtils$2.propagateBreaks(doc$$2);
|
|
@@ -13648,7 +13725,7 @@ function isSourceElement(opts, node) {
|
|
|
13648
13725
|
|
|
13649
13726
|
switch (opts.parser) {
|
|
13650
13727
|
case "flow":
|
|
13651
|
-
case "
|
|
13728
|
+
case "babel":
|
|
13652
13729
|
case "typescript":
|
|
13653
13730
|
return jsSourceElements.indexOf(node.type) > -1;
|
|
13654
13731
|
|
|
@@ -13711,10 +13788,16 @@ var rangeUtil = {
|
|
|
13711
13788
|
var normalizeOptions = options.normalize;
|
|
13712
13789
|
var guessEndOfLine = endOfLine.guessEndOfLine;
|
|
13713
13790
|
var convertEndOfLineToChars = endOfLine.convertEndOfLineToChars;
|
|
13791
|
+
var mapDoc = doc.utils.mapDoc;
|
|
13714
13792
|
var printDocToString = doc.printer.printDocToString;
|
|
13715
13793
|
var printDocToDebug = doc.debug.printDocToDebug;
|
|
13716
13794
|
var UTF8BOM = 0xfeff;
|
|
13717
13795
|
var CURSOR = Symbol("cursor");
|
|
13796
|
+
var PLACEHOLDERS = {
|
|
13797
|
+
cursorOffset: "<<<PRETTIER_CURSOR>>>",
|
|
13798
|
+
rangeStart: "<<<PRETTIER_RANGE_START>>>",
|
|
13799
|
+
rangeEnd: "<<<PRETTIER_RANGE_END>>>"
|
|
13800
|
+
};
|
|
13718
13801
|
|
|
13719
13802
|
function ensureAllCommentsPrinted(astComments) {
|
|
13720
13803
|
if (!astComments) {
|
|
@@ -13762,7 +13845,6 @@ function coreFormat(text, opts, addAlignmentSize) {
|
|
|
13762
13845
|
addAlignmentSize = addAlignmentSize || 0;
|
|
13763
13846
|
var parsed = parser.parse(text, opts);
|
|
13764
13847
|
var ast = parsed.ast;
|
|
13765
|
-
var originalText = text;
|
|
13766
13848
|
text = parsed.text;
|
|
13767
13849
|
|
|
13768
13850
|
if (opts.cursorOffset >= 0) {
|
|
@@ -13775,12 +13857,10 @@ function coreFormat(text, opts, addAlignmentSize) {
|
|
|
13775
13857
|
|
|
13776
13858
|
var astComments = attachComments(text, ast, opts);
|
|
13777
13859
|
var doc$$1 = astToDoc(ast, opts, addAlignmentSize);
|
|
13778
|
-
|
|
13779
|
-
|
|
13780
|
-
|
|
13781
|
-
}
|
|
13782
|
-
|
|
13783
|
-
var result = printDocToString(doc$$1, opts);
|
|
13860
|
+
var eol = convertEndOfLineToChars(opts.endOfLine);
|
|
13861
|
+
var result = printDocToString(opts.endOfLine === "lf" ? doc$$1 : mapDoc(doc$$1, function (currentDoc) {
|
|
13862
|
+
return typeof currentDoc === "string" && currentDoc.indexOf("\n") !== -1 ? currentDoc.replace(/\n/g, eol) : currentDoc;
|
|
13863
|
+
}), opts);
|
|
13784
13864
|
ensureAllCommentsPrinted(astComments); // Remove extra leading indentation as well as the added indentation after last newline
|
|
13785
13865
|
|
|
13786
13866
|
if (addAlignmentSize > 0) {
|
|
@@ -13894,7 +13974,8 @@ function formatRange(text, opts) {
|
|
|
13894
13974
|
// we need to remove the newline that was inserted by the `format` call.
|
|
13895
13975
|
|
|
13896
13976
|
var rangeTrimmed = rangeResult.formatted.trimRight();
|
|
13897
|
-
var
|
|
13977
|
+
var rangeLeft = text.slice(0, rangeStart);
|
|
13978
|
+
var rangeRight = text.slice(rangeEnd);
|
|
13898
13979
|
var cursorOffset = opts.cursorOffset;
|
|
13899
13980
|
|
|
13900
13981
|
if (opts.cursorOffset >= rangeEnd) {
|
|
@@ -13906,6 +13987,42 @@ function formatRange(text, opts) {
|
|
|
13906
13987
|
} // keep the cursor as it was if it was before the start of the range
|
|
13907
13988
|
|
|
13908
13989
|
|
|
13990
|
+
var formatted;
|
|
13991
|
+
|
|
13992
|
+
if (opts.endOfLine === "lf") {
|
|
13993
|
+
formatted = rangeLeft + rangeTrimmed + rangeRight;
|
|
13994
|
+
} else {
|
|
13995
|
+
var eol = convertEndOfLineToChars(opts.endOfLine);
|
|
13996
|
+
|
|
13997
|
+
if (cursorOffset >= 0) {
|
|
13998
|
+
var parts = [rangeLeft, rangeTrimmed, rangeRight];
|
|
13999
|
+
var partIndex = 0;
|
|
14000
|
+
var partOffset = cursorOffset;
|
|
14001
|
+
|
|
14002
|
+
while (partIndex < parts.length) {
|
|
14003
|
+
var part = parts[partIndex];
|
|
14004
|
+
|
|
14005
|
+
if (partOffset < part.length) {
|
|
14006
|
+
parts[partIndex] = parts[partIndex].slice(0, partOffset) + PLACEHOLDERS.cursorOffset + parts[partIndex].slice(partOffset);
|
|
14007
|
+
break;
|
|
14008
|
+
}
|
|
14009
|
+
|
|
14010
|
+
partIndex++;
|
|
14011
|
+
partOffset -= part.length;
|
|
14012
|
+
}
|
|
14013
|
+
|
|
14014
|
+
var newRangeLeft = parts[0],
|
|
14015
|
+
newRangeTrimmed = parts[1],
|
|
14016
|
+
newRangeRight = parts[2];
|
|
14017
|
+
formatted = (newRangeLeft.replace(/\n/g, eol) + newRangeTrimmed + newRangeRight.replace(/\n/g, eol)).replace(PLACEHOLDERS.cursorOffset, function (_, index) {
|
|
14018
|
+
cursorOffset = index;
|
|
14019
|
+
return "";
|
|
14020
|
+
});
|
|
14021
|
+
} else {
|
|
14022
|
+
formatted = rangeLeft.replace(/\n/g, eol) + rangeTrimmed + rangeRight.replace(/\n/g, eol);
|
|
14023
|
+
}
|
|
14024
|
+
}
|
|
14025
|
+
|
|
13909
14026
|
return {
|
|
13910
14027
|
formatted,
|
|
13911
14028
|
cursorOffset
|
|
@@ -13922,24 +14039,77 @@ function format(text, opts) {
|
|
|
13922
14039
|
};
|
|
13923
14040
|
}
|
|
13924
14041
|
|
|
13925
|
-
if (opts.
|
|
13926
|
-
|
|
14042
|
+
if (opts.endOfLine === "auto") {
|
|
14043
|
+
opts.endOfLine = guessEndOfLine(text);
|
|
14044
|
+
}
|
|
14045
|
+
|
|
14046
|
+
var hasCursor = opts.cursorOffset >= 0;
|
|
14047
|
+
var hasRangeStart = opts.rangeStart > 0;
|
|
14048
|
+
var hasRangeEnd = opts.rangeEnd < text.length; // get rid of CR/CRLF parsing
|
|
14049
|
+
|
|
14050
|
+
if (text.indexOf("\r") !== -1) {
|
|
14051
|
+
var offsetKeys = [hasCursor && "cursorOffset", hasRangeStart && "rangeStart", hasRangeEnd && "rangeEnd"].filter(Boolean).sort(function (aKey, bKey) {
|
|
14052
|
+
return opts[aKey] - opts[bKey];
|
|
14053
|
+
});
|
|
14054
|
+
|
|
14055
|
+
for (var i = offsetKeys.length - 1; i >= 0; i--) {
|
|
14056
|
+
var key = offsetKeys[i];
|
|
14057
|
+
text = text.slice(0, opts[key]) + PLACEHOLDERS[key] + text.slice(opts[key]);
|
|
14058
|
+
}
|
|
14059
|
+
|
|
14060
|
+
text = text.replace(/\r\n?/g, "\n");
|
|
14061
|
+
|
|
14062
|
+
var _loop = function _loop(_i) {
|
|
14063
|
+
var key = offsetKeys[_i];
|
|
14064
|
+
text = text.replace(PLACEHOLDERS[key], function (_, index) {
|
|
14065
|
+
opts[key] = index;
|
|
14066
|
+
return "";
|
|
14067
|
+
});
|
|
14068
|
+
};
|
|
14069
|
+
|
|
14070
|
+
for (var _i = 0; _i < offsetKeys.length; _i++) {
|
|
14071
|
+
_loop(_i);
|
|
14072
|
+
}
|
|
13927
14073
|
}
|
|
13928
14074
|
|
|
13929
14075
|
var hasUnicodeBOM = text.charCodeAt(0) === UTF8BOM;
|
|
13930
14076
|
|
|
13931
14077
|
if (hasUnicodeBOM) {
|
|
13932
14078
|
text = text.substring(1);
|
|
14079
|
+
|
|
14080
|
+
if (hasCursor) {
|
|
14081
|
+
opts.cursorOffset++;
|
|
14082
|
+
}
|
|
14083
|
+
|
|
14084
|
+
if (hasRangeStart) {
|
|
14085
|
+
opts.rangeStart++;
|
|
14086
|
+
}
|
|
14087
|
+
|
|
14088
|
+
if (hasRangeEnd) {
|
|
14089
|
+
opts.rangeEnd++;
|
|
14090
|
+
}
|
|
14091
|
+
}
|
|
14092
|
+
|
|
14093
|
+
if (!hasCursor) {
|
|
14094
|
+
opts.cursorOffset = -1;
|
|
13933
14095
|
}
|
|
13934
14096
|
|
|
13935
|
-
if (opts.
|
|
13936
|
-
|
|
14097
|
+
if (opts.rangeStart < 0) {
|
|
14098
|
+
opts.rangeStart = 0;
|
|
13937
14099
|
}
|
|
13938
14100
|
|
|
13939
|
-
|
|
14101
|
+
if (opts.rangeEnd > text.length) {
|
|
14102
|
+
opts.rangeEnd = text.length;
|
|
14103
|
+
}
|
|
14104
|
+
|
|
14105
|
+
var result = hasRangeStart || hasRangeEnd ? formatRange(text, opts) : coreFormat(opts.insertPragma && opts.printer.insertPragma && !hasPragma ? opts.printer.insertPragma(text) : text, opts);
|
|
13940
14106
|
|
|
13941
14107
|
if (hasUnicodeBOM) {
|
|
13942
14108
|
result.formatted = String.fromCharCode(UTF8BOM) + result.formatted;
|
|
14109
|
+
|
|
14110
|
+
if (hasCursor) {
|
|
14111
|
+
result.cursorOffset++;
|
|
14112
|
+
}
|
|
13943
14113
|
}
|
|
13944
14114
|
|
|
13945
14115
|
return result;
|
|
@@ -13953,6 +14123,11 @@ var core = {
|
|
|
13953
14123
|
|
|
13954
14124
|
parse(text, opts, massage) {
|
|
13955
14125
|
opts = normalizeOptions(opts);
|
|
14126
|
+
|
|
14127
|
+
if (text.indexOf("\r") !== -1) {
|
|
14128
|
+
text = text.replace(/\r\n?/g, "\n");
|
|
14129
|
+
}
|
|
14130
|
+
|
|
13956
14131
|
var parsed = parser.parse(text, opts);
|
|
13957
14132
|
|
|
13958
14133
|
if (massage) {
|
|
@@ -13972,7 +14147,7 @@ var core = {
|
|
|
13972
14147
|
formatDoc(doc$$1, opts) {
|
|
13973
14148
|
var debug = printDocToDebug(doc$$1);
|
|
13974
14149
|
opts = normalizeOptions(Object.assign({}, opts, {
|
|
13975
|
-
parser: "
|
|
14150
|
+
parser: "babel"
|
|
13976
14151
|
}));
|
|
13977
14152
|
return format(debug, opts).formatted;
|
|
13978
14153
|
},
|
|
@@ -21211,294 +21386,793 @@ var resolve$1 = createCommonjsModule(function (module, exports) {
|
|
|
21211
21386
|
module.exports = async;
|
|
21212
21387
|
});
|
|
21213
21388
|
|
|
21214
|
-
var
|
|
21215
|
-
var
|
|
21216
|
-
var
|
|
21217
|
-
var hardline$4 = _require$$0$builders$1.hardline;
|
|
21218
|
-
var softline$2 = _require$$0$builders$1.softline;
|
|
21219
|
-
var literalline$2 = _require$$0$builders$1.literalline;
|
|
21220
|
-
var concat$5 = _require$$0$builders$1.concat;
|
|
21221
|
-
var group$2 = _require$$0$builders$1.group;
|
|
21222
|
-
var dedentToRoot$1 = _require$$0$builders$1.dedentToRoot;
|
|
21223
|
-
var _require$$0$utils = doc.utils;
|
|
21224
|
-
var mapDoc$2 = _require$$0$utils.mapDoc;
|
|
21225
|
-
var stripTrailingHardline$1 = _require$$0$utils.stripTrailingHardline;
|
|
21226
|
-
|
|
21227
|
-
function embed(path$$1, print, textToDoc
|
|
21228
|
-
/*, options */
|
|
21229
|
-
) {
|
|
21230
|
-
var node = path$$1.getValue();
|
|
21231
|
-
var parent = path$$1.getParentNode();
|
|
21232
|
-
var parentParent = path$$1.getParentNode(1);
|
|
21233
|
-
|
|
21234
|
-
switch (node.type) {
|
|
21235
|
-
case "TemplateLiteral":
|
|
21236
|
-
{
|
|
21237
|
-
var isCss = [isStyledJsx, isStyledComponents, isCssProp, isAngularComponentStyles].some(function (isIt) {
|
|
21238
|
-
return isIt(path$$1);
|
|
21239
|
-
});
|
|
21240
|
-
|
|
21241
|
-
if (isCss) {
|
|
21242
|
-
// Get full template literal with expressions replaced by placeholders
|
|
21243
|
-
var rawQuasis = node.quasis.map(function (q) {
|
|
21244
|
-
return q.value.raw;
|
|
21245
|
-
});
|
|
21246
|
-
var placeholderID = 0;
|
|
21247
|
-
var text = rawQuasis.reduce(function (prevVal, currVal, idx) {
|
|
21248
|
-
return idx == 0 ? currVal : prevVal + "@prettier-placeholder-" + placeholderID++ + "-id" + currVal;
|
|
21249
|
-
}, "");
|
|
21250
|
-
var doc$$2 = textToDoc(text, {
|
|
21251
|
-
parser: "css"
|
|
21252
|
-
});
|
|
21253
|
-
return transformCssDoc(doc$$2, path$$1, print);
|
|
21254
|
-
}
|
|
21255
|
-
/*
|
|
21256
|
-
* react-relay and graphql-tag
|
|
21257
|
-
* graphql`...`
|
|
21258
|
-
* graphql.experimental`...`
|
|
21259
|
-
* gql`...`
|
|
21260
|
-
*
|
|
21261
|
-
* This intentionally excludes Relay Classic tags, as Prettier does not
|
|
21262
|
-
* support Relay Classic formatting.
|
|
21263
|
-
*/
|
|
21389
|
+
var addLeadingComment$2 = utilShared.addLeadingComment;
|
|
21390
|
+
var addTrailingComment$2 = utilShared.addTrailingComment;
|
|
21391
|
+
var addDanglingComment$2 = utilShared.addDanglingComment;
|
|
21264
21392
|
|
|
21393
|
+
function handleOwnLineComment(comment, text, options, ast, isLastComment) {
|
|
21394
|
+
var precedingNode = comment.precedingNode,
|
|
21395
|
+
enclosingNode = comment.enclosingNode,
|
|
21396
|
+
followingNode = comment.followingNode;
|
|
21265
21397
|
|
|
21266
|
-
|
|
21267
|
-
|
|
21268
|
-
|
|
21398
|
+
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)) {
|
|
21399
|
+
return true;
|
|
21400
|
+
}
|
|
21269
21401
|
|
|
21270
|
-
|
|
21271
|
-
|
|
21272
|
-
}
|
|
21402
|
+
return false;
|
|
21403
|
+
}
|
|
21273
21404
|
|
|
21274
|
-
|
|
21405
|
+
function handleEndOfLineComment(comment, text, options, ast, isLastComment) {
|
|
21406
|
+
var precedingNode = comment.precedingNode,
|
|
21407
|
+
enclosingNode = comment.enclosingNode,
|
|
21408
|
+
followingNode = comment.followingNode;
|
|
21275
21409
|
|
|
21276
|
-
|
|
21277
|
-
|
|
21278
|
-
|
|
21279
|
-
var isLast = i === numQuasis - 1;
|
|
21280
|
-
var _text = templateElement.value.cooked; // Bail out if any of the quasis have an invalid escape sequence
|
|
21281
|
-
// (which would make the `cooked` value be `null` or `undefined`)
|
|
21410
|
+
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)) {
|
|
21411
|
+
return true;
|
|
21412
|
+
}
|
|
21282
21413
|
|
|
21283
|
-
|
|
21284
|
-
|
|
21285
|
-
}
|
|
21414
|
+
return false;
|
|
21415
|
+
}
|
|
21286
21416
|
|
|
21287
|
-
|
|
21417
|
+
function handleRemainingComment(comment, text, options, ast, isLastComment) {
|
|
21418
|
+
var precedingNode = comment.precedingNode,
|
|
21419
|
+
enclosingNode = comment.enclosingNode,
|
|
21420
|
+
followingNode = comment.followingNode;
|
|
21288
21421
|
|
|
21289
|
-
|
|
21290
|
-
|
|
21291
|
-
|
|
21292
|
-
var endsWithBlankLine = numLines > 2 && lines[numLines - 1].trim() === "" && lines[numLines - 2].trim() === "";
|
|
21293
|
-
var commentsAndWhitespaceOnly = lines.every(function (line) {
|
|
21294
|
-
return /^\s*(?:#[^\r\n]*)?$/.test(line);
|
|
21295
|
-
}); // Bail out if an interpolation occurs within a comment.
|
|
21422
|
+
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)) {
|
|
21423
|
+
return true;
|
|
21424
|
+
}
|
|
21296
21425
|
|
|
21297
|
-
|
|
21298
|
-
|
|
21299
|
-
}
|
|
21426
|
+
return false;
|
|
21427
|
+
}
|
|
21300
21428
|
|
|
21301
|
-
|
|
21429
|
+
function addBlockStatementFirstComment(node, comment) {
|
|
21430
|
+
var body = node.body.filter(function (n) {
|
|
21431
|
+
return n.type !== "EmptyStatement";
|
|
21432
|
+
});
|
|
21302
21433
|
|
|
21303
|
-
|
|
21304
|
-
|
|
21305
|
-
|
|
21306
|
-
|
|
21307
|
-
|
|
21308
|
-
|
|
21309
|
-
}
|
|
21434
|
+
if (body.length === 0) {
|
|
21435
|
+
addDanglingComment$2(node, comment);
|
|
21436
|
+
} else {
|
|
21437
|
+
addLeadingComment$2(body[0], comment);
|
|
21438
|
+
}
|
|
21439
|
+
}
|
|
21310
21440
|
|
|
21311
|
-
|
|
21312
|
-
|
|
21441
|
+
function addBlockOrNotComment(node, comment) {
|
|
21442
|
+
if (node.type === "BlockStatement") {
|
|
21443
|
+
addBlockStatementFirstComment(node, comment);
|
|
21444
|
+
} else {
|
|
21445
|
+
addLeadingComment$2(node, comment);
|
|
21446
|
+
}
|
|
21447
|
+
} // There are often comments before the else clause of if statements like
|
|
21448
|
+
//
|
|
21449
|
+
// if (1) { ... }
|
|
21450
|
+
// // comment
|
|
21451
|
+
// else { ... }
|
|
21452
|
+
//
|
|
21453
|
+
// They are being attached as leading comments of the BlockExpression which
|
|
21454
|
+
// is not well printed. What we want is to instead move the comment inside
|
|
21455
|
+
// of the block and make it leadingComment of the first element of the block
|
|
21456
|
+
// or dangling comment of the block if there is nothing inside
|
|
21457
|
+
//
|
|
21458
|
+
// if (1) { ... }
|
|
21459
|
+
// else {
|
|
21460
|
+
// // comment
|
|
21461
|
+
// ...
|
|
21462
|
+
// }
|
|
21313
21463
|
|
|
21314
|
-
if (!isFirst && startsWithBlankLine) {
|
|
21315
|
-
parts.push("");
|
|
21316
|
-
}
|
|
21317
21464
|
|
|
21318
|
-
|
|
21465
|
+
function handleIfStatementComments(text, precedingNode, enclosingNode, followingNode, comment, options) {
|
|
21466
|
+
if (!enclosingNode || enclosingNode.type !== "IfStatement" || !followingNode) {
|
|
21467
|
+
return false;
|
|
21468
|
+
} // We unfortunately have no way using the AST or location of nodes to know
|
|
21469
|
+
// if the comment is positioned before the condition parenthesis:
|
|
21470
|
+
// if (a /* comment */) {}
|
|
21471
|
+
// The only workaround I found is to look at the next character to see if
|
|
21472
|
+
// it is a ).
|
|
21319
21473
|
|
|
21320
|
-
if (!isLast && endsWithBlankLine) {
|
|
21321
|
-
parts.push("");
|
|
21322
|
-
}
|
|
21323
|
-
} else if (!isFirst && !isLast && startsWithBlankLine) {
|
|
21324
|
-
parts.push("");
|
|
21325
|
-
}
|
|
21326
21474
|
|
|
21327
|
-
|
|
21328
|
-
parts.push(concat$5(["${", expressionDoc, "}"]));
|
|
21329
|
-
}
|
|
21330
|
-
}
|
|
21475
|
+
var nextCharacter = util$1.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd);
|
|
21331
21476
|
|
|
21332
|
-
|
|
21333
|
-
|
|
21477
|
+
if (nextCharacter === ")") {
|
|
21478
|
+
addTrailingComment$2(precedingNode, comment);
|
|
21479
|
+
return true;
|
|
21480
|
+
} // Comments before `else`:
|
|
21481
|
+
// - treat as trailing comments of the consequent, if it's a BlockStatement
|
|
21482
|
+
// - treat as a dangling comment otherwise
|
|
21334
21483
|
|
|
21335
|
-
if (isHtml(path$$1)) {
|
|
21336
|
-
return printHtmlTemplateLiteral(path$$1, print, textToDoc, "html");
|
|
21337
|
-
}
|
|
21338
21484
|
|
|
21339
|
-
|
|
21340
|
-
|
|
21341
|
-
|
|
21485
|
+
if (precedingNode === enclosingNode.consequent && followingNode === enclosingNode.alternate) {
|
|
21486
|
+
if (precedingNode.type === "BlockStatement") {
|
|
21487
|
+
addTrailingComment$2(precedingNode, comment);
|
|
21488
|
+
} else {
|
|
21489
|
+
addDanglingComment$2(enclosingNode, comment);
|
|
21490
|
+
}
|
|
21342
21491
|
|
|
21343
|
-
|
|
21344
|
-
|
|
21492
|
+
return true;
|
|
21493
|
+
}
|
|
21345
21494
|
|
|
21346
|
-
|
|
21347
|
-
|
|
21348
|
-
|
|
21349
|
-
|
|
21350
|
-
* markdown`...`
|
|
21351
|
-
*/
|
|
21352
|
-
if (parentParent && parentParent.type === "TaggedTemplateExpression" && parent.quasis.length === 1 && parentParent.tag.type === "Identifier" && (parentParent.tag.name === "md" || parentParent.tag.name === "markdown")) {
|
|
21353
|
-
var _text2 = parent.quasis[0].value.raw.replace(/((?:\\\\)*)\\`/g, function (_, backslashes) {
|
|
21354
|
-
return "\\".repeat(backslashes.length / 2) + "`";
|
|
21355
|
-
});
|
|
21495
|
+
if (followingNode.type === "BlockStatement") {
|
|
21496
|
+
addBlockStatementFirstComment(followingNode, comment);
|
|
21497
|
+
return true;
|
|
21498
|
+
}
|
|
21356
21499
|
|
|
21357
|
-
|
|
21358
|
-
|
|
21359
|
-
|
|
21360
|
-
|
|
21500
|
+
if (followingNode.type === "IfStatement") {
|
|
21501
|
+
addBlockOrNotComment(followingNode.consequent, comment);
|
|
21502
|
+
return true;
|
|
21503
|
+
} // For comments positioned after the condition parenthesis in an if statement
|
|
21504
|
+
// before the consequent without brackets on, such as
|
|
21505
|
+
// if (a) /* comment */ true,
|
|
21506
|
+
// we look at the next character to see if the following node
|
|
21507
|
+
// is the consequent for the if statement
|
|
21361
21508
|
|
|
21362
|
-
break;
|
|
21363
|
-
}
|
|
21364
|
-
}
|
|
21365
21509
|
|
|
21366
|
-
|
|
21367
|
-
|
|
21368
|
-
|
|
21369
|
-
__inJsTemplate: true
|
|
21370
|
-
});
|
|
21371
|
-
return stripTrailingHardline$1(escapeTemplateCharacters(doc$$2, true));
|
|
21510
|
+
if (enclosingNode.consequent === followingNode) {
|
|
21511
|
+
addLeadingComment$2(followingNode, comment);
|
|
21512
|
+
return true;
|
|
21372
21513
|
}
|
|
21373
|
-
}
|
|
21374
21514
|
|
|
21375
|
-
|
|
21376
|
-
var firstMatchedIndent = str.match(/^([^\S\n]*)\S/m);
|
|
21377
|
-
return firstMatchedIndent === null ? "" : firstMatchedIndent[1];
|
|
21515
|
+
return false;
|
|
21378
21516
|
}
|
|
21379
21517
|
|
|
21380
|
-
function
|
|
21381
|
-
|
|
21382
|
-
|
|
21383
|
-
|
|
21384
|
-
|
|
21518
|
+
function handleWhileComments(text, precedingNode, enclosingNode, followingNode, comment, options) {
|
|
21519
|
+
if (!enclosingNode || enclosingNode.type !== "WhileStatement" || !followingNode) {
|
|
21520
|
+
return false;
|
|
21521
|
+
} // We unfortunately have no way using the AST or location of nodes to know
|
|
21522
|
+
// if the comment is positioned before the condition parenthesis:
|
|
21523
|
+
// while (a /* comment */) {}
|
|
21524
|
+
// The only workaround I found is to look at the next character to see if
|
|
21525
|
+
// it is a ).
|
|
21385
21526
|
|
|
21386
|
-
var parts = [];
|
|
21387
|
-
currentDoc.parts.forEach(function (part) {
|
|
21388
|
-
if (typeof part === "string") {
|
|
21389
|
-
parts.push(raw ? part.replace(/(\\*)`/g, "$1$1\\`") : part.replace(/([\\`]|\$\{)/g, "\\$1"));
|
|
21390
|
-
} else {
|
|
21391
|
-
parts.push(part);
|
|
21392
|
-
}
|
|
21393
|
-
});
|
|
21394
|
-
return Object.assign({}, currentDoc, {
|
|
21395
|
-
parts
|
|
21396
|
-
});
|
|
21397
|
-
});
|
|
21398
|
-
}
|
|
21399
21527
|
|
|
21400
|
-
|
|
21401
|
-
var parentNode = path$$1.getValue();
|
|
21402
|
-
var isEmpty = parentNode.quasis.length === 1 && !parentNode.quasis[0].value.raw.trim();
|
|
21528
|
+
var nextCharacter = util$1.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd);
|
|
21403
21529
|
|
|
21404
|
-
if (
|
|
21405
|
-
|
|
21530
|
+
if (nextCharacter === ")") {
|
|
21531
|
+
addTrailingComment$2(precedingNode, comment);
|
|
21532
|
+
return true;
|
|
21406
21533
|
}
|
|
21407
21534
|
|
|
21408
|
-
|
|
21409
|
-
|
|
21410
|
-
|
|
21411
|
-
|
|
21412
|
-
if (!newDoc) {
|
|
21413
|
-
throw new Error("Couldn't insert all the expressions");
|
|
21535
|
+
if (followingNode.type === "BlockStatement") {
|
|
21536
|
+
addBlockStatementFirstComment(followingNode, comment);
|
|
21537
|
+
return true;
|
|
21414
21538
|
}
|
|
21415
21539
|
|
|
21416
|
-
return
|
|
21417
|
-
} //
|
|
21418
|
-
// and replace them with the expression docs one by one
|
|
21419
|
-
// returns a new doc with all the placeholders replaced,
|
|
21420
|
-
// or null if it couldn't replace any expression
|
|
21540
|
+
return false;
|
|
21541
|
+
} // Same as IfStatement but for TryStatement
|
|
21421
21542
|
|
|
21422
21543
|
|
|
21423
|
-
function
|
|
21424
|
-
if (!
|
|
21425
|
-
return
|
|
21544
|
+
function handleTryStatementComments(enclosingNode, precedingNode, followingNode, comment) {
|
|
21545
|
+
if (!enclosingNode || enclosingNode.type !== "TryStatement" && enclosingNode.type !== "CatchClause" || !followingNode) {
|
|
21546
|
+
return false;
|
|
21426
21547
|
}
|
|
21427
21548
|
|
|
21428
|
-
|
|
21429
|
-
|
|
21430
|
-
|
|
21431
|
-
|
|
21432
|
-
return doc$$2;
|
|
21433
|
-
}
|
|
21549
|
+
if (enclosingNode.type === "CatchClause" && precedingNode) {
|
|
21550
|
+
addTrailingComment$2(precedingNode, comment);
|
|
21551
|
+
return true;
|
|
21552
|
+
}
|
|
21434
21553
|
|
|
21435
|
-
|
|
21436
|
-
|
|
21437
|
-
|
|
21554
|
+
if (followingNode.type === "BlockStatement") {
|
|
21555
|
+
addBlockStatementFirstComment(followingNode, comment);
|
|
21556
|
+
return true;
|
|
21557
|
+
}
|
|
21438
21558
|
|
|
21439
|
-
|
|
21440
|
-
|
|
21441
|
-
|
|
21442
|
-
|
|
21443
|
-
var rest = parts.slice(placeholderIndex + 1);
|
|
21444
|
-
parts = parts.slice(0, atIndex).concat([at + placeholder]).concat(rest);
|
|
21445
|
-
}
|
|
21559
|
+
if (followingNode.type === "TryStatement") {
|
|
21560
|
+
addBlockOrNotComment(followingNode.finalizer, comment);
|
|
21561
|
+
return true;
|
|
21562
|
+
}
|
|
21446
21563
|
|
|
21447
|
-
|
|
21448
|
-
|
|
21449
|
-
|
|
21564
|
+
if (followingNode.type === "CatchClause") {
|
|
21565
|
+
addBlockOrNotComment(followingNode.body, comment);
|
|
21566
|
+
return true;
|
|
21567
|
+
}
|
|
21450
21568
|
|
|
21451
|
-
|
|
21452
|
-
|
|
21569
|
+
return false;
|
|
21570
|
+
}
|
|
21453
21571
|
|
|
21454
|
-
|
|
21572
|
+
function handleMemberExpressionComments(enclosingNode, followingNode, comment) {
|
|
21573
|
+
if (enclosingNode && enclosingNode.type === "MemberExpression" && followingNode && followingNode.type === "Identifier") {
|
|
21574
|
+
addLeadingComment$2(enclosingNode, comment);
|
|
21575
|
+
return true;
|
|
21576
|
+
}
|
|
21455
21577
|
|
|
21456
|
-
|
|
21578
|
+
return false;
|
|
21579
|
+
}
|
|
21457
21580
|
|
|
21458
|
-
|
|
21459
|
-
|
|
21581
|
+
function handleConditionalExpressionComments(enclosingNode, precedingNode, followingNode, comment, text, options) {
|
|
21582
|
+
var isSameLineAsPrecedingNode = precedingNode && !util$1.hasNewlineInRange(text, options.locEnd(precedingNode), options.locStart(comment));
|
|
21460
21583
|
|
|
21461
|
-
|
|
21462
|
-
|
|
21463
|
-
|
|
21464
|
-
|
|
21465
|
-
}
|
|
21584
|
+
if ((!precedingNode || !isSameLineAsPrecedingNode) && enclosingNode && enclosingNode.type === "ConditionalExpression" && followingNode) {
|
|
21585
|
+
addLeadingComment$2(followingNode, comment);
|
|
21586
|
+
return true;
|
|
21587
|
+
}
|
|
21466
21588
|
|
|
21467
|
-
|
|
21468
|
-
parts: parts
|
|
21469
|
-
});
|
|
21470
|
-
});
|
|
21471
|
-
return expressions.length === replaceCounter ? newDoc : null;
|
|
21589
|
+
return false;
|
|
21472
21590
|
}
|
|
21473
21591
|
|
|
21474
|
-
function
|
|
21475
|
-
|
|
21476
|
-
|
|
21477
|
-
|
|
21478
|
-
|
|
21479
|
-
}).forEach(function (textLine, i, array) {
|
|
21480
|
-
// Lines are either whitespace only, or a comment (with poential whitespace
|
|
21481
|
-
// around it). Drop whitespace-only lines.
|
|
21482
|
-
if (textLine === "") {
|
|
21483
|
-
return;
|
|
21484
|
-
}
|
|
21592
|
+
function handleObjectPropertyAssignment(enclosingNode, precedingNode, comment) {
|
|
21593
|
+
if (enclosingNode && (enclosingNode.type === "ObjectProperty" || enclosingNode.type === "Property") && enclosingNode.shorthand && enclosingNode.key === precedingNode && enclosingNode.value.type === "AssignmentPattern") {
|
|
21594
|
+
addTrailingComment$2(enclosingNode.value.left, comment);
|
|
21595
|
+
return true;
|
|
21596
|
+
}
|
|
21485
21597
|
|
|
21486
|
-
|
|
21487
|
-
|
|
21488
|
-
|
|
21489
|
-
|
|
21598
|
+
return false;
|
|
21599
|
+
}
|
|
21600
|
+
|
|
21601
|
+
function handleClassComments(enclosingNode, precedingNode, followingNode, comment) {
|
|
21602
|
+
if (enclosingNode && (enclosingNode.type === "ClassDeclaration" || enclosingNode.type === "ClassExpression") && enclosingNode.decorators && enclosingNode.decorators.length > 0 && !(followingNode && followingNode.type === "Decorator")) {
|
|
21603
|
+
if (!enclosingNode.decorators || enclosingNode.decorators.length === 0) {
|
|
21604
|
+
addLeadingComment$2(enclosingNode, comment);
|
|
21490
21605
|
} else {
|
|
21491
|
-
|
|
21606
|
+
addTrailingComment$2(enclosingNode.decorators[enclosingNode.decorators.length - 1], comment);
|
|
21492
21607
|
}
|
|
21493
21608
|
|
|
21494
|
-
|
|
21495
|
-
}
|
|
21609
|
+
return true;
|
|
21610
|
+
}
|
|
21496
21611
|
|
|
21497
|
-
return
|
|
21612
|
+
return false;
|
|
21498
21613
|
}
|
|
21499
|
-
|
|
21500
|
-
|
|
21501
|
-
|
|
21614
|
+
|
|
21615
|
+
function handleMethodNameComments(text, enclosingNode, precedingNode, comment, options) {
|
|
21616
|
+
// This is only needed for estree parsers (flow, typescript) to attach
|
|
21617
|
+
// after a method name:
|
|
21618
|
+
// obj = { fn /*comment*/() {} };
|
|
21619
|
+
if (enclosingNode && precedingNode && (enclosingNode.type === "Property" || enclosingNode.type === "MethodDefinition") && precedingNode.type === "Identifier" && enclosingNode.key === precedingNode && // special Property case: { key: /*comment*/(value) };
|
|
21620
|
+
// comment should be attached to value instead of key
|
|
21621
|
+
util$1.getNextNonSpaceNonCommentCharacter(text, precedingNode, options.locEnd) !== ":") {
|
|
21622
|
+
addTrailingComment$2(precedingNode, comment);
|
|
21623
|
+
return true;
|
|
21624
|
+
} // Print comments between decorators and class methods as a trailing comment
|
|
21625
|
+
// on the decorator node instead of the method node
|
|
21626
|
+
|
|
21627
|
+
|
|
21628
|
+
if (precedingNode && enclosingNode && precedingNode.type === "Decorator" && (enclosingNode.type === "ClassMethod" || enclosingNode.type === "ClassProperty" || enclosingNode.type === "TSAbstractClassProperty" || enclosingNode.type === "TSAbstractMethodDefinition" || enclosingNode.type === "MethodDefinition")) {
|
|
21629
|
+
addTrailingComment$2(precedingNode, comment);
|
|
21630
|
+
return true;
|
|
21631
|
+
}
|
|
21632
|
+
|
|
21633
|
+
return false;
|
|
21634
|
+
}
|
|
21635
|
+
|
|
21636
|
+
function handleFunctionNameComments(text, enclosingNode, precedingNode, comment, options) {
|
|
21637
|
+
if (util$1.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd) !== "(") {
|
|
21638
|
+
return false;
|
|
21639
|
+
}
|
|
21640
|
+
|
|
21641
|
+
if (precedingNode && enclosingNode && (enclosingNode.type === "FunctionDeclaration" || enclosingNode.type === "FunctionExpression" || enclosingNode.type === "ClassMethod" || enclosingNode.type === "MethodDefinition" || enclosingNode.type === "ObjectMethod")) {
|
|
21642
|
+
addTrailingComment$2(precedingNode, comment);
|
|
21643
|
+
return true;
|
|
21644
|
+
}
|
|
21645
|
+
|
|
21646
|
+
return false;
|
|
21647
|
+
}
|
|
21648
|
+
|
|
21649
|
+
function handleCommentAfterArrowParams(text, enclosingNode, comment, options) {
|
|
21650
|
+
if (!(enclosingNode && enclosingNode.type === "ArrowFunctionExpression")) {
|
|
21651
|
+
return false;
|
|
21652
|
+
}
|
|
21653
|
+
|
|
21654
|
+
var index = utilShared.getNextNonSpaceNonCommentCharacterIndex(text, comment, options);
|
|
21655
|
+
|
|
21656
|
+
if (text.substr(index, 2) === "=>") {
|
|
21657
|
+
addDanglingComment$2(enclosingNode, comment);
|
|
21658
|
+
return true;
|
|
21659
|
+
}
|
|
21660
|
+
|
|
21661
|
+
return false;
|
|
21662
|
+
}
|
|
21663
|
+
|
|
21664
|
+
function handleCommentInEmptyParens(text, enclosingNode, comment, options) {
|
|
21665
|
+
if (util$1.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd) !== ")") {
|
|
21666
|
+
return false;
|
|
21667
|
+
} // Only add dangling comments to fix the case when no params are present,
|
|
21668
|
+
// i.e. a function without any argument.
|
|
21669
|
+
|
|
21670
|
+
|
|
21671
|
+
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)) {
|
|
21672
|
+
addDanglingComment$2(enclosingNode, comment);
|
|
21673
|
+
return true;
|
|
21674
|
+
}
|
|
21675
|
+
|
|
21676
|
+
if (enclosingNode && enclosingNode.type === "MethodDefinition" && enclosingNode.value.params.length === 0) {
|
|
21677
|
+
addDanglingComment$2(enclosingNode.value, comment);
|
|
21678
|
+
return true;
|
|
21679
|
+
}
|
|
21680
|
+
|
|
21681
|
+
return false;
|
|
21682
|
+
}
|
|
21683
|
+
|
|
21684
|
+
function handleLastFunctionArgComments(text, precedingNode, enclosingNode, followingNode, comment, options) {
|
|
21685
|
+
// Type definitions functions
|
|
21686
|
+
if (precedingNode && precedingNode.type === "FunctionTypeParam" && enclosingNode && enclosingNode.type === "FunctionTypeAnnotation" && followingNode && followingNode.type !== "FunctionTypeParam") {
|
|
21687
|
+
addTrailingComment$2(precedingNode, comment);
|
|
21688
|
+
return true;
|
|
21689
|
+
} // Real functions
|
|
21690
|
+
|
|
21691
|
+
|
|
21692
|
+
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) === ")") {
|
|
21693
|
+
addTrailingComment$2(precedingNode, comment);
|
|
21694
|
+
return true;
|
|
21695
|
+
}
|
|
21696
|
+
|
|
21697
|
+
if (enclosingNode && enclosingNode.type === "FunctionDeclaration" && followingNode && followingNode.type === "BlockStatement") {
|
|
21698
|
+
var functionParamRightParenIndex = function () {
|
|
21699
|
+
if (enclosingNode.params.length !== 0) {
|
|
21700
|
+
return util$1.getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, options.locEnd(util$1.getLast(enclosingNode.params)));
|
|
21701
|
+
}
|
|
21702
|
+
|
|
21703
|
+
var functionParamLeftParenIndex = util$1.getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, options.locEnd(enclosingNode.id));
|
|
21704
|
+
return util$1.getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, functionParamLeftParenIndex + 1);
|
|
21705
|
+
}();
|
|
21706
|
+
|
|
21707
|
+
if (options.locStart(comment) > functionParamRightParenIndex) {
|
|
21708
|
+
addBlockStatementFirstComment(followingNode, comment);
|
|
21709
|
+
return true;
|
|
21710
|
+
}
|
|
21711
|
+
}
|
|
21712
|
+
|
|
21713
|
+
return false;
|
|
21714
|
+
}
|
|
21715
|
+
|
|
21716
|
+
function handleImportSpecifierComments(enclosingNode, comment) {
|
|
21717
|
+
if (enclosingNode && enclosingNode.type === "ImportSpecifier") {
|
|
21718
|
+
addLeadingComment$2(enclosingNode, comment);
|
|
21719
|
+
return true;
|
|
21720
|
+
}
|
|
21721
|
+
|
|
21722
|
+
return false;
|
|
21723
|
+
}
|
|
21724
|
+
|
|
21725
|
+
function handleLabeledStatementComments(enclosingNode, comment) {
|
|
21726
|
+
if (enclosingNode && enclosingNode.type === "LabeledStatement") {
|
|
21727
|
+
addLeadingComment$2(enclosingNode, comment);
|
|
21728
|
+
return true;
|
|
21729
|
+
}
|
|
21730
|
+
|
|
21731
|
+
return false;
|
|
21732
|
+
}
|
|
21733
|
+
|
|
21734
|
+
function handleBreakAndContinueStatementComments(enclosingNode, comment) {
|
|
21735
|
+
if (enclosingNode && (enclosingNode.type === "ContinueStatement" || enclosingNode.type === "BreakStatement") && !enclosingNode.label) {
|
|
21736
|
+
addTrailingComment$2(enclosingNode, comment);
|
|
21737
|
+
return true;
|
|
21738
|
+
}
|
|
21739
|
+
|
|
21740
|
+
return false;
|
|
21741
|
+
}
|
|
21742
|
+
|
|
21743
|
+
function handleCallExpressionComments(precedingNode, enclosingNode, comment) {
|
|
21744
|
+
if (enclosingNode && enclosingNode.type === "CallExpression" && precedingNode && enclosingNode.callee === precedingNode && enclosingNode.arguments.length > 0) {
|
|
21745
|
+
addLeadingComment$2(enclosingNode.arguments[0], comment);
|
|
21746
|
+
return true;
|
|
21747
|
+
}
|
|
21748
|
+
|
|
21749
|
+
return false;
|
|
21750
|
+
}
|
|
21751
|
+
|
|
21752
|
+
function handleUnionTypeComments(precedingNode, enclosingNode, followingNode, comment) {
|
|
21753
|
+
if (enclosingNode && (enclosingNode.type === "UnionTypeAnnotation" || enclosingNode.type === "TSUnionType")) {
|
|
21754
|
+
addTrailingComment$2(precedingNode, comment);
|
|
21755
|
+
return true;
|
|
21756
|
+
}
|
|
21757
|
+
|
|
21758
|
+
return false;
|
|
21759
|
+
}
|
|
21760
|
+
|
|
21761
|
+
function handlePropertyComments(enclosingNode, comment) {
|
|
21762
|
+
if (enclosingNode && (enclosingNode.type === "Property" || enclosingNode.type === "ObjectProperty")) {
|
|
21763
|
+
addLeadingComment$2(enclosingNode, comment);
|
|
21764
|
+
return true;
|
|
21765
|
+
}
|
|
21766
|
+
|
|
21767
|
+
return false;
|
|
21768
|
+
}
|
|
21769
|
+
|
|
21770
|
+
function handleOnlyComments(enclosingNode, ast, comment, isLastComment) {
|
|
21771
|
+
// With Flow the enclosingNode is undefined so use the AST instead.
|
|
21772
|
+
if (ast && ast.body && ast.body.length === 0) {
|
|
21773
|
+
if (isLastComment) {
|
|
21774
|
+
addDanglingComment$2(ast, comment);
|
|
21775
|
+
} else {
|
|
21776
|
+
addLeadingComment$2(ast, comment);
|
|
21777
|
+
}
|
|
21778
|
+
|
|
21779
|
+
return true;
|
|
21780
|
+
} else if (enclosingNode && enclosingNode.type === "Program" && enclosingNode.body.length === 0 && enclosingNode.directives && enclosingNode.directives.length === 0) {
|
|
21781
|
+
if (isLastComment) {
|
|
21782
|
+
addDanglingComment$2(enclosingNode, comment);
|
|
21783
|
+
} else {
|
|
21784
|
+
addLeadingComment$2(enclosingNode, comment);
|
|
21785
|
+
}
|
|
21786
|
+
|
|
21787
|
+
return true;
|
|
21788
|
+
}
|
|
21789
|
+
|
|
21790
|
+
return false;
|
|
21791
|
+
}
|
|
21792
|
+
|
|
21793
|
+
function handleForComments(enclosingNode, precedingNode, comment) {
|
|
21794
|
+
if (enclosingNode && (enclosingNode.type === "ForInStatement" || enclosingNode.type === "ForOfStatement")) {
|
|
21795
|
+
addLeadingComment$2(enclosingNode, comment);
|
|
21796
|
+
return true;
|
|
21797
|
+
}
|
|
21798
|
+
|
|
21799
|
+
return false;
|
|
21800
|
+
}
|
|
21801
|
+
|
|
21802
|
+
function handleImportDeclarationComments(text, enclosingNode, precedingNode, comment, options) {
|
|
21803
|
+
if (precedingNode && precedingNode.type === "ImportSpecifier" && enclosingNode && enclosingNode.type === "ImportDeclaration" && util$1.hasNewline(text, options.locEnd(comment))) {
|
|
21804
|
+
addTrailingComment$2(precedingNode, comment);
|
|
21805
|
+
return true;
|
|
21806
|
+
}
|
|
21807
|
+
|
|
21808
|
+
return false;
|
|
21809
|
+
}
|
|
21810
|
+
|
|
21811
|
+
function handleAssignmentPatternComments(enclosingNode, comment) {
|
|
21812
|
+
if (enclosingNode && enclosingNode.type === "AssignmentPattern") {
|
|
21813
|
+
addLeadingComment$2(enclosingNode, comment);
|
|
21814
|
+
return true;
|
|
21815
|
+
}
|
|
21816
|
+
|
|
21817
|
+
return false;
|
|
21818
|
+
}
|
|
21819
|
+
|
|
21820
|
+
function handleTypeAliasComments(enclosingNode, followingNode, comment) {
|
|
21821
|
+
if (enclosingNode && enclosingNode.type === "TypeAlias") {
|
|
21822
|
+
addLeadingComment$2(enclosingNode, comment);
|
|
21823
|
+
return true;
|
|
21824
|
+
}
|
|
21825
|
+
|
|
21826
|
+
return false;
|
|
21827
|
+
}
|
|
21828
|
+
|
|
21829
|
+
function handleVariableDeclaratorComments(enclosingNode, followingNode, comment) {
|
|
21830
|
+
if (enclosingNode && (enclosingNode.type === "VariableDeclarator" || enclosingNode.type === "AssignmentExpression") && followingNode && (followingNode.type === "ObjectExpression" || followingNode.type === "ArrayExpression" || followingNode.type === "TemplateLiteral" || followingNode.type === "TaggedTemplateExpression")) {
|
|
21831
|
+
addLeadingComment$2(followingNode, comment);
|
|
21832
|
+
return true;
|
|
21833
|
+
}
|
|
21834
|
+
|
|
21835
|
+
return false;
|
|
21836
|
+
}
|
|
21837
|
+
|
|
21838
|
+
function handleTSMappedTypeComments(text, enclosingNode, precedingNode, followingNode, comment) {
|
|
21839
|
+
if (!enclosingNode || enclosingNode.type !== "TSMappedType") {
|
|
21840
|
+
return false;
|
|
21841
|
+
}
|
|
21842
|
+
|
|
21843
|
+
if (followingNode && followingNode.type === "TSTypeParameter" && followingNode.name) {
|
|
21844
|
+
addLeadingComment$2(followingNode.name, comment);
|
|
21845
|
+
return true;
|
|
21846
|
+
}
|
|
21847
|
+
|
|
21848
|
+
if (precedingNode && precedingNode.type === "TSTypeParameter" && precedingNode.constraint) {
|
|
21849
|
+
addTrailingComment$2(precedingNode.constraint, comment);
|
|
21850
|
+
return true;
|
|
21851
|
+
}
|
|
21852
|
+
|
|
21853
|
+
return false;
|
|
21854
|
+
}
|
|
21855
|
+
|
|
21856
|
+
function isBlockComment$1(comment) {
|
|
21857
|
+
return comment.type === "Block" || comment.type === "CommentBlock";
|
|
21858
|
+
}
|
|
21859
|
+
|
|
21860
|
+
function hasLeadingComment$2(node) {
|
|
21861
|
+
var fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {
|
|
21862
|
+
return true;
|
|
21863
|
+
};
|
|
21864
|
+
|
|
21865
|
+
if (node.leadingComments) {
|
|
21866
|
+
return node.leadingComments.some(fn);
|
|
21867
|
+
}
|
|
21868
|
+
|
|
21869
|
+
if (node.comments) {
|
|
21870
|
+
return node.comments.some(function (comment) {
|
|
21871
|
+
return comment.leading && fn(comment);
|
|
21872
|
+
});
|
|
21873
|
+
}
|
|
21874
|
+
|
|
21875
|
+
return false;
|
|
21876
|
+
}
|
|
21877
|
+
|
|
21878
|
+
var comments$3 = {
|
|
21879
|
+
handleOwnLineComment,
|
|
21880
|
+
handleEndOfLineComment,
|
|
21881
|
+
handleRemainingComment,
|
|
21882
|
+
hasLeadingComment: hasLeadingComment$2,
|
|
21883
|
+
isBlockComment: isBlockComment$1
|
|
21884
|
+
};
|
|
21885
|
+
|
|
21886
|
+
var isBlockComment = comments$3.isBlockComment;
|
|
21887
|
+
var hasLeadingComment$1 = comments$3.hasLeadingComment;
|
|
21888
|
+
var _require$$1$builders = doc.builders;
|
|
21889
|
+
var indent$3 = _require$$1$builders.indent;
|
|
21890
|
+
var join$3 = _require$$1$builders.join;
|
|
21891
|
+
var hardline$4 = _require$$1$builders.hardline;
|
|
21892
|
+
var softline$2 = _require$$1$builders.softline;
|
|
21893
|
+
var literalline$2 = _require$$1$builders.literalline;
|
|
21894
|
+
var concat$5 = _require$$1$builders.concat;
|
|
21895
|
+
var group$2 = _require$$1$builders.group;
|
|
21896
|
+
var dedentToRoot$1 = _require$$1$builders.dedentToRoot;
|
|
21897
|
+
var _require$$1$utils = doc.utils;
|
|
21898
|
+
var mapDoc$3 = _require$$1$utils.mapDoc;
|
|
21899
|
+
var stripTrailingHardline$1 = _require$$1$utils.stripTrailingHardline;
|
|
21900
|
+
|
|
21901
|
+
function embed(path$$1, print, textToDoc
|
|
21902
|
+
/*, options */
|
|
21903
|
+
) {
|
|
21904
|
+
var node = path$$1.getValue();
|
|
21905
|
+
var parent = path$$1.getParentNode();
|
|
21906
|
+
var parentParent = path$$1.getParentNode(1);
|
|
21907
|
+
|
|
21908
|
+
switch (node.type) {
|
|
21909
|
+
case "TemplateLiteral":
|
|
21910
|
+
{
|
|
21911
|
+
var isCss = [isStyledJsx, isStyledComponents, isCssProp, isAngularComponentStyles].some(function (isIt) {
|
|
21912
|
+
return isIt(path$$1);
|
|
21913
|
+
});
|
|
21914
|
+
|
|
21915
|
+
if (isCss) {
|
|
21916
|
+
// Get full template literal with expressions replaced by placeholders
|
|
21917
|
+
var rawQuasis = node.quasis.map(function (q) {
|
|
21918
|
+
return q.value.raw;
|
|
21919
|
+
});
|
|
21920
|
+
var placeholderID = 0;
|
|
21921
|
+
var text = rawQuasis.reduce(function (prevVal, currVal, idx) {
|
|
21922
|
+
return idx == 0 ? currVal : prevVal + "@prettier-placeholder-" + placeholderID++ + "-id" + currVal;
|
|
21923
|
+
}, "");
|
|
21924
|
+
var doc$$2 = textToDoc(text, {
|
|
21925
|
+
parser: "css"
|
|
21926
|
+
});
|
|
21927
|
+
return transformCssDoc(doc$$2, path$$1, print);
|
|
21928
|
+
}
|
|
21929
|
+
/*
|
|
21930
|
+
* react-relay and graphql-tag
|
|
21931
|
+
* graphql`...`
|
|
21932
|
+
* graphql.experimental`...`
|
|
21933
|
+
* gql`...`
|
|
21934
|
+
*
|
|
21935
|
+
* This intentionally excludes Relay Classic tags, as Prettier does not
|
|
21936
|
+
* support Relay Classic formatting.
|
|
21937
|
+
*/
|
|
21938
|
+
|
|
21939
|
+
|
|
21940
|
+
if (isGraphQL(path$$1)) {
|
|
21941
|
+
var expressionDocs = node.expressions ? path$$1.map(print, "expressions") : [];
|
|
21942
|
+
var numQuasis = node.quasis.length;
|
|
21943
|
+
|
|
21944
|
+
if (numQuasis === 1 && node.quasis[0].value.raw.trim() === "") {
|
|
21945
|
+
return "``";
|
|
21946
|
+
}
|
|
21947
|
+
|
|
21948
|
+
var parts = [];
|
|
21949
|
+
|
|
21950
|
+
for (var i = 0; i < numQuasis; i++) {
|
|
21951
|
+
var templateElement = node.quasis[i];
|
|
21952
|
+
var isFirst = i === 0;
|
|
21953
|
+
var isLast = i === numQuasis - 1;
|
|
21954
|
+
var _text = templateElement.value.cooked; // Bail out if any of the quasis have an invalid escape sequence
|
|
21955
|
+
// (which would make the `cooked` value be `null` or `undefined`)
|
|
21956
|
+
|
|
21957
|
+
if (typeof _text !== "string") {
|
|
21958
|
+
return null;
|
|
21959
|
+
}
|
|
21960
|
+
|
|
21961
|
+
var lines = _text.split("\n");
|
|
21962
|
+
|
|
21963
|
+
var numLines = lines.length;
|
|
21964
|
+
var expressionDoc = expressionDocs[i];
|
|
21965
|
+
var startsWithBlankLine = numLines > 2 && lines[0].trim() === "" && lines[1].trim() === "";
|
|
21966
|
+
var endsWithBlankLine = numLines > 2 && lines[numLines - 1].trim() === "" && lines[numLines - 2].trim() === "";
|
|
21967
|
+
var commentsAndWhitespaceOnly = lines.every(function (line) {
|
|
21968
|
+
return /^\s*(?:#[^\r\n]*)?$/.test(line);
|
|
21969
|
+
}); // Bail out if an interpolation occurs within a comment.
|
|
21970
|
+
|
|
21971
|
+
if (!isLast && /#[^\r\n]*$/.test(lines[numLines - 1])) {
|
|
21972
|
+
return null;
|
|
21973
|
+
}
|
|
21974
|
+
|
|
21975
|
+
var _doc = null;
|
|
21976
|
+
|
|
21977
|
+
if (commentsAndWhitespaceOnly) {
|
|
21978
|
+
_doc = printGraphqlComments(lines);
|
|
21979
|
+
} else {
|
|
21980
|
+
_doc = stripTrailingHardline$1(textToDoc(_text, {
|
|
21981
|
+
parser: "graphql"
|
|
21982
|
+
}));
|
|
21983
|
+
}
|
|
21984
|
+
|
|
21985
|
+
if (_doc) {
|
|
21986
|
+
_doc = escapeTemplateCharacters(_doc, false);
|
|
21987
|
+
|
|
21988
|
+
if (!isFirst && startsWithBlankLine) {
|
|
21989
|
+
parts.push("");
|
|
21990
|
+
}
|
|
21991
|
+
|
|
21992
|
+
parts.push(_doc);
|
|
21993
|
+
|
|
21994
|
+
if (!isLast && endsWithBlankLine) {
|
|
21995
|
+
parts.push("");
|
|
21996
|
+
}
|
|
21997
|
+
} else if (!isFirst && !isLast && startsWithBlankLine) {
|
|
21998
|
+
parts.push("");
|
|
21999
|
+
}
|
|
22000
|
+
|
|
22001
|
+
if (expressionDoc) {
|
|
22002
|
+
parts.push(concat$5(["${", expressionDoc, "}"]));
|
|
22003
|
+
}
|
|
22004
|
+
}
|
|
22005
|
+
|
|
22006
|
+
return concat$5(["`", indent$3(concat$5([hardline$4, join$3(hardline$4, parts)])), hardline$4, "`"]);
|
|
22007
|
+
}
|
|
22008
|
+
|
|
22009
|
+
if (isHtml(path$$1)) {
|
|
22010
|
+
return printHtmlTemplateLiteral(path$$1, print, textToDoc, "html");
|
|
22011
|
+
}
|
|
22012
|
+
|
|
22013
|
+
if (isAngularComponentTemplate(path$$1)) {
|
|
22014
|
+
return printHtmlTemplateLiteral(path$$1, print, textToDoc, "angular");
|
|
22015
|
+
}
|
|
22016
|
+
|
|
22017
|
+
break;
|
|
22018
|
+
}
|
|
22019
|
+
|
|
22020
|
+
case "TemplateElement":
|
|
22021
|
+
{
|
|
22022
|
+
/**
|
|
22023
|
+
* md`...`
|
|
22024
|
+
* markdown`...`
|
|
22025
|
+
*/
|
|
22026
|
+
if (parentParent && parentParent.type === "TaggedTemplateExpression" && parent.quasis.length === 1 && parentParent.tag.type === "Identifier" && (parentParent.tag.name === "md" || parentParent.tag.name === "markdown")) {
|
|
22027
|
+
var _text2 = parent.quasis[0].value.raw.replace(/((?:\\\\)*)\\`/g, function (_, backslashes) {
|
|
22028
|
+
return "\\".repeat(backslashes.length / 2) + "`";
|
|
22029
|
+
});
|
|
22030
|
+
|
|
22031
|
+
var indentation = getIndentation(_text2);
|
|
22032
|
+
var hasIndent = indentation !== "";
|
|
22033
|
+
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]);
|
|
22034
|
+
}
|
|
22035
|
+
|
|
22036
|
+
break;
|
|
22037
|
+
}
|
|
22038
|
+
}
|
|
22039
|
+
|
|
22040
|
+
function printMarkdown(text) {
|
|
22041
|
+
var doc$$2 = textToDoc(text, {
|
|
22042
|
+
parser: "markdown",
|
|
22043
|
+
__inJsTemplate: true
|
|
22044
|
+
});
|
|
22045
|
+
return stripTrailingHardline$1(escapeTemplateCharacters(doc$$2, true));
|
|
22046
|
+
}
|
|
22047
|
+
}
|
|
22048
|
+
|
|
22049
|
+
function getIndentation(str) {
|
|
22050
|
+
var firstMatchedIndent = str.match(/^([^\S\n]*)\S/m);
|
|
22051
|
+
return firstMatchedIndent === null ? "" : firstMatchedIndent[1];
|
|
22052
|
+
}
|
|
22053
|
+
|
|
22054
|
+
function escapeTemplateCharacters(doc$$2, raw) {
|
|
22055
|
+
return mapDoc$3(doc$$2, function (currentDoc) {
|
|
22056
|
+
if (!currentDoc.parts) {
|
|
22057
|
+
return currentDoc;
|
|
22058
|
+
}
|
|
22059
|
+
|
|
22060
|
+
var parts = [];
|
|
22061
|
+
currentDoc.parts.forEach(function (part) {
|
|
22062
|
+
if (typeof part === "string") {
|
|
22063
|
+
parts.push(raw ? part.replace(/(\\*)`/g, "$1$1\\`") : part.replace(/([\\`]|\$\{)/g, "\\$1"));
|
|
22064
|
+
} else {
|
|
22065
|
+
parts.push(part);
|
|
22066
|
+
}
|
|
22067
|
+
});
|
|
22068
|
+
return Object.assign({}, currentDoc, {
|
|
22069
|
+
parts
|
|
22070
|
+
});
|
|
22071
|
+
});
|
|
22072
|
+
}
|
|
22073
|
+
|
|
22074
|
+
function transformCssDoc(quasisDoc, path$$1, print) {
|
|
22075
|
+
var parentNode = path$$1.getValue();
|
|
22076
|
+
var isEmpty = parentNode.quasis.length === 1 && !parentNode.quasis[0].value.raw.trim();
|
|
22077
|
+
|
|
22078
|
+
if (isEmpty) {
|
|
22079
|
+
return "``";
|
|
22080
|
+
}
|
|
22081
|
+
|
|
22082
|
+
var expressionDocs = parentNode.expressions ? path$$1.map(print, "expressions") : [];
|
|
22083
|
+
var newDoc = replacePlaceholders(quasisDoc, expressionDocs);
|
|
22084
|
+
/* istanbul ignore if */
|
|
22085
|
+
|
|
22086
|
+
if (!newDoc) {
|
|
22087
|
+
throw new Error("Couldn't insert all the expressions");
|
|
22088
|
+
}
|
|
22089
|
+
|
|
22090
|
+
return concat$5(["`", indent$3(concat$5([hardline$4, stripTrailingHardline$1(newDoc)])), softline$2, "`"]);
|
|
22091
|
+
} // Search all the placeholders in the quasisDoc tree
|
|
22092
|
+
// and replace them with the expression docs one by one
|
|
22093
|
+
// returns a new doc with all the placeholders replaced,
|
|
22094
|
+
// or null if it couldn't replace any expression
|
|
22095
|
+
|
|
22096
|
+
|
|
22097
|
+
function replacePlaceholders(quasisDoc, expressionDocs) {
|
|
22098
|
+
if (!expressionDocs || !expressionDocs.length) {
|
|
22099
|
+
return quasisDoc;
|
|
22100
|
+
}
|
|
22101
|
+
|
|
22102
|
+
var expressions = expressionDocs.slice();
|
|
22103
|
+
var replaceCounter = 0;
|
|
22104
|
+
var newDoc = mapDoc$3(quasisDoc, function (doc$$2) {
|
|
22105
|
+
if (!doc$$2 || !doc$$2.parts || !doc$$2.parts.length) {
|
|
22106
|
+
return doc$$2;
|
|
22107
|
+
}
|
|
22108
|
+
|
|
22109
|
+
var parts = doc$$2.parts;
|
|
22110
|
+
var atIndex = parts.indexOf("@");
|
|
22111
|
+
var placeholderIndex = atIndex + 1;
|
|
22112
|
+
|
|
22113
|
+
if (atIndex > -1 && typeof parts[placeholderIndex] === "string" && parts[placeholderIndex].startsWith("prettier-placeholder")) {
|
|
22114
|
+
// If placeholder is split, join it
|
|
22115
|
+
var at = parts[atIndex];
|
|
22116
|
+
var placeholder = parts[placeholderIndex];
|
|
22117
|
+
var rest = parts.slice(placeholderIndex + 1);
|
|
22118
|
+
parts = parts.slice(0, atIndex).concat([at + placeholder]).concat(rest);
|
|
22119
|
+
}
|
|
22120
|
+
|
|
22121
|
+
var atPlaceholderIndex = parts.findIndex(function (part) {
|
|
22122
|
+
return typeof part === "string" && part.startsWith("@prettier-placeholder");
|
|
22123
|
+
});
|
|
22124
|
+
|
|
22125
|
+
if (atPlaceholderIndex > -1) {
|
|
22126
|
+
var _placeholder = parts[atPlaceholderIndex];
|
|
22127
|
+
|
|
22128
|
+
var _rest = parts.slice(atPlaceholderIndex + 1);
|
|
22129
|
+
|
|
22130
|
+
var placeholderMatch = _placeholder.match(/@prettier-placeholder-(.+)-id([\s\S]*)/);
|
|
22131
|
+
|
|
22132
|
+
var placeholderID = placeholderMatch[1]; // When the expression has a suffix appended, like:
|
|
22133
|
+
// animation: linear ${time}s ease-out;
|
|
22134
|
+
|
|
22135
|
+
var suffix = placeholderMatch[2];
|
|
22136
|
+
var expression = expressions[placeholderID];
|
|
22137
|
+
replaceCounter++;
|
|
22138
|
+
parts = parts.slice(0, atPlaceholderIndex).concat(["${", expression, "}" + suffix]).concat(_rest);
|
|
22139
|
+
}
|
|
22140
|
+
|
|
22141
|
+
return Object.assign({}, doc$$2, {
|
|
22142
|
+
parts: parts
|
|
22143
|
+
});
|
|
22144
|
+
});
|
|
22145
|
+
return expressions.length === replaceCounter ? newDoc : null;
|
|
22146
|
+
}
|
|
22147
|
+
|
|
22148
|
+
function printGraphqlComments(lines) {
|
|
22149
|
+
var parts = [];
|
|
22150
|
+
var seenComment = false;
|
|
22151
|
+
lines.map(function (textLine) {
|
|
22152
|
+
return textLine.trim();
|
|
22153
|
+
}).forEach(function (textLine, i, array) {
|
|
22154
|
+
// Lines are either whitespace only, or a comment (with poential whitespace
|
|
22155
|
+
// around it). Drop whitespace-only lines.
|
|
22156
|
+
if (textLine === "") {
|
|
22157
|
+
return;
|
|
22158
|
+
}
|
|
22159
|
+
|
|
22160
|
+
if (array[i - 1] === "" && seenComment) {
|
|
22161
|
+
// If a non-first comment is preceded by a blank (whitespace only) line,
|
|
22162
|
+
// add in a blank line.
|
|
22163
|
+
parts.push(concat$5([hardline$4, textLine]));
|
|
22164
|
+
} else {
|
|
22165
|
+
parts.push(textLine);
|
|
22166
|
+
}
|
|
22167
|
+
|
|
22168
|
+
seenComment = true;
|
|
22169
|
+
}); // If `lines` was whitespace only, return `null`.
|
|
22170
|
+
|
|
22171
|
+
return parts.length === 0 ? null : join$3(hardline$4, parts);
|
|
22172
|
+
}
|
|
22173
|
+
/**
|
|
22174
|
+
* Template literal in this context:
|
|
22175
|
+
* <style jsx>{`div{color:red}`}</style>
|
|
21502
22176
|
*/
|
|
21503
22177
|
|
|
21504
22178
|
|
|
@@ -21632,8 +22306,8 @@ function hasLanguageComment(node, languageName) {
|
|
|
21632
22306
|
// we will not trim the comment value and we will expect exactly one space on
|
|
21633
22307
|
// either side of the GraphQL string
|
|
21634
22308
|
// Also see ./clean.js
|
|
21635
|
-
return node
|
|
21636
|
-
return comment
|
|
22309
|
+
return hasLeadingComment$1(node, function (comment) {
|
|
22310
|
+
return isBlockComment(comment) && comment.value === ` ${languageName} `;
|
|
21637
22311
|
});
|
|
21638
22312
|
}
|
|
21639
22313
|
|
|
@@ -21713,7 +22387,7 @@ function printHtmlTemplateLiteral(path$$1, print, textToDoc, parser) {
|
|
|
21713
22387
|
return "``";
|
|
21714
22388
|
}
|
|
21715
22389
|
|
|
21716
|
-
var contentDoc = mapDoc$
|
|
22390
|
+
var contentDoc = mapDoc$3(stripTrailingHardline$1(textToDoc(text, {
|
|
21717
22391
|
parser
|
|
21718
22392
|
})), function (doc$$2) {
|
|
21719
22393
|
var placeholderRegex = new RegExp(placeholderPattern, "g");
|
|
@@ -21738,7 +22412,7 @@ function printHtmlTemplateLiteral(path$$1, print, textToDoc, parser) {
|
|
|
21738
22412
|
}
|
|
21739
22413
|
|
|
21740
22414
|
var placeholderIndex = +component;
|
|
21741
|
-
parts.push(concat$5(["${", group$2(
|
|
22415
|
+
parts.push(concat$5(["${", group$2(expressionDocs[placeholderIndex]), "}"]));
|
|
21742
22416
|
}
|
|
21743
22417
|
|
|
21744
22418
|
return concat$5(parts);
|
|
@@ -21788,8 +22462,8 @@ function clean(ast, newObj, parent) {
|
|
|
21788
22462
|
} // (TypeScript) bypass TSParenthesizedType
|
|
21789
22463
|
|
|
21790
22464
|
|
|
21791
|
-
if (ast.type === "TSParenthesizedType"
|
|
21792
|
-
return newObj.typeAnnotation
|
|
22465
|
+
if (ast.type === "TSParenthesizedType") {
|
|
22466
|
+
return newObj.typeAnnotation;
|
|
21793
22467
|
} // We convert <div></div> to <div />
|
|
21794
22468
|
|
|
21795
22469
|
|
|
@@ -21900,672 +22574,194 @@ var clean_1 = clean;
|
|
|
21900
22574
|
var detectNewline = createCommonjsModule(function (module) {
|
|
21901
22575
|
'use strict';
|
|
21902
22576
|
|
|
21903
|
-
module.exports = function (str) {
|
|
21904
|
-
if (typeof str !== 'string') {
|
|
21905
|
-
throw new TypeError('Expected a string');
|
|
21906
|
-
}
|
|
21907
|
-
|
|
21908
|
-
var newlines = str.match(/(?:\r?\n)/g) || [];
|
|
21909
|
-
|
|
21910
|
-
if (newlines.length === 0) {
|
|
21911
|
-
return null;
|
|
21912
|
-
}
|
|
21913
|
-
|
|
21914
|
-
var crlf = newlines.filter(function (el) {
|
|
21915
|
-
return el === '\r\n';
|
|
21916
|
-
}).length;
|
|
21917
|
-
var lf = newlines.length - crlf;
|
|
21918
|
-
return crlf > lf ? '\r\n' : '\n';
|
|
21919
|
-
};
|
|
21920
|
-
|
|
21921
|
-
module.exports.graceful = function (str) {
|
|
21922
|
-
return module.exports(str) || '\n';
|
|
21923
|
-
};
|
|
21924
|
-
});
|
|
21925
|
-
|
|
21926
|
-
var build$1 = createCommonjsModule(function (module, exports) {
|
|
21927
|
-
'use strict';
|
|
21928
|
-
|
|
21929
|
-
Object.defineProperty(exports, '__esModule', {
|
|
21930
|
-
value: true
|
|
21931
|
-
});
|
|
21932
|
-
exports.extract = extract;
|
|
21933
|
-
exports.strip = strip;
|
|
21934
|
-
exports.parse = parse;
|
|
21935
|
-
exports.parseWithComments = parseWithComments;
|
|
21936
|
-
exports.print = print;
|
|
21937
|
-
|
|
21938
|
-
var _detectNewline;
|
|
21939
|
-
|
|
21940
|
-
function _load_detectNewline() {
|
|
21941
|
-
return _detectNewline = _interopRequireDefault(detectNewline);
|
|
21942
|
-
}
|
|
21943
|
-
|
|
21944
|
-
var _os;
|
|
21945
|
-
|
|
21946
|
-
function _load_os() {
|
|
21947
|
-
return _os = os;
|
|
21948
|
-
}
|
|
21949
|
-
|
|
21950
|
-
function _interopRequireDefault(obj) {
|
|
21951
|
-
return obj && obj.__esModule ? obj : {
|
|
21952
|
-
default: obj
|
|
21953
|
-
};
|
|
21954
|
-
}
|
|
21955
|
-
/**
|
|
21956
|
-
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
|
21957
|
-
*
|
|
21958
|
-
* This source code is licensed under the MIT license found in the
|
|
21959
|
-
* LICENSE file in the root directory of this source tree.
|
|
21960
|
-
*
|
|
21961
|
-
*
|
|
21962
|
-
*/
|
|
21963
|
-
|
|
21964
|
-
|
|
21965
|
-
var commentEndRe = /\*\/$/;
|
|
21966
|
-
var commentStartRe = /^\/\*\*/;
|
|
21967
|
-
var docblockRe = /^\s*(\/\*\*?(.|\r?\n)*?\*\/)/;
|
|
21968
|
-
var lineCommentRe = /(^|\s+)\/\/([^\r\n]*)/g;
|
|
21969
|
-
var ltrimNewlineRe = /^(\r?\n)+/;
|
|
21970
|
-
var multilineRe = /(?:^|\r?\n) *(@[^\r\n]*?) *\r?\n *(?![^@\r\n]*\/\/[^]*)([^@\r\n\s][^@\r\n]+?) *\r?\n/g;
|
|
21971
|
-
var propertyRe = /(?:^|\r?\n) *@(\S+) *([^\r\n]*)/g;
|
|
21972
|
-
var stringStartRe = /(\r?\n|^) *\* ?/g;
|
|
21973
|
-
|
|
21974
|
-
function extract(contents) {
|
|
21975
|
-
var match = contents.match(docblockRe);
|
|
21976
|
-
return match ? match[0].trimLeft() : '';
|
|
21977
|
-
}
|
|
21978
|
-
|
|
21979
|
-
function strip(contents) {
|
|
21980
|
-
var match = contents.match(docblockRe);
|
|
21981
|
-
return match && match[0] ? contents.substring(match[0].length) : contents;
|
|
21982
|
-
}
|
|
21983
|
-
|
|
21984
|
-
function parse(docblock) {
|
|
21985
|
-
return parseWithComments(docblock).pragmas;
|
|
21986
|
-
}
|
|
21987
|
-
|
|
21988
|
-
function parseWithComments(docblock) {
|
|
21989
|
-
var line = (0, (_detectNewline || _load_detectNewline()).default)(docblock) || (_os || _load_os()).EOL;
|
|
21990
|
-
|
|
21991
|
-
docblock = docblock.replace(commentStartRe, '').replace(commentEndRe, '').replace(stringStartRe, '$1'); // Normalize multi-line directives
|
|
21992
|
-
|
|
21993
|
-
var prev = '';
|
|
21994
|
-
|
|
21995
|
-
while (prev !== docblock) {
|
|
21996
|
-
prev = docblock;
|
|
21997
|
-
docblock = docblock.replace(multilineRe, `${line}$1 $2${line}`);
|
|
21998
|
-
}
|
|
21999
|
-
|
|
22000
|
-
docblock = docblock.replace(ltrimNewlineRe, '').trimRight();
|
|
22001
|
-
var result = Object.create(null);
|
|
22002
|
-
var comments = docblock.replace(propertyRe, '').replace(ltrimNewlineRe, '').trimRight();
|
|
22003
|
-
var match;
|
|
22004
|
-
|
|
22005
|
-
while (match = propertyRe.exec(docblock)) {
|
|
22006
|
-
// strip linecomments from pragmas
|
|
22007
|
-
var nextPragma = match[2].replace(lineCommentRe, '');
|
|
22008
|
-
|
|
22009
|
-
if (typeof result[match[1]] === 'string' || Array.isArray(result[match[1]])) {
|
|
22010
|
-
result[match[1]] = [].concat(result[match[1]], nextPragma);
|
|
22011
|
-
} else {
|
|
22012
|
-
result[match[1]] = nextPragma;
|
|
22013
|
-
}
|
|
22014
|
-
}
|
|
22015
|
-
|
|
22016
|
-
return {
|
|
22017
|
-
comments,
|
|
22018
|
-
pragmas: result
|
|
22019
|
-
};
|
|
22020
|
-
}
|
|
22021
|
-
|
|
22022
|
-
function print(_ref) {
|
|
22023
|
-
var _ref$comments = _ref.comments;
|
|
22024
|
-
var comments = _ref$comments === undefined ? '' : _ref$comments;
|
|
22025
|
-
var _ref$pragmas = _ref.pragmas;
|
|
22026
|
-
var pragmas = _ref$pragmas === undefined ? {} : _ref$pragmas;
|
|
22027
|
-
|
|
22028
|
-
var line = (0, (_detectNewline || _load_detectNewline()).default)(comments) || (_os || _load_os()).EOL;
|
|
22029
|
-
|
|
22030
|
-
var head = '/**';
|
|
22031
|
-
var start = ' *';
|
|
22032
|
-
var tail = ' */';
|
|
22033
|
-
var keys = Object.keys(pragmas);
|
|
22034
|
-
var printedObject = keys.map(function (key) {
|
|
22035
|
-
return printKeyValues(key, pragmas[key]);
|
|
22036
|
-
}).reduce(function (arr, next) {
|
|
22037
|
-
return arr.concat(next);
|
|
22038
|
-
}, []).map(function (keyValue) {
|
|
22039
|
-
return start + ' ' + keyValue + line;
|
|
22040
|
-
}).join('');
|
|
22041
|
-
|
|
22042
|
-
if (!comments) {
|
|
22043
|
-
if (keys.length === 0) {
|
|
22044
|
-
return '';
|
|
22045
|
-
}
|
|
22046
|
-
|
|
22047
|
-
if (keys.length === 1 && !Array.isArray(pragmas[keys[0]])) {
|
|
22048
|
-
var value = pragmas[keys[0]];
|
|
22049
|
-
return `${head} ${printKeyValues(keys[0], value)[0]}${tail}`;
|
|
22050
|
-
}
|
|
22051
|
-
}
|
|
22052
|
-
|
|
22053
|
-
var printedComments = comments.split(line).map(function (textLine) {
|
|
22054
|
-
return `${start} ${textLine}`;
|
|
22055
|
-
}).join(line) + line;
|
|
22056
|
-
return head + line + (comments ? printedComments : '') + (comments && keys.length ? start + line : '') + printedObject + tail;
|
|
22057
|
-
}
|
|
22058
|
-
|
|
22059
|
-
function printKeyValues(key, valueOrArray) {
|
|
22060
|
-
return [].concat(valueOrArray).map(function (value) {
|
|
22061
|
-
return `@${key} ${value}`.trim();
|
|
22062
|
-
});
|
|
22063
|
-
}
|
|
22064
|
-
});
|
|
22065
|
-
unwrapExports(build$1);
|
|
22066
|
-
|
|
22067
|
-
function hasPragma(text) {
|
|
22068
|
-
var pragmas = Object.keys(build$1.parse(build$1.extract(text)));
|
|
22069
|
-
return pragmas.indexOf("prettier") !== -1 || pragmas.indexOf("format") !== -1;
|
|
22070
|
-
}
|
|
22071
|
-
|
|
22072
|
-
function insertPragma$1(text) {
|
|
22073
|
-
var parsedDocblock = build$1.parseWithComments(build$1.extract(text));
|
|
22074
|
-
var pragmas = Object.assign({
|
|
22075
|
-
format: ""
|
|
22076
|
-
}, parsedDocblock.pragmas);
|
|
22077
|
-
var newDocblock = build$1.print({
|
|
22078
|
-
pragmas,
|
|
22079
|
-
comments: parsedDocblock.comments.replace(/^(\s+?\r?\n)+/, "") // remove leading newlines
|
|
22080
|
-
|
|
22081
|
-
}).replace(/(\r\n|\r)/g, "\n"); // normalise newlines (mitigate use of os.EOL by jest-docblock)
|
|
22082
|
-
|
|
22083
|
-
var strippedText = build$1.strip(text);
|
|
22084
|
-
var separatingNewlines = strippedText.startsWith("\n") ? "\n" : "\n\n";
|
|
22085
|
-
return newDocblock + separatingNewlines + strippedText;
|
|
22086
|
-
}
|
|
22087
|
-
|
|
22088
|
-
var pragma = {
|
|
22089
|
-
hasPragma,
|
|
22090
|
-
insertPragma: insertPragma$1
|
|
22091
|
-
};
|
|
22092
|
-
|
|
22093
|
-
var addLeadingComment$2 = utilShared.addLeadingComment;
|
|
22094
|
-
var addTrailingComment$2 = utilShared.addTrailingComment;
|
|
22095
|
-
var addDanglingComment$2 = utilShared.addDanglingComment;
|
|
22096
|
-
|
|
22097
|
-
function handleOwnLineComment(comment, text, options, ast, isLastComment) {
|
|
22098
|
-
var precedingNode = comment.precedingNode,
|
|
22099
|
-
enclosingNode = comment.enclosingNode,
|
|
22100
|
-
followingNode = comment.followingNode;
|
|
22101
|
-
|
|
22102
|
-
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)) {
|
|
22103
|
-
return true;
|
|
22104
|
-
}
|
|
22105
|
-
|
|
22106
|
-
return false;
|
|
22107
|
-
}
|
|
22108
|
-
|
|
22109
|
-
function handleEndOfLineComment(comment, text, options, ast, isLastComment) {
|
|
22110
|
-
var precedingNode = comment.precedingNode,
|
|
22111
|
-
enclosingNode = comment.enclosingNode,
|
|
22112
|
-
followingNode = comment.followingNode;
|
|
22113
|
-
|
|
22114
|
-
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)) {
|
|
22115
|
-
return true;
|
|
22116
|
-
}
|
|
22117
|
-
|
|
22118
|
-
return false;
|
|
22119
|
-
}
|
|
22120
|
-
|
|
22121
|
-
function handleRemainingComment(comment, text, options, ast, isLastComment) {
|
|
22122
|
-
var precedingNode = comment.precedingNode,
|
|
22123
|
-
enclosingNode = comment.enclosingNode,
|
|
22124
|
-
followingNode = comment.followingNode;
|
|
22125
|
-
|
|
22126
|
-
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)) {
|
|
22127
|
-
return true;
|
|
22128
|
-
}
|
|
22129
|
-
|
|
22130
|
-
return false;
|
|
22131
|
-
}
|
|
22132
|
-
|
|
22133
|
-
function addBlockStatementFirstComment(node, comment) {
|
|
22134
|
-
var body = node.body.filter(function (n) {
|
|
22135
|
-
return n.type !== "EmptyStatement";
|
|
22136
|
-
});
|
|
22137
|
-
|
|
22138
|
-
if (body.length === 0) {
|
|
22139
|
-
addDanglingComment$2(node, comment);
|
|
22140
|
-
} else {
|
|
22141
|
-
addLeadingComment$2(body[0], comment);
|
|
22142
|
-
}
|
|
22143
|
-
}
|
|
22144
|
-
|
|
22145
|
-
function addBlockOrNotComment(node, comment) {
|
|
22146
|
-
if (node.type === "BlockStatement") {
|
|
22147
|
-
addBlockStatementFirstComment(node, comment);
|
|
22148
|
-
} else {
|
|
22149
|
-
addLeadingComment$2(node, comment);
|
|
22150
|
-
}
|
|
22151
|
-
} // There are often comments before the else clause of if statements like
|
|
22152
|
-
//
|
|
22153
|
-
// if (1) { ... }
|
|
22154
|
-
// // comment
|
|
22155
|
-
// else { ... }
|
|
22156
|
-
//
|
|
22157
|
-
// They are being attached as leading comments of the BlockExpression which
|
|
22158
|
-
// is not well printed. What we want is to instead move the comment inside
|
|
22159
|
-
// of the block and make it leadingComment of the first element of the block
|
|
22160
|
-
// or dangling comment of the block if there is nothing inside
|
|
22161
|
-
//
|
|
22162
|
-
// if (1) { ... }
|
|
22163
|
-
// else {
|
|
22164
|
-
// // comment
|
|
22165
|
-
// ...
|
|
22166
|
-
// }
|
|
22167
|
-
|
|
22168
|
-
|
|
22169
|
-
function handleIfStatementComments(text, precedingNode, enclosingNode, followingNode, comment, options) {
|
|
22170
|
-
if (!enclosingNode || enclosingNode.type !== "IfStatement" || !followingNode) {
|
|
22171
|
-
return false;
|
|
22172
|
-
} // We unfortunately have no way using the AST or location of nodes to know
|
|
22173
|
-
// if the comment is positioned before the condition parenthesis:
|
|
22174
|
-
// if (a /* comment */) {}
|
|
22175
|
-
// The only workaround I found is to look at the next character to see if
|
|
22176
|
-
// it is a ).
|
|
22177
|
-
|
|
22178
|
-
|
|
22179
|
-
var nextCharacter = util$1.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd);
|
|
22180
|
-
|
|
22181
|
-
if (nextCharacter === ")") {
|
|
22182
|
-
addTrailingComment$2(precedingNode, comment);
|
|
22183
|
-
return true;
|
|
22184
|
-
} // Comments before `else`:
|
|
22185
|
-
// - treat as trailing comments of the consequent, if it's a BlockStatement
|
|
22186
|
-
// - treat as a dangling comment otherwise
|
|
22187
|
-
|
|
22188
|
-
|
|
22189
|
-
if (precedingNode === enclosingNode.consequent && followingNode === enclosingNode.alternate) {
|
|
22190
|
-
if (precedingNode.type === "BlockStatement") {
|
|
22191
|
-
addTrailingComment$2(precedingNode, comment);
|
|
22192
|
-
} else {
|
|
22193
|
-
addDanglingComment$2(enclosingNode, comment);
|
|
22194
|
-
}
|
|
22195
|
-
|
|
22196
|
-
return true;
|
|
22197
|
-
}
|
|
22198
|
-
|
|
22199
|
-
if (followingNode.type === "BlockStatement") {
|
|
22200
|
-
addBlockStatementFirstComment(followingNode, comment);
|
|
22201
|
-
return true;
|
|
22202
|
-
}
|
|
22203
|
-
|
|
22204
|
-
if (followingNode.type === "IfStatement") {
|
|
22205
|
-
addBlockOrNotComment(followingNode.consequent, comment);
|
|
22206
|
-
return true;
|
|
22207
|
-
} // For comments positioned after the condition parenthesis in an if statement
|
|
22208
|
-
// before the consequent without brackets on, such as
|
|
22209
|
-
// if (a) /* comment */ true,
|
|
22210
|
-
// we look at the next character to see if the following node
|
|
22211
|
-
// is the consequent for the if statement
|
|
22212
|
-
|
|
22213
|
-
|
|
22214
|
-
if (enclosingNode.consequent === followingNode) {
|
|
22215
|
-
addLeadingComment$2(followingNode, comment);
|
|
22216
|
-
return true;
|
|
22217
|
-
}
|
|
22218
|
-
|
|
22219
|
-
return false;
|
|
22220
|
-
}
|
|
22221
|
-
|
|
22222
|
-
function handleWhileComments(text, precedingNode, enclosingNode, followingNode, comment, options) {
|
|
22223
|
-
if (!enclosingNode || enclosingNode.type !== "WhileStatement" || !followingNode) {
|
|
22224
|
-
return false;
|
|
22225
|
-
} // We unfortunately have no way using the AST or location of nodes to know
|
|
22226
|
-
// if the comment is positioned before the condition parenthesis:
|
|
22227
|
-
// while (a /* comment */) {}
|
|
22228
|
-
// The only workaround I found is to look at the next character to see if
|
|
22229
|
-
// it is a ).
|
|
22230
|
-
|
|
22231
|
-
|
|
22232
|
-
var nextCharacter = util$1.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd);
|
|
22233
|
-
|
|
22234
|
-
if (nextCharacter === ")") {
|
|
22235
|
-
addTrailingComment$2(precedingNode, comment);
|
|
22236
|
-
return true;
|
|
22237
|
-
}
|
|
22238
|
-
|
|
22239
|
-
if (followingNode.type === "BlockStatement") {
|
|
22240
|
-
addBlockStatementFirstComment(followingNode, comment);
|
|
22241
|
-
return true;
|
|
22242
|
-
}
|
|
22243
|
-
|
|
22244
|
-
return false;
|
|
22245
|
-
} // Same as IfStatement but for TryStatement
|
|
22246
|
-
|
|
22247
|
-
|
|
22248
|
-
function handleTryStatementComments(enclosingNode, precedingNode, followingNode, comment) {
|
|
22249
|
-
if (!enclosingNode || enclosingNode.type !== "TryStatement" && enclosingNode.type !== "CatchClause" || !followingNode) {
|
|
22250
|
-
return false;
|
|
22251
|
-
}
|
|
22252
|
-
|
|
22253
|
-
if (enclosingNode.type === "CatchClause" && precedingNode) {
|
|
22254
|
-
addTrailingComment$2(precedingNode, comment);
|
|
22255
|
-
return true;
|
|
22256
|
-
}
|
|
22257
|
-
|
|
22258
|
-
if (followingNode.type === "BlockStatement") {
|
|
22259
|
-
addBlockStatementFirstComment(followingNode, comment);
|
|
22260
|
-
return true;
|
|
22261
|
-
}
|
|
22262
|
-
|
|
22263
|
-
if (followingNode.type === "TryStatement") {
|
|
22264
|
-
addBlockOrNotComment(followingNode.finalizer, comment);
|
|
22265
|
-
return true;
|
|
22266
|
-
}
|
|
22267
|
-
|
|
22268
|
-
if (followingNode.type === "CatchClause") {
|
|
22269
|
-
addBlockOrNotComment(followingNode.body, comment);
|
|
22270
|
-
return true;
|
|
22271
|
-
}
|
|
22272
|
-
|
|
22273
|
-
return false;
|
|
22274
|
-
}
|
|
22275
|
-
|
|
22276
|
-
function handleMemberExpressionComments(enclosingNode, followingNode, comment) {
|
|
22277
|
-
if (enclosingNode && enclosingNode.type === "MemberExpression" && followingNode && followingNode.type === "Identifier") {
|
|
22278
|
-
addLeadingComment$2(enclosingNode, comment);
|
|
22279
|
-
return true;
|
|
22280
|
-
}
|
|
22281
|
-
|
|
22282
|
-
return false;
|
|
22283
|
-
}
|
|
22284
|
-
|
|
22285
|
-
function handleConditionalExpressionComments(enclosingNode, precedingNode, followingNode, comment, text, options) {
|
|
22286
|
-
var isSameLineAsPrecedingNode = precedingNode && !util$1.hasNewlineInRange(text, options.locEnd(precedingNode), options.locStart(comment));
|
|
22287
|
-
|
|
22288
|
-
if ((!precedingNode || !isSameLineAsPrecedingNode) && enclosingNode && enclosingNode.type === "ConditionalExpression" && followingNode) {
|
|
22289
|
-
addLeadingComment$2(followingNode, comment);
|
|
22290
|
-
return true;
|
|
22291
|
-
}
|
|
22292
|
-
|
|
22293
|
-
return false;
|
|
22294
|
-
}
|
|
22295
|
-
|
|
22296
|
-
function handleObjectPropertyAssignment(enclosingNode, precedingNode, comment) {
|
|
22297
|
-
if (enclosingNode && (enclosingNode.type === "ObjectProperty" || enclosingNode.type === "Property") && enclosingNode.shorthand && enclosingNode.key === precedingNode && enclosingNode.value.type === "AssignmentPattern") {
|
|
22298
|
-
addTrailingComment$2(enclosingNode.value.left, comment);
|
|
22299
|
-
return true;
|
|
22300
|
-
}
|
|
22301
|
-
|
|
22302
|
-
return false;
|
|
22303
|
-
}
|
|
22304
|
-
|
|
22305
|
-
function handleClassComments(enclosingNode, precedingNode, followingNode, comment) {
|
|
22306
|
-
if (enclosingNode && (enclosingNode.type === "ClassDeclaration" || enclosingNode.type === "ClassExpression") && enclosingNode.decorators && enclosingNode.decorators.length > 0 && !(followingNode && followingNode.type === "Decorator")) {
|
|
22307
|
-
if (!enclosingNode.decorators || enclosingNode.decorators.length === 0) {
|
|
22308
|
-
addLeadingComment$2(enclosingNode, comment);
|
|
22309
|
-
} else {
|
|
22310
|
-
addTrailingComment$2(enclosingNode.decorators[enclosingNode.decorators.length - 1], comment);
|
|
22311
|
-
}
|
|
22312
|
-
|
|
22313
|
-
return true;
|
|
22314
|
-
}
|
|
22315
|
-
|
|
22316
|
-
return false;
|
|
22317
|
-
}
|
|
22318
|
-
|
|
22319
|
-
function handleMethodNameComments(text, enclosingNode, precedingNode, comment, options) {
|
|
22320
|
-
// This is only needed for estree parsers (flow, typescript) to attach
|
|
22321
|
-
// after a method name:
|
|
22322
|
-
// obj = { fn /*comment*/() {} };
|
|
22323
|
-
if (enclosingNode && precedingNode && (enclosingNode.type === "Property" || enclosingNode.type === "MethodDefinition") && precedingNode.type === "Identifier" && enclosingNode.key === precedingNode && // special Property case: { key: /*comment*/(value) };
|
|
22324
|
-
// comment should be attached to value instead of key
|
|
22325
|
-
util$1.getNextNonSpaceNonCommentCharacter(text, precedingNode, options.locEnd) !== ":") {
|
|
22326
|
-
addTrailingComment$2(precedingNode, comment);
|
|
22327
|
-
return true;
|
|
22328
|
-
} // Print comments between decorators and class methods as a trailing comment
|
|
22329
|
-
// on the decorator node instead of the method node
|
|
22330
|
-
|
|
22331
|
-
|
|
22332
|
-
if (precedingNode && enclosingNode && precedingNode.type === "Decorator" && (enclosingNode.type === "ClassMethod" || enclosingNode.type === "ClassProperty" || enclosingNode.type === "TSAbstractClassProperty" || enclosingNode.type === "TSAbstractMethodDefinition" || enclosingNode.type === "MethodDefinition")) {
|
|
22333
|
-
addTrailingComment$2(precedingNode, comment);
|
|
22334
|
-
return true;
|
|
22335
|
-
}
|
|
22336
|
-
|
|
22337
|
-
return false;
|
|
22338
|
-
}
|
|
22339
|
-
|
|
22340
|
-
function handleFunctionNameComments(text, enclosingNode, precedingNode, comment, options) {
|
|
22341
|
-
if (util$1.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd) !== "(") {
|
|
22342
|
-
return false;
|
|
22343
|
-
}
|
|
22344
|
-
|
|
22345
|
-
if (precedingNode && enclosingNode && (enclosingNode.type === "FunctionDeclaration" || enclosingNode.type === "FunctionExpression" || enclosingNode.type === "ClassMethod" || enclosingNode.type === "MethodDefinition" || enclosingNode.type === "ObjectMethod")) {
|
|
22346
|
-
addTrailingComment$2(precedingNode, comment);
|
|
22347
|
-
return true;
|
|
22348
|
-
}
|
|
22349
|
-
|
|
22350
|
-
return false;
|
|
22351
|
-
}
|
|
22352
|
-
|
|
22353
|
-
function handleCommentAfterArrowParams(text, enclosingNode, comment, options) {
|
|
22354
|
-
if (!(enclosingNode && enclosingNode.type === "ArrowFunctionExpression")) {
|
|
22355
|
-
return false;
|
|
22356
|
-
}
|
|
22357
|
-
|
|
22358
|
-
var index = utilShared.getNextNonSpaceNonCommentCharacterIndex(text, comment, options);
|
|
22359
|
-
|
|
22360
|
-
if (text.substr(index, 2) === "=>") {
|
|
22361
|
-
addDanglingComment$2(enclosingNode, comment);
|
|
22362
|
-
return true;
|
|
22363
|
-
}
|
|
22364
|
-
|
|
22365
|
-
return false;
|
|
22366
|
-
}
|
|
22367
|
-
|
|
22368
|
-
function handleCommentInEmptyParens(text, enclosingNode, comment, options) {
|
|
22369
|
-
if (util$1.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd) !== ")") {
|
|
22370
|
-
return false;
|
|
22371
|
-
} // Only add dangling comments to fix the case when no params are present,
|
|
22372
|
-
// i.e. a function without any argument.
|
|
22373
|
-
|
|
22374
|
-
|
|
22375
|
-
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)) {
|
|
22376
|
-
addDanglingComment$2(enclosingNode, comment);
|
|
22377
|
-
return true;
|
|
22378
|
-
}
|
|
22379
|
-
|
|
22380
|
-
if (enclosingNode && enclosingNode.type === "MethodDefinition" && enclosingNode.value.params.length === 0) {
|
|
22381
|
-
addDanglingComment$2(enclosingNode.value, comment);
|
|
22382
|
-
return true;
|
|
22383
|
-
}
|
|
22384
|
-
|
|
22385
|
-
return false;
|
|
22386
|
-
}
|
|
22577
|
+
module.exports = function (str) {
|
|
22578
|
+
if (typeof str !== 'string') {
|
|
22579
|
+
throw new TypeError('Expected a string');
|
|
22580
|
+
}
|
|
22387
22581
|
|
|
22388
|
-
|
|
22389
|
-
// Type definitions functions
|
|
22390
|
-
if (precedingNode && precedingNode.type === "FunctionTypeParam" && enclosingNode && enclosingNode.type === "FunctionTypeAnnotation" && followingNode && followingNode.type !== "FunctionTypeParam") {
|
|
22391
|
-
addTrailingComment$2(precedingNode, comment);
|
|
22392
|
-
return true;
|
|
22393
|
-
} // Real functions
|
|
22582
|
+
var newlines = str.match(/(?:\r?\n)/g) || [];
|
|
22394
22583
|
|
|
22584
|
+
if (newlines.length === 0) {
|
|
22585
|
+
return null;
|
|
22586
|
+
}
|
|
22395
22587
|
|
|
22396
|
-
|
|
22397
|
-
|
|
22398
|
-
|
|
22399
|
-
|
|
22588
|
+
var crlf = newlines.filter(function (el) {
|
|
22589
|
+
return el === '\r\n';
|
|
22590
|
+
}).length;
|
|
22591
|
+
var lf = newlines.length - crlf;
|
|
22592
|
+
return crlf > lf ? '\r\n' : '\n';
|
|
22593
|
+
};
|
|
22400
22594
|
|
|
22401
|
-
|
|
22402
|
-
|
|
22403
|
-
|
|
22404
|
-
|
|
22405
|
-
}
|
|
22595
|
+
module.exports.graceful = function (str) {
|
|
22596
|
+
return module.exports(str) || '\n';
|
|
22597
|
+
};
|
|
22598
|
+
});
|
|
22406
22599
|
|
|
22407
|
-
|
|
22408
|
-
|
|
22409
|
-
}();
|
|
22600
|
+
var build$1 = createCommonjsModule(function (module, exports) {
|
|
22601
|
+
'use strict';
|
|
22410
22602
|
|
|
22411
|
-
|
|
22412
|
-
|
|
22413
|
-
|
|
22414
|
-
|
|
22415
|
-
|
|
22603
|
+
Object.defineProperty(exports, '__esModule', {
|
|
22604
|
+
value: true
|
|
22605
|
+
});
|
|
22606
|
+
exports.extract = extract;
|
|
22607
|
+
exports.strip = strip;
|
|
22608
|
+
exports.parse = parse;
|
|
22609
|
+
exports.parseWithComments = parseWithComments;
|
|
22610
|
+
exports.print = print;
|
|
22416
22611
|
|
|
22417
|
-
|
|
22418
|
-
}
|
|
22612
|
+
var _detectNewline;
|
|
22419
22613
|
|
|
22420
|
-
function
|
|
22421
|
-
|
|
22422
|
-
addLeadingComment$2(enclosingNode, comment);
|
|
22423
|
-
return true;
|
|
22614
|
+
function _load_detectNewline() {
|
|
22615
|
+
return _detectNewline = _interopRequireDefault(detectNewline);
|
|
22424
22616
|
}
|
|
22425
22617
|
|
|
22426
|
-
|
|
22427
|
-
}
|
|
22618
|
+
var _os;
|
|
22428
22619
|
|
|
22429
|
-
function
|
|
22430
|
-
|
|
22431
|
-
addLeadingComment$2(enclosingNode, comment);
|
|
22432
|
-
return true;
|
|
22620
|
+
function _load_os() {
|
|
22621
|
+
return _os = os;
|
|
22433
22622
|
}
|
|
22434
22623
|
|
|
22435
|
-
|
|
22436
|
-
|
|
22437
|
-
|
|
22438
|
-
|
|
22439
|
-
if (enclosingNode && (enclosingNode.type === "ContinueStatement" || enclosingNode.type === "BreakStatement") && !enclosingNode.label) {
|
|
22440
|
-
addTrailingComment$2(enclosingNode, comment);
|
|
22441
|
-
return true;
|
|
22624
|
+
function _interopRequireDefault(obj) {
|
|
22625
|
+
return obj && obj.__esModule ? obj : {
|
|
22626
|
+
default: obj
|
|
22627
|
+
};
|
|
22442
22628
|
}
|
|
22629
|
+
/**
|
|
22630
|
+
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
|
22631
|
+
*
|
|
22632
|
+
* This source code is licensed under the MIT license found in the
|
|
22633
|
+
* LICENSE file in the root directory of this source tree.
|
|
22634
|
+
*
|
|
22635
|
+
*
|
|
22636
|
+
*/
|
|
22443
22637
|
|
|
22444
|
-
return false;
|
|
22445
|
-
}
|
|
22446
22638
|
|
|
22447
|
-
|
|
22448
|
-
|
|
22449
|
-
|
|
22450
|
-
|
|
22639
|
+
var commentEndRe = /\*\/$/;
|
|
22640
|
+
var commentStartRe = /^\/\*\*/;
|
|
22641
|
+
var docblockRe = /^\s*(\/\*\*?(.|\r?\n)*?\*\/)/;
|
|
22642
|
+
var lineCommentRe = /(^|\s+)\/\/([^\r\n]*)/g;
|
|
22643
|
+
var ltrimNewlineRe = /^(\r?\n)+/;
|
|
22644
|
+
var multilineRe = /(?:^|\r?\n) *(@[^\r\n]*?) *\r?\n *(?![^@\r\n]*\/\/[^]*)([^@\r\n\s][^@\r\n]+?) *\r?\n/g;
|
|
22645
|
+
var propertyRe = /(?:^|\r?\n) *@(\S+) *([^\r\n]*)/g;
|
|
22646
|
+
var stringStartRe = /(\r?\n|^) *\* ?/g;
|
|
22647
|
+
|
|
22648
|
+
function extract(contents) {
|
|
22649
|
+
var match = contents.match(docblockRe);
|
|
22650
|
+
return match ? match[0].trimLeft() : '';
|
|
22451
22651
|
}
|
|
22452
22652
|
|
|
22453
|
-
|
|
22454
|
-
|
|
22653
|
+
function strip(contents) {
|
|
22654
|
+
var match = contents.match(docblockRe);
|
|
22655
|
+
return match && match[0] ? contents.substring(match[0].length) : contents;
|
|
22656
|
+
}
|
|
22455
22657
|
|
|
22456
|
-
function
|
|
22457
|
-
|
|
22458
|
-
addTrailingComment$2(precedingNode, comment);
|
|
22459
|
-
return true;
|
|
22658
|
+
function parse(docblock) {
|
|
22659
|
+
return parseWithComments(docblock).pragmas;
|
|
22460
22660
|
}
|
|
22461
22661
|
|
|
22462
|
-
|
|
22463
|
-
|
|
22662
|
+
function parseWithComments(docblock) {
|
|
22663
|
+
var line = (0, (_detectNewline || _load_detectNewline()).default)(docblock) || (_os || _load_os()).EOL;
|
|
22464
22664
|
|
|
22465
|
-
|
|
22466
|
-
if (enclosingNode && (enclosingNode.type === "Property" || enclosingNode.type === "ObjectProperty")) {
|
|
22467
|
-
addLeadingComment$2(enclosingNode, comment);
|
|
22468
|
-
return true;
|
|
22469
|
-
}
|
|
22665
|
+
docblock = docblock.replace(commentStartRe, '').replace(commentEndRe, '').replace(stringStartRe, '$1'); // Normalize multi-line directives
|
|
22470
22666
|
|
|
22471
|
-
|
|
22472
|
-
}
|
|
22667
|
+
var prev = '';
|
|
22473
22668
|
|
|
22474
|
-
|
|
22475
|
-
|
|
22476
|
-
|
|
22477
|
-
if (isLastComment) {
|
|
22478
|
-
addDanglingComment$2(ast, comment);
|
|
22479
|
-
} else {
|
|
22480
|
-
addLeadingComment$2(ast, comment);
|
|
22669
|
+
while (prev !== docblock) {
|
|
22670
|
+
prev = docblock;
|
|
22671
|
+
docblock = docblock.replace(multilineRe, `${line}$1 $2${line}`);
|
|
22481
22672
|
}
|
|
22482
22673
|
|
|
22483
|
-
|
|
22484
|
-
|
|
22485
|
-
|
|
22486
|
-
|
|
22487
|
-
} else {
|
|
22488
|
-
addLeadingComment$2(enclosingNode, comment);
|
|
22489
|
-
}
|
|
22674
|
+
docblock = docblock.replace(ltrimNewlineRe, '').trimRight();
|
|
22675
|
+
var result = Object.create(null);
|
|
22676
|
+
var comments = docblock.replace(propertyRe, '').replace(ltrimNewlineRe, '').trimRight();
|
|
22677
|
+
var match;
|
|
22490
22678
|
|
|
22491
|
-
|
|
22492
|
-
|
|
22679
|
+
while (match = propertyRe.exec(docblock)) {
|
|
22680
|
+
// strip linecomments from pragmas
|
|
22681
|
+
var nextPragma = match[2].replace(lineCommentRe, '');
|
|
22493
22682
|
|
|
22494
|
-
|
|
22495
|
-
|
|
22683
|
+
if (typeof result[match[1]] === 'string' || Array.isArray(result[match[1]])) {
|
|
22684
|
+
result[match[1]] = [].concat(result[match[1]], nextPragma);
|
|
22685
|
+
} else {
|
|
22686
|
+
result[match[1]] = nextPragma;
|
|
22687
|
+
}
|
|
22688
|
+
}
|
|
22496
22689
|
|
|
22497
|
-
|
|
22498
|
-
|
|
22499
|
-
|
|
22500
|
-
|
|
22690
|
+
return {
|
|
22691
|
+
comments,
|
|
22692
|
+
pragmas: result
|
|
22693
|
+
};
|
|
22501
22694
|
}
|
|
22502
22695
|
|
|
22503
|
-
|
|
22504
|
-
|
|
22696
|
+
function print(_ref) {
|
|
22697
|
+
var _ref$comments = _ref.comments;
|
|
22698
|
+
var comments = _ref$comments === undefined ? '' : _ref$comments;
|
|
22699
|
+
var _ref$pragmas = _ref.pragmas;
|
|
22700
|
+
var pragmas = _ref$pragmas === undefined ? {} : _ref$pragmas;
|
|
22505
22701
|
|
|
22506
|
-
|
|
22507
|
-
if (precedingNode && precedingNode.type === "ImportSpecifier" && enclosingNode && enclosingNode.type === "ImportDeclaration" && util$1.hasNewline(text, options.locEnd(comment))) {
|
|
22508
|
-
addTrailingComment$2(precedingNode, comment);
|
|
22509
|
-
return true;
|
|
22510
|
-
}
|
|
22702
|
+
var line = (0, (_detectNewline || _load_detectNewline()).default)(comments) || (_os || _load_os()).EOL;
|
|
22511
22703
|
|
|
22512
|
-
|
|
22513
|
-
|
|
22704
|
+
var head = '/**';
|
|
22705
|
+
var start = ' *';
|
|
22706
|
+
var tail = ' */';
|
|
22707
|
+
var keys = Object.keys(pragmas);
|
|
22708
|
+
var printedObject = keys.map(function (key) {
|
|
22709
|
+
return printKeyValues(key, pragmas[key]);
|
|
22710
|
+
}).reduce(function (arr, next) {
|
|
22711
|
+
return arr.concat(next);
|
|
22712
|
+
}, []).map(function (keyValue) {
|
|
22713
|
+
return start + ' ' + keyValue + line;
|
|
22714
|
+
}).join('');
|
|
22514
22715
|
|
|
22515
|
-
|
|
22516
|
-
|
|
22517
|
-
|
|
22518
|
-
|
|
22519
|
-
}
|
|
22716
|
+
if (!comments) {
|
|
22717
|
+
if (keys.length === 0) {
|
|
22718
|
+
return '';
|
|
22719
|
+
}
|
|
22520
22720
|
|
|
22521
|
-
|
|
22522
|
-
|
|
22721
|
+
if (keys.length === 1 && !Array.isArray(pragmas[keys[0]])) {
|
|
22722
|
+
var value = pragmas[keys[0]];
|
|
22723
|
+
return `${head} ${printKeyValues(keys[0], value)[0]}${tail}`;
|
|
22724
|
+
}
|
|
22725
|
+
}
|
|
22523
22726
|
|
|
22524
|
-
|
|
22525
|
-
|
|
22526
|
-
|
|
22527
|
-
return
|
|
22727
|
+
var printedComments = comments.split(line).map(function (textLine) {
|
|
22728
|
+
return `${start} ${textLine}`;
|
|
22729
|
+
}).join(line) + line;
|
|
22730
|
+
return head + line + (comments ? printedComments : '') + (comments && keys.length ? start + line : '') + printedObject + tail;
|
|
22528
22731
|
}
|
|
22529
22732
|
|
|
22530
|
-
|
|
22531
|
-
|
|
22532
|
-
|
|
22533
|
-
|
|
22534
|
-
if (enclosingNode && (enclosingNode.type === "VariableDeclarator" || enclosingNode.type === "AssignmentExpression") && followingNode && (followingNode.type === "ObjectExpression" || followingNode.type === "ArrayExpression" || followingNode.type === "TemplateLiteral" || followingNode.type === "TaggedTemplateExpression")) {
|
|
22535
|
-
addLeadingComment$2(followingNode, comment);
|
|
22536
|
-
return true;
|
|
22733
|
+
function printKeyValues(key, valueOrArray) {
|
|
22734
|
+
return [].concat(valueOrArray).map(function (value) {
|
|
22735
|
+
return `@${key} ${value}`.trim();
|
|
22736
|
+
});
|
|
22537
22737
|
}
|
|
22738
|
+
});
|
|
22739
|
+
unwrapExports(build$1);
|
|
22538
22740
|
|
|
22539
|
-
|
|
22741
|
+
function hasPragma(text) {
|
|
22742
|
+
var pragmas = Object.keys(build$1.parse(build$1.extract(text)));
|
|
22743
|
+
return pragmas.indexOf("prettier") !== -1 || pragmas.indexOf("format") !== -1;
|
|
22540
22744
|
}
|
|
22541
22745
|
|
|
22542
|
-
function
|
|
22543
|
-
|
|
22544
|
-
|
|
22545
|
-
|
|
22546
|
-
|
|
22547
|
-
|
|
22548
|
-
|
|
22549
|
-
|
|
22550
|
-
}
|
|
22551
|
-
|
|
22552
|
-
if (precedingNode && precedingNode.type === "TSTypeParameter" && precedingNode.constraint) {
|
|
22553
|
-
addTrailingComment$2(precedingNode.constraint, comment);
|
|
22554
|
-
return true;
|
|
22555
|
-
}
|
|
22746
|
+
function insertPragma$1(text) {
|
|
22747
|
+
var parsedDocblock = build$1.parseWithComments(build$1.extract(text));
|
|
22748
|
+
var pragmas = Object.assign({
|
|
22749
|
+
format: ""
|
|
22750
|
+
}, parsedDocblock.pragmas);
|
|
22751
|
+
var newDocblock = build$1.print({
|
|
22752
|
+
pragmas,
|
|
22753
|
+
comments: parsedDocblock.comments.replace(/^(\s+?\r?\n)+/, "") // remove leading newlines
|
|
22556
22754
|
|
|
22557
|
-
|
|
22558
|
-
}
|
|
22755
|
+
}).replace(/(\r\n|\r)/g, "\n"); // normalise newlines (mitigate use of os.EOL by jest-docblock)
|
|
22559
22756
|
|
|
22560
|
-
|
|
22561
|
-
|
|
22757
|
+
var strippedText = build$1.strip(text);
|
|
22758
|
+
var separatingNewlines = strippedText.startsWith("\n") ? "\n" : "\n\n";
|
|
22759
|
+
return newDocblock + separatingNewlines + strippedText;
|
|
22562
22760
|
}
|
|
22563
22761
|
|
|
22564
|
-
var
|
|
22565
|
-
|
|
22566
|
-
|
|
22567
|
-
handleRemainingComment,
|
|
22568
|
-
isBlockComment
|
|
22762
|
+
var pragma = {
|
|
22763
|
+
hasPragma,
|
|
22764
|
+
insertPragma: insertPragma$1
|
|
22569
22765
|
};
|
|
22570
22766
|
|
|
22571
22767
|
// Flow annotation comments cannot be split across lines. For example:
|
|
@@ -22629,9 +22825,62 @@ function hasClosureCompilerTypeCastComment(text, path$$1, locStart, locEnd) {
|
|
|
22629
22825
|
|
|
22630
22826
|
function hasTypeCastComment(node) {
|
|
22631
22827
|
return node.comments && node.comments.some(function (comment) {
|
|
22632
|
-
return comment.leading && comments$3.isBlockComment(comment) && comment.value
|
|
22828
|
+
return comment.leading && comments$3.isBlockComment(comment) && isTypeCastComment(comment.value) && util$1.getNextNonSpaceNonCommentCharacter(text, comment, locEnd) === "(";
|
|
22633
22829
|
});
|
|
22634
22830
|
}
|
|
22831
|
+
|
|
22832
|
+
function isTypeCastComment(comment) {
|
|
22833
|
+
var trimmed = comment.trim();
|
|
22834
|
+
|
|
22835
|
+
if (!/^\*\s*@type\s*\{[^]+\}$/.test(trimmed)) {
|
|
22836
|
+
return false;
|
|
22837
|
+
}
|
|
22838
|
+
|
|
22839
|
+
var isCompletelyClosed = false;
|
|
22840
|
+
var unpairedBracketCount = 0;
|
|
22841
|
+
var _iteratorNormalCompletion = true;
|
|
22842
|
+
var _didIteratorError = false;
|
|
22843
|
+
var _iteratorError = undefined;
|
|
22844
|
+
|
|
22845
|
+
try {
|
|
22846
|
+
for (var _iterator = trimmed[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
22847
|
+
var char = _step.value;
|
|
22848
|
+
|
|
22849
|
+
if (char === "{") {
|
|
22850
|
+
if (isCompletelyClosed) {
|
|
22851
|
+
return false;
|
|
22852
|
+
}
|
|
22853
|
+
|
|
22854
|
+
unpairedBracketCount++;
|
|
22855
|
+
} else if (char === "}") {
|
|
22856
|
+
if (unpairedBracketCount === 0) {
|
|
22857
|
+
return false;
|
|
22858
|
+
}
|
|
22859
|
+
|
|
22860
|
+
unpairedBracketCount--;
|
|
22861
|
+
|
|
22862
|
+
if (unpairedBracketCount === 0) {
|
|
22863
|
+
isCompletelyClosed = true;
|
|
22864
|
+
}
|
|
22865
|
+
}
|
|
22866
|
+
}
|
|
22867
|
+
} catch (err) {
|
|
22868
|
+
_didIteratorError = true;
|
|
22869
|
+
_iteratorError = err;
|
|
22870
|
+
} finally {
|
|
22871
|
+
try {
|
|
22872
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
22873
|
+
_iterator.return();
|
|
22874
|
+
}
|
|
22875
|
+
} finally {
|
|
22876
|
+
if (_didIteratorError) {
|
|
22877
|
+
throw _iteratorError;
|
|
22878
|
+
}
|
|
22879
|
+
}
|
|
22880
|
+
}
|
|
22881
|
+
|
|
22882
|
+
return unpairedBracketCount === 0;
|
|
22883
|
+
}
|
|
22635
22884
|
}
|
|
22636
22885
|
|
|
22637
22886
|
function needsParens(path$$1, options) {
|
|
@@ -22648,6 +22897,11 @@ function needsParens(path$$1, options) {
|
|
|
22648
22897
|
|
|
22649
22898
|
if (path$$1.getValue() !== node) {
|
|
22650
22899
|
return false;
|
|
22900
|
+
} // to avoid unexpected `}}` in HTML interpolations
|
|
22901
|
+
|
|
22902
|
+
|
|
22903
|
+
if (options.__isInHtmlInterpolation && !options.bracketSpacing && endsWithRightBracket(node) && isFollowedByRightBracket(path$$1)) {
|
|
22904
|
+
return true;
|
|
22651
22905
|
} // Only statements don't need parentheses.
|
|
22652
22906
|
|
|
22653
22907
|
|
|
@@ -22683,6 +22937,42 @@ function needsParens(path$$1, options) {
|
|
|
22683
22937
|
return true;
|
|
22684
22938
|
}
|
|
22685
22939
|
|
|
22940
|
+
if (parent.type === "Decorator" && parent.expression === node) {
|
|
22941
|
+
var hasCallExpression = false;
|
|
22942
|
+
var hasMemberExpression = false;
|
|
22943
|
+
var current = node;
|
|
22944
|
+
|
|
22945
|
+
while (current) {
|
|
22946
|
+
switch (current.type) {
|
|
22947
|
+
case "MemberExpression":
|
|
22948
|
+
hasMemberExpression = true;
|
|
22949
|
+
current = current.object;
|
|
22950
|
+
break;
|
|
22951
|
+
|
|
22952
|
+
case "CallExpression":
|
|
22953
|
+
if (
|
|
22954
|
+
/** @(x().y) */
|
|
22955
|
+
hasMemberExpression ||
|
|
22956
|
+
/** @(x().y()) */
|
|
22957
|
+
hasCallExpression) {
|
|
22958
|
+
return true;
|
|
22959
|
+
}
|
|
22960
|
+
|
|
22961
|
+
hasCallExpression = true;
|
|
22962
|
+
current = current.callee;
|
|
22963
|
+
break;
|
|
22964
|
+
|
|
22965
|
+
case "Identifier":
|
|
22966
|
+
return false;
|
|
22967
|
+
|
|
22968
|
+
default:
|
|
22969
|
+
return true;
|
|
22970
|
+
}
|
|
22971
|
+
}
|
|
22972
|
+
|
|
22973
|
+
return true;
|
|
22974
|
+
}
|
|
22975
|
+
|
|
22686
22976
|
if (parent.type === "ArrowFunctionExpression" && parent.body === node && node.type !== "SequenceExpression" && // these have parens added anyway
|
|
22687
22977
|
util$1.startsWithNoLookaheadToken(node,
|
|
22688
22978
|
/* forbidFunctionClassAndDoExpr */
|
|
@@ -22784,7 +23074,7 @@ function needsParens(path$$1, options) {
|
|
|
22784
23074
|
}
|
|
22785
23075
|
// fallthrough
|
|
22786
23076
|
|
|
22787
|
-
case "
|
|
23077
|
+
case "TSTypeAssertion":
|
|
22788
23078
|
case "TSAsExpression":
|
|
22789
23079
|
case "LogicalExpression":
|
|
22790
23080
|
switch (parent.type) {
|
|
@@ -22800,7 +23090,7 @@ function needsParens(path$$1, options) {
|
|
|
22800
23090
|
case "TSAbstractClassDeclaration":
|
|
22801
23091
|
return name === "superClass" && parent.superClass === node;
|
|
22802
23092
|
|
|
22803
|
-
case "
|
|
23093
|
+
case "TSTypeAssertion":
|
|
22804
23094
|
case "TaggedTemplateExpression":
|
|
22805
23095
|
case "UnaryExpression":
|
|
22806
23096
|
case "SpreadElement":
|
|
@@ -22817,15 +23107,12 @@ function needsParens(path$$1, options) {
|
|
|
22817
23107
|
return name === "object" && parent.object === node;
|
|
22818
23108
|
|
|
22819
23109
|
case "AssignmentExpression":
|
|
22820
|
-
return parent.left === node && (node.type === "
|
|
22821
|
-
|
|
22822
|
-
case "Decorator":
|
|
22823
|
-
return parent.expression === node && (node.type === "TSTypeAssertionExpression" || node.type === "TSAsExpression");
|
|
23110
|
+
return parent.left === node && (node.type === "TSTypeAssertion" || node.type === "TSAsExpression");
|
|
22824
23111
|
|
|
22825
23112
|
case "BinaryExpression":
|
|
22826
23113
|
case "LogicalExpression":
|
|
22827
23114
|
{
|
|
22828
|
-
if (!node.operator && node.type !== "
|
|
23115
|
+
if (!node.operator && node.type !== "TSTypeAssertion") {
|
|
22829
23116
|
return true;
|
|
22830
23117
|
}
|
|
22831
23118
|
|
|
@@ -22871,8 +23158,16 @@ function needsParens(path$$1, options) {
|
|
|
22871
23158
|
case "TSParenthesizedType":
|
|
22872
23159
|
{
|
|
22873
23160
|
var grandParent = path$$1.getParentNode(1);
|
|
23161
|
+
/**
|
|
23162
|
+
* const foo = (): (() => void) => (): void => null;
|
|
23163
|
+
* ^ ^
|
|
23164
|
+
*/
|
|
23165
|
+
|
|
23166
|
+
if (getUnparenthesizedNode(node).type === "TSFunctionType" && parent.type === "TSTypeAnnotation" && grandParent.type === "ArrowFunctionExpression" && grandParent.returnType === parent) {
|
|
23167
|
+
return true;
|
|
23168
|
+
}
|
|
22874
23169
|
|
|
22875
|
-
if ((parent.type === "TSTypeParameter" || parent.type === "TypeParameter" || parent.type === "
|
|
23170
|
+
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") {
|
|
22876
23171
|
return false;
|
|
22877
23172
|
} // Delegate to inner TSParenthesizedType
|
|
22878
23173
|
|
|
@@ -23018,7 +23313,7 @@ function needsParens(path$$1, options) {
|
|
|
23018
23313
|
case "ExportDefaultDeclaration":
|
|
23019
23314
|
case "AwaitExpression":
|
|
23020
23315
|
case "JSXSpreadAttribute":
|
|
23021
|
-
case "
|
|
23316
|
+
case "TSTypeAssertion":
|
|
23022
23317
|
case "TypeCastExpression":
|
|
23023
23318
|
case "TSAsExpression":
|
|
23024
23319
|
case "TSNonNullExpression":
|
|
@@ -23074,7 +23369,7 @@ function needsParens(path$$1, options) {
|
|
|
23074
23369
|
case "LogicalExpression":
|
|
23075
23370
|
case "BinaryExpression":
|
|
23076
23371
|
case "AwaitExpression":
|
|
23077
|
-
case "
|
|
23372
|
+
case "TSTypeAssertion":
|
|
23078
23373
|
return true;
|
|
23079
23374
|
|
|
23080
23375
|
case "ConditionalExpression":
|
|
@@ -23128,15 +23423,76 @@ function needsParens(path$$1, options) {
|
|
|
23128
23423
|
}
|
|
23129
23424
|
|
|
23130
23425
|
function isStatement(node) {
|
|
23131
|
-
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";
|
|
23426
|
+
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";
|
|
23427
|
+
}
|
|
23428
|
+
|
|
23429
|
+
function getUnparenthesizedNode(node) {
|
|
23430
|
+
return node.type === "TSParenthesizedType" ? getUnparenthesizedNode(node.typeAnnotation) : node;
|
|
23431
|
+
}
|
|
23432
|
+
|
|
23433
|
+
function endsWithRightBracket(node) {
|
|
23434
|
+
switch (node.type) {
|
|
23435
|
+
case "ObjectExpression":
|
|
23436
|
+
return true;
|
|
23437
|
+
|
|
23438
|
+
default:
|
|
23439
|
+
return false;
|
|
23440
|
+
}
|
|
23441
|
+
}
|
|
23442
|
+
|
|
23443
|
+
function isFollowedByRightBracket(path$$1) {
|
|
23444
|
+
var node = path$$1.getValue();
|
|
23445
|
+
var parent = path$$1.getParentNode();
|
|
23446
|
+
var name = path$$1.getName();
|
|
23447
|
+
|
|
23448
|
+
switch (parent.type) {
|
|
23449
|
+
case "NGPipeExpression":
|
|
23450
|
+
if (typeof name === "number" && parent.arguments[name] === node && parent.arguments.length - 1 === name) {
|
|
23451
|
+
return path$$1.callParent(isFollowedByRightBracket);
|
|
23452
|
+
}
|
|
23453
|
+
|
|
23454
|
+
break;
|
|
23455
|
+
|
|
23456
|
+
case "ObjectProperty":
|
|
23457
|
+
if (name === "value") {
|
|
23458
|
+
var parentParent = path$$1.getParentNode(1);
|
|
23459
|
+
return parentParent.properties[parentParent.properties.length - 1] === parent;
|
|
23460
|
+
}
|
|
23461
|
+
|
|
23462
|
+
break;
|
|
23463
|
+
|
|
23464
|
+
case "BinaryExpression":
|
|
23465
|
+
case "LogicalExpression":
|
|
23466
|
+
if (name === "right") {
|
|
23467
|
+
return path$$1.callParent(isFollowedByRightBracket);
|
|
23468
|
+
}
|
|
23469
|
+
|
|
23470
|
+
break;
|
|
23471
|
+
|
|
23472
|
+
case "ConditionalExpression":
|
|
23473
|
+
if (name === "alternate") {
|
|
23474
|
+
return path$$1.callParent(isFollowedByRightBracket);
|
|
23475
|
+
}
|
|
23476
|
+
|
|
23477
|
+
break;
|
|
23478
|
+
|
|
23479
|
+
case "UnaryExpression":
|
|
23480
|
+
if (parent.prefix) {
|
|
23481
|
+
return path$$1.callParent(isFollowedByRightBracket);
|
|
23482
|
+
}
|
|
23483
|
+
|
|
23484
|
+
break;
|
|
23485
|
+
}
|
|
23486
|
+
|
|
23487
|
+
return false;
|
|
23132
23488
|
}
|
|
23133
23489
|
|
|
23134
23490
|
var needsParens_1 = needsParens;
|
|
23135
23491
|
|
|
23136
|
-
var _require$$0$builders$
|
|
23137
|
-
var concat$6 = _require$$0$builders$
|
|
23138
|
-
var join$4 = _require$$0$builders$
|
|
23139
|
-
var line$4 = _require$$0$builders$
|
|
23492
|
+
var _require$$0$builders$1 = doc.builders;
|
|
23493
|
+
var concat$6 = _require$$0$builders$1.concat;
|
|
23494
|
+
var join$4 = _require$$0$builders$1.join;
|
|
23495
|
+
var line$4 = _require$$0$builders$1.line;
|
|
23140
23496
|
|
|
23141
23497
|
function printHtmlBinding$1(path$$1, options, print) {
|
|
23142
23498
|
var node = path$$1.getValue();
|
|
@@ -23300,7 +23656,7 @@ function genericPrint(path$$1, options, printPath, args) {
|
|
|
23300
23656
|
var parentExportDecl = getParentExportDeclaration$1(path$$1);
|
|
23301
23657
|
var decorators = [];
|
|
23302
23658
|
|
|
23303
|
-
if (node.type === "ClassMethod" || node.type === "ClassProperty" || node.type === "TSAbstractClassProperty" || node.type === "ClassPrivateProperty" || node.type === "MethodDefinition" || node.type === "TSAbstractMethodDefinition") {// their decorators are handled themselves
|
|
23659
|
+
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
|
|
23304
23660
|
} else if (node.decorators && node.decorators.length > 0 && // If the parent node is an export declaration and the decorator
|
|
23305
23661
|
// was written before the export, the export will be responsible
|
|
23306
23662
|
// for printing the decorators.
|
|
@@ -23513,9 +23869,9 @@ function printTernaryOperator(path$$1, options, print, operatorOptions) {
|
|
|
23513
23869
|
}
|
|
23514
23870
|
|
|
23515
23871
|
function getTypeScriptMappedTypeModifier(tokenNode, keyword) {
|
|
23516
|
-
if (tokenNode
|
|
23872
|
+
if (tokenNode === "+") {
|
|
23517
23873
|
return "+" + keyword;
|
|
23518
|
-
} else if (tokenNode
|
|
23874
|
+
} else if (tokenNode === "-") {
|
|
23519
23875
|
return "-" + keyword;
|
|
23520
23876
|
}
|
|
23521
23877
|
|
|
@@ -23697,7 +24053,7 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
23697
24053
|
case "AssignmentPattern":
|
|
23698
24054
|
return concat$4([path$$1.call(print, "left"), " = ", path$$1.call(print, "right")]);
|
|
23699
24055
|
|
|
23700
|
-
case "
|
|
24056
|
+
case "TSTypeAssertion":
|
|
23701
24057
|
{
|
|
23702
24058
|
var shouldBreakAfterCast = !(n.expression.type === "ArrayExpression" || n.expression.type === "ObjectExpression");
|
|
23703
24059
|
var castGroup = group$1(concat$4(["<", indent$2(concat$4([softline$1, path$$1.call(print, "typeAnnotation")])), softline$1, ">"]));
|
|
@@ -23756,10 +24112,6 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
23756
24112
|
|
|
23757
24113
|
case "FunctionDeclaration":
|
|
23758
24114
|
case "FunctionExpression":
|
|
23759
|
-
if (isNodeStartingWithDeclare(n, options)) {
|
|
23760
|
-
parts.push("declare ");
|
|
23761
|
-
}
|
|
23762
|
-
|
|
23763
24115
|
parts.push(printFunctionDeclaration(path$$1, print, options));
|
|
23764
24116
|
|
|
23765
24117
|
if (!n.body) {
|
|
@@ -23887,21 +24239,11 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
23887
24239
|
|
|
23888
24240
|
case "ImportNamespaceSpecifier":
|
|
23889
24241
|
parts.push("* as ");
|
|
23890
|
-
|
|
23891
|
-
if (n.local) {
|
|
23892
|
-
parts.push(path$$1.call(print, "local"));
|
|
23893
|
-
} else if (n.id) {
|
|
23894
|
-
parts.push(path$$1.call(print, "id"));
|
|
23895
|
-
}
|
|
23896
|
-
|
|
24242
|
+
parts.push(path$$1.call(print, "local"));
|
|
23897
24243
|
return concat$4(parts);
|
|
23898
24244
|
|
|
23899
24245
|
case "ImportDefaultSpecifier":
|
|
23900
|
-
|
|
23901
|
-
return path$$1.call(print, "local");
|
|
23902
|
-
}
|
|
23903
|
-
|
|
23904
|
-
return path$$1.call(print, "id");
|
|
24246
|
+
return path$$1.call(print, "local");
|
|
23905
24247
|
|
|
23906
24248
|
case "TSExportAssignment":
|
|
23907
24249
|
return concat$4(["export = ", path$$1.call(print, "expression"), semi]);
|
|
@@ -23990,7 +24332,7 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
23990
24332
|
|
|
23991
24333
|
var _parentParent = path$$1.getParentNode(1);
|
|
23992
24334
|
|
|
23993
|
-
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")) {
|
|
24335
|
+
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")) {
|
|
23994
24336
|
return "{}";
|
|
23995
24337
|
}
|
|
23996
24338
|
|
|
@@ -24082,8 +24424,8 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
24082
24424
|
|
|
24083
24425
|
parts.push(n.abstract ? "abstract " : "", printTypeScriptModifiers(path$$1, options, print), "interface ", path$$1.call(print, "id"), n.typeParameters ? path$$1.call(print, "typeParameters") : "", " ");
|
|
24084
24426
|
|
|
24085
|
-
if (n.
|
|
24086
|
-
parts.push(group$1(indent$2(concat$4([softline$1, "extends ", (n.
|
|
24427
|
+
if (n.extends && n.extends.length) {
|
|
24428
|
+
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"))), " "]))));
|
|
24087
24429
|
}
|
|
24088
24430
|
|
|
24089
24431
|
parts.push(path$$1.call(print, "body"));
|
|
@@ -24152,7 +24494,7 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
24152
24494
|
var result = concat$4(separatorParts.concat(group$1(prop.printed)));
|
|
24153
24495
|
separatorParts = [separator, line$3];
|
|
24154
24496
|
|
|
24155
|
-
if ((prop.node.type === "TSPropertySignature" || prop.node.type === "TSMethodSignature" || prop.node.type === "
|
|
24497
|
+
if ((prop.node.type === "TSPropertySignature" || prop.node.type === "TSMethodSignature" || prop.node.type === "TSConstructSignatureDeclaration") && hasNodeIgnoreComment$1(prop.node)) {
|
|
24156
24498
|
separatorParts.shift();
|
|
24157
24499
|
}
|
|
24158
24500
|
|
|
@@ -24221,6 +24563,7 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
24221
24563
|
// Babel 6
|
|
24222
24564
|
|
|
24223
24565
|
case "ClassMethod":
|
|
24566
|
+
case "ClassPrivateMethod":
|
|
24224
24567
|
if (n.decorators && n.decorators.length !== 0) {
|
|
24225
24568
|
parts.push(printDecorators(path$$1, options, print));
|
|
24226
24569
|
}
|
|
@@ -24413,8 +24756,20 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
24413
24756
|
return group$1(concat$4(parts));
|
|
24414
24757
|
}
|
|
24415
24758
|
|
|
24759
|
+
case "TSTypeAliasDeclaration":
|
|
24760
|
+
{
|
|
24761
|
+
if (n.declare) {
|
|
24762
|
+
parts.push("declare ");
|
|
24763
|
+
}
|
|
24764
|
+
|
|
24765
|
+
var _printed = printAssignmentRight(n.id, n.typeAnnotation, n.typeAnnotation && path$$1.call(print, "typeAnnotation"), options);
|
|
24766
|
+
|
|
24767
|
+
parts.push("type ", path$$1.call(print, "id"), path$$1.call(print, "typeParameters"), " =", _printed, semi);
|
|
24768
|
+
return group$1(concat$4(parts));
|
|
24769
|
+
}
|
|
24770
|
+
|
|
24416
24771
|
case "VariableDeclarator":
|
|
24417
|
-
return printAssignment(n.id,
|
|
24772
|
+
return printAssignment(n.id, path$$1.call(print, "id"), " =", n.init, n.init && path$$1.call(print, "init"), options);
|
|
24418
24773
|
|
|
24419
24774
|
case "WithStatement":
|
|
24420
24775
|
return group$1(concat$4(["with (", path$$1.call(print, "object"), ")", adjustClause(n.body, path$$1.call(print, "body"))]));
|
|
@@ -24472,7 +24827,7 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
24472
24827
|
case "ForOfStatement":
|
|
24473
24828
|
case "ForAwaitStatement":
|
|
24474
24829
|
{
|
|
24475
|
-
//
|
|
24830
|
+
// Babel 7 removed ForAwaitStatement in favor of ForOfStatement
|
|
24476
24831
|
// with `"await": true`:
|
|
24477
24832
|
// https://github.com/estree/estree/pull/138
|
|
24478
24833
|
var isAwait = n.type === "ForAwaitStatement" || n.await;
|
|
@@ -24795,7 +25150,7 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
24795
25150
|
return concat$4(parts);
|
|
24796
25151
|
|
|
24797
25152
|
case "TSInterfaceHeritage":
|
|
24798
|
-
parts.push(path$$1.call(print, "
|
|
25153
|
+
parts.push(path$$1.call(print, "expression"));
|
|
24799
25154
|
|
|
24800
25155
|
if (n.typeParameters) {
|
|
24801
25156
|
parts.push(path$$1.call(print, "typeParameters"));
|
|
@@ -24839,7 +25194,8 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
24839
25194
|
})) {
|
|
24840
25195
|
var stringifiedExpressions = expressions.map(function (doc$$2) {
|
|
24841
25196
|
return "${" + printDocToString$2(doc$$2, Object.assign({}, options, {
|
|
24842
|
-
printWidth: Infinity
|
|
25197
|
+
printWidth: Infinity,
|
|
25198
|
+
endOfLine: "lf"
|
|
24843
25199
|
})).formatted + "}";
|
|
24844
25200
|
});
|
|
24845
25201
|
var tableBody = [{
|
|
@@ -24909,14 +25265,15 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
24909
25265
|
// expression inside at the beginning of ${ instead of the beginning
|
|
24910
25266
|
// of the `.
|
|
24911
25267
|
var tabWidth = options.tabWidth;
|
|
24912
|
-
var
|
|
24913
|
-
var
|
|
25268
|
+
var quasi = childPath.getValue();
|
|
25269
|
+
var indentSize = getIndentSize$1(quasi.value.raw, tabWidth);
|
|
25270
|
+
var _printed2 = expressions[i];
|
|
24914
25271
|
|
|
24915
25272
|
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") {
|
|
24916
|
-
|
|
25273
|
+
_printed2 = concat$4([indent$2(concat$4([softline$1, _printed2])), softline$1]);
|
|
24917
25274
|
}
|
|
24918
25275
|
|
|
24919
|
-
var aligned = addAlignmentToDoc$2(
|
|
25276
|
+
var aligned = indentSize === 0 && quasi.value.raw.endsWith("\n") ? align$1(-Infinity, _printed2) : addAlignmentToDoc$2(_printed2, indentSize, tabWidth);
|
|
24920
25277
|
parts.push(group$1(concat$4(["${", aligned, lineSuffixBoundary$1, "}"])));
|
|
24921
25278
|
}
|
|
24922
25279
|
}, "quasis");
|
|
@@ -24993,13 +25350,12 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
24993
25350
|
case "DeclareClass":
|
|
24994
25351
|
return printFlowDeclaration(path$$1, printClass(path$$1, options, print));
|
|
24995
25352
|
|
|
24996
|
-
case "
|
|
24997
|
-
// For TypeScript the
|
|
25353
|
+
case "TSDeclareFunction":
|
|
25354
|
+
// For TypeScript the TSDeclareFunction node shares the AST
|
|
24998
25355
|
// structure with FunctionDeclaration
|
|
24999
|
-
|
|
25000
|
-
return concat$4(["declare ", printFunctionDeclaration(path$$1, print, options), semi]);
|
|
25001
|
-
}
|
|
25356
|
+
return concat$4([n.declare ? "declare " : "", printFunctionDeclaration(path$$1, print, options), semi]);
|
|
25002
25357
|
|
|
25358
|
+
case "DeclareFunction":
|
|
25003
25359
|
return printFlowDeclaration(path$$1, ["function ", path$$1.call(print, "id"), n.predicate ? " " : "", path$$1.call(print, "predicate"), semi]);
|
|
25004
25360
|
|
|
25005
25361
|
case "DeclareModule":
|
|
@@ -25123,6 +25479,9 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
25123
25479
|
case "InterfaceExtends":
|
|
25124
25480
|
return concat$4([path$$1.call(print, "id"), path$$1.call(print, "typeParameters")]);
|
|
25125
25481
|
|
|
25482
|
+
case "TSClassImplements":
|
|
25483
|
+
return concat$4([path$$1.call(print, "expression"), path$$1.call(print, "typeParameters")]);
|
|
25484
|
+
|
|
25126
25485
|
case "TSIntersectionType":
|
|
25127
25486
|
case "IntersectionTypeAnnotation":
|
|
25128
25487
|
{
|
|
@@ -25161,12 +25520,10 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
25161
25520
|
// | A
|
|
25162
25521
|
// | B
|
|
25163
25522
|
// | C
|
|
25164
|
-
var _parent8 = path$$1.getParentNode();
|
|
25165
|
-
|
|
25166
|
-
var _parentParent3 = path$$1.getParentNode(1); // If there's a leading comment, the parent is doing the indentation
|
|
25523
|
+
var _parent8 = path$$1.getParentNode(); // If there's a leading comment, the parent is doing the indentation
|
|
25167
25524
|
|
|
25168
25525
|
|
|
25169
|
-
var shouldIndent = _parent8.type !== "TypeParameterInstantiation" && _parent8.type !== "TSTypeParameterInstantiation" && _parent8.type !== "GenericTypeAnnotation" && _parent8.type !== "TSTypeReference" && !(_parent8.type === "FunctionTypeParam" && !_parent8.name) &&
|
|
25526
|
+
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)); // {
|
|
25170
25527
|
// a: string
|
|
25171
25528
|
// } | null | void
|
|
25172
25529
|
// should be inlined and not be printed in the multi-line variant
|
|
@@ -25176,7 +25533,7 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
25176
25533
|
// // comment
|
|
25177
25534
|
// | child2
|
|
25178
25535
|
|
|
25179
|
-
var
|
|
25536
|
+
var _printed3 = path$$1.map(function (typePath) {
|
|
25180
25537
|
var printedType = typePath.call(print);
|
|
25181
25538
|
|
|
25182
25539
|
if (!shouldHug) {
|
|
@@ -25189,11 +25546,11 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
25189
25546
|
}, "types");
|
|
25190
25547
|
|
|
25191
25548
|
if (shouldHug) {
|
|
25192
|
-
return join$2(" | ",
|
|
25549
|
+
return join$2(" | ", _printed3);
|
|
25193
25550
|
}
|
|
25194
25551
|
|
|
25195
25552
|
var shouldAddStartLine = shouldIndent && !hasLeadingOwnLineComment(options.originalText, n, options);
|
|
25196
|
-
var code = concat$4([ifBreak$1(concat$4([shouldAddStartLine ? line$3 : "", "| "])), join$2(concat$4([line$3, "| "]),
|
|
25553
|
+
var code = concat$4([ifBreak$1(concat$4([shouldAddStartLine ? line$3 : "", "| "])), join$2(concat$4([line$3, "| "]), _printed3)]);
|
|
25197
25554
|
var hasParens;
|
|
25198
25555
|
|
|
25199
25556
|
if (n.type === "TSUnionType") {
|
|
@@ -25279,9 +25636,9 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
25279
25636
|
parts.push("declare ");
|
|
25280
25637
|
}
|
|
25281
25638
|
|
|
25282
|
-
var
|
|
25639
|
+
var _printed4 = printAssignmentRight(n.id, n.right, path$$1.call(print, "right"), options);
|
|
25283
25640
|
|
|
25284
|
-
parts.push("type ", path$$1.call(print, "id"), path$$1.call(print, "typeParameters"), " =",
|
|
25641
|
+
parts.push("type ", path$$1.call(print, "id"), path$$1.call(print, "typeParameters"), " =", _printed4, semi);
|
|
25285
25642
|
return group$1(concat$4(parts));
|
|
25286
25643
|
}
|
|
25287
25644
|
|
|
@@ -25294,7 +25651,7 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
25294
25651
|
// a type annotation comment.
|
|
25295
25652
|
//
|
|
25296
25653
|
// Note that we're able to use the normal whitespace regex here because the Flow parser has
|
|
25297
|
-
// already deemed this AST node to be a type cast. Only the
|
|
25654
|
+
// already deemed this AST node to be a type cast. Only the Babel parser needs the
|
|
25298
25655
|
// non-line-break whitespace regex, which is why hasFlowShorthandAnnotationComment() is
|
|
25299
25656
|
// implemented differently.
|
|
25300
25657
|
|
|
@@ -25525,7 +25882,7 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
25525
25882
|
{
|
|
25526
25883
|
var _parent10 = path$$1.getParentNode();
|
|
25527
25884
|
|
|
25528
|
-
return concat$4([n.export ? "export " : "", n.accessibility ? concat$4([n.accessibility, " "]) : "", n.static ? "static " : "", n.readonly ? "readonly " : "", "[", path$$1.
|
|
25885
|
+
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 : ""]);
|
|
25529
25886
|
}
|
|
25530
25887
|
|
|
25531
25888
|
case "TSTypePredicate":
|
|
@@ -25546,11 +25903,11 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
25546
25903
|
case "TSIndexedAccessType":
|
|
25547
25904
|
return concat$4([path$$1.call(print, "objectType"), "[", path$$1.call(print, "indexType"), "]"]);
|
|
25548
25905
|
|
|
25549
|
-
case "
|
|
25906
|
+
case "TSConstructSignatureDeclaration":
|
|
25907
|
+
case "TSCallSignatureDeclaration":
|
|
25550
25908
|
case "TSConstructorType":
|
|
25551
|
-
case "TSCallSignature":
|
|
25552
25909
|
{
|
|
25553
|
-
if (n.type !== "
|
|
25910
|
+
if (n.type !== "TSCallSignatureDeclaration") {
|
|
25554
25911
|
parts.push("new ");
|
|
25555
25912
|
}
|
|
25556
25913
|
|
|
@@ -25560,9 +25917,9 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
25560
25917
|
/* printTypeParams */
|
|
25561
25918
|
true)));
|
|
25562
25919
|
|
|
25563
|
-
if (n.
|
|
25920
|
+
if (n.returnType) {
|
|
25564
25921
|
var isType = n.type === "TSConstructorType";
|
|
25565
|
-
parts.push(isType ? " => " : ": ", path$$1.call(print, "
|
|
25922
|
+
parts.push(isType ? " => " : ": ", path$$1.call(print, "returnType"));
|
|
25566
25923
|
}
|
|
25567
25924
|
|
|
25568
25925
|
return concat$4(parts);
|
|
@@ -25572,7 +25929,7 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
25572
25929
|
return concat$4([n.operator, " ", path$$1.call(print, "typeAnnotation")]);
|
|
25573
25930
|
|
|
25574
25931
|
case "TSMappedType":
|
|
25575
|
-
return group$1(concat$4(["{", indent$2(concat$4([options.bracketSpacing ? line$3 : softline$1, n.
|
|
25932
|
+
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,
|
|
25576
25933
|
/* sameIndent */
|
|
25577
25934
|
true), options.bracketSpacing ? line$3 : softline$1, "}"]));
|
|
25578
25935
|
|
|
@@ -25583,14 +25940,14 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
25583
25940
|
/* printTypeParams */
|
|
25584
25941
|
true));
|
|
25585
25942
|
|
|
25586
|
-
if (n.
|
|
25587
|
-
parts.push(": ", path$$1.call(print, "
|
|
25943
|
+
if (n.returnType) {
|
|
25944
|
+
parts.push(": ", path$$1.call(print, "returnType"));
|
|
25588
25945
|
}
|
|
25589
25946
|
|
|
25590
25947
|
return group$1(concat$4(parts));
|
|
25591
25948
|
|
|
25592
25949
|
case "TSNamespaceExportDeclaration":
|
|
25593
|
-
parts.push("export as namespace ", path$$1.call(print, "
|
|
25950
|
+
parts.push("export as namespace ", path$$1.call(print, "id"));
|
|
25594
25951
|
|
|
25595
25952
|
if (options.semi) {
|
|
25596
25953
|
parts.push(";");
|
|
@@ -25633,7 +25990,11 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
25633
25990
|
return concat$4(parts);
|
|
25634
25991
|
|
|
25635
25992
|
case "TSImportEqualsDeclaration":
|
|
25636
|
-
|
|
25993
|
+
if (n.isExport) {
|
|
25994
|
+
parts.push("export ");
|
|
25995
|
+
}
|
|
25996
|
+
|
|
25997
|
+
parts.push("import ", path$$1.call(print, "id"), " = ", path$$1.call(print, "moduleReference"));
|
|
25637
25998
|
|
|
25638
25999
|
if (options.semi) {
|
|
25639
26000
|
parts.push(";");
|
|
@@ -25872,7 +26233,7 @@ function printMethod(path$$1, options, print) {
|
|
|
25872
26233
|
var kind = node.kind;
|
|
25873
26234
|
var parts = [];
|
|
25874
26235
|
|
|
25875
|
-
if (node.type === "ObjectMethod" || node.type === "ClassMethod") {
|
|
26236
|
+
if (node.type === "ObjectMethod" || node.type === "ClassMethod" || node.type === "ClassPrivateMethod") {
|
|
25876
26237
|
node.value = node;
|
|
25877
26238
|
}
|
|
25878
26239
|
|
|
@@ -25909,7 +26270,7 @@ function printMethod(path$$1, options, print) {
|
|
|
25909
26270
|
}
|
|
25910
26271
|
|
|
25911
26272
|
function couldGroupArg(arg) {
|
|
25912
|
-
return arg.type === "ObjectExpression" && (arg.properties.length > 0 || arg.comments) || arg.type === "ArrayExpression" && (arg.elements.length > 0 || arg.comments) || arg.type === "
|
|
26273
|
+
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));
|
|
25913
26274
|
}
|
|
25914
26275
|
|
|
25915
26276
|
function shouldGroupLastArg(args) {
|
|
@@ -25947,13 +26308,15 @@ var functionCompositionFunctionNames = new Set(["pipe", // RxJS, Ramda
|
|
|
25947
26308
|
"connect", // Redux
|
|
25948
26309
|
"createSelector" // Reselect
|
|
25949
26310
|
]);
|
|
26311
|
+
var ordinaryMethodNames = new Set(["connect" // GObject, MongoDB
|
|
26312
|
+
]);
|
|
25950
26313
|
|
|
25951
26314
|
function isFunctionCompositionFunction(node) {
|
|
25952
26315
|
switch (node.type) {
|
|
25953
26316
|
case "OptionalMemberExpression":
|
|
25954
26317
|
case "MemberExpression":
|
|
25955
26318
|
{
|
|
25956
|
-
return isFunctionCompositionFunction(node.property);
|
|
26319
|
+
return isFunctionCompositionFunction(node.property) && !ordinaryMethodNames.has(node.property.name);
|
|
25957
26320
|
}
|
|
25958
26321
|
|
|
25959
26322
|
case "Identifier":
|
|
@@ -25977,6 +26340,13 @@ function printArgumentsList(path$$1, options, print) {
|
|
|
25977
26340
|
return concat$4(["(", comments.printDanglingComments(path$$1, options,
|
|
25978
26341
|
/* sameIndent */
|
|
25979
26342
|
true), ")"]);
|
|
26343
|
+
} // useEffect(() => { ... }, [foo, bar, baz])
|
|
26344
|
+
|
|
26345
|
+
|
|
26346
|
+
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) {
|
|
26347
|
+
return arg.leadingComments || arg.trailingComments;
|
|
26348
|
+
})) {
|
|
26349
|
+
return concat$4(["(", path$$1.call(print, "arguments", 0), ", ", path$$1.call(print, "arguments", 1), ")"]);
|
|
25980
26350
|
}
|
|
25981
26351
|
|
|
25982
26352
|
var anyArgEmptyLine = false;
|
|
@@ -26275,7 +26645,7 @@ function printExportDeclaration(path$$1, options, print) {
|
|
|
26275
26645
|
if (decl.declaration) {
|
|
26276
26646
|
parts.push(path$$1.call(print, "declaration"));
|
|
26277
26647
|
|
|
26278
|
-
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") {
|
|
26648
|
+
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") {
|
|
26279
26649
|
parts.push(semi);
|
|
26280
26650
|
}
|
|
26281
26651
|
} else {
|
|
@@ -26329,7 +26699,7 @@ function printFlowDeclaration(path$$1, parts) {
|
|
|
26329
26699
|
function getFlowVariance(path$$1) {
|
|
26330
26700
|
if (!path$$1.variance) {
|
|
26331
26701
|
return null;
|
|
26332
|
-
} //
|
|
26702
|
+
} // Babel 7.0 currently uses variance node type, and flow should
|
|
26333
26703
|
// follow suit soon:
|
|
26334
26704
|
// https://github.com/babel/babel/issues/4722
|
|
26335
26705
|
|
|
@@ -27492,8 +27862,9 @@ function classChildNeedsASIProtection(node) {
|
|
|
27492
27862
|
case "TSAbstractMethodDefinition": // TypeScript
|
|
27493
27863
|
|
|
27494
27864
|
case "ClassMethod":
|
|
27865
|
+
case "ClassPrivateMethod":
|
|
27495
27866
|
{
|
|
27496
|
-
//
|
|
27867
|
+
// Babel
|
|
27497
27868
|
var isAsync = node.value ? node.value.async : node.async;
|
|
27498
27869
|
var isGenerator = node.value ? node.value.generator : node.generator;
|
|
27499
27870
|
|
|
@@ -27836,11 +28207,11 @@ var printerEstree = {
|
|
|
27836
28207
|
}
|
|
27837
28208
|
};
|
|
27838
28209
|
|
|
27839
|
-
var _require$$0$builders$
|
|
27840
|
-
var concat$7 = _require$$0$builders$
|
|
27841
|
-
var hardline$5 = _require$$0$builders$
|
|
27842
|
-
var indent$4 = _require$$0$builders$
|
|
27843
|
-
var join$5 = _require$$0$builders$
|
|
28210
|
+
var _require$$0$builders$2 = doc.builders;
|
|
28211
|
+
var concat$7 = _require$$0$builders$2.concat;
|
|
28212
|
+
var hardline$5 = _require$$0$builders$2.hardline;
|
|
28213
|
+
var indent$4 = _require$$0$builders$2.indent;
|
|
28214
|
+
var join$5 = _require$$0$builders$2.join;
|
|
27844
28215
|
|
|
27845
28216
|
function genericPrint$1(path$$1, options, print) {
|
|
27846
28217
|
var node = path$$1.getValue();
|
|
@@ -28283,9 +28654,9 @@ var json5$1 = Object.freeze({
|
|
|
28283
28654
|
default: json5
|
|
28284
28655
|
});
|
|
28285
28656
|
|
|
28286
|
-
var require$$0$
|
|
28657
|
+
var require$$0$21 = ( javascript$1 && javascript ) || javascript$1;
|
|
28287
28658
|
|
|
28288
|
-
var require$$1$
|
|
28659
|
+
var require$$1$9 = ( jsx$1 && jsx ) || jsx$1;
|
|
28289
28660
|
|
|
28290
28661
|
var require$$2$10 = ( typescript$1 && typescript ) || typescript$1;
|
|
28291
28662
|
|
|
@@ -28295,29 +28666,29 @@ var require$$4$2 = ( jsonWithComments$1 && jsonWithComments ) || jsonWithComment
|
|
|
28295
28666
|
|
|
28296
28667
|
var require$$5$1 = ( json5$1 && json5 ) || json5$1;
|
|
28297
28668
|
|
|
28298
|
-
var languages = [createLanguage(require$$0$
|
|
28669
|
+
var languages = [createLanguage(require$$0$21, {
|
|
28299
28670
|
override: {
|
|
28300
28671
|
since: "0.0.0",
|
|
28301
|
-
parsers: ["
|
|
28672
|
+
parsers: ["babel", "flow"],
|
|
28302
28673
|
vscodeLanguageIds: ["javascript"]
|
|
28303
28674
|
},
|
|
28304
28675
|
extend: {
|
|
28305
28676
|
interpreters: ["nodejs"]
|
|
28306
28677
|
}
|
|
28307
|
-
}), createLanguage(require$$0$
|
|
28678
|
+
}), createLanguage(require$$0$21, {
|
|
28308
28679
|
override: {
|
|
28309
28680
|
name: "Flow",
|
|
28310
28681
|
since: "0.0.0",
|
|
28311
|
-
parsers: ["
|
|
28682
|
+
parsers: ["babel", "flow"],
|
|
28312
28683
|
vscodeLanguageIds: ["javascript"],
|
|
28313
28684
|
aliases: [],
|
|
28314
28685
|
filenames: [],
|
|
28315
28686
|
extensions: [".js.flow"]
|
|
28316
28687
|
}
|
|
28317
|
-
}), createLanguage(require$$1$
|
|
28688
|
+
}), createLanguage(require$$1$9, {
|
|
28318
28689
|
override: {
|
|
28319
28690
|
since: "0.0.0",
|
|
28320
|
-
parsers: ["
|
|
28691
|
+
parsers: ["babel", "flow"],
|
|
28321
28692
|
vscodeLanguageIds: ["javascriptreact"]
|
|
28322
28693
|
}
|
|
28323
28694
|
}), createLanguage(require$$2$10, {
|
|
@@ -28495,12 +28866,12 @@ function cleanCSSStrings(value) {
|
|
|
28495
28866
|
|
|
28496
28867
|
var clean_1$2 = clean$3;
|
|
28497
28868
|
|
|
28498
|
-
var _require$$0$builders$
|
|
28499
|
-
var hardline$7 = _require$$0$builders$
|
|
28500
|
-
var literalline$3 = _require$$0$builders$
|
|
28501
|
-
var concat$9 = _require$$0$builders$
|
|
28502
|
-
var markAsRoot$1 = _require$$0$builders$
|
|
28503
|
-
var mapDoc$
|
|
28869
|
+
var _require$$0$builders$3 = doc.builders;
|
|
28870
|
+
var hardline$7 = _require$$0$builders$3.hardline;
|
|
28871
|
+
var literalline$3 = _require$$0$builders$3.literalline;
|
|
28872
|
+
var concat$9 = _require$$0$builders$3.concat;
|
|
28873
|
+
var markAsRoot$1 = _require$$0$builders$3.markAsRoot;
|
|
28874
|
+
var mapDoc$4 = doc.utils.mapDoc;
|
|
28504
28875
|
|
|
28505
28876
|
function embed$2(path$$1, print, textToDoc
|
|
28506
28877
|
/*, options */
|
|
@@ -28516,7 +28887,7 @@ function embed$2(path$$1, print, textToDoc
|
|
|
28516
28887
|
return null;
|
|
28517
28888
|
|
|
28518
28889
|
function replaceNewlinesWithLiterallines(doc$$2) {
|
|
28519
|
-
return mapDoc$
|
|
28890
|
+
return mapDoc$4(doc$$2, function (currentDoc) {
|
|
28520
28891
|
return typeof currentDoc === "string" && currentDoc.includes("\n") ? concat$9(currentDoc.split(/(\n)/g).map(function (v, i) {
|
|
28521
28892
|
return i % 2 === 0 ? v : literalline$3;
|
|
28522
28893
|
})) : currentDoc;
|
|
@@ -28985,8 +29356,7 @@ function genericPrint$2(path$$1, options, print) {
|
|
|
28985
29356
|
case "css-comment":
|
|
28986
29357
|
{
|
|
28987
29358
|
if (node.raws.content) {
|
|
28988
|
-
return node.raws.content
|
|
28989
|
-
.replace(/^(\/\/[^]+)\r+$/, "$1");
|
|
29359
|
+
return node.raws.content;
|
|
28990
29360
|
}
|
|
28991
29361
|
|
|
28992
29362
|
var text = options.originalText.slice(options.locStart(node), options.locEnd(node));
|
|
@@ -29247,6 +29617,16 @@ function genericPrint$2(path$$1, options, print) {
|
|
|
29247
29617
|
|
|
29248
29618
|
if (iNode.value === "~") {
|
|
29249
29619
|
continue;
|
|
29620
|
+
} // Ignore escape `\`
|
|
29621
|
+
|
|
29622
|
+
|
|
29623
|
+
if (iNode.value && iNode.value.indexOf("\\") !== -1 && iNextNode && iNextNode.type !== "value-comment") {
|
|
29624
|
+
continue;
|
|
29625
|
+
} // Ignore escaped `/`
|
|
29626
|
+
|
|
29627
|
+
|
|
29628
|
+
if (iPrevNode && iPrevNode.value && iPrevNode.value.indexOf("\\") === iPrevNode.value.length - 1 && iNode.type === "value-operator" && iNode.value === "/") {
|
|
29629
|
+
continue;
|
|
29250
29630
|
} // Ignore `\` (i.e. `$variable: \@small;`)
|
|
29251
29631
|
|
|
29252
29632
|
|
|
@@ -29294,16 +29674,11 @@ function genericPrint$2(path$$1, options, print) {
|
|
|
29294
29674
|
|
|
29295
29675
|
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)))) {
|
|
29296
29676
|
continue;
|
|
29297
|
-
} //
|
|
29298
|
-
// Add `hardline` after inline comment (i.e. `// comment\n foo: bar;`)
|
|
29299
|
-
|
|
29677
|
+
} // Add `hardline` after inline comment (i.e. `// comment\n foo: bar;`)
|
|
29300
29678
|
|
|
29301
|
-
var isInlineComment = isInlineValueCommentNode(iNode);
|
|
29302
29679
|
|
|
29303
|
-
if (
|
|
29304
|
-
|
|
29305
|
-
_parts.push(hardline$6);
|
|
29306
|
-
}
|
|
29680
|
+
if (isInlineValueCommentNode(iNode)) {
|
|
29681
|
+
_parts.push(hardline$6);
|
|
29307
29682
|
|
|
29308
29683
|
continue;
|
|
29309
29684
|
} // Handle keywords in SCSS control directive
|
|
@@ -29676,21 +30051,21 @@ var scss$1 = Object.freeze({
|
|
|
29676
30051
|
default: scss
|
|
29677
30052
|
});
|
|
29678
30053
|
|
|
29679
|
-
var require$$0$
|
|
30054
|
+
var require$$0$23 = ( css$3 && css$2 ) || css$3;
|
|
29680
30055
|
|
|
29681
|
-
var require$$1$
|
|
30056
|
+
var require$$1$10 = ( postcss$1 && postcss ) || postcss$1;
|
|
29682
30057
|
|
|
29683
30058
|
var require$$2$11 = ( less$1 && less ) || less$1;
|
|
29684
30059
|
|
|
29685
30060
|
var require$$3$4 = ( scss$1 && scss ) || scss$1;
|
|
29686
30061
|
|
|
29687
|
-
var languages$1 = [createLanguage(require$$0$
|
|
30062
|
+
var languages$1 = [createLanguage(require$$0$23, {
|
|
29688
30063
|
override: {
|
|
29689
30064
|
since: "1.4.0",
|
|
29690
30065
|
parsers: ["css"],
|
|
29691
30066
|
vscodeLanguageIds: ["css"]
|
|
29692
30067
|
}
|
|
29693
|
-
}), createLanguage(require$$1$
|
|
30068
|
+
}), createLanguage(require$$1$10, {
|
|
29694
30069
|
override: {
|
|
29695
30070
|
since: "1.4.0",
|
|
29696
30071
|
parsers: ["css"],
|
|
@@ -29721,15 +30096,15 @@ var languageCss = {
|
|
|
29721
30096
|
printers: printers$1
|
|
29722
30097
|
};
|
|
29723
30098
|
|
|
29724
|
-
var _require$$0$builders$
|
|
29725
|
-
var concat$10 = _require$$0$builders$
|
|
29726
|
-
var join$7 = _require$$0$builders$
|
|
29727
|
-
var softline$4 = _require$$0$builders$
|
|
29728
|
-
var hardline$8 = _require$$0$builders$
|
|
29729
|
-
var line$6 = _require$$0$builders$
|
|
29730
|
-
var group$10 = _require$$0$builders$
|
|
29731
|
-
var indent$6 = _require$$0$builders$
|
|
29732
|
-
var ifBreak$3 = _require$$0$builders$
|
|
30099
|
+
var _require$$0$builders$4 = doc.builders;
|
|
30100
|
+
var concat$10 = _require$$0$builders$4.concat;
|
|
30101
|
+
var join$7 = _require$$0$builders$4.join;
|
|
30102
|
+
var softline$4 = _require$$0$builders$4.softline;
|
|
30103
|
+
var hardline$8 = _require$$0$builders$4.hardline;
|
|
30104
|
+
var line$6 = _require$$0$builders$4.line;
|
|
30105
|
+
var group$10 = _require$$0$builders$4.group;
|
|
30106
|
+
var indent$6 = _require$$0$builders$4.indent;
|
|
30107
|
+
var ifBreak$3 = _require$$0$builders$4.ifBreak; // http://w3c.github.io/html/single-page.html#void-elements
|
|
29733
30108
|
|
|
29734
30109
|
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:
|
|
29735
30110
|
// https://github.com/glimmerjs/glimmer-vm/blob/master/packages/%40glimmer/syntax/lib/generation/print.ts
|
|
@@ -30069,9 +30444,9 @@ var handlebars$1 = Object.freeze({
|
|
|
30069
30444
|
default: handlebars
|
|
30070
30445
|
});
|
|
30071
30446
|
|
|
30072
|
-
var require$$0$
|
|
30447
|
+
var require$$0$24 = ( handlebars$1 && handlebars ) || handlebars$1;
|
|
30073
30448
|
|
|
30074
|
-
var languages$2 = [createLanguage(require$$0$
|
|
30449
|
+
var languages$2 = [createLanguage(require$$0$24, {
|
|
30075
30450
|
override: {
|
|
30076
30451
|
since: null,
|
|
30077
30452
|
// unreleased
|
|
@@ -30100,15 +30475,15 @@ var pragma$4 = {
|
|
|
30100
30475
|
insertPragma: insertPragma$5
|
|
30101
30476
|
};
|
|
30102
30477
|
|
|
30103
|
-
var _require$$0$builders$
|
|
30104
|
-
var concat$11 = _require$$0$builders$
|
|
30105
|
-
var join$8 = _require$$0$builders$
|
|
30106
|
-
var hardline$9 = _require$$0$builders$
|
|
30107
|
-
var line$7 = _require$$0$builders$
|
|
30108
|
-
var softline$5 = _require$$0$builders$
|
|
30109
|
-
var group$12 = _require$$0$builders$
|
|
30110
|
-
var indent$7 = _require$$0$builders$
|
|
30111
|
-
var ifBreak$4 = _require$$0$builders$
|
|
30478
|
+
var _require$$0$builders$5 = doc.builders;
|
|
30479
|
+
var concat$11 = _require$$0$builders$5.concat;
|
|
30480
|
+
var join$8 = _require$$0$builders$5.join;
|
|
30481
|
+
var hardline$9 = _require$$0$builders$5.hardline;
|
|
30482
|
+
var line$7 = _require$$0$builders$5.line;
|
|
30483
|
+
var softline$5 = _require$$0$builders$5.softline;
|
|
30484
|
+
var group$12 = _require$$0$builders$5.group;
|
|
30485
|
+
var indent$7 = _require$$0$builders$5.indent;
|
|
30486
|
+
var ifBreak$4 = _require$$0$builders$5.ifBreak;
|
|
30112
30487
|
var hasIgnoreComment$3 = util$1.hasIgnoreComment;
|
|
30113
30488
|
var isNextLineEmpty$4 = utilShared.isNextLineEmpty;
|
|
30114
30489
|
var insertPragma$4 = pragma$4.insertPragma;
|
|
@@ -30444,9 +30819,9 @@ var graphql$1 = Object.freeze({
|
|
|
30444
30819
|
default: graphql
|
|
30445
30820
|
});
|
|
30446
30821
|
|
|
30447
|
-
var require$$0$
|
|
30822
|
+
var require$$0$25 = ( graphql$1 && graphql ) || graphql$1;
|
|
30448
30823
|
|
|
30449
|
-
var languages$3 = [createLanguage(require$$0$
|
|
30824
|
+
var languages$3 = [createLanguage(require$$0$25, {
|
|
30450
30825
|
override: {
|
|
30451
30826
|
since: "1.5.0",
|
|
30452
30827
|
parsers: ["graphql"],
|
|
@@ -30468,6 +30843,8 @@ var cjkPattern = json$6.cjkPattern;
|
|
|
30468
30843
|
var kPattern = json$6.kPattern;
|
|
30469
30844
|
var punctuationPattern$1 = json$6.punctuationPattern;
|
|
30470
30845
|
var getLast$5 = util$1.getLast;
|
|
30846
|
+
var INLINE_NODE_TYPES$1 = ["liquidNode", "inlineCode", "emphasis", "strong", "delete", "link", "linkReference", "image", "imageReference", "footnote", "footnoteReference", "sentence", "whitespace", "word", "break", "inlineMath"];
|
|
30847
|
+
var INLINE_NODE_WRAPPER_TYPES$1 = INLINE_NODE_TYPES$1.concat(["tableCell", "paragraph", "heading"]);
|
|
30471
30848
|
var kRegex = new RegExp(kPattern);
|
|
30472
30849
|
var punctuationRegex = new RegExp(punctuationPattern$1);
|
|
30473
30850
|
/**
|
|
@@ -30583,7 +30960,7 @@ function getFencedCodeBlockValue$2(node, originalText) {
|
|
|
30583
30960
|
var text = originalText.slice(node.position.start.offset, node.position.end.offset);
|
|
30584
30961
|
var leadingSpaceCount = text.match(/^\s*/)[0].length;
|
|
30585
30962
|
var replaceRegex = new RegExp(`^\\s{0,${leadingSpaceCount}}`);
|
|
30586
|
-
var lineContents = text.
|
|
30963
|
+
var lineContents = text.split("\n");
|
|
30587
30964
|
var markerStyle = text[leadingSpaceCount]; // ` or ~
|
|
30588
30965
|
|
|
30589
30966
|
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
|
|
@@ -30619,15 +30996,17 @@ var utils$8 = {
|
|
|
30619
30996
|
splitText: splitText$1,
|
|
30620
30997
|
punctuationPattern: punctuationPattern$1,
|
|
30621
30998
|
getFencedCodeBlockValue: getFencedCodeBlockValue$2,
|
|
30622
|
-
getOrderedListItemInfo: getOrderedListItemInfo$1
|
|
30999
|
+
getOrderedListItemInfo: getOrderedListItemInfo$1,
|
|
31000
|
+
INLINE_NODE_TYPES: INLINE_NODE_TYPES$1,
|
|
31001
|
+
INLINE_NODE_WRAPPER_TYPES: INLINE_NODE_WRAPPER_TYPES$1
|
|
30623
31002
|
};
|
|
30624
31003
|
|
|
30625
|
-
var _require$$0$builders$
|
|
30626
|
-
var hardline$11 = _require$$0$builders$
|
|
30627
|
-
var literalline$5 = _require$$0$builders$
|
|
30628
|
-
var concat$13 = _require$$0$builders$
|
|
30629
|
-
var markAsRoot$3 = _require$$0$builders$
|
|
30630
|
-
var mapDoc$
|
|
31004
|
+
var _require$$0$builders$7 = doc.builders;
|
|
31005
|
+
var hardline$11 = _require$$0$builders$7.hardline;
|
|
31006
|
+
var literalline$5 = _require$$0$builders$7.literalline;
|
|
31007
|
+
var concat$13 = _require$$0$builders$7.concat;
|
|
31008
|
+
var markAsRoot$3 = _require$$0$builders$7.markAsRoot;
|
|
31009
|
+
var mapDoc$6 = doc.utils.mapDoc;
|
|
30631
31010
|
var getFencedCodeBlockValue$1 = utils$8.getFencedCodeBlockValue;
|
|
30632
31011
|
|
|
30633
31012
|
function embed$4(path$$1, print, textToDoc, options) {
|
|
@@ -30650,7 +31029,7 @@ function embed$4(path$$1, print, textToDoc, options) {
|
|
|
30650
31029
|
}
|
|
30651
31030
|
|
|
30652
31031
|
if (node.type === "yaml") {
|
|
30653
|
-
return markAsRoot$3(concat$13(["---", hardline$11, node.value.trim() ? replaceNewlinesWithLiterallines(textToDoc(node.value, {
|
|
31032
|
+
return markAsRoot$3(concat$13(["---", hardline$11, node.value && node.value.trim() ? replaceNewlinesWithLiterallines(textToDoc(node.value, {
|
|
30654
31033
|
parser: "yaml"
|
|
30655
31034
|
})) : "", "---"]));
|
|
30656
31035
|
} // MDX
|
|
@@ -30659,7 +31038,7 @@ function embed$4(path$$1, print, textToDoc, options) {
|
|
|
30659
31038
|
switch (node.type) {
|
|
30660
31039
|
case "importExport":
|
|
30661
31040
|
return textToDoc(node.value, {
|
|
30662
|
-
parser: "
|
|
31041
|
+
parser: "babel"
|
|
30663
31042
|
});
|
|
30664
31043
|
|
|
30665
31044
|
case "jsx":
|
|
@@ -30688,7 +31067,7 @@ function embed$4(path$$1, print, textToDoc, options) {
|
|
|
30688
31067
|
}
|
|
30689
31068
|
|
|
30690
31069
|
function replaceNewlinesWithLiterallines(doc$$2) {
|
|
30691
|
-
return mapDoc$
|
|
31070
|
+
return mapDoc$6(doc$$2, function (currentDoc) {
|
|
30692
31071
|
return typeof currentDoc === "string" && currentDoc.includes("\n") ? concat$13(currentDoc.split(/(\n)/g).map(function (v, i) {
|
|
30693
31072
|
return i % 2 === 0 ? v : literalline$5;
|
|
30694
31073
|
})) : currentDoc;
|
|
@@ -30705,7 +31084,7 @@ var pragma$6 = createCommonjsModule(function (module) {
|
|
|
30705
31084
|
|
|
30706
31085
|
function startWithPragma(text) {
|
|
30707
31086
|
var pragma = `@(${pragmas.join("|")})`;
|
|
30708
|
-
var regex = new RegExp([`<!--\\s*${pragma}\\s*-->`, `<!--.*\n[\\s\\S]*(^|\n)[^\\S\n]*${pragma}[^\\S\n]*($|\n)[\\s\\S]*\n.*-->`].join("|"), "m");
|
|
31087
|
+
var regex = new RegExp([`<!--\\s*${pragma}\\s*-->`, `<!--.*\r?\n[\\s\\S]*(^|\n)[^\\S\n]*${pragma}[^\\S\n]*($|\n)[\\s\\S]*\n.*-->`].join("|"), "m");
|
|
30709
31088
|
var matched = text.match(regex);
|
|
30710
31089
|
return matched && matched.index === 0;
|
|
30711
31090
|
}
|
|
@@ -30995,29 +31374,30 @@ function markAlignedList(ast, options) {
|
|
|
30995
31374
|
|
|
30996
31375
|
var preprocess_1$2 = preprocess$2;
|
|
30997
31376
|
|
|
30998
|
-
var _require$$0$builders$
|
|
30999
|
-
var concat$12 = _require$$0$builders$
|
|
31000
|
-
var join$9 = _require$$0$builders$
|
|
31001
|
-
var line$8 = _require$$0$builders$
|
|
31002
|
-
var literalline$4 = _require$$0$builders$
|
|
31003
|
-
var markAsRoot$2 = _require$$0$builders$
|
|
31004
|
-
var hardline$10 = _require$$0$builders$
|
|
31005
|
-
var softline$6 = _require$$0$builders$
|
|
31006
|
-
var fill$4 = _require$$0$builders$
|
|
31007
|
-
var align$2 = _require$$0$builders$
|
|
31008
|
-
var indent$8 = _require$$0$builders$
|
|
31009
|
-
var group$13 = _require$$0$builders$
|
|
31010
|
-
var mapDoc$
|
|
31377
|
+
var _require$$0$builders$6 = doc.builders;
|
|
31378
|
+
var concat$12 = _require$$0$builders$6.concat;
|
|
31379
|
+
var join$9 = _require$$0$builders$6.join;
|
|
31380
|
+
var line$8 = _require$$0$builders$6.line;
|
|
31381
|
+
var literalline$4 = _require$$0$builders$6.literalline;
|
|
31382
|
+
var markAsRoot$2 = _require$$0$builders$6.markAsRoot;
|
|
31383
|
+
var hardline$10 = _require$$0$builders$6.hardline;
|
|
31384
|
+
var softline$6 = _require$$0$builders$6.softline;
|
|
31385
|
+
var fill$4 = _require$$0$builders$6.fill;
|
|
31386
|
+
var align$2 = _require$$0$builders$6.align;
|
|
31387
|
+
var indent$8 = _require$$0$builders$6.indent;
|
|
31388
|
+
var group$13 = _require$$0$builders$6.group;
|
|
31389
|
+
var mapDoc$5 = doc.utils.mapDoc;
|
|
31011
31390
|
var printDocToString$3 = doc.printer.printDocToString;
|
|
31012
31391
|
var getFencedCodeBlockValue = utils$8.getFencedCodeBlockValue;
|
|
31013
31392
|
var getOrderedListItemInfo = utils$8.getOrderedListItemInfo;
|
|
31014
31393
|
var splitText = utils$8.splitText;
|
|
31015
31394
|
var punctuationPattern = utils$8.punctuationPattern;
|
|
31395
|
+
var INLINE_NODE_TYPES = utils$8.INLINE_NODE_TYPES;
|
|
31396
|
+
var INLINE_NODE_WRAPPER_TYPES = utils$8.INLINE_NODE_WRAPPER_TYPES;
|
|
31397
|
+
var replaceEndOfLineWith$1 = util$1.replaceEndOfLineWith;
|
|
31016
31398
|
var TRAILING_HARDLINE_NODES = ["importExport"];
|
|
31017
31399
|
var SINGLE_LINE_NODE_TYPES = ["heading", "tableCell", "link"];
|
|
31018
31400
|
var SIBLING_NODE_TYPES = ["listItem", "definition", "footnoteDefinition"];
|
|
31019
|
-
var INLINE_NODE_TYPES = ["liquidNode", "inlineCode", "emphasis", "strong", "delete", "link", "linkReference", "image", "imageReference", "footnote", "footnoteReference", "sentence", "whitespace", "word", "break", "inlineMath"];
|
|
31020
|
-
var INLINE_NODE_WRAPPER_TYPES = INLINE_NODE_TYPES.concat(["tableCell", "paragraph", "heading"]);
|
|
31021
31401
|
|
|
31022
31402
|
function genericPrint$4(path$$1, options, print) {
|
|
31023
31403
|
var node = path$$1.getValue();
|
|
@@ -31124,7 +31504,7 @@ function genericPrint$4(path$$1, options, print) {
|
|
|
31124
31504
|
if (node.isIndented) {
|
|
31125
31505
|
// indented code block
|
|
31126
31506
|
var alignment = " ".repeat(4);
|
|
31127
|
-
return align$2(alignment, concat$12([alignment,
|
|
31507
|
+
return align$2(alignment, concat$12([alignment, concat$12(replaceEndOfLineWith$1(node.value, hardline$10))]));
|
|
31128
31508
|
} // fenced code block
|
|
31129
31509
|
|
|
31130
31510
|
|
|
@@ -31132,7 +31512,7 @@ function genericPrint$4(path$$1, options, print) {
|
|
|
31132
31512
|
|
|
31133
31513
|
var _style2 = styleUnit.repeat(Math.max(3, util$1.getMaxContinuousCount(node.value, styleUnit) + 1));
|
|
31134
31514
|
|
|
31135
|
-
return concat$12([_style2, node.lang || "", hardline$10,
|
|
31515
|
+
return concat$12([_style2, node.lang || "", hardline$10, concat$12(replaceEndOfLineWith$1(getFencedCodeBlockValue(node, options.originalText), hardline$10)), hardline$10, _style2]);
|
|
31136
31516
|
}
|
|
31137
31517
|
|
|
31138
31518
|
case "yaml":
|
|
@@ -31145,7 +31525,7 @@ function genericPrint$4(path$$1, options, print) {
|
|
|
31145
31525
|
|
|
31146
31526
|
var value = _parentNode2.type === "root" && util$1.getLast(_parentNode2.children) === node ? node.value.trimRight() : node.value;
|
|
31147
31527
|
var isHtmlComment = /^<!--[\s\S]*-->$/.test(value);
|
|
31148
|
-
return
|
|
31528
|
+
return concat$12(replaceEndOfLineWith$1(value, isHtmlComment ? hardline$10 : markAsRoot$2(literalline$4)));
|
|
31149
31529
|
}
|
|
31150
31530
|
|
|
31151
31531
|
case "list":
|
|
@@ -31225,7 +31605,7 @@ function genericPrint$4(path$$1, options, print) {
|
|
|
31225
31605
|
return /\s/.test(options.originalText[node.position.start.offset]) ? concat$12([" ", markAsRoot$2(literalline$4)]) : concat$12(["\\", hardline$10]);
|
|
31226
31606
|
|
|
31227
31607
|
case "liquidNode":
|
|
31228
|
-
return
|
|
31608
|
+
return concat$12(replaceEndOfLineWith$1(node.value, hardline$10));
|
|
31229
31609
|
// MDX
|
|
31230
31610
|
|
|
31231
31611
|
case "importExport":
|
|
@@ -31234,7 +31614,7 @@ function genericPrint$4(path$$1, options, print) {
|
|
|
31234
31614
|
// fallback to the original text if multiparser failed
|
|
31235
31615
|
|
|
31236
31616
|
case "math":
|
|
31237
|
-
return concat$12(["$$", hardline$10, node.value ? concat$12([
|
|
31617
|
+
return concat$12(["$$", hardline$10, node.value ? concat$12([concat$12(replaceEndOfLineWith$1(node.value, hardline$10)), hardline$10]) : "", "$$"]);
|
|
31238
31618
|
|
|
31239
31619
|
case "inlineMath":
|
|
31240
31620
|
{
|
|
@@ -31285,10 +31665,6 @@ function getNthListSiblingIndex(node, parentNode) {
|
|
|
31285
31665
|
});
|
|
31286
31666
|
}
|
|
31287
31667
|
|
|
31288
|
-
function replaceNewlinesWith(str, doc$$2) {
|
|
31289
|
-
return join$9(doc$$2, str.replace(/\r\n?/g, "\n").split("\n"));
|
|
31290
|
-
}
|
|
31291
|
-
|
|
31292
31668
|
function getNthSiblingIndex(node, parentNode, condition) {
|
|
31293
31669
|
condition = condition || function () {
|
|
31294
31670
|
return true;
|
|
@@ -31589,7 +31965,7 @@ function shouldRemainTheSameContent(path$$1) {
|
|
|
31589
31965
|
}
|
|
31590
31966
|
|
|
31591
31967
|
function normalizeDoc(doc$$2) {
|
|
31592
|
-
return mapDoc$
|
|
31968
|
+
return mapDoc$5(doc$$2, function (currentDoc) {
|
|
31593
31969
|
if (!currentDoc.parts) {
|
|
31594
31970
|
return currentDoc;
|
|
31595
31971
|
}
|
|
@@ -31752,9 +32128,9 @@ var markdown$1 = Object.freeze({
|
|
|
31752
32128
|
default: markdown
|
|
31753
32129
|
});
|
|
31754
32130
|
|
|
31755
|
-
var require$$0$
|
|
32131
|
+
var require$$0$28 = ( markdown$1 && markdown ) || markdown$1;
|
|
31756
32132
|
|
|
31757
|
-
var languages$4 = [createLanguage(require$$0$
|
|
32133
|
+
var languages$4 = [createLanguage(require$$0$28, {
|
|
31758
32134
|
override: {
|
|
31759
32135
|
since: "1.8.0",
|
|
31760
32136
|
parsers: ["remark"],
|
|
@@ -32057,8 +32433,6 @@ var json$9 = {"CSS_DISPLAY_TAGS":{"area":"none","base":"none","basefont":"none",
|
|
|
32057
32433
|
|
|
32058
32434
|
var htmlElementAttributes$1 = ( htmlElementAttributes && index$13 ) || htmlElementAttributes;
|
|
32059
32435
|
|
|
32060
|
-
var concat$15 = doc.builders.concat;
|
|
32061
|
-
var mapDoc$7 = doc.utils.mapDoc;
|
|
32062
32436
|
var CSS_DISPLAY_TAGS = json$9.CSS_DISPLAY_TAGS;
|
|
32063
32437
|
var CSS_DISPLAY_DEFAULT = json$9.CSS_DISPLAY_DEFAULT;
|
|
32064
32438
|
var CSS_WHITE_SPACE_TAGS = json$9.CSS_WHITE_SPACE_TAGS;
|
|
@@ -32273,18 +32647,6 @@ function isDanglingSpaceSensitiveNode(node) {
|
|
|
32273
32647
|
return isDanglingSpaceSensitiveCssDisplay(node.cssDisplay) && !isScriptLikeTag$1(node);
|
|
32274
32648
|
}
|
|
32275
32649
|
|
|
32276
|
-
function replaceNewlines$1(text, replacement) {
|
|
32277
|
-
return text.split(/(\n)/g).map(function (data, index) {
|
|
32278
|
-
return index % 2 === 1 ? replacement : data;
|
|
32279
|
-
});
|
|
32280
|
-
}
|
|
32281
|
-
|
|
32282
|
-
function replaceDocNewlines$1(doc$$2, replacement) {
|
|
32283
|
-
return mapDoc$7(doc$$2, function (currentDoc) {
|
|
32284
|
-
return typeof currentDoc === "string" && currentDoc.includes("\n") ? concat$15(replaceNewlines$1(currentDoc, replacement)) : currentDoc;
|
|
32285
|
-
});
|
|
32286
|
-
}
|
|
32287
|
-
|
|
32288
32650
|
function forceNextEmptyLine$1(node) {
|
|
32289
32651
|
return isFrontMatterNode(node) || node.next && node.sourceSpan.end.line + 1 < node.next.sourceSpan.start.line;
|
|
32290
32652
|
}
|
|
@@ -32294,7 +32656,7 @@ function forceNextEmptyLine$1(node) {
|
|
|
32294
32656
|
function forceBreakContent$1(node) {
|
|
32295
32657
|
return forceBreakChildren$1(node) || node.type === "element" && node.children.length !== 0 && (["body", "template", "script", "style"].indexOf(node.name) !== -1 || node.children.some(function (child) {
|
|
32296
32658
|
return hasNonTextChild(child);
|
|
32297
|
-
}));
|
|
32659
|
+
})) || node.firstChild && node.firstChild === node.lastChild && hasLeadingLineBreak(node.firstChild) && (!node.lastChild.isTrailingSpaceSensitive || hasTrailingLineBreak(node.lastChild));
|
|
32298
32660
|
}
|
|
32299
32661
|
/** spaces between children */
|
|
32300
32662
|
|
|
@@ -32304,19 +32666,11 @@ function forceBreakChildren$1(node) {
|
|
|
32304
32666
|
}
|
|
32305
32667
|
|
|
32306
32668
|
function preferHardlineAsLeadingSpaces$1(node) {
|
|
32307
|
-
return preferHardlineAsSurroundingSpaces(node) || node.prev && preferHardlineAsTrailingSpaces(node.prev) ||
|
|
32669
|
+
return preferHardlineAsSurroundingSpaces(node) || node.prev && preferHardlineAsTrailingSpaces(node.prev) || hasSurroundingLineBreak(node);
|
|
32308
32670
|
}
|
|
32309
32671
|
|
|
32310
32672
|
function preferHardlineAsTrailingSpaces(node) {
|
|
32311
|
-
return preferHardlineAsSurroundingSpaces(node) || node.type === "element" && node.fullName === "br" ||
|
|
32312
|
-
}
|
|
32313
|
-
|
|
32314
|
-
function isCustomElementWithSurroundingLineBreak(node) {
|
|
32315
|
-
return isCustomElement(node) && hasSurroundingLineBreak(node);
|
|
32316
|
-
}
|
|
32317
|
-
|
|
32318
|
-
function isCustomElement(node) {
|
|
32319
|
-
return node.type === "element" && !node.namespace && (node.name.includes("-") || /[A-Z]/.test(node.name[0]));
|
|
32673
|
+
return preferHardlineAsSurroundingSpaces(node) || node.type === "element" && node.fullName === "br" || hasSurroundingLineBreak(node);
|
|
32320
32674
|
}
|
|
32321
32675
|
|
|
32322
32676
|
function hasSurroundingLineBreak(node) {
|
|
@@ -32358,7 +32712,7 @@ function hasNonTextChild(node) {
|
|
|
32358
32712
|
function inferScriptParser$1(node) {
|
|
32359
32713
|
if (node.name === "script" && !node.attrMap.src) {
|
|
32360
32714
|
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") {
|
|
32361
|
-
return "
|
|
32715
|
+
return "babel";
|
|
32362
32716
|
}
|
|
32363
32717
|
|
|
32364
32718
|
if (node.attrMap.type === "application/x-typescript" || node.attrMap.lang === "ts" || node.attrMap.lang === "tsx") {
|
|
@@ -32368,6 +32722,10 @@ function inferScriptParser$1(node) {
|
|
|
32368
32722
|
if (node.attrMap.type === "text/markdown") {
|
|
32369
32723
|
return "markdown";
|
|
32370
32724
|
}
|
|
32725
|
+
|
|
32726
|
+
if (node.attrMap.type === "application/ld+json") {
|
|
32727
|
+
return "json";
|
|
32728
|
+
}
|
|
32371
32729
|
}
|
|
32372
32730
|
|
|
32373
32731
|
if (node.name === "style") {
|
|
@@ -32572,10 +32930,27 @@ function shouldNotPrintClosingTag$1(node, options) {
|
|
|
32572
32930
|
return !node.isSelfClosing && !node.endSourceSpan && (hasPrettierIgnore$3(node) || shouldPreserveContent$1(node.parent, options));
|
|
32573
32931
|
}
|
|
32574
32932
|
|
|
32575
|
-
|
|
32933
|
+
function countChars$1(text, char) {
|
|
32934
|
+
var counter = 0;
|
|
32935
|
+
|
|
32936
|
+
for (var i = 0; i < text.length; i++) {
|
|
32937
|
+
if (text[i] === char) {
|
|
32938
|
+
counter++;
|
|
32939
|
+
}
|
|
32940
|
+
}
|
|
32941
|
+
|
|
32942
|
+
return counter;
|
|
32943
|
+
}
|
|
32944
|
+
|
|
32945
|
+
function unescapeQuoteEntities$1(text) {
|
|
32946
|
+
return text.replace(/'/g, "'").replace(/"/g, '"');
|
|
32947
|
+
}
|
|
32948
|
+
|
|
32949
|
+
var utils$10 = {
|
|
32576
32950
|
HTML_ELEMENT_ATTRIBUTES,
|
|
32577
32951
|
HTML_TAGS,
|
|
32578
32952
|
canHaveInterpolation,
|
|
32953
|
+
countChars: countChars$1,
|
|
32579
32954
|
countParents: countParents$1,
|
|
32580
32955
|
dedentString: dedentString$1,
|
|
32581
32956
|
forceBreakChildren: forceBreakChildren$1,
|
|
@@ -32600,19 +32975,18 @@ var utils_1$3 = {
|
|
|
32600
32975
|
normalizeParts: normalizeParts$2,
|
|
32601
32976
|
preferHardlineAsLeadingSpaces: preferHardlineAsLeadingSpaces$1,
|
|
32602
32977
|
preferHardlineAsTrailingSpaces,
|
|
32603
|
-
replaceDocNewlines: replaceDocNewlines$1,
|
|
32604
|
-
replaceNewlines: replaceNewlines$1,
|
|
32605
32978
|
shouldNotPrintClosingTag: shouldNotPrintClosingTag$1,
|
|
32606
|
-
shouldPreserveContent: shouldPreserveContent$1
|
|
32979
|
+
shouldPreserveContent: shouldPreserveContent$1,
|
|
32980
|
+
unescapeQuoteEntities: unescapeQuoteEntities$1
|
|
32607
32981
|
};
|
|
32608
32982
|
|
|
32609
|
-
var canHaveInterpolation$1 =
|
|
32610
|
-
var getNodeCssStyleDisplay$1 =
|
|
32611
|
-
var isDanglingSpaceSensitiveNode$1 =
|
|
32612
|
-
var isIndentationSensitiveNode$1 =
|
|
32613
|
-
var isLeadingSpaceSensitiveNode$1 =
|
|
32614
|
-
var isTrailingSpaceSensitiveNode$1 =
|
|
32615
|
-
var isWhitespaceSensitiveNode$1 =
|
|
32983
|
+
var canHaveInterpolation$1 = utils$10.canHaveInterpolation;
|
|
32984
|
+
var getNodeCssStyleDisplay$1 = utils$10.getNodeCssStyleDisplay;
|
|
32985
|
+
var isDanglingSpaceSensitiveNode$1 = utils$10.isDanglingSpaceSensitiveNode;
|
|
32986
|
+
var isIndentationSensitiveNode$1 = utils$10.isIndentationSensitiveNode;
|
|
32987
|
+
var isLeadingSpaceSensitiveNode$1 = utils$10.isLeadingSpaceSensitiveNode;
|
|
32988
|
+
var isTrailingSpaceSensitiveNode$1 = utils$10.isTrailingSpaceSensitiveNode;
|
|
32989
|
+
var isWhitespaceSensitiveNode$1 = utils$10.isWhitespaceSensitiveNode;
|
|
32616
32990
|
var PREPROCESS_PIPELINE = [removeIgnorableFirstLf, mergeIeConditonalStartEndCommentIntoElementOpeningTag, mergeCdataIntoText, extractInterpolation, extractWhitespaces, addCssDisplay, addIsSelfClosing, addHasHtmComponentClosingTag, addIsSpaceSensitive, mergeSimpleElementIntoText];
|
|
32617
32991
|
|
|
32618
32992
|
function preprocess$4(ast, options) {
|
|
@@ -33035,9 +33409,9 @@ var pragma$9 = {
|
|
|
33035
33409
|
insertPragma: insertPragma$7
|
|
33036
33410
|
};
|
|
33037
33411
|
|
|
33038
|
-
var _require$$0$builders$
|
|
33039
|
-
var concat$
|
|
33040
|
-
var group$15 = _require$$0$builders$
|
|
33412
|
+
var _require$$0$builders$8 = doc.builders;
|
|
33413
|
+
var concat$15 = _require$$0$builders$8.concat;
|
|
33414
|
+
var group$15 = _require$$0$builders$8.group;
|
|
33041
33415
|
/**
|
|
33042
33416
|
* v-for="... in ..."
|
|
33043
33417
|
* v-for="... of ..."
|
|
@@ -33051,8 +33425,8 @@ function printVueFor$1(value, textToDoc) {
|
|
|
33051
33425
|
operator = _parseVueFor.operator,
|
|
33052
33426
|
right = _parseVueFor.right;
|
|
33053
33427
|
|
|
33054
|
-
return concat$
|
|
33055
|
-
parser: "
|
|
33428
|
+
return concat$15([group$15(textToDoc(`function _(${left}) {}`, {
|
|
33429
|
+
parser: "babel",
|
|
33056
33430
|
__isVueForBindingLeft: true
|
|
33057
33431
|
})), " ", operator, " ", textToDoc(right, {
|
|
33058
33432
|
parser: "__js_expression"
|
|
@@ -33095,7 +33469,7 @@ function parseVueFor(value) {
|
|
|
33095
33469
|
|
|
33096
33470
|
function printVueSlotScope$1(value, textToDoc) {
|
|
33097
33471
|
return textToDoc(`function _(${value}) {}`, {
|
|
33098
|
-
parser: "
|
|
33472
|
+
parser: "babel",
|
|
33099
33473
|
__isVueSlotScope: true
|
|
33100
33474
|
});
|
|
33101
33475
|
}
|
|
@@ -33441,11 +33815,11 @@ var parseSrcset = createCommonjsModule(function (module) {
|
|
|
33441
33815
|
});
|
|
33442
33816
|
});
|
|
33443
33817
|
|
|
33444
|
-
var _require$$0$builders$
|
|
33445
|
-
var concat$
|
|
33446
|
-
var ifBreak$6 = _require$$0$builders$
|
|
33447
|
-
var join$11 = _require$$0$builders$
|
|
33448
|
-
var line$10 = _require$$0$builders$
|
|
33818
|
+
var _require$$0$builders$9 = doc.builders;
|
|
33819
|
+
var concat$16 = _require$$0$builders$9.concat;
|
|
33820
|
+
var ifBreak$6 = _require$$0$builders$9.ifBreak;
|
|
33821
|
+
var join$11 = _require$$0$builders$9.join;
|
|
33822
|
+
var line$10 = _require$$0$builders$9.line;
|
|
33449
33823
|
|
|
33450
33824
|
function printImgSrcset$1(value) {
|
|
33451
33825
|
var srcset = parseSrcset(value, {
|
|
@@ -33493,7 +33867,7 @@ function printImgSrcset$1(value) {
|
|
|
33493
33867
|
return index === -1 ? descriptor.length : index;
|
|
33494
33868
|
});
|
|
33495
33869
|
var maxDescriptorLeftLength = getMax(descriptorLeftLengths);
|
|
33496
|
-
return join$11(concat$
|
|
33870
|
+
return join$11(concat$16([",", line$10]), urls.map(function (url, index) {
|
|
33497
33871
|
var parts = [url];
|
|
33498
33872
|
var descriptor = descriptors[index];
|
|
33499
33873
|
|
|
@@ -33504,7 +33878,7 @@ function printImgSrcset$1(value) {
|
|
|
33504
33878
|
parts.push(ifBreak$6(alignment, " "), descriptor + unit);
|
|
33505
33879
|
}
|
|
33506
33880
|
|
|
33507
|
-
return concat$
|
|
33881
|
+
return concat$16(parts);
|
|
33508
33882
|
}));
|
|
33509
33883
|
}
|
|
33510
33884
|
|
|
@@ -33513,9 +33887,9 @@ var syntaxAttribute = {
|
|
|
33513
33887
|
};
|
|
33514
33888
|
|
|
33515
33889
|
var builders = doc.builders;
|
|
33516
|
-
var _require$$0$utils
|
|
33517
|
-
var stripTrailingHardline$2 = _require$$0$utils
|
|
33518
|
-
var mapDoc$
|
|
33890
|
+
var _require$$0$utils = doc.utils;
|
|
33891
|
+
var stripTrailingHardline$2 = _require$$0$utils.stripTrailingHardline;
|
|
33892
|
+
var mapDoc$7 = _require$$0$utils.mapDoc;
|
|
33519
33893
|
var breakParent$3 = builders.breakParent;
|
|
33520
33894
|
var dedentToRoot$2 = builders.dedentToRoot;
|
|
33521
33895
|
var fill$5 = builders.fill;
|
|
@@ -33528,23 +33902,24 @@ var line$9 = builders.line;
|
|
|
33528
33902
|
var literalline$6 = builders.literalline;
|
|
33529
33903
|
var markAsRoot$4 = builders.markAsRoot;
|
|
33530
33904
|
var softline$7 = builders.softline;
|
|
33531
|
-
var
|
|
33532
|
-
var
|
|
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
|
|
33905
|
+
var countChars = utils$10.countChars;
|
|
33906
|
+
var countParents = utils$10.countParents;
|
|
33907
|
+
var dedentString = utils$10.dedentString;
|
|
33908
|
+
var forceBreakChildren = utils$10.forceBreakChildren;
|
|
33909
|
+
var forceBreakContent = utils$10.forceBreakContent;
|
|
33910
|
+
var forceNextEmptyLine = utils$10.forceNextEmptyLine;
|
|
33911
|
+
var getLastDescendant = utils$10.getLastDescendant;
|
|
33912
|
+
var getPrettierIgnoreAttributeCommentData = utils$10.getPrettierIgnoreAttributeCommentData;
|
|
33913
|
+
var hasPrettierIgnore$2 = utils$10.hasPrettierIgnore;
|
|
33914
|
+
var inferScriptParser = utils$10.inferScriptParser;
|
|
33915
|
+
var isScriptLikeTag = utils$10.isScriptLikeTag;
|
|
33916
|
+
var isTextLikeNode = utils$10.isTextLikeNode;
|
|
33917
|
+
var normalizeParts$1 = utils$10.normalizeParts;
|
|
33918
|
+
var preferHardlineAsLeadingSpaces = utils$10.preferHardlineAsLeadingSpaces;
|
|
33919
|
+
var shouldNotPrintClosingTag = utils$10.shouldNotPrintClosingTag;
|
|
33920
|
+
var shouldPreserveContent = utils$10.shouldPreserveContent;
|
|
33921
|
+
var unescapeQuoteEntities = utils$10.unescapeQuoteEntities;
|
|
33922
|
+
var replaceEndOfLineWith$2 = util$1.replaceEndOfLineWith;
|
|
33548
33923
|
var insertPragma$6 = pragma$9.insertPragma;
|
|
33549
33924
|
var printVueFor = syntaxVue.printVueFor;
|
|
33550
33925
|
var printVueSlotScope = syntaxVue.printVueSlotScope;
|
|
@@ -33572,14 +33947,17 @@ function embed$6(path$$1, print, textToDoc, options) {
|
|
|
33572
33947
|
})), printClosingTagSuffix(node, options)])]);
|
|
33573
33948
|
}
|
|
33574
33949
|
} else if (node.parent.type === "interpolation") {
|
|
33575
|
-
return concat$14([indent$9(concat$14([line$9, textToDoc(node.value,
|
|
33950
|
+
return concat$14([indent$9(concat$14([line$9, textToDoc(node.value, Object.assign({
|
|
33951
|
+
__isInHtmlInterpolation: true // to avoid unexpected `}}`
|
|
33952
|
+
|
|
33953
|
+
}, options.parser === "angular" ? {
|
|
33576
33954
|
parser: "__ng_interpolation",
|
|
33577
33955
|
trailingComma: "none"
|
|
33578
33956
|
} : options.parser === "vue" ? {
|
|
33579
33957
|
parser: "__vue_expression"
|
|
33580
33958
|
} : {
|
|
33581
33959
|
parser: "__js_expression"
|
|
33582
|
-
})])), node.parent.next && needsToBorrowPrevClosingTagEndMarker(node.parent.next) ? " " : line$9]);
|
|
33960
|
+
}))])), node.parent.next && needsToBorrowPrevClosingTagEndMarker(node.parent.next) ? " " : line$9]);
|
|
33583
33961
|
}
|
|
33584
33962
|
|
|
33585
33963
|
break;
|
|
@@ -33605,7 +33983,7 @@ function embed$6(path$$1, print, textToDoc, options) {
|
|
|
33605
33983
|
}, options);
|
|
33606
33984
|
|
|
33607
33985
|
if (embeddedAttributeValueDoc) {
|
|
33608
|
-
return concat$14([node.rawName, '="', group$14(mapDoc$
|
|
33986
|
+
return concat$14([node.rawName, '="', group$14(mapDoc$7(embeddedAttributeValueDoc, function (doc$$2) {
|
|
33609
33987
|
return typeof doc$$2 === "string" ? doc$$2.replace(/"/g, """) : doc$$2;
|
|
33610
33988
|
})), '"']);
|
|
33611
33989
|
}
|
|
@@ -33614,9 +33992,9 @@ function embed$6(path$$1, print, textToDoc, options) {
|
|
|
33614
33992
|
}
|
|
33615
33993
|
|
|
33616
33994
|
case "yaml":
|
|
33617
|
-
return markAsRoot$4(concat$14(["---", hardline$12, node.value.trim().length === 0 ? "" :
|
|
33995
|
+
return markAsRoot$4(concat$14(["---", hardline$12, node.value.trim().length === 0 ? "" : textToDoc(node.value, {
|
|
33618
33996
|
parser: "yaml"
|
|
33619
|
-
}),
|
|
33997
|
+
}), "---"]));
|
|
33620
33998
|
}
|
|
33621
33999
|
}
|
|
33622
34000
|
|
|
@@ -33691,7 +34069,7 @@ function genericPrint$5(path$$1, options, print) {
|
|
|
33691
34069
|
var trailingNewlineRegex = /\n[^\S\n]*?$/;
|
|
33692
34070
|
var hasTrailingNewline = trailingNewlineRegex.test(node.value);
|
|
33693
34071
|
var value = hasTrailingNewline ? node.value.replace(trailingNewlineRegex, "") : node.value;
|
|
33694
|
-
return concat$14([concat$14(
|
|
34072
|
+
return concat$14([concat$14(replaceEndOfLineWith$2(value, literalline$6)), hasTrailingNewline ? hardline$12 : ""]);
|
|
33695
34073
|
}
|
|
33696
34074
|
|
|
33697
34075
|
return fill$5(normalizeParts$1([].concat(printOpeningTagPrefix(node, options), getTextValueParts(node), printClosingTagSuffix(node, options))));
|
|
@@ -33702,15 +34080,26 @@ function genericPrint$5(path$$1, options, print) {
|
|
|
33702
34080
|
|
|
33703
34081
|
case "comment":
|
|
33704
34082
|
{
|
|
33705
|
-
return concat$14([printOpeningTagPrefix(node, options), concat$14(
|
|
34083
|
+
return concat$14([printOpeningTagPrefix(node, options), concat$14(replaceEndOfLineWith$2(options.originalText.slice(options.locStart(node), options.locEnd(node)), literalline$6)), printClosingTagSuffix(node, options)]);
|
|
33706
34084
|
}
|
|
33707
34085
|
|
|
33708
34086
|
case "attribute":
|
|
33709
|
-
|
|
34087
|
+
{
|
|
34088
|
+
if (node.value === null) {
|
|
34089
|
+
return node.rawName;
|
|
34090
|
+
}
|
|
34091
|
+
|
|
34092
|
+
var _value = unescapeQuoteEntities(node.value);
|
|
34093
|
+
|
|
34094
|
+
var singleQuoteCount = countChars(_value, "'");
|
|
34095
|
+
var doubleQuoteCount = countChars(_value, '"');
|
|
34096
|
+
var quote = singleQuoteCount < doubleQuoteCount ? "'" : '"';
|
|
34097
|
+
return concat$14([node.rawName, concat$14(["=", quote, concat$14(replaceEndOfLineWith$2(quote === '"' ? _value.replace(/"/g, """) : _value.replace(/'/g, "'"), literalline$6)), quote])]);
|
|
34098
|
+
}
|
|
33710
34099
|
|
|
33711
34100
|
case "yaml":
|
|
33712
34101
|
case "toml":
|
|
33713
|
-
return node.raw;
|
|
34102
|
+
return concat$14(replaceEndOfLineWith$2(node.raw, literalline$6));
|
|
33714
34103
|
|
|
33715
34104
|
default:
|
|
33716
34105
|
throw new Error(`Unexpected node type ${node.type}`);
|
|
@@ -33796,11 +34185,11 @@ function printChildren$1(path$$1, options, print) {
|
|
|
33796
34185
|
var child = childPath.getValue();
|
|
33797
34186
|
|
|
33798
34187
|
if (hasPrettierIgnore$2(child)) {
|
|
33799
|
-
return concat$14([].concat(printOpeningTagPrefix(child, options),
|
|
34188
|
+
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)));
|
|
33800
34189
|
}
|
|
33801
34190
|
|
|
33802
34191
|
if (shouldPreserveContent(child, options)) {
|
|
33803
|
-
return concat$14([].concat(printOpeningTagPrefix(child, options), group$14(printOpeningTag(childPath, options, print)),
|
|
34192
|
+
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)));
|
|
33804
34193
|
}
|
|
33805
34194
|
|
|
33806
34195
|
return print(childPath);
|
|
@@ -33861,7 +34250,7 @@ function printOpeningTag(path$$1, options, print) {
|
|
|
33861
34250
|
};
|
|
33862
34251
|
return path$$1.map(function (attrPath) {
|
|
33863
34252
|
var attr = attrPath.getValue();
|
|
33864
|
-
return hasPrettierIgnoreAttribute(attr) ? concat$14(
|
|
34253
|
+
return hasPrettierIgnoreAttribute(attr) ? concat$14(replaceEndOfLineWith$2(options.originalText.slice(options.locStart(attr), options.locEnd(attr)), literalline$6)) : print(attrPath);
|
|
33865
34254
|
}, "attrs");
|
|
33866
34255
|
}(node.prev && node.prev.type === "comment" && getPrettierIgnoreAttributeCommentData(node.prev.value)))])),
|
|
33867
34256
|
/**
|
|
@@ -34072,8 +34461,8 @@ function printClosingTagEndMarker(node, options) {
|
|
|
34072
34461
|
|
|
34073
34462
|
function getTextValueParts(node) {
|
|
34074
34463
|
var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : node.value;
|
|
34075
|
-
return node.parent.isWhitespaceSensitive ? node.parent.isIndentationSensitive ?
|
|
34076
|
-
join$10(line$9, value.split(/[
|
|
34464
|
+
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
|
|
34465
|
+
join$10(line$9, value.split(/[\t\n\f\r ]+/)).parts;
|
|
34077
34466
|
}
|
|
34078
34467
|
|
|
34079
34468
|
function printEmbeddedAttributeValue(node, originalTextToDoc, options) {
|
|
@@ -34082,7 +34471,7 @@ function printEmbeddedAttributeValue(node, originalTextToDoc, options) {
|
|
|
34082
34471
|
};
|
|
34083
34472
|
|
|
34084
34473
|
var getValue = function getValue() {
|
|
34085
|
-
return node.value
|
|
34474
|
+
return unescapeQuoteEntities(node.value);
|
|
34086
34475
|
};
|
|
34087
34476
|
|
|
34088
34477
|
var shouldHug = false;
|
|
@@ -34217,21 +34606,23 @@ function printEmbeddedAttributeValue(node, originalTextToDoc, options) {
|
|
|
34217
34606
|
|
|
34218
34607
|
var interpolationRegex = /\{\{([\s\S]+?)\}\}/g;
|
|
34219
34608
|
|
|
34220
|
-
var
|
|
34609
|
+
var _value2 = getValue();
|
|
34221
34610
|
|
|
34222
|
-
if (interpolationRegex.test(
|
|
34611
|
+
if (interpolationRegex.test(_value2)) {
|
|
34223
34612
|
var parts = [];
|
|
34224
34613
|
|
|
34225
|
-
|
|
34614
|
+
_value2.split(interpolationRegex).forEach(function (part, index) {
|
|
34226
34615
|
if (index % 2 === 0) {
|
|
34227
|
-
parts.push(concat$14(
|
|
34616
|
+
parts.push(concat$14(replaceEndOfLineWith$2(part, literalline$6)));
|
|
34228
34617
|
} else {
|
|
34229
34618
|
try {
|
|
34230
34619
|
parts.push(group$14(concat$14(["{{", indent$9(concat$14([line$9, ngTextToDoc(part, {
|
|
34231
|
-
parser: "__ng_interpolation"
|
|
34620
|
+
parser: "__ng_interpolation",
|
|
34621
|
+
__isInHtmlInterpolation: true // to avoid unexpected `}}`
|
|
34622
|
+
|
|
34232
34623
|
})])), line$9, "}}"])));
|
|
34233
34624
|
} catch (e) {
|
|
34234
|
-
parts.push("{{", concat$14(
|
|
34625
|
+
parts.push("{{", concat$14(replaceEndOfLineWith$2(part, literalline$6)), "}}");
|
|
34235
34626
|
}
|
|
34236
34627
|
}
|
|
34237
34628
|
});
|
|
@@ -34338,11 +34729,11 @@ var vue$1 = Object.freeze({
|
|
|
34338
34729
|
default: vue
|
|
34339
34730
|
});
|
|
34340
34731
|
|
|
34341
|
-
var require$$0$
|
|
34732
|
+
var require$$0$31 = ( html$2 && html$1 ) || html$2;
|
|
34342
34733
|
|
|
34343
|
-
var require$$1$
|
|
34734
|
+
var require$$1$11 = ( vue$1 && vue ) || vue$1;
|
|
34344
34735
|
|
|
34345
|
-
var languages$5 = [createLanguage(require$$0$
|
|
34736
|
+
var languages$5 = [createLanguage(require$$0$31, {
|
|
34346
34737
|
override: {
|
|
34347
34738
|
name: "Angular",
|
|
34348
34739
|
since: "1.15.0",
|
|
@@ -34351,13 +34742,17 @@ var languages$5 = [createLanguage(require$$0$29, {
|
|
|
34351
34742
|
extensions: [".component.html"],
|
|
34352
34743
|
filenames: []
|
|
34353
34744
|
}
|
|
34354
|
-
}), createLanguage(require$$0$
|
|
34745
|
+
}), createLanguage(require$$0$31, {
|
|
34355
34746
|
override: {
|
|
34356
34747
|
since: "1.15.0",
|
|
34357
34748
|
parsers: ["html"],
|
|
34358
34749
|
vscodeLanguageIds: ["html"]
|
|
34750
|
+
},
|
|
34751
|
+
extend: {
|
|
34752
|
+
extensions: [".mjml" // MJML is considered XML in Linguist but it should be formatted as HTML
|
|
34753
|
+
]
|
|
34359
34754
|
}
|
|
34360
|
-
}), createLanguage(require$$1$
|
|
34755
|
+
}), createLanguage(require$$1$11, {
|
|
34361
34756
|
override: {
|
|
34362
34757
|
since: "1.10.0",
|
|
34363
34758
|
parsers: ["vue"],
|
|
@@ -34391,9 +34786,7 @@ var pragma$11 = {
|
|
|
34391
34786
|
insertPragma: insertPragma$9
|
|
34392
34787
|
};
|
|
34393
34788
|
|
|
34394
|
-
|
|
34395
|
-
return array[array.length - 1];
|
|
34396
|
-
}
|
|
34789
|
+
var getLast$7 = util$1.getLast;
|
|
34397
34790
|
|
|
34398
34791
|
function getAncestorCount$1(path$$1, filter) {
|
|
34399
34792
|
var counter = 0;
|
|
@@ -34656,7 +35049,7 @@ function getBlockValueLineContents$1(node, _ref) {
|
|
|
34656
35049
|
}
|
|
34657
35050
|
}
|
|
34658
35051
|
|
|
34659
|
-
var utils$
|
|
35052
|
+
var utils$12 = {
|
|
34660
35053
|
getLast: getLast$7,
|
|
34661
35054
|
getAncestorCount: getAncestorCount$1,
|
|
34662
35055
|
isNode: isNode$2,
|
|
@@ -34678,27 +35071,27 @@ var utils$10 = {
|
|
|
34678
35071
|
|
|
34679
35072
|
var insertPragma$8 = pragma$11.insertPragma;
|
|
34680
35073
|
var isPragma = pragma$11.isPragma;
|
|
34681
|
-
var getAncestorCount = utils$
|
|
34682
|
-
var getBlockValueLineContents = utils$
|
|
34683
|
-
var getFlowScalarLineContents = utils$
|
|
34684
|
-
var getLast$6 = utils$
|
|
34685
|
-
var getLastDescendantNode$1 = utils$
|
|
34686
|
-
var hasLeadingComments = utils$
|
|
34687
|
-
var hasMiddleComments = utils$
|
|
34688
|
-
var hasIndicatorComment = utils$
|
|
34689
|
-
var hasTrailingComment$1 = utils$
|
|
34690
|
-
var hasEndComments = utils$
|
|
34691
|
-
var hasPrettierIgnore$4 = utils$
|
|
34692
|
-
var isLastDescendantNode = utils$
|
|
34693
|
-
var isNextLineEmpty$5 = utils$
|
|
34694
|
-
var isNode$1 = utils$
|
|
34695
|
-
var isEmptyNode = utils$
|
|
34696
|
-
var defineShortcut = utils$
|
|
34697
|
-
var mapNode = utils$
|
|
35074
|
+
var getAncestorCount = utils$12.getAncestorCount;
|
|
35075
|
+
var getBlockValueLineContents = utils$12.getBlockValueLineContents;
|
|
35076
|
+
var getFlowScalarLineContents = utils$12.getFlowScalarLineContents;
|
|
35077
|
+
var getLast$6 = utils$12.getLast;
|
|
35078
|
+
var getLastDescendantNode$1 = utils$12.getLastDescendantNode;
|
|
35079
|
+
var hasLeadingComments = utils$12.hasLeadingComments;
|
|
35080
|
+
var hasMiddleComments = utils$12.hasMiddleComments;
|
|
35081
|
+
var hasIndicatorComment = utils$12.hasIndicatorComment;
|
|
35082
|
+
var hasTrailingComment$1 = utils$12.hasTrailingComment;
|
|
35083
|
+
var hasEndComments = utils$12.hasEndComments;
|
|
35084
|
+
var hasPrettierIgnore$4 = utils$12.hasPrettierIgnore;
|
|
35085
|
+
var isLastDescendantNode = utils$12.isLastDescendantNode;
|
|
35086
|
+
var isNextLineEmpty$5 = utils$12.isNextLineEmpty;
|
|
35087
|
+
var isNode$1 = utils$12.isNode;
|
|
35088
|
+
var isEmptyNode = utils$12.isEmptyNode;
|
|
35089
|
+
var defineShortcut = utils$12.defineShortcut;
|
|
35090
|
+
var mapNode = utils$12.mapNode;
|
|
34698
35091
|
var docBuilders$3 = doc.builders;
|
|
34699
35092
|
var conditionalGroup$2 = docBuilders$3.conditionalGroup;
|
|
34700
35093
|
var breakParent$4 = docBuilders$3.breakParent;
|
|
34701
|
-
var concat$
|
|
35094
|
+
var concat$17 = docBuilders$3.concat;
|
|
34702
35095
|
var dedent$4 = docBuilders$3.dedent;
|
|
34703
35096
|
var dedentToRoot$3 = docBuilders$3.dedentToRoot;
|
|
34704
35097
|
var fill$6 = docBuilders$3.fill;
|
|
@@ -34711,6 +35104,7 @@ var lineSuffix$2 = docBuilders$3.lineSuffix;
|
|
|
34711
35104
|
var literalline$7 = docBuilders$3.literalline;
|
|
34712
35105
|
var markAsRoot$5 = docBuilders$3.markAsRoot;
|
|
34713
35106
|
var softline$8 = docBuilders$3.softline;
|
|
35107
|
+
var replaceEndOfLineWith$3 = util$1.replaceEndOfLineWith;
|
|
34714
35108
|
|
|
34715
35109
|
function preprocess$6(ast) {
|
|
34716
35110
|
return mapNode(ast, defineShortcuts);
|
|
@@ -34757,16 +35151,16 @@ function genericPrint$6(path$$1, options, print) {
|
|
|
34757
35151
|
var tag = !node.tag ? "" : path$$1.call(print, "tag");
|
|
34758
35152
|
var anchor = !node.anchor ? "" : path$$1.call(print, "anchor");
|
|
34759
35153
|
var nextEmptyLine = isNode$1(node, ["mapping", "sequence", "comment", "directive", "mappingItem", "sequenceItem"]) && !isLastDescendantNode(path$$1) ? printNextEmptyLine(path$$1, options.originalText) : "";
|
|
34760
|
-
return concat$
|
|
35154
|
+
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"))])) : ""]);
|
|
34761
35155
|
}
|
|
34762
35156
|
|
|
34763
35157
|
function _print(node, parentNode, path$$1, options, print) {
|
|
34764
35158
|
switch (node.type) {
|
|
34765
35159
|
case "root":
|
|
34766
|
-
return concat$
|
|
35160
|
+
return concat$17([join$12(hardline$13, path$$1.map(function (childPath, index) {
|
|
34767
35161
|
var document = node.children[index];
|
|
34768
35162
|
var nextDocument = node.children[index + 1];
|
|
34769
|
-
return concat$
|
|
35163
|
+
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, "---"])]);
|
|
34770
35164
|
}, "children")), node.children.length === 0 || function (lastDescendantNode) {
|
|
34771
35165
|
return isNode$1(lastDescendantNode, ["blockLiteral", "blockFolded"]) && lastDescendantNode.chomping === "keep";
|
|
34772
35166
|
}(getLastDescendantNode$1(node)) ? "" : hardline$13]);
|
|
@@ -34774,7 +35168,7 @@ function _print(node, parentNode, path$$1, options, print) {
|
|
|
34774
35168
|
case "document":
|
|
34775
35169
|
{
|
|
34776
35170
|
var nextDocument = parentNode.children[path$$1.getName() + 1];
|
|
34777
|
-
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$
|
|
35171
|
+
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));
|
|
34778
35172
|
}
|
|
34779
35173
|
|
|
34780
35174
|
case "documentHead":
|
|
@@ -34787,25 +35181,25 @@ function _print(node, parentNode, path$$1, options, print) {
|
|
|
34787
35181
|
var separator = children.length === 0 || endComments.length === 0 ? "" : function (lastDescendantNode) {
|
|
34788
35182
|
return isNode$1(lastDescendantNode, ["blockFolded", "blockLiteral"]) ? lastDescendantNode.chomping === "keep" ? // there's already a newline printed at the end of blockValue (chomping=keep, lastDescendant=true)
|
|
34789
35183
|
"" : // an extra newline for better readability
|
|
34790
|
-
concat$
|
|
35184
|
+
concat$17([hardline$13, hardline$13]) : hardline$13;
|
|
34791
35185
|
}(getLastDescendantNode$1(node));
|
|
34792
|
-
return concat$
|
|
35186
|
+
return concat$17([].concat(children, separator, endComments));
|
|
34793
35187
|
}
|
|
34794
35188
|
|
|
34795
35189
|
case "directive":
|
|
34796
|
-
return concat$
|
|
35190
|
+
return concat$17(["%", join$12(" ", [node.name].concat(node.parameters))]);
|
|
34797
35191
|
|
|
34798
35192
|
case "comment":
|
|
34799
|
-
return concat$
|
|
35193
|
+
return concat$17(["#", node.value]);
|
|
34800
35194
|
|
|
34801
35195
|
case "alias":
|
|
34802
|
-
return concat$
|
|
35196
|
+
return concat$17(["*", node.value]);
|
|
34803
35197
|
|
|
34804
35198
|
case "tag":
|
|
34805
35199
|
return options.originalText.slice(node.position.start.offset, node.position.end.offset);
|
|
34806
35200
|
|
|
34807
35201
|
case "anchor":
|
|
34808
|
-
return concat$
|
|
35202
|
+
return concat$17(["&", node.value]);
|
|
34809
35203
|
|
|
34810
35204
|
case "plain":
|
|
34811
35205
|
return printFlowScalarContent(node.type, options.originalText.slice(node.position.start.offset, node.position.end.offset), options);
|
|
@@ -34821,19 +35215,19 @@ function _print(node, parentNode, path$$1, options, print) {
|
|
|
34821
35215
|
// only quoteDouble can use escape chars
|
|
34822
35216
|
// and quoteSingle do not need to escape backslashes
|
|
34823
35217
|
var originalQuote = node.type === "quoteDouble" ? doubleQuote : singleQuote;
|
|
34824
|
-
return concat$
|
|
35218
|
+
return concat$17([originalQuote, printFlowScalarContent(node.type, raw, options), originalQuote]);
|
|
34825
35219
|
} else if (raw.includes(doubleQuote)) {
|
|
34826
|
-
return concat$
|
|
35220
|
+
return concat$17([singleQuote, printFlowScalarContent(node.type, node.type === "quoteDouble" ? raw // double quote needs to be escaped by backslash in quoteDouble
|
|
34827
35221
|
.replace(/\\"/g, doubleQuote).replace(/'/g, singleQuote.repeat(2)) : raw, options), singleQuote]);
|
|
34828
35222
|
}
|
|
34829
35223
|
|
|
34830
35224
|
if (raw.includes(singleQuote)) {
|
|
34831
|
-
return concat$
|
|
35225
|
+
return concat$17([doubleQuote, printFlowScalarContent(node.type, node.type === "quoteSingle" ? // single quote needs to be escaped by 2 single quotes in quoteSingle
|
|
34832
35226
|
raw.replace(/''/g, singleQuote) : raw, options), doubleQuote]);
|
|
34833
35227
|
}
|
|
34834
35228
|
|
|
34835
35229
|
var quote = options.singleQuote ? singleQuote : doubleQuote;
|
|
34836
|
-
return concat$
|
|
35230
|
+
return concat$17([quote, printFlowScalarContent(node.type, raw, options), quote]);
|
|
34837
35231
|
}
|
|
34838
35232
|
|
|
34839
35233
|
case "blockFolded":
|
|
@@ -34843,7 +35237,7 @@ function _print(node, parentNode, path$$1, options, print) {
|
|
|
34843
35237
|
return isNode$1(ancestorNode, ["sequence", "mapping"]);
|
|
34844
35238
|
});
|
|
34845
35239
|
var isLastDescendant = isLastDescendantNode(path$$1);
|
|
34846
|
-
return concat$
|
|
35240
|
+
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, {
|
|
34847
35241
|
parentIndent,
|
|
34848
35242
|
isLastDescendant,
|
|
34849
35243
|
options
|
|
@@ -34856,7 +35250,7 @@ function _print(node, parentNode, path$$1, options, print) {
|
|
|
34856
35250
|
return join$12(hardline$13, path$$1.map(print, "children"));
|
|
34857
35251
|
|
|
34858
35252
|
case "sequenceItem":
|
|
34859
|
-
return concat$
|
|
35253
|
+
return concat$17(["- ", align$3(2, !node.content ? "" : path$$1.call(print, "content"))]);
|
|
34860
35254
|
|
|
34861
35255
|
case "mappingKey":
|
|
34862
35256
|
return !node.content ? "" : path$$1.call(print, "content");
|
|
@@ -34874,28 +35268,28 @@ function _print(node, parentNode, path$$1, options, print) {
|
|
|
34874
35268
|
var isEmptyMappingValue = isEmptyNode(node.value);
|
|
34875
35269
|
|
|
34876
35270
|
if (isEmptyMappingKey && isEmptyMappingValue) {
|
|
34877
|
-
return concat$
|
|
35271
|
+
return concat$17([": "]);
|
|
34878
35272
|
}
|
|
34879
35273
|
|
|
34880
35274
|
var key = path$$1.call(print, "key");
|
|
34881
35275
|
var value = path$$1.call(print, "value");
|
|
34882
35276
|
|
|
34883
35277
|
if (isEmptyMappingValue) {
|
|
34884
|
-
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$
|
|
35278
|
+
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)]);
|
|
34885
35279
|
}
|
|
34886
35280
|
|
|
34887
35281
|
if (isEmptyMappingKey) {
|
|
34888
|
-
return concat$
|
|
35282
|
+
return concat$17([": ", align$3(2, value)]);
|
|
34889
35283
|
}
|
|
34890
35284
|
|
|
34891
35285
|
var groupId = Symbol("mappingKey");
|
|
34892
35286
|
var forceExplicitKey = hasLeadingComments(node.value) || !isInlineNode(node.key.content);
|
|
34893
|
-
return forceExplicitKey ? concat$
|
|
34894
|
-
return concat$
|
|
35287
|
+
return forceExplicitKey ? concat$17(["? ", align$3(2, key), hardline$13, join$12("", path$$1.map(print, "value", "leadingComments").map(function (comment) {
|
|
35288
|
+
return concat$17([comment, hardline$13]);
|
|
34895
35289
|
})), ": ", align$3(2, value)]) : // force singleline
|
|
34896
|
-
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$
|
|
35290
|
+
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), {
|
|
34897
35291
|
id: groupId
|
|
34898
|
-
})])), ifBreak$7(concat$
|
|
35292
|
+
})])), 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])), {
|
|
34899
35293
|
groupId
|
|
34900
35294
|
})])]);
|
|
34901
35295
|
}
|
|
@@ -34911,8 +35305,8 @@ function _print(node, parentNode, path$$1, options, print) {
|
|
|
34911
35305
|
return lastItem.type === "flowMappingItem" && isEmptyNode(lastItem.key) && isEmptyNode(lastItem.value);
|
|
34912
35306
|
}(getLast$6(node.children));
|
|
34913
35307
|
|
|
34914
|
-
return concat$
|
|
34915
|
-
return concat$
|
|
35308
|
+
return concat$17([openMarker, indent(concat$17([bracketSpacing, concat$17(path$$1.map(function (childPath, index) {
|
|
35309
|
+
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) : ""])]);
|
|
34916
35310
|
}, "children")), ifBreak$7(",", "")])), isLastItemEmptyMappingItem ? "" : bracketSpacing, closeMarker]);
|
|
34917
35311
|
}
|
|
34918
35312
|
|
|
@@ -35166,9 +35560,9 @@ var yaml$1 = Object.freeze({
|
|
|
35166
35560
|
default: yaml
|
|
35167
35561
|
});
|
|
35168
35562
|
|
|
35169
|
-
var require$$0$
|
|
35563
|
+
var require$$0$33 = ( yaml$1 && yaml ) || yaml$1;
|
|
35170
35564
|
|
|
35171
|
-
var languages$6 = [createLanguage(require$$0$
|
|
35565
|
+
var languages$6 = [createLanguage(require$$0$33, {
|
|
35172
35566
|
override: {
|
|
35173
35567
|
since: "1.14.0",
|
|
35174
35568
|
parsers: ["yaml"],
|
|
@@ -35191,9 +35585,17 @@ var languageYaml = {
|
|
|
35191
35585
|
var internalPlugins = [// JS
|
|
35192
35586
|
languageJs, {
|
|
35193
35587
|
parsers: {
|
|
35194
|
-
// JS -
|
|
35588
|
+
// JS - Babel
|
|
35589
|
+
get babel() {
|
|
35590
|
+
return require("./parser-babylon").parsers.babel;
|
|
35591
|
+
},
|
|
35592
|
+
|
|
35593
|
+
get "babel-flow"() {
|
|
35594
|
+
return require("./parser-babylon").parsers["babel-flow"];
|
|
35595
|
+
},
|
|
35596
|
+
|
|
35195
35597
|
get babylon() {
|
|
35196
|
-
return require("./parser-babylon").parsers.
|
|
35598
|
+
return require("./parser-babylon").parsers.babel;
|
|
35197
35599
|
},
|
|
35198
35600
|
|
|
35199
35601
|
get json() {
|
|
@@ -35336,6 +35738,19 @@ languageYaml, {
|
|
|
35336
35738
|
}
|
|
35337
35739
|
}];
|
|
35338
35740
|
|
|
35741
|
+
var partition = function partition(array, fn) {
|
|
35742
|
+
var a = [];
|
|
35743
|
+
var b = [];
|
|
35744
|
+
array.forEach(function (item) {
|
|
35745
|
+
if (fn(item)) {
|
|
35746
|
+
a.push(item);
|
|
35747
|
+
} else {
|
|
35748
|
+
b.push(item);
|
|
35749
|
+
}
|
|
35750
|
+
});
|
|
35751
|
+
return [a, b];
|
|
35752
|
+
};
|
|
35753
|
+
|
|
35339
35754
|
var thirdParty$1 = ( thirdParty && thirdParty__default ) || thirdParty;
|
|
35340
35755
|
|
|
35341
35756
|
function loadPlugins(plugins, pluginSearchDirs) {
|
|
@@ -35356,7 +35771,14 @@ function loadPlugins(plugins, pluginSearchDirs) {
|
|
|
35356
35771
|
}
|
|
35357
35772
|
}
|
|
35358
35773
|
|
|
35359
|
-
var
|
|
35774
|
+
var _partition = partition(plugins, function (plugin) {
|
|
35775
|
+
return typeof plugin === "string";
|
|
35776
|
+
}),
|
|
35777
|
+
_partition2 = _slicedToArray(_partition, 2),
|
|
35778
|
+
externalPluginNames = _partition2[0],
|
|
35779
|
+
externalPluginInstances = _partition2[1];
|
|
35780
|
+
|
|
35781
|
+
var externalManualLoadPluginInfos = externalPluginNames.map(function (pluginName) {
|
|
35360
35782
|
var requirePath;
|
|
35361
35783
|
|
|
35362
35784
|
try {
|
|
@@ -35397,7 +35819,7 @@ function loadPlugins(plugins, pluginSearchDirs) {
|
|
|
35397
35819
|
return Object.assign({
|
|
35398
35820
|
name: externalPluginInfo.name
|
|
35399
35821
|
}, require(externalPluginInfo.requirePath));
|
|
35400
|
-
});
|
|
35822
|
+
}).concat(externalPluginInstances);
|
|
35401
35823
|
return internalPlugins.concat(externalPlugins);
|
|
35402
35824
|
}
|
|
35403
35825
|
|