prettier 1.16.1 → 1.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin-prettier.js +680 -489
- package/doc.js +1935 -0
- package/index.js +668 -485
- package/package.json +1 -4
- package/parser-babylon.js +1 -1
- package/parser-flow.js +1 -1
- package/parser-graphql.js +1 -1
- package/parser-html.js +1 -1
- package/parser-typescript.js +1 -1
- package/standalone.js +296 -144
- package/third-party.js +353 -133
package/bin-prettier.js
CHANGED
|
@@ -14,7 +14,7 @@ var thirdParty__default = thirdParty['default'];
|
|
|
14
14
|
var readline = _interopDefault(require('readline'));
|
|
15
15
|
|
|
16
16
|
var name = "prettier";
|
|
17
|
-
var version$1 = "1.
|
|
17
|
+
var version$1 = "1.17.0";
|
|
18
18
|
var description = "Prettier is an opinionated code formatter";
|
|
19
19
|
var bin = {
|
|
20
20
|
"prettier": "./bin/prettier.js"
|
|
@@ -28,11 +28,12 @@ var engines = {
|
|
|
28
28
|
"node": ">=6"
|
|
29
29
|
};
|
|
30
30
|
var dependencies = {
|
|
31
|
-
"@angular/compiler": "
|
|
32
|
-
"@babel/code-frame": "7.0.0
|
|
31
|
+
"@angular/compiler": "7.2.9",
|
|
32
|
+
"@babel/code-frame": "7.0.0",
|
|
33
33
|
"@babel/parser": "7.2.0",
|
|
34
34
|
"@glimmer/syntax": "0.30.3",
|
|
35
35
|
"@iarna/toml": "2.0.0",
|
|
36
|
+
"@typescript-eslint/typescript-estree": "1.6.0",
|
|
36
37
|
"angular-estree-parser": "1.1.5",
|
|
37
38
|
"angular-html-parser": "1.2.0",
|
|
38
39
|
"camelcase": "4.1.0",
|
|
@@ -51,11 +52,12 @@ var dependencies = {
|
|
|
51
52
|
"flow-parser": "0.84.0",
|
|
52
53
|
"get-stream": "3.0.0",
|
|
53
54
|
"globby": "6.1.0",
|
|
54
|
-
"graphql": "
|
|
55
|
+
"graphql": "14.2.0",
|
|
55
56
|
"html-element-attributes": "2.0.0",
|
|
56
57
|
"html-styles": "1.0.0",
|
|
57
58
|
"html-tag-names": "1.1.2",
|
|
58
|
-
"ignore": "
|
|
59
|
+
"ignore": "4.0.6",
|
|
60
|
+
"is-ci": "2.0.0",
|
|
59
61
|
"jest-docblock": "23.2.0",
|
|
60
62
|
"json-stable-stringify": "1.0.1",
|
|
61
63
|
"leven": "2.1.0",
|
|
@@ -79,8 +81,7 @@ var dependencies = {
|
|
|
79
81
|
"resolve": "1.5.0",
|
|
80
82
|
"semver": "5.4.1",
|
|
81
83
|
"string-width": "3.0.0",
|
|
82
|
-
"typescript": "3.
|
|
83
|
-
"typescript-estree": "18.0.0",
|
|
84
|
+
"typescript": "3.4.1",
|
|
84
85
|
"unicode-regex": "2.0.0",
|
|
85
86
|
"unified": "6.1.6",
|
|
86
87
|
"vnopts": "1.0.2",
|
|
@@ -109,7 +110,7 @@ var devDependencies = {
|
|
|
109
110
|
"jest-snapshot-serializer-raw": "1.1.0",
|
|
110
111
|
"jest-watch-typeahead": "0.1.0",
|
|
111
112
|
"mkdirp": "0.5.1",
|
|
112
|
-
"prettier": "1.16.
|
|
113
|
+
"prettier": "1.16.4",
|
|
113
114
|
"prettylint": "1.0.0",
|
|
114
115
|
"rimraf": "2.6.2",
|
|
115
116
|
"rollup": "0.47.6",
|
|
@@ -128,9 +129,6 @@ var devDependencies = {
|
|
|
128
129
|
"tempy": "0.2.1",
|
|
129
130
|
"webpack": "3.12.0"
|
|
130
131
|
};
|
|
131
|
-
var resolutions = {
|
|
132
|
-
"@babel/code-frame": "7.0.0-beta.46"
|
|
133
|
-
};
|
|
134
132
|
var scripts = {
|
|
135
133
|
"prepublishOnly": "echo \"Error: must publish from dist/\" && exit 1",
|
|
136
134
|
"prepare-release": "yarn && yarn build && yarn test:dist",
|
|
@@ -160,7 +158,6 @@ var _package = {
|
|
|
160
158
|
engines: engines,
|
|
161
159
|
dependencies: dependencies,
|
|
162
160
|
devDependencies: devDependencies,
|
|
163
|
-
resolutions: resolutions,
|
|
164
161
|
scripts: scripts
|
|
165
162
|
};
|
|
166
163
|
|
|
@@ -177,7 +174,6 @@ var _package$1 = Object.freeze({
|
|
|
177
174
|
engines: engines,
|
|
178
175
|
dependencies: dependencies,
|
|
179
176
|
devDependencies: devDependencies,
|
|
180
|
-
resolutions: resolutions,
|
|
181
177
|
scripts: scripts,
|
|
182
178
|
default: _package
|
|
183
179
|
});
|
|
@@ -3946,6 +3942,10 @@ var options$2 = {
|
|
|
3946
3942
|
value: "angular",
|
|
3947
3943
|
since: "1.15.0",
|
|
3948
3944
|
description: "Angular"
|
|
3945
|
+
}, {
|
|
3946
|
+
value: "lwc",
|
|
3947
|
+
since: "1.17.0",
|
|
3948
|
+
description: "Lightning Web Components"
|
|
3949
3949
|
}]
|
|
3950
3950
|
},
|
|
3951
3951
|
plugins: {
|
|
@@ -4139,6 +4139,7 @@ function getSupportInfo$2(version, opts) {
|
|
|
4139
4139
|
});
|
|
4140
4140
|
});
|
|
4141
4141
|
var usePostCssParser = semver.lt(version, "1.7.1");
|
|
4142
|
+
var useBabylonParser = semver.lt(version, "1.16.0");
|
|
4142
4143
|
var languages = plugins.reduce(function (all, plugin) {
|
|
4143
4144
|
return all.concat(plugin.languages || []);
|
|
4144
4145
|
}, []).filter(filterSince).map(function (language) {
|
|
@@ -4153,6 +4154,15 @@ function getSupportInfo$2(version, opts) {
|
|
|
4153
4154
|
return Object.assign({}, language, {
|
|
4154
4155
|
parsers: ["typescript"]
|
|
4155
4156
|
});
|
|
4157
|
+
} // "babylon" was renamed to "babel" in 1.16.0
|
|
4158
|
+
|
|
4159
|
+
|
|
4160
|
+
if (useBabylonParser && language.parsers.indexOf("babel") !== -1) {
|
|
4161
|
+
return Object.assign({}, language, {
|
|
4162
|
+
parsers: language.parsers.map(function (parser) {
|
|
4163
|
+
return parser === "babel" ? "babylon" : parser;
|
|
4164
|
+
})
|
|
4165
|
+
});
|
|
4156
4166
|
}
|
|
4157
4167
|
|
|
4158
4168
|
if (usePostCssParser && (language.name === "CSS" || language.group === "CSS")) {
|
|
@@ -8987,19 +8997,20 @@ var loc = {
|
|
|
8987
8997
|
};
|
|
8988
8998
|
|
|
8989
8999
|
var jsTokens = createCommonjsModule(function (module, exports) {
|
|
8990
|
-
// Copyright 2014, 2015, 2016, 2017 Simon Lydell
|
|
9000
|
+
// Copyright 2014, 2015, 2016, 2017, 2018 Simon Lydell
|
|
8991
9001
|
// License: MIT. (See LICENSE.)
|
|
8992
9002
|
Object.defineProperty(exports, "__esModule", {
|
|
8993
9003
|
value: true
|
|
8994
9004
|
}); // This regex comes from regex.coffee, and is inserted here by generate-index.js
|
|
8995
9005
|
// (run `npm run build`).
|
|
8996
9006
|
|
|
8997
|
-
exports.default = /((['"])(?:(?!\2|\\).|\\(?:\r\n|[\s\S]))*(\2)?|`(?:[^`\\$]|\\[\s\S]|\$(?!\{)|\$\{(?:[^{}]|\{[^}]*\}?)*\}?)*(`)?)|(\/\/.*)|(\/\*(?:[^*]|\*(?!\/))*(\*\/)?)|(\/(?!\*)(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\]\\]).|\\.)+\/(?:(?!\s*(?:\b|[\u0080-\uFFFF$\\'"~({]|[+\-!](?!=)|\.?\d))|[
|
|
9007
|
+
exports.default = /((['"])(?:(?!\2|\\).|\\(?:\r\n|[\s\S]))*(\2)?|`(?:[^`\\$]|\\[\s\S]|\$(?!\{)|\$\{(?:[^{}]|\{[^}]*\}?)*\}?)*(`)?)|(\/\/.*)|(\/\*(?:[^*]|\*(?!\/))*(\*\/)?)|(\/(?!\*)(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\]\\]).|\\.)+\/(?:(?!\s*(?:\b|[\u0080-\uFFFF$\\'"~({]|[+\-!](?!=)|\.?\d))|[gmiyus]{1,6}\b(?![\u0080-\uFFFF$\\]|\s*(?:[+\-*%&|^<>!=?({]|\/(?![\/*])))))|(0[xX][\da-fA-F]+|0[oO][0-7]+|0[bB][01]+|(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?)|((?!\d)(?:(?!\s)[$\w\u0080-\uFFFF]|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+)|(--|\+\+|&&|\|\||=>|\.{3}|(?:[+\-\/%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2})=?|[?~.,:;[\](){}])|(\s+)|(^$|[\s\S])/g;
|
|
8998
9008
|
|
|
8999
9009
|
exports.matchToToken = function (match) {
|
|
9000
9010
|
var token = {
|
|
9001
9011
|
type: "invalid",
|
|
9002
|
-
value: match[0]
|
|
9012
|
+
value: match[0],
|
|
9013
|
+
closed: undefined
|
|
9003
9014
|
};
|
|
9004
9015
|
if (match[1]) token.type = "string", token.closed = !!(match[3] || match[4]);else if (match[5]) token.type = "comment";else if (match[6]) token.type = "comment", token.closed = !!match[7];else if (match[8]) token.type = "regex";else if (match[9]) token.type = "number";else if (match[10]) token.type = "name";else if (match[11]) token.type = "punctuator";else if (match[12]) token.type = "whitespace";
|
|
9005
9016
|
return token;
|
|
@@ -10130,7 +10141,7 @@ var lib$3 = createCommonjsModule(function (module, exports) {
|
|
|
10130
10141
|
exports.default = highlight;
|
|
10131
10142
|
|
|
10132
10143
|
function _jsTokens() {
|
|
10133
|
-
var data = _interopRequireWildcard(jsTokens);
|
|
10144
|
+
var data = _interopRequireWildcard$$1(jsTokens);
|
|
10134
10145
|
|
|
10135
10146
|
_jsTokens = function _jsTokens() {
|
|
10136
10147
|
return data;
|
|
@@ -10140,7 +10151,7 @@ var lib$3 = createCommonjsModule(function (module, exports) {
|
|
|
10140
10151
|
}
|
|
10141
10152
|
|
|
10142
10153
|
function _esutils() {
|
|
10143
|
-
var data = _interopRequireDefault(utils$2);
|
|
10154
|
+
var data = _interopRequireDefault$$1(utils$2);
|
|
10144
10155
|
|
|
10145
10156
|
_esutils = function _esutils() {
|
|
10146
10157
|
return data;
|
|
@@ -10150,7 +10161,7 @@ var lib$3 = createCommonjsModule(function (module, exports) {
|
|
|
10150
10161
|
}
|
|
10151
10162
|
|
|
10152
10163
|
function _chalk() {
|
|
10153
|
-
var data = _interopRequireDefault(chalk$5);
|
|
10164
|
+
var data = _interopRequireDefault$$1(chalk$5);
|
|
10154
10165
|
|
|
10155
10166
|
_chalk = function _chalk() {
|
|
10156
10167
|
return data;
|
|
@@ -10159,13 +10170,13 @@ var lib$3 = createCommonjsModule(function (module, exports) {
|
|
|
10159
10170
|
return data;
|
|
10160
10171
|
}
|
|
10161
10172
|
|
|
10162
|
-
function _interopRequireDefault(obj) {
|
|
10173
|
+
function _interopRequireDefault$$1(obj) {
|
|
10163
10174
|
return obj && obj.__esModule ? obj : {
|
|
10164
10175
|
default: obj
|
|
10165
10176
|
};
|
|
10166
10177
|
}
|
|
10167
10178
|
|
|
10168
|
-
function _interopRequireWildcard(obj) {
|
|
10179
|
+
function _interopRequireWildcard$$1(obj) {
|
|
10169
10180
|
if (obj && obj.__esModule) {
|
|
10170
10181
|
return obj;
|
|
10171
10182
|
} else {
|
|
@@ -10210,8 +10221,9 @@ var lib$3 = createCommonjsModule(function (module, exports) {
|
|
|
10210
10221
|
|
|
10211
10222
|
function getTokenType(match) {
|
|
10212
10223
|
var _match$slice = match.slice(-2),
|
|
10213
|
-
|
|
10214
|
-
|
|
10224
|
+
_match$slice2 = _slicedToArray(_match$slice, 2),
|
|
10225
|
+
offset = _match$slice2[0],
|
|
10226
|
+
text = _match$slice2[1];
|
|
10215
10227
|
|
|
10216
10228
|
var token = (0, _jsTokens().matchToToken)(match);
|
|
10217
10229
|
|
|
@@ -10276,10 +10288,8 @@ var lib$3 = createCommonjsModule(function (module, exports) {
|
|
|
10276
10288
|
return chalk;
|
|
10277
10289
|
}
|
|
10278
10290
|
|
|
10279
|
-
function highlight(code
|
|
10280
|
-
|
|
10281
|
-
options = {};
|
|
10282
|
-
}
|
|
10291
|
+
function highlight(code) {
|
|
10292
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
10283
10293
|
|
|
10284
10294
|
if (shouldHighlight(options)) {
|
|
10285
10295
|
var chalk = getChalk(options);
|
|
@@ -10349,7 +10359,7 @@ var lib$2 = createCommonjsModule(function (module, exports) {
|
|
|
10349
10359
|
var NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
|
|
10350
10360
|
|
|
10351
10361
|
function getMarkerLines(loc, source, opts) {
|
|
10352
|
-
var startLoc = Object.assign({
|
|
10362
|
+
var startLoc = Object.assign({
|
|
10353
10363
|
column: 0,
|
|
10354
10364
|
line: -1
|
|
10355
10365
|
}, loc.start);
|
|
@@ -10408,17 +10418,14 @@ var lib$2 = createCommonjsModule(function (module, exports) {
|
|
|
10408
10418
|
}
|
|
10409
10419
|
|
|
10410
10420
|
return {
|
|
10411
|
-
start
|
|
10412
|
-
end
|
|
10413
|
-
markerLines
|
|
10421
|
+
start,
|
|
10422
|
+
end,
|
|
10423
|
+
markerLines
|
|
10414
10424
|
};
|
|
10415
10425
|
}
|
|
10416
10426
|
|
|
10417
|
-
function codeFrameColumns(rawLines, loc
|
|
10418
|
-
|
|
10419
|
-
opts = {};
|
|
10420
|
-
}
|
|
10421
|
-
|
|
10427
|
+
function codeFrameColumns(rawLines, loc) {
|
|
10428
|
+
var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
10422
10429
|
var highlighted = (opts.highlightCode || opts.forceColor) && (0, _highlight().shouldHighlight)(opts);
|
|
10423
10430
|
var chalk = (0, _highlight().getChalk)(opts);
|
|
10424
10431
|
var defs = getDefs(chalk);
|
|
@@ -10439,8 +10446,8 @@ var lib$2 = createCommonjsModule(function (module, exports) {
|
|
|
10439
10446
|
var numberMaxWidth = String(end).length;
|
|
10440
10447
|
var frame = lines.slice(start, end).map(function (line, index) {
|
|
10441
10448
|
var number = start + 1 + index;
|
|
10442
|
-
var paddedNumber =
|
|
10443
|
-
var gutter =
|
|
10449
|
+
var paddedNumber = ` ${number}`.slice(-numberMaxWidth);
|
|
10450
|
+
var gutter = ` ${paddedNumber} | `;
|
|
10444
10451
|
var hasMarker = markerLines[number];
|
|
10445
10452
|
var lastMarkerLine = !markerLines[number + 1];
|
|
10446
10453
|
|
|
@@ -10459,12 +10466,12 @@ var lib$2 = createCommonjsModule(function (module, exports) {
|
|
|
10459
10466
|
|
|
10460
10467
|
return [maybeHighlight(defs.marker, ">"), maybeHighlight(defs.gutter, gutter), line, markerLine].join("");
|
|
10461
10468
|
} else {
|
|
10462
|
-
return
|
|
10469
|
+
return ` ${maybeHighlight(defs.gutter, gutter)}${line}`;
|
|
10463
10470
|
}
|
|
10464
10471
|
}).join("\n");
|
|
10465
10472
|
|
|
10466
10473
|
if (opts.message && !hasColumns) {
|
|
10467
|
-
frame = "
|
|
10474
|
+
frame = `${" ".repeat(numberMaxWidth + 1)}${opts.message}\n${frame}`;
|
|
10468
10475
|
}
|
|
10469
10476
|
|
|
10470
10477
|
if (highlighted) {
|
|
@@ -10474,10 +10481,8 @@ var lib$2 = createCommonjsModule(function (module, exports) {
|
|
|
10474
10481
|
}
|
|
10475
10482
|
}
|
|
10476
10483
|
|
|
10477
|
-
function _default(rawLines, lineNumber, colNumber
|
|
10478
|
-
|
|
10479
|
-
opts = {};
|
|
10480
|
-
}
|
|
10484
|
+
function _default(rawLines, lineNumber, colNumber) {
|
|
10485
|
+
var opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
10481
10486
|
|
|
10482
10487
|
if (!deprecationWarningShown) {
|
|
10483
10488
|
deprecationWarningShown = true;
|
|
@@ -11149,14 +11154,6 @@ function getPenultimate(arr) {
|
|
|
11149
11154
|
return null;
|
|
11150
11155
|
}
|
|
11151
11156
|
|
|
11152
|
-
function getLast$3(arr) {
|
|
11153
|
-
if (arr.length > 0) {
|
|
11154
|
-
return arr[arr.length - 1];
|
|
11155
|
-
}
|
|
11156
|
-
|
|
11157
|
-
return null;
|
|
11158
|
-
}
|
|
11159
|
-
|
|
11160
11157
|
function skip(chars) {
|
|
11161
11158
|
return function (text, index, opts) {
|
|
11162
11159
|
var backwards = opts && opts.backwards; // Allow `skip` functions to be threaded together without having
|
|
@@ -11571,7 +11568,7 @@ function printString(raw, options, isDirectiveLiteral) {
|
|
|
11571
11568
|
// sure that we consistently output the minimum amount of escaped quotes.
|
|
11572
11569
|
|
|
11573
11570
|
|
|
11574
|
-
return makeString(rawContent, enclosingQuote, !(options.parser === "css" || options.parser === "less" || options.parser === "scss" || options.parentParser === "html" || options.parentParser === "vue" || options.parentParser === "angular"));
|
|
11571
|
+
return makeString(rawContent, enclosingQuote, !(options.parser === "css" || options.parser === "less" || options.parser === "scss" || options.parentParser === "html" || options.parentParser === "vue" || options.parentParser === "angular" || options.parentParser === "lwc"));
|
|
11575
11572
|
}
|
|
11576
11573
|
|
|
11577
11574
|
function makeString(rawContent, enclosingQuote, unescapeUnnecessaryEscapes) {
|
|
@@ -11759,7 +11756,7 @@ var util$1 = {
|
|
|
11759
11756
|
isExportDeclaration,
|
|
11760
11757
|
getParentExportDeclaration,
|
|
11761
11758
|
getPenultimate,
|
|
11762
|
-
getLast
|
|
11759
|
+
getLast,
|
|
11763
11760
|
getNextNonSpaceNonCommentCharacterIndexWithStartIndex,
|
|
11764
11761
|
getNextNonSpaceNonCommentCharacterIndex,
|
|
11765
11762
|
getNextNonSpaceNonCommentCharacter,
|
|
@@ -13210,7 +13207,7 @@ function printTrailingComment(commentPath, print, options) {
|
|
|
13210
13207
|
return concat([" ", contents]);
|
|
13211
13208
|
}
|
|
13212
13209
|
|
|
13213
|
-
return concat([lineSuffix(" "
|
|
13210
|
+
return concat([lineSuffix(concat([" ", contents])), !isBlock ? breakParent : ""]);
|
|
13214
13211
|
}
|
|
13215
13212
|
|
|
13216
13213
|
function printDanglingComments(path$$1, options, sameIndent, filter) {
|
|
@@ -14168,367 +14165,384 @@ var core = {
|
|
|
14168
14165
|
|
|
14169
14166
|
};
|
|
14170
14167
|
|
|
14171
|
-
var
|
|
14172
|
-
|
|
14173
|
-
|
|
14174
|
-
|
|
14175
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
14176
|
-
descriptor.configurable = true;
|
|
14177
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
14178
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
14179
|
-
}
|
|
14168
|
+
var ignore = createCommonjsModule(function (module) {
|
|
14169
|
+
// A simple implementation of make-array
|
|
14170
|
+
function make_array(subject) {
|
|
14171
|
+
return Array.isArray(subject) ? subject : [subject];
|
|
14180
14172
|
}
|
|
14181
14173
|
|
|
14182
|
-
|
|
14183
|
-
|
|
14184
|
-
|
|
14185
|
-
|
|
14174
|
+
var REGEX_BLANK_LINE = /^\s+$/;
|
|
14175
|
+
var REGEX_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
|
|
14176
|
+
var REGEX_LEADING_EXCAPED_HASH = /^\\#/;
|
|
14177
|
+
var SLASH = '/';
|
|
14178
|
+
var KEY_IGNORE = typeof Symbol !== 'undefined' ? Symbol.for('node-ignore')
|
|
14179
|
+
/* istanbul ignore next */
|
|
14180
|
+
: 'node-ignore';
|
|
14181
|
+
|
|
14182
|
+
var define = function define(object, key, value) {
|
|
14183
|
+
return Object.defineProperty(object, key, {
|
|
14184
|
+
value
|
|
14185
|
+
});
|
|
14186
14186
|
};
|
|
14187
|
-
}();
|
|
14188
14187
|
|
|
14189
|
-
|
|
14190
|
-
|
|
14191
|
-
throw new TypeError("Cannot call a class as a function");
|
|
14192
|
-
}
|
|
14193
|
-
}
|
|
14188
|
+
var REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g; // Sanitize the range of a regular expression
|
|
14189
|
+
// The cases are complicated, see test cases for details
|
|
14194
14190
|
|
|
14195
|
-
var
|
|
14196
|
-
|
|
14197
|
-
|
|
14191
|
+
var sanitizeRange = function sanitizeRange(range) {
|
|
14192
|
+
return range.replace(REGEX_REGEXP_RANGE, function (match, from, to) {
|
|
14193
|
+
return from.charCodeAt(0) <= to.charCodeAt(0) ? match // Invalid range (out of order) which is ok for gitignore rules but
|
|
14194
|
+
// fatal for JavaScript regular expression, so eliminate it.
|
|
14195
|
+
: '';
|
|
14196
|
+
});
|
|
14197
|
+
}; // > If the pattern ends with a slash,
|
|
14198
|
+
// > it is removed for the purpose of the following description,
|
|
14199
|
+
// > but it would only find a match with a directory.
|
|
14200
|
+
// > In other words, foo/ will match a directory foo and paths underneath it,
|
|
14201
|
+
// > but will not match a regular file or a symbolic link foo
|
|
14202
|
+
// > (this is consistent with the way how pathspec works in general in Git).
|
|
14203
|
+
// '`foo/`' will not match regular file '`foo`' or symbolic link '`foo`'
|
|
14204
|
+
// -> ignore-rules will not deal with it, because it costs extra `fs.stat` call
|
|
14205
|
+
// you could use option `mark: true` with `glob`
|
|
14206
|
+
// '`foo/`' should not continue with the '`..`'
|
|
14207
|
+
|
|
14208
|
+
|
|
14209
|
+
var DEFAULT_REPLACER_PREFIX = [// > Trailing spaces are ignored unless they are quoted with backslash ("\")
|
|
14210
|
+
[// (a\ ) -> (a )
|
|
14211
|
+
// (a ) -> (a)
|
|
14212
|
+
// (a \ ) -> (a )
|
|
14213
|
+
/\\?\s+$/, function (match) {
|
|
14214
|
+
return match.indexOf('\\') === 0 ? ' ' : '';
|
|
14215
|
+
}], // replace (\ ) with ' '
|
|
14216
|
+
[/\\\s/g, function () {
|
|
14217
|
+
return ' ';
|
|
14218
|
+
}], // Escape metacharacters
|
|
14219
|
+
// which is written down by users but means special for regular expressions.
|
|
14220
|
+
// > There are 12 characters with special meanings:
|
|
14221
|
+
// > - the backslash \,
|
|
14222
|
+
// > - the caret ^,
|
|
14223
|
+
// > - the dollar sign $,
|
|
14224
|
+
// > - the period or dot .,
|
|
14225
|
+
// > - the vertical bar or pipe symbol |,
|
|
14226
|
+
// > - the question mark ?,
|
|
14227
|
+
// > - the asterisk or star *,
|
|
14228
|
+
// > - the plus sign +,
|
|
14229
|
+
// > - the opening parenthesis (,
|
|
14230
|
+
// > - the closing parenthesis ),
|
|
14231
|
+
// > - and the opening square bracket [,
|
|
14232
|
+
// > - the opening curly brace {,
|
|
14233
|
+
// > These special characters are often called "metacharacters".
|
|
14234
|
+
[/[\\^$.|*+(){]/g, function (match) {
|
|
14235
|
+
return `\\${match}`;
|
|
14236
|
+
}], [// > [abc] matches any character inside the brackets
|
|
14237
|
+
// > (in this case a, b, or c);
|
|
14238
|
+
/\[([^\]/]*)($|\])/g, function (match, p1, p2) {
|
|
14239
|
+
return p2 === ']' ? `[${sanitizeRange(p1)}]` : `\\${match}`;
|
|
14240
|
+
}], [// > a question mark (?) matches a single character
|
|
14241
|
+
/(?!\\)\?/g, function () {
|
|
14242
|
+
return '[^/]';
|
|
14243
|
+
}], // leading slash
|
|
14244
|
+
[// > A leading slash matches the beginning of the pathname.
|
|
14245
|
+
// > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
|
|
14246
|
+
// A leading slash matches the beginning of the pathname
|
|
14247
|
+
/^\//, function () {
|
|
14248
|
+
return '^';
|
|
14249
|
+
}], // replace special metacharacter slash after the leading slash
|
|
14250
|
+
[/\//g, function () {
|
|
14251
|
+
return '\\/';
|
|
14252
|
+
}], [// > A leading "**" followed by a slash means match in all directories.
|
|
14253
|
+
// > For example, "**/foo" matches file or directory "foo" anywhere,
|
|
14254
|
+
// > the same as pattern "foo".
|
|
14255
|
+
// > "**/foo/bar" matches file or directory "bar" anywhere that is directly
|
|
14256
|
+
// > under directory "foo".
|
|
14257
|
+
// Notice that the '*'s have been replaced as '\\*'
|
|
14258
|
+
/^\^*\\\*\\\*\\\//, // '**/foo' <-> 'foo'
|
|
14259
|
+
function () {
|
|
14260
|
+
return '^(?:.*\\/)?';
|
|
14261
|
+
}]];
|
|
14262
|
+
var DEFAULT_REPLACER_SUFFIX = [// starting
|
|
14263
|
+
[// there will be no leading '/'
|
|
14264
|
+
// (which has been replaced by section "leading slash")
|
|
14265
|
+
// If starts with '**', adding a '^' to the regular expression also works
|
|
14266
|
+
/^(?=[^^])/, function startingReplacer() {
|
|
14267
|
+
return !/\/(?!$)/.test(this) // > If the pattern does not contain a slash /,
|
|
14268
|
+
// > Git treats it as a shell glob pattern
|
|
14269
|
+
// Actually, if there is only a trailing slash,
|
|
14270
|
+
// git also treats it as a shell glob pattern
|
|
14271
|
+
? '(?:^|\\/)' // > Otherwise, Git treats the pattern as a shell glob suitable for
|
|
14272
|
+
// > consumption by fnmatch(3)
|
|
14273
|
+
: '^';
|
|
14274
|
+
}], // two globstars
|
|
14275
|
+
[// Use lookahead assertions so that we could match more than one `'/**'`
|
|
14276
|
+
/\\\/\\\*\\\*(?=\\\/|$)/g, // Zero, one or several directories
|
|
14277
|
+
// should not use '*', or it will be replaced by the next replacer
|
|
14278
|
+
// Check if it is not the last `'/**'`
|
|
14279
|
+
function (match, index, str) {
|
|
14280
|
+
return index + 6 < str.length // case: /**/
|
|
14281
|
+
// > A slash followed by two consecutive asterisks then a slash matches
|
|
14282
|
+
// > zero or more directories.
|
|
14283
|
+
// > For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on.
|
|
14284
|
+
// '/**/'
|
|
14285
|
+
? '(?:\\/[^\\/]+)*' // case: /**
|
|
14286
|
+
// > A trailing `"/**"` matches everything inside.
|
|
14287
|
+
// #21: everything inside but it should not include the current folder
|
|
14288
|
+
: '\\/.+';
|
|
14289
|
+
}], // intermediate wildcards
|
|
14290
|
+
[// Never replace escaped '*'
|
|
14291
|
+
// ignore rule '\*' will match the path '*'
|
|
14292
|
+
// 'abc.*/' -> go
|
|
14293
|
+
// 'abc.*' -> skip this rule
|
|
14294
|
+
/(^|[^\\]+)\\\*(?=.+)/g, // '*.js' matches '.js'
|
|
14295
|
+
// '*.js' doesn't match 'abc'
|
|
14296
|
+
function (match, p1) {
|
|
14297
|
+
return `${p1}[^\\/]*`;
|
|
14298
|
+
}], // trailing wildcard
|
|
14299
|
+
[/(\^|\\\/)?\\\*$/, function (match, p1) {
|
|
14300
|
+
var prefix = p1 // '\^':
|
|
14301
|
+
// '/*' does not match ''
|
|
14302
|
+
// '/*' does not match everything
|
|
14303
|
+
// '\\\/':
|
|
14304
|
+
// 'abc/*' does not match 'abc/'
|
|
14305
|
+
? `${p1}[^/]+` // 'a*' matches 'a'
|
|
14306
|
+
// 'a*' matches 'aa'
|
|
14307
|
+
: '[^/]*';
|
|
14308
|
+
return `${prefix}(?=$|\\/$)`;
|
|
14309
|
+
}], [// unescape
|
|
14310
|
+
/\\\\\\/g, function () {
|
|
14311
|
+
return '\\';
|
|
14312
|
+
}]];
|
|
14313
|
+
var POSITIVE_REPLACERS = DEFAULT_REPLACER_PREFIX.concat([// 'f'
|
|
14314
|
+
// matches
|
|
14315
|
+
// - /f(end)
|
|
14316
|
+
// - /f/
|
|
14317
|
+
// - (start)f(end)
|
|
14318
|
+
// - (start)f/
|
|
14319
|
+
// doesn't match
|
|
14320
|
+
// - oof
|
|
14321
|
+
// - foo
|
|
14322
|
+
// pseudo:
|
|
14323
|
+
// -> (^|/)f(/|$)
|
|
14324
|
+
// ending
|
|
14325
|
+
[// 'js' will not match 'js.'
|
|
14326
|
+
// 'ab' will not match 'abc'
|
|
14327
|
+
/(?:[^*/])$/, // 'js*' will not match 'a.js'
|
|
14328
|
+
// 'js/' will not match 'a.js'
|
|
14329
|
+
// 'js' will match 'a.js' and 'a.js/'
|
|
14330
|
+
function (match) {
|
|
14331
|
+
return `${match}(?=$|\\/)`;
|
|
14332
|
+
}]], DEFAULT_REPLACER_SUFFIX);
|
|
14333
|
+
var NEGATIVE_REPLACERS = DEFAULT_REPLACER_PREFIX.concat([// #24, #38
|
|
14334
|
+
// The MISSING rule of [gitignore docs](https://git-scm.com/docs/gitignore)
|
|
14335
|
+
// A negative pattern without a trailing wildcard should not
|
|
14336
|
+
// re-include the things inside that directory.
|
|
14337
|
+
// eg:
|
|
14338
|
+
// ['node_modules/*', '!node_modules']
|
|
14339
|
+
// should ignore `node_modules/a.js`
|
|
14340
|
+
[/(?:[^*])$/, function (match) {
|
|
14341
|
+
return `${match}(?=$|\\/$)`;
|
|
14342
|
+
}]], DEFAULT_REPLACER_SUFFIX); // A simple cache, because an ignore rule only has only one certain meaning
|
|
14343
|
+
|
|
14344
|
+
var cache = Object.create(null); // @param {pattern}
|
|
14345
|
+
|
|
14346
|
+
var make_regex = function make_regex(pattern, negative, ignorecase) {
|
|
14347
|
+
var r = cache[pattern];
|
|
14348
|
+
|
|
14349
|
+
if (r) {
|
|
14350
|
+
return r;
|
|
14351
|
+
}
|
|
14352
|
+
|
|
14353
|
+
var replacers = negative ? NEGATIVE_REPLACERS : POSITIVE_REPLACERS;
|
|
14354
|
+
var source = replacers.reduce(function (prev, current) {
|
|
14355
|
+
return prev.replace(current[0], current[1].bind(pattern));
|
|
14356
|
+
}, pattern);
|
|
14357
|
+
return cache[pattern] = ignorecase ? new RegExp(source, 'i') : new RegExp(source);
|
|
14358
|
+
}; // > A blank line matches no files, so it can serve as a separator for readability.
|
|
14359
|
+
|
|
14360
|
+
|
|
14361
|
+
var checkPattern = function checkPattern(pattern) {
|
|
14362
|
+
return pattern && typeof pattern === 'string' && !REGEX_BLANK_LINE.test(pattern) // > A line starting with # serves as a comment.
|
|
14363
|
+
&& pattern.indexOf('#') !== 0;
|
|
14364
|
+
};
|
|
14198
14365
|
|
|
14366
|
+
var createRule = function createRule(pattern, ignorecase) {
|
|
14367
|
+
var origin = pattern;
|
|
14368
|
+
var negative = false; // > An optional prefix "!" which negates the pattern;
|
|
14199
14369
|
|
|
14200
|
-
|
|
14201
|
-
|
|
14202
|
-
|
|
14370
|
+
if (pattern.indexOf('!') === 0) {
|
|
14371
|
+
negative = true;
|
|
14372
|
+
pattern = pattern.substr(1);
|
|
14373
|
+
}
|
|
14203
14374
|
|
|
14204
|
-
|
|
14205
|
-
|
|
14206
|
-
|
|
14207
|
-
|
|
14208
|
-
|
|
14209
|
-
|
|
14210
|
-
|
|
14375
|
+
pattern = pattern // > Put a backslash ("\") in front of the first "!" for patterns that
|
|
14376
|
+
// > begin with a literal "!", for example, `"\!important!.txt"`.
|
|
14377
|
+
.replace(REGEX_LEADING_EXCAPED_EXCLAMATION, '!') // > Put a backslash ("\") in front of the first hash for patterns that
|
|
14378
|
+
// > begin with a hash.
|
|
14379
|
+
.replace(REGEX_LEADING_EXCAPED_HASH, '#');
|
|
14380
|
+
var regex = make_regex(pattern, negative, ignorecase);
|
|
14381
|
+
return {
|
|
14382
|
+
origin,
|
|
14383
|
+
pattern,
|
|
14384
|
+
negative,
|
|
14385
|
+
regex
|
|
14386
|
+
};
|
|
14387
|
+
};
|
|
14211
14388
|
|
|
14212
|
-
var IgnoreBase =
|
|
14213
|
-
|
|
14214
|
-
|
|
14389
|
+
var IgnoreBase =
|
|
14390
|
+
/*#__PURE__*/
|
|
14391
|
+
function () {
|
|
14392
|
+
function IgnoreBase() {
|
|
14393
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
14394
|
+
_ref$ignorecase = _ref.ignorecase,
|
|
14395
|
+
ignorecase = _ref$ignorecase === void 0 ? true : _ref$ignorecase;
|
|
14215
14396
|
|
|
14216
|
-
|
|
14217
|
-
this[KEY_IGNORE] = true;
|
|
14397
|
+
_classCallCheck(this, IgnoreBase);
|
|
14218
14398
|
|
|
14219
|
-
|
|
14220
|
-
|
|
14399
|
+
this._rules = [];
|
|
14400
|
+
this._ignorecase = ignorecase;
|
|
14401
|
+
define(this, KEY_IGNORE, true);
|
|
14221
14402
|
|
|
14222
|
-
|
|
14223
|
-
|
|
14224
|
-
value: function _initCache() {
|
|
14225
|
-
this._cache = {};
|
|
14226
|
-
} // @param {Array.<string>|string|Ignore} pattern
|
|
14403
|
+
this._initCache();
|
|
14404
|
+
}
|
|
14227
14405
|
|
|
14228
|
-
|
|
14229
|
-
|
|
14230
|
-
|
|
14231
|
-
|
|
14406
|
+
_createClass(IgnoreBase, [{
|
|
14407
|
+
key: "_initCache",
|
|
14408
|
+
value: function _initCache() {
|
|
14409
|
+
this._cache = Object.create(null);
|
|
14410
|
+
} // @param {Array.<string>|string|Ignore} pattern
|
|
14232
14411
|
|
|
14233
|
-
|
|
14234
|
-
|
|
14235
|
-
|
|
14412
|
+
}, {
|
|
14413
|
+
key: "add",
|
|
14414
|
+
value: function add(pattern) {
|
|
14415
|
+
this._added = false;
|
|
14236
14416
|
|
|
14237
|
-
|
|
14238
|
-
|
|
14417
|
+
if (typeof pattern === 'string') {
|
|
14418
|
+
pattern = pattern.split(/\r?\n/g);
|
|
14419
|
+
}
|
|
14239
14420
|
|
|
14240
|
-
|
|
14241
|
-
|
|
14242
|
-
}
|
|
14421
|
+
make_array(pattern).forEach(this._addPattern, this); // Some rules have just added to the ignore,
|
|
14422
|
+
// making the behavior changed.
|
|
14243
14423
|
|
|
14244
|
-
|
|
14245
|
-
|
|
14424
|
+
if (this._added) {
|
|
14425
|
+
this._initCache();
|
|
14426
|
+
}
|
|
14246
14427
|
|
|
14247
|
-
|
|
14248
|
-
|
|
14249
|
-
|
|
14250
|
-
|
|
14251
|
-
|
|
14252
|
-
|
|
14253
|
-
|
|
14254
|
-
value: function _addPattern(pattern) {
|
|
14255
|
-
// #32
|
|
14256
|
-
if (pattern && pattern[KEY_IGNORE]) {
|
|
14257
|
-
this._rules = this._rules.concat(pattern._rules);
|
|
14258
|
-
this._added = true;
|
|
14259
|
-
return;
|
|
14428
|
+
return this;
|
|
14429
|
+
} // legacy
|
|
14430
|
+
|
|
14431
|
+
}, {
|
|
14432
|
+
key: "addPattern",
|
|
14433
|
+
value: function addPattern(pattern) {
|
|
14434
|
+
return this.add(pattern);
|
|
14260
14435
|
}
|
|
14436
|
+
}, {
|
|
14437
|
+
key: "_addPattern",
|
|
14438
|
+
value: function _addPattern(pattern) {
|
|
14439
|
+
// #32
|
|
14440
|
+
if (pattern && pattern[KEY_IGNORE]) {
|
|
14441
|
+
this._rules = this._rules.concat(pattern._rules);
|
|
14442
|
+
this._added = true;
|
|
14443
|
+
return;
|
|
14444
|
+
}
|
|
14261
14445
|
|
|
14262
|
-
|
|
14263
|
-
|
|
14446
|
+
if (checkPattern(pattern)) {
|
|
14447
|
+
var rule = createRule(pattern, this._ignorecase);
|
|
14448
|
+
this._added = true;
|
|
14264
14449
|
|
|
14265
|
-
|
|
14450
|
+
this._rules.push(rule);
|
|
14451
|
+
}
|
|
14452
|
+
}
|
|
14453
|
+
}, {
|
|
14454
|
+
key: "filter",
|
|
14455
|
+
value: function filter(paths) {
|
|
14456
|
+
var _this = this;
|
|
14266
14457
|
|
|
14267
|
-
|
|
14458
|
+
return make_array(paths).filter(function (path$$1) {
|
|
14459
|
+
return _this._filter(path$$1);
|
|
14460
|
+
});
|
|
14268
14461
|
}
|
|
14269
|
-
}
|
|
14270
|
-
|
|
14271
|
-
|
|
14272
|
-
|
|
14273
|
-
// > A blank line matches no files, so it can serve as a separator for readability.
|
|
14274
|
-
return pattern && typeof pattern === 'string' && !REGEX_BLANK_LINE.test(pattern) // > A line starting with # serves as a comment.
|
|
14275
|
-
&& pattern.indexOf('#') !== 0;
|
|
14276
|
-
}
|
|
14277
|
-
}, {
|
|
14278
|
-
key: 'filter',
|
|
14279
|
-
value: function filter(paths) {
|
|
14280
|
-
var _this = this;
|
|
14462
|
+
}, {
|
|
14463
|
+
key: "createFilter",
|
|
14464
|
+
value: function createFilter() {
|
|
14465
|
+
var _this2 = this;
|
|
14281
14466
|
|
|
14282
|
-
|
|
14283
|
-
|
|
14284
|
-
|
|
14285
|
-
|
|
14286
|
-
|
|
14287
|
-
|
|
14288
|
-
|
|
14289
|
-
|
|
14467
|
+
return function (path$$1) {
|
|
14468
|
+
return _this2._filter(path$$1);
|
|
14469
|
+
};
|
|
14470
|
+
}
|
|
14471
|
+
}, {
|
|
14472
|
+
key: "ignores",
|
|
14473
|
+
value: function ignores(path$$1) {
|
|
14474
|
+
return !this._filter(path$$1);
|
|
14475
|
+
} // @returns `Boolean` true if the `path` is NOT ignored
|
|
14290
14476
|
|
|
14291
|
-
|
|
14292
|
-
|
|
14293
|
-
|
|
14294
|
-
|
|
14295
|
-
|
|
14296
|
-
|
|
14297
|
-
value: function ignores(path$$1) {
|
|
14298
|
-
return !this._filter(path$$1);
|
|
14299
|
-
}
|
|
14300
|
-
}, {
|
|
14301
|
-
key: '_createRule',
|
|
14302
|
-
value: function _createRule(pattern) {
|
|
14303
|
-
var origin = pattern;
|
|
14304
|
-
var negative = false; // > An optional prefix "!" which negates the pattern;
|
|
14477
|
+
}, {
|
|
14478
|
+
key: "_filter",
|
|
14479
|
+
value: function _filter(path$$1, slices) {
|
|
14480
|
+
if (!path$$1) {
|
|
14481
|
+
return false;
|
|
14482
|
+
}
|
|
14305
14483
|
|
|
14306
|
-
|
|
14307
|
-
|
|
14308
|
-
|
|
14309
|
-
}
|
|
14484
|
+
if (path$$1 in this._cache) {
|
|
14485
|
+
return this._cache[path$$1];
|
|
14486
|
+
}
|
|
14310
14487
|
|
|
14311
|
-
|
|
14312
|
-
|
|
14313
|
-
|
|
14314
|
-
|
|
14315
|
-
|
|
14316
|
-
origin: origin,
|
|
14317
|
-
pattern: pattern,
|
|
14318
|
-
negative: negative,
|
|
14319
|
-
regex: regex
|
|
14320
|
-
};
|
|
14321
|
-
} // @returns `Boolean` true if the `path` is NOT ignored
|
|
14488
|
+
if (!slices) {
|
|
14489
|
+
// path/to/a.js
|
|
14490
|
+
// ['path', 'to', 'a.js']
|
|
14491
|
+
slices = path$$1.split(SLASH);
|
|
14492
|
+
}
|
|
14322
14493
|
|
|
14323
|
-
|
|
14324
|
-
|
|
14325
|
-
|
|
14326
|
-
|
|
14327
|
-
|
|
14328
|
-
|
|
14494
|
+
slices.pop();
|
|
14495
|
+
return this._cache[path$$1] = slices.length // > It is not possible to re-include a file if a parent directory of
|
|
14496
|
+
// > that file is excluded.
|
|
14497
|
+
// If the path contains a parent directory, check the parent first
|
|
14498
|
+
? this._filter(slices.join(SLASH) + SLASH, slices) && this._test(path$$1) // Or only test the path
|
|
14499
|
+
: this._test(path$$1);
|
|
14500
|
+
} // @returns {Boolean} true if a file is NOT ignored
|
|
14329
14501
|
|
|
14330
|
-
|
|
14331
|
-
|
|
14332
|
-
|
|
14502
|
+
}, {
|
|
14503
|
+
key: "_test",
|
|
14504
|
+
value: function _test(path$$1) {
|
|
14505
|
+
// Explicitly define variable type by setting matched to `0`
|
|
14506
|
+
var matched = 0;
|
|
14507
|
+
|
|
14508
|
+
this._rules.forEach(function (rule) {
|
|
14509
|
+
// if matched = true, then we only test negative rules
|
|
14510
|
+
// if matched = false, then we test non-negative rules
|
|
14511
|
+
if (!(matched ^ rule.negative)) {
|
|
14512
|
+
matched = rule.negative ^ rule.regex.test(path$$1);
|
|
14513
|
+
}
|
|
14514
|
+
});
|
|
14333
14515
|
|
|
14334
|
-
|
|
14335
|
-
// path/to/a.js
|
|
14336
|
-
// ['path', 'to', 'a.js']
|
|
14337
|
-
slices = path$$1.split(SLASH);
|
|
14516
|
+
return !matched;
|
|
14338
14517
|
}
|
|
14518
|
+
}]);
|
|
14339
14519
|
|
|
14340
|
-
|
|
14341
|
-
|
|
14342
|
-
|
|
14343
|
-
? this._filter(slices.join(SLASH) + SLASH, slices) && this._test(path$$1) // Or only test the path
|
|
14344
|
-
: this._test(path$$1);
|
|
14345
|
-
} // @returns {Boolean} true if a file is NOT ignored
|
|
14520
|
+
return IgnoreBase;
|
|
14521
|
+
}(); // Windows
|
|
14522
|
+
// --------------------------------------------------------------
|
|
14346
14523
|
|
|
14347
|
-
|
|
14348
|
-
key: '_test',
|
|
14349
|
-
value: function _test(path$$1) {
|
|
14350
|
-
// Explicitly define variable type by setting matched to `0`
|
|
14351
|
-
var matched = 0;
|
|
14524
|
+
/* istanbul ignore if */
|
|
14352
14525
|
|
|
14353
|
-
this._rules.forEach(function (rule) {
|
|
14354
|
-
// if matched = true, then we only test negative rules
|
|
14355
|
-
// if matched = false, then we test non-negative rules
|
|
14356
|
-
if (!(matched ^ rule.negative)) {
|
|
14357
|
-
matched = rule.negative ^ rule.regex.test(path$$1);
|
|
14358
|
-
}
|
|
14359
|
-
});
|
|
14360
14526
|
|
|
14361
|
-
|
|
14362
|
-
|
|
14363
|
-
|
|
14527
|
+
if ( // Detect `process` so that it can run in browsers.
|
|
14528
|
+
typeof process !== 'undefined' && (process.env && process.env.IGNORE_TEST_WIN32 || process.platform === 'win32')) {
|
|
14529
|
+
var filter = IgnoreBase.prototype._filter;
|
|
14530
|
+
/* eslint no-control-regex: "off" */
|
|
14364
14531
|
|
|
14365
|
-
|
|
14366
|
-
|
|
14367
|
-
|
|
14368
|
-
|
|
14369
|
-
|
|
14370
|
-
|
|
14371
|
-
|
|
14372
|
-
|
|
14373
|
-
|
|
14374
|
-
// you could use option `mark: true` with `glob`
|
|
14375
|
-
// '`foo/`' should not continue with the '`..`'
|
|
14376
|
-
|
|
14377
|
-
|
|
14378
|
-
var DEFAULT_REPLACER_PREFIX = [// > Trailing spaces are ignored unless they are quoted with backslash ("\")
|
|
14379
|
-
[// (a\ ) -> (a )
|
|
14380
|
-
// (a ) -> (a)
|
|
14381
|
-
// (a \ ) -> (a )
|
|
14382
|
-
/\\?\s+$/, function (match) {
|
|
14383
|
-
return match.indexOf('\\') === 0 ? ' ' : '';
|
|
14384
|
-
}], // replace (\ ) with ' '
|
|
14385
|
-
[/\\\s/g, function () {
|
|
14386
|
-
return ' ';
|
|
14387
|
-
}], // Escape metacharacters
|
|
14388
|
-
// which is written down by users but means special for regular expressions.
|
|
14389
|
-
// > There are 12 characters with special meanings:
|
|
14390
|
-
// > - the backslash \,
|
|
14391
|
-
// > - the caret ^,
|
|
14392
|
-
// > - the dollar sign $,
|
|
14393
|
-
// > - the period or dot .,
|
|
14394
|
-
// > - the vertical bar or pipe symbol |,
|
|
14395
|
-
// > - the question mark ?,
|
|
14396
|
-
// > - the asterisk or star *,
|
|
14397
|
-
// > - the plus sign +,
|
|
14398
|
-
// > - the opening parenthesis (,
|
|
14399
|
-
// > - the closing parenthesis ),
|
|
14400
|
-
// > - and the opening square bracket [,
|
|
14401
|
-
// > - the opening curly brace {,
|
|
14402
|
-
// > These special characters are often called "metacharacters".
|
|
14403
|
-
[/[\\\^$.|?*+()\[{]/g, function (match) {
|
|
14404
|
-
return '\\' + match;
|
|
14405
|
-
}], // leading slash
|
|
14406
|
-
[// > A leading slash matches the beginning of the pathname.
|
|
14407
|
-
// > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
|
|
14408
|
-
// A leading slash matches the beginning of the pathname
|
|
14409
|
-
/^\//, function () {
|
|
14410
|
-
return '^';
|
|
14411
|
-
}], // replace special metacharacter slash after the leading slash
|
|
14412
|
-
[/\//g, function () {
|
|
14413
|
-
return '\\/';
|
|
14414
|
-
}], [// > A leading "**" followed by a slash means match in all directories.
|
|
14415
|
-
// > For example, "**/foo" matches file or directory "foo" anywhere,
|
|
14416
|
-
// > the same as pattern "foo".
|
|
14417
|
-
// > "**/foo/bar" matches file or directory "bar" anywhere that is directly under directory "foo".
|
|
14418
|
-
// Notice that the '*'s have been replaced as '\\*'
|
|
14419
|
-
/^\^*\\\*\\\*\\\//, // '**/foo' <-> 'foo'
|
|
14420
|
-
function () {
|
|
14421
|
-
return '^(?:.*\\/)?';
|
|
14422
|
-
}]];
|
|
14423
|
-
var DEFAULT_REPLACER_SUFFIX = [// starting
|
|
14424
|
-
[// there will be no leading '/' (which has been replaced by section "leading slash")
|
|
14425
|
-
// If starts with '**', adding a '^' to the regular expression also works
|
|
14426
|
-
/^(?=[^\^])/, function () {
|
|
14427
|
-
return !/\/(?!$)/.test(this) // > If the pattern does not contain a slash /, Git treats it as a shell glob pattern
|
|
14428
|
-
// Actually, if there is only a trailing slash, git also treats it as a shell glob pattern
|
|
14429
|
-
? '(?:^|\\/)' // > Otherwise, Git treats the pattern as a shell glob suitable for consumption by fnmatch(3)
|
|
14430
|
-
: '^';
|
|
14431
|
-
}], // two globstars
|
|
14432
|
-
[// Use lookahead assertions so that we could match more than one `'/**'`
|
|
14433
|
-
/\\\/\\\*\\\*(?=\\\/|$)/g, // Zero, one or several directories
|
|
14434
|
-
// should not use '*', or it will be replaced by the next replacer
|
|
14435
|
-
// Check if it is not the last `'/**'`
|
|
14436
|
-
function (match, index, str) {
|
|
14437
|
-
return index + 6 < str.length // case: /**/
|
|
14438
|
-
// > A slash followed by two consecutive asterisks then a slash matches zero or more directories.
|
|
14439
|
-
// > For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on.
|
|
14440
|
-
// '/**/'
|
|
14441
|
-
? '(?:\\/[^\\/]+)*' // case: /**
|
|
14442
|
-
// > A trailing `"/**"` matches everything inside.
|
|
14443
|
-
// #21: everything inside but it should not include the current folder
|
|
14444
|
-
: '\\/.+';
|
|
14445
|
-
}], // intermediate wildcards
|
|
14446
|
-
[// Never replace escaped '*'
|
|
14447
|
-
// ignore rule '\*' will match the path '*'
|
|
14448
|
-
// 'abc.*/' -> go
|
|
14449
|
-
// 'abc.*' -> skip this rule
|
|
14450
|
-
/(^|[^\\]+)\\\*(?=.+)/g, // '*.js' matches '.js'
|
|
14451
|
-
// '*.js' doesn't match 'abc'
|
|
14452
|
-
function (match, p1) {
|
|
14453
|
-
return p1 + '[^\\/]*';
|
|
14454
|
-
}], // trailing wildcard
|
|
14455
|
-
[/(\^|\\\/)?\\\*$/, function (match, p1) {
|
|
14456
|
-
return (p1 // '\^':
|
|
14457
|
-
// '/*' does not match ''
|
|
14458
|
-
// '/*' does not match everything
|
|
14459
|
-
// '\\\/':
|
|
14460
|
-
// 'abc/*' does not match 'abc/'
|
|
14461
|
-
? p1 + '[^/]+' // 'a*' matches 'a'
|
|
14462
|
-
// 'a*' matches 'aa'
|
|
14463
|
-
: '[^/]*') + '(?=$|\\/$)';
|
|
14464
|
-
}], [// unescape
|
|
14465
|
-
/\\\\\\/g, function () {
|
|
14466
|
-
return '\\';
|
|
14467
|
-
}]];
|
|
14468
|
-
var POSITIVE_REPLACERS = [].concat(DEFAULT_REPLACER_PREFIX, [// 'f'
|
|
14469
|
-
// matches
|
|
14470
|
-
// - /f(end)
|
|
14471
|
-
// - /f/
|
|
14472
|
-
// - (start)f(end)
|
|
14473
|
-
// - (start)f/
|
|
14474
|
-
// doesn't match
|
|
14475
|
-
// - oof
|
|
14476
|
-
// - foo
|
|
14477
|
-
// pseudo:
|
|
14478
|
-
// -> (^|/)f(/|$)
|
|
14479
|
-
// ending
|
|
14480
|
-
[// 'js' will not match 'js.'
|
|
14481
|
-
// 'ab' will not match 'abc'
|
|
14482
|
-
/(?:[^*\/])$/, // 'js*' will not match 'a.js'
|
|
14483
|
-
// 'js/' will not match 'a.js'
|
|
14484
|
-
// 'js' will match 'a.js' and 'a.js/'
|
|
14485
|
-
function (match) {
|
|
14486
|
-
return match + '(?=$|\\/)';
|
|
14487
|
-
}]], DEFAULT_REPLACER_SUFFIX);
|
|
14488
|
-
var NEGATIVE_REPLACERS = [].concat(DEFAULT_REPLACER_PREFIX, [// #24
|
|
14489
|
-
// The MISSING rule of [gitignore docs](https://git-scm.com/docs/gitignore)
|
|
14490
|
-
// A negative pattern without a trailing wildcard should not
|
|
14491
|
-
// re-include the things inside that directory.
|
|
14492
|
-
// eg:
|
|
14493
|
-
// ['node_modules/*', '!node_modules']
|
|
14494
|
-
// should ignore `node_modules/a.js`
|
|
14495
|
-
[/(?:[^*\/])$/, function (match) {
|
|
14496
|
-
return match + '(?=$|\\/$)';
|
|
14497
|
-
}]], DEFAULT_REPLACER_SUFFIX); // A simple cache, because an ignore rule only has only one certain meaning
|
|
14498
|
-
|
|
14499
|
-
var cache = {}; // @param {pattern}
|
|
14500
|
-
|
|
14501
|
-
function make_regex(pattern, negative) {
|
|
14502
|
-
var r = cache[pattern];
|
|
14503
|
-
|
|
14504
|
-
if (r) {
|
|
14505
|
-
return r;
|
|
14506
|
-
}
|
|
14507
|
-
|
|
14508
|
-
var replacers = negative ? NEGATIVE_REPLACERS : POSITIVE_REPLACERS;
|
|
14509
|
-
var source = replacers.reduce(function (prev, current) {
|
|
14510
|
-
return prev.replace(current[0], current[1].bind(pattern));
|
|
14511
|
-
}, pattern);
|
|
14512
|
-
return cache[pattern] = new RegExp(source, 'i');
|
|
14513
|
-
} // Windows
|
|
14514
|
-
// --------------------------------------------------------------
|
|
14515
|
-
|
|
14516
|
-
/* istanbul ignore if */
|
|
14517
|
-
|
|
14518
|
-
|
|
14519
|
-
if ( // Detect `process` so that it can run in browsers.
|
|
14520
|
-
typeof process !== 'undefined' && (process.env && process.env.IGNORE_TEST_WIN32 || process.platform === 'win32')) {
|
|
14521
|
-
var filter = IgnoreBase.prototype._filter;
|
|
14522
|
-
|
|
14523
|
-
var make_posix = function make_posix(str) {
|
|
14524
|
-
return /^\\\\\?\\/.test(str) || /[^\x00-\x80]+/.test(str) ? str : str.replace(/\\/g, '/');
|
|
14525
|
-
};
|
|
14532
|
+
var make_posix = function make_posix(str) {
|
|
14533
|
+
return /^\\\\\?\\/.test(str) || /[^\x00-\x80]+/.test(str) ? str : str.replace(/\\/g, '/');
|
|
14534
|
+
};
|
|
14535
|
+
|
|
14536
|
+
IgnoreBase.prototype._filter = function filterWin32(path$$1, slices) {
|
|
14537
|
+
path$$1 = make_posix(path$$1);
|
|
14538
|
+
return filter.call(this, path$$1, slices);
|
|
14539
|
+
};
|
|
14540
|
+
}
|
|
14526
14541
|
|
|
14527
|
-
|
|
14528
|
-
|
|
14529
|
-
return filter.call(this, path$$1, slices);
|
|
14542
|
+
module.exports = function (options) {
|
|
14543
|
+
return new IgnoreBase(options);
|
|
14530
14544
|
};
|
|
14531
|
-
}
|
|
14545
|
+
});
|
|
14532
14546
|
|
|
14533
14547
|
/**
|
|
14534
14548
|
* @param {string} filename
|
|
@@ -18294,9 +18308,9 @@ function charSet(s) {
|
|
|
18294
18308
|
|
|
18295
18309
|
|
|
18296
18310
|
var slashSplit = /\/+/;
|
|
18297
|
-
minimatch.filter = filter
|
|
18311
|
+
minimatch.filter = filter;
|
|
18298
18312
|
|
|
18299
|
-
function filter
|
|
18313
|
+
function filter(pattern, options) {
|
|
18300
18314
|
options = options || {};
|
|
18301
18315
|
return function (p, i, list) {
|
|
18302
18316
|
return minimatch(p, pattern, options);
|
|
@@ -22826,9 +22840,62 @@ function hasClosureCompilerTypeCastComment(text, path$$1, locStart, locEnd) {
|
|
|
22826
22840
|
|
|
22827
22841
|
function hasTypeCastComment(node) {
|
|
22828
22842
|
return node.comments && node.comments.some(function (comment) {
|
|
22829
|
-
return comment.leading && comments$3.isBlockComment(comment) && comment.value
|
|
22843
|
+
return comment.leading && comments$3.isBlockComment(comment) && isTypeCastComment(comment.value) && util$1.getNextNonSpaceNonCommentCharacter(text, comment, locEnd) === "(";
|
|
22830
22844
|
});
|
|
22831
22845
|
}
|
|
22846
|
+
|
|
22847
|
+
function isTypeCastComment(comment) {
|
|
22848
|
+
var trimmed = comment.trim();
|
|
22849
|
+
|
|
22850
|
+
if (!/^\*\s*@type\s*\{[^]+\}$/.test(trimmed)) {
|
|
22851
|
+
return false;
|
|
22852
|
+
}
|
|
22853
|
+
|
|
22854
|
+
var isCompletelyClosed = false;
|
|
22855
|
+
var unpairedBracketCount = 0;
|
|
22856
|
+
var _iteratorNormalCompletion = true;
|
|
22857
|
+
var _didIteratorError = false;
|
|
22858
|
+
var _iteratorError = undefined;
|
|
22859
|
+
|
|
22860
|
+
try {
|
|
22861
|
+
for (var _iterator = trimmed[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
22862
|
+
var char = _step.value;
|
|
22863
|
+
|
|
22864
|
+
if (char === "{") {
|
|
22865
|
+
if (isCompletelyClosed) {
|
|
22866
|
+
return false;
|
|
22867
|
+
}
|
|
22868
|
+
|
|
22869
|
+
unpairedBracketCount++;
|
|
22870
|
+
} else if (char === "}") {
|
|
22871
|
+
if (unpairedBracketCount === 0) {
|
|
22872
|
+
return false;
|
|
22873
|
+
}
|
|
22874
|
+
|
|
22875
|
+
unpairedBracketCount--;
|
|
22876
|
+
|
|
22877
|
+
if (unpairedBracketCount === 0) {
|
|
22878
|
+
isCompletelyClosed = true;
|
|
22879
|
+
}
|
|
22880
|
+
}
|
|
22881
|
+
}
|
|
22882
|
+
} catch (err) {
|
|
22883
|
+
_didIteratorError = true;
|
|
22884
|
+
_iteratorError = err;
|
|
22885
|
+
} finally {
|
|
22886
|
+
try {
|
|
22887
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
22888
|
+
_iterator.return();
|
|
22889
|
+
}
|
|
22890
|
+
} finally {
|
|
22891
|
+
if (_didIteratorError) {
|
|
22892
|
+
throw _iteratorError;
|
|
22893
|
+
}
|
|
22894
|
+
}
|
|
22895
|
+
}
|
|
22896
|
+
|
|
22897
|
+
return unpairedBracketCount === 0;
|
|
22898
|
+
}
|
|
22832
22899
|
}
|
|
22833
22900
|
|
|
22834
22901
|
function needsParens(path$$1, options) {
|
|
@@ -23035,7 +23102,6 @@ function needsParens(path$$1, options) {
|
|
|
23035
23102
|
|
|
23036
23103
|
case "ClassExpression":
|
|
23037
23104
|
case "ClassDeclaration":
|
|
23038
|
-
case "TSAbstractClassDeclaration":
|
|
23039
23105
|
return name === "superClass" && parent.superClass === node;
|
|
23040
23106
|
|
|
23041
23107
|
case "TSTypeAssertion":
|
|
@@ -23284,6 +23350,7 @@ function needsParens(path$$1, options) {
|
|
|
23284
23350
|
|
|
23285
23351
|
case "FunctionExpression":
|
|
23286
23352
|
switch (parent.type) {
|
|
23353
|
+
case "NewExpression":
|
|
23287
23354
|
case "CallExpression":
|
|
23288
23355
|
return name === "callee";
|
|
23289
23356
|
// Not strictly necessary, but it's clearer to the reader if IIFEs are wrapped in parentheses.
|
|
@@ -23328,7 +23395,16 @@ function needsParens(path$$1, options) {
|
|
|
23328
23395
|
}
|
|
23329
23396
|
|
|
23330
23397
|
case "ClassExpression":
|
|
23331
|
-
|
|
23398
|
+
switch (parent.type) {
|
|
23399
|
+
case "ExportDefaultDeclaration":
|
|
23400
|
+
return true;
|
|
23401
|
+
|
|
23402
|
+
case "NewExpression":
|
|
23403
|
+
return name === "callee" && parent.callee === node;
|
|
23404
|
+
|
|
23405
|
+
default:
|
|
23406
|
+
return false;
|
|
23407
|
+
}
|
|
23332
23408
|
|
|
23333
23409
|
case "OptionalMemberExpression":
|
|
23334
23410
|
return parent.type === "MemberExpression";
|
|
@@ -23360,7 +23436,7 @@ function needsParens(path$$1, options) {
|
|
|
23360
23436
|
return false;
|
|
23361
23437
|
|
|
23362
23438
|
case "NGPipeExpression":
|
|
23363
|
-
if (parent.type === "NGRoot" || parent.type === "ObjectProperty" || parent.type === "ArrayExpression" || (parent.type === "CallExpression" || parent.type === "OptionalCallExpression") && parent.arguments[name] === node || parent.type === "NGPipeExpression" && name === "right" || parent.type === "MemberExpression" && name === "property" || parent.type === "AssignmentExpression") {
|
|
23439
|
+
if (parent.type === "NGRoot" || parent.type === "NGMicrosyntaxExpression" || parent.type === "ObjectProperty" || parent.type === "ArrayExpression" || (parent.type === "CallExpression" || parent.type === "OptionalCallExpression") && parent.arguments[name] === node || parent.type === "NGPipeExpression" && name === "right" || parent.type === "MemberExpression" && name === "property" || parent.type === "AssignmentExpression") {
|
|
23364
23440
|
return false;
|
|
23365
23441
|
}
|
|
23366
23442
|
|
|
@@ -23371,7 +23447,7 @@ function needsParens(path$$1, options) {
|
|
|
23371
23447
|
}
|
|
23372
23448
|
|
|
23373
23449
|
function isStatement(node) {
|
|
23374
|
-
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 === "
|
|
23450
|
+
return node.type === "BlockStatement" || node.type === "BreakStatement" || node.type === "ClassBody" || node.type === "ClassDeclaration" || node.type === "ClassMethod" || node.type === "ClassProperty" || node.type === "ClassPrivateProperty" || node.type === "ContinueStatement" || node.type === "DebuggerStatement" || node.type === "DeclareClass" || node.type === "DeclareExportAllDeclaration" || node.type === "DeclareExportDeclaration" || node.type === "DeclareFunction" || node.type === "DeclareInterface" || node.type === "DeclareModule" || node.type === "DeclareModuleExports" || node.type === "DeclareVariable" || node.type === "DoWhileStatement" || node.type === "ExportAllDeclaration" || node.type === "ExportDefaultDeclaration" || node.type === "ExportNamedDeclaration" || node.type === "ExpressionStatement" || node.type === "ForAwaitStatement" || node.type === "ForInStatement" || node.type === "ForOfStatement" || node.type === "ForStatement" || node.type === "FunctionDeclaration" || node.type === "IfStatement" || node.type === "ImportDeclaration" || node.type === "InterfaceDeclaration" || node.type === "LabeledStatement" || node.type === "MethodDefinition" || node.type === "ReturnStatement" || node.type === "SwitchStatement" || node.type === "ThrowStatement" || node.type === "TryStatement" || node.type === "TSDeclareFunction" || node.type === "TSEnumDeclaration" || node.type === "TSImportEqualsDeclaration" || node.type === "TSInterfaceDeclaration" || node.type === "TSModuleDeclaration" || node.type === "TSNamespaceExportDeclaration" || node.type === "TypeAlias" || node.type === "VariableDeclaration" || node.type === "WhileStatement" || node.type === "WithStatement";
|
|
23375
23451
|
}
|
|
23376
23452
|
|
|
23377
23453
|
function getUnparenthesizedNode(node) {
|
|
@@ -23521,7 +23597,7 @@ var shouldFlatten$1 = util$1.shouldFlatten;
|
|
|
23521
23597
|
var getNextNonSpaceNonCommentCharacter$1 = util$1.getNextNonSpaceNonCommentCharacter;
|
|
23522
23598
|
var hasNewline$2 = util$1.hasNewline;
|
|
23523
23599
|
var hasNewlineInRange$1 = util$1.hasNewlineInRange;
|
|
23524
|
-
var getLast$
|
|
23600
|
+
var getLast$3 = util$1.getLast;
|
|
23525
23601
|
var getStringWidth$2 = util$1.getStringWidth;
|
|
23526
23602
|
var printString$1 = util$1.printString;
|
|
23527
23603
|
var printNumber$1 = util$1.printNumber;
|
|
@@ -23543,6 +23619,7 @@ var isVueEventBindingExpression = htmlBinding.isVueEventBindingExpression;
|
|
|
23543
23619
|
var hasNode = utils$4.hasNode;
|
|
23544
23620
|
var hasFlowAnnotationComment = utils$4.hasFlowAnnotationComment;
|
|
23545
23621
|
var hasFlowShorthandAnnotationComment = utils$4.hasFlowShorthandAnnotationComment;
|
|
23622
|
+
var needsQuoteProps = new WeakMap();
|
|
23546
23623
|
var _require$$6$builders = doc.builders;
|
|
23547
23624
|
var concat$4 = _require$$6$builders.concat;
|
|
23548
23625
|
var join$2 = _require$$6$builders.join;
|
|
@@ -23675,7 +23752,7 @@ function genericPrint(path$$1, options, printPath, args) {
|
|
|
23675
23752
|
}
|
|
23676
23753
|
|
|
23677
23754
|
function hasNewlineBetweenOrAfterDecorators(node, options) {
|
|
23678
|
-
return hasNewlineInRange$1(options.originalText, options.locStart(node.decorators[0]), options.locEnd(getLast$
|
|
23755
|
+
return hasNewlineInRange$1(options.originalText, options.locStart(node.decorators[0]), options.locEnd(getLast$3(node.decorators))) || hasNewline$2(options.originalText, options.locEnd(getLast$3(node.decorators)));
|
|
23679
23756
|
}
|
|
23680
23757
|
|
|
23681
23758
|
function printDecorators(path$$1, options, print) {
|
|
@@ -23992,7 +24069,7 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
23992
24069
|
return chain;
|
|
23993
24070
|
}
|
|
23994
24071
|
|
|
23995
|
-
var jsxPart = getLast$
|
|
24072
|
+
var jsxPart = getLast$3(_parts);
|
|
23996
24073
|
return group$1(concat$4([chain, ifBreak$1(indent$2(jsxPart), jsxPart, {
|
|
23997
24074
|
groupId
|
|
23998
24075
|
})]));
|
|
@@ -24337,7 +24414,7 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
24337
24414
|
if ( // We want to keep CommonJS- and AMD-style require calls, and AMD-style
|
|
24338
24415
|
// define calls, as a unit.
|
|
24339
24416
|
// e.g. `define(["some/lib", (lib) => {`
|
|
24340
|
-
!isNew && n.callee.type === "Identifier" && (n.callee.name === "require" || n.callee.name === "define") ||
|
|
24417
|
+
!isNew && n.callee.type === "Identifier" && (n.callee.name === "require" || n.callee.name === "define") || // Template literals as single arguments
|
|
24341
24418
|
n.arguments.length === 1 && isTemplateOnItsOwnLine(n.arguments[0], options.originalText, options) || // Keep test declarations on a single line
|
|
24342
24419
|
// e.g. `it('long name', () => {`
|
|
24343
24420
|
!isNew && isTestCall(n, path$$1.getParentNode())) {
|
|
@@ -24457,7 +24534,7 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
24457
24534
|
props.push(concat$4(separatorParts.concat(group$1("..."))));
|
|
24458
24535
|
}
|
|
24459
24536
|
|
|
24460
|
-
var lastElem = getLast$
|
|
24537
|
+
var lastElem = getLast$3(n[propertiesField]);
|
|
24461
24538
|
var canHaveTrailingSeparator = !(lastElem && (lastElem.type === "RestProperty" || lastElem.type === "RestElement" || hasNodeIgnoreComment$1(lastElem) || n.inexact));
|
|
24462
24539
|
var content;
|
|
24463
24540
|
|
|
@@ -24539,7 +24616,7 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
24539
24616
|
parts.push(group$1(concat$4(["[", comments.printDanglingComments(path$$1, options), softline$1, "]"])));
|
|
24540
24617
|
}
|
|
24541
24618
|
} else {
|
|
24542
|
-
var _lastElem = getLast$
|
|
24619
|
+
var _lastElem = getLast$3(n.elements);
|
|
24543
24620
|
|
|
24544
24621
|
var canHaveTrailingComma = !(_lastElem && _lastElem.type === "RestElement"); // JavaScript allows you to have empty elements in an array which
|
|
24545
24622
|
// changes its length based on the number of commas. The algorithm
|
|
@@ -24983,7 +25060,7 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
24983
25060
|
return group$1(concat$4(["<", path$$1.call(print, "name"), path$$1.call(print, "typeParameters"), " ", concat$4(path$$1.map(print, "attributes")), _n.selfClosing ? " />" : ">"]));
|
|
24984
25061
|
}
|
|
24985
25062
|
|
|
24986
|
-
var lastAttrHasTrailingComments = _n.attributes.length && hasTrailingComment(getLast$
|
|
25063
|
+
var lastAttrHasTrailingComments = _n.attributes.length && hasTrailingComment(getLast$3(_n.attributes));
|
|
24987
25064
|
var bracketSameLine = // Simple tags (no attributes and no comment in tag name) should be
|
|
24988
25065
|
// kept unbroken regardless of `jsxBracketSameLine`
|
|
24989
25066
|
!_n.attributes.length && !nameHasComments || options.jsxBracketSameLine && ( // We should print the bracket in a new line for the following cases:
|
|
@@ -25089,7 +25166,6 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
25089
25166
|
|
|
25090
25167
|
case "ClassDeclaration":
|
|
25091
25168
|
case "ClassExpression":
|
|
25092
|
-
case "TSAbstractClassDeclaration":
|
|
25093
25169
|
if (isNodeStartingWithDeclare(n, options)) {
|
|
25094
25170
|
parts.push("declare ");
|
|
25095
25171
|
}
|
|
@@ -26152,18 +26228,27 @@ function printStatementSequence(path$$1, options, print) {
|
|
|
26152
26228
|
|
|
26153
26229
|
function printPropertyKey(path$$1, options, print) {
|
|
26154
26230
|
var node = path$$1.getNode();
|
|
26231
|
+
var parent = path$$1.getParentNode();
|
|
26155
26232
|
var key = node.key;
|
|
26156
26233
|
|
|
26157
|
-
if (
|
|
26234
|
+
if (options.quoteProps === "consistent" && !needsQuoteProps.has(parent)) {
|
|
26235
|
+
var objectHasStringProp = (parent.properties || parent.body || parent.members).some(function (prop) {
|
|
26236
|
+
return prop.key && prop.key.type !== "Identifier" && !isStringPropSafeToCoerceToIdentifier(prop, options);
|
|
26237
|
+
});
|
|
26238
|
+
needsQuoteProps.set(parent, objectHasStringProp);
|
|
26239
|
+
}
|
|
26240
|
+
|
|
26241
|
+
if (key.type === "Identifier" && !node.computed && (options.parser === "json" || options.quoteProps === "consistent" && needsQuoteProps.get(parent))) {
|
|
26158
26242
|
// a -> "a"
|
|
26243
|
+
var prop = printString$1(JSON.stringify(key.name), options);
|
|
26159
26244
|
return path$$1.call(function (keyPath) {
|
|
26160
26245
|
return comments.printComments(keyPath, function () {
|
|
26161
|
-
return
|
|
26246
|
+
return prop;
|
|
26162
26247
|
}, options);
|
|
26163
26248
|
}, "key");
|
|
26164
26249
|
}
|
|
26165
26250
|
|
|
26166
|
-
if (
|
|
26251
|
+
if (isStringPropSafeToCoerceToIdentifier(node, options) && (options.quoteProps === "as-needed" || options.quoteProps === "consistent" && !needsQuoteProps.get(parent))) {
|
|
26167
26252
|
// 'a' -> a
|
|
26168
26253
|
return path$$1.call(function (keyPath) {
|
|
26169
26254
|
return comments.printComments(keyPath, function () {
|
|
@@ -26222,7 +26307,7 @@ function couldGroupArg(arg) {
|
|
|
26222
26307
|
}
|
|
26223
26308
|
|
|
26224
26309
|
function shouldGroupLastArg(args) {
|
|
26225
|
-
var lastArg = getLast$
|
|
26310
|
+
var lastArg = getLast$3(args);
|
|
26226
26311
|
var penultimateArg = getPenultimate$1(args);
|
|
26227
26312
|
return !hasLeadingComment(lastArg) && !hasTrailingComment(lastArg) && couldGroupArg(lastArg) && ( // If the last two arguments are of the same type,
|
|
26228
26313
|
// disable last element expansion.
|
|
@@ -26318,7 +26403,8 @@ function printArgumentsList(path$$1, options, print) {
|
|
|
26318
26403
|
|
|
26319
26404
|
return concat$4(parts);
|
|
26320
26405
|
}, "arguments");
|
|
26321
|
-
var maybeTrailingComma =
|
|
26406
|
+
var maybeTrailingComma = // Dynamic imports cannot have trailing commas
|
|
26407
|
+
!(node.callee && node.callee.type === "Import") && shouldPrintComma(options, "all") ? "," : "";
|
|
26322
26408
|
|
|
26323
26409
|
function allArgsBrokenOut() {
|
|
26324
26410
|
return group$1(concat$4(["(", indent$2(concat$4([line$3, concat$4(printedArguments)])), maybeTrailingComma, line$3, ")"]), {
|
|
@@ -26367,14 +26453,14 @@ function printArgumentsList(path$$1, options, print) {
|
|
|
26367
26453
|
var somePrintedArgumentsWillBreak = printedArguments.some(willBreak$1);
|
|
26368
26454
|
return concat$4([somePrintedArgumentsWillBreak ? breakParent$2 : "", conditionalGroup$1([concat$4([ifBreak$1(indent$2(concat$4(["(", softline$1, concat$4(printedExpanded)])), concat$4(["(", concat$4(printedExpanded)])), somePrintedArgumentsWillBreak ? concat$4([ifBreak$1(maybeTrailingComma), softline$1]) : "", ")"]), shouldGroupFirst ? concat$4(["(", group$1(printedExpanded[0], {
|
|
26369
26455
|
shouldBreak: true
|
|
26370
|
-
}), concat$4(printedExpanded.slice(1)), ")"]) : concat$4(["(", concat$4(printedArguments.slice(0, -1)), group$1(getLast$
|
|
26456
|
+
}), concat$4(printedExpanded.slice(1)), ")"]) : concat$4(["(", concat$4(printedArguments.slice(0, -1)), group$1(getLast$3(printedExpanded), {
|
|
26371
26457
|
shouldBreak: true
|
|
26372
26458
|
}), ")"]), allArgsBrokenOut()], {
|
|
26373
26459
|
shouldBreak
|
|
26374
26460
|
})]);
|
|
26375
26461
|
}
|
|
26376
26462
|
|
|
26377
|
-
return group$1(concat$4(["(", indent$2(concat$4([softline$1, concat$4(printedArguments)])), ifBreak$1(
|
|
26463
|
+
return group$1(concat$4(["(", indent$2(concat$4([softline$1, concat$4(printedArguments)])), ifBreak$1(maybeTrailingComma), softline$1, ")"]), {
|
|
26378
26464
|
shouldBreak: printedArguments.some(willBreak$1) || anyArgEmptyLine
|
|
26379
26465
|
});
|
|
26380
26466
|
}
|
|
@@ -26413,12 +26499,37 @@ function printFunctionTypeParameters(path$$1, options, print) {
|
|
|
26413
26499
|
|
|
26414
26500
|
function printFunctionParams(path$$1, print, options, expandArg, printTypeParams) {
|
|
26415
26501
|
var fun = path$$1.getValue();
|
|
26502
|
+
var parent = path$$1.getParentNode();
|
|
26416
26503
|
var paramsField = fun.parameters ? "parameters" : "params";
|
|
26504
|
+
var isParametersInTestCall = isTestCall(parent);
|
|
26505
|
+
var shouldHugParameters = shouldHugArguments(fun);
|
|
26506
|
+
var shouldExpandParameters = expandArg && !(fun[paramsField] && fun[paramsField].some(function (n) {
|
|
26507
|
+
return n.comments;
|
|
26508
|
+
}));
|
|
26417
26509
|
var typeParams = printTypeParams ? printFunctionTypeParameters(path$$1, options, print) : "";
|
|
26418
26510
|
var printed = [];
|
|
26419
26511
|
|
|
26420
26512
|
if (fun[paramsField]) {
|
|
26421
|
-
|
|
26513
|
+
var lastArgIndex = fun[paramsField].length - 1;
|
|
26514
|
+
printed = path$$1.map(function (childPath, index) {
|
|
26515
|
+
var parts = [];
|
|
26516
|
+
var param = childPath.getValue();
|
|
26517
|
+
parts.push(print(childPath));
|
|
26518
|
+
|
|
26519
|
+
if (index === lastArgIndex) {
|
|
26520
|
+
if (fun.rest) {
|
|
26521
|
+
parts.push(",", line$3);
|
|
26522
|
+
}
|
|
26523
|
+
} else if (isParametersInTestCall || shouldHugParameters || shouldExpandParameters) {
|
|
26524
|
+
parts.push(", ");
|
|
26525
|
+
} else if (isNextLineEmpty$2(options.originalText, param, options)) {
|
|
26526
|
+
parts.push(",", hardline$3, hardline$3);
|
|
26527
|
+
} else {
|
|
26528
|
+
parts.push(",", line$3);
|
|
26529
|
+
}
|
|
26530
|
+
|
|
26531
|
+
return concat$4(parts);
|
|
26532
|
+
}, paramsField);
|
|
26422
26533
|
}
|
|
26423
26534
|
|
|
26424
26535
|
if (fun.rest) {
|
|
@@ -26433,7 +26544,7 @@ function printFunctionParams(path$$1, print, options, expandArg, printTypeParams
|
|
|
26433
26544
|
}), ")"]);
|
|
26434
26545
|
}
|
|
26435
26546
|
|
|
26436
|
-
var lastParam = getLast$
|
|
26547
|
+
var lastParam = getLast$3(fun[paramsField]); // If the parent is a call with the first/last argument expansion and this is the
|
|
26437
26548
|
// params of the first/last argument, we dont want the arguments to break and instead
|
|
26438
26549
|
// want the whole expression to be on a new line.
|
|
26439
26550
|
//
|
|
@@ -26444,10 +26555,8 @@ function printFunctionParams(path$$1, print, options, expandArg, printTypeParams
|
|
|
26444
26555
|
// }) ) => {
|
|
26445
26556
|
// })
|
|
26446
26557
|
|
|
26447
|
-
if (
|
|
26448
|
-
return
|
|
26449
|
-
}))) {
|
|
26450
|
-
return group$1(concat$4([removeLines$1(typeParams), "(", join$2(", ", printed.map(removeLines$1)), ")"]));
|
|
26558
|
+
if (shouldExpandParameters) {
|
|
26559
|
+
return group$1(concat$4([removeLines$1(typeParams), "(", concat$4(printed.map(removeLines$1)), ")"]));
|
|
26451
26560
|
} // Single object destructuring should hug
|
|
26452
26561
|
//
|
|
26453
26562
|
// function({
|
|
@@ -26457,14 +26566,13 @@ function printFunctionParams(path$$1, print, options, expandArg, printTypeParams
|
|
|
26457
26566
|
// }) {}
|
|
26458
26567
|
|
|
26459
26568
|
|
|
26460
|
-
if (
|
|
26461
|
-
return concat$4([typeParams, "(",
|
|
26462
|
-
}
|
|
26569
|
+
if (shouldHugParameters) {
|
|
26570
|
+
return concat$4([typeParams, "(", concat$4(printed), ")"]);
|
|
26571
|
+
} // don't break in specs, eg; `it("should maintain parens around done even when long", (done) => {})`
|
|
26463
26572
|
|
|
26464
|
-
var parent = path$$1.getParentNode(); // don't break in specs, eg; `it("should maintain parens around done even when long", (done) => {})`
|
|
26465
26573
|
|
|
26466
|
-
if (
|
|
26467
|
-
return concat$4([typeParams, "(",
|
|
26574
|
+
if (isParametersInTestCall) {
|
|
26575
|
+
return concat$4([typeParams, "(", concat$4(printed), ")"]);
|
|
26468
26576
|
}
|
|
26469
26577
|
|
|
26470
26578
|
var isFlowShorthandWithOneArg = (isObjectTypePropertyAFunction(parent, options) || isTypeAnnotationAFunction(parent, options) || parent.type === "TypeAlias" || parent.type === "UnionTypeAnnotation" || parent.type === "TSUnionType" || parent.type === "IntersectionTypeAnnotation" || parent.type === "FunctionTypeAnnotation" && parent.returnType === fun) && fun[paramsField].length === 1 && fun[paramsField][0].name === null && fun[paramsField][0].typeAnnotation && fun.typeParameters === null && isSimpleFlowType(fun[paramsField][0].typeAnnotation) && !fun.rest;
|
|
@@ -26478,7 +26586,7 @@ function printFunctionParams(path$$1, print, options, expandArg, printTypeParams
|
|
|
26478
26586
|
}
|
|
26479
26587
|
|
|
26480
26588
|
var canHaveTrailingComma = !(lastParam && lastParam.type === "RestElement") && !fun.rest;
|
|
26481
|
-
return concat$4([typeParams, "(", indent$2(concat$4([softline$1,
|
|
26589
|
+
return concat$4([typeParams, "(", indent$2(concat$4([softline$1, concat$4(printed)])), ifBreak$1(canHaveTrailingComma && shouldPrintComma(options, "all") ? "," : ""), softline$1, ")"]);
|
|
26482
26590
|
}
|
|
26483
26591
|
|
|
26484
26592
|
function shouldPrintParamsWithoutParens(path$$1, options) {
|
|
@@ -26593,7 +26701,7 @@ function printExportDeclaration(path$$1, options, print) {
|
|
|
26593
26701
|
if (decl.declaration) {
|
|
26594
26702
|
parts.push(path$$1.call(print, "declaration"));
|
|
26595
26703
|
|
|
26596
|
-
if (isDefault && decl.declaration.type !== "ClassDeclaration" && decl.declaration.type !== "FunctionDeclaration" && decl.declaration.type !== "
|
|
26704
|
+
if (isDefault && decl.declaration.type !== "ClassDeclaration" && decl.declaration.type !== "FunctionDeclaration" && decl.declaration.type !== "TSInterfaceDeclaration" && decl.declaration.type !== "DeclareClass" && decl.declaration.type !== "DeclareFunction" && decl.declaration.type !== "TSDeclareFunction") {
|
|
26597
26705
|
parts.push(semi);
|
|
26598
26706
|
}
|
|
26599
26707
|
} else {
|
|
@@ -26704,7 +26812,7 @@ function printClass(path$$1, options, print) {
|
|
|
26704
26812
|
var n = path$$1.getValue();
|
|
26705
26813
|
var parts = [];
|
|
26706
26814
|
|
|
26707
|
-
if (n.
|
|
26815
|
+
if (n.abstract) {
|
|
26708
26816
|
parts.push("abstract ");
|
|
26709
26817
|
}
|
|
26710
26818
|
|
|
@@ -27005,27 +27113,23 @@ function printMemberChain(path$$1, options, print) {
|
|
|
27005
27113
|
return firstNode.type === "ThisExpression" || firstNode.type === "Identifier" && (isFactory(firstNode.name) || isExpression && isShort(firstNode.name) || hasComputed);
|
|
27006
27114
|
}
|
|
27007
27115
|
|
|
27008
|
-
var lastNode = getLast$
|
|
27116
|
+
var lastNode = getLast$3(groups[0]).node;
|
|
27009
27117
|
return (lastNode.type === "MemberExpression" || lastNode.type === "OptionalMemberExpression") && lastNode.property.type === "Identifier" && (isFactory(lastNode.property.name) || hasComputed);
|
|
27010
27118
|
}
|
|
27011
27119
|
|
|
27012
27120
|
var shouldMerge = groups.length >= 2 && !groups[1][0].node.comments && shouldNotWrap(groups);
|
|
27013
27121
|
|
|
27014
27122
|
function printGroup(printedGroup) {
|
|
27015
|
-
var
|
|
27123
|
+
var printed = printedGroup.map(function (tuple) {
|
|
27124
|
+
return tuple.printed;
|
|
27125
|
+
}); // Checks if the last node (i.e. the parent node) needs parens and print
|
|
27126
|
+
// accordingly
|
|
27016
27127
|
|
|
27017
|
-
|
|
27018
|
-
|
|
27019
|
-
// and print accordingly
|
|
27020
|
-
if (printedGroup[_i3 + 1] && printedGroup[_i3 + 1].needsParens) {
|
|
27021
|
-
result.push("(", printedGroup[_i3].printed, printedGroup[_i3 + 1].printed, ")");
|
|
27022
|
-
_i3++;
|
|
27023
|
-
} else {
|
|
27024
|
-
result.push(printedGroup[_i3].printed);
|
|
27025
|
-
}
|
|
27128
|
+
if (printedGroup.length > 0 && printedGroup[printedGroup.length - 1].needsParens) {
|
|
27129
|
+
return concat$4(["("].concat(_toConsumableArray(printed), [")"]));
|
|
27026
27130
|
}
|
|
27027
27131
|
|
|
27028
|
-
return concat$4(
|
|
27132
|
+
return concat$4(printed);
|
|
27029
27133
|
}
|
|
27030
27134
|
|
|
27031
27135
|
function printIndentedGroup(groups) {
|
|
@@ -27055,7 +27159,7 @@ function printMemberChain(path$$1, options, print) {
|
|
|
27055
27159
|
// empty line after
|
|
27056
27160
|
|
|
27057
27161
|
|
|
27058
|
-
var lastNodeBeforeIndent = getLast$
|
|
27162
|
+
var lastNodeBeforeIndent = getLast$3(shouldMerge ? groups.slice(1, 2)[0] : groups[0]).node;
|
|
27059
27163
|
var shouldHaveEmptyLineBeforeIndent = lastNodeBeforeIndent.type !== "CallExpression" && lastNodeBeforeIndent.type !== "OptionalCallExpression" && shouldInsertEmptyLineAfter(lastNodeBeforeIndent);
|
|
27060
27164
|
var expanded = concat$4([printGroup(groups[0]), shouldMerge ? concat$4(groups.slice(1, 2).map(printGroup)) : "", shouldHaveEmptyLineBeforeIndent ? hardline$3 : "", printIndentedGroup(groups.slice(shouldMerge ? 2 : 1))]);
|
|
27061
27165
|
var callExpressions = printedNodes.map(function (_ref) {
|
|
@@ -27075,7 +27179,7 @@ function printMemberChain(path$$1, options, print) {
|
|
|
27075
27179
|
*/
|
|
27076
27180
|
function (lastGroupDoc, lastGroupNode) {
|
|
27077
27181
|
return isCallOrOptionalCallExpression(lastGroupNode) && willBreak$1(lastGroupDoc);
|
|
27078
|
-
}(getLast$
|
|
27182
|
+
}(getLast$3(printedGroups), getLast$3(getLast$3(groups)).node) && callExpressions.slice(0, -1).some(function (n) {
|
|
27079
27183
|
return n.arguments.some(isFunctionOrArrowExpression);
|
|
27080
27184
|
})) {
|
|
27081
27185
|
return group$1(expanded);
|
|
@@ -27286,7 +27390,7 @@ function printJSXChildren(path$$1, options, print, jsxWhitespace, isFacebookTran
|
|
|
27286
27390
|
|
|
27287
27391
|
var endWhitespace; // Ends with whitespace
|
|
27288
27392
|
|
|
27289
|
-
if (getLast$
|
|
27393
|
+
if (getLast$3(words) === "") {
|
|
27290
27394
|
words.pop();
|
|
27291
27395
|
endWhitespace = words.pop();
|
|
27292
27396
|
} // This was whitespace only without a new line.
|
|
@@ -27307,13 +27411,13 @@ function printJSXChildren(path$$1, options, print, jsxWhitespace, isFacebookTran
|
|
|
27307
27411
|
if (endWhitespace !== undefined) {
|
|
27308
27412
|
if (/\n/.test(endWhitespace)) {
|
|
27309
27413
|
var _next = n.children[i + 1];
|
|
27310
|
-
children.push(separatorWithWhitespace(isFacebookTranslationTag, getLast$
|
|
27414
|
+
children.push(separatorWithWhitespace(isFacebookTranslationTag, getLast$3(children), child, _next));
|
|
27311
27415
|
} else {
|
|
27312
27416
|
children.push(jsxWhitespace);
|
|
27313
27417
|
}
|
|
27314
27418
|
} else {
|
|
27315
27419
|
var _next2 = n.children[i + 1];
|
|
27316
|
-
children.push(separatorNoWhitespace(isFacebookTranslationTag, getLast$
|
|
27420
|
+
children.push(separatorNoWhitespace(isFacebookTranslationTag, getLast$3(children), child, _next2));
|
|
27317
27421
|
}
|
|
27318
27422
|
} else if (/\n/.test(text)) {
|
|
27319
27423
|
// Keep (up to one) blank line between tags/expressions/text.
|
|
@@ -27422,7 +27526,7 @@ function printJSXElement(path$$1, options, print) {
|
|
|
27422
27526
|
} // Trim trailing lines (or empty strings)
|
|
27423
27527
|
|
|
27424
27528
|
|
|
27425
|
-
while (children.length && (isLineNext$1(getLast$
|
|
27529
|
+
while (children.length && (isLineNext$1(getLast$3(children)) || isEmpty$1(getLast$3(children)))) {
|
|
27426
27530
|
children.pop();
|
|
27427
27531
|
} // Trim leading lines (or empty strings)
|
|
27428
27532
|
|
|
@@ -27969,7 +28073,7 @@ function needsHardlineAfterDanglingComment(node) {
|
|
|
27969
28073
|
return false;
|
|
27970
28074
|
}
|
|
27971
28075
|
|
|
27972
|
-
var lastDanglingComment = getLast$
|
|
28076
|
+
var lastDanglingComment = getLast$3(node.comments.filter(function (comment) {
|
|
27973
28077
|
return !comment.leading && !comment.trailing;
|
|
27974
28078
|
}));
|
|
27975
28079
|
return lastDanglingComment && !comments$3.isBlockComment(lastDanglingComment);
|
|
@@ -27979,6 +28083,10 @@ function isLiteral(node) {
|
|
|
27979
28083
|
return node.type === "BooleanLiteral" || node.type === "DirectiveLiteral" || node.type === "Literal" || node.type === "NullLiteral" || node.type === "NumericLiteral" || node.type === "RegExpLiteral" || node.type === "StringLiteral" || node.type === "TemplateLiteral" || node.type === "TSTypeLiteral" || node.type === "JSXText";
|
|
27980
28084
|
}
|
|
27981
28085
|
|
|
28086
|
+
function isStringPropSafeToCoerceToIdentifier(node, options) {
|
|
28087
|
+
return isStringLiteral(node.key) && isIdentifierName(node.key.value) && !node.computed && options.parser !== "json" && !(options.parser === "typescript" && node.type === "ClassProperty");
|
|
28088
|
+
}
|
|
28089
|
+
|
|
27982
28090
|
function isNumericLiteral(node) {
|
|
27983
28091
|
return node.type === "NumericLiteral" || node.type === "Literal" && typeof node.value === "number";
|
|
27984
28092
|
}
|
|
@@ -28069,7 +28177,7 @@ function willPrintOwnComments(path$$1) {
|
|
|
28069
28177
|
}
|
|
28070
28178
|
|
|
28071
28179
|
function canAttachComment(node) {
|
|
28072
|
-
return node.type && node.type !== "CommentBlock" && node.type !== "CommentLine" && node.type !== "Line" && node.type !== "Block" && node.type !== "EmptyStatement" && node.type !== "TemplateElement" && node.type !== "Import"
|
|
28180
|
+
return node.type && node.type !== "CommentBlock" && node.type !== "CommentLine" && node.type !== "Line" && node.type !== "Block" && node.type !== "EmptyStatement" && node.type !== "TemplateElement" && node.type !== "Import";
|
|
28073
28181
|
}
|
|
28074
28182
|
|
|
28075
28183
|
function printComment$1(commentPath, options) {
|
|
@@ -28321,6 +28429,23 @@ var options$3 = {
|
|
|
28321
28429
|
default: false,
|
|
28322
28430
|
description: "Use single quotes in JSX."
|
|
28323
28431
|
},
|
|
28432
|
+
quoteProps: {
|
|
28433
|
+
since: "1.17.0",
|
|
28434
|
+
category: CATEGORY_JAVASCRIPT,
|
|
28435
|
+
type: "choice",
|
|
28436
|
+
default: "as-needed",
|
|
28437
|
+
description: "Change when properties in objects are quoted.",
|
|
28438
|
+
choices: [{
|
|
28439
|
+
value: "as-needed",
|
|
28440
|
+
description: "Only add quotes around object properties where required."
|
|
28441
|
+
}, {
|
|
28442
|
+
value: "consistent",
|
|
28443
|
+
description: "If at least one property in an object requires quotes, quote all properties."
|
|
28444
|
+
}, {
|
|
28445
|
+
value: "preserve",
|
|
28446
|
+
description: "Respect the input use of quotes in object properties."
|
|
28447
|
+
}]
|
|
28448
|
+
},
|
|
28324
28449
|
trailingComma: {
|
|
28325
28450
|
since: "0.0.0",
|
|
28326
28451
|
category: CATEGORY_JAVASCRIPT,
|
|
@@ -30474,7 +30599,7 @@ function genericPrint$3(path$$1, options, print) {
|
|
|
30474
30599
|
|
|
30475
30600
|
case "FragmentDefinition":
|
|
30476
30601
|
{
|
|
30477
|
-
return concat$11(["fragment ", path$$1.call(print, "name"), " on ", path$$1.call(print, "typeCondition"), printDirectives(path$$1, print, n), " ", path$$1.call(print, "selectionSet")]);
|
|
30602
|
+
return concat$11(["fragment ", path$$1.call(print, "name"), n.variableDefinitions && n.variableDefinitions.length ? group$12(concat$11(["(", indent$7(concat$11([softline$5, join$8(concat$11([ifBreak$4("", ", "), softline$5]), path$$1.map(print, "variableDefinitions"))])), softline$5, ")"])) : "", " on ", path$$1.call(print, "typeCondition"), printDirectives(path$$1, print, n), " ", path$$1.call(print, "selectionSet")]);
|
|
30478
30603
|
}
|
|
30479
30604
|
|
|
30480
30605
|
case "SelectionSet":
|
|
@@ -30557,7 +30682,7 @@ function genericPrint$3(path$$1, options, print) {
|
|
|
30557
30682
|
|
|
30558
30683
|
case "VariableDefinition":
|
|
30559
30684
|
{
|
|
30560
|
-
return concat$11([path$$1.call(print, "variable"), ": ", path$$1.call(print, "type"), n.defaultValue ? concat$11([" = ", path$$1.call(print, "defaultValue")]) : ""]);
|
|
30685
|
+
return concat$11([path$$1.call(print, "variable"), ": ", path$$1.call(print, "type"), n.defaultValue ? concat$11([" = ", path$$1.call(print, "defaultValue")]) : "", printDirectives(path$$1, print, n)]);
|
|
30561
30686
|
}
|
|
30562
30687
|
|
|
30563
30688
|
case "TypeExtensionDefinition":
|
|
@@ -30790,7 +30915,7 @@ var json$6 = {"cjkPattern":"[\\u02ea-\\u02eb\\u1100-\\u11ff\\u2e80-\\u2e99\\u2e9
|
|
|
30790
30915
|
var cjkPattern = json$6.cjkPattern;
|
|
30791
30916
|
var kPattern = json$6.kPattern;
|
|
30792
30917
|
var punctuationPattern$1 = json$6.punctuationPattern;
|
|
30793
|
-
var getLast$
|
|
30918
|
+
var getLast$4 = util$1.getLast;
|
|
30794
30919
|
var INLINE_NODE_TYPES$1 = ["liquidNode", "inlineCode", "emphasis", "strong", "delete", "link", "linkReference", "image", "imageReference", "footnote", "footnoteReference", "sentence", "whitespace", "word", "break", "inlineMath"];
|
|
30795
30920
|
var INLINE_NODE_WRAPPER_TYPES$1 = INLINE_NODE_TYPES$1.concat(["tableCell", "paragraph", "heading"]);
|
|
30796
30921
|
var kRegex = new RegExp(kPattern);
|
|
@@ -30835,7 +30960,7 @@ function splitText$1(text, options) {
|
|
|
30835
30960
|
value: innerToken,
|
|
30836
30961
|
kind: KIND_NON_CJK,
|
|
30837
30962
|
hasLeadingPunctuation: punctuationRegex.test(innerToken[0]),
|
|
30838
|
-
hasTrailingPunctuation: punctuationRegex.test(getLast$
|
|
30963
|
+
hasTrailingPunctuation: punctuationRegex.test(getLast$4(innerToken))
|
|
30839
30964
|
});
|
|
30840
30965
|
}
|
|
30841
30966
|
|
|
@@ -30861,7 +30986,7 @@ function splitText$1(text, options) {
|
|
|
30861
30986
|
return nodes;
|
|
30862
30987
|
|
|
30863
30988
|
function appendNode(node) {
|
|
30864
|
-
var lastNode = getLast$
|
|
30989
|
+
var lastNode = getLast$4(nodes);
|
|
30865
30990
|
|
|
30866
30991
|
if (lastNode && lastNode.type === "word") {
|
|
30867
30992
|
if (lastNode.kind === KIND_NON_CJK && node.kind === KIND_CJ_LETTER && !lastNode.hasTrailingPunctuation || lastNode.kind === KIND_CJ_LETTER && node.kind === KIND_NON_CJK && !node.hasLeadingPunctuation) {
|
|
@@ -31323,6 +31448,7 @@ function markAlignedList(ast, options) {
|
|
|
31323
31448
|
var preprocess_1$2 = preprocess$2;
|
|
31324
31449
|
|
|
31325
31450
|
var _require$$0$builders$6 = doc.builders;
|
|
31451
|
+
var breakParent$3 = _require$$0$builders$6.breakParent;
|
|
31326
31452
|
var concat$12 = _require$$0$builders$6.concat;
|
|
31327
31453
|
var join$9 = _require$$0$builders$6.join;
|
|
31328
31454
|
var line$8 = _require$$0$builders$6.line;
|
|
@@ -31330,6 +31456,7 @@ var literalline$4 = _require$$0$builders$6.literalline;
|
|
|
31330
31456
|
var markAsRoot$2 = _require$$0$builders$6.markAsRoot;
|
|
31331
31457
|
var hardline$10 = _require$$0$builders$6.hardline;
|
|
31332
31458
|
var softline$6 = _require$$0$builders$6.softline;
|
|
31459
|
+
var ifBreak$5 = _require$$0$builders$6.ifBreak;
|
|
31333
31460
|
var fill$4 = _require$$0$builders$6.fill;
|
|
31334
31461
|
var align$2 = _require$$0$builders$6.align;
|
|
31335
31462
|
var indent$8 = _require$$0$builders$6.indent;
|
|
@@ -31682,6 +31809,7 @@ function printLine(path$$1, value, options) {
|
|
|
31682
31809
|
}
|
|
31683
31810
|
|
|
31684
31811
|
function printTable(path$$1, options, print) {
|
|
31812
|
+
var hardlineWithoutBreakParent = hardline$10.parts[0];
|
|
31685
31813
|
var node = path$$1.getValue();
|
|
31686
31814
|
var contents = []; // { [rowIndex: number]: { [columnIndex: number]: string } }
|
|
31687
31815
|
|
|
@@ -31691,7 +31819,8 @@ function printTable(path$$1, options, print) {
|
|
|
31691
31819
|
rowContents.push(printDocToString$3(cellPath.call(print), options).formatted);
|
|
31692
31820
|
}, "children");
|
|
31693
31821
|
contents.push(rowContents);
|
|
31694
|
-
}, "children");
|
|
31822
|
+
}, "children"); // Get the width of each column
|
|
31823
|
+
|
|
31695
31824
|
var columnMaxWidths = contents.reduce(function (currentWidths, rowContents) {
|
|
31696
31825
|
return currentWidths.map(function (width, columnIndex) {
|
|
31697
31826
|
return Math.max(width, util$1.getStringWidth(rowContents[columnIndex]));
|
|
@@ -31700,28 +31829,48 @@ function printTable(path$$1, options, print) {
|
|
|
31700
31829
|
return 3;
|
|
31701
31830
|
}) // minimum width = 3 (---, :--, :-:, --:)
|
|
31702
31831
|
);
|
|
31703
|
-
|
|
31704
|
-
|
|
31705
|
-
|
|
31832
|
+
var alignedTable = join$9(hardlineWithoutBreakParent, [printRow(contents[0]), printSeparator(), join$9(hardlineWithoutBreakParent, contents.slice(1).map(function (rowContents) {
|
|
31833
|
+
return printRow(rowContents);
|
|
31834
|
+
}))]);
|
|
31835
|
+
|
|
31836
|
+
if (options.proseWrap !== "never") {
|
|
31837
|
+
return concat$12([breakParent$3, alignedTable]);
|
|
31838
|
+
} // Only if the --prose-wrap never is set and it exceeds the print width.
|
|
31839
|
+
|
|
31840
|
+
|
|
31841
|
+
var compactTable = join$9(hardlineWithoutBreakParent, [printRow(contents[0],
|
|
31842
|
+
/* isCompact */
|
|
31843
|
+
true), printSeparator(
|
|
31844
|
+
/* isCompact */
|
|
31845
|
+
true), join$9(hardlineWithoutBreakParent, contents.slice(1).map(function (rowContents) {
|
|
31846
|
+
return printRow(rowContents,
|
|
31847
|
+
/* isCompact */
|
|
31848
|
+
true);
|
|
31849
|
+
}))]);
|
|
31850
|
+
return concat$12([breakParent$3, group$13(ifBreak$5(compactTable, alignedTable))]);
|
|
31851
|
+
|
|
31852
|
+
function printSeparator(isCompact) {
|
|
31706
31853
|
return concat$12(["| ", join$9(" | ", columnMaxWidths.map(function (width, index) {
|
|
31854
|
+
var spaces = isCompact ? 3 : width;
|
|
31855
|
+
|
|
31707
31856
|
switch (node.align[index]) {
|
|
31708
31857
|
case "left":
|
|
31709
|
-
return ":" + "-".repeat(
|
|
31858
|
+
return ":" + "-".repeat(spaces - 1);
|
|
31710
31859
|
|
|
31711
31860
|
case "right":
|
|
31712
|
-
return "-".repeat(
|
|
31861
|
+
return "-".repeat(spaces - 1) + ":";
|
|
31713
31862
|
|
|
31714
31863
|
case "center":
|
|
31715
|
-
return ":" + "-".repeat(
|
|
31864
|
+
return ":" + "-".repeat(spaces - 2) + ":";
|
|
31716
31865
|
|
|
31717
31866
|
default:
|
|
31718
|
-
return "-".repeat(
|
|
31867
|
+
return "-".repeat(spaces);
|
|
31719
31868
|
}
|
|
31720
31869
|
})), " |"]);
|
|
31721
31870
|
}
|
|
31722
31871
|
|
|
31723
|
-
function printRow(rowContents) {
|
|
31724
|
-
return concat$12(["| ", join$9(" | ", rowContents.map(function (rowContent, columnIndex) {
|
|
31872
|
+
function printRow(rowContents, isCompact) {
|
|
31873
|
+
return concat$12(["| ", join$9(" | ", isCompact ? rowContents : rowContents.map(function (rowContent, columnIndex) {
|
|
31725
31874
|
switch (node.align[columnIndex]) {
|
|
31726
31875
|
case "right":
|
|
31727
31876
|
return alignRight(rowContent, columnMaxWidths[columnIndex]);
|
|
@@ -31736,11 +31885,13 @@ function printTable(path$$1, options, print) {
|
|
|
31736
31885
|
}
|
|
31737
31886
|
|
|
31738
31887
|
function alignLeft(text, width) {
|
|
31739
|
-
|
|
31888
|
+
var spaces = width - util$1.getStringWidth(text);
|
|
31889
|
+
return concat$12([text, " ".repeat(spaces)]);
|
|
31740
31890
|
}
|
|
31741
31891
|
|
|
31742
31892
|
function alignRight(text, width) {
|
|
31743
|
-
|
|
31893
|
+
var spaces = width - util$1.getStringWidth(text);
|
|
31894
|
+
return concat$12([" ".repeat(spaces), text]);
|
|
31744
31895
|
}
|
|
31745
31896
|
|
|
31746
31897
|
function alignCenter(text, width) {
|
|
@@ -33765,7 +33916,7 @@ var parseSrcset = createCommonjsModule(function (module) {
|
|
|
33765
33916
|
|
|
33766
33917
|
var _require$$0$builders$9 = doc.builders;
|
|
33767
33918
|
var concat$16 = _require$$0$builders$9.concat;
|
|
33768
|
-
var ifBreak$
|
|
33919
|
+
var ifBreak$7 = _require$$0$builders$9.ifBreak;
|
|
33769
33920
|
var join$11 = _require$$0$builders$9.join;
|
|
33770
33921
|
var line$10 = _require$$0$builders$9.line;
|
|
33771
33922
|
|
|
@@ -33823,7 +33974,7 @@ function printImgSrcset$1(value) {
|
|
|
33823
33974
|
var urlPadding = maxUrlLength - url.length + 1;
|
|
33824
33975
|
var descriptorPadding = maxDescriptorLeftLength - descriptorLeftLengths[index];
|
|
33825
33976
|
var alignment = " ".repeat(urlPadding + descriptorPadding);
|
|
33826
|
-
parts.push(ifBreak$
|
|
33977
|
+
parts.push(ifBreak$7(alignment, " "), descriptor + unit);
|
|
33827
33978
|
}
|
|
33828
33979
|
|
|
33829
33980
|
return concat$16(parts);
|
|
@@ -33838,12 +33989,12 @@ var builders = doc.builders;
|
|
|
33838
33989
|
var _require$$0$utils = doc.utils;
|
|
33839
33990
|
var stripTrailingHardline$2 = _require$$0$utils.stripTrailingHardline;
|
|
33840
33991
|
var mapDoc$7 = _require$$0$utils.mapDoc;
|
|
33841
|
-
var breakParent$
|
|
33992
|
+
var breakParent$4 = builders.breakParent;
|
|
33842
33993
|
var dedentToRoot$2 = builders.dedentToRoot;
|
|
33843
33994
|
var fill$5 = builders.fill;
|
|
33844
33995
|
var group$14 = builders.group;
|
|
33845
33996
|
var hardline$12 = builders.hardline;
|
|
33846
|
-
var ifBreak$
|
|
33997
|
+
var ifBreak$6 = builders.ifBreak;
|
|
33847
33998
|
var indent$9 = builders.indent;
|
|
33848
33999
|
var join$10 = builders.join;
|
|
33849
34000
|
var line$9 = builders.line;
|
|
@@ -33890,7 +34041,7 @@ function embed$6(path$$1, print, textToDoc, options) {
|
|
|
33890
34041
|
|
|
33891
34042
|
if (parser) {
|
|
33892
34043
|
var value = parser === "markdown" ? dedentString(node.value.replace(/^[^\S\n]*?\n/, "")) : node.value;
|
|
33893
|
-
return builders.concat([concat$14([breakParent$
|
|
34044
|
+
return builders.concat([concat$14([breakParent$4, printOpeningTagPrefix(node, options), stripTrailingHardline$2(textToDoc(value, {
|
|
33894
34045
|
parser
|
|
33895
34046
|
})), printClosingTagSuffix(node, options)])]);
|
|
33896
34047
|
}
|
|
@@ -33920,6 +34071,15 @@ function embed$6(path$$1, print, textToDoc, options) {
|
|
|
33920
34071
|
|
|
33921
34072
|
if (/^PRETTIER_HTML_PLACEHOLDER_\d+_IN_JS$/.test(options.originalText.slice(node.valueSpan.start.offset, node.valueSpan.end.offset))) {
|
|
33922
34073
|
return concat$14([node.rawName, "=", node.value]);
|
|
34074
|
+
} // lwc: html`<my-element data-for={value}></my-elememt>`
|
|
34075
|
+
|
|
34076
|
+
|
|
34077
|
+
if (options.parser === "lwc") {
|
|
34078
|
+
var interpolationRegex = /^\{[\s\S]*\}$/;
|
|
34079
|
+
|
|
34080
|
+
if (interpolationRegex.test(options.originalText.slice(node.valueSpan.start.offset, node.valueSpan.end.offset))) {
|
|
34081
|
+
return concat$14([node.rawName, "=", node.value]);
|
|
34082
|
+
}
|
|
33923
34083
|
}
|
|
33924
34084
|
|
|
33925
34085
|
var embeddedAttributeValueDoc = printEmbeddedAttributeValue(node, function (code, opts) {
|
|
@@ -33981,13 +34141,13 @@ function genericPrint$5(path$$1, options, print) {
|
|
|
33981
34141
|
var attrGroupId = Symbol("element-attr-group-id");
|
|
33982
34142
|
return concat$14([group$14(concat$14([group$14(printOpeningTag(path$$1, options, print), {
|
|
33983
34143
|
id: attrGroupId
|
|
33984
|
-
}), node.children.length === 0 ? node.hasDanglingSpaces && node.isDanglingSpaceSensitive ? line$9 : "" : concat$14([forceBreakContent(node) ? breakParent$
|
|
33985
|
-
return shouldHugContent ? ifBreak$
|
|
34144
|
+
}), node.children.length === 0 ? node.hasDanglingSpaces && node.isDanglingSpaceSensitive ? line$9 : "" : concat$14([forceBreakContent(node) ? breakParent$4 : "", function (childrenDoc) {
|
|
34145
|
+
return shouldHugContent ? ifBreak$6(indent$9(childrenDoc), childrenDoc, {
|
|
33986
34146
|
groupId: attrGroupId
|
|
33987
34147
|
}) : isScriptLikeTag(node) && node.parent.type === "root" && options.parser === "vue" ? childrenDoc : indent$9(childrenDoc);
|
|
33988
|
-
}(concat$14([shouldHugContent ? ifBreak$
|
|
34148
|
+
}(concat$14([shouldHugContent ? ifBreak$6(softline$7, "", {
|
|
33989
34149
|
groupId: attrGroupId
|
|
33990
|
-
}) : node.firstChild.hasLeadingSpaces && node.firstChild.isLeadingSpaceSensitive ? line$9 : node.firstChild.type === "text" && node.isWhitespaceSensitive && node.isIndentationSensitive ? dedentToRoot$2(softline$7) : softline$7, printChildren$1(path$$1, options, print)])), (node.next ? needsToBorrowPrevClosingTagEndMarker(node.next) : needsToBorrowLastChildClosingTagEndMarker(node.parent)) ? node.lastChild.hasTrailingSpaces && node.lastChild.isTrailingSpaceSensitive ? " " : "" : shouldHugContent ? ifBreak$
|
|
34150
|
+
}) : node.firstChild.hasLeadingSpaces && node.firstChild.isLeadingSpaceSensitive ? line$9 : node.firstChild.type === "text" && node.isWhitespaceSensitive && node.isIndentationSensitive ? dedentToRoot$2(softline$7) : softline$7, printChildren$1(path$$1, options, print)])), (node.next ? needsToBorrowPrevClosingTagEndMarker(node.next) : needsToBorrowLastChildClosingTagEndMarker(node.parent)) ? node.lastChild.hasTrailingSpaces && node.lastChild.isTrailingSpaceSensitive ? " " : "" : shouldHugContent ? ifBreak$6(softline$7, "", {
|
|
33991
34151
|
groupId: attrGroupId
|
|
33992
34152
|
}) : node.lastChild.hasTrailingSpaces && node.lastChild.isTrailingSpaceSensitive ? line$9 : (node.lastChild.type === "comment" || node.lastChild.type === "text" && node.isWhitespaceSensitive && node.isIndentationSensitive) && new RegExp(`\\n\\s{${options.tabWidth * countParents(path$$1, function (n) {
|
|
33993
34153
|
return n.parent && n.parent.type !== "root";
|
|
@@ -34058,7 +34218,7 @@ function printChildren$1(path$$1, options, print) {
|
|
|
34058
34218
|
var node = path$$1.getValue();
|
|
34059
34219
|
|
|
34060
34220
|
if (forceBreakChildren(node)) {
|
|
34061
|
-
return concat$14([breakParent$
|
|
34221
|
+
return concat$14([breakParent$4, concat$14(path$$1.map(function (childPath) {
|
|
34062
34222
|
var childNode = childPath.getValue();
|
|
34063
34223
|
var prevBetweenLine = !childNode.prev ? "" : printBetweenLine(childNode.prev, childNode);
|
|
34064
34224
|
return concat$14([!prevBetweenLine ? "" : concat$14([prevBetweenLine, forceNextEmptyLine(childNode.prev) ? hardline$12 : ""]), printChild(childPath)]);
|
|
@@ -34103,7 +34263,7 @@ function printChildren$1(path$$1, options, print) {
|
|
|
34103
34263
|
if (isTextLikeNode(childNode.prev)) {
|
|
34104
34264
|
leadingParts.push(prevBetweenLine);
|
|
34105
34265
|
} else {
|
|
34106
|
-
leadingParts.push(ifBreak$
|
|
34266
|
+
leadingParts.push(ifBreak$6("", softline$7, {
|
|
34107
34267
|
groupId: groupIds[childIndex - 1]
|
|
34108
34268
|
}));
|
|
34109
34269
|
}
|
|
@@ -34409,8 +34569,8 @@ function printClosingTagEndMarker(node, options) {
|
|
|
34409
34569
|
|
|
34410
34570
|
function getTextValueParts(node) {
|
|
34411
34571
|
var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : node.value;
|
|
34412
|
-
return node.parent.isWhitespaceSensitive ? node.parent.isIndentationSensitive ? replaceEndOfLineWith$2(value, literalline$6) : replaceEndOfLineWith$2(dedentString(value.replace(/^\s*?\n|\n\s*?$/g, "")), hardline$12) : //
|
|
34413
|
-
join$10(line$9, value.split(/[
|
|
34572
|
+
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
|
|
34573
|
+
join$10(line$9, value.split(/[\t\n\f\r ]+/)).parts;
|
|
34414
34574
|
}
|
|
34415
34575
|
|
|
34416
34576
|
function printEmbeddedAttributeValue(node, originalTextToDoc, options) {
|
|
@@ -34700,6 +34860,15 @@ var languages$5 = [createLanguage(require$$0$31, {
|
|
|
34700
34860
|
extensions: [".mjml" // MJML is considered XML in Linguist but it should be formatted as HTML
|
|
34701
34861
|
]
|
|
34702
34862
|
}
|
|
34863
|
+
}), createLanguage(require$$0$31, {
|
|
34864
|
+
override: {
|
|
34865
|
+
name: "Lightning Web Components",
|
|
34866
|
+
since: "1.17.0",
|
|
34867
|
+
parsers: ["lwc"],
|
|
34868
|
+
vscodeLanguageIds: ["html"],
|
|
34869
|
+
extensions: [],
|
|
34870
|
+
filenames: []
|
|
34871
|
+
}
|
|
34703
34872
|
}), createLanguage(require$$1$10, {
|
|
34704
34873
|
override: {
|
|
34705
34874
|
since: "1.10.0",
|
|
@@ -34734,7 +34903,7 @@ var pragma$11 = {
|
|
|
34734
34903
|
insertPragma: insertPragma$9
|
|
34735
34904
|
};
|
|
34736
34905
|
|
|
34737
|
-
var getLast$
|
|
34906
|
+
var getLast$6 = util$1.getLast;
|
|
34738
34907
|
|
|
34739
34908
|
function getAncestorCount$1(path$$1, filter) {
|
|
34740
34909
|
var counter = 0;
|
|
@@ -34823,7 +34992,7 @@ function isLastDescendantNode$1(path$$1) {
|
|
|
34823
34992
|
}
|
|
34824
34993
|
|
|
34825
34994
|
function getLastDescendantNode$2(node) {
|
|
34826
|
-
return "children" in node && node.children.length !== 0 ? getLastDescendantNode$2(getLast$
|
|
34995
|
+
return "children" in node && node.children.length !== 0 ? getLastDescendantNode$2(getLast$6(node.children)) : node;
|
|
34827
34996
|
}
|
|
34828
34997
|
|
|
34829
34998
|
function isPrettierIgnore$2(comment) {
|
|
@@ -34835,10 +35004,10 @@ function hasPrettierIgnore$5(path$$1) {
|
|
|
34835
35004
|
|
|
34836
35005
|
if (node.type === "documentBody") {
|
|
34837
35006
|
var document = path$$1.getParentNode();
|
|
34838
|
-
return hasEndComments$1(document.head) && isPrettierIgnore$2(getLast$
|
|
35007
|
+
return hasEndComments$1(document.head) && isPrettierIgnore$2(getLast$6(document.head.endComments));
|
|
34839
35008
|
}
|
|
34840
35009
|
|
|
34841
|
-
return hasLeadingComments$1(node) && isPrettierIgnore$2(getLast$
|
|
35010
|
+
return hasLeadingComments$1(node) && isPrettierIgnore$2(getLast$6(node.leadingComments));
|
|
34842
35011
|
}
|
|
34843
35012
|
|
|
34844
35013
|
function isEmptyNode$1(node) {
|
|
@@ -34938,7 +35107,7 @@ function getFlowScalarLineContents$1(nodeType, content, options) {
|
|
|
34938
35107
|
return lineContent.length === 0 ? [] : splitWithSingleSpace(lineContent);
|
|
34939
35108
|
}).reduce(function (reduced, lineContentWords, index) {
|
|
34940
35109
|
return index !== 0 && rawLineContents[index - 1].length !== 0 && lineContentWords.length !== 0 && !( // trailing backslash in quoteDouble should be preserved
|
|
34941
|
-
nodeType === "quoteDouble" && getLast$
|
|
35110
|
+
nodeType === "quoteDouble" && getLast$6(getLast$6(reduced)).endsWith("\\")) ? reduced.concat([reduced.pop().concat(lineContentWords)]) : reduced.concat([lineContentWords]);
|
|
34942
35111
|
}, []).map(function (lineContentWords) {
|
|
34943
35112
|
return options.proseWrap === "never" ? [lineContentWords.join(" ")] : lineContentWords;
|
|
34944
35113
|
});
|
|
@@ -34966,11 +35135,11 @@ function getBlockValueLineContents$1(node, _ref) {
|
|
|
34966
35135
|
return removeUnnecessaryTrailingNewlines(rawLineContents.map(function (lineContent) {
|
|
34967
35136
|
return lineContent.length === 0 ? [] : splitWithSingleSpace(lineContent);
|
|
34968
35137
|
}).reduce(function (reduced, lineContentWords, index) {
|
|
34969
|
-
return index !== 0 && rawLineContents[index - 1].length !== 0 && lineContentWords.length !== 0 && !/^\s/.test(lineContentWords[0]) && !/^\s|\s$/.test(getLast$
|
|
35138
|
+
return index !== 0 && rawLineContents[index - 1].length !== 0 && lineContentWords.length !== 0 && !/^\s/.test(lineContentWords[0]) && !/^\s|\s$/.test(getLast$6(reduced)) ? reduced.concat([reduced.pop().concat(lineContentWords)]) : reduced.concat([lineContentWords]);
|
|
34970
35139
|
}, []).map(function (lineContentWords) {
|
|
34971
35140
|
return lineContentWords.reduce(function (reduced, word) {
|
|
34972
35141
|
return (// disallow trailing spaces
|
|
34973
|
-
reduced.length !== 0 && /\s$/.test(getLast$
|
|
35142
|
+
reduced.length !== 0 && /\s$/.test(getLast$6(reduced)) ? reduced.concat(reduced.pop() + " " + word) : reduced.concat(word)
|
|
34974
35143
|
);
|
|
34975
35144
|
}, []);
|
|
34976
35145
|
}).map(function (lineContentWords) {
|
|
@@ -34979,7 +35148,7 @@ function getBlockValueLineContents$1(node, _ref) {
|
|
|
34979
35148
|
|
|
34980
35149
|
function removeUnnecessaryTrailingNewlines(lineContents) {
|
|
34981
35150
|
if (node.chomping === "keep") {
|
|
34982
|
-
return getLast$
|
|
35151
|
+
return getLast$6(lineContents).length === 0 ? lineContents.slice(0, -1) : lineContents;
|
|
34983
35152
|
}
|
|
34984
35153
|
|
|
34985
35154
|
var trailingNewlineCount = 0;
|
|
@@ -34998,7 +35167,7 @@ function getBlockValueLineContents$1(node, _ref) {
|
|
|
34998
35167
|
}
|
|
34999
35168
|
|
|
35000
35169
|
var utils$12 = {
|
|
35001
|
-
getLast: getLast$
|
|
35170
|
+
getLast: getLast$6,
|
|
35002
35171
|
getAncestorCount: getAncestorCount$1,
|
|
35003
35172
|
isNode: isNode$2,
|
|
35004
35173
|
isEmptyNode: isEmptyNode$1,
|
|
@@ -35022,7 +35191,7 @@ var isPragma = pragma$11.isPragma;
|
|
|
35022
35191
|
var getAncestorCount = utils$12.getAncestorCount;
|
|
35023
35192
|
var getBlockValueLineContents = utils$12.getBlockValueLineContents;
|
|
35024
35193
|
var getFlowScalarLineContents = utils$12.getFlowScalarLineContents;
|
|
35025
|
-
var getLast$
|
|
35194
|
+
var getLast$5 = utils$12.getLast;
|
|
35026
35195
|
var getLastDescendantNode$1 = utils$12.getLastDescendantNode;
|
|
35027
35196
|
var hasLeadingComments = utils$12.hasLeadingComments;
|
|
35028
35197
|
var hasMiddleComments = utils$12.hasMiddleComments;
|
|
@@ -35038,14 +35207,14 @@ var defineShortcut = utils$12.defineShortcut;
|
|
|
35038
35207
|
var mapNode = utils$12.mapNode;
|
|
35039
35208
|
var docBuilders$3 = doc.builders;
|
|
35040
35209
|
var conditionalGroup$2 = docBuilders$3.conditionalGroup;
|
|
35041
|
-
var breakParent$
|
|
35210
|
+
var breakParent$5 = docBuilders$3.breakParent;
|
|
35042
35211
|
var concat$17 = docBuilders$3.concat;
|
|
35043
35212
|
var dedent$4 = docBuilders$3.dedent;
|
|
35044
35213
|
var dedentToRoot$3 = docBuilders$3.dedentToRoot;
|
|
35045
35214
|
var fill$6 = docBuilders$3.fill;
|
|
35046
35215
|
var group$16 = docBuilders$3.group;
|
|
35047
35216
|
var hardline$13 = docBuilders$3.hardline;
|
|
35048
|
-
var ifBreak$
|
|
35217
|
+
var ifBreak$8 = docBuilders$3.ifBreak;
|
|
35049
35218
|
var join$12 = docBuilders$3.join;
|
|
35050
35219
|
var line$11 = docBuilders$3.line;
|
|
35051
35220
|
var lineSuffix$2 = docBuilders$3.lineSuffix;
|
|
@@ -35099,7 +35268,7 @@ function genericPrint$6(path$$1, options, print) {
|
|
|
35099
35268
|
var tag = !node.tag ? "" : path$$1.call(print, "tag");
|
|
35100
35269
|
var anchor = !node.anchor ? "" : path$$1.call(print, "anchor");
|
|
35101
35270
|
var nextEmptyLine = isNode$1(node, ["mapping", "sequence", "comment", "directive", "mappingItem", "sequenceItem"]) && !isLastDescendantNode(path$$1) ? printNextEmptyLine(path$$1, options.originalText) : "";
|
|
35102
|
-
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$
|
|
35271
|
+
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$5, 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"))])) : ""]);
|
|
35103
35272
|
}
|
|
35104
35273
|
|
|
35105
35274
|
function _print(node, parentNode, path$$1, options, print) {
|
|
@@ -35235,9 +35404,9 @@ function _print(node, parentNode, path$$1, options, print) {
|
|
|
35235
35404
|
return forceExplicitKey ? concat$17(["? ", align$3(2, key), hardline$13, join$12("", path$$1.map(print, "value", "leadingComments").map(function (comment) {
|
|
35236
35405
|
return concat$17([comment, hardline$13]);
|
|
35237
35406
|
})), ": ", align$3(2, value)]) : // force singleline
|
|
35238
|
-
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$
|
|
35407
|
+
isSingleLineNode(node.key.content) && !hasLeadingComments(node.key.content) && !hasMiddleComments(node.key.content) && !hasTrailingComment$1(node.key.content) && !hasEndComments(node.key) && !hasLeadingComments(node.value.content) && !hasMiddleComments(node.value.content) && !hasEndComments(node.value) && isAbsolutelyPrintedAsSingleLineNode(node.value.content, options) ? concat$17([key, needsSpaceInFrontOfMappingValue(node) ? " " : "", ": ", value]) : conditionalGroup$2([concat$17([group$16(concat$17([ifBreak$8("? "), group$16(align$3(2, key), {
|
|
35239
35408
|
id: groupId
|
|
35240
|
-
})])), ifBreak$
|
|
35409
|
+
})])), ifBreak$8(concat$17([hardline$13, ": ", align$3(2, value)]), indent(concat$17([needsSpaceInFrontOfMappingValue(node) ? " " : "", ":", hasLeadingComments(node.value.content) || hasEndComments(node.value) && node.value.content && !isNode$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])), {
|
|
35241
35410
|
groupId
|
|
35242
35411
|
})])]);
|
|
35243
35412
|
}
|
|
@@ -35251,11 +35420,11 @@ function _print(node, parentNode, path$$1, options, print) {
|
|
|
35251
35420
|
|
|
35252
35421
|
var isLastItemEmptyMappingItem = node.children.length !== 0 && function (lastItem) {
|
|
35253
35422
|
return lastItem.type === "flowMappingItem" && isEmptyNode(lastItem.key) && isEmptyNode(lastItem.value);
|
|
35254
|
-
}(getLast$
|
|
35423
|
+
}(getLast$5(node.children));
|
|
35255
35424
|
|
|
35256
35425
|
return concat$17([openMarker, indent(concat$17([bracketSpacing, concat$17(path$$1.map(function (childPath, index) {
|
|
35257
35426
|
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) : ""])]);
|
|
35258
|
-
}, "children")), ifBreak$
|
|
35427
|
+
}, "children")), ifBreak$8(",", "")])), isLastItemEmptyMappingItem ? "" : bracketSpacing, closeMarker]);
|
|
35259
35428
|
}
|
|
35260
35429
|
|
|
35261
35430
|
case "flowSequenceItem":
|
|
@@ -35673,6 +35842,11 @@ languageMarkdown, {
|
|
|
35673
35842
|
// Angular
|
|
35674
35843
|
get angular() {
|
|
35675
35844
|
return require("./parser-html").parsers.angular;
|
|
35845
|
+
},
|
|
35846
|
+
|
|
35847
|
+
// Lightning Web Components
|
|
35848
|
+
get lwc() {
|
|
35849
|
+
return require("./parser-html").parsers.lwc;
|
|
35676
35850
|
}
|
|
35677
35851
|
|
|
35678
35852
|
}
|
|
@@ -35746,12 +35920,14 @@ function loadPlugins(plugins, pluginSearchDirs) {
|
|
|
35746
35920
|
});
|
|
35747
35921
|
var externalAutoLoadPluginInfos = pluginSearchDirs.map(function (pluginSearchDir) {
|
|
35748
35922
|
var resolvedPluginSearchDir = path.resolve(process.cwd(), pluginSearchDir);
|
|
35923
|
+
var nodeModulesDir = path.resolve(resolvedPluginSearchDir, "node_modules"); // In some fringe cases (ex: files "mounted" as virtual directories), the
|
|
35924
|
+
// isDirectory(resolvedPluginSearchDir) check might be false even though
|
|
35925
|
+
// the node_modules actually exists.
|
|
35749
35926
|
|
|
35750
|
-
if (!isDirectory(resolvedPluginSearchDir)) {
|
|
35927
|
+
if (!isDirectory(nodeModulesDir) && !isDirectory(resolvedPluginSearchDir)) {
|
|
35751
35928
|
throw new Error(`${pluginSearchDir} does not exist or is not a directory`);
|
|
35752
35929
|
}
|
|
35753
35930
|
|
|
35754
|
-
var nodeModulesDir = path.resolve(resolvedPluginSearchDir, "node_modules");
|
|
35755
35931
|
return findPluginsInNodeModules(nodeModulesDir).map(function (pluginName) {
|
|
35756
35932
|
return {
|
|
35757
35933
|
name: pluginName,
|
|
@@ -35772,7 +35948,7 @@ function loadPlugins(plugins, pluginSearchDirs) {
|
|
|
35772
35948
|
}
|
|
35773
35949
|
|
|
35774
35950
|
function findPluginsInNodeModules(nodeModulesDir) {
|
|
35775
|
-
var pluginPackageJsonPaths = globby.sync(["prettier-plugin-*/package.json", "@prettier/plugin-*/package.json"], {
|
|
35951
|
+
var pluginPackageJsonPaths = globby.sync(["prettier-plugin-*/package.json", "@*/prettier-plugin-*/package.json", "@prettier/plugin-*/package.json"], {
|
|
35776
35952
|
cwd: nodeModulesDir
|
|
35777
35953
|
});
|
|
35778
35954
|
return pluginPackageJsonPaths.map(path.dirname);
|
|
@@ -42158,6 +42334,13 @@ var resolveConfig_1 = createCommonjsModule(function (module) {
|
|
|
42158
42334
|
cache: opts.cache,
|
|
42159
42335
|
transform: function transform(result) {
|
|
42160
42336
|
if (result && result.config) {
|
|
42337
|
+
if (typeof result.config === "string") {
|
|
42338
|
+
var modulePath = resolve$1.sync(result.config, {
|
|
42339
|
+
basedir: path.dirname(result.filepath)
|
|
42340
|
+
});
|
|
42341
|
+
result.config = require(modulePath);
|
|
42342
|
+
}
|
|
42343
|
+
|
|
42161
42344
|
if (typeof result.config !== "object") {
|
|
42162
42345
|
throw new Error(`Config is only allowed to be an object, ` + `but received ${typeof result.config} in "${result.filepath}"`);
|
|
42163
42346
|
}
|
|
@@ -43470,6 +43653,14 @@ var constant = {
|
|
|
43470
43653
|
usageSummary
|
|
43471
43654
|
};
|
|
43472
43655
|
|
|
43656
|
+
// which causes unwanted lines in the output. An additional check for isCI() helps.
|
|
43657
|
+
// See https://github.com/prettier/prettier/issues/5801
|
|
43658
|
+
|
|
43659
|
+
|
|
43660
|
+
var isTty = function isTTY() {
|
|
43661
|
+
return process.stdout.isTTY && !thirdParty$1.isCI();
|
|
43662
|
+
};
|
|
43663
|
+
|
|
43473
43664
|
var OPTION_USAGE_THRESHOLD = 25;
|
|
43474
43665
|
var CHOICE_USAGE_MARGIN = 3;
|
|
43475
43666
|
var CHOICE_USAGE_INDENTATION = 2;
|
|
@@ -43501,7 +43692,7 @@ function diff(a, b) {
|
|
|
43501
43692
|
|
|
43502
43693
|
function handleError(context, filename, error) {
|
|
43503
43694
|
if (error instanceof errors.UndefinedParserError) {
|
|
43504
|
-
if (context.argv["write"] &&
|
|
43695
|
+
if (context.argv["write"] && isTty()) {
|
|
43505
43696
|
readline.clearLine(process.stdout, 0);
|
|
43506
43697
|
readline.cursorTo(process.stdout, 0, null);
|
|
43507
43698
|
}
|
|
@@ -43791,7 +43982,7 @@ function formatStdin(context) {
|
|
|
43791
43982
|
|
|
43792
43983
|
writeOutput(context, format$1(context, input, options$$2), options$$2);
|
|
43793
43984
|
} catch (error) {
|
|
43794
|
-
handleError(context, "stdin", error);
|
|
43985
|
+
handleError(context, relativeFilepath || "stdin", error);
|
|
43795
43986
|
}
|
|
43796
43987
|
});
|
|
43797
43988
|
}
|
|
@@ -43858,7 +44049,7 @@ function formatFiles(context) {
|
|
|
43858
44049
|
return;
|
|
43859
44050
|
}
|
|
43860
44051
|
|
|
43861
|
-
if (
|
|
44052
|
+
if (isTty()) {
|
|
43862
44053
|
// Don't use `console.log` here since we need to replace this line.
|
|
43863
44054
|
context.logger.log(filename, {
|
|
43864
44055
|
newline: false
|
|
@@ -43901,7 +44092,7 @@ function formatFiles(context) {
|
|
|
43901
44092
|
|
|
43902
44093
|
var isDifferent = output !== input;
|
|
43903
44094
|
|
|
43904
|
-
if (
|
|
44095
|
+
if (isTty()) {
|
|
43905
44096
|
// Remove previously printed filename to log it with duration.
|
|
43906
44097
|
readline.clearLine(process.stdout, 0);
|
|
43907
44098
|
readline.cursorTo(process.stdout, 0, null);
|