prettier 1.16.2 → 1.17.1
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 +629 -489
- package/doc.js +1935 -0
- package/index.js +628 -488
- 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 +256 -147
package/bin-prettier.js
CHANGED
|
@@ -14,7 +14,7 @@ var thirdParty__default = thirdParty['default'];
|
|
|
14
14
|
var readline = _interopDefault(require('readline'));
|
|
15
15
|
|
|
16
16
|
var name = "prettier";
|
|
17
|
-
var version$1 = "1.
|
|
17
|
+
var version$1 = "1.17.1";
|
|
18
18
|
var description = "Prettier is an opinionated code formatter";
|
|
19
19
|
var bin = {
|
|
20
20
|
"prettier": "./bin/prettier.js"
|
|
@@ -28,12 +28,12 @@ var engines = {
|
|
|
28
28
|
"node": ">=6"
|
|
29
29
|
};
|
|
30
30
|
var dependencies = {
|
|
31
|
-
"@angular/compiler": "
|
|
32
|
-
"@babel/code-frame": "7.0.0
|
|
31
|
+
"@angular/compiler": "7.2.9",
|
|
32
|
+
"@babel/code-frame": "7.0.0",
|
|
33
33
|
"@babel/parser": "7.2.0",
|
|
34
34
|
"@glimmer/syntax": "0.30.3",
|
|
35
35
|
"@iarna/toml": "2.0.0",
|
|
36
|
-
"@typescript-eslint/typescript-estree": "1.
|
|
36
|
+
"@typescript-eslint/typescript-estree": "1.6.0",
|
|
37
37
|
"angular-estree-parser": "1.1.5",
|
|
38
38
|
"angular-html-parser": "1.2.0",
|
|
39
39
|
"camelcase": "4.1.0",
|
|
@@ -52,11 +52,11 @@ var dependencies = {
|
|
|
52
52
|
"flow-parser": "0.84.0",
|
|
53
53
|
"get-stream": "3.0.0",
|
|
54
54
|
"globby": "6.1.0",
|
|
55
|
-
"graphql": "
|
|
55
|
+
"graphql": "14.2.0",
|
|
56
56
|
"html-element-attributes": "2.0.0",
|
|
57
57
|
"html-styles": "1.0.0",
|
|
58
58
|
"html-tag-names": "1.1.2",
|
|
59
|
-
"ignore": "
|
|
59
|
+
"ignore": "4.0.6",
|
|
60
60
|
"is-ci": "2.0.0",
|
|
61
61
|
"jest-docblock": "23.2.0",
|
|
62
62
|
"json-stable-stringify": "1.0.1",
|
|
@@ -81,7 +81,7 @@ var dependencies = {
|
|
|
81
81
|
"resolve": "1.5.0",
|
|
82
82
|
"semver": "5.4.1",
|
|
83
83
|
"string-width": "3.0.0",
|
|
84
|
-
"typescript": "3.
|
|
84
|
+
"typescript": "3.4.1",
|
|
85
85
|
"unicode-regex": "2.0.0",
|
|
86
86
|
"unified": "6.1.6",
|
|
87
87
|
"vnopts": "1.0.2",
|
|
@@ -110,7 +110,7 @@ var devDependencies = {
|
|
|
110
110
|
"jest-snapshot-serializer-raw": "1.1.0",
|
|
111
111
|
"jest-watch-typeahead": "0.1.0",
|
|
112
112
|
"mkdirp": "0.5.1",
|
|
113
|
-
"prettier": "1.
|
|
113
|
+
"prettier": "1.17.0",
|
|
114
114
|
"prettylint": "1.0.0",
|
|
115
115
|
"rimraf": "2.6.2",
|
|
116
116
|
"rollup": "0.47.6",
|
|
@@ -129,9 +129,6 @@ var devDependencies = {
|
|
|
129
129
|
"tempy": "0.2.1",
|
|
130
130
|
"webpack": "3.12.0"
|
|
131
131
|
};
|
|
132
|
-
var resolutions = {
|
|
133
|
-
"@babel/code-frame": "7.0.0-beta.46"
|
|
134
|
-
};
|
|
135
132
|
var scripts = {
|
|
136
133
|
"prepublishOnly": "echo \"Error: must publish from dist/\" && exit 1",
|
|
137
134
|
"prepare-release": "yarn && yarn build && yarn test:dist",
|
|
@@ -161,7 +158,6 @@ var _package = {
|
|
|
161
158
|
engines: engines,
|
|
162
159
|
dependencies: dependencies,
|
|
163
160
|
devDependencies: devDependencies,
|
|
164
|
-
resolutions: resolutions,
|
|
165
161
|
scripts: scripts
|
|
166
162
|
};
|
|
167
163
|
|
|
@@ -178,7 +174,6 @@ var _package$1 = Object.freeze({
|
|
|
178
174
|
engines: engines,
|
|
179
175
|
dependencies: dependencies,
|
|
180
176
|
devDependencies: devDependencies,
|
|
181
|
-
resolutions: resolutions,
|
|
182
177
|
scripts: scripts,
|
|
183
178
|
default: _package
|
|
184
179
|
});
|
|
@@ -3947,6 +3942,10 @@ var options$2 = {
|
|
|
3947
3942
|
value: "angular",
|
|
3948
3943
|
since: "1.15.0",
|
|
3949
3944
|
description: "Angular"
|
|
3945
|
+
}, {
|
|
3946
|
+
value: "lwc",
|
|
3947
|
+
since: "1.17.0",
|
|
3948
|
+
description: "Lightning Web Components"
|
|
3950
3949
|
}]
|
|
3951
3950
|
},
|
|
3952
3951
|
plugins: {
|
|
@@ -4140,6 +4139,7 @@ function getSupportInfo$2(version, opts) {
|
|
|
4140
4139
|
});
|
|
4141
4140
|
});
|
|
4142
4141
|
var usePostCssParser = semver.lt(version, "1.7.1");
|
|
4142
|
+
var useBabylonParser = semver.lt(version, "1.16.0");
|
|
4143
4143
|
var languages = plugins.reduce(function (all, plugin) {
|
|
4144
4144
|
return all.concat(plugin.languages || []);
|
|
4145
4145
|
}, []).filter(filterSince).map(function (language) {
|
|
@@ -4154,6 +4154,15 @@ function getSupportInfo$2(version, opts) {
|
|
|
4154
4154
|
return Object.assign({}, language, {
|
|
4155
4155
|
parsers: ["typescript"]
|
|
4156
4156
|
});
|
|
4157
|
+
} // "babylon" was renamed to "babel" in 1.16.0
|
|
4158
|
+
|
|
4159
|
+
|
|
4160
|
+
if (useBabylonParser && language.parsers.indexOf("babel") !== -1) {
|
|
4161
|
+
return Object.assign({}, language, {
|
|
4162
|
+
parsers: language.parsers.map(function (parser) {
|
|
4163
|
+
return parser === "babel" ? "babylon" : parser;
|
|
4164
|
+
})
|
|
4165
|
+
});
|
|
4157
4166
|
}
|
|
4158
4167
|
|
|
4159
4168
|
if (usePostCssParser && (language.name === "CSS" || language.group === "CSS")) {
|
|
@@ -8988,19 +8997,20 @@ var loc = {
|
|
|
8988
8997
|
};
|
|
8989
8998
|
|
|
8990
8999
|
var jsTokens = createCommonjsModule(function (module, exports) {
|
|
8991
|
-
// Copyright 2014, 2015, 2016, 2017 Simon Lydell
|
|
9000
|
+
// Copyright 2014, 2015, 2016, 2017, 2018 Simon Lydell
|
|
8992
9001
|
// License: MIT. (See LICENSE.)
|
|
8993
9002
|
Object.defineProperty(exports, "__esModule", {
|
|
8994
9003
|
value: true
|
|
8995
9004
|
}); // This regex comes from regex.coffee, and is inserted here by generate-index.js
|
|
8996
9005
|
// (run `npm run build`).
|
|
8997
9006
|
|
|
8998
|
-
exports.default = /((['"])(?:(?!\2|\\).|\\(?:\r\n|[\s\S]))*(\2)?|`(?:[^`\\$]|\\[\s\S]|\$(?!\{)|\$\{(?:[^{}]|\{[^}]*\}?)*\}?)*(`)?)|(\/\/.*)|(\/\*(?:[^*]|\*(?!\/))*(\*\/)?)|(\/(?!\*)(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\]\\]).|\\.)+\/(?:(?!\s*(?:\b|[\u0080-\uFFFF$\\'"~({]|[+\-!](?!=)|\.?\d))|[
|
|
9007
|
+
exports.default = /((['"])(?:(?!\2|\\).|\\(?:\r\n|[\s\S]))*(\2)?|`(?:[^`\\$]|\\[\s\S]|\$(?!\{)|\$\{(?:[^{}]|\{[^}]*\}?)*\}?)*(`)?)|(\/\/.*)|(\/\*(?:[^*]|\*(?!\/))*(\*\/)?)|(\/(?!\*)(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\]\\]).|\\.)+\/(?:(?!\s*(?:\b|[\u0080-\uFFFF$\\'"~({]|[+\-!](?!=)|\.?\d))|[gmiyus]{1,6}\b(?![\u0080-\uFFFF$\\]|\s*(?:[+\-*%&|^<>!=?({]|\/(?![\/*])))))|(0[xX][\da-fA-F]+|0[oO][0-7]+|0[bB][01]+|(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?)|((?!\d)(?:(?!\s)[$\w\u0080-\uFFFF]|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+)|(--|\+\+|&&|\|\||=>|\.{3}|(?:[+\-\/%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2})=?|[?~.,:;[\](){}])|(\s+)|(^$|[\s\S])/g;
|
|
8999
9008
|
|
|
9000
9009
|
exports.matchToToken = function (match) {
|
|
9001
9010
|
var token = {
|
|
9002
9011
|
type: "invalid",
|
|
9003
|
-
value: match[0]
|
|
9012
|
+
value: match[0],
|
|
9013
|
+
closed: undefined
|
|
9004
9014
|
};
|
|
9005
9015
|
if (match[1]) token.type = "string", token.closed = !!(match[3] || match[4]);else if (match[5]) token.type = "comment";else if (match[6]) token.type = "comment", token.closed = !!match[7];else if (match[8]) token.type = "regex";else if (match[9]) token.type = "number";else if (match[10]) token.type = "name";else if (match[11]) token.type = "punctuator";else if (match[12]) token.type = "whitespace";
|
|
9006
9016
|
return token;
|
|
@@ -10131,7 +10141,7 @@ var lib$3 = createCommonjsModule(function (module, exports) {
|
|
|
10131
10141
|
exports.default = highlight;
|
|
10132
10142
|
|
|
10133
10143
|
function _jsTokens() {
|
|
10134
|
-
var data = _interopRequireWildcard(jsTokens);
|
|
10144
|
+
var data = _interopRequireWildcard$$1(jsTokens);
|
|
10135
10145
|
|
|
10136
10146
|
_jsTokens = function _jsTokens() {
|
|
10137
10147
|
return data;
|
|
@@ -10141,7 +10151,7 @@ var lib$3 = createCommonjsModule(function (module, exports) {
|
|
|
10141
10151
|
}
|
|
10142
10152
|
|
|
10143
10153
|
function _esutils() {
|
|
10144
|
-
var data = _interopRequireDefault(utils$2);
|
|
10154
|
+
var data = _interopRequireDefault$$1(utils$2);
|
|
10145
10155
|
|
|
10146
10156
|
_esutils = function _esutils() {
|
|
10147
10157
|
return data;
|
|
@@ -10151,7 +10161,7 @@ var lib$3 = createCommonjsModule(function (module, exports) {
|
|
|
10151
10161
|
}
|
|
10152
10162
|
|
|
10153
10163
|
function _chalk() {
|
|
10154
|
-
var data = _interopRequireDefault(chalk$5);
|
|
10164
|
+
var data = _interopRequireDefault$$1(chalk$5);
|
|
10155
10165
|
|
|
10156
10166
|
_chalk = function _chalk() {
|
|
10157
10167
|
return data;
|
|
@@ -10160,13 +10170,13 @@ var lib$3 = createCommonjsModule(function (module, exports) {
|
|
|
10160
10170
|
return data;
|
|
10161
10171
|
}
|
|
10162
10172
|
|
|
10163
|
-
function _interopRequireDefault(obj) {
|
|
10173
|
+
function _interopRequireDefault$$1(obj) {
|
|
10164
10174
|
return obj && obj.__esModule ? obj : {
|
|
10165
10175
|
default: obj
|
|
10166
10176
|
};
|
|
10167
10177
|
}
|
|
10168
10178
|
|
|
10169
|
-
function _interopRequireWildcard(obj) {
|
|
10179
|
+
function _interopRequireWildcard$$1(obj) {
|
|
10170
10180
|
if (obj && obj.__esModule) {
|
|
10171
10181
|
return obj;
|
|
10172
10182
|
} else {
|
|
@@ -10211,8 +10221,9 @@ var lib$3 = createCommonjsModule(function (module, exports) {
|
|
|
10211
10221
|
|
|
10212
10222
|
function getTokenType(match) {
|
|
10213
10223
|
var _match$slice = match.slice(-2),
|
|
10214
|
-
|
|
10215
|
-
|
|
10224
|
+
_match$slice2 = _slicedToArray(_match$slice, 2),
|
|
10225
|
+
offset = _match$slice2[0],
|
|
10226
|
+
text = _match$slice2[1];
|
|
10216
10227
|
|
|
10217
10228
|
var token = (0, _jsTokens().matchToToken)(match);
|
|
10218
10229
|
|
|
@@ -10277,10 +10288,8 @@ var lib$3 = createCommonjsModule(function (module, exports) {
|
|
|
10277
10288
|
return chalk;
|
|
10278
10289
|
}
|
|
10279
10290
|
|
|
10280
|
-
function highlight(code
|
|
10281
|
-
|
|
10282
|
-
options = {};
|
|
10283
|
-
}
|
|
10291
|
+
function highlight(code) {
|
|
10292
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
10284
10293
|
|
|
10285
10294
|
if (shouldHighlight(options)) {
|
|
10286
10295
|
var chalk = getChalk(options);
|
|
@@ -10350,7 +10359,7 @@ var lib$2 = createCommonjsModule(function (module, exports) {
|
|
|
10350
10359
|
var NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
|
|
10351
10360
|
|
|
10352
10361
|
function getMarkerLines(loc, source, opts) {
|
|
10353
|
-
var startLoc = Object.assign({
|
|
10362
|
+
var startLoc = Object.assign({
|
|
10354
10363
|
column: 0,
|
|
10355
10364
|
line: -1
|
|
10356
10365
|
}, loc.start);
|
|
@@ -10409,17 +10418,14 @@ var lib$2 = createCommonjsModule(function (module, exports) {
|
|
|
10409
10418
|
}
|
|
10410
10419
|
|
|
10411
10420
|
return {
|
|
10412
|
-
start
|
|
10413
|
-
end
|
|
10414
|
-
markerLines
|
|
10421
|
+
start,
|
|
10422
|
+
end,
|
|
10423
|
+
markerLines
|
|
10415
10424
|
};
|
|
10416
10425
|
}
|
|
10417
10426
|
|
|
10418
|
-
function codeFrameColumns(rawLines, loc
|
|
10419
|
-
|
|
10420
|
-
opts = {};
|
|
10421
|
-
}
|
|
10422
|
-
|
|
10427
|
+
function codeFrameColumns(rawLines, loc) {
|
|
10428
|
+
var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
10423
10429
|
var highlighted = (opts.highlightCode || opts.forceColor) && (0, _highlight().shouldHighlight)(opts);
|
|
10424
10430
|
var chalk = (0, _highlight().getChalk)(opts);
|
|
10425
10431
|
var defs = getDefs(chalk);
|
|
@@ -10440,8 +10446,8 @@ var lib$2 = createCommonjsModule(function (module, exports) {
|
|
|
10440
10446
|
var numberMaxWidth = String(end).length;
|
|
10441
10447
|
var frame = lines.slice(start, end).map(function (line, index) {
|
|
10442
10448
|
var number = start + 1 + index;
|
|
10443
|
-
var paddedNumber =
|
|
10444
|
-
var gutter =
|
|
10449
|
+
var paddedNumber = ` ${number}`.slice(-numberMaxWidth);
|
|
10450
|
+
var gutter = ` ${paddedNumber} | `;
|
|
10445
10451
|
var hasMarker = markerLines[number];
|
|
10446
10452
|
var lastMarkerLine = !markerLines[number + 1];
|
|
10447
10453
|
|
|
@@ -10460,12 +10466,12 @@ var lib$2 = createCommonjsModule(function (module, exports) {
|
|
|
10460
10466
|
|
|
10461
10467
|
return [maybeHighlight(defs.marker, ">"), maybeHighlight(defs.gutter, gutter), line, markerLine].join("");
|
|
10462
10468
|
} else {
|
|
10463
|
-
return
|
|
10469
|
+
return ` ${maybeHighlight(defs.gutter, gutter)}${line}`;
|
|
10464
10470
|
}
|
|
10465
10471
|
}).join("\n");
|
|
10466
10472
|
|
|
10467
10473
|
if (opts.message && !hasColumns) {
|
|
10468
|
-
frame = "
|
|
10474
|
+
frame = `${" ".repeat(numberMaxWidth + 1)}${opts.message}\n${frame}`;
|
|
10469
10475
|
}
|
|
10470
10476
|
|
|
10471
10477
|
if (highlighted) {
|
|
@@ -10475,10 +10481,8 @@ var lib$2 = createCommonjsModule(function (module, exports) {
|
|
|
10475
10481
|
}
|
|
10476
10482
|
}
|
|
10477
10483
|
|
|
10478
|
-
function _default(rawLines, lineNumber, colNumber
|
|
10479
|
-
|
|
10480
|
-
opts = {};
|
|
10481
|
-
}
|
|
10484
|
+
function _default(rawLines, lineNumber, colNumber) {
|
|
10485
|
+
var opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
10482
10486
|
|
|
10483
10487
|
if (!deprecationWarningShown) {
|
|
10484
10488
|
deprecationWarningShown = true;
|
|
@@ -11150,14 +11154,6 @@ function getPenultimate(arr) {
|
|
|
11150
11154
|
return null;
|
|
11151
11155
|
}
|
|
11152
11156
|
|
|
11153
|
-
function getLast$3(arr) {
|
|
11154
|
-
if (arr.length > 0) {
|
|
11155
|
-
return arr[arr.length - 1];
|
|
11156
|
-
}
|
|
11157
|
-
|
|
11158
|
-
return null;
|
|
11159
|
-
}
|
|
11160
|
-
|
|
11161
11157
|
function skip(chars) {
|
|
11162
11158
|
return function (text, index, opts) {
|
|
11163
11159
|
var backwards = opts && opts.backwards; // Allow `skip` functions to be threaded together without having
|
|
@@ -11572,7 +11568,7 @@ function printString(raw, options, isDirectiveLiteral) {
|
|
|
11572
11568
|
// sure that we consistently output the minimum amount of escaped quotes.
|
|
11573
11569
|
|
|
11574
11570
|
|
|
11575
|
-
return makeString(rawContent, enclosingQuote, !(options.parser === "css" || options.parser === "less" || options.parser === "scss" || options.parentParser === "html" || options.parentParser === "vue" || options.parentParser === "angular"));
|
|
11571
|
+
return makeString(rawContent, enclosingQuote, !(options.parser === "css" || options.parser === "less" || options.parser === "scss" || options.parentParser === "html" || options.parentParser === "vue" || options.parentParser === "angular" || options.parentParser === "lwc"));
|
|
11576
11572
|
}
|
|
11577
11573
|
|
|
11578
11574
|
function makeString(rawContent, enclosingQuote, unescapeUnnecessaryEscapes) {
|
|
@@ -11760,7 +11756,7 @@ var util$1 = {
|
|
|
11760
11756
|
isExportDeclaration,
|
|
11761
11757
|
getParentExportDeclaration,
|
|
11762
11758
|
getPenultimate,
|
|
11763
|
-
getLast
|
|
11759
|
+
getLast,
|
|
11764
11760
|
getNextNonSpaceNonCommentCharacterIndexWithStartIndex,
|
|
11765
11761
|
getNextNonSpaceNonCommentCharacterIndex,
|
|
11766
11762
|
getNextNonSpaceNonCommentCharacter,
|
|
@@ -13211,7 +13207,7 @@ function printTrailingComment(commentPath, print, options) {
|
|
|
13211
13207
|
return concat([" ", contents]);
|
|
13212
13208
|
}
|
|
13213
13209
|
|
|
13214
|
-
return concat([lineSuffix(" "
|
|
13210
|
+
return concat([lineSuffix(concat([" ", contents])), !isBlock ? breakParent : ""]);
|
|
13215
13211
|
}
|
|
13216
13212
|
|
|
13217
13213
|
function printDanglingComments(path$$1, options, sameIndent, filter) {
|
|
@@ -13969,7 +13965,6 @@ function formatRange(text, opts) {
|
|
|
13969
13965
|
var rangeResult = coreFormat(rangeString, Object.assign({}, opts, {
|
|
13970
13966
|
rangeStart: 0,
|
|
13971
13967
|
rangeEnd: Infinity,
|
|
13972
|
-
printWidth: opts.printWidth - alignmentSize,
|
|
13973
13968
|
// track the cursor offset only if it's within our range
|
|
13974
13969
|
cursorOffset: opts.cursorOffset >= rangeStart && opts.cursorOffset < rangeEnd ? opts.cursorOffset - rangeStart : -1
|
|
13975
13970
|
}), alignmentSize); // Since the range contracts to avoid trailing whitespace,
|
|
@@ -14169,367 +14164,384 @@ var core = {
|
|
|
14169
14164
|
|
|
14170
14165
|
};
|
|
14171
14166
|
|
|
14172
|
-
var
|
|
14173
|
-
|
|
14174
|
-
|
|
14175
|
-
|
|
14176
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
14177
|
-
descriptor.configurable = true;
|
|
14178
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
14179
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
14180
|
-
}
|
|
14167
|
+
var ignore = createCommonjsModule(function (module) {
|
|
14168
|
+
// A simple implementation of make-array
|
|
14169
|
+
function make_array(subject) {
|
|
14170
|
+
return Array.isArray(subject) ? subject : [subject];
|
|
14181
14171
|
}
|
|
14182
14172
|
|
|
14183
|
-
|
|
14184
|
-
|
|
14185
|
-
|
|
14186
|
-
|
|
14173
|
+
var REGEX_BLANK_LINE = /^\s+$/;
|
|
14174
|
+
var REGEX_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
|
|
14175
|
+
var REGEX_LEADING_EXCAPED_HASH = /^\\#/;
|
|
14176
|
+
var SLASH = '/';
|
|
14177
|
+
var KEY_IGNORE = typeof Symbol !== 'undefined' ? Symbol.for('node-ignore')
|
|
14178
|
+
/* istanbul ignore next */
|
|
14179
|
+
: 'node-ignore';
|
|
14180
|
+
|
|
14181
|
+
var define = function define(object, key, value) {
|
|
14182
|
+
return Object.defineProperty(object, key, {
|
|
14183
|
+
value
|
|
14184
|
+
});
|
|
14187
14185
|
};
|
|
14188
|
-
}();
|
|
14189
14186
|
|
|
14190
|
-
|
|
14191
|
-
|
|
14192
|
-
throw new TypeError("Cannot call a class as a function");
|
|
14193
|
-
}
|
|
14194
|
-
}
|
|
14187
|
+
var REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g; // Sanitize the range of a regular expression
|
|
14188
|
+
// The cases are complicated, see test cases for details
|
|
14195
14189
|
|
|
14196
|
-
var
|
|
14197
|
-
|
|
14198
|
-
|
|
14190
|
+
var sanitizeRange = function sanitizeRange(range) {
|
|
14191
|
+
return range.replace(REGEX_REGEXP_RANGE, function (match, from, to) {
|
|
14192
|
+
return from.charCodeAt(0) <= to.charCodeAt(0) ? match // Invalid range (out of order) which is ok for gitignore rules but
|
|
14193
|
+
// fatal for JavaScript regular expression, so eliminate it.
|
|
14194
|
+
: '';
|
|
14195
|
+
});
|
|
14196
|
+
}; // > If the pattern ends with a slash,
|
|
14197
|
+
// > it is removed for the purpose of the following description,
|
|
14198
|
+
// > but it would only find a match with a directory.
|
|
14199
|
+
// > In other words, foo/ will match a directory foo and paths underneath it,
|
|
14200
|
+
// > but will not match a regular file or a symbolic link foo
|
|
14201
|
+
// > (this is consistent with the way how pathspec works in general in Git).
|
|
14202
|
+
// '`foo/`' will not match regular file '`foo`' or symbolic link '`foo`'
|
|
14203
|
+
// -> ignore-rules will not deal with it, because it costs extra `fs.stat` call
|
|
14204
|
+
// you could use option `mark: true` with `glob`
|
|
14205
|
+
// '`foo/`' should not continue with the '`..`'
|
|
14206
|
+
|
|
14207
|
+
|
|
14208
|
+
var DEFAULT_REPLACER_PREFIX = [// > Trailing spaces are ignored unless they are quoted with backslash ("\")
|
|
14209
|
+
[// (a\ ) -> (a )
|
|
14210
|
+
// (a ) -> (a)
|
|
14211
|
+
// (a \ ) -> (a )
|
|
14212
|
+
/\\?\s+$/, function (match) {
|
|
14213
|
+
return match.indexOf('\\') === 0 ? ' ' : '';
|
|
14214
|
+
}], // replace (\ ) with ' '
|
|
14215
|
+
[/\\\s/g, function () {
|
|
14216
|
+
return ' ';
|
|
14217
|
+
}], // Escape metacharacters
|
|
14218
|
+
// which is written down by users but means special for regular expressions.
|
|
14219
|
+
// > There are 12 characters with special meanings:
|
|
14220
|
+
// > - the backslash \,
|
|
14221
|
+
// > - the caret ^,
|
|
14222
|
+
// > - the dollar sign $,
|
|
14223
|
+
// > - the period or dot .,
|
|
14224
|
+
// > - the vertical bar or pipe symbol |,
|
|
14225
|
+
// > - the question mark ?,
|
|
14226
|
+
// > - the asterisk or star *,
|
|
14227
|
+
// > - the plus sign +,
|
|
14228
|
+
// > - the opening parenthesis (,
|
|
14229
|
+
// > - the closing parenthesis ),
|
|
14230
|
+
// > - and the opening square bracket [,
|
|
14231
|
+
// > - the opening curly brace {,
|
|
14232
|
+
// > These special characters are often called "metacharacters".
|
|
14233
|
+
[/[\\^$.|*+(){]/g, function (match) {
|
|
14234
|
+
return `\\${match}`;
|
|
14235
|
+
}], [// > [abc] matches any character inside the brackets
|
|
14236
|
+
// > (in this case a, b, or c);
|
|
14237
|
+
/\[([^\]/]*)($|\])/g, function (match, p1, p2) {
|
|
14238
|
+
return p2 === ']' ? `[${sanitizeRange(p1)}]` : `\\${match}`;
|
|
14239
|
+
}], [// > a question mark (?) matches a single character
|
|
14240
|
+
/(?!\\)\?/g, function () {
|
|
14241
|
+
return '[^/]';
|
|
14242
|
+
}], // leading slash
|
|
14243
|
+
[// > A leading slash matches the beginning of the pathname.
|
|
14244
|
+
// > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
|
|
14245
|
+
// A leading slash matches the beginning of the pathname
|
|
14246
|
+
/^\//, function () {
|
|
14247
|
+
return '^';
|
|
14248
|
+
}], // replace special metacharacter slash after the leading slash
|
|
14249
|
+
[/\//g, function () {
|
|
14250
|
+
return '\\/';
|
|
14251
|
+
}], [// > A leading "**" followed by a slash means match in all directories.
|
|
14252
|
+
// > For example, "**/foo" matches file or directory "foo" anywhere,
|
|
14253
|
+
// > the same as pattern "foo".
|
|
14254
|
+
// > "**/foo/bar" matches file or directory "bar" anywhere that is directly
|
|
14255
|
+
// > under directory "foo".
|
|
14256
|
+
// Notice that the '*'s have been replaced as '\\*'
|
|
14257
|
+
/^\^*\\\*\\\*\\\//, // '**/foo' <-> 'foo'
|
|
14258
|
+
function () {
|
|
14259
|
+
return '^(?:.*\\/)?';
|
|
14260
|
+
}]];
|
|
14261
|
+
var DEFAULT_REPLACER_SUFFIX = [// starting
|
|
14262
|
+
[// there will be no leading '/'
|
|
14263
|
+
// (which has been replaced by section "leading slash")
|
|
14264
|
+
// If starts with '**', adding a '^' to the regular expression also works
|
|
14265
|
+
/^(?=[^^])/, function startingReplacer() {
|
|
14266
|
+
return !/\/(?!$)/.test(this) // > If the pattern does not contain a slash /,
|
|
14267
|
+
// > Git treats it as a shell glob pattern
|
|
14268
|
+
// Actually, if there is only a trailing slash,
|
|
14269
|
+
// git also treats it as a shell glob pattern
|
|
14270
|
+
? '(?:^|\\/)' // > Otherwise, Git treats the pattern as a shell glob suitable for
|
|
14271
|
+
// > consumption by fnmatch(3)
|
|
14272
|
+
: '^';
|
|
14273
|
+
}], // two globstars
|
|
14274
|
+
[// Use lookahead assertions so that we could match more than one `'/**'`
|
|
14275
|
+
/\\\/\\\*\\\*(?=\\\/|$)/g, // Zero, one or several directories
|
|
14276
|
+
// should not use '*', or it will be replaced by the next replacer
|
|
14277
|
+
// Check if it is not the last `'/**'`
|
|
14278
|
+
function (match, index, str) {
|
|
14279
|
+
return index + 6 < str.length // case: /**/
|
|
14280
|
+
// > A slash followed by two consecutive asterisks then a slash matches
|
|
14281
|
+
// > zero or more directories.
|
|
14282
|
+
// > For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on.
|
|
14283
|
+
// '/**/'
|
|
14284
|
+
? '(?:\\/[^\\/]+)*' // case: /**
|
|
14285
|
+
// > A trailing `"/**"` matches everything inside.
|
|
14286
|
+
// #21: everything inside but it should not include the current folder
|
|
14287
|
+
: '\\/.+';
|
|
14288
|
+
}], // intermediate wildcards
|
|
14289
|
+
[// Never replace escaped '*'
|
|
14290
|
+
// ignore rule '\*' will match the path '*'
|
|
14291
|
+
// 'abc.*/' -> go
|
|
14292
|
+
// 'abc.*' -> skip this rule
|
|
14293
|
+
/(^|[^\\]+)\\\*(?=.+)/g, // '*.js' matches '.js'
|
|
14294
|
+
// '*.js' doesn't match 'abc'
|
|
14295
|
+
function (match, p1) {
|
|
14296
|
+
return `${p1}[^\\/]*`;
|
|
14297
|
+
}], // trailing wildcard
|
|
14298
|
+
[/(\^|\\\/)?\\\*$/, function (match, p1) {
|
|
14299
|
+
var prefix = p1 // '\^':
|
|
14300
|
+
// '/*' does not match ''
|
|
14301
|
+
// '/*' does not match everything
|
|
14302
|
+
// '\\\/':
|
|
14303
|
+
// 'abc/*' does not match 'abc/'
|
|
14304
|
+
? `${p1}[^/]+` // 'a*' matches 'a'
|
|
14305
|
+
// 'a*' matches 'aa'
|
|
14306
|
+
: '[^/]*';
|
|
14307
|
+
return `${prefix}(?=$|\\/$)`;
|
|
14308
|
+
}], [// unescape
|
|
14309
|
+
/\\\\\\/g, function () {
|
|
14310
|
+
return '\\';
|
|
14311
|
+
}]];
|
|
14312
|
+
var POSITIVE_REPLACERS = DEFAULT_REPLACER_PREFIX.concat([// 'f'
|
|
14313
|
+
// matches
|
|
14314
|
+
// - /f(end)
|
|
14315
|
+
// - /f/
|
|
14316
|
+
// - (start)f(end)
|
|
14317
|
+
// - (start)f/
|
|
14318
|
+
// doesn't match
|
|
14319
|
+
// - oof
|
|
14320
|
+
// - foo
|
|
14321
|
+
// pseudo:
|
|
14322
|
+
// -> (^|/)f(/|$)
|
|
14323
|
+
// ending
|
|
14324
|
+
[// 'js' will not match 'js.'
|
|
14325
|
+
// 'ab' will not match 'abc'
|
|
14326
|
+
/(?:[^*/])$/, // 'js*' will not match 'a.js'
|
|
14327
|
+
// 'js/' will not match 'a.js'
|
|
14328
|
+
// 'js' will match 'a.js' and 'a.js/'
|
|
14329
|
+
function (match) {
|
|
14330
|
+
return `${match}(?=$|\\/)`;
|
|
14331
|
+
}]], DEFAULT_REPLACER_SUFFIX);
|
|
14332
|
+
var NEGATIVE_REPLACERS = DEFAULT_REPLACER_PREFIX.concat([// #24, #38
|
|
14333
|
+
// The MISSING rule of [gitignore docs](https://git-scm.com/docs/gitignore)
|
|
14334
|
+
// A negative pattern without a trailing wildcard should not
|
|
14335
|
+
// re-include the things inside that directory.
|
|
14336
|
+
// eg:
|
|
14337
|
+
// ['node_modules/*', '!node_modules']
|
|
14338
|
+
// should ignore `node_modules/a.js`
|
|
14339
|
+
[/(?:[^*])$/, function (match) {
|
|
14340
|
+
return `${match}(?=$|\\/$)`;
|
|
14341
|
+
}]], DEFAULT_REPLACER_SUFFIX); // A simple cache, because an ignore rule only has only one certain meaning
|
|
14342
|
+
|
|
14343
|
+
var cache = Object.create(null); // @param {pattern}
|
|
14344
|
+
|
|
14345
|
+
var make_regex = function make_regex(pattern, negative, ignorecase) {
|
|
14346
|
+
var r = cache[pattern];
|
|
14347
|
+
|
|
14348
|
+
if (r) {
|
|
14349
|
+
return r;
|
|
14350
|
+
}
|
|
14351
|
+
|
|
14352
|
+
var replacers = negative ? NEGATIVE_REPLACERS : POSITIVE_REPLACERS;
|
|
14353
|
+
var source = replacers.reduce(function (prev, current) {
|
|
14354
|
+
return prev.replace(current[0], current[1].bind(pattern));
|
|
14355
|
+
}, pattern);
|
|
14356
|
+
return cache[pattern] = ignorecase ? new RegExp(source, 'i') : new RegExp(source);
|
|
14357
|
+
}; // > A blank line matches no files, so it can serve as a separator for readability.
|
|
14358
|
+
|
|
14359
|
+
|
|
14360
|
+
var checkPattern = function checkPattern(pattern) {
|
|
14361
|
+
return pattern && typeof pattern === 'string' && !REGEX_BLANK_LINE.test(pattern) // > A line starting with # serves as a comment.
|
|
14362
|
+
&& pattern.indexOf('#') !== 0;
|
|
14363
|
+
};
|
|
14199
14364
|
|
|
14365
|
+
var createRule = function createRule(pattern, ignorecase) {
|
|
14366
|
+
var origin = pattern;
|
|
14367
|
+
var negative = false; // > An optional prefix "!" which negates the pattern;
|
|
14200
14368
|
|
|
14201
|
-
|
|
14202
|
-
|
|
14203
|
-
|
|
14369
|
+
if (pattern.indexOf('!') === 0) {
|
|
14370
|
+
negative = true;
|
|
14371
|
+
pattern = pattern.substr(1);
|
|
14372
|
+
}
|
|
14204
14373
|
|
|
14205
|
-
|
|
14206
|
-
|
|
14207
|
-
|
|
14208
|
-
|
|
14209
|
-
|
|
14210
|
-
|
|
14211
|
-
|
|
14374
|
+
pattern = pattern // > Put a backslash ("\") in front of the first "!" for patterns that
|
|
14375
|
+
// > begin with a literal "!", for example, `"\!important!.txt"`.
|
|
14376
|
+
.replace(REGEX_LEADING_EXCAPED_EXCLAMATION, '!') // > Put a backslash ("\") in front of the first hash for patterns that
|
|
14377
|
+
// > begin with a hash.
|
|
14378
|
+
.replace(REGEX_LEADING_EXCAPED_HASH, '#');
|
|
14379
|
+
var regex = make_regex(pattern, negative, ignorecase);
|
|
14380
|
+
return {
|
|
14381
|
+
origin,
|
|
14382
|
+
pattern,
|
|
14383
|
+
negative,
|
|
14384
|
+
regex
|
|
14385
|
+
};
|
|
14386
|
+
};
|
|
14212
14387
|
|
|
14213
|
-
var IgnoreBase =
|
|
14214
|
-
|
|
14215
|
-
|
|
14388
|
+
var IgnoreBase =
|
|
14389
|
+
/*#__PURE__*/
|
|
14390
|
+
function () {
|
|
14391
|
+
function IgnoreBase() {
|
|
14392
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
14393
|
+
_ref$ignorecase = _ref.ignorecase,
|
|
14394
|
+
ignorecase = _ref$ignorecase === void 0 ? true : _ref$ignorecase;
|
|
14216
14395
|
|
|
14217
|
-
|
|
14218
|
-
this[KEY_IGNORE] = true;
|
|
14396
|
+
_classCallCheck(this, IgnoreBase);
|
|
14219
14397
|
|
|
14220
|
-
|
|
14221
|
-
|
|
14398
|
+
this._rules = [];
|
|
14399
|
+
this._ignorecase = ignorecase;
|
|
14400
|
+
define(this, KEY_IGNORE, true);
|
|
14222
14401
|
|
|
14223
|
-
|
|
14224
|
-
|
|
14225
|
-
value: function _initCache() {
|
|
14226
|
-
this._cache = {};
|
|
14227
|
-
} // @param {Array.<string>|string|Ignore} pattern
|
|
14402
|
+
this._initCache();
|
|
14403
|
+
}
|
|
14228
14404
|
|
|
14229
|
-
|
|
14230
|
-
|
|
14231
|
-
|
|
14232
|
-
|
|
14405
|
+
_createClass(IgnoreBase, [{
|
|
14406
|
+
key: "_initCache",
|
|
14407
|
+
value: function _initCache() {
|
|
14408
|
+
this._cache = Object.create(null);
|
|
14409
|
+
} // @param {Array.<string>|string|Ignore} pattern
|
|
14233
14410
|
|
|
14234
|
-
|
|
14235
|
-
|
|
14236
|
-
|
|
14411
|
+
}, {
|
|
14412
|
+
key: "add",
|
|
14413
|
+
value: function add(pattern) {
|
|
14414
|
+
this._added = false;
|
|
14237
14415
|
|
|
14238
|
-
|
|
14239
|
-
|
|
14416
|
+
if (typeof pattern === 'string') {
|
|
14417
|
+
pattern = pattern.split(/\r?\n/g);
|
|
14418
|
+
}
|
|
14240
14419
|
|
|
14241
|
-
|
|
14242
|
-
|
|
14243
|
-
}
|
|
14420
|
+
make_array(pattern).forEach(this._addPattern, this); // Some rules have just added to the ignore,
|
|
14421
|
+
// making the behavior changed.
|
|
14244
14422
|
|
|
14245
|
-
|
|
14246
|
-
|
|
14423
|
+
if (this._added) {
|
|
14424
|
+
this._initCache();
|
|
14425
|
+
}
|
|
14247
14426
|
|
|
14248
|
-
|
|
14249
|
-
|
|
14250
|
-
|
|
14251
|
-
|
|
14252
|
-
|
|
14253
|
-
|
|
14254
|
-
|
|
14255
|
-
value: function _addPattern(pattern) {
|
|
14256
|
-
// #32
|
|
14257
|
-
if (pattern && pattern[KEY_IGNORE]) {
|
|
14258
|
-
this._rules = this._rules.concat(pattern._rules);
|
|
14259
|
-
this._added = true;
|
|
14260
|
-
return;
|
|
14427
|
+
return this;
|
|
14428
|
+
} // legacy
|
|
14429
|
+
|
|
14430
|
+
}, {
|
|
14431
|
+
key: "addPattern",
|
|
14432
|
+
value: function addPattern(pattern) {
|
|
14433
|
+
return this.add(pattern);
|
|
14261
14434
|
}
|
|
14435
|
+
}, {
|
|
14436
|
+
key: "_addPattern",
|
|
14437
|
+
value: function _addPattern(pattern) {
|
|
14438
|
+
// #32
|
|
14439
|
+
if (pattern && pattern[KEY_IGNORE]) {
|
|
14440
|
+
this._rules = this._rules.concat(pattern._rules);
|
|
14441
|
+
this._added = true;
|
|
14442
|
+
return;
|
|
14443
|
+
}
|
|
14262
14444
|
|
|
14263
|
-
|
|
14264
|
-
|
|
14445
|
+
if (checkPattern(pattern)) {
|
|
14446
|
+
var rule = createRule(pattern, this._ignorecase);
|
|
14447
|
+
this._added = true;
|
|
14265
14448
|
|
|
14266
|
-
|
|
14449
|
+
this._rules.push(rule);
|
|
14450
|
+
}
|
|
14451
|
+
}
|
|
14452
|
+
}, {
|
|
14453
|
+
key: "filter",
|
|
14454
|
+
value: function filter(paths) {
|
|
14455
|
+
var _this = this;
|
|
14267
14456
|
|
|
14268
|
-
|
|
14457
|
+
return make_array(paths).filter(function (path$$1) {
|
|
14458
|
+
return _this._filter(path$$1);
|
|
14459
|
+
});
|
|
14269
14460
|
}
|
|
14270
|
-
}
|
|
14271
|
-
|
|
14272
|
-
|
|
14273
|
-
|
|
14274
|
-
// > A blank line matches no files, so it can serve as a separator for readability.
|
|
14275
|
-
return pattern && typeof pattern === 'string' && !REGEX_BLANK_LINE.test(pattern) // > A line starting with # serves as a comment.
|
|
14276
|
-
&& pattern.indexOf('#') !== 0;
|
|
14277
|
-
}
|
|
14278
|
-
}, {
|
|
14279
|
-
key: 'filter',
|
|
14280
|
-
value: function filter(paths) {
|
|
14281
|
-
var _this = this;
|
|
14461
|
+
}, {
|
|
14462
|
+
key: "createFilter",
|
|
14463
|
+
value: function createFilter() {
|
|
14464
|
+
var _this2 = this;
|
|
14282
14465
|
|
|
14283
|
-
|
|
14284
|
-
|
|
14285
|
-
|
|
14286
|
-
|
|
14287
|
-
|
|
14288
|
-
|
|
14289
|
-
|
|
14290
|
-
|
|
14466
|
+
return function (path$$1) {
|
|
14467
|
+
return _this2._filter(path$$1);
|
|
14468
|
+
};
|
|
14469
|
+
}
|
|
14470
|
+
}, {
|
|
14471
|
+
key: "ignores",
|
|
14472
|
+
value: function ignores(path$$1) {
|
|
14473
|
+
return !this._filter(path$$1);
|
|
14474
|
+
} // @returns `Boolean` true if the `path` is NOT ignored
|
|
14291
14475
|
|
|
14292
|
-
|
|
14293
|
-
|
|
14294
|
-
|
|
14295
|
-
|
|
14296
|
-
|
|
14297
|
-
|
|
14298
|
-
value: function ignores(path$$1) {
|
|
14299
|
-
return !this._filter(path$$1);
|
|
14300
|
-
}
|
|
14301
|
-
}, {
|
|
14302
|
-
key: '_createRule',
|
|
14303
|
-
value: function _createRule(pattern) {
|
|
14304
|
-
var origin = pattern;
|
|
14305
|
-
var negative = false; // > An optional prefix "!" which negates the pattern;
|
|
14476
|
+
}, {
|
|
14477
|
+
key: "_filter",
|
|
14478
|
+
value: function _filter(path$$1, slices) {
|
|
14479
|
+
if (!path$$1) {
|
|
14480
|
+
return false;
|
|
14481
|
+
}
|
|
14306
14482
|
|
|
14307
|
-
|
|
14308
|
-
|
|
14309
|
-
|
|
14310
|
-
}
|
|
14483
|
+
if (path$$1 in this._cache) {
|
|
14484
|
+
return this._cache[path$$1];
|
|
14485
|
+
}
|
|
14311
14486
|
|
|
14312
|
-
|
|
14313
|
-
|
|
14314
|
-
|
|
14315
|
-
|
|
14316
|
-
|
|
14317
|
-
origin: origin,
|
|
14318
|
-
pattern: pattern,
|
|
14319
|
-
negative: negative,
|
|
14320
|
-
regex: regex
|
|
14321
|
-
};
|
|
14322
|
-
} // @returns `Boolean` true if the `path` is NOT ignored
|
|
14487
|
+
if (!slices) {
|
|
14488
|
+
// path/to/a.js
|
|
14489
|
+
// ['path', 'to', 'a.js']
|
|
14490
|
+
slices = path$$1.split(SLASH);
|
|
14491
|
+
}
|
|
14323
14492
|
|
|
14324
|
-
|
|
14325
|
-
|
|
14326
|
-
|
|
14327
|
-
|
|
14328
|
-
|
|
14329
|
-
|
|
14493
|
+
slices.pop();
|
|
14494
|
+
return this._cache[path$$1] = slices.length // > It is not possible to re-include a file if a parent directory of
|
|
14495
|
+
// > that file is excluded.
|
|
14496
|
+
// If the path contains a parent directory, check the parent first
|
|
14497
|
+
? this._filter(slices.join(SLASH) + SLASH, slices) && this._test(path$$1) // Or only test the path
|
|
14498
|
+
: this._test(path$$1);
|
|
14499
|
+
} // @returns {Boolean} true if a file is NOT ignored
|
|
14330
14500
|
|
|
14331
|
-
|
|
14332
|
-
|
|
14333
|
-
|
|
14501
|
+
}, {
|
|
14502
|
+
key: "_test",
|
|
14503
|
+
value: function _test(path$$1) {
|
|
14504
|
+
// Explicitly define variable type by setting matched to `0`
|
|
14505
|
+
var matched = 0;
|
|
14506
|
+
|
|
14507
|
+
this._rules.forEach(function (rule) {
|
|
14508
|
+
// if matched = true, then we only test negative rules
|
|
14509
|
+
// if matched = false, then we test non-negative rules
|
|
14510
|
+
if (!(matched ^ rule.negative)) {
|
|
14511
|
+
matched = rule.negative ^ rule.regex.test(path$$1);
|
|
14512
|
+
}
|
|
14513
|
+
});
|
|
14334
14514
|
|
|
14335
|
-
|
|
14336
|
-
// path/to/a.js
|
|
14337
|
-
// ['path', 'to', 'a.js']
|
|
14338
|
-
slices = path$$1.split(SLASH);
|
|
14515
|
+
return !matched;
|
|
14339
14516
|
}
|
|
14517
|
+
}]);
|
|
14340
14518
|
|
|
14341
|
-
|
|
14342
|
-
|
|
14343
|
-
|
|
14344
|
-
? this._filter(slices.join(SLASH) + SLASH, slices) && this._test(path$$1) // Or only test the path
|
|
14345
|
-
: this._test(path$$1);
|
|
14346
|
-
} // @returns {Boolean} true if a file is NOT ignored
|
|
14519
|
+
return IgnoreBase;
|
|
14520
|
+
}(); // Windows
|
|
14521
|
+
// --------------------------------------------------------------
|
|
14347
14522
|
|
|
14348
|
-
|
|
14349
|
-
key: '_test',
|
|
14350
|
-
value: function _test(path$$1) {
|
|
14351
|
-
// Explicitly define variable type by setting matched to `0`
|
|
14352
|
-
var matched = 0;
|
|
14523
|
+
/* istanbul ignore if */
|
|
14353
14524
|
|
|
14354
|
-
this._rules.forEach(function (rule) {
|
|
14355
|
-
// if matched = true, then we only test negative rules
|
|
14356
|
-
// if matched = false, then we test non-negative rules
|
|
14357
|
-
if (!(matched ^ rule.negative)) {
|
|
14358
|
-
matched = rule.negative ^ rule.regex.test(path$$1);
|
|
14359
|
-
}
|
|
14360
|
-
});
|
|
14361
14525
|
|
|
14362
|
-
|
|
14363
|
-
|
|
14364
|
-
|
|
14526
|
+
if ( // Detect `process` so that it can run in browsers.
|
|
14527
|
+
typeof process !== 'undefined' && (process.env && process.env.IGNORE_TEST_WIN32 || process.platform === 'win32')) {
|
|
14528
|
+
var filter = IgnoreBase.prototype._filter;
|
|
14529
|
+
/* eslint no-control-regex: "off" */
|
|
14365
14530
|
|
|
14366
|
-
|
|
14367
|
-
|
|
14368
|
-
|
|
14369
|
-
// > but it would only find a match with a directory.
|
|
14370
|
-
// > In other words, foo/ will match a directory foo and paths underneath it,
|
|
14371
|
-
// > but will not match a regular file or a symbolic link foo
|
|
14372
|
-
// > (this is consistent with the way how pathspec works in general in Git).
|
|
14373
|
-
// '`foo/`' will not match regular file '`foo`' or symbolic link '`foo`'
|
|
14374
|
-
// -> ignore-rules will not deal with it, because it costs extra `fs.stat` call
|
|
14375
|
-
// you could use option `mark: true` with `glob`
|
|
14376
|
-
// '`foo/`' should not continue with the '`..`'
|
|
14377
|
-
|
|
14378
|
-
|
|
14379
|
-
var DEFAULT_REPLACER_PREFIX = [// > Trailing spaces are ignored unless they are quoted with backslash ("\")
|
|
14380
|
-
[// (a\ ) -> (a )
|
|
14381
|
-
// (a ) -> (a)
|
|
14382
|
-
// (a \ ) -> (a )
|
|
14383
|
-
/\\?\s+$/, function (match) {
|
|
14384
|
-
return match.indexOf('\\') === 0 ? ' ' : '';
|
|
14385
|
-
}], // replace (\ ) with ' '
|
|
14386
|
-
[/\\\s/g, function () {
|
|
14387
|
-
return ' ';
|
|
14388
|
-
}], // Escape metacharacters
|
|
14389
|
-
// which is written down by users but means special for regular expressions.
|
|
14390
|
-
// > There are 12 characters with special meanings:
|
|
14391
|
-
// > - the backslash \,
|
|
14392
|
-
// > - the caret ^,
|
|
14393
|
-
// > - the dollar sign $,
|
|
14394
|
-
// > - the period or dot .,
|
|
14395
|
-
// > - the vertical bar or pipe symbol |,
|
|
14396
|
-
// > - the question mark ?,
|
|
14397
|
-
// > - the asterisk or star *,
|
|
14398
|
-
// > - the plus sign +,
|
|
14399
|
-
// > - the opening parenthesis (,
|
|
14400
|
-
// > - the closing parenthesis ),
|
|
14401
|
-
// > - and the opening square bracket [,
|
|
14402
|
-
// > - the opening curly brace {,
|
|
14403
|
-
// > These special characters are often called "metacharacters".
|
|
14404
|
-
[/[\\\^$.|?*+()\[{]/g, function (match) {
|
|
14405
|
-
return '\\' + match;
|
|
14406
|
-
}], // leading slash
|
|
14407
|
-
[// > A leading slash matches the beginning of the pathname.
|
|
14408
|
-
// > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
|
|
14409
|
-
// A leading slash matches the beginning of the pathname
|
|
14410
|
-
/^\//, function () {
|
|
14411
|
-
return '^';
|
|
14412
|
-
}], // replace special metacharacter slash after the leading slash
|
|
14413
|
-
[/\//g, function () {
|
|
14414
|
-
return '\\/';
|
|
14415
|
-
}], [// > A leading "**" followed by a slash means match in all directories.
|
|
14416
|
-
// > For example, "**/foo" matches file or directory "foo" anywhere,
|
|
14417
|
-
// > the same as pattern "foo".
|
|
14418
|
-
// > "**/foo/bar" matches file or directory "bar" anywhere that is directly under directory "foo".
|
|
14419
|
-
// Notice that the '*'s have been replaced as '\\*'
|
|
14420
|
-
/^\^*\\\*\\\*\\\//, // '**/foo' <-> 'foo'
|
|
14421
|
-
function () {
|
|
14422
|
-
return '^(?:.*\\/)?';
|
|
14423
|
-
}]];
|
|
14424
|
-
var DEFAULT_REPLACER_SUFFIX = [// starting
|
|
14425
|
-
[// there will be no leading '/' (which has been replaced by section "leading slash")
|
|
14426
|
-
// If starts with '**', adding a '^' to the regular expression also works
|
|
14427
|
-
/^(?=[^\^])/, function () {
|
|
14428
|
-
return !/\/(?!$)/.test(this) // > If the pattern does not contain a slash /, Git treats it as a shell glob pattern
|
|
14429
|
-
// Actually, if there is only a trailing slash, git also treats it as a shell glob pattern
|
|
14430
|
-
? '(?:^|\\/)' // > Otherwise, Git treats the pattern as a shell glob suitable for consumption by fnmatch(3)
|
|
14431
|
-
: '^';
|
|
14432
|
-
}], // two globstars
|
|
14433
|
-
[// Use lookahead assertions so that we could match more than one `'/**'`
|
|
14434
|
-
/\\\/\\\*\\\*(?=\\\/|$)/g, // Zero, one or several directories
|
|
14435
|
-
// should not use '*', or it will be replaced by the next replacer
|
|
14436
|
-
// Check if it is not the last `'/**'`
|
|
14437
|
-
function (match, index, str) {
|
|
14438
|
-
return index + 6 < str.length // case: /**/
|
|
14439
|
-
// > A slash followed by two consecutive asterisks then a slash matches zero or more directories.
|
|
14440
|
-
// > For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on.
|
|
14441
|
-
// '/**/'
|
|
14442
|
-
? '(?:\\/[^\\/]+)*' // case: /**
|
|
14443
|
-
// > A trailing `"/**"` matches everything inside.
|
|
14444
|
-
// #21: everything inside but it should not include the current folder
|
|
14445
|
-
: '\\/.+';
|
|
14446
|
-
}], // intermediate wildcards
|
|
14447
|
-
[// Never replace escaped '*'
|
|
14448
|
-
// ignore rule '\*' will match the path '*'
|
|
14449
|
-
// 'abc.*/' -> go
|
|
14450
|
-
// 'abc.*' -> skip this rule
|
|
14451
|
-
/(^|[^\\]+)\\\*(?=.+)/g, // '*.js' matches '.js'
|
|
14452
|
-
// '*.js' doesn't match 'abc'
|
|
14453
|
-
function (match, p1) {
|
|
14454
|
-
return p1 + '[^\\/]*';
|
|
14455
|
-
}], // trailing wildcard
|
|
14456
|
-
[/(\^|\\\/)?\\\*$/, function (match, p1) {
|
|
14457
|
-
return (p1 // '\^':
|
|
14458
|
-
// '/*' does not match ''
|
|
14459
|
-
// '/*' does not match everything
|
|
14460
|
-
// '\\\/':
|
|
14461
|
-
// 'abc/*' does not match 'abc/'
|
|
14462
|
-
? p1 + '[^/]+' // 'a*' matches 'a'
|
|
14463
|
-
// 'a*' matches 'aa'
|
|
14464
|
-
: '[^/]*') + '(?=$|\\/$)';
|
|
14465
|
-
}], [// unescape
|
|
14466
|
-
/\\\\\\/g, function () {
|
|
14467
|
-
return '\\';
|
|
14468
|
-
}]];
|
|
14469
|
-
var POSITIVE_REPLACERS = [].concat(DEFAULT_REPLACER_PREFIX, [// 'f'
|
|
14470
|
-
// matches
|
|
14471
|
-
// - /f(end)
|
|
14472
|
-
// - /f/
|
|
14473
|
-
// - (start)f(end)
|
|
14474
|
-
// - (start)f/
|
|
14475
|
-
// doesn't match
|
|
14476
|
-
// - oof
|
|
14477
|
-
// - foo
|
|
14478
|
-
// pseudo:
|
|
14479
|
-
// -> (^|/)f(/|$)
|
|
14480
|
-
// ending
|
|
14481
|
-
[// 'js' will not match 'js.'
|
|
14482
|
-
// 'ab' will not match 'abc'
|
|
14483
|
-
/(?:[^*\/])$/, // 'js*' will not match 'a.js'
|
|
14484
|
-
// 'js/' will not match 'a.js'
|
|
14485
|
-
// 'js' will match 'a.js' and 'a.js/'
|
|
14486
|
-
function (match) {
|
|
14487
|
-
return match + '(?=$|\\/)';
|
|
14488
|
-
}]], DEFAULT_REPLACER_SUFFIX);
|
|
14489
|
-
var NEGATIVE_REPLACERS = [].concat(DEFAULT_REPLACER_PREFIX, [// #24
|
|
14490
|
-
// The MISSING rule of [gitignore docs](https://git-scm.com/docs/gitignore)
|
|
14491
|
-
// A negative pattern without a trailing wildcard should not
|
|
14492
|
-
// re-include the things inside that directory.
|
|
14493
|
-
// eg:
|
|
14494
|
-
// ['node_modules/*', '!node_modules']
|
|
14495
|
-
// should ignore `node_modules/a.js`
|
|
14496
|
-
[/(?:[^*\/])$/, function (match) {
|
|
14497
|
-
return match + '(?=$|\\/$)';
|
|
14498
|
-
}]], DEFAULT_REPLACER_SUFFIX); // A simple cache, because an ignore rule only has only one certain meaning
|
|
14499
|
-
|
|
14500
|
-
var cache = {}; // @param {pattern}
|
|
14501
|
-
|
|
14502
|
-
function make_regex(pattern, negative) {
|
|
14503
|
-
var r = cache[pattern];
|
|
14504
|
-
|
|
14505
|
-
if (r) {
|
|
14506
|
-
return r;
|
|
14507
|
-
}
|
|
14508
|
-
|
|
14509
|
-
var replacers = negative ? NEGATIVE_REPLACERS : POSITIVE_REPLACERS;
|
|
14510
|
-
var source = replacers.reduce(function (prev, current) {
|
|
14511
|
-
return prev.replace(current[0], current[1].bind(pattern));
|
|
14512
|
-
}, pattern);
|
|
14513
|
-
return cache[pattern] = new RegExp(source, 'i');
|
|
14514
|
-
} // Windows
|
|
14515
|
-
// --------------------------------------------------------------
|
|
14516
|
-
|
|
14517
|
-
/* istanbul ignore if */
|
|
14518
|
-
|
|
14519
|
-
|
|
14520
|
-
if ( // Detect `process` so that it can run in browsers.
|
|
14521
|
-
typeof process !== 'undefined' && (process.env && process.env.IGNORE_TEST_WIN32 || process.platform === 'win32')) {
|
|
14522
|
-
var filter = IgnoreBase.prototype._filter;
|
|
14523
|
-
|
|
14524
|
-
var make_posix = function make_posix(str) {
|
|
14525
|
-
return /^\\\\\?\\/.test(str) || /[^\x00-\x80]+/.test(str) ? str : str.replace(/\\/g, '/');
|
|
14526
|
-
};
|
|
14531
|
+
var make_posix = function make_posix(str) {
|
|
14532
|
+
return /^\\\\\?\\/.test(str) || /[^\x00-\x80]+/.test(str) ? str : str.replace(/\\/g, '/');
|
|
14533
|
+
};
|
|
14527
14534
|
|
|
14528
|
-
|
|
14529
|
-
|
|
14530
|
-
|
|
14535
|
+
IgnoreBase.prototype._filter = function filterWin32(path$$1, slices) {
|
|
14536
|
+
path$$1 = make_posix(path$$1);
|
|
14537
|
+
return filter.call(this, path$$1, slices);
|
|
14538
|
+
};
|
|
14539
|
+
}
|
|
14540
|
+
|
|
14541
|
+
module.exports = function (options) {
|
|
14542
|
+
return new IgnoreBase(options);
|
|
14531
14543
|
};
|
|
14532
|
-
}
|
|
14544
|
+
});
|
|
14533
14545
|
|
|
14534
14546
|
/**
|
|
14535
14547
|
* @param {string} filename
|
|
@@ -18295,9 +18307,9 @@ function charSet(s) {
|
|
|
18295
18307
|
|
|
18296
18308
|
|
|
18297
18309
|
var slashSplit = /\/+/;
|
|
18298
|
-
minimatch.filter = filter
|
|
18310
|
+
minimatch.filter = filter;
|
|
18299
18311
|
|
|
18300
|
-
function filter
|
|
18312
|
+
function filter(pattern, options) {
|
|
18301
18313
|
options = options || {};
|
|
18302
18314
|
return function (p, i, list) {
|
|
18303
18315
|
return minimatch(p, pattern, options);
|
|
@@ -22814,27 +22826,36 @@ var utils$4 = {
|
|
|
22814
22826
|
|
|
22815
22827
|
var hasFlowShorthandAnnotationComment$1 = utils$4.hasFlowShorthandAnnotationComment;
|
|
22816
22828
|
|
|
22817
|
-
function hasClosureCompilerTypeCastComment(text, path$$1
|
|
22829
|
+
function hasClosureCompilerTypeCastComment(text, path$$1) {
|
|
22818
22830
|
// https://github.com/google/closure-compiler/wiki/Annotating-Types#type-casts
|
|
22819
22831
|
// Syntax example: var x = /** @type {string} */ (fruit);
|
|
22820
22832
|
var n = path$$1.getValue();
|
|
22821
|
-
return
|
|
22833
|
+
return isParenthesized(n) && (hasTypeCastComment(n) || hasAncestorTypeCastComment(0)); // for sub-item: /** @type {array} */ (numberOrString).map(x => x);
|
|
22822
22834
|
|
|
22823
22835
|
function hasAncestorTypeCastComment(index) {
|
|
22824
22836
|
var ancestor = path$$1.getParentNode(index);
|
|
22825
|
-
return ancestor &&
|
|
22837
|
+
return ancestor && !isParenthesized(ancestor) ? hasTypeCastComment(ancestor) || hasAncestorTypeCastComment(index + 1) : false;
|
|
22826
22838
|
}
|
|
22827
22839
|
|
|
22828
22840
|
function hasTypeCastComment(node) {
|
|
22829
22841
|
return node.comments && node.comments.some(function (comment) {
|
|
22830
|
-
return comment.leading && comments$3.isBlockComment(comment) && isTypeCastComment(comment.value)
|
|
22842
|
+
return comment.leading && comments$3.isBlockComment(comment) && isTypeCastComment(comment.value);
|
|
22831
22843
|
});
|
|
22832
22844
|
}
|
|
22833
22845
|
|
|
22846
|
+
function isParenthesized(node) {
|
|
22847
|
+
// Closure typecast comments only really make sense when _not_ using
|
|
22848
|
+
// typescript or flow parsers, so we take advantage of the babel parser's
|
|
22849
|
+
// parenthesized expressions.
|
|
22850
|
+
return node.extra && node.extra.parenthesized;
|
|
22851
|
+
}
|
|
22852
|
+
|
|
22834
22853
|
function isTypeCastComment(comment) {
|
|
22835
|
-
var
|
|
22854
|
+
var cleaned = comment.trim().split("\n").map(function (line) {
|
|
22855
|
+
return line.replace(/^[\s*]+/, "");
|
|
22856
|
+
}).join(" ").trim();
|
|
22836
22857
|
|
|
22837
|
-
if (
|
|
22858
|
+
if (!/^@type\s+\{[^]+\}$/.test(cleaned)) {
|
|
22838
22859
|
return false;
|
|
22839
22860
|
}
|
|
22840
22861
|
|
|
@@ -22845,7 +22866,7 @@ function hasClosureCompilerTypeCastComment(text, path$$1, locStart, locEnd) {
|
|
|
22845
22866
|
var _iteratorError = undefined;
|
|
22846
22867
|
|
|
22847
22868
|
try {
|
|
22848
|
-
for (var _iterator =
|
|
22869
|
+
for (var _iterator = cleaned[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
22849
22870
|
var char = _step.value;
|
|
22850
22871
|
|
|
22851
22872
|
if (char === "{") {
|
|
@@ -22913,7 +22934,7 @@ function needsParens(path$$1, options) {
|
|
|
22913
22934
|
// parentheses.
|
|
22914
22935
|
|
|
22915
22936
|
|
|
22916
|
-
if (hasClosureCompilerTypeCastComment(options.originalText, path$$1
|
|
22937
|
+
if (hasClosureCompilerTypeCastComment(options.originalText, path$$1)) {
|
|
22917
22938
|
return true;
|
|
22918
22939
|
}
|
|
22919
22940
|
|
|
@@ -23224,6 +23245,7 @@ function needsParens(path$$1, options) {
|
|
|
23224
23245
|
case "TSAsExpression":
|
|
23225
23246
|
case "TSNonNullExpression":
|
|
23226
23247
|
case "BindExpression":
|
|
23248
|
+
case "OptionalMemberExpression":
|
|
23227
23249
|
return true;
|
|
23228
23250
|
|
|
23229
23251
|
case "MemberExpression":
|
|
@@ -23337,6 +23359,7 @@ function needsParens(path$$1, options) {
|
|
|
23337
23359
|
|
|
23338
23360
|
case "FunctionExpression":
|
|
23339
23361
|
switch (parent.type) {
|
|
23362
|
+
case "NewExpression":
|
|
23340
23363
|
case "CallExpression":
|
|
23341
23364
|
return name === "callee";
|
|
23342
23365
|
// Not strictly necessary, but it's clearer to the reader if IIFEs are wrapped in parentheses.
|
|
@@ -23381,7 +23404,16 @@ function needsParens(path$$1, options) {
|
|
|
23381
23404
|
}
|
|
23382
23405
|
|
|
23383
23406
|
case "ClassExpression":
|
|
23384
|
-
|
|
23407
|
+
switch (parent.type) {
|
|
23408
|
+
case "ExportDefaultDeclaration":
|
|
23409
|
+
return true;
|
|
23410
|
+
|
|
23411
|
+
case "NewExpression":
|
|
23412
|
+
return name === "callee" && parent.callee === node;
|
|
23413
|
+
|
|
23414
|
+
default:
|
|
23415
|
+
return false;
|
|
23416
|
+
}
|
|
23385
23417
|
|
|
23386
23418
|
case "OptionalMemberExpression":
|
|
23387
23419
|
return parent.type === "MemberExpression";
|
|
@@ -23413,7 +23445,7 @@ function needsParens(path$$1, options) {
|
|
|
23413
23445
|
return false;
|
|
23414
23446
|
|
|
23415
23447
|
case "NGPipeExpression":
|
|
23416
|
-
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") {
|
|
23448
|
+
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") {
|
|
23417
23449
|
return false;
|
|
23418
23450
|
}
|
|
23419
23451
|
|
|
@@ -23574,7 +23606,7 @@ var shouldFlatten$1 = util$1.shouldFlatten;
|
|
|
23574
23606
|
var getNextNonSpaceNonCommentCharacter$1 = util$1.getNextNonSpaceNonCommentCharacter;
|
|
23575
23607
|
var hasNewline$2 = util$1.hasNewline;
|
|
23576
23608
|
var hasNewlineInRange$1 = util$1.hasNewlineInRange;
|
|
23577
|
-
var getLast$
|
|
23609
|
+
var getLast$3 = util$1.getLast;
|
|
23578
23610
|
var getStringWidth$2 = util$1.getStringWidth;
|
|
23579
23611
|
var printString$1 = util$1.printString;
|
|
23580
23612
|
var printNumber$1 = util$1.printNumber;
|
|
@@ -23596,6 +23628,7 @@ var isVueEventBindingExpression = htmlBinding.isVueEventBindingExpression;
|
|
|
23596
23628
|
var hasNode = utils$4.hasNode;
|
|
23597
23629
|
var hasFlowAnnotationComment = utils$4.hasFlowAnnotationComment;
|
|
23598
23630
|
var hasFlowShorthandAnnotationComment = utils$4.hasFlowShorthandAnnotationComment;
|
|
23631
|
+
var needsQuoteProps = new WeakMap();
|
|
23599
23632
|
var _require$$6$builders = doc.builders;
|
|
23600
23633
|
var concat$4 = _require$$6$builders.concat;
|
|
23601
23634
|
var join$2 = _require$$6$builders.join;
|
|
@@ -23728,7 +23761,7 @@ function genericPrint(path$$1, options, printPath, args) {
|
|
|
23728
23761
|
}
|
|
23729
23762
|
|
|
23730
23763
|
function hasNewlineBetweenOrAfterDecorators(node, options) {
|
|
23731
|
-
return hasNewlineInRange$1(options.originalText, options.locStart(node.decorators[0]), options.locEnd(getLast$
|
|
23764
|
+
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)));
|
|
23732
23765
|
}
|
|
23733
23766
|
|
|
23734
23767
|
function printDecorators(path$$1, options, print) {
|
|
@@ -24045,7 +24078,7 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
24045
24078
|
return chain;
|
|
24046
24079
|
}
|
|
24047
24080
|
|
|
24048
|
-
var jsxPart = getLast$
|
|
24081
|
+
var jsxPart = getLast$3(_parts);
|
|
24049
24082
|
return group$1(concat$4([chain, ifBreak$1(indent$2(jsxPart), jsxPart, {
|
|
24050
24083
|
groupId
|
|
24051
24084
|
})]));
|
|
@@ -24390,7 +24423,7 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
24390
24423
|
if ( // We want to keep CommonJS- and AMD-style require calls, and AMD-style
|
|
24391
24424
|
// define calls, as a unit.
|
|
24392
24425
|
// e.g. `define(["some/lib", (lib) => {`
|
|
24393
|
-
!isNew && n.callee.type === "Identifier" && (n.callee.name === "require" || n.callee.name === "define") ||
|
|
24426
|
+
!isNew && n.callee.type === "Identifier" && (n.callee.name === "require" || n.callee.name === "define") || // Template literals as single arguments
|
|
24394
24427
|
n.arguments.length === 1 && isTemplateOnItsOwnLine(n.arguments[0], options.originalText, options) || // Keep test declarations on a single line
|
|
24395
24428
|
// e.g. `it('long name', () => {`
|
|
24396
24429
|
!isNew && isTestCall(n, path$$1.getParentNode())) {
|
|
@@ -24510,7 +24543,7 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
24510
24543
|
props.push(concat$4(separatorParts.concat(group$1("..."))));
|
|
24511
24544
|
}
|
|
24512
24545
|
|
|
24513
|
-
var lastElem = getLast$
|
|
24546
|
+
var lastElem = getLast$3(n[propertiesField]);
|
|
24514
24547
|
var canHaveTrailingSeparator = !(lastElem && (lastElem.type === "RestProperty" || lastElem.type === "RestElement" || hasNodeIgnoreComment$1(lastElem) || n.inexact));
|
|
24515
24548
|
var content;
|
|
24516
24549
|
|
|
@@ -24592,7 +24625,7 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
24592
24625
|
parts.push(group$1(concat$4(["[", comments.printDanglingComments(path$$1, options), softline$1, "]"])));
|
|
24593
24626
|
}
|
|
24594
24627
|
} else {
|
|
24595
|
-
var _lastElem = getLast$
|
|
24628
|
+
var _lastElem = getLast$3(n.elements);
|
|
24596
24629
|
|
|
24597
24630
|
var canHaveTrailingComma = !(_lastElem && _lastElem.type === "RestElement"); // JavaScript allows you to have empty elements in an array which
|
|
24598
24631
|
// changes its length based on the number of commas. The algorithm
|
|
@@ -25036,7 +25069,7 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
25036
25069
|
return group$1(concat$4(["<", path$$1.call(print, "name"), path$$1.call(print, "typeParameters"), " ", concat$4(path$$1.map(print, "attributes")), _n.selfClosing ? " />" : ">"]));
|
|
25037
25070
|
}
|
|
25038
25071
|
|
|
25039
|
-
var lastAttrHasTrailingComments = _n.attributes.length && hasTrailingComment(getLast$
|
|
25072
|
+
var lastAttrHasTrailingComments = _n.attributes.length && hasTrailingComment(getLast$3(_n.attributes));
|
|
25040
25073
|
var bracketSameLine = // Simple tags (no attributes and no comment in tag name) should be
|
|
25041
25074
|
// kept unbroken regardless of `jsxBracketSameLine`
|
|
25042
25075
|
!_n.attributes.length && !nameHasComments || options.jsxBracketSameLine && ( // We should print the bracket in a new line for the following cases:
|
|
@@ -26204,18 +26237,27 @@ function printStatementSequence(path$$1, options, print) {
|
|
|
26204
26237
|
|
|
26205
26238
|
function printPropertyKey(path$$1, options, print) {
|
|
26206
26239
|
var node = path$$1.getNode();
|
|
26240
|
+
var parent = path$$1.getParentNode();
|
|
26207
26241
|
var key = node.key;
|
|
26208
26242
|
|
|
26209
|
-
if (
|
|
26243
|
+
if (options.quoteProps === "consistent" && !needsQuoteProps.has(parent)) {
|
|
26244
|
+
var objectHasStringProp = (parent.properties || parent.body || parent.members).some(function (prop) {
|
|
26245
|
+
return prop.key && prop.key.type !== "Identifier" && !isStringPropSafeToCoerceToIdentifier(prop, options);
|
|
26246
|
+
});
|
|
26247
|
+
needsQuoteProps.set(parent, objectHasStringProp);
|
|
26248
|
+
}
|
|
26249
|
+
|
|
26250
|
+
if (key.type === "Identifier" && !node.computed && (options.parser === "json" || options.quoteProps === "consistent" && needsQuoteProps.get(parent))) {
|
|
26210
26251
|
// a -> "a"
|
|
26252
|
+
var prop = printString$1(JSON.stringify(key.name), options);
|
|
26211
26253
|
return path$$1.call(function (keyPath) {
|
|
26212
26254
|
return comments.printComments(keyPath, function () {
|
|
26213
|
-
return
|
|
26255
|
+
return prop;
|
|
26214
26256
|
}, options);
|
|
26215
26257
|
}, "key");
|
|
26216
26258
|
}
|
|
26217
26259
|
|
|
26218
|
-
if (
|
|
26260
|
+
if (isStringPropSafeToCoerceToIdentifier(node, options) && (options.quoteProps === "as-needed" || options.quoteProps === "consistent" && !needsQuoteProps.get(parent))) {
|
|
26219
26261
|
// 'a' -> a
|
|
26220
26262
|
return path$$1.call(function (keyPath) {
|
|
26221
26263
|
return comments.printComments(keyPath, function () {
|
|
@@ -26274,7 +26316,7 @@ function couldGroupArg(arg) {
|
|
|
26274
26316
|
}
|
|
26275
26317
|
|
|
26276
26318
|
function shouldGroupLastArg(args) {
|
|
26277
|
-
var lastArg = getLast$
|
|
26319
|
+
var lastArg = getLast$3(args);
|
|
26278
26320
|
var penultimateArg = getPenultimate$1(args);
|
|
26279
26321
|
return !hasLeadingComment(lastArg) && !hasTrailingComment(lastArg) && couldGroupArg(lastArg) && ( // If the last two arguments are of the same type,
|
|
26280
26322
|
// disable last element expansion.
|
|
@@ -26370,7 +26412,8 @@ function printArgumentsList(path$$1, options, print) {
|
|
|
26370
26412
|
|
|
26371
26413
|
return concat$4(parts);
|
|
26372
26414
|
}, "arguments");
|
|
26373
|
-
var maybeTrailingComma =
|
|
26415
|
+
var maybeTrailingComma = // Dynamic imports cannot have trailing commas
|
|
26416
|
+
!(node.callee && node.callee.type === "Import") && shouldPrintComma(options, "all") ? "," : "";
|
|
26374
26417
|
|
|
26375
26418
|
function allArgsBrokenOut() {
|
|
26376
26419
|
return group$1(concat$4(["(", indent$2(concat$4([line$3, concat$4(printedArguments)])), maybeTrailingComma, line$3, ")"]), {
|
|
@@ -26419,14 +26462,14 @@ function printArgumentsList(path$$1, options, print) {
|
|
|
26419
26462
|
var somePrintedArgumentsWillBreak = printedArguments.some(willBreak$1);
|
|
26420
26463
|
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], {
|
|
26421
26464
|
shouldBreak: true
|
|
26422
|
-
}), concat$4(printedExpanded.slice(1)), ")"]) : concat$4(["(", concat$4(printedArguments.slice(0, -1)), group$1(getLast$
|
|
26465
|
+
}), concat$4(printedExpanded.slice(1)), ")"]) : concat$4(["(", concat$4(printedArguments.slice(0, -1)), group$1(getLast$3(printedExpanded), {
|
|
26423
26466
|
shouldBreak: true
|
|
26424
26467
|
}), ")"]), allArgsBrokenOut()], {
|
|
26425
26468
|
shouldBreak
|
|
26426
26469
|
})]);
|
|
26427
26470
|
}
|
|
26428
26471
|
|
|
26429
|
-
return group$1(concat$4(["(", indent$2(concat$4([softline$1, concat$4(printedArguments)])), ifBreak$1(
|
|
26472
|
+
return group$1(concat$4(["(", indent$2(concat$4([softline$1, concat$4(printedArguments)])), ifBreak$1(maybeTrailingComma), softline$1, ")"]), {
|
|
26430
26473
|
shouldBreak: printedArguments.some(willBreak$1) || anyArgEmptyLine
|
|
26431
26474
|
});
|
|
26432
26475
|
}
|
|
@@ -26465,12 +26508,37 @@ function printFunctionTypeParameters(path$$1, options, print) {
|
|
|
26465
26508
|
|
|
26466
26509
|
function printFunctionParams(path$$1, print, options, expandArg, printTypeParams) {
|
|
26467
26510
|
var fun = path$$1.getValue();
|
|
26511
|
+
var parent = path$$1.getParentNode();
|
|
26468
26512
|
var paramsField = fun.parameters ? "parameters" : "params";
|
|
26513
|
+
var isParametersInTestCall = isTestCall(parent);
|
|
26514
|
+
var shouldHugParameters = shouldHugArguments(fun);
|
|
26515
|
+
var shouldExpandParameters = expandArg && !(fun[paramsField] && fun[paramsField].some(function (n) {
|
|
26516
|
+
return n.comments;
|
|
26517
|
+
}));
|
|
26469
26518
|
var typeParams = printTypeParams ? printFunctionTypeParameters(path$$1, options, print) : "";
|
|
26470
26519
|
var printed = [];
|
|
26471
26520
|
|
|
26472
26521
|
if (fun[paramsField]) {
|
|
26473
|
-
|
|
26522
|
+
var lastArgIndex = fun[paramsField].length - 1;
|
|
26523
|
+
printed = path$$1.map(function (childPath, index) {
|
|
26524
|
+
var parts = [];
|
|
26525
|
+
var param = childPath.getValue();
|
|
26526
|
+
parts.push(print(childPath));
|
|
26527
|
+
|
|
26528
|
+
if (index === lastArgIndex) {
|
|
26529
|
+
if (fun.rest) {
|
|
26530
|
+
parts.push(",", line$3);
|
|
26531
|
+
}
|
|
26532
|
+
} else if (isParametersInTestCall || shouldHugParameters || shouldExpandParameters) {
|
|
26533
|
+
parts.push(", ");
|
|
26534
|
+
} else if (isNextLineEmpty$2(options.originalText, param, options)) {
|
|
26535
|
+
parts.push(",", hardline$3, hardline$3);
|
|
26536
|
+
} else {
|
|
26537
|
+
parts.push(",", line$3);
|
|
26538
|
+
}
|
|
26539
|
+
|
|
26540
|
+
return concat$4(parts);
|
|
26541
|
+
}, paramsField);
|
|
26474
26542
|
}
|
|
26475
26543
|
|
|
26476
26544
|
if (fun.rest) {
|
|
@@ -26485,7 +26553,7 @@ function printFunctionParams(path$$1, print, options, expandArg, printTypeParams
|
|
|
26485
26553
|
}), ")"]);
|
|
26486
26554
|
}
|
|
26487
26555
|
|
|
26488
|
-
var lastParam = getLast$
|
|
26556
|
+
var lastParam = getLast$3(fun[paramsField]); // If the parent is a call with the first/last argument expansion and this is the
|
|
26489
26557
|
// params of the first/last argument, we dont want the arguments to break and instead
|
|
26490
26558
|
// want the whole expression to be on a new line.
|
|
26491
26559
|
//
|
|
@@ -26496,10 +26564,8 @@ function printFunctionParams(path$$1, print, options, expandArg, printTypeParams
|
|
|
26496
26564
|
// }) ) => {
|
|
26497
26565
|
// })
|
|
26498
26566
|
|
|
26499
|
-
if (
|
|
26500
|
-
return
|
|
26501
|
-
}))) {
|
|
26502
|
-
return group$1(concat$4([removeLines$1(typeParams), "(", join$2(", ", printed.map(removeLines$1)), ")"]));
|
|
26567
|
+
if (shouldExpandParameters) {
|
|
26568
|
+
return group$1(concat$4([removeLines$1(typeParams), "(", concat$4(printed.map(removeLines$1)), ")"]));
|
|
26503
26569
|
} // Single object destructuring should hug
|
|
26504
26570
|
//
|
|
26505
26571
|
// function({
|
|
@@ -26509,14 +26575,13 @@ function printFunctionParams(path$$1, print, options, expandArg, printTypeParams
|
|
|
26509
26575
|
// }) {}
|
|
26510
26576
|
|
|
26511
26577
|
|
|
26512
|
-
if (
|
|
26513
|
-
return concat$4([typeParams, "(",
|
|
26514
|
-
}
|
|
26578
|
+
if (shouldHugParameters) {
|
|
26579
|
+
return concat$4([typeParams, "(", concat$4(printed), ")"]);
|
|
26580
|
+
} // don't break in specs, eg; `it("should maintain parens around done even when long", (done) => {})`
|
|
26515
26581
|
|
|
26516
|
-
var parent = path$$1.getParentNode(); // don't break in specs, eg; `it("should maintain parens around done even when long", (done) => {})`
|
|
26517
26582
|
|
|
26518
|
-
if (
|
|
26519
|
-
return concat$4([typeParams, "(",
|
|
26583
|
+
if (isParametersInTestCall) {
|
|
26584
|
+
return concat$4([typeParams, "(", concat$4(printed), ")"]);
|
|
26520
26585
|
}
|
|
26521
26586
|
|
|
26522
26587
|
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;
|
|
@@ -26530,7 +26595,7 @@ function printFunctionParams(path$$1, print, options, expandArg, printTypeParams
|
|
|
26530
26595
|
}
|
|
26531
26596
|
|
|
26532
26597
|
var canHaveTrailingComma = !(lastParam && lastParam.type === "RestElement") && !fun.rest;
|
|
26533
|
-
return concat$4([typeParams, "(", indent$2(concat$4([softline$1,
|
|
26598
|
+
return concat$4([typeParams, "(", indent$2(concat$4([softline$1, concat$4(printed)])), ifBreak$1(canHaveTrailingComma && shouldPrintComma(options, "all") ? "," : ""), softline$1, ")"]);
|
|
26534
26599
|
}
|
|
26535
26600
|
|
|
26536
26601
|
function shouldPrintParamsWithoutParens(path$$1, options) {
|
|
@@ -27057,27 +27122,23 @@ function printMemberChain(path$$1, options, print) {
|
|
|
27057
27122
|
return firstNode.type === "ThisExpression" || firstNode.type === "Identifier" && (isFactory(firstNode.name) || isExpression && isShort(firstNode.name) || hasComputed);
|
|
27058
27123
|
}
|
|
27059
27124
|
|
|
27060
|
-
var lastNode = getLast$
|
|
27125
|
+
var lastNode = getLast$3(groups[0]).node;
|
|
27061
27126
|
return (lastNode.type === "MemberExpression" || lastNode.type === "OptionalMemberExpression") && lastNode.property.type === "Identifier" && (isFactory(lastNode.property.name) || hasComputed);
|
|
27062
27127
|
}
|
|
27063
27128
|
|
|
27064
27129
|
var shouldMerge = groups.length >= 2 && !groups[1][0].node.comments && shouldNotWrap(groups);
|
|
27065
27130
|
|
|
27066
27131
|
function printGroup(printedGroup) {
|
|
27067
|
-
var
|
|
27132
|
+
var printed = printedGroup.map(function (tuple) {
|
|
27133
|
+
return tuple.printed;
|
|
27134
|
+
}); // Checks if the last node (i.e. the parent node) needs parens and print
|
|
27135
|
+
// accordingly
|
|
27068
27136
|
|
|
27069
|
-
|
|
27070
|
-
|
|
27071
|
-
// and print accordingly
|
|
27072
|
-
if (printedGroup[_i3 + 1] && printedGroup[_i3 + 1].needsParens) {
|
|
27073
|
-
result.push("(", printedGroup[_i3].printed, printedGroup[_i3 + 1].printed, ")");
|
|
27074
|
-
_i3++;
|
|
27075
|
-
} else {
|
|
27076
|
-
result.push(printedGroup[_i3].printed);
|
|
27077
|
-
}
|
|
27137
|
+
if (printedGroup.length > 0 && printedGroup[printedGroup.length - 1].needsParens) {
|
|
27138
|
+
return concat$4(["("].concat(_toConsumableArray(printed), [")"]));
|
|
27078
27139
|
}
|
|
27079
27140
|
|
|
27080
|
-
return concat$4(
|
|
27141
|
+
return concat$4(printed);
|
|
27081
27142
|
}
|
|
27082
27143
|
|
|
27083
27144
|
function printIndentedGroup(groups) {
|
|
@@ -27107,7 +27168,7 @@ function printMemberChain(path$$1, options, print) {
|
|
|
27107
27168
|
// empty line after
|
|
27108
27169
|
|
|
27109
27170
|
|
|
27110
|
-
var lastNodeBeforeIndent = getLast$
|
|
27171
|
+
var lastNodeBeforeIndent = getLast$3(shouldMerge ? groups.slice(1, 2)[0] : groups[0]).node;
|
|
27111
27172
|
var shouldHaveEmptyLineBeforeIndent = lastNodeBeforeIndent.type !== "CallExpression" && lastNodeBeforeIndent.type !== "OptionalCallExpression" && shouldInsertEmptyLineAfter(lastNodeBeforeIndent);
|
|
27112
27173
|
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))]);
|
|
27113
27174
|
var callExpressions = printedNodes.map(function (_ref) {
|
|
@@ -27127,7 +27188,7 @@ function printMemberChain(path$$1, options, print) {
|
|
|
27127
27188
|
*/
|
|
27128
27189
|
function (lastGroupDoc, lastGroupNode) {
|
|
27129
27190
|
return isCallOrOptionalCallExpression(lastGroupNode) && willBreak$1(lastGroupDoc);
|
|
27130
|
-
}(getLast$
|
|
27191
|
+
}(getLast$3(printedGroups), getLast$3(getLast$3(groups)).node) && callExpressions.slice(0, -1).some(function (n) {
|
|
27131
27192
|
return n.arguments.some(isFunctionOrArrowExpression);
|
|
27132
27193
|
})) {
|
|
27133
27194
|
return group$1(expanded);
|
|
@@ -27338,7 +27399,7 @@ function printJSXChildren(path$$1, options, print, jsxWhitespace, isFacebookTran
|
|
|
27338
27399
|
|
|
27339
27400
|
var endWhitespace; // Ends with whitespace
|
|
27340
27401
|
|
|
27341
|
-
if (getLast$
|
|
27402
|
+
if (getLast$3(words) === "") {
|
|
27342
27403
|
words.pop();
|
|
27343
27404
|
endWhitespace = words.pop();
|
|
27344
27405
|
} // This was whitespace only without a new line.
|
|
@@ -27359,13 +27420,13 @@ function printJSXChildren(path$$1, options, print, jsxWhitespace, isFacebookTran
|
|
|
27359
27420
|
if (endWhitespace !== undefined) {
|
|
27360
27421
|
if (/\n/.test(endWhitespace)) {
|
|
27361
27422
|
var _next = n.children[i + 1];
|
|
27362
|
-
children.push(separatorWithWhitespace(isFacebookTranslationTag, getLast$
|
|
27423
|
+
children.push(separatorWithWhitespace(isFacebookTranslationTag, getLast$3(children), child, _next));
|
|
27363
27424
|
} else {
|
|
27364
27425
|
children.push(jsxWhitespace);
|
|
27365
27426
|
}
|
|
27366
27427
|
} else {
|
|
27367
27428
|
var _next2 = n.children[i + 1];
|
|
27368
|
-
children.push(separatorNoWhitespace(isFacebookTranslationTag, getLast$
|
|
27429
|
+
children.push(separatorNoWhitespace(isFacebookTranslationTag, getLast$3(children), child, _next2));
|
|
27369
27430
|
}
|
|
27370
27431
|
} else if (/\n/.test(text)) {
|
|
27371
27432
|
// Keep (up to one) blank line between tags/expressions/text.
|
|
@@ -27474,7 +27535,7 @@ function printJSXElement(path$$1, options, print) {
|
|
|
27474
27535
|
} // Trim trailing lines (or empty strings)
|
|
27475
27536
|
|
|
27476
27537
|
|
|
27477
|
-
while (children.length && (isLineNext$1(getLast$
|
|
27538
|
+
while (children.length && (isLineNext$1(getLast$3(children)) || isEmpty$1(getLast$3(children)))) {
|
|
27478
27539
|
children.pop();
|
|
27479
27540
|
} // Trim leading lines (or empty strings)
|
|
27480
27541
|
|
|
@@ -28021,7 +28082,7 @@ function needsHardlineAfterDanglingComment(node) {
|
|
|
28021
28082
|
return false;
|
|
28022
28083
|
}
|
|
28023
28084
|
|
|
28024
|
-
var lastDanglingComment = getLast$
|
|
28085
|
+
var lastDanglingComment = getLast$3(node.comments.filter(function (comment) {
|
|
28025
28086
|
return !comment.leading && !comment.trailing;
|
|
28026
28087
|
}));
|
|
28027
28088
|
return lastDanglingComment && !comments$3.isBlockComment(lastDanglingComment);
|
|
@@ -28031,6 +28092,10 @@ function isLiteral(node) {
|
|
|
28031
28092
|
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";
|
|
28032
28093
|
}
|
|
28033
28094
|
|
|
28095
|
+
function isStringPropSafeToCoerceToIdentifier(node, options) {
|
|
28096
|
+
return isStringLiteral(node.key) && isIdentifierName(node.key.value) && !node.computed && options.parser !== "json" && !(options.parser === "typescript" && node.type === "ClassProperty");
|
|
28097
|
+
}
|
|
28098
|
+
|
|
28034
28099
|
function isNumericLiteral(node) {
|
|
28035
28100
|
return node.type === "NumericLiteral" || node.type === "Literal" && typeof node.value === "number";
|
|
28036
28101
|
}
|
|
@@ -28121,7 +28186,7 @@ function willPrintOwnComments(path$$1) {
|
|
|
28121
28186
|
}
|
|
28122
28187
|
|
|
28123
28188
|
function canAttachComment(node) {
|
|
28124
|
-
return node.type && node.type !== "CommentBlock" && node.type !== "CommentLine" && node.type !== "Line" && node.type !== "Block" && node.type !== "EmptyStatement" && node.type !== "TemplateElement" && node.type !== "Import"
|
|
28189
|
+
return node.type && node.type !== "CommentBlock" && node.type !== "CommentLine" && node.type !== "Line" && node.type !== "Block" && node.type !== "EmptyStatement" && node.type !== "TemplateElement" && node.type !== "Import";
|
|
28125
28190
|
}
|
|
28126
28191
|
|
|
28127
28192
|
function printComment$1(commentPath, options) {
|
|
@@ -28373,6 +28438,23 @@ var options$3 = {
|
|
|
28373
28438
|
default: false,
|
|
28374
28439
|
description: "Use single quotes in JSX."
|
|
28375
28440
|
},
|
|
28441
|
+
quoteProps: {
|
|
28442
|
+
since: "1.17.0",
|
|
28443
|
+
category: CATEGORY_JAVASCRIPT,
|
|
28444
|
+
type: "choice",
|
|
28445
|
+
default: "as-needed",
|
|
28446
|
+
description: "Change when properties in objects are quoted.",
|
|
28447
|
+
choices: [{
|
|
28448
|
+
value: "as-needed",
|
|
28449
|
+
description: "Only add quotes around object properties where required."
|
|
28450
|
+
}, {
|
|
28451
|
+
value: "consistent",
|
|
28452
|
+
description: "If at least one property in an object requires quotes, quote all properties."
|
|
28453
|
+
}, {
|
|
28454
|
+
value: "preserve",
|
|
28455
|
+
description: "Respect the input use of quotes in object properties."
|
|
28456
|
+
}]
|
|
28457
|
+
},
|
|
28376
28458
|
trailingComma: {
|
|
28377
28459
|
since: "0.0.0",
|
|
28378
28460
|
category: CATEGORY_JAVASCRIPT,
|
|
@@ -30157,8 +30239,8 @@ function print(path$$1, options, print) {
|
|
|
30157
30239
|
case "BlockStatement":
|
|
30158
30240
|
{
|
|
30159
30241
|
var pp = path$$1.getParentNode(1);
|
|
30160
|
-
var isElseIf = pp && pp.inverse && pp.inverse.body[0] === n && pp.inverse.body[0].path.parts[0] === "if";
|
|
30161
|
-
var hasElseIf = n.inverse && n.inverse.body
|
|
30242
|
+
var isElseIf = pp && pp.inverse && pp.inverse.body.length === 1 && pp.inverse.body[0] === n && pp.inverse.body[0].path.parts[0] === "if";
|
|
30243
|
+
var hasElseIf = n.inverse && n.inverse.body.length === 1 && n.inverse.body[0].type === "BlockStatement" && n.inverse.body[0].path.parts[0] === "if";
|
|
30162
30244
|
var indentElse = hasElseIf ? function (a) {
|
|
30163
30245
|
return a;
|
|
30164
30246
|
} : indent$6;
|
|
@@ -30526,7 +30608,7 @@ function genericPrint$3(path$$1, options, print) {
|
|
|
30526
30608
|
|
|
30527
30609
|
case "FragmentDefinition":
|
|
30528
30610
|
{
|
|
30529
|
-
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")]);
|
|
30611
|
+
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")]);
|
|
30530
30612
|
}
|
|
30531
30613
|
|
|
30532
30614
|
case "SelectionSet":
|
|
@@ -30609,7 +30691,7 @@ function genericPrint$3(path$$1, options, print) {
|
|
|
30609
30691
|
|
|
30610
30692
|
case "VariableDefinition":
|
|
30611
30693
|
{
|
|
30612
|
-
return concat$11([path$$1.call(print, "variable"), ": ", path$$1.call(print, "type"), n.defaultValue ? concat$11([" = ", path$$1.call(print, "defaultValue")]) : ""]);
|
|
30694
|
+
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)]);
|
|
30613
30695
|
}
|
|
30614
30696
|
|
|
30615
30697
|
case "TypeExtensionDefinition":
|
|
@@ -30842,7 +30924,7 @@ var json$6 = {"cjkPattern":"[\\u02ea-\\u02eb\\u1100-\\u11ff\\u2e80-\\u2e99\\u2e9
|
|
|
30842
30924
|
var cjkPattern = json$6.cjkPattern;
|
|
30843
30925
|
var kPattern = json$6.kPattern;
|
|
30844
30926
|
var punctuationPattern$1 = json$6.punctuationPattern;
|
|
30845
|
-
var getLast$
|
|
30927
|
+
var getLast$4 = util$1.getLast;
|
|
30846
30928
|
var INLINE_NODE_TYPES$1 = ["liquidNode", "inlineCode", "emphasis", "strong", "delete", "link", "linkReference", "image", "imageReference", "footnote", "footnoteReference", "sentence", "whitespace", "word", "break", "inlineMath"];
|
|
30847
30929
|
var INLINE_NODE_WRAPPER_TYPES$1 = INLINE_NODE_TYPES$1.concat(["tableCell", "paragraph", "heading"]);
|
|
30848
30930
|
var kRegex = new RegExp(kPattern);
|
|
@@ -30887,7 +30969,7 @@ function splitText$1(text, options) {
|
|
|
30887
30969
|
value: innerToken,
|
|
30888
30970
|
kind: KIND_NON_CJK,
|
|
30889
30971
|
hasLeadingPunctuation: punctuationRegex.test(innerToken[0]),
|
|
30890
|
-
hasTrailingPunctuation: punctuationRegex.test(getLast$
|
|
30972
|
+
hasTrailingPunctuation: punctuationRegex.test(getLast$4(innerToken))
|
|
30891
30973
|
});
|
|
30892
30974
|
}
|
|
30893
30975
|
|
|
@@ -30913,7 +30995,7 @@ function splitText$1(text, options) {
|
|
|
30913
30995
|
return nodes;
|
|
30914
30996
|
|
|
30915
30997
|
function appendNode(node) {
|
|
30916
|
-
var lastNode = getLast$
|
|
30998
|
+
var lastNode = getLast$4(nodes);
|
|
30917
30999
|
|
|
30918
31000
|
if (lastNode && lastNode.type === "word") {
|
|
30919
31001
|
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) {
|
|
@@ -31375,6 +31457,7 @@ function markAlignedList(ast, options) {
|
|
|
31375
31457
|
var preprocess_1$2 = preprocess$2;
|
|
31376
31458
|
|
|
31377
31459
|
var _require$$0$builders$6 = doc.builders;
|
|
31460
|
+
var breakParent$3 = _require$$0$builders$6.breakParent;
|
|
31378
31461
|
var concat$12 = _require$$0$builders$6.concat;
|
|
31379
31462
|
var join$9 = _require$$0$builders$6.join;
|
|
31380
31463
|
var line$8 = _require$$0$builders$6.line;
|
|
@@ -31382,6 +31465,7 @@ var literalline$4 = _require$$0$builders$6.literalline;
|
|
|
31382
31465
|
var markAsRoot$2 = _require$$0$builders$6.markAsRoot;
|
|
31383
31466
|
var hardline$10 = _require$$0$builders$6.hardline;
|
|
31384
31467
|
var softline$6 = _require$$0$builders$6.softline;
|
|
31468
|
+
var ifBreak$5 = _require$$0$builders$6.ifBreak;
|
|
31385
31469
|
var fill$4 = _require$$0$builders$6.fill;
|
|
31386
31470
|
var align$2 = _require$$0$builders$6.align;
|
|
31387
31471
|
var indent$8 = _require$$0$builders$6.indent;
|
|
@@ -31734,6 +31818,7 @@ function printLine(path$$1, value, options) {
|
|
|
31734
31818
|
}
|
|
31735
31819
|
|
|
31736
31820
|
function printTable(path$$1, options, print) {
|
|
31821
|
+
var hardlineWithoutBreakParent = hardline$10.parts[0];
|
|
31737
31822
|
var node = path$$1.getValue();
|
|
31738
31823
|
var contents = []; // { [rowIndex: number]: { [columnIndex: number]: string } }
|
|
31739
31824
|
|
|
@@ -31743,7 +31828,8 @@ function printTable(path$$1, options, print) {
|
|
|
31743
31828
|
rowContents.push(printDocToString$3(cellPath.call(print), options).formatted);
|
|
31744
31829
|
}, "children");
|
|
31745
31830
|
contents.push(rowContents);
|
|
31746
|
-
}, "children");
|
|
31831
|
+
}, "children"); // Get the width of each column
|
|
31832
|
+
|
|
31747
31833
|
var columnMaxWidths = contents.reduce(function (currentWidths, rowContents) {
|
|
31748
31834
|
return currentWidths.map(function (width, columnIndex) {
|
|
31749
31835
|
return Math.max(width, util$1.getStringWidth(rowContents[columnIndex]));
|
|
@@ -31752,28 +31838,48 @@ function printTable(path$$1, options, print) {
|
|
|
31752
31838
|
return 3;
|
|
31753
31839
|
}) // minimum width = 3 (---, :--, :-:, --:)
|
|
31754
31840
|
);
|
|
31755
|
-
|
|
31756
|
-
|
|
31757
|
-
|
|
31841
|
+
var alignedTable = join$9(hardlineWithoutBreakParent, [printRow(contents[0]), printSeparator(), join$9(hardlineWithoutBreakParent, contents.slice(1).map(function (rowContents) {
|
|
31842
|
+
return printRow(rowContents);
|
|
31843
|
+
}))]);
|
|
31844
|
+
|
|
31845
|
+
if (options.proseWrap !== "never") {
|
|
31846
|
+
return concat$12([breakParent$3, alignedTable]);
|
|
31847
|
+
} // Only if the --prose-wrap never is set and it exceeds the print width.
|
|
31848
|
+
|
|
31849
|
+
|
|
31850
|
+
var compactTable = join$9(hardlineWithoutBreakParent, [printRow(contents[0],
|
|
31851
|
+
/* isCompact */
|
|
31852
|
+
true), printSeparator(
|
|
31853
|
+
/* isCompact */
|
|
31854
|
+
true), join$9(hardlineWithoutBreakParent, contents.slice(1).map(function (rowContents) {
|
|
31855
|
+
return printRow(rowContents,
|
|
31856
|
+
/* isCompact */
|
|
31857
|
+
true);
|
|
31858
|
+
}))]);
|
|
31859
|
+
return concat$12([breakParent$3, group$13(ifBreak$5(compactTable, alignedTable))]);
|
|
31860
|
+
|
|
31861
|
+
function printSeparator(isCompact) {
|
|
31758
31862
|
return concat$12(["| ", join$9(" | ", columnMaxWidths.map(function (width, index) {
|
|
31863
|
+
var spaces = isCompact ? 3 : width;
|
|
31864
|
+
|
|
31759
31865
|
switch (node.align[index]) {
|
|
31760
31866
|
case "left":
|
|
31761
|
-
return ":" + "-".repeat(
|
|
31867
|
+
return ":" + "-".repeat(spaces - 1);
|
|
31762
31868
|
|
|
31763
31869
|
case "right":
|
|
31764
|
-
return "-".repeat(
|
|
31870
|
+
return "-".repeat(spaces - 1) + ":";
|
|
31765
31871
|
|
|
31766
31872
|
case "center":
|
|
31767
|
-
return ":" + "-".repeat(
|
|
31873
|
+
return ":" + "-".repeat(spaces - 2) + ":";
|
|
31768
31874
|
|
|
31769
31875
|
default:
|
|
31770
|
-
return "-".repeat(
|
|
31876
|
+
return "-".repeat(spaces);
|
|
31771
31877
|
}
|
|
31772
31878
|
})), " |"]);
|
|
31773
31879
|
}
|
|
31774
31880
|
|
|
31775
|
-
function printRow(rowContents) {
|
|
31776
|
-
return concat$12(["| ", join$9(" | ", rowContents.map(function (rowContent, columnIndex) {
|
|
31881
|
+
function printRow(rowContents, isCompact) {
|
|
31882
|
+
return concat$12(["| ", join$9(" | ", isCompact ? rowContents : rowContents.map(function (rowContent, columnIndex) {
|
|
31777
31883
|
switch (node.align[columnIndex]) {
|
|
31778
31884
|
case "right":
|
|
31779
31885
|
return alignRight(rowContent, columnMaxWidths[columnIndex]);
|
|
@@ -31788,11 +31894,13 @@ function printTable(path$$1, options, print) {
|
|
|
31788
31894
|
}
|
|
31789
31895
|
|
|
31790
31896
|
function alignLeft(text, width) {
|
|
31791
|
-
|
|
31897
|
+
var spaces = width - util$1.getStringWidth(text);
|
|
31898
|
+
return concat$12([text, " ".repeat(spaces)]);
|
|
31792
31899
|
}
|
|
31793
31900
|
|
|
31794
31901
|
function alignRight(text, width) {
|
|
31795
|
-
|
|
31902
|
+
var spaces = width - util$1.getStringWidth(text);
|
|
31903
|
+
return concat$12([" ".repeat(spaces), text]);
|
|
31796
31904
|
}
|
|
31797
31905
|
|
|
31798
31906
|
function alignCenter(text, width) {
|
|
@@ -33817,7 +33925,7 @@ var parseSrcset = createCommonjsModule(function (module) {
|
|
|
33817
33925
|
|
|
33818
33926
|
var _require$$0$builders$9 = doc.builders;
|
|
33819
33927
|
var concat$16 = _require$$0$builders$9.concat;
|
|
33820
|
-
var ifBreak$
|
|
33928
|
+
var ifBreak$7 = _require$$0$builders$9.ifBreak;
|
|
33821
33929
|
var join$11 = _require$$0$builders$9.join;
|
|
33822
33930
|
var line$10 = _require$$0$builders$9.line;
|
|
33823
33931
|
|
|
@@ -33875,7 +33983,7 @@ function printImgSrcset$1(value) {
|
|
|
33875
33983
|
var urlPadding = maxUrlLength - url.length + 1;
|
|
33876
33984
|
var descriptorPadding = maxDescriptorLeftLength - descriptorLeftLengths[index];
|
|
33877
33985
|
var alignment = " ".repeat(urlPadding + descriptorPadding);
|
|
33878
|
-
parts.push(ifBreak$
|
|
33986
|
+
parts.push(ifBreak$7(alignment, " "), descriptor + unit);
|
|
33879
33987
|
}
|
|
33880
33988
|
|
|
33881
33989
|
return concat$16(parts);
|
|
@@ -33890,12 +33998,12 @@ var builders = doc.builders;
|
|
|
33890
33998
|
var _require$$0$utils = doc.utils;
|
|
33891
33999
|
var stripTrailingHardline$2 = _require$$0$utils.stripTrailingHardline;
|
|
33892
34000
|
var mapDoc$7 = _require$$0$utils.mapDoc;
|
|
33893
|
-
var breakParent$
|
|
34001
|
+
var breakParent$4 = builders.breakParent;
|
|
33894
34002
|
var dedentToRoot$2 = builders.dedentToRoot;
|
|
33895
34003
|
var fill$5 = builders.fill;
|
|
33896
34004
|
var group$14 = builders.group;
|
|
33897
34005
|
var hardline$12 = builders.hardline;
|
|
33898
|
-
var ifBreak$
|
|
34006
|
+
var ifBreak$6 = builders.ifBreak;
|
|
33899
34007
|
var indent$9 = builders.indent;
|
|
33900
34008
|
var join$10 = builders.join;
|
|
33901
34009
|
var line$9 = builders.line;
|
|
@@ -33942,7 +34050,7 @@ function embed$6(path$$1, print, textToDoc, options) {
|
|
|
33942
34050
|
|
|
33943
34051
|
if (parser) {
|
|
33944
34052
|
var value = parser === "markdown" ? dedentString(node.value.replace(/^[^\S\n]*?\n/, "")) : node.value;
|
|
33945
|
-
return builders.concat([concat$14([breakParent$
|
|
34053
|
+
return builders.concat([concat$14([breakParent$4, printOpeningTagPrefix(node, options), stripTrailingHardline$2(textToDoc(value, {
|
|
33946
34054
|
parser
|
|
33947
34055
|
})), printClosingTagSuffix(node, options)])]);
|
|
33948
34056
|
}
|
|
@@ -33972,6 +34080,15 @@ function embed$6(path$$1, print, textToDoc, options) {
|
|
|
33972
34080
|
|
|
33973
34081
|
if (/^PRETTIER_HTML_PLACEHOLDER_\d+_IN_JS$/.test(options.originalText.slice(node.valueSpan.start.offset, node.valueSpan.end.offset))) {
|
|
33974
34082
|
return concat$14([node.rawName, "=", node.value]);
|
|
34083
|
+
} // lwc: html`<my-element data-for={value}></my-elememt>`
|
|
34084
|
+
|
|
34085
|
+
|
|
34086
|
+
if (options.parser === "lwc") {
|
|
34087
|
+
var interpolationRegex = /^\{[\s\S]*\}$/;
|
|
34088
|
+
|
|
34089
|
+
if (interpolationRegex.test(options.originalText.slice(node.valueSpan.start.offset, node.valueSpan.end.offset))) {
|
|
34090
|
+
return concat$14([node.rawName, "=", node.value]);
|
|
34091
|
+
}
|
|
33975
34092
|
}
|
|
33976
34093
|
|
|
33977
34094
|
var embeddedAttributeValueDoc = printEmbeddedAttributeValue(node, function (code, opts) {
|
|
@@ -34033,13 +34150,13 @@ function genericPrint$5(path$$1, options, print) {
|
|
|
34033
34150
|
var attrGroupId = Symbol("element-attr-group-id");
|
|
34034
34151
|
return concat$14([group$14(concat$14([group$14(printOpeningTag(path$$1, options, print), {
|
|
34035
34152
|
id: attrGroupId
|
|
34036
|
-
}), node.children.length === 0 ? node.hasDanglingSpaces && node.isDanglingSpaceSensitive ? line$9 : "" : concat$14([forceBreakContent(node) ? breakParent$
|
|
34037
|
-
return shouldHugContent ? ifBreak$
|
|
34153
|
+
}), node.children.length === 0 ? node.hasDanglingSpaces && node.isDanglingSpaceSensitive ? line$9 : "" : concat$14([forceBreakContent(node) ? breakParent$4 : "", function (childrenDoc) {
|
|
34154
|
+
return shouldHugContent ? ifBreak$6(indent$9(childrenDoc), childrenDoc, {
|
|
34038
34155
|
groupId: attrGroupId
|
|
34039
34156
|
}) : isScriptLikeTag(node) && node.parent.type === "root" && options.parser === "vue" ? childrenDoc : indent$9(childrenDoc);
|
|
34040
|
-
}(concat$14([shouldHugContent ? ifBreak$
|
|
34157
|
+
}(concat$14([shouldHugContent ? ifBreak$6(softline$7, "", {
|
|
34041
34158
|
groupId: attrGroupId
|
|
34042
|
-
}) : 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$
|
|
34159
|
+
}) : 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, "", {
|
|
34043
34160
|
groupId: attrGroupId
|
|
34044
34161
|
}) : 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) {
|
|
34045
34162
|
return n.parent && n.parent.type !== "root";
|
|
@@ -34110,7 +34227,7 @@ function printChildren$1(path$$1, options, print) {
|
|
|
34110
34227
|
var node = path$$1.getValue();
|
|
34111
34228
|
|
|
34112
34229
|
if (forceBreakChildren(node)) {
|
|
34113
|
-
return concat$14([breakParent$
|
|
34230
|
+
return concat$14([breakParent$4, concat$14(path$$1.map(function (childPath) {
|
|
34114
34231
|
var childNode = childPath.getValue();
|
|
34115
34232
|
var prevBetweenLine = !childNode.prev ? "" : printBetweenLine(childNode.prev, childNode);
|
|
34116
34233
|
return concat$14([!prevBetweenLine ? "" : concat$14([prevBetweenLine, forceNextEmptyLine(childNode.prev) ? hardline$12 : ""]), printChild(childPath)]);
|
|
@@ -34155,7 +34272,7 @@ function printChildren$1(path$$1, options, print) {
|
|
|
34155
34272
|
if (isTextLikeNode(childNode.prev)) {
|
|
34156
34273
|
leadingParts.push(prevBetweenLine);
|
|
34157
34274
|
} else {
|
|
34158
|
-
leadingParts.push(ifBreak$
|
|
34275
|
+
leadingParts.push(ifBreak$6("", softline$7, {
|
|
34159
34276
|
groupId: groupIds[childIndex - 1]
|
|
34160
34277
|
}));
|
|
34161
34278
|
}
|
|
@@ -34752,6 +34869,15 @@ var languages$5 = [createLanguage(require$$0$31, {
|
|
|
34752
34869
|
extensions: [".mjml" // MJML is considered XML in Linguist but it should be formatted as HTML
|
|
34753
34870
|
]
|
|
34754
34871
|
}
|
|
34872
|
+
}), createLanguage(require$$0$31, {
|
|
34873
|
+
override: {
|
|
34874
|
+
name: "Lightning Web Components",
|
|
34875
|
+
since: "1.17.0",
|
|
34876
|
+
parsers: ["lwc"],
|
|
34877
|
+
vscodeLanguageIds: ["html"],
|
|
34878
|
+
extensions: [],
|
|
34879
|
+
filenames: []
|
|
34880
|
+
}
|
|
34755
34881
|
}), createLanguage(require$$1$10, {
|
|
34756
34882
|
override: {
|
|
34757
34883
|
since: "1.10.0",
|
|
@@ -34786,7 +34912,7 @@ var pragma$11 = {
|
|
|
34786
34912
|
insertPragma: insertPragma$9
|
|
34787
34913
|
};
|
|
34788
34914
|
|
|
34789
|
-
var getLast$
|
|
34915
|
+
var getLast$6 = util$1.getLast;
|
|
34790
34916
|
|
|
34791
34917
|
function getAncestorCount$1(path$$1, filter) {
|
|
34792
34918
|
var counter = 0;
|
|
@@ -34875,7 +35001,7 @@ function isLastDescendantNode$1(path$$1) {
|
|
|
34875
35001
|
}
|
|
34876
35002
|
|
|
34877
35003
|
function getLastDescendantNode$2(node) {
|
|
34878
|
-
return "children" in node && node.children.length !== 0 ? getLastDescendantNode$2(getLast$
|
|
35004
|
+
return "children" in node && node.children.length !== 0 ? getLastDescendantNode$2(getLast$6(node.children)) : node;
|
|
34879
35005
|
}
|
|
34880
35006
|
|
|
34881
35007
|
function isPrettierIgnore$2(comment) {
|
|
@@ -34887,10 +35013,10 @@ function hasPrettierIgnore$5(path$$1) {
|
|
|
34887
35013
|
|
|
34888
35014
|
if (node.type === "documentBody") {
|
|
34889
35015
|
var document = path$$1.getParentNode();
|
|
34890
|
-
return hasEndComments$1(document.head) && isPrettierIgnore$2(getLast$
|
|
35016
|
+
return hasEndComments$1(document.head) && isPrettierIgnore$2(getLast$6(document.head.endComments));
|
|
34891
35017
|
}
|
|
34892
35018
|
|
|
34893
|
-
return hasLeadingComments$1(node) && isPrettierIgnore$2(getLast$
|
|
35019
|
+
return hasLeadingComments$1(node) && isPrettierIgnore$2(getLast$6(node.leadingComments));
|
|
34894
35020
|
}
|
|
34895
35021
|
|
|
34896
35022
|
function isEmptyNode$1(node) {
|
|
@@ -34990,7 +35116,7 @@ function getFlowScalarLineContents$1(nodeType, content, options) {
|
|
|
34990
35116
|
return lineContent.length === 0 ? [] : splitWithSingleSpace(lineContent);
|
|
34991
35117
|
}).reduce(function (reduced, lineContentWords, index) {
|
|
34992
35118
|
return index !== 0 && rawLineContents[index - 1].length !== 0 && lineContentWords.length !== 0 && !( // trailing backslash in quoteDouble should be preserved
|
|
34993
|
-
nodeType === "quoteDouble" && getLast$
|
|
35119
|
+
nodeType === "quoteDouble" && getLast$6(getLast$6(reduced)).endsWith("\\")) ? reduced.concat([reduced.pop().concat(lineContentWords)]) : reduced.concat([lineContentWords]);
|
|
34994
35120
|
}, []).map(function (lineContentWords) {
|
|
34995
35121
|
return options.proseWrap === "never" ? [lineContentWords.join(" ")] : lineContentWords;
|
|
34996
35122
|
});
|
|
@@ -35018,11 +35144,11 @@ function getBlockValueLineContents$1(node, _ref) {
|
|
|
35018
35144
|
return removeUnnecessaryTrailingNewlines(rawLineContents.map(function (lineContent) {
|
|
35019
35145
|
return lineContent.length === 0 ? [] : splitWithSingleSpace(lineContent);
|
|
35020
35146
|
}).reduce(function (reduced, lineContentWords, index) {
|
|
35021
|
-
return index !== 0 && rawLineContents[index - 1].length !== 0 && lineContentWords.length !== 0 && !/^\s/.test(lineContentWords[0]) && !/^\s|\s$/.test(getLast$
|
|
35147
|
+
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]);
|
|
35022
35148
|
}, []).map(function (lineContentWords) {
|
|
35023
35149
|
return lineContentWords.reduce(function (reduced, word) {
|
|
35024
35150
|
return (// disallow trailing spaces
|
|
35025
|
-
reduced.length !== 0 && /\s$/.test(getLast$
|
|
35151
|
+
reduced.length !== 0 && /\s$/.test(getLast$6(reduced)) ? reduced.concat(reduced.pop() + " " + word) : reduced.concat(word)
|
|
35026
35152
|
);
|
|
35027
35153
|
}, []);
|
|
35028
35154
|
}).map(function (lineContentWords) {
|
|
@@ -35031,7 +35157,7 @@ function getBlockValueLineContents$1(node, _ref) {
|
|
|
35031
35157
|
|
|
35032
35158
|
function removeUnnecessaryTrailingNewlines(lineContents) {
|
|
35033
35159
|
if (node.chomping === "keep") {
|
|
35034
|
-
return getLast$
|
|
35160
|
+
return getLast$6(lineContents).length === 0 ? lineContents.slice(0, -1) : lineContents;
|
|
35035
35161
|
}
|
|
35036
35162
|
|
|
35037
35163
|
var trailingNewlineCount = 0;
|
|
@@ -35050,7 +35176,7 @@ function getBlockValueLineContents$1(node, _ref) {
|
|
|
35050
35176
|
}
|
|
35051
35177
|
|
|
35052
35178
|
var utils$12 = {
|
|
35053
|
-
getLast: getLast$
|
|
35179
|
+
getLast: getLast$6,
|
|
35054
35180
|
getAncestorCount: getAncestorCount$1,
|
|
35055
35181
|
isNode: isNode$2,
|
|
35056
35182
|
isEmptyNode: isEmptyNode$1,
|
|
@@ -35074,7 +35200,7 @@ var isPragma = pragma$11.isPragma;
|
|
|
35074
35200
|
var getAncestorCount = utils$12.getAncestorCount;
|
|
35075
35201
|
var getBlockValueLineContents = utils$12.getBlockValueLineContents;
|
|
35076
35202
|
var getFlowScalarLineContents = utils$12.getFlowScalarLineContents;
|
|
35077
|
-
var getLast$
|
|
35203
|
+
var getLast$5 = utils$12.getLast;
|
|
35078
35204
|
var getLastDescendantNode$1 = utils$12.getLastDescendantNode;
|
|
35079
35205
|
var hasLeadingComments = utils$12.hasLeadingComments;
|
|
35080
35206
|
var hasMiddleComments = utils$12.hasMiddleComments;
|
|
@@ -35090,14 +35216,14 @@ var defineShortcut = utils$12.defineShortcut;
|
|
|
35090
35216
|
var mapNode = utils$12.mapNode;
|
|
35091
35217
|
var docBuilders$3 = doc.builders;
|
|
35092
35218
|
var conditionalGroup$2 = docBuilders$3.conditionalGroup;
|
|
35093
|
-
var breakParent$
|
|
35219
|
+
var breakParent$5 = docBuilders$3.breakParent;
|
|
35094
35220
|
var concat$17 = docBuilders$3.concat;
|
|
35095
35221
|
var dedent$4 = docBuilders$3.dedent;
|
|
35096
35222
|
var dedentToRoot$3 = docBuilders$3.dedentToRoot;
|
|
35097
35223
|
var fill$6 = docBuilders$3.fill;
|
|
35098
35224
|
var group$16 = docBuilders$3.group;
|
|
35099
35225
|
var hardline$13 = docBuilders$3.hardline;
|
|
35100
|
-
var ifBreak$
|
|
35226
|
+
var ifBreak$8 = docBuilders$3.ifBreak;
|
|
35101
35227
|
var join$12 = docBuilders$3.join;
|
|
35102
35228
|
var line$11 = docBuilders$3.line;
|
|
35103
35229
|
var lineSuffix$2 = docBuilders$3.lineSuffix;
|
|
@@ -35151,7 +35277,7 @@ function genericPrint$6(path$$1, options, print) {
|
|
|
35151
35277
|
var tag = !node.tag ? "" : path$$1.call(print, "tag");
|
|
35152
35278
|
var anchor = !node.anchor ? "" : path$$1.call(print, "anchor");
|
|
35153
35279
|
var nextEmptyLine = isNode$1(node, ["mapping", "sequence", "comment", "directive", "mappingItem", "sequenceItem"]) && !isLastDescendantNode(path$$1) ? printNextEmptyLine(path$$1, options.originalText) : "";
|
|
35154
|
-
return concat$17([node.type !== "mappingValue" && hasLeadingComments(node) ? concat$17([join$12(hardline$13, path$$1.map(print, "leadingComments")), hardline$13]) : "", tag, tag && anchor ? " " : "", anchor, tag || anchor ? isNode$1(node, ["sequence", "mapping"]) && !hasMiddleComments(node) ? hardline$13 : " " : "", hasMiddleComments(node) ? concat$17([node.middleComments.length === 1 ? "" : hardline$13, join$12(hardline$13, path$$1.map(print, "middleComments")), hardline$13]) : "", hasPrettierIgnore$4(path$$1) ? concat$17(replaceEndOfLineWith$3(options.originalText.slice(node.position.start.offset, node.position.end.offset), literalline$7)) : group$16(_print(node, parentNode, path$$1, options, print)), hasTrailingComment$1(node) && !isNode$1(node, ["document", "documentHead"]) ? lineSuffix$2(concat$17([node.type === "mappingValue" && !node.content ? "" : " ", parentNode.type === "mappingKey" && path$$1.getParentNode(2).type === "mapping" && isInlineNode(node) ? "" : breakParent$
|
|
35280
|
+
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"))])) : ""]);
|
|
35155
35281
|
}
|
|
35156
35282
|
|
|
35157
35283
|
function _print(node, parentNode, path$$1, options, print) {
|
|
@@ -35287,9 +35413,9 @@ function _print(node, parentNode, path$$1, options, print) {
|
|
|
35287
35413
|
return forceExplicitKey ? concat$17(["? ", align$3(2, key), hardline$13, join$12("", path$$1.map(print, "value", "leadingComments").map(function (comment) {
|
|
35288
35414
|
return concat$17([comment, hardline$13]);
|
|
35289
35415
|
})), ": ", align$3(2, value)]) : // force singleline
|
|
35290
|
-
isSingleLineNode(node.key.content) && !hasLeadingComments(node.key.content) && !hasMiddleComments(node.key.content) && !hasTrailingComment$1(node.key.content) && !hasEndComments(node.key) && !hasLeadingComments(node.value.content) && !hasMiddleComments(node.value.content) && !hasEndComments(node.value) && isAbsolutelyPrintedAsSingleLineNode(node.value.content, options) ? concat$17([key, needsSpaceInFrontOfMappingValue(node) ? " " : "", ": ", value]) : conditionalGroup$2([concat$17([group$16(concat$17([ifBreak$
|
|
35416
|
+
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), {
|
|
35291
35417
|
id: groupId
|
|
35292
|
-
})])), ifBreak$
|
|
35418
|
+
})])), 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])), {
|
|
35293
35419
|
groupId
|
|
35294
35420
|
})])]);
|
|
35295
35421
|
}
|
|
@@ -35303,11 +35429,11 @@ function _print(node, parentNode, path$$1, options, print) {
|
|
|
35303
35429
|
|
|
35304
35430
|
var isLastItemEmptyMappingItem = node.children.length !== 0 && function (lastItem) {
|
|
35305
35431
|
return lastItem.type === "flowMappingItem" && isEmptyNode(lastItem.key) && isEmptyNode(lastItem.value);
|
|
35306
|
-
}(getLast$
|
|
35432
|
+
}(getLast$5(node.children));
|
|
35307
35433
|
|
|
35308
35434
|
return concat$17([openMarker, indent(concat$17([bracketSpacing, concat$17(path$$1.map(function (childPath, index) {
|
|
35309
35435
|
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) : ""])]);
|
|
35310
|
-
}, "children")), ifBreak$
|
|
35436
|
+
}, "children")), ifBreak$8(",", "")])), isLastItemEmptyMappingItem ? "" : bracketSpacing, closeMarker]);
|
|
35311
35437
|
}
|
|
35312
35438
|
|
|
35313
35439
|
case "flowSequenceItem":
|
|
@@ -35725,6 +35851,11 @@ languageMarkdown, {
|
|
|
35725
35851
|
// Angular
|
|
35726
35852
|
get angular() {
|
|
35727
35853
|
return require("./parser-html").parsers.angular;
|
|
35854
|
+
},
|
|
35855
|
+
|
|
35856
|
+
// Lightning Web Components
|
|
35857
|
+
get lwc() {
|
|
35858
|
+
return require("./parser-html").parsers.lwc;
|
|
35728
35859
|
}
|
|
35729
35860
|
|
|
35730
35861
|
}
|
|
@@ -35798,12 +35929,14 @@ function loadPlugins(plugins, pluginSearchDirs) {
|
|
|
35798
35929
|
});
|
|
35799
35930
|
var externalAutoLoadPluginInfos = pluginSearchDirs.map(function (pluginSearchDir) {
|
|
35800
35931
|
var resolvedPluginSearchDir = path.resolve(process.cwd(), pluginSearchDir);
|
|
35932
|
+
var nodeModulesDir = path.resolve(resolvedPluginSearchDir, "node_modules"); // In some fringe cases (ex: files "mounted" as virtual directories), the
|
|
35933
|
+
// isDirectory(resolvedPluginSearchDir) check might be false even though
|
|
35934
|
+
// the node_modules actually exists.
|
|
35801
35935
|
|
|
35802
|
-
if (!isDirectory(resolvedPluginSearchDir)) {
|
|
35936
|
+
if (!isDirectory(nodeModulesDir) && !isDirectory(resolvedPluginSearchDir)) {
|
|
35803
35937
|
throw new Error(`${pluginSearchDir} does not exist or is not a directory`);
|
|
35804
35938
|
}
|
|
35805
35939
|
|
|
35806
|
-
var nodeModulesDir = path.resolve(resolvedPluginSearchDir, "node_modules");
|
|
35807
35940
|
return findPluginsInNodeModules(nodeModulesDir).map(function (pluginName) {
|
|
35808
35941
|
return {
|
|
35809
35942
|
name: pluginName,
|
|
@@ -35824,7 +35957,7 @@ function loadPlugins(plugins, pluginSearchDirs) {
|
|
|
35824
35957
|
}
|
|
35825
35958
|
|
|
35826
35959
|
function findPluginsInNodeModules(nodeModulesDir) {
|
|
35827
|
-
var pluginPackageJsonPaths = globby.sync(["prettier-plugin-*/package.json", "@prettier/plugin-*/package.json"], {
|
|
35960
|
+
var pluginPackageJsonPaths = globby.sync(["prettier-plugin-*/package.json", "@*/prettier-plugin-*/package.json", "@prettier/plugin-*/package.json"], {
|
|
35828
35961
|
cwd: nodeModulesDir
|
|
35829
35962
|
});
|
|
35830
35963
|
return pluginPackageJsonPaths.map(path.dirname);
|
|
@@ -42210,6 +42343,13 @@ var resolveConfig_1 = createCommonjsModule(function (module) {
|
|
|
42210
42343
|
cache: opts.cache,
|
|
42211
42344
|
transform: function transform(result) {
|
|
42212
42345
|
if (result && result.config) {
|
|
42346
|
+
if (typeof result.config === "string") {
|
|
42347
|
+
var modulePath = resolve$1.sync(result.config, {
|
|
42348
|
+
basedir: path.dirname(result.filepath)
|
|
42349
|
+
});
|
|
42350
|
+
result.config = require(modulePath);
|
|
42351
|
+
}
|
|
42352
|
+
|
|
42213
42353
|
if (typeof result.config !== "object") {
|
|
42214
42354
|
throw new Error(`Config is only allowed to be an object, ` + `but received ${typeof result.config} in "${result.filepath}"`);
|
|
42215
42355
|
}
|
|
@@ -43851,7 +43991,7 @@ function formatStdin(context) {
|
|
|
43851
43991
|
|
|
43852
43992
|
writeOutput(context, format$1(context, input, options$$2), options$$2);
|
|
43853
43993
|
} catch (error) {
|
|
43854
|
-
handleError(context, "stdin", error);
|
|
43994
|
+
handleError(context, relativeFilepath || "stdin", error);
|
|
43855
43995
|
}
|
|
43856
43996
|
});
|
|
43857
43997
|
}
|