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