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/index.js
CHANGED
|
@@ -12,7 +12,7 @@ var thirdParty = require('./third-party');
|
|
|
12
12
|
var thirdParty__default = thirdParty['default'];
|
|
13
13
|
|
|
14
14
|
var name = "prettier";
|
|
15
|
-
var version$1 = "1.
|
|
15
|
+
var version$1 = "1.17.0";
|
|
16
16
|
var description = "Prettier is an opinionated code formatter";
|
|
17
17
|
var bin = {
|
|
18
18
|
"prettier": "./bin/prettier.js"
|
|
@@ -26,11 +26,12 @@ var engines = {
|
|
|
26
26
|
"node": ">=6"
|
|
27
27
|
};
|
|
28
28
|
var dependencies = {
|
|
29
|
-
"@angular/compiler": "
|
|
30
|
-
"@babel/code-frame": "7.0.0
|
|
29
|
+
"@angular/compiler": "7.2.9",
|
|
30
|
+
"@babel/code-frame": "7.0.0",
|
|
31
31
|
"@babel/parser": "7.2.0",
|
|
32
32
|
"@glimmer/syntax": "0.30.3",
|
|
33
33
|
"@iarna/toml": "2.0.0",
|
|
34
|
+
"@typescript-eslint/typescript-estree": "1.6.0",
|
|
34
35
|
"angular-estree-parser": "1.1.5",
|
|
35
36
|
"angular-html-parser": "1.2.0",
|
|
36
37
|
"camelcase": "4.1.0",
|
|
@@ -49,11 +50,12 @@ var dependencies = {
|
|
|
49
50
|
"flow-parser": "0.84.0",
|
|
50
51
|
"get-stream": "3.0.0",
|
|
51
52
|
"globby": "6.1.0",
|
|
52
|
-
"graphql": "
|
|
53
|
+
"graphql": "14.2.0",
|
|
53
54
|
"html-element-attributes": "2.0.0",
|
|
54
55
|
"html-styles": "1.0.0",
|
|
55
56
|
"html-tag-names": "1.1.2",
|
|
56
|
-
"ignore": "
|
|
57
|
+
"ignore": "4.0.6",
|
|
58
|
+
"is-ci": "2.0.0",
|
|
57
59
|
"jest-docblock": "23.2.0",
|
|
58
60
|
"json-stable-stringify": "1.0.1",
|
|
59
61
|
"leven": "2.1.0",
|
|
@@ -77,8 +79,7 @@ var dependencies = {
|
|
|
77
79
|
"resolve": "1.5.0",
|
|
78
80
|
"semver": "5.4.1",
|
|
79
81
|
"string-width": "3.0.0",
|
|
80
|
-
"typescript": "3.
|
|
81
|
-
"typescript-estree": "18.0.0",
|
|
82
|
+
"typescript": "3.4.1",
|
|
82
83
|
"unicode-regex": "2.0.0",
|
|
83
84
|
"unified": "6.1.6",
|
|
84
85
|
"vnopts": "1.0.2",
|
|
@@ -107,7 +108,7 @@ var devDependencies = {
|
|
|
107
108
|
"jest-snapshot-serializer-raw": "1.1.0",
|
|
108
109
|
"jest-watch-typeahead": "0.1.0",
|
|
109
110
|
"mkdirp": "0.5.1",
|
|
110
|
-
"prettier": "1.16.
|
|
111
|
+
"prettier": "1.16.4",
|
|
111
112
|
"prettylint": "1.0.0",
|
|
112
113
|
"rimraf": "2.6.2",
|
|
113
114
|
"rollup": "0.47.6",
|
|
@@ -126,9 +127,6 @@ var devDependencies = {
|
|
|
126
127
|
"tempy": "0.2.1",
|
|
127
128
|
"webpack": "3.12.0"
|
|
128
129
|
};
|
|
129
|
-
var resolutions = {
|
|
130
|
-
"@babel/code-frame": "7.0.0-beta.46"
|
|
131
|
-
};
|
|
132
130
|
var scripts = {
|
|
133
131
|
"prepublishOnly": "echo \"Error: must publish from dist/\" && exit 1",
|
|
134
132
|
"prepare-release": "yarn && yarn build && yarn test:dist",
|
|
@@ -158,7 +156,6 @@ var _package = {
|
|
|
158
156
|
engines: engines,
|
|
159
157
|
dependencies: dependencies,
|
|
160
158
|
devDependencies: devDependencies,
|
|
161
|
-
resolutions: resolutions,
|
|
162
159
|
scripts: scripts
|
|
163
160
|
};
|
|
164
161
|
|
|
@@ -175,7 +172,6 @@ var _package$1 = Object.freeze({
|
|
|
175
172
|
engines: engines,
|
|
176
173
|
dependencies: dependencies,
|
|
177
174
|
devDependencies: devDependencies,
|
|
178
|
-
resolutions: resolutions,
|
|
179
175
|
scripts: scripts,
|
|
180
176
|
default: _package
|
|
181
177
|
});
|
|
@@ -3944,6 +3940,10 @@ var options$2 = {
|
|
|
3944
3940
|
value: "angular",
|
|
3945
3941
|
since: "1.15.0",
|
|
3946
3942
|
description: "Angular"
|
|
3943
|
+
}, {
|
|
3944
|
+
value: "lwc",
|
|
3945
|
+
since: "1.17.0",
|
|
3946
|
+
description: "Lightning Web Components"
|
|
3947
3947
|
}]
|
|
3948
3948
|
},
|
|
3949
3949
|
plugins: {
|
|
@@ -4137,6 +4137,7 @@ function getSupportInfo$2(version, opts) {
|
|
|
4137
4137
|
});
|
|
4138
4138
|
});
|
|
4139
4139
|
var usePostCssParser = semver.lt(version, "1.7.1");
|
|
4140
|
+
var useBabylonParser = semver.lt(version, "1.16.0");
|
|
4140
4141
|
var languages = plugins.reduce(function (all, plugin) {
|
|
4141
4142
|
return all.concat(plugin.languages || []);
|
|
4142
4143
|
}, []).filter(filterSince).map(function (language) {
|
|
@@ -4151,6 +4152,15 @@ function getSupportInfo$2(version, opts) {
|
|
|
4151
4152
|
return Object.assign({}, language, {
|
|
4152
4153
|
parsers: ["typescript"]
|
|
4153
4154
|
});
|
|
4155
|
+
} // "babylon" was renamed to "babel" in 1.16.0
|
|
4156
|
+
|
|
4157
|
+
|
|
4158
|
+
if (useBabylonParser && language.parsers.indexOf("babel") !== -1) {
|
|
4159
|
+
return Object.assign({}, language, {
|
|
4160
|
+
parsers: language.parsers.map(function (parser) {
|
|
4161
|
+
return parser === "babel" ? "babylon" : parser;
|
|
4162
|
+
})
|
|
4163
|
+
});
|
|
4154
4164
|
}
|
|
4155
4165
|
|
|
4156
4166
|
if (usePostCssParser && (language.name === "CSS" || language.group === "CSS")) {
|
|
@@ -8985,19 +8995,20 @@ var loc = {
|
|
|
8985
8995
|
};
|
|
8986
8996
|
|
|
8987
8997
|
var jsTokens = createCommonjsModule(function (module, exports) {
|
|
8988
|
-
// Copyright 2014, 2015, 2016, 2017 Simon Lydell
|
|
8998
|
+
// Copyright 2014, 2015, 2016, 2017, 2018 Simon Lydell
|
|
8989
8999
|
// License: MIT. (See LICENSE.)
|
|
8990
9000
|
Object.defineProperty(exports, "__esModule", {
|
|
8991
9001
|
value: true
|
|
8992
9002
|
}); // This regex comes from regex.coffee, and is inserted here by generate-index.js
|
|
8993
9003
|
// (run `npm run build`).
|
|
8994
9004
|
|
|
8995
|
-
exports.default = /((['"])(?:(?!\2|\\).|\\(?:\r\n|[\s\S]))*(\2)?|`(?:[^`\\$]|\\[\s\S]|\$(?!\{)|\$\{(?:[^{}]|\{[^}]*\}?)*\}?)*(`)?)|(\/\/.*)|(\/\*(?:[^*]|\*(?!\/))*(\*\/)?)|(\/(?!\*)(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\]\\]).|\\.)+\/(?:(?!\s*(?:\b|[\u0080-\uFFFF$\\'"~({]|[+\-!](?!=)|\.?\d))|[
|
|
9005
|
+
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;
|
|
8996
9006
|
|
|
8997
9007
|
exports.matchToToken = function (match) {
|
|
8998
9008
|
var token = {
|
|
8999
9009
|
type: "invalid",
|
|
9000
|
-
value: match[0]
|
|
9010
|
+
value: match[0],
|
|
9011
|
+
closed: undefined
|
|
9001
9012
|
};
|
|
9002
9013
|
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";
|
|
9003
9014
|
return token;
|
|
@@ -10128,7 +10139,7 @@ var lib$3 = createCommonjsModule(function (module, exports) {
|
|
|
10128
10139
|
exports.default = highlight;
|
|
10129
10140
|
|
|
10130
10141
|
function _jsTokens() {
|
|
10131
|
-
var data = _interopRequireWildcard(jsTokens);
|
|
10142
|
+
var data = _interopRequireWildcard$$1(jsTokens);
|
|
10132
10143
|
|
|
10133
10144
|
_jsTokens = function _jsTokens() {
|
|
10134
10145
|
return data;
|
|
@@ -10138,7 +10149,7 @@ var lib$3 = createCommonjsModule(function (module, exports) {
|
|
|
10138
10149
|
}
|
|
10139
10150
|
|
|
10140
10151
|
function _esutils() {
|
|
10141
|
-
var data = _interopRequireDefault(utils$2);
|
|
10152
|
+
var data = _interopRequireDefault$$1(utils$2);
|
|
10142
10153
|
|
|
10143
10154
|
_esutils = function _esutils() {
|
|
10144
10155
|
return data;
|
|
@@ -10148,7 +10159,7 @@ var lib$3 = createCommonjsModule(function (module, exports) {
|
|
|
10148
10159
|
}
|
|
10149
10160
|
|
|
10150
10161
|
function _chalk() {
|
|
10151
|
-
var data = _interopRequireDefault(chalk$5);
|
|
10162
|
+
var data = _interopRequireDefault$$1(chalk$5);
|
|
10152
10163
|
|
|
10153
10164
|
_chalk = function _chalk() {
|
|
10154
10165
|
return data;
|
|
@@ -10157,13 +10168,13 @@ var lib$3 = createCommonjsModule(function (module, exports) {
|
|
|
10157
10168
|
return data;
|
|
10158
10169
|
}
|
|
10159
10170
|
|
|
10160
|
-
function _interopRequireDefault(obj) {
|
|
10171
|
+
function _interopRequireDefault$$1(obj) {
|
|
10161
10172
|
return obj && obj.__esModule ? obj : {
|
|
10162
10173
|
default: obj
|
|
10163
10174
|
};
|
|
10164
10175
|
}
|
|
10165
10176
|
|
|
10166
|
-
function _interopRequireWildcard(obj) {
|
|
10177
|
+
function _interopRequireWildcard$$1(obj) {
|
|
10167
10178
|
if (obj && obj.__esModule) {
|
|
10168
10179
|
return obj;
|
|
10169
10180
|
} else {
|
|
@@ -10208,8 +10219,9 @@ var lib$3 = createCommonjsModule(function (module, exports) {
|
|
|
10208
10219
|
|
|
10209
10220
|
function getTokenType(match) {
|
|
10210
10221
|
var _match$slice = match.slice(-2),
|
|
10211
|
-
|
|
10212
|
-
|
|
10222
|
+
_match$slice2 = _slicedToArray(_match$slice, 2),
|
|
10223
|
+
offset = _match$slice2[0],
|
|
10224
|
+
text = _match$slice2[1];
|
|
10213
10225
|
|
|
10214
10226
|
var token = (0, _jsTokens().matchToToken)(match);
|
|
10215
10227
|
|
|
@@ -10274,10 +10286,8 @@ var lib$3 = createCommonjsModule(function (module, exports) {
|
|
|
10274
10286
|
return chalk;
|
|
10275
10287
|
}
|
|
10276
10288
|
|
|
10277
|
-
function highlight(code
|
|
10278
|
-
|
|
10279
|
-
options = {};
|
|
10280
|
-
}
|
|
10289
|
+
function highlight(code) {
|
|
10290
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
10281
10291
|
|
|
10282
10292
|
if (shouldHighlight(options)) {
|
|
10283
10293
|
var chalk = getChalk(options);
|
|
@@ -10347,7 +10357,7 @@ var lib$2 = createCommonjsModule(function (module, exports) {
|
|
|
10347
10357
|
var NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
|
|
10348
10358
|
|
|
10349
10359
|
function getMarkerLines(loc, source, opts) {
|
|
10350
|
-
var startLoc = Object.assign({
|
|
10360
|
+
var startLoc = Object.assign({
|
|
10351
10361
|
column: 0,
|
|
10352
10362
|
line: -1
|
|
10353
10363
|
}, loc.start);
|
|
@@ -10406,17 +10416,14 @@ var lib$2 = createCommonjsModule(function (module, exports) {
|
|
|
10406
10416
|
}
|
|
10407
10417
|
|
|
10408
10418
|
return {
|
|
10409
|
-
start
|
|
10410
|
-
end
|
|
10411
|
-
markerLines
|
|
10419
|
+
start,
|
|
10420
|
+
end,
|
|
10421
|
+
markerLines
|
|
10412
10422
|
};
|
|
10413
10423
|
}
|
|
10414
10424
|
|
|
10415
|
-
function codeFrameColumns(rawLines, loc
|
|
10416
|
-
|
|
10417
|
-
opts = {};
|
|
10418
|
-
}
|
|
10419
|
-
|
|
10425
|
+
function codeFrameColumns(rawLines, loc) {
|
|
10426
|
+
var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
10420
10427
|
var highlighted = (opts.highlightCode || opts.forceColor) && (0, _highlight().shouldHighlight)(opts);
|
|
10421
10428
|
var chalk = (0, _highlight().getChalk)(opts);
|
|
10422
10429
|
var defs = getDefs(chalk);
|
|
@@ -10437,8 +10444,8 @@ var lib$2 = createCommonjsModule(function (module, exports) {
|
|
|
10437
10444
|
var numberMaxWidth = String(end).length;
|
|
10438
10445
|
var frame = lines.slice(start, end).map(function (line, index) {
|
|
10439
10446
|
var number = start + 1 + index;
|
|
10440
|
-
var paddedNumber =
|
|
10441
|
-
var gutter =
|
|
10447
|
+
var paddedNumber = ` ${number}`.slice(-numberMaxWidth);
|
|
10448
|
+
var gutter = ` ${paddedNumber} | `;
|
|
10442
10449
|
var hasMarker = markerLines[number];
|
|
10443
10450
|
var lastMarkerLine = !markerLines[number + 1];
|
|
10444
10451
|
|
|
@@ -10457,12 +10464,12 @@ var lib$2 = createCommonjsModule(function (module, exports) {
|
|
|
10457
10464
|
|
|
10458
10465
|
return [maybeHighlight(defs.marker, ">"), maybeHighlight(defs.gutter, gutter), line, markerLine].join("");
|
|
10459
10466
|
} else {
|
|
10460
|
-
return
|
|
10467
|
+
return ` ${maybeHighlight(defs.gutter, gutter)}${line}`;
|
|
10461
10468
|
}
|
|
10462
10469
|
}).join("\n");
|
|
10463
10470
|
|
|
10464
10471
|
if (opts.message && !hasColumns) {
|
|
10465
|
-
frame = "
|
|
10472
|
+
frame = `${" ".repeat(numberMaxWidth + 1)}${opts.message}\n${frame}`;
|
|
10466
10473
|
}
|
|
10467
10474
|
|
|
10468
10475
|
if (highlighted) {
|
|
@@ -10472,10 +10479,8 @@ var lib$2 = createCommonjsModule(function (module, exports) {
|
|
|
10472
10479
|
}
|
|
10473
10480
|
}
|
|
10474
10481
|
|
|
10475
|
-
function _default(rawLines, lineNumber, colNumber
|
|
10476
|
-
|
|
10477
|
-
opts = {};
|
|
10478
|
-
}
|
|
10482
|
+
function _default(rawLines, lineNumber, colNumber) {
|
|
10483
|
+
var opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
10479
10484
|
|
|
10480
10485
|
if (!deprecationWarningShown) {
|
|
10481
10486
|
deprecationWarningShown = true;
|
|
@@ -11147,14 +11152,6 @@ function getPenultimate(arr) {
|
|
|
11147
11152
|
return null;
|
|
11148
11153
|
}
|
|
11149
11154
|
|
|
11150
|
-
function getLast$3(arr) {
|
|
11151
|
-
if (arr.length > 0) {
|
|
11152
|
-
return arr[arr.length - 1];
|
|
11153
|
-
}
|
|
11154
|
-
|
|
11155
|
-
return null;
|
|
11156
|
-
}
|
|
11157
|
-
|
|
11158
11155
|
function skip(chars) {
|
|
11159
11156
|
return function (text, index, opts) {
|
|
11160
11157
|
var backwards = opts && opts.backwards; // Allow `skip` functions to be threaded together without having
|
|
@@ -11569,7 +11566,7 @@ function printString(raw, options, isDirectiveLiteral) {
|
|
|
11569
11566
|
// sure that we consistently output the minimum amount of escaped quotes.
|
|
11570
11567
|
|
|
11571
11568
|
|
|
11572
|
-
return makeString(rawContent, enclosingQuote, !(options.parser === "css" || options.parser === "less" || options.parser === "scss" || options.parentParser === "html" || options.parentParser === "vue" || options.parentParser === "angular"));
|
|
11569
|
+
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"));
|
|
11573
11570
|
}
|
|
11574
11571
|
|
|
11575
11572
|
function makeString(rawContent, enclosingQuote, unescapeUnnecessaryEscapes) {
|
|
@@ -11757,7 +11754,7 @@ var util$1 = {
|
|
|
11757
11754
|
isExportDeclaration,
|
|
11758
11755
|
getParentExportDeclaration,
|
|
11759
11756
|
getPenultimate,
|
|
11760
|
-
getLast
|
|
11757
|
+
getLast,
|
|
11761
11758
|
getNextNonSpaceNonCommentCharacterIndexWithStartIndex,
|
|
11762
11759
|
getNextNonSpaceNonCommentCharacterIndex,
|
|
11763
11760
|
getNextNonSpaceNonCommentCharacter,
|
|
@@ -13208,7 +13205,7 @@ function printTrailingComment(commentPath, print, options) {
|
|
|
13208
13205
|
return concat([" ", contents]);
|
|
13209
13206
|
}
|
|
13210
13207
|
|
|
13211
|
-
return concat([lineSuffix(" "
|
|
13208
|
+
return concat([lineSuffix(concat([" ", contents])), !isBlock ? breakParent : ""]);
|
|
13212
13209
|
}
|
|
13213
13210
|
|
|
13214
13211
|
function printDanglingComments(path$$1, options, sameIndent, filter) {
|
|
@@ -14166,367 +14163,384 @@ var core = {
|
|
|
14166
14163
|
|
|
14167
14164
|
};
|
|
14168
14165
|
|
|
14169
|
-
var
|
|
14170
|
-
|
|
14171
|
-
|
|
14172
|
-
|
|
14173
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
14174
|
-
descriptor.configurable = true;
|
|
14175
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
14176
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
14177
|
-
}
|
|
14166
|
+
var ignore = createCommonjsModule(function (module) {
|
|
14167
|
+
// A simple implementation of make-array
|
|
14168
|
+
function make_array(subject) {
|
|
14169
|
+
return Array.isArray(subject) ? subject : [subject];
|
|
14178
14170
|
}
|
|
14179
14171
|
|
|
14180
|
-
|
|
14181
|
-
|
|
14182
|
-
|
|
14183
|
-
|
|
14172
|
+
var REGEX_BLANK_LINE = /^\s+$/;
|
|
14173
|
+
var REGEX_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
|
|
14174
|
+
var REGEX_LEADING_EXCAPED_HASH = /^\\#/;
|
|
14175
|
+
var SLASH = '/';
|
|
14176
|
+
var KEY_IGNORE = typeof Symbol !== 'undefined' ? Symbol.for('node-ignore')
|
|
14177
|
+
/* istanbul ignore next */
|
|
14178
|
+
: 'node-ignore';
|
|
14179
|
+
|
|
14180
|
+
var define = function define(object, key, value) {
|
|
14181
|
+
return Object.defineProperty(object, key, {
|
|
14182
|
+
value
|
|
14183
|
+
});
|
|
14184
14184
|
};
|
|
14185
|
-
}();
|
|
14186
14185
|
|
|
14187
|
-
|
|
14188
|
-
|
|
14189
|
-
throw new TypeError("Cannot call a class as a function");
|
|
14190
|
-
}
|
|
14191
|
-
}
|
|
14186
|
+
var REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g; // Sanitize the range of a regular expression
|
|
14187
|
+
// The cases are complicated, see test cases for details
|
|
14192
14188
|
|
|
14193
|
-
var
|
|
14194
|
-
|
|
14195
|
-
|
|
14189
|
+
var sanitizeRange = function sanitizeRange(range) {
|
|
14190
|
+
return range.replace(REGEX_REGEXP_RANGE, function (match, from, to) {
|
|
14191
|
+
return from.charCodeAt(0) <= to.charCodeAt(0) ? match // Invalid range (out of order) which is ok for gitignore rules but
|
|
14192
|
+
// fatal for JavaScript regular expression, so eliminate it.
|
|
14193
|
+
: '';
|
|
14194
|
+
});
|
|
14195
|
+
}; // > If the pattern ends with a slash,
|
|
14196
|
+
// > it is removed for the purpose of the following description,
|
|
14197
|
+
// > but it would only find a match with a directory.
|
|
14198
|
+
// > In other words, foo/ will match a directory foo and paths underneath it,
|
|
14199
|
+
// > but will not match a regular file or a symbolic link foo
|
|
14200
|
+
// > (this is consistent with the way how pathspec works in general in Git).
|
|
14201
|
+
// '`foo/`' will not match regular file '`foo`' or symbolic link '`foo`'
|
|
14202
|
+
// -> ignore-rules will not deal with it, because it costs extra `fs.stat` call
|
|
14203
|
+
// you could use option `mark: true` with `glob`
|
|
14204
|
+
// '`foo/`' should not continue with the '`..`'
|
|
14205
|
+
|
|
14206
|
+
|
|
14207
|
+
var DEFAULT_REPLACER_PREFIX = [// > Trailing spaces are ignored unless they are quoted with backslash ("\")
|
|
14208
|
+
[// (a\ ) -> (a )
|
|
14209
|
+
// (a ) -> (a)
|
|
14210
|
+
// (a \ ) -> (a )
|
|
14211
|
+
/\\?\s+$/, function (match) {
|
|
14212
|
+
return match.indexOf('\\') === 0 ? ' ' : '';
|
|
14213
|
+
}], // replace (\ ) with ' '
|
|
14214
|
+
[/\\\s/g, function () {
|
|
14215
|
+
return ' ';
|
|
14216
|
+
}], // Escape metacharacters
|
|
14217
|
+
// which is written down by users but means special for regular expressions.
|
|
14218
|
+
// > There are 12 characters with special meanings:
|
|
14219
|
+
// > - the backslash \,
|
|
14220
|
+
// > - the caret ^,
|
|
14221
|
+
// > - the dollar sign $,
|
|
14222
|
+
// > - the period or dot .,
|
|
14223
|
+
// > - the vertical bar or pipe symbol |,
|
|
14224
|
+
// > - the question mark ?,
|
|
14225
|
+
// > - the asterisk or star *,
|
|
14226
|
+
// > - the plus sign +,
|
|
14227
|
+
// > - the opening parenthesis (,
|
|
14228
|
+
// > - the closing parenthesis ),
|
|
14229
|
+
// > - and the opening square bracket [,
|
|
14230
|
+
// > - the opening curly brace {,
|
|
14231
|
+
// > These special characters are often called "metacharacters".
|
|
14232
|
+
[/[\\^$.|*+(){]/g, function (match) {
|
|
14233
|
+
return `\\${match}`;
|
|
14234
|
+
}], [// > [abc] matches any character inside the brackets
|
|
14235
|
+
// > (in this case a, b, or c);
|
|
14236
|
+
/\[([^\]/]*)($|\])/g, function (match, p1, p2) {
|
|
14237
|
+
return p2 === ']' ? `[${sanitizeRange(p1)}]` : `\\${match}`;
|
|
14238
|
+
}], [// > a question mark (?) matches a single character
|
|
14239
|
+
/(?!\\)\?/g, function () {
|
|
14240
|
+
return '[^/]';
|
|
14241
|
+
}], // leading slash
|
|
14242
|
+
[// > A leading slash matches the beginning of the pathname.
|
|
14243
|
+
// > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
|
|
14244
|
+
// A leading slash matches the beginning of the pathname
|
|
14245
|
+
/^\//, function () {
|
|
14246
|
+
return '^';
|
|
14247
|
+
}], // replace special metacharacter slash after the leading slash
|
|
14248
|
+
[/\//g, function () {
|
|
14249
|
+
return '\\/';
|
|
14250
|
+
}], [// > A leading "**" followed by a slash means match in all directories.
|
|
14251
|
+
// > For example, "**/foo" matches file or directory "foo" anywhere,
|
|
14252
|
+
// > the same as pattern "foo".
|
|
14253
|
+
// > "**/foo/bar" matches file or directory "bar" anywhere that is directly
|
|
14254
|
+
// > under directory "foo".
|
|
14255
|
+
// Notice that the '*'s have been replaced as '\\*'
|
|
14256
|
+
/^\^*\\\*\\\*\\\//, // '**/foo' <-> 'foo'
|
|
14257
|
+
function () {
|
|
14258
|
+
return '^(?:.*\\/)?';
|
|
14259
|
+
}]];
|
|
14260
|
+
var DEFAULT_REPLACER_SUFFIX = [// starting
|
|
14261
|
+
[// there will be no leading '/'
|
|
14262
|
+
// (which has been replaced by section "leading slash")
|
|
14263
|
+
// If starts with '**', adding a '^' to the regular expression also works
|
|
14264
|
+
/^(?=[^^])/, function startingReplacer() {
|
|
14265
|
+
return !/\/(?!$)/.test(this) // > If the pattern does not contain a slash /,
|
|
14266
|
+
// > Git treats it as a shell glob pattern
|
|
14267
|
+
// Actually, if there is only a trailing slash,
|
|
14268
|
+
// git also treats it as a shell glob pattern
|
|
14269
|
+
? '(?:^|\\/)' // > Otherwise, Git treats the pattern as a shell glob suitable for
|
|
14270
|
+
// > consumption by fnmatch(3)
|
|
14271
|
+
: '^';
|
|
14272
|
+
}], // two globstars
|
|
14273
|
+
[// Use lookahead assertions so that we could match more than one `'/**'`
|
|
14274
|
+
/\\\/\\\*\\\*(?=\\\/|$)/g, // Zero, one or several directories
|
|
14275
|
+
// should not use '*', or it will be replaced by the next replacer
|
|
14276
|
+
// Check if it is not the last `'/**'`
|
|
14277
|
+
function (match, index, str) {
|
|
14278
|
+
return index + 6 < str.length // case: /**/
|
|
14279
|
+
// > A slash followed by two consecutive asterisks then a slash matches
|
|
14280
|
+
// > zero or more directories.
|
|
14281
|
+
// > For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on.
|
|
14282
|
+
// '/**/'
|
|
14283
|
+
? '(?:\\/[^\\/]+)*' // case: /**
|
|
14284
|
+
// > A trailing `"/**"` matches everything inside.
|
|
14285
|
+
// #21: everything inside but it should not include the current folder
|
|
14286
|
+
: '\\/.+';
|
|
14287
|
+
}], // intermediate wildcards
|
|
14288
|
+
[// Never replace escaped '*'
|
|
14289
|
+
// ignore rule '\*' will match the path '*'
|
|
14290
|
+
// 'abc.*/' -> go
|
|
14291
|
+
// 'abc.*' -> skip this rule
|
|
14292
|
+
/(^|[^\\]+)\\\*(?=.+)/g, // '*.js' matches '.js'
|
|
14293
|
+
// '*.js' doesn't match 'abc'
|
|
14294
|
+
function (match, p1) {
|
|
14295
|
+
return `${p1}[^\\/]*`;
|
|
14296
|
+
}], // trailing wildcard
|
|
14297
|
+
[/(\^|\\\/)?\\\*$/, function (match, p1) {
|
|
14298
|
+
var prefix = p1 // '\^':
|
|
14299
|
+
// '/*' does not match ''
|
|
14300
|
+
// '/*' does not match everything
|
|
14301
|
+
// '\\\/':
|
|
14302
|
+
// 'abc/*' does not match 'abc/'
|
|
14303
|
+
? `${p1}[^/]+` // 'a*' matches 'a'
|
|
14304
|
+
// 'a*' matches 'aa'
|
|
14305
|
+
: '[^/]*';
|
|
14306
|
+
return `${prefix}(?=$|\\/$)`;
|
|
14307
|
+
}], [// unescape
|
|
14308
|
+
/\\\\\\/g, function () {
|
|
14309
|
+
return '\\';
|
|
14310
|
+
}]];
|
|
14311
|
+
var POSITIVE_REPLACERS = DEFAULT_REPLACER_PREFIX.concat([// 'f'
|
|
14312
|
+
// matches
|
|
14313
|
+
// - /f(end)
|
|
14314
|
+
// - /f/
|
|
14315
|
+
// - (start)f(end)
|
|
14316
|
+
// - (start)f/
|
|
14317
|
+
// doesn't match
|
|
14318
|
+
// - oof
|
|
14319
|
+
// - foo
|
|
14320
|
+
// pseudo:
|
|
14321
|
+
// -> (^|/)f(/|$)
|
|
14322
|
+
// ending
|
|
14323
|
+
[// 'js' will not match 'js.'
|
|
14324
|
+
// 'ab' will not match 'abc'
|
|
14325
|
+
/(?:[^*/])$/, // 'js*' will not match 'a.js'
|
|
14326
|
+
// 'js/' will not match 'a.js'
|
|
14327
|
+
// 'js' will match 'a.js' and 'a.js/'
|
|
14328
|
+
function (match) {
|
|
14329
|
+
return `${match}(?=$|\\/)`;
|
|
14330
|
+
}]], DEFAULT_REPLACER_SUFFIX);
|
|
14331
|
+
var NEGATIVE_REPLACERS = DEFAULT_REPLACER_PREFIX.concat([// #24, #38
|
|
14332
|
+
// The MISSING rule of [gitignore docs](https://git-scm.com/docs/gitignore)
|
|
14333
|
+
// A negative pattern without a trailing wildcard should not
|
|
14334
|
+
// re-include the things inside that directory.
|
|
14335
|
+
// eg:
|
|
14336
|
+
// ['node_modules/*', '!node_modules']
|
|
14337
|
+
// should ignore `node_modules/a.js`
|
|
14338
|
+
[/(?:[^*])$/, function (match) {
|
|
14339
|
+
return `${match}(?=$|\\/$)`;
|
|
14340
|
+
}]], DEFAULT_REPLACER_SUFFIX); // A simple cache, because an ignore rule only has only one certain meaning
|
|
14341
|
+
|
|
14342
|
+
var cache = Object.create(null); // @param {pattern}
|
|
14343
|
+
|
|
14344
|
+
var make_regex = function make_regex(pattern, negative, ignorecase) {
|
|
14345
|
+
var r = cache[pattern];
|
|
14346
|
+
|
|
14347
|
+
if (r) {
|
|
14348
|
+
return r;
|
|
14349
|
+
}
|
|
14350
|
+
|
|
14351
|
+
var replacers = negative ? NEGATIVE_REPLACERS : POSITIVE_REPLACERS;
|
|
14352
|
+
var source = replacers.reduce(function (prev, current) {
|
|
14353
|
+
return prev.replace(current[0], current[1].bind(pattern));
|
|
14354
|
+
}, pattern);
|
|
14355
|
+
return cache[pattern] = ignorecase ? new RegExp(source, 'i') : new RegExp(source);
|
|
14356
|
+
}; // > A blank line matches no files, so it can serve as a separator for readability.
|
|
14357
|
+
|
|
14358
|
+
|
|
14359
|
+
var checkPattern = function checkPattern(pattern) {
|
|
14360
|
+
return pattern && typeof pattern === 'string' && !REGEX_BLANK_LINE.test(pattern) // > A line starting with # serves as a comment.
|
|
14361
|
+
&& pattern.indexOf('#') !== 0;
|
|
14362
|
+
};
|
|
14196
14363
|
|
|
14364
|
+
var createRule = function createRule(pattern, ignorecase) {
|
|
14365
|
+
var origin = pattern;
|
|
14366
|
+
var negative = false; // > An optional prefix "!" which negates the pattern;
|
|
14197
14367
|
|
|
14198
|
-
|
|
14199
|
-
|
|
14200
|
-
|
|
14368
|
+
if (pattern.indexOf('!') === 0) {
|
|
14369
|
+
negative = true;
|
|
14370
|
+
pattern = pattern.substr(1);
|
|
14371
|
+
}
|
|
14201
14372
|
|
|
14202
|
-
|
|
14203
|
-
|
|
14204
|
-
|
|
14205
|
-
|
|
14206
|
-
|
|
14207
|
-
|
|
14208
|
-
|
|
14373
|
+
pattern = pattern // > Put a backslash ("\") in front of the first "!" for patterns that
|
|
14374
|
+
// > begin with a literal "!", for example, `"\!important!.txt"`.
|
|
14375
|
+
.replace(REGEX_LEADING_EXCAPED_EXCLAMATION, '!') // > Put a backslash ("\") in front of the first hash for patterns that
|
|
14376
|
+
// > begin with a hash.
|
|
14377
|
+
.replace(REGEX_LEADING_EXCAPED_HASH, '#');
|
|
14378
|
+
var regex = make_regex(pattern, negative, ignorecase);
|
|
14379
|
+
return {
|
|
14380
|
+
origin,
|
|
14381
|
+
pattern,
|
|
14382
|
+
negative,
|
|
14383
|
+
regex
|
|
14384
|
+
};
|
|
14385
|
+
};
|
|
14209
14386
|
|
|
14210
|
-
var IgnoreBase =
|
|
14211
|
-
|
|
14212
|
-
|
|
14387
|
+
var IgnoreBase =
|
|
14388
|
+
/*#__PURE__*/
|
|
14389
|
+
function () {
|
|
14390
|
+
function IgnoreBase() {
|
|
14391
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
14392
|
+
_ref$ignorecase = _ref.ignorecase,
|
|
14393
|
+
ignorecase = _ref$ignorecase === void 0 ? true : _ref$ignorecase;
|
|
14213
14394
|
|
|
14214
|
-
|
|
14215
|
-
this[KEY_IGNORE] = true;
|
|
14395
|
+
_classCallCheck(this, IgnoreBase);
|
|
14216
14396
|
|
|
14217
|
-
|
|
14218
|
-
|
|
14397
|
+
this._rules = [];
|
|
14398
|
+
this._ignorecase = ignorecase;
|
|
14399
|
+
define(this, KEY_IGNORE, true);
|
|
14219
14400
|
|
|
14220
|
-
|
|
14221
|
-
|
|
14222
|
-
value: function _initCache() {
|
|
14223
|
-
this._cache = {};
|
|
14224
|
-
} // @param {Array.<string>|string|Ignore} pattern
|
|
14401
|
+
this._initCache();
|
|
14402
|
+
}
|
|
14225
14403
|
|
|
14226
|
-
|
|
14227
|
-
|
|
14228
|
-
|
|
14229
|
-
|
|
14404
|
+
_createClass(IgnoreBase, [{
|
|
14405
|
+
key: "_initCache",
|
|
14406
|
+
value: function _initCache() {
|
|
14407
|
+
this._cache = Object.create(null);
|
|
14408
|
+
} // @param {Array.<string>|string|Ignore} pattern
|
|
14230
14409
|
|
|
14231
|
-
|
|
14232
|
-
|
|
14233
|
-
|
|
14410
|
+
}, {
|
|
14411
|
+
key: "add",
|
|
14412
|
+
value: function add(pattern) {
|
|
14413
|
+
this._added = false;
|
|
14234
14414
|
|
|
14235
|
-
|
|
14236
|
-
|
|
14415
|
+
if (typeof pattern === 'string') {
|
|
14416
|
+
pattern = pattern.split(/\r?\n/g);
|
|
14417
|
+
}
|
|
14237
14418
|
|
|
14238
|
-
|
|
14239
|
-
|
|
14240
|
-
}
|
|
14419
|
+
make_array(pattern).forEach(this._addPattern, this); // Some rules have just added to the ignore,
|
|
14420
|
+
// making the behavior changed.
|
|
14241
14421
|
|
|
14242
|
-
|
|
14243
|
-
|
|
14422
|
+
if (this._added) {
|
|
14423
|
+
this._initCache();
|
|
14424
|
+
}
|
|
14244
14425
|
|
|
14245
|
-
|
|
14246
|
-
|
|
14247
|
-
|
|
14248
|
-
|
|
14249
|
-
|
|
14250
|
-
|
|
14251
|
-
|
|
14252
|
-
value: function _addPattern(pattern) {
|
|
14253
|
-
// #32
|
|
14254
|
-
if (pattern && pattern[KEY_IGNORE]) {
|
|
14255
|
-
this._rules = this._rules.concat(pattern._rules);
|
|
14256
|
-
this._added = true;
|
|
14257
|
-
return;
|
|
14426
|
+
return this;
|
|
14427
|
+
} // legacy
|
|
14428
|
+
|
|
14429
|
+
}, {
|
|
14430
|
+
key: "addPattern",
|
|
14431
|
+
value: function addPattern(pattern) {
|
|
14432
|
+
return this.add(pattern);
|
|
14258
14433
|
}
|
|
14434
|
+
}, {
|
|
14435
|
+
key: "_addPattern",
|
|
14436
|
+
value: function _addPattern(pattern) {
|
|
14437
|
+
// #32
|
|
14438
|
+
if (pattern && pattern[KEY_IGNORE]) {
|
|
14439
|
+
this._rules = this._rules.concat(pattern._rules);
|
|
14440
|
+
this._added = true;
|
|
14441
|
+
return;
|
|
14442
|
+
}
|
|
14259
14443
|
|
|
14260
|
-
|
|
14261
|
-
|
|
14444
|
+
if (checkPattern(pattern)) {
|
|
14445
|
+
var rule = createRule(pattern, this._ignorecase);
|
|
14446
|
+
this._added = true;
|
|
14262
14447
|
|
|
14263
|
-
|
|
14448
|
+
this._rules.push(rule);
|
|
14449
|
+
}
|
|
14450
|
+
}
|
|
14451
|
+
}, {
|
|
14452
|
+
key: "filter",
|
|
14453
|
+
value: function filter(paths) {
|
|
14454
|
+
var _this = this;
|
|
14264
14455
|
|
|
14265
|
-
|
|
14456
|
+
return make_array(paths).filter(function (path$$1) {
|
|
14457
|
+
return _this._filter(path$$1);
|
|
14458
|
+
});
|
|
14266
14459
|
}
|
|
14267
|
-
}
|
|
14268
|
-
|
|
14269
|
-
|
|
14270
|
-
|
|
14271
|
-
// > A blank line matches no files, so it can serve as a separator for readability.
|
|
14272
|
-
return pattern && typeof pattern === 'string' && !REGEX_BLANK_LINE.test(pattern) // > A line starting with # serves as a comment.
|
|
14273
|
-
&& pattern.indexOf('#') !== 0;
|
|
14274
|
-
}
|
|
14275
|
-
}, {
|
|
14276
|
-
key: 'filter',
|
|
14277
|
-
value: function filter(paths) {
|
|
14278
|
-
var _this = this;
|
|
14460
|
+
}, {
|
|
14461
|
+
key: "createFilter",
|
|
14462
|
+
value: function createFilter() {
|
|
14463
|
+
var _this2 = this;
|
|
14279
14464
|
|
|
14280
|
-
|
|
14281
|
-
|
|
14282
|
-
|
|
14283
|
-
|
|
14284
|
-
|
|
14285
|
-
|
|
14286
|
-
|
|
14287
|
-
|
|
14465
|
+
return function (path$$1) {
|
|
14466
|
+
return _this2._filter(path$$1);
|
|
14467
|
+
};
|
|
14468
|
+
}
|
|
14469
|
+
}, {
|
|
14470
|
+
key: "ignores",
|
|
14471
|
+
value: function ignores(path$$1) {
|
|
14472
|
+
return !this._filter(path$$1);
|
|
14473
|
+
} // @returns `Boolean` true if the `path` is NOT ignored
|
|
14288
14474
|
|
|
14289
|
-
|
|
14290
|
-
|
|
14291
|
-
|
|
14292
|
-
|
|
14293
|
-
|
|
14294
|
-
|
|
14295
|
-
value: function ignores(path$$1) {
|
|
14296
|
-
return !this._filter(path$$1);
|
|
14297
|
-
}
|
|
14298
|
-
}, {
|
|
14299
|
-
key: '_createRule',
|
|
14300
|
-
value: function _createRule(pattern) {
|
|
14301
|
-
var origin = pattern;
|
|
14302
|
-
var negative = false; // > An optional prefix "!" which negates the pattern;
|
|
14475
|
+
}, {
|
|
14476
|
+
key: "_filter",
|
|
14477
|
+
value: function _filter(path$$1, slices) {
|
|
14478
|
+
if (!path$$1) {
|
|
14479
|
+
return false;
|
|
14480
|
+
}
|
|
14303
14481
|
|
|
14304
|
-
|
|
14305
|
-
|
|
14306
|
-
|
|
14307
|
-
}
|
|
14482
|
+
if (path$$1 in this._cache) {
|
|
14483
|
+
return this._cache[path$$1];
|
|
14484
|
+
}
|
|
14308
14485
|
|
|
14309
|
-
|
|
14310
|
-
|
|
14311
|
-
|
|
14312
|
-
|
|
14313
|
-
|
|
14314
|
-
origin: origin,
|
|
14315
|
-
pattern: pattern,
|
|
14316
|
-
negative: negative,
|
|
14317
|
-
regex: regex
|
|
14318
|
-
};
|
|
14319
|
-
} // @returns `Boolean` true if the `path` is NOT ignored
|
|
14486
|
+
if (!slices) {
|
|
14487
|
+
// path/to/a.js
|
|
14488
|
+
// ['path', 'to', 'a.js']
|
|
14489
|
+
slices = path$$1.split(SLASH);
|
|
14490
|
+
}
|
|
14320
14491
|
|
|
14321
|
-
|
|
14322
|
-
|
|
14323
|
-
|
|
14324
|
-
|
|
14325
|
-
|
|
14326
|
-
|
|
14492
|
+
slices.pop();
|
|
14493
|
+
return this._cache[path$$1] = slices.length // > It is not possible to re-include a file if a parent directory of
|
|
14494
|
+
// > that file is excluded.
|
|
14495
|
+
// If the path contains a parent directory, check the parent first
|
|
14496
|
+
? this._filter(slices.join(SLASH) + SLASH, slices) && this._test(path$$1) // Or only test the path
|
|
14497
|
+
: this._test(path$$1);
|
|
14498
|
+
} // @returns {Boolean} true if a file is NOT ignored
|
|
14327
14499
|
|
|
14328
|
-
|
|
14329
|
-
|
|
14330
|
-
|
|
14500
|
+
}, {
|
|
14501
|
+
key: "_test",
|
|
14502
|
+
value: function _test(path$$1) {
|
|
14503
|
+
// Explicitly define variable type by setting matched to `0`
|
|
14504
|
+
var matched = 0;
|
|
14505
|
+
|
|
14506
|
+
this._rules.forEach(function (rule) {
|
|
14507
|
+
// if matched = true, then we only test negative rules
|
|
14508
|
+
// if matched = false, then we test non-negative rules
|
|
14509
|
+
if (!(matched ^ rule.negative)) {
|
|
14510
|
+
matched = rule.negative ^ rule.regex.test(path$$1);
|
|
14511
|
+
}
|
|
14512
|
+
});
|
|
14331
14513
|
|
|
14332
|
-
|
|
14333
|
-
// path/to/a.js
|
|
14334
|
-
// ['path', 'to', 'a.js']
|
|
14335
|
-
slices = path$$1.split(SLASH);
|
|
14514
|
+
return !matched;
|
|
14336
14515
|
}
|
|
14516
|
+
}]);
|
|
14337
14517
|
|
|
14338
|
-
|
|
14339
|
-
|
|
14340
|
-
|
|
14341
|
-
? this._filter(slices.join(SLASH) + SLASH, slices) && this._test(path$$1) // Or only test the path
|
|
14342
|
-
: this._test(path$$1);
|
|
14343
|
-
} // @returns {Boolean} true if a file is NOT ignored
|
|
14518
|
+
return IgnoreBase;
|
|
14519
|
+
}(); // Windows
|
|
14520
|
+
// --------------------------------------------------------------
|
|
14344
14521
|
|
|
14345
|
-
|
|
14346
|
-
key: '_test',
|
|
14347
|
-
value: function _test(path$$1) {
|
|
14348
|
-
// Explicitly define variable type by setting matched to `0`
|
|
14349
|
-
var matched = 0;
|
|
14522
|
+
/* istanbul ignore if */
|
|
14350
14523
|
|
|
14351
|
-
this._rules.forEach(function (rule) {
|
|
14352
|
-
// if matched = true, then we only test negative rules
|
|
14353
|
-
// if matched = false, then we test non-negative rules
|
|
14354
|
-
if (!(matched ^ rule.negative)) {
|
|
14355
|
-
matched = rule.negative ^ rule.regex.test(path$$1);
|
|
14356
|
-
}
|
|
14357
|
-
});
|
|
14358
14524
|
|
|
14359
|
-
|
|
14360
|
-
|
|
14361
|
-
|
|
14525
|
+
if ( // Detect `process` so that it can run in browsers.
|
|
14526
|
+
typeof process !== 'undefined' && (process.env && process.env.IGNORE_TEST_WIN32 || process.platform === 'win32')) {
|
|
14527
|
+
var filter = IgnoreBase.prototype._filter;
|
|
14528
|
+
/* eslint no-control-regex: "off" */
|
|
14362
14529
|
|
|
14363
|
-
|
|
14364
|
-
|
|
14365
|
-
|
|
14366
|
-
|
|
14367
|
-
|
|
14368
|
-
|
|
14369
|
-
|
|
14370
|
-
|
|
14371
|
-
|
|
14372
|
-
// you could use option `mark: true` with `glob`
|
|
14373
|
-
// '`foo/`' should not continue with the '`..`'
|
|
14374
|
-
|
|
14375
|
-
|
|
14376
|
-
var DEFAULT_REPLACER_PREFIX = [// > Trailing spaces are ignored unless they are quoted with backslash ("\")
|
|
14377
|
-
[// (a\ ) -> (a )
|
|
14378
|
-
// (a ) -> (a)
|
|
14379
|
-
// (a \ ) -> (a )
|
|
14380
|
-
/\\?\s+$/, function (match) {
|
|
14381
|
-
return match.indexOf('\\') === 0 ? ' ' : '';
|
|
14382
|
-
}], // replace (\ ) with ' '
|
|
14383
|
-
[/\\\s/g, function () {
|
|
14384
|
-
return ' ';
|
|
14385
|
-
}], // Escape metacharacters
|
|
14386
|
-
// which is written down by users but means special for regular expressions.
|
|
14387
|
-
// > There are 12 characters with special meanings:
|
|
14388
|
-
// > - the backslash \,
|
|
14389
|
-
// > - the caret ^,
|
|
14390
|
-
// > - the dollar sign $,
|
|
14391
|
-
// > - the period or dot .,
|
|
14392
|
-
// > - the vertical bar or pipe symbol |,
|
|
14393
|
-
// > - the question mark ?,
|
|
14394
|
-
// > - the asterisk or star *,
|
|
14395
|
-
// > - the plus sign +,
|
|
14396
|
-
// > - the opening parenthesis (,
|
|
14397
|
-
// > - the closing parenthesis ),
|
|
14398
|
-
// > - and the opening square bracket [,
|
|
14399
|
-
// > - the opening curly brace {,
|
|
14400
|
-
// > These special characters are often called "metacharacters".
|
|
14401
|
-
[/[\\\^$.|?*+()\[{]/g, function (match) {
|
|
14402
|
-
return '\\' + match;
|
|
14403
|
-
}], // leading slash
|
|
14404
|
-
[// > A leading slash matches the beginning of the pathname.
|
|
14405
|
-
// > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
|
|
14406
|
-
// A leading slash matches the beginning of the pathname
|
|
14407
|
-
/^\//, function () {
|
|
14408
|
-
return '^';
|
|
14409
|
-
}], // replace special metacharacter slash after the leading slash
|
|
14410
|
-
[/\//g, function () {
|
|
14411
|
-
return '\\/';
|
|
14412
|
-
}], [// > A leading "**" followed by a slash means match in all directories.
|
|
14413
|
-
// > For example, "**/foo" matches file or directory "foo" anywhere,
|
|
14414
|
-
// > the same as pattern "foo".
|
|
14415
|
-
// > "**/foo/bar" matches file or directory "bar" anywhere that is directly under directory "foo".
|
|
14416
|
-
// Notice that the '*'s have been replaced as '\\*'
|
|
14417
|
-
/^\^*\\\*\\\*\\\//, // '**/foo' <-> 'foo'
|
|
14418
|
-
function () {
|
|
14419
|
-
return '^(?:.*\\/)?';
|
|
14420
|
-
}]];
|
|
14421
|
-
var DEFAULT_REPLACER_SUFFIX = [// starting
|
|
14422
|
-
[// there will be no leading '/' (which has been replaced by section "leading slash")
|
|
14423
|
-
// If starts with '**', adding a '^' to the regular expression also works
|
|
14424
|
-
/^(?=[^\^])/, function () {
|
|
14425
|
-
return !/\/(?!$)/.test(this) // > If the pattern does not contain a slash /, Git treats it as a shell glob pattern
|
|
14426
|
-
// Actually, if there is only a trailing slash, git also treats it as a shell glob pattern
|
|
14427
|
-
? '(?:^|\\/)' // > Otherwise, Git treats the pattern as a shell glob suitable for consumption by fnmatch(3)
|
|
14428
|
-
: '^';
|
|
14429
|
-
}], // two globstars
|
|
14430
|
-
[// Use lookahead assertions so that we could match more than one `'/**'`
|
|
14431
|
-
/\\\/\\\*\\\*(?=\\\/|$)/g, // Zero, one or several directories
|
|
14432
|
-
// should not use '*', or it will be replaced by the next replacer
|
|
14433
|
-
// Check if it is not the last `'/**'`
|
|
14434
|
-
function (match, index, str) {
|
|
14435
|
-
return index + 6 < str.length // case: /**/
|
|
14436
|
-
// > A slash followed by two consecutive asterisks then a slash matches zero or more directories.
|
|
14437
|
-
// > For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on.
|
|
14438
|
-
// '/**/'
|
|
14439
|
-
? '(?:\\/[^\\/]+)*' // case: /**
|
|
14440
|
-
// > A trailing `"/**"` matches everything inside.
|
|
14441
|
-
// #21: everything inside but it should not include the current folder
|
|
14442
|
-
: '\\/.+';
|
|
14443
|
-
}], // intermediate wildcards
|
|
14444
|
-
[// Never replace escaped '*'
|
|
14445
|
-
// ignore rule '\*' will match the path '*'
|
|
14446
|
-
// 'abc.*/' -> go
|
|
14447
|
-
// 'abc.*' -> skip this rule
|
|
14448
|
-
/(^|[^\\]+)\\\*(?=.+)/g, // '*.js' matches '.js'
|
|
14449
|
-
// '*.js' doesn't match 'abc'
|
|
14450
|
-
function (match, p1) {
|
|
14451
|
-
return p1 + '[^\\/]*';
|
|
14452
|
-
}], // trailing wildcard
|
|
14453
|
-
[/(\^|\\\/)?\\\*$/, function (match, p1) {
|
|
14454
|
-
return (p1 // '\^':
|
|
14455
|
-
// '/*' does not match ''
|
|
14456
|
-
// '/*' does not match everything
|
|
14457
|
-
// '\\\/':
|
|
14458
|
-
// 'abc/*' does not match 'abc/'
|
|
14459
|
-
? p1 + '[^/]+' // 'a*' matches 'a'
|
|
14460
|
-
// 'a*' matches 'aa'
|
|
14461
|
-
: '[^/]*') + '(?=$|\\/$)';
|
|
14462
|
-
}], [// unescape
|
|
14463
|
-
/\\\\\\/g, function () {
|
|
14464
|
-
return '\\';
|
|
14465
|
-
}]];
|
|
14466
|
-
var POSITIVE_REPLACERS = [].concat(DEFAULT_REPLACER_PREFIX, [// 'f'
|
|
14467
|
-
// matches
|
|
14468
|
-
// - /f(end)
|
|
14469
|
-
// - /f/
|
|
14470
|
-
// - (start)f(end)
|
|
14471
|
-
// - (start)f/
|
|
14472
|
-
// doesn't match
|
|
14473
|
-
// - oof
|
|
14474
|
-
// - foo
|
|
14475
|
-
// pseudo:
|
|
14476
|
-
// -> (^|/)f(/|$)
|
|
14477
|
-
// ending
|
|
14478
|
-
[// 'js' will not match 'js.'
|
|
14479
|
-
// 'ab' will not match 'abc'
|
|
14480
|
-
/(?:[^*\/])$/, // 'js*' will not match 'a.js'
|
|
14481
|
-
// 'js/' will not match 'a.js'
|
|
14482
|
-
// 'js' will match 'a.js' and 'a.js/'
|
|
14483
|
-
function (match) {
|
|
14484
|
-
return match + '(?=$|\\/)';
|
|
14485
|
-
}]], DEFAULT_REPLACER_SUFFIX);
|
|
14486
|
-
var NEGATIVE_REPLACERS = [].concat(DEFAULT_REPLACER_PREFIX, [// #24
|
|
14487
|
-
// The MISSING rule of [gitignore docs](https://git-scm.com/docs/gitignore)
|
|
14488
|
-
// A negative pattern without a trailing wildcard should not
|
|
14489
|
-
// re-include the things inside that directory.
|
|
14490
|
-
// eg:
|
|
14491
|
-
// ['node_modules/*', '!node_modules']
|
|
14492
|
-
// should ignore `node_modules/a.js`
|
|
14493
|
-
[/(?:[^*\/])$/, function (match) {
|
|
14494
|
-
return match + '(?=$|\\/$)';
|
|
14495
|
-
}]], DEFAULT_REPLACER_SUFFIX); // A simple cache, because an ignore rule only has only one certain meaning
|
|
14496
|
-
|
|
14497
|
-
var cache = {}; // @param {pattern}
|
|
14498
|
-
|
|
14499
|
-
function make_regex(pattern, negative) {
|
|
14500
|
-
var r = cache[pattern];
|
|
14501
|
-
|
|
14502
|
-
if (r) {
|
|
14503
|
-
return r;
|
|
14504
|
-
}
|
|
14505
|
-
|
|
14506
|
-
var replacers = negative ? NEGATIVE_REPLACERS : POSITIVE_REPLACERS;
|
|
14507
|
-
var source = replacers.reduce(function (prev, current) {
|
|
14508
|
-
return prev.replace(current[0], current[1].bind(pattern));
|
|
14509
|
-
}, pattern);
|
|
14510
|
-
return cache[pattern] = new RegExp(source, 'i');
|
|
14511
|
-
} // Windows
|
|
14512
|
-
// --------------------------------------------------------------
|
|
14513
|
-
|
|
14514
|
-
/* istanbul ignore if */
|
|
14515
|
-
|
|
14516
|
-
|
|
14517
|
-
if ( // Detect `process` so that it can run in browsers.
|
|
14518
|
-
typeof process !== 'undefined' && (process.env && process.env.IGNORE_TEST_WIN32 || process.platform === 'win32')) {
|
|
14519
|
-
var filter = IgnoreBase.prototype._filter;
|
|
14520
|
-
|
|
14521
|
-
var make_posix = function make_posix(str) {
|
|
14522
|
-
return /^\\\\\?\\/.test(str) || /[^\x00-\x80]+/.test(str) ? str : str.replace(/\\/g, '/');
|
|
14523
|
-
};
|
|
14530
|
+
var make_posix = function make_posix(str) {
|
|
14531
|
+
return /^\\\\\?\\/.test(str) || /[^\x00-\x80]+/.test(str) ? str : str.replace(/\\/g, '/');
|
|
14532
|
+
};
|
|
14533
|
+
|
|
14534
|
+
IgnoreBase.prototype._filter = function filterWin32(path$$1, slices) {
|
|
14535
|
+
path$$1 = make_posix(path$$1);
|
|
14536
|
+
return filter.call(this, path$$1, slices);
|
|
14537
|
+
};
|
|
14538
|
+
}
|
|
14524
14539
|
|
|
14525
|
-
|
|
14526
|
-
|
|
14527
|
-
return filter.call(this, path$$1, slices);
|
|
14540
|
+
module.exports = function (options) {
|
|
14541
|
+
return new IgnoreBase(options);
|
|
14528
14542
|
};
|
|
14529
|
-
}
|
|
14543
|
+
});
|
|
14530
14544
|
|
|
14531
14545
|
/**
|
|
14532
14546
|
* @param {string} filename
|
|
@@ -18292,9 +18306,9 @@ function charSet(s) {
|
|
|
18292
18306
|
|
|
18293
18307
|
|
|
18294
18308
|
var slashSplit = /\/+/;
|
|
18295
|
-
minimatch.filter = filter
|
|
18309
|
+
minimatch.filter = filter;
|
|
18296
18310
|
|
|
18297
|
-
function filter
|
|
18311
|
+
function filter(pattern, options) {
|
|
18298
18312
|
options = options || {};
|
|
18299
18313
|
return function (p, i, list) {
|
|
18300
18314
|
return minimatch(p, pattern, options);
|
|
@@ -22824,9 +22838,62 @@ function hasClosureCompilerTypeCastComment(text, path$$1, locStart, locEnd) {
|
|
|
22824
22838
|
|
|
22825
22839
|
function hasTypeCastComment(node) {
|
|
22826
22840
|
return node.comments && node.comments.some(function (comment) {
|
|
22827
|
-
return comment.leading && comments$3.isBlockComment(comment) && comment.value
|
|
22841
|
+
return comment.leading && comments$3.isBlockComment(comment) && isTypeCastComment(comment.value) && util$1.getNextNonSpaceNonCommentCharacter(text, comment, locEnd) === "(";
|
|
22828
22842
|
});
|
|
22829
22843
|
}
|
|
22844
|
+
|
|
22845
|
+
function isTypeCastComment(comment) {
|
|
22846
|
+
var trimmed = comment.trim();
|
|
22847
|
+
|
|
22848
|
+
if (!/^\*\s*@type\s*\{[^]+\}$/.test(trimmed)) {
|
|
22849
|
+
return false;
|
|
22850
|
+
}
|
|
22851
|
+
|
|
22852
|
+
var isCompletelyClosed = false;
|
|
22853
|
+
var unpairedBracketCount = 0;
|
|
22854
|
+
var _iteratorNormalCompletion = true;
|
|
22855
|
+
var _didIteratorError = false;
|
|
22856
|
+
var _iteratorError = undefined;
|
|
22857
|
+
|
|
22858
|
+
try {
|
|
22859
|
+
for (var _iterator = trimmed[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
22860
|
+
var char = _step.value;
|
|
22861
|
+
|
|
22862
|
+
if (char === "{") {
|
|
22863
|
+
if (isCompletelyClosed) {
|
|
22864
|
+
return false;
|
|
22865
|
+
}
|
|
22866
|
+
|
|
22867
|
+
unpairedBracketCount++;
|
|
22868
|
+
} else if (char === "}") {
|
|
22869
|
+
if (unpairedBracketCount === 0) {
|
|
22870
|
+
return false;
|
|
22871
|
+
}
|
|
22872
|
+
|
|
22873
|
+
unpairedBracketCount--;
|
|
22874
|
+
|
|
22875
|
+
if (unpairedBracketCount === 0) {
|
|
22876
|
+
isCompletelyClosed = true;
|
|
22877
|
+
}
|
|
22878
|
+
}
|
|
22879
|
+
}
|
|
22880
|
+
} catch (err) {
|
|
22881
|
+
_didIteratorError = true;
|
|
22882
|
+
_iteratorError = err;
|
|
22883
|
+
} finally {
|
|
22884
|
+
try {
|
|
22885
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
22886
|
+
_iterator.return();
|
|
22887
|
+
}
|
|
22888
|
+
} finally {
|
|
22889
|
+
if (_didIteratorError) {
|
|
22890
|
+
throw _iteratorError;
|
|
22891
|
+
}
|
|
22892
|
+
}
|
|
22893
|
+
}
|
|
22894
|
+
|
|
22895
|
+
return unpairedBracketCount === 0;
|
|
22896
|
+
}
|
|
22830
22897
|
}
|
|
22831
22898
|
|
|
22832
22899
|
function needsParens(path$$1, options) {
|
|
@@ -23033,7 +23100,6 @@ function needsParens(path$$1, options) {
|
|
|
23033
23100
|
|
|
23034
23101
|
case "ClassExpression":
|
|
23035
23102
|
case "ClassDeclaration":
|
|
23036
|
-
case "TSAbstractClassDeclaration":
|
|
23037
23103
|
return name === "superClass" && parent.superClass === node;
|
|
23038
23104
|
|
|
23039
23105
|
case "TSTypeAssertion":
|
|
@@ -23282,6 +23348,7 @@ function needsParens(path$$1, options) {
|
|
|
23282
23348
|
|
|
23283
23349
|
case "FunctionExpression":
|
|
23284
23350
|
switch (parent.type) {
|
|
23351
|
+
case "NewExpression":
|
|
23285
23352
|
case "CallExpression":
|
|
23286
23353
|
return name === "callee";
|
|
23287
23354
|
// Not strictly necessary, but it's clearer to the reader if IIFEs are wrapped in parentheses.
|
|
@@ -23326,7 +23393,16 @@ function needsParens(path$$1, options) {
|
|
|
23326
23393
|
}
|
|
23327
23394
|
|
|
23328
23395
|
case "ClassExpression":
|
|
23329
|
-
|
|
23396
|
+
switch (parent.type) {
|
|
23397
|
+
case "ExportDefaultDeclaration":
|
|
23398
|
+
return true;
|
|
23399
|
+
|
|
23400
|
+
case "NewExpression":
|
|
23401
|
+
return name === "callee" && parent.callee === node;
|
|
23402
|
+
|
|
23403
|
+
default:
|
|
23404
|
+
return false;
|
|
23405
|
+
}
|
|
23330
23406
|
|
|
23331
23407
|
case "OptionalMemberExpression":
|
|
23332
23408
|
return parent.type === "MemberExpression";
|
|
@@ -23358,7 +23434,7 @@ function needsParens(path$$1, options) {
|
|
|
23358
23434
|
return false;
|
|
23359
23435
|
|
|
23360
23436
|
case "NGPipeExpression":
|
|
23361
|
-
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") {
|
|
23437
|
+
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") {
|
|
23362
23438
|
return false;
|
|
23363
23439
|
}
|
|
23364
23440
|
|
|
@@ -23369,7 +23445,7 @@ function needsParens(path$$1, options) {
|
|
|
23369
23445
|
}
|
|
23370
23446
|
|
|
23371
23447
|
function isStatement(node) {
|
|
23372
|
-
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 === "
|
|
23448
|
+
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";
|
|
23373
23449
|
}
|
|
23374
23450
|
|
|
23375
23451
|
function getUnparenthesizedNode(node) {
|
|
@@ -23519,7 +23595,7 @@ var shouldFlatten$1 = util$1.shouldFlatten;
|
|
|
23519
23595
|
var getNextNonSpaceNonCommentCharacter$1 = util$1.getNextNonSpaceNonCommentCharacter;
|
|
23520
23596
|
var hasNewline$2 = util$1.hasNewline;
|
|
23521
23597
|
var hasNewlineInRange$1 = util$1.hasNewlineInRange;
|
|
23522
|
-
var getLast$
|
|
23598
|
+
var getLast$3 = util$1.getLast;
|
|
23523
23599
|
var getStringWidth$2 = util$1.getStringWidth;
|
|
23524
23600
|
var printString$1 = util$1.printString;
|
|
23525
23601
|
var printNumber$1 = util$1.printNumber;
|
|
@@ -23541,6 +23617,7 @@ var isVueEventBindingExpression = htmlBinding.isVueEventBindingExpression;
|
|
|
23541
23617
|
var hasNode = utils$4.hasNode;
|
|
23542
23618
|
var hasFlowAnnotationComment = utils$4.hasFlowAnnotationComment;
|
|
23543
23619
|
var hasFlowShorthandAnnotationComment = utils$4.hasFlowShorthandAnnotationComment;
|
|
23620
|
+
var needsQuoteProps = new WeakMap();
|
|
23544
23621
|
var _require$$6$builders = doc.builders;
|
|
23545
23622
|
var concat$4 = _require$$6$builders.concat;
|
|
23546
23623
|
var join$2 = _require$$6$builders.join;
|
|
@@ -23673,7 +23750,7 @@ function genericPrint(path$$1, options, printPath, args) {
|
|
|
23673
23750
|
}
|
|
23674
23751
|
|
|
23675
23752
|
function hasNewlineBetweenOrAfterDecorators(node, options) {
|
|
23676
|
-
return hasNewlineInRange$1(options.originalText, options.locStart(node.decorators[0]), options.locEnd(getLast$
|
|
23753
|
+
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)));
|
|
23677
23754
|
}
|
|
23678
23755
|
|
|
23679
23756
|
function printDecorators(path$$1, options, print) {
|
|
@@ -23990,7 +24067,7 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
23990
24067
|
return chain;
|
|
23991
24068
|
}
|
|
23992
24069
|
|
|
23993
|
-
var jsxPart = getLast$
|
|
24070
|
+
var jsxPart = getLast$3(_parts);
|
|
23994
24071
|
return group$1(concat$4([chain, ifBreak$1(indent$2(jsxPart), jsxPart, {
|
|
23995
24072
|
groupId
|
|
23996
24073
|
})]));
|
|
@@ -24335,7 +24412,7 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
24335
24412
|
if ( // We want to keep CommonJS- and AMD-style require calls, and AMD-style
|
|
24336
24413
|
// define calls, as a unit.
|
|
24337
24414
|
// e.g. `define(["some/lib", (lib) => {`
|
|
24338
|
-
!isNew && n.callee.type === "Identifier" && (n.callee.name === "require" || n.callee.name === "define") ||
|
|
24415
|
+
!isNew && n.callee.type === "Identifier" && (n.callee.name === "require" || n.callee.name === "define") || // Template literals as single arguments
|
|
24339
24416
|
n.arguments.length === 1 && isTemplateOnItsOwnLine(n.arguments[0], options.originalText, options) || // Keep test declarations on a single line
|
|
24340
24417
|
// e.g. `it('long name', () => {`
|
|
24341
24418
|
!isNew && isTestCall(n, path$$1.getParentNode())) {
|
|
@@ -24455,7 +24532,7 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
24455
24532
|
props.push(concat$4(separatorParts.concat(group$1("..."))));
|
|
24456
24533
|
}
|
|
24457
24534
|
|
|
24458
|
-
var lastElem = getLast$
|
|
24535
|
+
var lastElem = getLast$3(n[propertiesField]);
|
|
24459
24536
|
var canHaveTrailingSeparator = !(lastElem && (lastElem.type === "RestProperty" || lastElem.type === "RestElement" || hasNodeIgnoreComment$1(lastElem) || n.inexact));
|
|
24460
24537
|
var content;
|
|
24461
24538
|
|
|
@@ -24537,7 +24614,7 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
24537
24614
|
parts.push(group$1(concat$4(["[", comments.printDanglingComments(path$$1, options), softline$1, "]"])));
|
|
24538
24615
|
}
|
|
24539
24616
|
} else {
|
|
24540
|
-
var _lastElem = getLast$
|
|
24617
|
+
var _lastElem = getLast$3(n.elements);
|
|
24541
24618
|
|
|
24542
24619
|
var canHaveTrailingComma = !(_lastElem && _lastElem.type === "RestElement"); // JavaScript allows you to have empty elements in an array which
|
|
24543
24620
|
// changes its length based on the number of commas. The algorithm
|
|
@@ -24981,7 +25058,7 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
24981
25058
|
return group$1(concat$4(["<", path$$1.call(print, "name"), path$$1.call(print, "typeParameters"), " ", concat$4(path$$1.map(print, "attributes")), _n.selfClosing ? " />" : ">"]));
|
|
24982
25059
|
}
|
|
24983
25060
|
|
|
24984
|
-
var lastAttrHasTrailingComments = _n.attributes.length && hasTrailingComment(getLast$
|
|
25061
|
+
var lastAttrHasTrailingComments = _n.attributes.length && hasTrailingComment(getLast$3(_n.attributes));
|
|
24985
25062
|
var bracketSameLine = // Simple tags (no attributes and no comment in tag name) should be
|
|
24986
25063
|
// kept unbroken regardless of `jsxBracketSameLine`
|
|
24987
25064
|
!_n.attributes.length && !nameHasComments || options.jsxBracketSameLine && ( // We should print the bracket in a new line for the following cases:
|
|
@@ -25087,7 +25164,6 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
25087
25164
|
|
|
25088
25165
|
case "ClassDeclaration":
|
|
25089
25166
|
case "ClassExpression":
|
|
25090
|
-
case "TSAbstractClassDeclaration":
|
|
25091
25167
|
if (isNodeStartingWithDeclare(n, options)) {
|
|
25092
25168
|
parts.push("declare ");
|
|
25093
25169
|
}
|
|
@@ -26150,18 +26226,27 @@ function printStatementSequence(path$$1, options, print) {
|
|
|
26150
26226
|
|
|
26151
26227
|
function printPropertyKey(path$$1, options, print) {
|
|
26152
26228
|
var node = path$$1.getNode();
|
|
26229
|
+
var parent = path$$1.getParentNode();
|
|
26153
26230
|
var key = node.key;
|
|
26154
26231
|
|
|
26155
|
-
if (
|
|
26232
|
+
if (options.quoteProps === "consistent" && !needsQuoteProps.has(parent)) {
|
|
26233
|
+
var objectHasStringProp = (parent.properties || parent.body || parent.members).some(function (prop) {
|
|
26234
|
+
return prop.key && prop.key.type !== "Identifier" && !isStringPropSafeToCoerceToIdentifier(prop, options);
|
|
26235
|
+
});
|
|
26236
|
+
needsQuoteProps.set(parent, objectHasStringProp);
|
|
26237
|
+
}
|
|
26238
|
+
|
|
26239
|
+
if (key.type === "Identifier" && !node.computed && (options.parser === "json" || options.quoteProps === "consistent" && needsQuoteProps.get(parent))) {
|
|
26156
26240
|
// a -> "a"
|
|
26241
|
+
var prop = printString$1(JSON.stringify(key.name), options);
|
|
26157
26242
|
return path$$1.call(function (keyPath) {
|
|
26158
26243
|
return comments.printComments(keyPath, function () {
|
|
26159
|
-
return
|
|
26244
|
+
return prop;
|
|
26160
26245
|
}, options);
|
|
26161
26246
|
}, "key");
|
|
26162
26247
|
}
|
|
26163
26248
|
|
|
26164
|
-
if (
|
|
26249
|
+
if (isStringPropSafeToCoerceToIdentifier(node, options) && (options.quoteProps === "as-needed" || options.quoteProps === "consistent" && !needsQuoteProps.get(parent))) {
|
|
26165
26250
|
// 'a' -> a
|
|
26166
26251
|
return path$$1.call(function (keyPath) {
|
|
26167
26252
|
return comments.printComments(keyPath, function () {
|
|
@@ -26220,7 +26305,7 @@ function couldGroupArg(arg) {
|
|
|
26220
26305
|
}
|
|
26221
26306
|
|
|
26222
26307
|
function shouldGroupLastArg(args) {
|
|
26223
|
-
var lastArg = getLast$
|
|
26308
|
+
var lastArg = getLast$3(args);
|
|
26224
26309
|
var penultimateArg = getPenultimate$1(args);
|
|
26225
26310
|
return !hasLeadingComment(lastArg) && !hasTrailingComment(lastArg) && couldGroupArg(lastArg) && ( // If the last two arguments are of the same type,
|
|
26226
26311
|
// disable last element expansion.
|
|
@@ -26316,7 +26401,8 @@ function printArgumentsList(path$$1, options, print) {
|
|
|
26316
26401
|
|
|
26317
26402
|
return concat$4(parts);
|
|
26318
26403
|
}, "arguments");
|
|
26319
|
-
var maybeTrailingComma =
|
|
26404
|
+
var maybeTrailingComma = // Dynamic imports cannot have trailing commas
|
|
26405
|
+
!(node.callee && node.callee.type === "Import") && shouldPrintComma(options, "all") ? "," : "";
|
|
26320
26406
|
|
|
26321
26407
|
function allArgsBrokenOut() {
|
|
26322
26408
|
return group$1(concat$4(["(", indent$2(concat$4([line$3, concat$4(printedArguments)])), maybeTrailingComma, line$3, ")"]), {
|
|
@@ -26365,14 +26451,14 @@ function printArgumentsList(path$$1, options, print) {
|
|
|
26365
26451
|
var somePrintedArgumentsWillBreak = printedArguments.some(willBreak$1);
|
|
26366
26452
|
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], {
|
|
26367
26453
|
shouldBreak: true
|
|
26368
|
-
}), concat$4(printedExpanded.slice(1)), ")"]) : concat$4(["(", concat$4(printedArguments.slice(0, -1)), group$1(getLast$
|
|
26454
|
+
}), concat$4(printedExpanded.slice(1)), ")"]) : concat$4(["(", concat$4(printedArguments.slice(0, -1)), group$1(getLast$3(printedExpanded), {
|
|
26369
26455
|
shouldBreak: true
|
|
26370
26456
|
}), ")"]), allArgsBrokenOut()], {
|
|
26371
26457
|
shouldBreak
|
|
26372
26458
|
})]);
|
|
26373
26459
|
}
|
|
26374
26460
|
|
|
26375
|
-
return group$1(concat$4(["(", indent$2(concat$4([softline$1, concat$4(printedArguments)])), ifBreak$1(
|
|
26461
|
+
return group$1(concat$4(["(", indent$2(concat$4([softline$1, concat$4(printedArguments)])), ifBreak$1(maybeTrailingComma), softline$1, ")"]), {
|
|
26376
26462
|
shouldBreak: printedArguments.some(willBreak$1) || anyArgEmptyLine
|
|
26377
26463
|
});
|
|
26378
26464
|
}
|
|
@@ -26411,12 +26497,37 @@ function printFunctionTypeParameters(path$$1, options, print) {
|
|
|
26411
26497
|
|
|
26412
26498
|
function printFunctionParams(path$$1, print, options, expandArg, printTypeParams) {
|
|
26413
26499
|
var fun = path$$1.getValue();
|
|
26500
|
+
var parent = path$$1.getParentNode();
|
|
26414
26501
|
var paramsField = fun.parameters ? "parameters" : "params";
|
|
26502
|
+
var isParametersInTestCall = isTestCall(parent);
|
|
26503
|
+
var shouldHugParameters = shouldHugArguments(fun);
|
|
26504
|
+
var shouldExpandParameters = expandArg && !(fun[paramsField] && fun[paramsField].some(function (n) {
|
|
26505
|
+
return n.comments;
|
|
26506
|
+
}));
|
|
26415
26507
|
var typeParams = printTypeParams ? printFunctionTypeParameters(path$$1, options, print) : "";
|
|
26416
26508
|
var printed = [];
|
|
26417
26509
|
|
|
26418
26510
|
if (fun[paramsField]) {
|
|
26419
|
-
|
|
26511
|
+
var lastArgIndex = fun[paramsField].length - 1;
|
|
26512
|
+
printed = path$$1.map(function (childPath, index) {
|
|
26513
|
+
var parts = [];
|
|
26514
|
+
var param = childPath.getValue();
|
|
26515
|
+
parts.push(print(childPath));
|
|
26516
|
+
|
|
26517
|
+
if (index === lastArgIndex) {
|
|
26518
|
+
if (fun.rest) {
|
|
26519
|
+
parts.push(",", line$3);
|
|
26520
|
+
}
|
|
26521
|
+
} else if (isParametersInTestCall || shouldHugParameters || shouldExpandParameters) {
|
|
26522
|
+
parts.push(", ");
|
|
26523
|
+
} else if (isNextLineEmpty$2(options.originalText, param, options)) {
|
|
26524
|
+
parts.push(",", hardline$3, hardline$3);
|
|
26525
|
+
} else {
|
|
26526
|
+
parts.push(",", line$3);
|
|
26527
|
+
}
|
|
26528
|
+
|
|
26529
|
+
return concat$4(parts);
|
|
26530
|
+
}, paramsField);
|
|
26420
26531
|
}
|
|
26421
26532
|
|
|
26422
26533
|
if (fun.rest) {
|
|
@@ -26431,7 +26542,7 @@ function printFunctionParams(path$$1, print, options, expandArg, printTypeParams
|
|
|
26431
26542
|
}), ")"]);
|
|
26432
26543
|
}
|
|
26433
26544
|
|
|
26434
|
-
var lastParam = getLast$
|
|
26545
|
+
var lastParam = getLast$3(fun[paramsField]); // If the parent is a call with the first/last argument expansion and this is the
|
|
26435
26546
|
// params of the first/last argument, we dont want the arguments to break and instead
|
|
26436
26547
|
// want the whole expression to be on a new line.
|
|
26437
26548
|
//
|
|
@@ -26442,10 +26553,8 @@ function printFunctionParams(path$$1, print, options, expandArg, printTypeParams
|
|
|
26442
26553
|
// }) ) => {
|
|
26443
26554
|
// })
|
|
26444
26555
|
|
|
26445
|
-
if (
|
|
26446
|
-
return
|
|
26447
|
-
}))) {
|
|
26448
|
-
return group$1(concat$4([removeLines$1(typeParams), "(", join$2(", ", printed.map(removeLines$1)), ")"]));
|
|
26556
|
+
if (shouldExpandParameters) {
|
|
26557
|
+
return group$1(concat$4([removeLines$1(typeParams), "(", concat$4(printed.map(removeLines$1)), ")"]));
|
|
26449
26558
|
} // Single object destructuring should hug
|
|
26450
26559
|
//
|
|
26451
26560
|
// function({
|
|
@@ -26455,14 +26564,13 @@ function printFunctionParams(path$$1, print, options, expandArg, printTypeParams
|
|
|
26455
26564
|
// }) {}
|
|
26456
26565
|
|
|
26457
26566
|
|
|
26458
|
-
if (
|
|
26459
|
-
return concat$4([typeParams, "(",
|
|
26460
|
-
}
|
|
26567
|
+
if (shouldHugParameters) {
|
|
26568
|
+
return concat$4([typeParams, "(", concat$4(printed), ")"]);
|
|
26569
|
+
} // don't break in specs, eg; `it("should maintain parens around done even when long", (done) => {})`
|
|
26461
26570
|
|
|
26462
|
-
var parent = path$$1.getParentNode(); // don't break in specs, eg; `it("should maintain parens around done even when long", (done) => {})`
|
|
26463
26571
|
|
|
26464
|
-
if (
|
|
26465
|
-
return concat$4([typeParams, "(",
|
|
26572
|
+
if (isParametersInTestCall) {
|
|
26573
|
+
return concat$4([typeParams, "(", concat$4(printed), ")"]);
|
|
26466
26574
|
}
|
|
26467
26575
|
|
|
26468
26576
|
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;
|
|
@@ -26476,7 +26584,7 @@ function printFunctionParams(path$$1, print, options, expandArg, printTypeParams
|
|
|
26476
26584
|
}
|
|
26477
26585
|
|
|
26478
26586
|
var canHaveTrailingComma = !(lastParam && lastParam.type === "RestElement") && !fun.rest;
|
|
26479
|
-
return concat$4([typeParams, "(", indent$2(concat$4([softline$1,
|
|
26587
|
+
return concat$4([typeParams, "(", indent$2(concat$4([softline$1, concat$4(printed)])), ifBreak$1(canHaveTrailingComma && shouldPrintComma(options, "all") ? "," : ""), softline$1, ")"]);
|
|
26480
26588
|
}
|
|
26481
26589
|
|
|
26482
26590
|
function shouldPrintParamsWithoutParens(path$$1, options) {
|
|
@@ -26591,7 +26699,7 @@ function printExportDeclaration(path$$1, options, print) {
|
|
|
26591
26699
|
if (decl.declaration) {
|
|
26592
26700
|
parts.push(path$$1.call(print, "declaration"));
|
|
26593
26701
|
|
|
26594
|
-
if (isDefault && decl.declaration.type !== "ClassDeclaration" && decl.declaration.type !== "FunctionDeclaration" && decl.declaration.type !== "
|
|
26702
|
+
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") {
|
|
26595
26703
|
parts.push(semi);
|
|
26596
26704
|
}
|
|
26597
26705
|
} else {
|
|
@@ -26702,7 +26810,7 @@ function printClass(path$$1, options, print) {
|
|
|
26702
26810
|
var n = path$$1.getValue();
|
|
26703
26811
|
var parts = [];
|
|
26704
26812
|
|
|
26705
|
-
if (n.
|
|
26813
|
+
if (n.abstract) {
|
|
26706
26814
|
parts.push("abstract ");
|
|
26707
26815
|
}
|
|
26708
26816
|
|
|
@@ -27003,27 +27111,23 @@ function printMemberChain(path$$1, options, print) {
|
|
|
27003
27111
|
return firstNode.type === "ThisExpression" || firstNode.type === "Identifier" && (isFactory(firstNode.name) || isExpression && isShort(firstNode.name) || hasComputed);
|
|
27004
27112
|
}
|
|
27005
27113
|
|
|
27006
|
-
var lastNode = getLast$
|
|
27114
|
+
var lastNode = getLast$3(groups[0]).node;
|
|
27007
27115
|
return (lastNode.type === "MemberExpression" || lastNode.type === "OptionalMemberExpression") && lastNode.property.type === "Identifier" && (isFactory(lastNode.property.name) || hasComputed);
|
|
27008
27116
|
}
|
|
27009
27117
|
|
|
27010
27118
|
var shouldMerge = groups.length >= 2 && !groups[1][0].node.comments && shouldNotWrap(groups);
|
|
27011
27119
|
|
|
27012
27120
|
function printGroup(printedGroup) {
|
|
27013
|
-
var
|
|
27121
|
+
var printed = printedGroup.map(function (tuple) {
|
|
27122
|
+
return tuple.printed;
|
|
27123
|
+
}); // Checks if the last node (i.e. the parent node) needs parens and print
|
|
27124
|
+
// accordingly
|
|
27014
27125
|
|
|
27015
|
-
|
|
27016
|
-
|
|
27017
|
-
// and print accordingly
|
|
27018
|
-
if (printedGroup[_i3 + 1] && printedGroup[_i3 + 1].needsParens) {
|
|
27019
|
-
result.push("(", printedGroup[_i3].printed, printedGroup[_i3 + 1].printed, ")");
|
|
27020
|
-
_i3++;
|
|
27021
|
-
} else {
|
|
27022
|
-
result.push(printedGroup[_i3].printed);
|
|
27023
|
-
}
|
|
27126
|
+
if (printedGroup.length > 0 && printedGroup[printedGroup.length - 1].needsParens) {
|
|
27127
|
+
return concat$4(["("].concat(_toConsumableArray(printed), [")"]));
|
|
27024
27128
|
}
|
|
27025
27129
|
|
|
27026
|
-
return concat$4(
|
|
27130
|
+
return concat$4(printed);
|
|
27027
27131
|
}
|
|
27028
27132
|
|
|
27029
27133
|
function printIndentedGroup(groups) {
|
|
@@ -27053,7 +27157,7 @@ function printMemberChain(path$$1, options, print) {
|
|
|
27053
27157
|
// empty line after
|
|
27054
27158
|
|
|
27055
27159
|
|
|
27056
|
-
var lastNodeBeforeIndent = getLast$
|
|
27160
|
+
var lastNodeBeforeIndent = getLast$3(shouldMerge ? groups.slice(1, 2)[0] : groups[0]).node;
|
|
27057
27161
|
var shouldHaveEmptyLineBeforeIndent = lastNodeBeforeIndent.type !== "CallExpression" && lastNodeBeforeIndent.type !== "OptionalCallExpression" && shouldInsertEmptyLineAfter(lastNodeBeforeIndent);
|
|
27058
27162
|
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))]);
|
|
27059
27163
|
var callExpressions = printedNodes.map(function (_ref) {
|
|
@@ -27073,7 +27177,7 @@ function printMemberChain(path$$1, options, print) {
|
|
|
27073
27177
|
*/
|
|
27074
27178
|
function (lastGroupDoc, lastGroupNode) {
|
|
27075
27179
|
return isCallOrOptionalCallExpression(lastGroupNode) && willBreak$1(lastGroupDoc);
|
|
27076
|
-
}(getLast$
|
|
27180
|
+
}(getLast$3(printedGroups), getLast$3(getLast$3(groups)).node) && callExpressions.slice(0, -1).some(function (n) {
|
|
27077
27181
|
return n.arguments.some(isFunctionOrArrowExpression);
|
|
27078
27182
|
})) {
|
|
27079
27183
|
return group$1(expanded);
|
|
@@ -27284,7 +27388,7 @@ function printJSXChildren(path$$1, options, print, jsxWhitespace, isFacebookTran
|
|
|
27284
27388
|
|
|
27285
27389
|
var endWhitespace; // Ends with whitespace
|
|
27286
27390
|
|
|
27287
|
-
if (getLast$
|
|
27391
|
+
if (getLast$3(words) === "") {
|
|
27288
27392
|
words.pop();
|
|
27289
27393
|
endWhitespace = words.pop();
|
|
27290
27394
|
} // This was whitespace only without a new line.
|
|
@@ -27305,13 +27409,13 @@ function printJSXChildren(path$$1, options, print, jsxWhitespace, isFacebookTran
|
|
|
27305
27409
|
if (endWhitespace !== undefined) {
|
|
27306
27410
|
if (/\n/.test(endWhitespace)) {
|
|
27307
27411
|
var _next = n.children[i + 1];
|
|
27308
|
-
children.push(separatorWithWhitespace(isFacebookTranslationTag, getLast$
|
|
27412
|
+
children.push(separatorWithWhitespace(isFacebookTranslationTag, getLast$3(children), child, _next));
|
|
27309
27413
|
} else {
|
|
27310
27414
|
children.push(jsxWhitespace);
|
|
27311
27415
|
}
|
|
27312
27416
|
} else {
|
|
27313
27417
|
var _next2 = n.children[i + 1];
|
|
27314
|
-
children.push(separatorNoWhitespace(isFacebookTranslationTag, getLast$
|
|
27418
|
+
children.push(separatorNoWhitespace(isFacebookTranslationTag, getLast$3(children), child, _next2));
|
|
27315
27419
|
}
|
|
27316
27420
|
} else if (/\n/.test(text)) {
|
|
27317
27421
|
// Keep (up to one) blank line between tags/expressions/text.
|
|
@@ -27420,7 +27524,7 @@ function printJSXElement(path$$1, options, print) {
|
|
|
27420
27524
|
} // Trim trailing lines (or empty strings)
|
|
27421
27525
|
|
|
27422
27526
|
|
|
27423
|
-
while (children.length && (isLineNext$1(getLast$
|
|
27527
|
+
while (children.length && (isLineNext$1(getLast$3(children)) || isEmpty$1(getLast$3(children)))) {
|
|
27424
27528
|
children.pop();
|
|
27425
27529
|
} // Trim leading lines (or empty strings)
|
|
27426
27530
|
|
|
@@ -27967,7 +28071,7 @@ function needsHardlineAfterDanglingComment(node) {
|
|
|
27967
28071
|
return false;
|
|
27968
28072
|
}
|
|
27969
28073
|
|
|
27970
|
-
var lastDanglingComment = getLast$
|
|
28074
|
+
var lastDanglingComment = getLast$3(node.comments.filter(function (comment) {
|
|
27971
28075
|
return !comment.leading && !comment.trailing;
|
|
27972
28076
|
}));
|
|
27973
28077
|
return lastDanglingComment && !comments$3.isBlockComment(lastDanglingComment);
|
|
@@ -27977,6 +28081,10 @@ function isLiteral(node) {
|
|
|
27977
28081
|
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";
|
|
27978
28082
|
}
|
|
27979
28083
|
|
|
28084
|
+
function isStringPropSafeToCoerceToIdentifier(node, options) {
|
|
28085
|
+
return isStringLiteral(node.key) && isIdentifierName(node.key.value) && !node.computed && options.parser !== "json" && !(options.parser === "typescript" && node.type === "ClassProperty");
|
|
28086
|
+
}
|
|
28087
|
+
|
|
27980
28088
|
function isNumericLiteral(node) {
|
|
27981
28089
|
return node.type === "NumericLiteral" || node.type === "Literal" && typeof node.value === "number";
|
|
27982
28090
|
}
|
|
@@ -28067,7 +28175,7 @@ function willPrintOwnComments(path$$1) {
|
|
|
28067
28175
|
}
|
|
28068
28176
|
|
|
28069
28177
|
function canAttachComment(node) {
|
|
28070
|
-
return node.type && node.type !== "CommentBlock" && node.type !== "CommentLine" && node.type !== "Line" && node.type !== "Block" && node.type !== "EmptyStatement" && node.type !== "TemplateElement" && node.type !== "Import"
|
|
28178
|
+
return node.type && node.type !== "CommentBlock" && node.type !== "CommentLine" && node.type !== "Line" && node.type !== "Block" && node.type !== "EmptyStatement" && node.type !== "TemplateElement" && node.type !== "Import";
|
|
28071
28179
|
}
|
|
28072
28180
|
|
|
28073
28181
|
function printComment$1(commentPath, options) {
|
|
@@ -28319,6 +28427,23 @@ var options$4 = {
|
|
|
28319
28427
|
default: false,
|
|
28320
28428
|
description: "Use single quotes in JSX."
|
|
28321
28429
|
},
|
|
28430
|
+
quoteProps: {
|
|
28431
|
+
since: "1.17.0",
|
|
28432
|
+
category: CATEGORY_JAVASCRIPT,
|
|
28433
|
+
type: "choice",
|
|
28434
|
+
default: "as-needed",
|
|
28435
|
+
description: "Change when properties in objects are quoted.",
|
|
28436
|
+
choices: [{
|
|
28437
|
+
value: "as-needed",
|
|
28438
|
+
description: "Only add quotes around object properties where required."
|
|
28439
|
+
}, {
|
|
28440
|
+
value: "consistent",
|
|
28441
|
+
description: "If at least one property in an object requires quotes, quote all properties."
|
|
28442
|
+
}, {
|
|
28443
|
+
value: "preserve",
|
|
28444
|
+
description: "Respect the input use of quotes in object properties."
|
|
28445
|
+
}]
|
|
28446
|
+
},
|
|
28322
28447
|
trailingComma: {
|
|
28323
28448
|
since: "0.0.0",
|
|
28324
28449
|
category: CATEGORY_JAVASCRIPT,
|
|
@@ -30472,7 +30597,7 @@ function genericPrint$3(path$$1, options, print) {
|
|
|
30472
30597
|
|
|
30473
30598
|
case "FragmentDefinition":
|
|
30474
30599
|
{
|
|
30475
|
-
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")]);
|
|
30600
|
+
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")]);
|
|
30476
30601
|
}
|
|
30477
30602
|
|
|
30478
30603
|
case "SelectionSet":
|
|
@@ -30555,7 +30680,7 @@ function genericPrint$3(path$$1, options, print) {
|
|
|
30555
30680
|
|
|
30556
30681
|
case "VariableDefinition":
|
|
30557
30682
|
{
|
|
30558
|
-
return concat$11([path$$1.call(print, "variable"), ": ", path$$1.call(print, "type"), n.defaultValue ? concat$11([" = ", path$$1.call(print, "defaultValue")]) : ""]);
|
|
30683
|
+
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)]);
|
|
30559
30684
|
}
|
|
30560
30685
|
|
|
30561
30686
|
case "TypeExtensionDefinition":
|
|
@@ -30788,7 +30913,7 @@ var json$6 = {"cjkPattern":"[\\u02ea-\\u02eb\\u1100-\\u11ff\\u2e80-\\u2e99\\u2e9
|
|
|
30788
30913
|
var cjkPattern = json$6.cjkPattern;
|
|
30789
30914
|
var kPattern = json$6.kPattern;
|
|
30790
30915
|
var punctuationPattern$1 = json$6.punctuationPattern;
|
|
30791
|
-
var getLast$
|
|
30916
|
+
var getLast$4 = util$1.getLast;
|
|
30792
30917
|
var INLINE_NODE_TYPES$1 = ["liquidNode", "inlineCode", "emphasis", "strong", "delete", "link", "linkReference", "image", "imageReference", "footnote", "footnoteReference", "sentence", "whitespace", "word", "break", "inlineMath"];
|
|
30793
30918
|
var INLINE_NODE_WRAPPER_TYPES$1 = INLINE_NODE_TYPES$1.concat(["tableCell", "paragraph", "heading"]);
|
|
30794
30919
|
var kRegex = new RegExp(kPattern);
|
|
@@ -30833,7 +30958,7 @@ function splitText$1(text, options) {
|
|
|
30833
30958
|
value: innerToken,
|
|
30834
30959
|
kind: KIND_NON_CJK,
|
|
30835
30960
|
hasLeadingPunctuation: punctuationRegex.test(innerToken[0]),
|
|
30836
|
-
hasTrailingPunctuation: punctuationRegex.test(getLast$
|
|
30961
|
+
hasTrailingPunctuation: punctuationRegex.test(getLast$4(innerToken))
|
|
30837
30962
|
});
|
|
30838
30963
|
}
|
|
30839
30964
|
|
|
@@ -30859,7 +30984,7 @@ function splitText$1(text, options) {
|
|
|
30859
30984
|
return nodes;
|
|
30860
30985
|
|
|
30861
30986
|
function appendNode(node) {
|
|
30862
|
-
var lastNode = getLast$
|
|
30987
|
+
var lastNode = getLast$4(nodes);
|
|
30863
30988
|
|
|
30864
30989
|
if (lastNode && lastNode.type === "word") {
|
|
30865
30990
|
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) {
|
|
@@ -31321,6 +31446,7 @@ function markAlignedList(ast, options) {
|
|
|
31321
31446
|
var preprocess_1$2 = preprocess$2;
|
|
31322
31447
|
|
|
31323
31448
|
var _require$$0$builders$6 = doc.builders;
|
|
31449
|
+
var breakParent$3 = _require$$0$builders$6.breakParent;
|
|
31324
31450
|
var concat$12 = _require$$0$builders$6.concat;
|
|
31325
31451
|
var join$9 = _require$$0$builders$6.join;
|
|
31326
31452
|
var line$8 = _require$$0$builders$6.line;
|
|
@@ -31328,6 +31454,7 @@ var literalline$4 = _require$$0$builders$6.literalline;
|
|
|
31328
31454
|
var markAsRoot$2 = _require$$0$builders$6.markAsRoot;
|
|
31329
31455
|
var hardline$10 = _require$$0$builders$6.hardline;
|
|
31330
31456
|
var softline$6 = _require$$0$builders$6.softline;
|
|
31457
|
+
var ifBreak$5 = _require$$0$builders$6.ifBreak;
|
|
31331
31458
|
var fill$4 = _require$$0$builders$6.fill;
|
|
31332
31459
|
var align$2 = _require$$0$builders$6.align;
|
|
31333
31460
|
var indent$8 = _require$$0$builders$6.indent;
|
|
@@ -31680,6 +31807,7 @@ function printLine(path$$1, value, options) {
|
|
|
31680
31807
|
}
|
|
31681
31808
|
|
|
31682
31809
|
function printTable(path$$1, options, print) {
|
|
31810
|
+
var hardlineWithoutBreakParent = hardline$10.parts[0];
|
|
31683
31811
|
var node = path$$1.getValue();
|
|
31684
31812
|
var contents = []; // { [rowIndex: number]: { [columnIndex: number]: string } }
|
|
31685
31813
|
|
|
@@ -31689,7 +31817,8 @@ function printTable(path$$1, options, print) {
|
|
|
31689
31817
|
rowContents.push(printDocToString$3(cellPath.call(print), options).formatted);
|
|
31690
31818
|
}, "children");
|
|
31691
31819
|
contents.push(rowContents);
|
|
31692
|
-
}, "children");
|
|
31820
|
+
}, "children"); // Get the width of each column
|
|
31821
|
+
|
|
31693
31822
|
var columnMaxWidths = contents.reduce(function (currentWidths, rowContents) {
|
|
31694
31823
|
return currentWidths.map(function (width, columnIndex) {
|
|
31695
31824
|
return Math.max(width, util$1.getStringWidth(rowContents[columnIndex]));
|
|
@@ -31698,28 +31827,48 @@ function printTable(path$$1, options, print) {
|
|
|
31698
31827
|
return 3;
|
|
31699
31828
|
}) // minimum width = 3 (---, :--, :-:, --:)
|
|
31700
31829
|
);
|
|
31701
|
-
|
|
31702
|
-
|
|
31703
|
-
|
|
31830
|
+
var alignedTable = join$9(hardlineWithoutBreakParent, [printRow(contents[0]), printSeparator(), join$9(hardlineWithoutBreakParent, contents.slice(1).map(function (rowContents) {
|
|
31831
|
+
return printRow(rowContents);
|
|
31832
|
+
}))]);
|
|
31833
|
+
|
|
31834
|
+
if (options.proseWrap !== "never") {
|
|
31835
|
+
return concat$12([breakParent$3, alignedTable]);
|
|
31836
|
+
} // Only if the --prose-wrap never is set and it exceeds the print width.
|
|
31837
|
+
|
|
31838
|
+
|
|
31839
|
+
var compactTable = join$9(hardlineWithoutBreakParent, [printRow(contents[0],
|
|
31840
|
+
/* isCompact */
|
|
31841
|
+
true), printSeparator(
|
|
31842
|
+
/* isCompact */
|
|
31843
|
+
true), join$9(hardlineWithoutBreakParent, contents.slice(1).map(function (rowContents) {
|
|
31844
|
+
return printRow(rowContents,
|
|
31845
|
+
/* isCompact */
|
|
31846
|
+
true);
|
|
31847
|
+
}))]);
|
|
31848
|
+
return concat$12([breakParent$3, group$13(ifBreak$5(compactTable, alignedTable))]);
|
|
31849
|
+
|
|
31850
|
+
function printSeparator(isCompact) {
|
|
31704
31851
|
return concat$12(["| ", join$9(" | ", columnMaxWidths.map(function (width, index) {
|
|
31852
|
+
var spaces = isCompact ? 3 : width;
|
|
31853
|
+
|
|
31705
31854
|
switch (node.align[index]) {
|
|
31706
31855
|
case "left":
|
|
31707
|
-
return ":" + "-".repeat(
|
|
31856
|
+
return ":" + "-".repeat(spaces - 1);
|
|
31708
31857
|
|
|
31709
31858
|
case "right":
|
|
31710
|
-
return "-".repeat(
|
|
31859
|
+
return "-".repeat(spaces - 1) + ":";
|
|
31711
31860
|
|
|
31712
31861
|
case "center":
|
|
31713
|
-
return ":" + "-".repeat(
|
|
31862
|
+
return ":" + "-".repeat(spaces - 2) + ":";
|
|
31714
31863
|
|
|
31715
31864
|
default:
|
|
31716
|
-
return "-".repeat(
|
|
31865
|
+
return "-".repeat(spaces);
|
|
31717
31866
|
}
|
|
31718
31867
|
})), " |"]);
|
|
31719
31868
|
}
|
|
31720
31869
|
|
|
31721
|
-
function printRow(rowContents) {
|
|
31722
|
-
return concat$12(["| ", join$9(" | ", rowContents.map(function (rowContent, columnIndex) {
|
|
31870
|
+
function printRow(rowContents, isCompact) {
|
|
31871
|
+
return concat$12(["| ", join$9(" | ", isCompact ? rowContents : rowContents.map(function (rowContent, columnIndex) {
|
|
31723
31872
|
switch (node.align[columnIndex]) {
|
|
31724
31873
|
case "right":
|
|
31725
31874
|
return alignRight(rowContent, columnMaxWidths[columnIndex]);
|
|
@@ -31734,11 +31883,13 @@ function printTable(path$$1, options, print) {
|
|
|
31734
31883
|
}
|
|
31735
31884
|
|
|
31736
31885
|
function alignLeft(text, width) {
|
|
31737
|
-
|
|
31886
|
+
var spaces = width - util$1.getStringWidth(text);
|
|
31887
|
+
return concat$12([text, " ".repeat(spaces)]);
|
|
31738
31888
|
}
|
|
31739
31889
|
|
|
31740
31890
|
function alignRight(text, width) {
|
|
31741
|
-
|
|
31891
|
+
var spaces = width - util$1.getStringWidth(text);
|
|
31892
|
+
return concat$12([" ".repeat(spaces), text]);
|
|
31742
31893
|
}
|
|
31743
31894
|
|
|
31744
31895
|
function alignCenter(text, width) {
|
|
@@ -33763,7 +33914,7 @@ var parseSrcset = createCommonjsModule(function (module) {
|
|
|
33763
33914
|
|
|
33764
33915
|
var _require$$0$builders$9 = doc.builders;
|
|
33765
33916
|
var concat$16 = _require$$0$builders$9.concat;
|
|
33766
|
-
var ifBreak$
|
|
33917
|
+
var ifBreak$7 = _require$$0$builders$9.ifBreak;
|
|
33767
33918
|
var join$11 = _require$$0$builders$9.join;
|
|
33768
33919
|
var line$10 = _require$$0$builders$9.line;
|
|
33769
33920
|
|
|
@@ -33821,7 +33972,7 @@ function printImgSrcset$1(value) {
|
|
|
33821
33972
|
var urlPadding = maxUrlLength - url.length + 1;
|
|
33822
33973
|
var descriptorPadding = maxDescriptorLeftLength - descriptorLeftLengths[index];
|
|
33823
33974
|
var alignment = " ".repeat(urlPadding + descriptorPadding);
|
|
33824
|
-
parts.push(ifBreak$
|
|
33975
|
+
parts.push(ifBreak$7(alignment, " "), descriptor + unit);
|
|
33825
33976
|
}
|
|
33826
33977
|
|
|
33827
33978
|
return concat$16(parts);
|
|
@@ -33836,12 +33987,12 @@ var builders = doc.builders;
|
|
|
33836
33987
|
var _require$$0$utils = doc.utils;
|
|
33837
33988
|
var stripTrailingHardline$2 = _require$$0$utils.stripTrailingHardline;
|
|
33838
33989
|
var mapDoc$7 = _require$$0$utils.mapDoc;
|
|
33839
|
-
var breakParent$
|
|
33990
|
+
var breakParent$4 = builders.breakParent;
|
|
33840
33991
|
var dedentToRoot$2 = builders.dedentToRoot;
|
|
33841
33992
|
var fill$5 = builders.fill;
|
|
33842
33993
|
var group$14 = builders.group;
|
|
33843
33994
|
var hardline$12 = builders.hardline;
|
|
33844
|
-
var ifBreak$
|
|
33995
|
+
var ifBreak$6 = builders.ifBreak;
|
|
33845
33996
|
var indent$9 = builders.indent;
|
|
33846
33997
|
var join$10 = builders.join;
|
|
33847
33998
|
var line$9 = builders.line;
|
|
@@ -33888,7 +34039,7 @@ function embed$6(path$$1, print, textToDoc, options) {
|
|
|
33888
34039
|
|
|
33889
34040
|
if (parser) {
|
|
33890
34041
|
var value = parser === "markdown" ? dedentString(node.value.replace(/^[^\S\n]*?\n/, "")) : node.value;
|
|
33891
|
-
return builders.concat([concat$14([breakParent$
|
|
34042
|
+
return builders.concat([concat$14([breakParent$4, printOpeningTagPrefix(node, options), stripTrailingHardline$2(textToDoc(value, {
|
|
33892
34043
|
parser
|
|
33893
34044
|
})), printClosingTagSuffix(node, options)])]);
|
|
33894
34045
|
}
|
|
@@ -33918,6 +34069,15 @@ function embed$6(path$$1, print, textToDoc, options) {
|
|
|
33918
34069
|
|
|
33919
34070
|
if (/^PRETTIER_HTML_PLACEHOLDER_\d+_IN_JS$/.test(options.originalText.slice(node.valueSpan.start.offset, node.valueSpan.end.offset))) {
|
|
33920
34071
|
return concat$14([node.rawName, "=", node.value]);
|
|
34072
|
+
} // lwc: html`<my-element data-for={value}></my-elememt>`
|
|
34073
|
+
|
|
34074
|
+
|
|
34075
|
+
if (options.parser === "lwc") {
|
|
34076
|
+
var interpolationRegex = /^\{[\s\S]*\}$/;
|
|
34077
|
+
|
|
34078
|
+
if (interpolationRegex.test(options.originalText.slice(node.valueSpan.start.offset, node.valueSpan.end.offset))) {
|
|
34079
|
+
return concat$14([node.rawName, "=", node.value]);
|
|
34080
|
+
}
|
|
33921
34081
|
}
|
|
33922
34082
|
|
|
33923
34083
|
var embeddedAttributeValueDoc = printEmbeddedAttributeValue(node, function (code, opts) {
|
|
@@ -33979,13 +34139,13 @@ function genericPrint$5(path$$1, options, print) {
|
|
|
33979
34139
|
var attrGroupId = Symbol("element-attr-group-id");
|
|
33980
34140
|
return concat$14([group$14(concat$14([group$14(printOpeningTag(path$$1, options, print), {
|
|
33981
34141
|
id: attrGroupId
|
|
33982
|
-
}), node.children.length === 0 ? node.hasDanglingSpaces && node.isDanglingSpaceSensitive ? line$9 : "" : concat$14([forceBreakContent(node) ? breakParent$
|
|
33983
|
-
return shouldHugContent ? ifBreak$
|
|
34142
|
+
}), node.children.length === 0 ? node.hasDanglingSpaces && node.isDanglingSpaceSensitive ? line$9 : "" : concat$14([forceBreakContent(node) ? breakParent$4 : "", function (childrenDoc) {
|
|
34143
|
+
return shouldHugContent ? ifBreak$6(indent$9(childrenDoc), childrenDoc, {
|
|
33984
34144
|
groupId: attrGroupId
|
|
33985
34145
|
}) : isScriptLikeTag(node) && node.parent.type === "root" && options.parser === "vue" ? childrenDoc : indent$9(childrenDoc);
|
|
33986
|
-
}(concat$14([shouldHugContent ? ifBreak$
|
|
34146
|
+
}(concat$14([shouldHugContent ? ifBreak$6(softline$7, "", {
|
|
33987
34147
|
groupId: attrGroupId
|
|
33988
|
-
}) : 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$
|
|
34148
|
+
}) : 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, "", {
|
|
33989
34149
|
groupId: attrGroupId
|
|
33990
34150
|
}) : 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) {
|
|
33991
34151
|
return n.parent && n.parent.type !== "root";
|
|
@@ -34056,7 +34216,7 @@ function printChildren$1(path$$1, options, print) {
|
|
|
34056
34216
|
var node = path$$1.getValue();
|
|
34057
34217
|
|
|
34058
34218
|
if (forceBreakChildren(node)) {
|
|
34059
|
-
return concat$14([breakParent$
|
|
34219
|
+
return concat$14([breakParent$4, concat$14(path$$1.map(function (childPath) {
|
|
34060
34220
|
var childNode = childPath.getValue();
|
|
34061
34221
|
var prevBetweenLine = !childNode.prev ? "" : printBetweenLine(childNode.prev, childNode);
|
|
34062
34222
|
return concat$14([!prevBetweenLine ? "" : concat$14([prevBetweenLine, forceNextEmptyLine(childNode.prev) ? hardline$12 : ""]), printChild(childPath)]);
|
|
@@ -34101,7 +34261,7 @@ function printChildren$1(path$$1, options, print) {
|
|
|
34101
34261
|
if (isTextLikeNode(childNode.prev)) {
|
|
34102
34262
|
leadingParts.push(prevBetweenLine);
|
|
34103
34263
|
} else {
|
|
34104
|
-
leadingParts.push(ifBreak$
|
|
34264
|
+
leadingParts.push(ifBreak$6("", softline$7, {
|
|
34105
34265
|
groupId: groupIds[childIndex - 1]
|
|
34106
34266
|
}));
|
|
34107
34267
|
}
|
|
@@ -34407,8 +34567,8 @@ function printClosingTagEndMarker(node, options) {
|
|
|
34407
34567
|
|
|
34408
34568
|
function getTextValueParts(node) {
|
|
34409
34569
|
var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : node.value;
|
|
34410
|
-
return node.parent.isWhitespaceSensitive ? node.parent.isIndentationSensitive ? replaceEndOfLineWith$2(value, literalline$6) : replaceEndOfLineWith$2(dedentString(value.replace(/^\s*?\n|\n\s*?$/g, "")), hardline$12) : //
|
|
34411
|
-
join$10(line$9, value.split(/[
|
|
34570
|
+
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
|
|
34571
|
+
join$10(line$9, value.split(/[\t\n\f\r ]+/)).parts;
|
|
34412
34572
|
}
|
|
34413
34573
|
|
|
34414
34574
|
function printEmbeddedAttributeValue(node, originalTextToDoc, options) {
|
|
@@ -34698,6 +34858,15 @@ var languages$5 = [createLanguage(require$$0$31, {
|
|
|
34698
34858
|
extensions: [".mjml" // MJML is considered XML in Linguist but it should be formatted as HTML
|
|
34699
34859
|
]
|
|
34700
34860
|
}
|
|
34861
|
+
}), createLanguage(require$$0$31, {
|
|
34862
|
+
override: {
|
|
34863
|
+
name: "Lightning Web Components",
|
|
34864
|
+
since: "1.17.0",
|
|
34865
|
+
parsers: ["lwc"],
|
|
34866
|
+
vscodeLanguageIds: ["html"],
|
|
34867
|
+
extensions: [],
|
|
34868
|
+
filenames: []
|
|
34869
|
+
}
|
|
34701
34870
|
}), createLanguage(require$$1$11, {
|
|
34702
34871
|
override: {
|
|
34703
34872
|
since: "1.10.0",
|
|
@@ -34732,7 +34901,7 @@ var pragma$11 = {
|
|
|
34732
34901
|
insertPragma: insertPragma$9
|
|
34733
34902
|
};
|
|
34734
34903
|
|
|
34735
|
-
var getLast$
|
|
34904
|
+
var getLast$6 = util$1.getLast;
|
|
34736
34905
|
|
|
34737
34906
|
function getAncestorCount$1(path$$1, filter) {
|
|
34738
34907
|
var counter = 0;
|
|
@@ -34821,7 +34990,7 @@ function isLastDescendantNode$1(path$$1) {
|
|
|
34821
34990
|
}
|
|
34822
34991
|
|
|
34823
34992
|
function getLastDescendantNode$2(node) {
|
|
34824
|
-
return "children" in node && node.children.length !== 0 ? getLastDescendantNode$2(getLast$
|
|
34993
|
+
return "children" in node && node.children.length !== 0 ? getLastDescendantNode$2(getLast$6(node.children)) : node;
|
|
34825
34994
|
}
|
|
34826
34995
|
|
|
34827
34996
|
function isPrettierIgnore$2(comment) {
|
|
@@ -34833,10 +35002,10 @@ function hasPrettierIgnore$5(path$$1) {
|
|
|
34833
35002
|
|
|
34834
35003
|
if (node.type === "documentBody") {
|
|
34835
35004
|
var document = path$$1.getParentNode();
|
|
34836
|
-
return hasEndComments$1(document.head) && isPrettierIgnore$2(getLast$
|
|
35005
|
+
return hasEndComments$1(document.head) && isPrettierIgnore$2(getLast$6(document.head.endComments));
|
|
34837
35006
|
}
|
|
34838
35007
|
|
|
34839
|
-
return hasLeadingComments$1(node) && isPrettierIgnore$2(getLast$
|
|
35008
|
+
return hasLeadingComments$1(node) && isPrettierIgnore$2(getLast$6(node.leadingComments));
|
|
34840
35009
|
}
|
|
34841
35010
|
|
|
34842
35011
|
function isEmptyNode$1(node) {
|
|
@@ -34936,7 +35105,7 @@ function getFlowScalarLineContents$1(nodeType, content, options) {
|
|
|
34936
35105
|
return lineContent.length === 0 ? [] : splitWithSingleSpace(lineContent);
|
|
34937
35106
|
}).reduce(function (reduced, lineContentWords, index) {
|
|
34938
35107
|
return index !== 0 && rawLineContents[index - 1].length !== 0 && lineContentWords.length !== 0 && !( // trailing backslash in quoteDouble should be preserved
|
|
34939
|
-
nodeType === "quoteDouble" && getLast$
|
|
35108
|
+
nodeType === "quoteDouble" && getLast$6(getLast$6(reduced)).endsWith("\\")) ? reduced.concat([reduced.pop().concat(lineContentWords)]) : reduced.concat([lineContentWords]);
|
|
34940
35109
|
}, []).map(function (lineContentWords) {
|
|
34941
35110
|
return options.proseWrap === "never" ? [lineContentWords.join(" ")] : lineContentWords;
|
|
34942
35111
|
});
|
|
@@ -34964,11 +35133,11 @@ function getBlockValueLineContents$1(node, _ref) {
|
|
|
34964
35133
|
return removeUnnecessaryTrailingNewlines(rawLineContents.map(function (lineContent) {
|
|
34965
35134
|
return lineContent.length === 0 ? [] : splitWithSingleSpace(lineContent);
|
|
34966
35135
|
}).reduce(function (reduced, lineContentWords, index) {
|
|
34967
|
-
return index !== 0 && rawLineContents[index - 1].length !== 0 && lineContentWords.length !== 0 && !/^\s/.test(lineContentWords[0]) && !/^\s|\s$/.test(getLast$
|
|
35136
|
+
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]);
|
|
34968
35137
|
}, []).map(function (lineContentWords) {
|
|
34969
35138
|
return lineContentWords.reduce(function (reduced, word) {
|
|
34970
35139
|
return (// disallow trailing spaces
|
|
34971
|
-
reduced.length !== 0 && /\s$/.test(getLast$
|
|
35140
|
+
reduced.length !== 0 && /\s$/.test(getLast$6(reduced)) ? reduced.concat(reduced.pop() + " " + word) : reduced.concat(word)
|
|
34972
35141
|
);
|
|
34973
35142
|
}, []);
|
|
34974
35143
|
}).map(function (lineContentWords) {
|
|
@@ -34977,7 +35146,7 @@ function getBlockValueLineContents$1(node, _ref) {
|
|
|
34977
35146
|
|
|
34978
35147
|
function removeUnnecessaryTrailingNewlines(lineContents) {
|
|
34979
35148
|
if (node.chomping === "keep") {
|
|
34980
|
-
return getLast$
|
|
35149
|
+
return getLast$6(lineContents).length === 0 ? lineContents.slice(0, -1) : lineContents;
|
|
34981
35150
|
}
|
|
34982
35151
|
|
|
34983
35152
|
var trailingNewlineCount = 0;
|
|
@@ -34996,7 +35165,7 @@ function getBlockValueLineContents$1(node, _ref) {
|
|
|
34996
35165
|
}
|
|
34997
35166
|
|
|
34998
35167
|
var utils$12 = {
|
|
34999
|
-
getLast: getLast$
|
|
35168
|
+
getLast: getLast$6,
|
|
35000
35169
|
getAncestorCount: getAncestorCount$1,
|
|
35001
35170
|
isNode: isNode$2,
|
|
35002
35171
|
isEmptyNode: isEmptyNode$1,
|
|
@@ -35020,7 +35189,7 @@ var isPragma = pragma$11.isPragma;
|
|
|
35020
35189
|
var getAncestorCount = utils$12.getAncestorCount;
|
|
35021
35190
|
var getBlockValueLineContents = utils$12.getBlockValueLineContents;
|
|
35022
35191
|
var getFlowScalarLineContents = utils$12.getFlowScalarLineContents;
|
|
35023
|
-
var getLast$
|
|
35192
|
+
var getLast$5 = utils$12.getLast;
|
|
35024
35193
|
var getLastDescendantNode$1 = utils$12.getLastDescendantNode;
|
|
35025
35194
|
var hasLeadingComments = utils$12.hasLeadingComments;
|
|
35026
35195
|
var hasMiddleComments = utils$12.hasMiddleComments;
|
|
@@ -35036,14 +35205,14 @@ var defineShortcut = utils$12.defineShortcut;
|
|
|
35036
35205
|
var mapNode = utils$12.mapNode;
|
|
35037
35206
|
var docBuilders$3 = doc.builders;
|
|
35038
35207
|
var conditionalGroup$2 = docBuilders$3.conditionalGroup;
|
|
35039
|
-
var breakParent$
|
|
35208
|
+
var breakParent$5 = docBuilders$3.breakParent;
|
|
35040
35209
|
var concat$17 = docBuilders$3.concat;
|
|
35041
35210
|
var dedent$4 = docBuilders$3.dedent;
|
|
35042
35211
|
var dedentToRoot$3 = docBuilders$3.dedentToRoot;
|
|
35043
35212
|
var fill$6 = docBuilders$3.fill;
|
|
35044
35213
|
var group$16 = docBuilders$3.group;
|
|
35045
35214
|
var hardline$13 = docBuilders$3.hardline;
|
|
35046
|
-
var ifBreak$
|
|
35215
|
+
var ifBreak$8 = docBuilders$3.ifBreak;
|
|
35047
35216
|
var join$12 = docBuilders$3.join;
|
|
35048
35217
|
var line$11 = docBuilders$3.line;
|
|
35049
35218
|
var lineSuffix$2 = docBuilders$3.lineSuffix;
|
|
@@ -35097,7 +35266,7 @@ function genericPrint$6(path$$1, options, print) {
|
|
|
35097
35266
|
var tag = !node.tag ? "" : path$$1.call(print, "tag");
|
|
35098
35267
|
var anchor = !node.anchor ? "" : path$$1.call(print, "anchor");
|
|
35099
35268
|
var nextEmptyLine = isNode$1(node, ["mapping", "sequence", "comment", "directive", "mappingItem", "sequenceItem"]) && !isLastDescendantNode(path$$1) ? printNextEmptyLine(path$$1, options.originalText) : "";
|
|
35100
|
-
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$
|
|
35269
|
+
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"))])) : ""]);
|
|
35101
35270
|
}
|
|
35102
35271
|
|
|
35103
35272
|
function _print(node, parentNode, path$$1, options, print) {
|
|
@@ -35233,9 +35402,9 @@ function _print(node, parentNode, path$$1, options, print) {
|
|
|
35233
35402
|
return forceExplicitKey ? concat$17(["? ", align$3(2, key), hardline$13, join$12("", path$$1.map(print, "value", "leadingComments").map(function (comment) {
|
|
35234
35403
|
return concat$17([comment, hardline$13]);
|
|
35235
35404
|
})), ": ", align$3(2, value)]) : // force singleline
|
|
35236
|
-
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$
|
|
35405
|
+
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), {
|
|
35237
35406
|
id: groupId
|
|
35238
|
-
})])), ifBreak$
|
|
35407
|
+
})])), 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])), {
|
|
35239
35408
|
groupId
|
|
35240
35409
|
})])]);
|
|
35241
35410
|
}
|
|
@@ -35249,11 +35418,11 @@ function _print(node, parentNode, path$$1, options, print) {
|
|
|
35249
35418
|
|
|
35250
35419
|
var isLastItemEmptyMappingItem = node.children.length !== 0 && function (lastItem) {
|
|
35251
35420
|
return lastItem.type === "flowMappingItem" && isEmptyNode(lastItem.key) && isEmptyNode(lastItem.value);
|
|
35252
|
-
}(getLast$
|
|
35421
|
+
}(getLast$5(node.children));
|
|
35253
35422
|
|
|
35254
35423
|
return concat$17([openMarker, indent(concat$17([bracketSpacing, concat$17(path$$1.map(function (childPath, index) {
|
|
35255
35424
|
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) : ""])]);
|
|
35256
|
-
}, "children")), ifBreak$
|
|
35425
|
+
}, "children")), ifBreak$8(",", "")])), isLastItemEmptyMappingItem ? "" : bracketSpacing, closeMarker]);
|
|
35257
35426
|
}
|
|
35258
35427
|
|
|
35259
35428
|
case "flowSequenceItem":
|
|
@@ -35671,6 +35840,11 @@ languageMarkdown, {
|
|
|
35671
35840
|
// Angular
|
|
35672
35841
|
get angular() {
|
|
35673
35842
|
return require("./parser-html").parsers.angular;
|
|
35843
|
+
},
|
|
35844
|
+
|
|
35845
|
+
// Lightning Web Components
|
|
35846
|
+
get lwc() {
|
|
35847
|
+
return require("./parser-html").parsers.lwc;
|
|
35674
35848
|
}
|
|
35675
35849
|
|
|
35676
35850
|
}
|
|
@@ -35744,12 +35918,14 @@ function loadPlugins(plugins, pluginSearchDirs) {
|
|
|
35744
35918
|
});
|
|
35745
35919
|
var externalAutoLoadPluginInfos = pluginSearchDirs.map(function (pluginSearchDir) {
|
|
35746
35920
|
var resolvedPluginSearchDir = path.resolve(process.cwd(), pluginSearchDir);
|
|
35921
|
+
var nodeModulesDir = path.resolve(resolvedPluginSearchDir, "node_modules"); // In some fringe cases (ex: files "mounted" as virtual directories), the
|
|
35922
|
+
// isDirectory(resolvedPluginSearchDir) check might be false even though
|
|
35923
|
+
// the node_modules actually exists.
|
|
35747
35924
|
|
|
35748
|
-
if (!isDirectory(resolvedPluginSearchDir)) {
|
|
35925
|
+
if (!isDirectory(nodeModulesDir) && !isDirectory(resolvedPluginSearchDir)) {
|
|
35749
35926
|
throw new Error(`${pluginSearchDir} does not exist or is not a directory`);
|
|
35750
35927
|
}
|
|
35751
35928
|
|
|
35752
|
-
var nodeModulesDir = path.resolve(resolvedPluginSearchDir, "node_modules");
|
|
35753
35929
|
return findPluginsInNodeModules(nodeModulesDir).map(function (pluginName) {
|
|
35754
35930
|
return {
|
|
35755
35931
|
name: pluginName,
|
|
@@ -35770,7 +35946,7 @@ function loadPlugins(plugins, pluginSearchDirs) {
|
|
|
35770
35946
|
}
|
|
35771
35947
|
|
|
35772
35948
|
function findPluginsInNodeModules(nodeModulesDir) {
|
|
35773
|
-
var pluginPackageJsonPaths = globby.sync(["prettier-plugin-*/package.json", "@prettier/plugin-*/package.json"], {
|
|
35949
|
+
var pluginPackageJsonPaths = globby.sync(["prettier-plugin-*/package.json", "@*/prettier-plugin-*/package.json", "@prettier/plugin-*/package.json"], {
|
|
35774
35950
|
cwd: nodeModulesDir
|
|
35775
35951
|
});
|
|
35776
35952
|
return pluginPackageJsonPaths.map(path.dirname);
|
|
@@ -42156,6 +42332,13 @@ var resolveConfig_1 = createCommonjsModule(function (module) {
|
|
|
42156
42332
|
cache: opts.cache,
|
|
42157
42333
|
transform: function transform(result) {
|
|
42158
42334
|
if (result && result.config) {
|
|
42335
|
+
if (typeof result.config === "string") {
|
|
42336
|
+
var modulePath = resolve$1.sync(result.config, {
|
|
42337
|
+
basedir: path.dirname(result.filepath)
|
|
42338
|
+
});
|
|
42339
|
+
result.config = require(modulePath);
|
|
42340
|
+
}
|
|
42341
|
+
|
|
42159
42342
|
if (typeof result.config !== "object") {
|
|
42160
42343
|
throw new Error(`Config is only allowed to be an object, ` + `but received ${typeof result.config} in "${result.filepath}"`);
|
|
42161
42344
|
}
|