prettier 1.16.4 → 1.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin-prettier.js +602 -483
- package/doc.js +1935 -0
- package/index.js +601 -482
- 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 +229 -141
package/index.js
CHANGED
|
@@ -12,7 +12,7 @@ var thirdParty = require('./third-party');
|
|
|
12
12
|
var thirdParty__default = thirdParty['default'];
|
|
13
13
|
|
|
14
14
|
var name = "prettier";
|
|
15
|
-
var version$1 = "1.
|
|
15
|
+
var version$1 = "1.17.0";
|
|
16
16
|
var description = "Prettier is an opinionated code formatter";
|
|
17
17
|
var bin = {
|
|
18
18
|
"prettier": "./bin/prettier.js"
|
|
@@ -26,11 +26,12 @@ var engines = {
|
|
|
26
26
|
"node": ">=6"
|
|
27
27
|
};
|
|
28
28
|
var dependencies = {
|
|
29
|
-
"@angular/compiler": "
|
|
30
|
-
"@babel/code-frame": "7.0.0
|
|
29
|
+
"@angular/compiler": "7.2.9",
|
|
30
|
+
"@babel/code-frame": "7.0.0",
|
|
31
31
|
"@babel/parser": "7.2.0",
|
|
32
32
|
"@glimmer/syntax": "0.30.3",
|
|
33
33
|
"@iarna/toml": "2.0.0",
|
|
34
|
+
"@typescript-eslint/typescript-estree": "1.6.0",
|
|
34
35
|
"angular-estree-parser": "1.1.5",
|
|
35
36
|
"angular-html-parser": "1.2.0",
|
|
36
37
|
"camelcase": "4.1.0",
|
|
@@ -49,11 +50,11 @@ var dependencies = {
|
|
|
49
50
|
"flow-parser": "0.84.0",
|
|
50
51
|
"get-stream": "3.0.0",
|
|
51
52
|
"globby": "6.1.0",
|
|
52
|
-
"graphql": "
|
|
53
|
+
"graphql": "14.2.0",
|
|
53
54
|
"html-element-attributes": "2.0.0",
|
|
54
55
|
"html-styles": "1.0.0",
|
|
55
56
|
"html-tag-names": "1.1.2",
|
|
56
|
-
"ignore": "
|
|
57
|
+
"ignore": "4.0.6",
|
|
57
58
|
"is-ci": "2.0.0",
|
|
58
59
|
"jest-docblock": "23.2.0",
|
|
59
60
|
"json-stable-stringify": "1.0.1",
|
|
@@ -78,8 +79,7 @@ var dependencies = {
|
|
|
78
79
|
"resolve": "1.5.0",
|
|
79
80
|
"semver": "5.4.1",
|
|
80
81
|
"string-width": "3.0.0",
|
|
81
|
-
"typescript": "3.
|
|
82
|
-
"typescript-estree": "18.0.0",
|
|
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.16.
|
|
111
|
+
"prettier": "1.16.4",
|
|
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: {
|
|
@@ -8996,19 +8995,20 @@ var loc = {
|
|
|
8996
8995
|
};
|
|
8997
8996
|
|
|
8998
8997
|
var jsTokens = createCommonjsModule(function (module, exports) {
|
|
8999
|
-
// Copyright 2014, 2015, 2016, 2017 Simon Lydell
|
|
8998
|
+
// Copyright 2014, 2015, 2016, 2017, 2018 Simon Lydell
|
|
9000
8999
|
// License: MIT. (See LICENSE.)
|
|
9001
9000
|
Object.defineProperty(exports, "__esModule", {
|
|
9002
9001
|
value: true
|
|
9003
9002
|
}); // This regex comes from regex.coffee, and is inserted here by generate-index.js
|
|
9004
9003
|
// (run `npm run build`).
|
|
9005
9004
|
|
|
9006
|
-
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;
|
|
9007
9006
|
|
|
9008
9007
|
exports.matchToToken = function (match) {
|
|
9009
9008
|
var token = {
|
|
9010
9009
|
type: "invalid",
|
|
9011
|
-
value: match[0]
|
|
9010
|
+
value: match[0],
|
|
9011
|
+
closed: undefined
|
|
9012
9012
|
};
|
|
9013
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";
|
|
9014
9014
|
return token;
|
|
@@ -10139,7 +10139,7 @@ var lib$3 = createCommonjsModule(function (module, exports) {
|
|
|
10139
10139
|
exports.default = highlight;
|
|
10140
10140
|
|
|
10141
10141
|
function _jsTokens() {
|
|
10142
|
-
var data = _interopRequireWildcard(jsTokens);
|
|
10142
|
+
var data = _interopRequireWildcard$$1(jsTokens);
|
|
10143
10143
|
|
|
10144
10144
|
_jsTokens = function _jsTokens() {
|
|
10145
10145
|
return data;
|
|
@@ -10149,7 +10149,7 @@ var lib$3 = createCommonjsModule(function (module, exports) {
|
|
|
10149
10149
|
}
|
|
10150
10150
|
|
|
10151
10151
|
function _esutils() {
|
|
10152
|
-
var data = _interopRequireDefault(utils$2);
|
|
10152
|
+
var data = _interopRequireDefault$$1(utils$2);
|
|
10153
10153
|
|
|
10154
10154
|
_esutils = function _esutils() {
|
|
10155
10155
|
return data;
|
|
@@ -10159,7 +10159,7 @@ var lib$3 = createCommonjsModule(function (module, exports) {
|
|
|
10159
10159
|
}
|
|
10160
10160
|
|
|
10161
10161
|
function _chalk() {
|
|
10162
|
-
var data = _interopRequireDefault(chalk$5);
|
|
10162
|
+
var data = _interopRequireDefault$$1(chalk$5);
|
|
10163
10163
|
|
|
10164
10164
|
_chalk = function _chalk() {
|
|
10165
10165
|
return data;
|
|
@@ -10168,13 +10168,13 @@ var lib$3 = createCommonjsModule(function (module, exports) {
|
|
|
10168
10168
|
return data;
|
|
10169
10169
|
}
|
|
10170
10170
|
|
|
10171
|
-
function _interopRequireDefault(obj) {
|
|
10171
|
+
function _interopRequireDefault$$1(obj) {
|
|
10172
10172
|
return obj && obj.__esModule ? obj : {
|
|
10173
10173
|
default: obj
|
|
10174
10174
|
};
|
|
10175
10175
|
}
|
|
10176
10176
|
|
|
10177
|
-
function _interopRequireWildcard(obj) {
|
|
10177
|
+
function _interopRequireWildcard$$1(obj) {
|
|
10178
10178
|
if (obj && obj.__esModule) {
|
|
10179
10179
|
return obj;
|
|
10180
10180
|
} else {
|
|
@@ -10219,8 +10219,9 @@ var lib$3 = createCommonjsModule(function (module, exports) {
|
|
|
10219
10219
|
|
|
10220
10220
|
function getTokenType(match) {
|
|
10221
10221
|
var _match$slice = match.slice(-2),
|
|
10222
|
-
|
|
10223
|
-
|
|
10222
|
+
_match$slice2 = _slicedToArray(_match$slice, 2),
|
|
10223
|
+
offset = _match$slice2[0],
|
|
10224
|
+
text = _match$slice2[1];
|
|
10224
10225
|
|
|
10225
10226
|
var token = (0, _jsTokens().matchToToken)(match);
|
|
10226
10227
|
|
|
@@ -10285,10 +10286,8 @@ var lib$3 = createCommonjsModule(function (module, exports) {
|
|
|
10285
10286
|
return chalk;
|
|
10286
10287
|
}
|
|
10287
10288
|
|
|
10288
|
-
function highlight(code
|
|
10289
|
-
|
|
10290
|
-
options = {};
|
|
10291
|
-
}
|
|
10289
|
+
function highlight(code) {
|
|
10290
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
10292
10291
|
|
|
10293
10292
|
if (shouldHighlight(options)) {
|
|
10294
10293
|
var chalk = getChalk(options);
|
|
@@ -10358,7 +10357,7 @@ var lib$2 = createCommonjsModule(function (module, exports) {
|
|
|
10358
10357
|
var NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
|
|
10359
10358
|
|
|
10360
10359
|
function getMarkerLines(loc, source, opts) {
|
|
10361
|
-
var startLoc = Object.assign({
|
|
10360
|
+
var startLoc = Object.assign({
|
|
10362
10361
|
column: 0,
|
|
10363
10362
|
line: -1
|
|
10364
10363
|
}, loc.start);
|
|
@@ -10417,17 +10416,14 @@ var lib$2 = createCommonjsModule(function (module, exports) {
|
|
|
10417
10416
|
}
|
|
10418
10417
|
|
|
10419
10418
|
return {
|
|
10420
|
-
start
|
|
10421
|
-
end
|
|
10422
|
-
markerLines
|
|
10419
|
+
start,
|
|
10420
|
+
end,
|
|
10421
|
+
markerLines
|
|
10423
10422
|
};
|
|
10424
10423
|
}
|
|
10425
10424
|
|
|
10426
|
-
function codeFrameColumns(rawLines, loc
|
|
10427
|
-
|
|
10428
|
-
opts = {};
|
|
10429
|
-
}
|
|
10430
|
-
|
|
10425
|
+
function codeFrameColumns(rawLines, loc) {
|
|
10426
|
+
var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
10431
10427
|
var highlighted = (opts.highlightCode || opts.forceColor) && (0, _highlight().shouldHighlight)(opts);
|
|
10432
10428
|
var chalk = (0, _highlight().getChalk)(opts);
|
|
10433
10429
|
var defs = getDefs(chalk);
|
|
@@ -10448,8 +10444,8 @@ var lib$2 = createCommonjsModule(function (module, exports) {
|
|
|
10448
10444
|
var numberMaxWidth = String(end).length;
|
|
10449
10445
|
var frame = lines.slice(start, end).map(function (line, index) {
|
|
10450
10446
|
var number = start + 1 + index;
|
|
10451
|
-
var paddedNumber =
|
|
10452
|
-
var gutter =
|
|
10447
|
+
var paddedNumber = ` ${number}`.slice(-numberMaxWidth);
|
|
10448
|
+
var gutter = ` ${paddedNumber} | `;
|
|
10453
10449
|
var hasMarker = markerLines[number];
|
|
10454
10450
|
var lastMarkerLine = !markerLines[number + 1];
|
|
10455
10451
|
|
|
@@ -10468,12 +10464,12 @@ var lib$2 = createCommonjsModule(function (module, exports) {
|
|
|
10468
10464
|
|
|
10469
10465
|
return [maybeHighlight(defs.marker, ">"), maybeHighlight(defs.gutter, gutter), line, markerLine].join("");
|
|
10470
10466
|
} else {
|
|
10471
|
-
return
|
|
10467
|
+
return ` ${maybeHighlight(defs.gutter, gutter)}${line}`;
|
|
10472
10468
|
}
|
|
10473
10469
|
}).join("\n");
|
|
10474
10470
|
|
|
10475
10471
|
if (opts.message && !hasColumns) {
|
|
10476
|
-
frame = "
|
|
10472
|
+
frame = `${" ".repeat(numberMaxWidth + 1)}${opts.message}\n${frame}`;
|
|
10477
10473
|
}
|
|
10478
10474
|
|
|
10479
10475
|
if (highlighted) {
|
|
@@ -10483,10 +10479,8 @@ var lib$2 = createCommonjsModule(function (module, exports) {
|
|
|
10483
10479
|
}
|
|
10484
10480
|
}
|
|
10485
10481
|
|
|
10486
|
-
function _default(rawLines, lineNumber, colNumber
|
|
10487
|
-
|
|
10488
|
-
opts = {};
|
|
10489
|
-
}
|
|
10482
|
+
function _default(rawLines, lineNumber, colNumber) {
|
|
10483
|
+
var opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
10490
10484
|
|
|
10491
10485
|
if (!deprecationWarningShown) {
|
|
10492
10486
|
deprecationWarningShown = true;
|
|
@@ -11158,14 +11152,6 @@ function getPenultimate(arr) {
|
|
|
11158
11152
|
return null;
|
|
11159
11153
|
}
|
|
11160
11154
|
|
|
11161
|
-
function getLast$3(arr) {
|
|
11162
|
-
if (arr.length > 0) {
|
|
11163
|
-
return arr[arr.length - 1];
|
|
11164
|
-
}
|
|
11165
|
-
|
|
11166
|
-
return null;
|
|
11167
|
-
}
|
|
11168
|
-
|
|
11169
11155
|
function skip(chars) {
|
|
11170
11156
|
return function (text, index, opts) {
|
|
11171
11157
|
var backwards = opts && opts.backwards; // Allow `skip` functions to be threaded together without having
|
|
@@ -11580,7 +11566,7 @@ function printString(raw, options, isDirectiveLiteral) {
|
|
|
11580
11566
|
// sure that we consistently output the minimum amount of escaped quotes.
|
|
11581
11567
|
|
|
11582
11568
|
|
|
11583
|
-
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"));
|
|
11584
11570
|
}
|
|
11585
11571
|
|
|
11586
11572
|
function makeString(rawContent, enclosingQuote, unescapeUnnecessaryEscapes) {
|
|
@@ -11768,7 +11754,7 @@ var util$1 = {
|
|
|
11768
11754
|
isExportDeclaration,
|
|
11769
11755
|
getParentExportDeclaration,
|
|
11770
11756
|
getPenultimate,
|
|
11771
|
-
getLast
|
|
11757
|
+
getLast,
|
|
11772
11758
|
getNextNonSpaceNonCommentCharacterIndexWithStartIndex,
|
|
11773
11759
|
getNextNonSpaceNonCommentCharacterIndex,
|
|
11774
11760
|
getNextNonSpaceNonCommentCharacter,
|
|
@@ -13219,7 +13205,7 @@ function printTrailingComment(commentPath, print, options) {
|
|
|
13219
13205
|
return concat([" ", contents]);
|
|
13220
13206
|
}
|
|
13221
13207
|
|
|
13222
|
-
return concat([lineSuffix(" "
|
|
13208
|
+
return concat([lineSuffix(concat([" ", contents])), !isBlock ? breakParent : ""]);
|
|
13223
13209
|
}
|
|
13224
13210
|
|
|
13225
13211
|
function printDanglingComments(path$$1, options, sameIndent, filter) {
|
|
@@ -14177,367 +14163,384 @@ var core = {
|
|
|
14177
14163
|
|
|
14178
14164
|
};
|
|
14179
14165
|
|
|
14180
|
-
var
|
|
14181
|
-
|
|
14182
|
-
|
|
14183
|
-
|
|
14184
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
14185
|
-
descriptor.configurable = true;
|
|
14186
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
14187
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
14188
|
-
}
|
|
14166
|
+
var ignore = createCommonjsModule(function (module) {
|
|
14167
|
+
// A simple implementation of make-array
|
|
14168
|
+
function make_array(subject) {
|
|
14169
|
+
return Array.isArray(subject) ? subject : [subject];
|
|
14189
14170
|
}
|
|
14190
14171
|
|
|
14191
|
-
|
|
14192
|
-
|
|
14193
|
-
|
|
14194
|
-
|
|
14172
|
+
var REGEX_BLANK_LINE = /^\s+$/;
|
|
14173
|
+
var REGEX_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
|
|
14174
|
+
var REGEX_LEADING_EXCAPED_HASH = /^\\#/;
|
|
14175
|
+
var SLASH = '/';
|
|
14176
|
+
var KEY_IGNORE = typeof Symbol !== 'undefined' ? Symbol.for('node-ignore')
|
|
14177
|
+
/* istanbul ignore next */
|
|
14178
|
+
: 'node-ignore';
|
|
14179
|
+
|
|
14180
|
+
var define = function define(object, key, value) {
|
|
14181
|
+
return Object.defineProperty(object, key, {
|
|
14182
|
+
value
|
|
14183
|
+
});
|
|
14195
14184
|
};
|
|
14196
|
-
}();
|
|
14197
14185
|
|
|
14198
|
-
|
|
14199
|
-
|
|
14200
|
-
throw new TypeError("Cannot call a class as a function");
|
|
14201
|
-
}
|
|
14202
|
-
}
|
|
14186
|
+
var REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g; // Sanitize the range of a regular expression
|
|
14187
|
+
// The cases are complicated, see test cases for details
|
|
14203
14188
|
|
|
14204
|
-
var
|
|
14205
|
-
|
|
14206
|
-
|
|
14189
|
+
var sanitizeRange = function sanitizeRange(range) {
|
|
14190
|
+
return range.replace(REGEX_REGEXP_RANGE, function (match, from, to) {
|
|
14191
|
+
return from.charCodeAt(0) <= to.charCodeAt(0) ? match // Invalid range (out of order) which is ok for gitignore rules but
|
|
14192
|
+
// fatal for JavaScript regular expression, so eliminate it.
|
|
14193
|
+
: '';
|
|
14194
|
+
});
|
|
14195
|
+
}; // > If the pattern ends with a slash,
|
|
14196
|
+
// > it is removed for the purpose of the following description,
|
|
14197
|
+
// > but it would only find a match with a directory.
|
|
14198
|
+
// > In other words, foo/ will match a directory foo and paths underneath it,
|
|
14199
|
+
// > but will not match a regular file or a symbolic link foo
|
|
14200
|
+
// > (this is consistent with the way how pathspec works in general in Git).
|
|
14201
|
+
// '`foo/`' will not match regular file '`foo`' or symbolic link '`foo`'
|
|
14202
|
+
// -> ignore-rules will not deal with it, because it costs extra `fs.stat` call
|
|
14203
|
+
// you could use option `mark: true` with `glob`
|
|
14204
|
+
// '`foo/`' should not continue with the '`..`'
|
|
14205
|
+
|
|
14206
|
+
|
|
14207
|
+
var DEFAULT_REPLACER_PREFIX = [// > Trailing spaces are ignored unless they are quoted with backslash ("\")
|
|
14208
|
+
[// (a\ ) -> (a )
|
|
14209
|
+
// (a ) -> (a)
|
|
14210
|
+
// (a \ ) -> (a )
|
|
14211
|
+
/\\?\s+$/, function (match) {
|
|
14212
|
+
return match.indexOf('\\') === 0 ? ' ' : '';
|
|
14213
|
+
}], // replace (\ ) with ' '
|
|
14214
|
+
[/\\\s/g, function () {
|
|
14215
|
+
return ' ';
|
|
14216
|
+
}], // Escape metacharacters
|
|
14217
|
+
// which is written down by users but means special for regular expressions.
|
|
14218
|
+
// > There are 12 characters with special meanings:
|
|
14219
|
+
// > - the backslash \,
|
|
14220
|
+
// > - the caret ^,
|
|
14221
|
+
// > - the dollar sign $,
|
|
14222
|
+
// > - the period or dot .,
|
|
14223
|
+
// > - the vertical bar or pipe symbol |,
|
|
14224
|
+
// > - the question mark ?,
|
|
14225
|
+
// > - the asterisk or star *,
|
|
14226
|
+
// > - the plus sign +,
|
|
14227
|
+
// > - the opening parenthesis (,
|
|
14228
|
+
// > - the closing parenthesis ),
|
|
14229
|
+
// > - and the opening square bracket [,
|
|
14230
|
+
// > - the opening curly brace {,
|
|
14231
|
+
// > These special characters are often called "metacharacters".
|
|
14232
|
+
[/[\\^$.|*+(){]/g, function (match) {
|
|
14233
|
+
return `\\${match}`;
|
|
14234
|
+
}], [// > [abc] matches any character inside the brackets
|
|
14235
|
+
// > (in this case a, b, or c);
|
|
14236
|
+
/\[([^\]/]*)($|\])/g, function (match, p1, p2) {
|
|
14237
|
+
return p2 === ']' ? `[${sanitizeRange(p1)}]` : `\\${match}`;
|
|
14238
|
+
}], [// > a question mark (?) matches a single character
|
|
14239
|
+
/(?!\\)\?/g, function () {
|
|
14240
|
+
return '[^/]';
|
|
14241
|
+
}], // leading slash
|
|
14242
|
+
[// > A leading slash matches the beginning of the pathname.
|
|
14243
|
+
// > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
|
|
14244
|
+
// A leading slash matches the beginning of the pathname
|
|
14245
|
+
/^\//, function () {
|
|
14246
|
+
return '^';
|
|
14247
|
+
}], // replace special metacharacter slash after the leading slash
|
|
14248
|
+
[/\//g, function () {
|
|
14249
|
+
return '\\/';
|
|
14250
|
+
}], [// > A leading "**" followed by a slash means match in all directories.
|
|
14251
|
+
// > For example, "**/foo" matches file or directory "foo" anywhere,
|
|
14252
|
+
// > the same as pattern "foo".
|
|
14253
|
+
// > "**/foo/bar" matches file or directory "bar" anywhere that is directly
|
|
14254
|
+
// > under directory "foo".
|
|
14255
|
+
// Notice that the '*'s have been replaced as '\\*'
|
|
14256
|
+
/^\^*\\\*\\\*\\\//, // '**/foo' <-> 'foo'
|
|
14257
|
+
function () {
|
|
14258
|
+
return '^(?:.*\\/)?';
|
|
14259
|
+
}]];
|
|
14260
|
+
var DEFAULT_REPLACER_SUFFIX = [// starting
|
|
14261
|
+
[// there will be no leading '/'
|
|
14262
|
+
// (which has been replaced by section "leading slash")
|
|
14263
|
+
// If starts with '**', adding a '^' to the regular expression also works
|
|
14264
|
+
/^(?=[^^])/, function startingReplacer() {
|
|
14265
|
+
return !/\/(?!$)/.test(this) // > If the pattern does not contain a slash /,
|
|
14266
|
+
// > Git treats it as a shell glob pattern
|
|
14267
|
+
// Actually, if there is only a trailing slash,
|
|
14268
|
+
// git also treats it as a shell glob pattern
|
|
14269
|
+
? '(?:^|\\/)' // > Otherwise, Git treats the pattern as a shell glob suitable for
|
|
14270
|
+
// > consumption by fnmatch(3)
|
|
14271
|
+
: '^';
|
|
14272
|
+
}], // two globstars
|
|
14273
|
+
[// Use lookahead assertions so that we could match more than one `'/**'`
|
|
14274
|
+
/\\\/\\\*\\\*(?=\\\/|$)/g, // Zero, one or several directories
|
|
14275
|
+
// should not use '*', or it will be replaced by the next replacer
|
|
14276
|
+
// Check if it is not the last `'/**'`
|
|
14277
|
+
function (match, index, str) {
|
|
14278
|
+
return index + 6 < str.length // case: /**/
|
|
14279
|
+
// > A slash followed by two consecutive asterisks then a slash matches
|
|
14280
|
+
// > zero or more directories.
|
|
14281
|
+
// > For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on.
|
|
14282
|
+
// '/**/'
|
|
14283
|
+
? '(?:\\/[^\\/]+)*' // case: /**
|
|
14284
|
+
// > A trailing `"/**"` matches everything inside.
|
|
14285
|
+
// #21: everything inside but it should not include the current folder
|
|
14286
|
+
: '\\/.+';
|
|
14287
|
+
}], // intermediate wildcards
|
|
14288
|
+
[// Never replace escaped '*'
|
|
14289
|
+
// ignore rule '\*' will match the path '*'
|
|
14290
|
+
// 'abc.*/' -> go
|
|
14291
|
+
// 'abc.*' -> skip this rule
|
|
14292
|
+
/(^|[^\\]+)\\\*(?=.+)/g, // '*.js' matches '.js'
|
|
14293
|
+
// '*.js' doesn't match 'abc'
|
|
14294
|
+
function (match, p1) {
|
|
14295
|
+
return `${p1}[^\\/]*`;
|
|
14296
|
+
}], // trailing wildcard
|
|
14297
|
+
[/(\^|\\\/)?\\\*$/, function (match, p1) {
|
|
14298
|
+
var prefix = p1 // '\^':
|
|
14299
|
+
// '/*' does not match ''
|
|
14300
|
+
// '/*' does not match everything
|
|
14301
|
+
// '\\\/':
|
|
14302
|
+
// 'abc/*' does not match 'abc/'
|
|
14303
|
+
? `${p1}[^/]+` // 'a*' matches 'a'
|
|
14304
|
+
// 'a*' matches 'aa'
|
|
14305
|
+
: '[^/]*';
|
|
14306
|
+
return `${prefix}(?=$|\\/$)`;
|
|
14307
|
+
}], [// unescape
|
|
14308
|
+
/\\\\\\/g, function () {
|
|
14309
|
+
return '\\';
|
|
14310
|
+
}]];
|
|
14311
|
+
var POSITIVE_REPLACERS = DEFAULT_REPLACER_PREFIX.concat([// 'f'
|
|
14312
|
+
// matches
|
|
14313
|
+
// - /f(end)
|
|
14314
|
+
// - /f/
|
|
14315
|
+
// - (start)f(end)
|
|
14316
|
+
// - (start)f/
|
|
14317
|
+
// doesn't match
|
|
14318
|
+
// - oof
|
|
14319
|
+
// - foo
|
|
14320
|
+
// pseudo:
|
|
14321
|
+
// -> (^|/)f(/|$)
|
|
14322
|
+
// ending
|
|
14323
|
+
[// 'js' will not match 'js.'
|
|
14324
|
+
// 'ab' will not match 'abc'
|
|
14325
|
+
/(?:[^*/])$/, // 'js*' will not match 'a.js'
|
|
14326
|
+
// 'js/' will not match 'a.js'
|
|
14327
|
+
// 'js' will match 'a.js' and 'a.js/'
|
|
14328
|
+
function (match) {
|
|
14329
|
+
return `${match}(?=$|\\/)`;
|
|
14330
|
+
}]], DEFAULT_REPLACER_SUFFIX);
|
|
14331
|
+
var NEGATIVE_REPLACERS = DEFAULT_REPLACER_PREFIX.concat([// #24, #38
|
|
14332
|
+
// The MISSING rule of [gitignore docs](https://git-scm.com/docs/gitignore)
|
|
14333
|
+
// A negative pattern without a trailing wildcard should not
|
|
14334
|
+
// re-include the things inside that directory.
|
|
14335
|
+
// eg:
|
|
14336
|
+
// ['node_modules/*', '!node_modules']
|
|
14337
|
+
// should ignore `node_modules/a.js`
|
|
14338
|
+
[/(?:[^*])$/, function (match) {
|
|
14339
|
+
return `${match}(?=$|\\/$)`;
|
|
14340
|
+
}]], DEFAULT_REPLACER_SUFFIX); // A simple cache, because an ignore rule only has only one certain meaning
|
|
14341
|
+
|
|
14342
|
+
var cache = Object.create(null); // @param {pattern}
|
|
14343
|
+
|
|
14344
|
+
var make_regex = function make_regex(pattern, negative, ignorecase) {
|
|
14345
|
+
var r = cache[pattern];
|
|
14346
|
+
|
|
14347
|
+
if (r) {
|
|
14348
|
+
return r;
|
|
14349
|
+
}
|
|
14350
|
+
|
|
14351
|
+
var replacers = negative ? NEGATIVE_REPLACERS : POSITIVE_REPLACERS;
|
|
14352
|
+
var source = replacers.reduce(function (prev, current) {
|
|
14353
|
+
return prev.replace(current[0], current[1].bind(pattern));
|
|
14354
|
+
}, pattern);
|
|
14355
|
+
return cache[pattern] = ignorecase ? new RegExp(source, 'i') : new RegExp(source);
|
|
14356
|
+
}; // > A blank line matches no files, so it can serve as a separator for readability.
|
|
14357
|
+
|
|
14358
|
+
|
|
14359
|
+
var checkPattern = function checkPattern(pattern) {
|
|
14360
|
+
return pattern && typeof pattern === 'string' && !REGEX_BLANK_LINE.test(pattern) // > A line starting with # serves as a comment.
|
|
14361
|
+
&& pattern.indexOf('#') !== 0;
|
|
14362
|
+
};
|
|
14207
14363
|
|
|
14364
|
+
var createRule = function createRule(pattern, ignorecase) {
|
|
14365
|
+
var origin = pattern;
|
|
14366
|
+
var negative = false; // > An optional prefix "!" which negates the pattern;
|
|
14208
14367
|
|
|
14209
|
-
|
|
14210
|
-
|
|
14211
|
-
|
|
14368
|
+
if (pattern.indexOf('!') === 0) {
|
|
14369
|
+
negative = true;
|
|
14370
|
+
pattern = pattern.substr(1);
|
|
14371
|
+
}
|
|
14212
14372
|
|
|
14213
|
-
|
|
14214
|
-
|
|
14215
|
-
|
|
14216
|
-
|
|
14217
|
-
|
|
14218
|
-
|
|
14219
|
-
|
|
14373
|
+
pattern = pattern // > Put a backslash ("\") in front of the first "!" for patterns that
|
|
14374
|
+
// > begin with a literal "!", for example, `"\!important!.txt"`.
|
|
14375
|
+
.replace(REGEX_LEADING_EXCAPED_EXCLAMATION, '!') // > Put a backslash ("\") in front of the first hash for patterns that
|
|
14376
|
+
// > begin with a hash.
|
|
14377
|
+
.replace(REGEX_LEADING_EXCAPED_HASH, '#');
|
|
14378
|
+
var regex = make_regex(pattern, negative, ignorecase);
|
|
14379
|
+
return {
|
|
14380
|
+
origin,
|
|
14381
|
+
pattern,
|
|
14382
|
+
negative,
|
|
14383
|
+
regex
|
|
14384
|
+
};
|
|
14385
|
+
};
|
|
14220
14386
|
|
|
14221
|
-
var IgnoreBase =
|
|
14222
|
-
|
|
14223
|
-
|
|
14387
|
+
var IgnoreBase =
|
|
14388
|
+
/*#__PURE__*/
|
|
14389
|
+
function () {
|
|
14390
|
+
function IgnoreBase() {
|
|
14391
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
14392
|
+
_ref$ignorecase = _ref.ignorecase,
|
|
14393
|
+
ignorecase = _ref$ignorecase === void 0 ? true : _ref$ignorecase;
|
|
14224
14394
|
|
|
14225
|
-
|
|
14226
|
-
this[KEY_IGNORE] = true;
|
|
14395
|
+
_classCallCheck(this, IgnoreBase);
|
|
14227
14396
|
|
|
14228
|
-
|
|
14229
|
-
|
|
14397
|
+
this._rules = [];
|
|
14398
|
+
this._ignorecase = ignorecase;
|
|
14399
|
+
define(this, KEY_IGNORE, true);
|
|
14230
14400
|
|
|
14231
|
-
|
|
14232
|
-
|
|
14233
|
-
value: function _initCache() {
|
|
14234
|
-
this._cache = {};
|
|
14235
|
-
} // @param {Array.<string>|string|Ignore} pattern
|
|
14401
|
+
this._initCache();
|
|
14402
|
+
}
|
|
14236
14403
|
|
|
14237
|
-
|
|
14238
|
-
|
|
14239
|
-
|
|
14240
|
-
|
|
14404
|
+
_createClass(IgnoreBase, [{
|
|
14405
|
+
key: "_initCache",
|
|
14406
|
+
value: function _initCache() {
|
|
14407
|
+
this._cache = Object.create(null);
|
|
14408
|
+
} // @param {Array.<string>|string|Ignore} pattern
|
|
14241
14409
|
|
|
14242
|
-
|
|
14243
|
-
|
|
14244
|
-
|
|
14410
|
+
}, {
|
|
14411
|
+
key: "add",
|
|
14412
|
+
value: function add(pattern) {
|
|
14413
|
+
this._added = false;
|
|
14245
14414
|
|
|
14246
|
-
|
|
14247
|
-
|
|
14415
|
+
if (typeof pattern === 'string') {
|
|
14416
|
+
pattern = pattern.split(/\r?\n/g);
|
|
14417
|
+
}
|
|
14248
14418
|
|
|
14249
|
-
|
|
14250
|
-
|
|
14251
|
-
}
|
|
14419
|
+
make_array(pattern).forEach(this._addPattern, this); // Some rules have just added to the ignore,
|
|
14420
|
+
// making the behavior changed.
|
|
14252
14421
|
|
|
14253
|
-
|
|
14254
|
-
|
|
14422
|
+
if (this._added) {
|
|
14423
|
+
this._initCache();
|
|
14424
|
+
}
|
|
14255
14425
|
|
|
14256
|
-
|
|
14257
|
-
|
|
14258
|
-
|
|
14259
|
-
|
|
14260
|
-
|
|
14261
|
-
|
|
14262
|
-
|
|
14263
|
-
value: function _addPattern(pattern) {
|
|
14264
|
-
// #32
|
|
14265
|
-
if (pattern && pattern[KEY_IGNORE]) {
|
|
14266
|
-
this._rules = this._rules.concat(pattern._rules);
|
|
14267
|
-
this._added = true;
|
|
14268
|
-
return;
|
|
14426
|
+
return this;
|
|
14427
|
+
} // legacy
|
|
14428
|
+
|
|
14429
|
+
}, {
|
|
14430
|
+
key: "addPattern",
|
|
14431
|
+
value: function addPattern(pattern) {
|
|
14432
|
+
return this.add(pattern);
|
|
14269
14433
|
}
|
|
14434
|
+
}, {
|
|
14435
|
+
key: "_addPattern",
|
|
14436
|
+
value: function _addPattern(pattern) {
|
|
14437
|
+
// #32
|
|
14438
|
+
if (pattern && pattern[KEY_IGNORE]) {
|
|
14439
|
+
this._rules = this._rules.concat(pattern._rules);
|
|
14440
|
+
this._added = true;
|
|
14441
|
+
return;
|
|
14442
|
+
}
|
|
14270
14443
|
|
|
14271
|
-
|
|
14272
|
-
|
|
14444
|
+
if (checkPattern(pattern)) {
|
|
14445
|
+
var rule = createRule(pattern, this._ignorecase);
|
|
14446
|
+
this._added = true;
|
|
14273
14447
|
|
|
14274
|
-
|
|
14448
|
+
this._rules.push(rule);
|
|
14449
|
+
}
|
|
14450
|
+
}
|
|
14451
|
+
}, {
|
|
14452
|
+
key: "filter",
|
|
14453
|
+
value: function filter(paths) {
|
|
14454
|
+
var _this = this;
|
|
14275
14455
|
|
|
14276
|
-
|
|
14456
|
+
return make_array(paths).filter(function (path$$1) {
|
|
14457
|
+
return _this._filter(path$$1);
|
|
14458
|
+
});
|
|
14277
14459
|
}
|
|
14278
|
-
}
|
|
14279
|
-
|
|
14280
|
-
|
|
14281
|
-
|
|
14282
|
-
// > A blank line matches no files, so it can serve as a separator for readability.
|
|
14283
|
-
return pattern && typeof pattern === 'string' && !REGEX_BLANK_LINE.test(pattern) // > A line starting with # serves as a comment.
|
|
14284
|
-
&& pattern.indexOf('#') !== 0;
|
|
14285
|
-
}
|
|
14286
|
-
}, {
|
|
14287
|
-
key: 'filter',
|
|
14288
|
-
value: function filter(paths) {
|
|
14289
|
-
var _this = this;
|
|
14460
|
+
}, {
|
|
14461
|
+
key: "createFilter",
|
|
14462
|
+
value: function createFilter() {
|
|
14463
|
+
var _this2 = this;
|
|
14290
14464
|
|
|
14291
|
-
|
|
14292
|
-
|
|
14293
|
-
|
|
14294
|
-
|
|
14295
|
-
|
|
14296
|
-
|
|
14297
|
-
|
|
14298
|
-
|
|
14465
|
+
return function (path$$1) {
|
|
14466
|
+
return _this2._filter(path$$1);
|
|
14467
|
+
};
|
|
14468
|
+
}
|
|
14469
|
+
}, {
|
|
14470
|
+
key: "ignores",
|
|
14471
|
+
value: function ignores(path$$1) {
|
|
14472
|
+
return !this._filter(path$$1);
|
|
14473
|
+
} // @returns `Boolean` true if the `path` is NOT ignored
|
|
14299
14474
|
|
|
14300
|
-
|
|
14301
|
-
|
|
14302
|
-
|
|
14303
|
-
|
|
14304
|
-
|
|
14305
|
-
|
|
14306
|
-
value: function ignores(path$$1) {
|
|
14307
|
-
return !this._filter(path$$1);
|
|
14308
|
-
}
|
|
14309
|
-
}, {
|
|
14310
|
-
key: '_createRule',
|
|
14311
|
-
value: function _createRule(pattern) {
|
|
14312
|
-
var origin = pattern;
|
|
14313
|
-
var negative = false; // > An optional prefix "!" which negates the pattern;
|
|
14475
|
+
}, {
|
|
14476
|
+
key: "_filter",
|
|
14477
|
+
value: function _filter(path$$1, slices) {
|
|
14478
|
+
if (!path$$1) {
|
|
14479
|
+
return false;
|
|
14480
|
+
}
|
|
14314
14481
|
|
|
14315
|
-
|
|
14316
|
-
|
|
14317
|
-
|
|
14318
|
-
}
|
|
14482
|
+
if (path$$1 in this._cache) {
|
|
14483
|
+
return this._cache[path$$1];
|
|
14484
|
+
}
|
|
14319
14485
|
|
|
14320
|
-
|
|
14321
|
-
|
|
14322
|
-
|
|
14323
|
-
|
|
14324
|
-
|
|
14325
|
-
origin: origin,
|
|
14326
|
-
pattern: pattern,
|
|
14327
|
-
negative: negative,
|
|
14328
|
-
regex: regex
|
|
14329
|
-
};
|
|
14330
|
-
} // @returns `Boolean` true if the `path` is NOT ignored
|
|
14486
|
+
if (!slices) {
|
|
14487
|
+
// path/to/a.js
|
|
14488
|
+
// ['path', 'to', 'a.js']
|
|
14489
|
+
slices = path$$1.split(SLASH);
|
|
14490
|
+
}
|
|
14331
14491
|
|
|
14332
|
-
|
|
14333
|
-
|
|
14334
|
-
|
|
14335
|
-
|
|
14336
|
-
|
|
14337
|
-
|
|
14492
|
+
slices.pop();
|
|
14493
|
+
return this._cache[path$$1] = slices.length // > It is not possible to re-include a file if a parent directory of
|
|
14494
|
+
// > that file is excluded.
|
|
14495
|
+
// If the path contains a parent directory, check the parent first
|
|
14496
|
+
? this._filter(slices.join(SLASH) + SLASH, slices) && this._test(path$$1) // Or only test the path
|
|
14497
|
+
: this._test(path$$1);
|
|
14498
|
+
} // @returns {Boolean} true if a file is NOT ignored
|
|
14338
14499
|
|
|
14339
|
-
|
|
14340
|
-
|
|
14341
|
-
|
|
14500
|
+
}, {
|
|
14501
|
+
key: "_test",
|
|
14502
|
+
value: function _test(path$$1) {
|
|
14503
|
+
// Explicitly define variable type by setting matched to `0`
|
|
14504
|
+
var matched = 0;
|
|
14505
|
+
|
|
14506
|
+
this._rules.forEach(function (rule) {
|
|
14507
|
+
// if matched = true, then we only test negative rules
|
|
14508
|
+
// if matched = false, then we test non-negative rules
|
|
14509
|
+
if (!(matched ^ rule.negative)) {
|
|
14510
|
+
matched = rule.negative ^ rule.regex.test(path$$1);
|
|
14511
|
+
}
|
|
14512
|
+
});
|
|
14342
14513
|
|
|
14343
|
-
|
|
14344
|
-
// path/to/a.js
|
|
14345
|
-
// ['path', 'to', 'a.js']
|
|
14346
|
-
slices = path$$1.split(SLASH);
|
|
14514
|
+
return !matched;
|
|
14347
14515
|
}
|
|
14516
|
+
}]);
|
|
14348
14517
|
|
|
14349
|
-
|
|
14350
|
-
|
|
14351
|
-
|
|
14352
|
-
? this._filter(slices.join(SLASH) + SLASH, slices) && this._test(path$$1) // Or only test the path
|
|
14353
|
-
: this._test(path$$1);
|
|
14354
|
-
} // @returns {Boolean} true if a file is NOT ignored
|
|
14518
|
+
return IgnoreBase;
|
|
14519
|
+
}(); // Windows
|
|
14520
|
+
// --------------------------------------------------------------
|
|
14355
14521
|
|
|
14356
|
-
|
|
14357
|
-
key: '_test',
|
|
14358
|
-
value: function _test(path$$1) {
|
|
14359
|
-
// Explicitly define variable type by setting matched to `0`
|
|
14360
|
-
var matched = 0;
|
|
14522
|
+
/* istanbul ignore if */
|
|
14361
14523
|
|
|
14362
|
-
this._rules.forEach(function (rule) {
|
|
14363
|
-
// if matched = true, then we only test negative rules
|
|
14364
|
-
// if matched = false, then we test non-negative rules
|
|
14365
|
-
if (!(matched ^ rule.negative)) {
|
|
14366
|
-
matched = rule.negative ^ rule.regex.test(path$$1);
|
|
14367
|
-
}
|
|
14368
|
-
});
|
|
14369
14524
|
|
|
14370
|
-
|
|
14371
|
-
|
|
14372
|
-
|
|
14525
|
+
if ( // Detect `process` so that it can run in browsers.
|
|
14526
|
+
typeof process !== 'undefined' && (process.env && process.env.IGNORE_TEST_WIN32 || process.platform === 'win32')) {
|
|
14527
|
+
var filter = IgnoreBase.prototype._filter;
|
|
14528
|
+
/* eslint no-control-regex: "off" */
|
|
14373
14529
|
|
|
14374
|
-
|
|
14375
|
-
|
|
14376
|
-
|
|
14377
|
-
// > but it would only find a match with a directory.
|
|
14378
|
-
// > In other words, foo/ will match a directory foo and paths underneath it,
|
|
14379
|
-
// > but will not match a regular file or a symbolic link foo
|
|
14380
|
-
// > (this is consistent with the way how pathspec works in general in Git).
|
|
14381
|
-
// '`foo/`' will not match regular file '`foo`' or symbolic link '`foo`'
|
|
14382
|
-
// -> ignore-rules will not deal with it, because it costs extra `fs.stat` call
|
|
14383
|
-
// you could use option `mark: true` with `glob`
|
|
14384
|
-
// '`foo/`' should not continue with the '`..`'
|
|
14385
|
-
|
|
14386
|
-
|
|
14387
|
-
var DEFAULT_REPLACER_PREFIX = [// > Trailing spaces are ignored unless they are quoted with backslash ("\")
|
|
14388
|
-
[// (a\ ) -> (a )
|
|
14389
|
-
// (a ) -> (a)
|
|
14390
|
-
// (a \ ) -> (a )
|
|
14391
|
-
/\\?\s+$/, function (match) {
|
|
14392
|
-
return match.indexOf('\\') === 0 ? ' ' : '';
|
|
14393
|
-
}], // replace (\ ) with ' '
|
|
14394
|
-
[/\\\s/g, function () {
|
|
14395
|
-
return ' ';
|
|
14396
|
-
}], // Escape metacharacters
|
|
14397
|
-
// which is written down by users but means special for regular expressions.
|
|
14398
|
-
// > There are 12 characters with special meanings:
|
|
14399
|
-
// > - the backslash \,
|
|
14400
|
-
// > - the caret ^,
|
|
14401
|
-
// > - the dollar sign $,
|
|
14402
|
-
// > - the period or dot .,
|
|
14403
|
-
// > - the vertical bar or pipe symbol |,
|
|
14404
|
-
// > - the question mark ?,
|
|
14405
|
-
// > - the asterisk or star *,
|
|
14406
|
-
// > - the plus sign +,
|
|
14407
|
-
// > - the opening parenthesis (,
|
|
14408
|
-
// > - the closing parenthesis ),
|
|
14409
|
-
// > - and the opening square bracket [,
|
|
14410
|
-
// > - the opening curly brace {,
|
|
14411
|
-
// > These special characters are often called "metacharacters".
|
|
14412
|
-
[/[\\\^$.|?*+()\[{]/g, function (match) {
|
|
14413
|
-
return '\\' + match;
|
|
14414
|
-
}], // leading slash
|
|
14415
|
-
[// > A leading slash matches the beginning of the pathname.
|
|
14416
|
-
// > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
|
|
14417
|
-
// A leading slash matches the beginning of the pathname
|
|
14418
|
-
/^\//, function () {
|
|
14419
|
-
return '^';
|
|
14420
|
-
}], // replace special metacharacter slash after the leading slash
|
|
14421
|
-
[/\//g, function () {
|
|
14422
|
-
return '\\/';
|
|
14423
|
-
}], [// > A leading "**" followed by a slash means match in all directories.
|
|
14424
|
-
// > For example, "**/foo" matches file or directory "foo" anywhere,
|
|
14425
|
-
// > the same as pattern "foo".
|
|
14426
|
-
// > "**/foo/bar" matches file or directory "bar" anywhere that is directly under directory "foo".
|
|
14427
|
-
// Notice that the '*'s have been replaced as '\\*'
|
|
14428
|
-
/^\^*\\\*\\\*\\\//, // '**/foo' <-> 'foo'
|
|
14429
|
-
function () {
|
|
14430
|
-
return '^(?:.*\\/)?';
|
|
14431
|
-
}]];
|
|
14432
|
-
var DEFAULT_REPLACER_SUFFIX = [// starting
|
|
14433
|
-
[// there will be no leading '/' (which has been replaced by section "leading slash")
|
|
14434
|
-
// If starts with '**', adding a '^' to the regular expression also works
|
|
14435
|
-
/^(?=[^\^])/, function () {
|
|
14436
|
-
return !/\/(?!$)/.test(this) // > If the pattern does not contain a slash /, Git treats it as a shell glob pattern
|
|
14437
|
-
// Actually, if there is only a trailing slash, git also treats it as a shell glob pattern
|
|
14438
|
-
? '(?:^|\\/)' // > Otherwise, Git treats the pattern as a shell glob suitable for consumption by fnmatch(3)
|
|
14439
|
-
: '^';
|
|
14440
|
-
}], // two globstars
|
|
14441
|
-
[// Use lookahead assertions so that we could match more than one `'/**'`
|
|
14442
|
-
/\\\/\\\*\\\*(?=\\\/|$)/g, // Zero, one or several directories
|
|
14443
|
-
// should not use '*', or it will be replaced by the next replacer
|
|
14444
|
-
// Check if it is not the last `'/**'`
|
|
14445
|
-
function (match, index, str) {
|
|
14446
|
-
return index + 6 < str.length // case: /**/
|
|
14447
|
-
// > A slash followed by two consecutive asterisks then a slash matches zero or more directories.
|
|
14448
|
-
// > For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on.
|
|
14449
|
-
// '/**/'
|
|
14450
|
-
? '(?:\\/[^\\/]+)*' // case: /**
|
|
14451
|
-
// > A trailing `"/**"` matches everything inside.
|
|
14452
|
-
// #21: everything inside but it should not include the current folder
|
|
14453
|
-
: '\\/.+';
|
|
14454
|
-
}], // intermediate wildcards
|
|
14455
|
-
[// Never replace escaped '*'
|
|
14456
|
-
// ignore rule '\*' will match the path '*'
|
|
14457
|
-
// 'abc.*/' -> go
|
|
14458
|
-
// 'abc.*' -> skip this rule
|
|
14459
|
-
/(^|[^\\]+)\\\*(?=.+)/g, // '*.js' matches '.js'
|
|
14460
|
-
// '*.js' doesn't match 'abc'
|
|
14461
|
-
function (match, p1) {
|
|
14462
|
-
return p1 + '[^\\/]*';
|
|
14463
|
-
}], // trailing wildcard
|
|
14464
|
-
[/(\^|\\\/)?\\\*$/, function (match, p1) {
|
|
14465
|
-
return (p1 // '\^':
|
|
14466
|
-
// '/*' does not match ''
|
|
14467
|
-
// '/*' does not match everything
|
|
14468
|
-
// '\\\/':
|
|
14469
|
-
// 'abc/*' does not match 'abc/'
|
|
14470
|
-
? p1 + '[^/]+' // 'a*' matches 'a'
|
|
14471
|
-
// 'a*' matches 'aa'
|
|
14472
|
-
: '[^/]*') + '(?=$|\\/$)';
|
|
14473
|
-
}], [// unescape
|
|
14474
|
-
/\\\\\\/g, function () {
|
|
14475
|
-
return '\\';
|
|
14476
|
-
}]];
|
|
14477
|
-
var POSITIVE_REPLACERS = [].concat(DEFAULT_REPLACER_PREFIX, [// 'f'
|
|
14478
|
-
// matches
|
|
14479
|
-
// - /f(end)
|
|
14480
|
-
// - /f/
|
|
14481
|
-
// - (start)f(end)
|
|
14482
|
-
// - (start)f/
|
|
14483
|
-
// doesn't match
|
|
14484
|
-
// - oof
|
|
14485
|
-
// - foo
|
|
14486
|
-
// pseudo:
|
|
14487
|
-
// -> (^|/)f(/|$)
|
|
14488
|
-
// ending
|
|
14489
|
-
[// 'js' will not match 'js.'
|
|
14490
|
-
// 'ab' will not match 'abc'
|
|
14491
|
-
/(?:[^*\/])$/, // 'js*' will not match 'a.js'
|
|
14492
|
-
// 'js/' will not match 'a.js'
|
|
14493
|
-
// 'js' will match 'a.js' and 'a.js/'
|
|
14494
|
-
function (match) {
|
|
14495
|
-
return match + '(?=$|\\/)';
|
|
14496
|
-
}]], DEFAULT_REPLACER_SUFFIX);
|
|
14497
|
-
var NEGATIVE_REPLACERS = [].concat(DEFAULT_REPLACER_PREFIX, [// #24
|
|
14498
|
-
// The MISSING rule of [gitignore docs](https://git-scm.com/docs/gitignore)
|
|
14499
|
-
// A negative pattern without a trailing wildcard should not
|
|
14500
|
-
// re-include the things inside that directory.
|
|
14501
|
-
// eg:
|
|
14502
|
-
// ['node_modules/*', '!node_modules']
|
|
14503
|
-
// should ignore `node_modules/a.js`
|
|
14504
|
-
[/(?:[^*\/])$/, function (match) {
|
|
14505
|
-
return match + '(?=$|\\/$)';
|
|
14506
|
-
}]], DEFAULT_REPLACER_SUFFIX); // A simple cache, because an ignore rule only has only one certain meaning
|
|
14507
|
-
|
|
14508
|
-
var cache = {}; // @param {pattern}
|
|
14509
|
-
|
|
14510
|
-
function make_regex(pattern, negative) {
|
|
14511
|
-
var r = cache[pattern];
|
|
14512
|
-
|
|
14513
|
-
if (r) {
|
|
14514
|
-
return r;
|
|
14515
|
-
}
|
|
14516
|
-
|
|
14517
|
-
var replacers = negative ? NEGATIVE_REPLACERS : POSITIVE_REPLACERS;
|
|
14518
|
-
var source = replacers.reduce(function (prev, current) {
|
|
14519
|
-
return prev.replace(current[0], current[1].bind(pattern));
|
|
14520
|
-
}, pattern);
|
|
14521
|
-
return cache[pattern] = new RegExp(source, 'i');
|
|
14522
|
-
} // Windows
|
|
14523
|
-
// --------------------------------------------------------------
|
|
14524
|
-
|
|
14525
|
-
/* istanbul ignore if */
|
|
14526
|
-
|
|
14527
|
-
|
|
14528
|
-
if ( // Detect `process` so that it can run in browsers.
|
|
14529
|
-
typeof process !== 'undefined' && (process.env && process.env.IGNORE_TEST_WIN32 || process.platform === 'win32')) {
|
|
14530
|
-
var filter = IgnoreBase.prototype._filter;
|
|
14531
|
-
|
|
14532
|
-
var make_posix = function make_posix(str) {
|
|
14533
|
-
return /^\\\\\?\\/.test(str) || /[^\x00-\x80]+/.test(str) ? str : str.replace(/\\/g, '/');
|
|
14534
|
-
};
|
|
14530
|
+
var make_posix = function make_posix(str) {
|
|
14531
|
+
return /^\\\\\?\\/.test(str) || /[^\x00-\x80]+/.test(str) ? str : str.replace(/\\/g, '/');
|
|
14532
|
+
};
|
|
14535
14533
|
|
|
14536
|
-
|
|
14537
|
-
|
|
14538
|
-
|
|
14534
|
+
IgnoreBase.prototype._filter = function filterWin32(path$$1, slices) {
|
|
14535
|
+
path$$1 = make_posix(path$$1);
|
|
14536
|
+
return filter.call(this, path$$1, slices);
|
|
14537
|
+
};
|
|
14538
|
+
}
|
|
14539
|
+
|
|
14540
|
+
module.exports = function (options) {
|
|
14541
|
+
return new IgnoreBase(options);
|
|
14539
14542
|
};
|
|
14540
|
-
}
|
|
14543
|
+
});
|
|
14541
14544
|
|
|
14542
14545
|
/**
|
|
14543
14546
|
* @param {string} filename
|
|
@@ -18303,9 +18306,9 @@ function charSet(s) {
|
|
|
18303
18306
|
|
|
18304
18307
|
|
|
18305
18308
|
var slashSplit = /\/+/;
|
|
18306
|
-
minimatch.filter = filter
|
|
18309
|
+
minimatch.filter = filter;
|
|
18307
18310
|
|
|
18308
|
-
function filter
|
|
18311
|
+
function filter(pattern, options) {
|
|
18309
18312
|
options = options || {};
|
|
18310
18313
|
return function (p, i, list) {
|
|
18311
18314
|
return minimatch(p, pattern, options);
|
|
@@ -23097,7 +23100,6 @@ function needsParens(path$$1, options) {
|
|
|
23097
23100
|
|
|
23098
23101
|
case "ClassExpression":
|
|
23099
23102
|
case "ClassDeclaration":
|
|
23100
|
-
case "TSAbstractClassDeclaration":
|
|
23101
23103
|
return name === "superClass" && parent.superClass === node;
|
|
23102
23104
|
|
|
23103
23105
|
case "TSTypeAssertion":
|
|
@@ -23346,6 +23348,7 @@ function needsParens(path$$1, options) {
|
|
|
23346
23348
|
|
|
23347
23349
|
case "FunctionExpression":
|
|
23348
23350
|
switch (parent.type) {
|
|
23351
|
+
case "NewExpression":
|
|
23349
23352
|
case "CallExpression":
|
|
23350
23353
|
return name === "callee";
|
|
23351
23354
|
// Not strictly necessary, but it's clearer to the reader if IIFEs are wrapped in parentheses.
|
|
@@ -23390,7 +23393,16 @@ function needsParens(path$$1, options) {
|
|
|
23390
23393
|
}
|
|
23391
23394
|
|
|
23392
23395
|
case "ClassExpression":
|
|
23393
|
-
|
|
23396
|
+
switch (parent.type) {
|
|
23397
|
+
case "ExportDefaultDeclaration":
|
|
23398
|
+
return true;
|
|
23399
|
+
|
|
23400
|
+
case "NewExpression":
|
|
23401
|
+
return name === "callee" && parent.callee === node;
|
|
23402
|
+
|
|
23403
|
+
default:
|
|
23404
|
+
return false;
|
|
23405
|
+
}
|
|
23394
23406
|
|
|
23395
23407
|
case "OptionalMemberExpression":
|
|
23396
23408
|
return parent.type === "MemberExpression";
|
|
@@ -23422,7 +23434,7 @@ function needsParens(path$$1, options) {
|
|
|
23422
23434
|
return false;
|
|
23423
23435
|
|
|
23424
23436
|
case "NGPipeExpression":
|
|
23425
|
-
if (parent.type === "NGRoot" || parent.type === "ObjectProperty" || parent.type === "ArrayExpression" || (parent.type === "CallExpression" || parent.type === "OptionalCallExpression") && parent.arguments[name] === node || parent.type === "NGPipeExpression" && name === "right" || parent.type === "MemberExpression" && name === "property" || parent.type === "AssignmentExpression") {
|
|
23437
|
+
if (parent.type === "NGRoot" || parent.type === "NGMicrosyntaxExpression" || parent.type === "ObjectProperty" || parent.type === "ArrayExpression" || (parent.type === "CallExpression" || parent.type === "OptionalCallExpression") && parent.arguments[name] === node || parent.type === "NGPipeExpression" && name === "right" || parent.type === "MemberExpression" && name === "property" || parent.type === "AssignmentExpression") {
|
|
23426
23438
|
return false;
|
|
23427
23439
|
}
|
|
23428
23440
|
|
|
@@ -23433,7 +23445,7 @@ function needsParens(path$$1, options) {
|
|
|
23433
23445
|
}
|
|
23434
23446
|
|
|
23435
23447
|
function isStatement(node) {
|
|
23436
|
-
return node.type === "BlockStatement" || node.type === "BreakStatement" || node.type === "ClassBody" || node.type === "ClassDeclaration" || node.type === "ClassMethod" || node.type === "ClassProperty" || node.type === "ClassPrivateProperty" || node.type === "ContinueStatement" || node.type === "DebuggerStatement" || node.type === "DeclareClass" || node.type === "DeclareExportAllDeclaration" || node.type === "DeclareExportDeclaration" || node.type === "DeclareFunction" || node.type === "DeclareInterface" || node.type === "DeclareModule" || node.type === "DeclareModuleExports" || node.type === "DeclareVariable" || node.type === "DoWhileStatement" || node.type === "ExportAllDeclaration" || node.type === "ExportDefaultDeclaration" || node.type === "ExportNamedDeclaration" || node.type === "ExpressionStatement" || node.type === "ForAwaitStatement" || node.type === "ForInStatement" || node.type === "ForOfStatement" || node.type === "ForStatement" || node.type === "FunctionDeclaration" || node.type === "IfStatement" || node.type === "ImportDeclaration" || node.type === "InterfaceDeclaration" || node.type === "LabeledStatement" || node.type === "MethodDefinition" || node.type === "ReturnStatement" || node.type === "SwitchStatement" || node.type === "ThrowStatement" || node.type === "TryStatement" || node.type === "
|
|
23448
|
+
return node.type === "BlockStatement" || node.type === "BreakStatement" || node.type === "ClassBody" || node.type === "ClassDeclaration" || node.type === "ClassMethod" || node.type === "ClassProperty" || node.type === "ClassPrivateProperty" || node.type === "ContinueStatement" || node.type === "DebuggerStatement" || node.type === "DeclareClass" || node.type === "DeclareExportAllDeclaration" || node.type === "DeclareExportDeclaration" || node.type === "DeclareFunction" || node.type === "DeclareInterface" || node.type === "DeclareModule" || node.type === "DeclareModuleExports" || node.type === "DeclareVariable" || node.type === "DoWhileStatement" || node.type === "ExportAllDeclaration" || node.type === "ExportDefaultDeclaration" || node.type === "ExportNamedDeclaration" || node.type === "ExpressionStatement" || node.type === "ForAwaitStatement" || node.type === "ForInStatement" || node.type === "ForOfStatement" || node.type === "ForStatement" || node.type === "FunctionDeclaration" || node.type === "IfStatement" || node.type === "ImportDeclaration" || node.type === "InterfaceDeclaration" || node.type === "LabeledStatement" || node.type === "MethodDefinition" || node.type === "ReturnStatement" || node.type === "SwitchStatement" || node.type === "ThrowStatement" || node.type === "TryStatement" || node.type === "TSDeclareFunction" || node.type === "TSEnumDeclaration" || node.type === "TSImportEqualsDeclaration" || node.type === "TSInterfaceDeclaration" || node.type === "TSModuleDeclaration" || node.type === "TSNamespaceExportDeclaration" || node.type === "TypeAlias" || node.type === "VariableDeclaration" || node.type === "WhileStatement" || node.type === "WithStatement";
|
|
23437
23449
|
}
|
|
23438
23450
|
|
|
23439
23451
|
function getUnparenthesizedNode(node) {
|
|
@@ -23583,7 +23595,7 @@ var shouldFlatten$1 = util$1.shouldFlatten;
|
|
|
23583
23595
|
var getNextNonSpaceNonCommentCharacter$1 = util$1.getNextNonSpaceNonCommentCharacter;
|
|
23584
23596
|
var hasNewline$2 = util$1.hasNewline;
|
|
23585
23597
|
var hasNewlineInRange$1 = util$1.hasNewlineInRange;
|
|
23586
|
-
var getLast$
|
|
23598
|
+
var getLast$3 = util$1.getLast;
|
|
23587
23599
|
var getStringWidth$2 = util$1.getStringWidth;
|
|
23588
23600
|
var printString$1 = util$1.printString;
|
|
23589
23601
|
var printNumber$1 = util$1.printNumber;
|
|
@@ -23605,6 +23617,7 @@ var isVueEventBindingExpression = htmlBinding.isVueEventBindingExpression;
|
|
|
23605
23617
|
var hasNode = utils$4.hasNode;
|
|
23606
23618
|
var hasFlowAnnotationComment = utils$4.hasFlowAnnotationComment;
|
|
23607
23619
|
var hasFlowShorthandAnnotationComment = utils$4.hasFlowShorthandAnnotationComment;
|
|
23620
|
+
var needsQuoteProps = new WeakMap();
|
|
23608
23621
|
var _require$$6$builders = doc.builders;
|
|
23609
23622
|
var concat$4 = _require$$6$builders.concat;
|
|
23610
23623
|
var join$2 = _require$$6$builders.join;
|
|
@@ -23737,7 +23750,7 @@ function genericPrint(path$$1, options, printPath, args) {
|
|
|
23737
23750
|
}
|
|
23738
23751
|
|
|
23739
23752
|
function hasNewlineBetweenOrAfterDecorators(node, options) {
|
|
23740
|
-
return hasNewlineInRange$1(options.originalText, options.locStart(node.decorators[0]), options.locEnd(getLast$
|
|
23753
|
+
return hasNewlineInRange$1(options.originalText, options.locStart(node.decorators[0]), options.locEnd(getLast$3(node.decorators))) || hasNewline$2(options.originalText, options.locEnd(getLast$3(node.decorators)));
|
|
23741
23754
|
}
|
|
23742
23755
|
|
|
23743
23756
|
function printDecorators(path$$1, options, print) {
|
|
@@ -24054,7 +24067,7 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
24054
24067
|
return chain;
|
|
24055
24068
|
}
|
|
24056
24069
|
|
|
24057
|
-
var jsxPart = getLast$
|
|
24070
|
+
var jsxPart = getLast$3(_parts);
|
|
24058
24071
|
return group$1(concat$4([chain, ifBreak$1(indent$2(jsxPart), jsxPart, {
|
|
24059
24072
|
groupId
|
|
24060
24073
|
})]));
|
|
@@ -24399,7 +24412,7 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
24399
24412
|
if ( // We want to keep CommonJS- and AMD-style require calls, and AMD-style
|
|
24400
24413
|
// define calls, as a unit.
|
|
24401
24414
|
// e.g. `define(["some/lib", (lib) => {`
|
|
24402
|
-
!isNew && n.callee.type === "Identifier" && (n.callee.name === "require" || n.callee.name === "define") ||
|
|
24415
|
+
!isNew && n.callee.type === "Identifier" && (n.callee.name === "require" || n.callee.name === "define") || // Template literals as single arguments
|
|
24403
24416
|
n.arguments.length === 1 && isTemplateOnItsOwnLine(n.arguments[0], options.originalText, options) || // Keep test declarations on a single line
|
|
24404
24417
|
// e.g. `it('long name', () => {`
|
|
24405
24418
|
!isNew && isTestCall(n, path$$1.getParentNode())) {
|
|
@@ -24519,7 +24532,7 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
24519
24532
|
props.push(concat$4(separatorParts.concat(group$1("..."))));
|
|
24520
24533
|
}
|
|
24521
24534
|
|
|
24522
|
-
var lastElem = getLast$
|
|
24535
|
+
var lastElem = getLast$3(n[propertiesField]);
|
|
24523
24536
|
var canHaveTrailingSeparator = !(lastElem && (lastElem.type === "RestProperty" || lastElem.type === "RestElement" || hasNodeIgnoreComment$1(lastElem) || n.inexact));
|
|
24524
24537
|
var content;
|
|
24525
24538
|
|
|
@@ -24601,7 +24614,7 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
24601
24614
|
parts.push(group$1(concat$4(["[", comments.printDanglingComments(path$$1, options), softline$1, "]"])));
|
|
24602
24615
|
}
|
|
24603
24616
|
} else {
|
|
24604
|
-
var _lastElem = getLast$
|
|
24617
|
+
var _lastElem = getLast$3(n.elements);
|
|
24605
24618
|
|
|
24606
24619
|
var canHaveTrailingComma = !(_lastElem && _lastElem.type === "RestElement"); // JavaScript allows you to have empty elements in an array which
|
|
24607
24620
|
// changes its length based on the number of commas. The algorithm
|
|
@@ -25045,7 +25058,7 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
25045
25058
|
return group$1(concat$4(["<", path$$1.call(print, "name"), path$$1.call(print, "typeParameters"), " ", concat$4(path$$1.map(print, "attributes")), _n.selfClosing ? " />" : ">"]));
|
|
25046
25059
|
}
|
|
25047
25060
|
|
|
25048
|
-
var lastAttrHasTrailingComments = _n.attributes.length && hasTrailingComment(getLast$
|
|
25061
|
+
var lastAttrHasTrailingComments = _n.attributes.length && hasTrailingComment(getLast$3(_n.attributes));
|
|
25049
25062
|
var bracketSameLine = // Simple tags (no attributes and no comment in tag name) should be
|
|
25050
25063
|
// kept unbroken regardless of `jsxBracketSameLine`
|
|
25051
25064
|
!_n.attributes.length && !nameHasComments || options.jsxBracketSameLine && ( // We should print the bracket in a new line for the following cases:
|
|
@@ -25151,7 +25164,6 @@ function printPathNoParens(path$$1, options, print, args) {
|
|
|
25151
25164
|
|
|
25152
25165
|
case "ClassDeclaration":
|
|
25153
25166
|
case "ClassExpression":
|
|
25154
|
-
case "TSAbstractClassDeclaration":
|
|
25155
25167
|
if (isNodeStartingWithDeclare(n, options)) {
|
|
25156
25168
|
parts.push("declare ");
|
|
25157
25169
|
}
|
|
@@ -26214,18 +26226,27 @@ function printStatementSequence(path$$1, options, print) {
|
|
|
26214
26226
|
|
|
26215
26227
|
function printPropertyKey(path$$1, options, print) {
|
|
26216
26228
|
var node = path$$1.getNode();
|
|
26229
|
+
var parent = path$$1.getParentNode();
|
|
26217
26230
|
var key = node.key;
|
|
26218
26231
|
|
|
26219
|
-
if (
|
|
26232
|
+
if (options.quoteProps === "consistent" && !needsQuoteProps.has(parent)) {
|
|
26233
|
+
var objectHasStringProp = (parent.properties || parent.body || parent.members).some(function (prop) {
|
|
26234
|
+
return prop.key && prop.key.type !== "Identifier" && !isStringPropSafeToCoerceToIdentifier(prop, options);
|
|
26235
|
+
});
|
|
26236
|
+
needsQuoteProps.set(parent, objectHasStringProp);
|
|
26237
|
+
}
|
|
26238
|
+
|
|
26239
|
+
if (key.type === "Identifier" && !node.computed && (options.parser === "json" || options.quoteProps === "consistent" && needsQuoteProps.get(parent))) {
|
|
26220
26240
|
// a -> "a"
|
|
26241
|
+
var prop = printString$1(JSON.stringify(key.name), options);
|
|
26221
26242
|
return path$$1.call(function (keyPath) {
|
|
26222
26243
|
return comments.printComments(keyPath, function () {
|
|
26223
|
-
return
|
|
26244
|
+
return prop;
|
|
26224
26245
|
}, options);
|
|
26225
26246
|
}, "key");
|
|
26226
26247
|
}
|
|
26227
26248
|
|
|
26228
|
-
if (
|
|
26249
|
+
if (isStringPropSafeToCoerceToIdentifier(node, options) && (options.quoteProps === "as-needed" || options.quoteProps === "consistent" && !needsQuoteProps.get(parent))) {
|
|
26229
26250
|
// 'a' -> a
|
|
26230
26251
|
return path$$1.call(function (keyPath) {
|
|
26231
26252
|
return comments.printComments(keyPath, function () {
|
|
@@ -26284,7 +26305,7 @@ function couldGroupArg(arg) {
|
|
|
26284
26305
|
}
|
|
26285
26306
|
|
|
26286
26307
|
function shouldGroupLastArg(args) {
|
|
26287
|
-
var lastArg = getLast$
|
|
26308
|
+
var lastArg = getLast$3(args);
|
|
26288
26309
|
var penultimateArg = getPenultimate$1(args);
|
|
26289
26310
|
return !hasLeadingComment(lastArg) && !hasTrailingComment(lastArg) && couldGroupArg(lastArg) && ( // If the last two arguments are of the same type,
|
|
26290
26311
|
// disable last element expansion.
|
|
@@ -26380,7 +26401,8 @@ function printArgumentsList(path$$1, options, print) {
|
|
|
26380
26401
|
|
|
26381
26402
|
return concat$4(parts);
|
|
26382
26403
|
}, "arguments");
|
|
26383
|
-
var maybeTrailingComma =
|
|
26404
|
+
var maybeTrailingComma = // Dynamic imports cannot have trailing commas
|
|
26405
|
+
!(node.callee && node.callee.type === "Import") && shouldPrintComma(options, "all") ? "," : "";
|
|
26384
26406
|
|
|
26385
26407
|
function allArgsBrokenOut() {
|
|
26386
26408
|
return group$1(concat$4(["(", indent$2(concat$4([line$3, concat$4(printedArguments)])), maybeTrailingComma, line$3, ")"]), {
|
|
@@ -26429,14 +26451,14 @@ function printArgumentsList(path$$1, options, print) {
|
|
|
26429
26451
|
var somePrintedArgumentsWillBreak = printedArguments.some(willBreak$1);
|
|
26430
26452
|
return concat$4([somePrintedArgumentsWillBreak ? breakParent$2 : "", conditionalGroup$1([concat$4([ifBreak$1(indent$2(concat$4(["(", softline$1, concat$4(printedExpanded)])), concat$4(["(", concat$4(printedExpanded)])), somePrintedArgumentsWillBreak ? concat$4([ifBreak$1(maybeTrailingComma), softline$1]) : "", ")"]), shouldGroupFirst ? concat$4(["(", group$1(printedExpanded[0], {
|
|
26431
26453
|
shouldBreak: true
|
|
26432
|
-
}), concat$4(printedExpanded.slice(1)), ")"]) : concat$4(["(", concat$4(printedArguments.slice(0, -1)), group$1(getLast$
|
|
26454
|
+
}), concat$4(printedExpanded.slice(1)), ")"]) : concat$4(["(", concat$4(printedArguments.slice(0, -1)), group$1(getLast$3(printedExpanded), {
|
|
26433
26455
|
shouldBreak: true
|
|
26434
26456
|
}), ")"]), allArgsBrokenOut()], {
|
|
26435
26457
|
shouldBreak
|
|
26436
26458
|
})]);
|
|
26437
26459
|
}
|
|
26438
26460
|
|
|
26439
|
-
return group$1(concat$4(["(", indent$2(concat$4([softline$1, concat$4(printedArguments)])), ifBreak$1(
|
|
26461
|
+
return group$1(concat$4(["(", indent$2(concat$4([softline$1, concat$4(printedArguments)])), ifBreak$1(maybeTrailingComma), softline$1, ")"]), {
|
|
26440
26462
|
shouldBreak: printedArguments.some(willBreak$1) || anyArgEmptyLine
|
|
26441
26463
|
});
|
|
26442
26464
|
}
|
|
@@ -26475,12 +26497,37 @@ function printFunctionTypeParameters(path$$1, options, print) {
|
|
|
26475
26497
|
|
|
26476
26498
|
function printFunctionParams(path$$1, print, options, expandArg, printTypeParams) {
|
|
26477
26499
|
var fun = path$$1.getValue();
|
|
26500
|
+
var parent = path$$1.getParentNode();
|
|
26478
26501
|
var paramsField = fun.parameters ? "parameters" : "params";
|
|
26502
|
+
var isParametersInTestCall = isTestCall(parent);
|
|
26503
|
+
var shouldHugParameters = shouldHugArguments(fun);
|
|
26504
|
+
var shouldExpandParameters = expandArg && !(fun[paramsField] && fun[paramsField].some(function (n) {
|
|
26505
|
+
return n.comments;
|
|
26506
|
+
}));
|
|
26479
26507
|
var typeParams = printTypeParams ? printFunctionTypeParameters(path$$1, options, print) : "";
|
|
26480
26508
|
var printed = [];
|
|
26481
26509
|
|
|
26482
26510
|
if (fun[paramsField]) {
|
|
26483
|
-
|
|
26511
|
+
var lastArgIndex = fun[paramsField].length - 1;
|
|
26512
|
+
printed = path$$1.map(function (childPath, index) {
|
|
26513
|
+
var parts = [];
|
|
26514
|
+
var param = childPath.getValue();
|
|
26515
|
+
parts.push(print(childPath));
|
|
26516
|
+
|
|
26517
|
+
if (index === lastArgIndex) {
|
|
26518
|
+
if (fun.rest) {
|
|
26519
|
+
parts.push(",", line$3);
|
|
26520
|
+
}
|
|
26521
|
+
} else if (isParametersInTestCall || shouldHugParameters || shouldExpandParameters) {
|
|
26522
|
+
parts.push(", ");
|
|
26523
|
+
} else if (isNextLineEmpty$2(options.originalText, param, options)) {
|
|
26524
|
+
parts.push(",", hardline$3, hardline$3);
|
|
26525
|
+
} else {
|
|
26526
|
+
parts.push(",", line$3);
|
|
26527
|
+
}
|
|
26528
|
+
|
|
26529
|
+
return concat$4(parts);
|
|
26530
|
+
}, paramsField);
|
|
26484
26531
|
}
|
|
26485
26532
|
|
|
26486
26533
|
if (fun.rest) {
|
|
@@ -26495,7 +26542,7 @@ function printFunctionParams(path$$1, print, options, expandArg, printTypeParams
|
|
|
26495
26542
|
}), ")"]);
|
|
26496
26543
|
}
|
|
26497
26544
|
|
|
26498
|
-
var lastParam = getLast$
|
|
26545
|
+
var lastParam = getLast$3(fun[paramsField]); // If the parent is a call with the first/last argument expansion and this is the
|
|
26499
26546
|
// params of the first/last argument, we dont want the arguments to break and instead
|
|
26500
26547
|
// want the whole expression to be on a new line.
|
|
26501
26548
|
//
|
|
@@ -26506,10 +26553,8 @@ function printFunctionParams(path$$1, print, options, expandArg, printTypeParams
|
|
|
26506
26553
|
// }) ) => {
|
|
26507
26554
|
// })
|
|
26508
26555
|
|
|
26509
|
-
if (
|
|
26510
|
-
return
|
|
26511
|
-
}))) {
|
|
26512
|
-
return group$1(concat$4([removeLines$1(typeParams), "(", join$2(", ", printed.map(removeLines$1)), ")"]));
|
|
26556
|
+
if (shouldExpandParameters) {
|
|
26557
|
+
return group$1(concat$4([removeLines$1(typeParams), "(", concat$4(printed.map(removeLines$1)), ")"]));
|
|
26513
26558
|
} // Single object destructuring should hug
|
|
26514
26559
|
//
|
|
26515
26560
|
// function({
|
|
@@ -26519,14 +26564,13 @@ function printFunctionParams(path$$1, print, options, expandArg, printTypeParams
|
|
|
26519
26564
|
// }) {}
|
|
26520
26565
|
|
|
26521
26566
|
|
|
26522
|
-
if (
|
|
26523
|
-
return concat$4([typeParams, "(",
|
|
26524
|
-
}
|
|
26567
|
+
if (shouldHugParameters) {
|
|
26568
|
+
return concat$4([typeParams, "(", concat$4(printed), ")"]);
|
|
26569
|
+
} // don't break in specs, eg; `it("should maintain parens around done even when long", (done) => {})`
|
|
26525
26570
|
|
|
26526
|
-
var parent = path$$1.getParentNode(); // don't break in specs, eg; `it("should maintain parens around done even when long", (done) => {})`
|
|
26527
26571
|
|
|
26528
|
-
if (
|
|
26529
|
-
return concat$4([typeParams, "(",
|
|
26572
|
+
if (isParametersInTestCall) {
|
|
26573
|
+
return concat$4([typeParams, "(", concat$4(printed), ")"]);
|
|
26530
26574
|
}
|
|
26531
26575
|
|
|
26532
26576
|
var isFlowShorthandWithOneArg = (isObjectTypePropertyAFunction(parent, options) || isTypeAnnotationAFunction(parent, options) || parent.type === "TypeAlias" || parent.type === "UnionTypeAnnotation" || parent.type === "TSUnionType" || parent.type === "IntersectionTypeAnnotation" || parent.type === "FunctionTypeAnnotation" && parent.returnType === fun) && fun[paramsField].length === 1 && fun[paramsField][0].name === null && fun[paramsField][0].typeAnnotation && fun.typeParameters === null && isSimpleFlowType(fun[paramsField][0].typeAnnotation) && !fun.rest;
|
|
@@ -26540,7 +26584,7 @@ function printFunctionParams(path$$1, print, options, expandArg, printTypeParams
|
|
|
26540
26584
|
}
|
|
26541
26585
|
|
|
26542
26586
|
var canHaveTrailingComma = !(lastParam && lastParam.type === "RestElement") && !fun.rest;
|
|
26543
|
-
return concat$4([typeParams, "(", indent$2(concat$4([softline$1,
|
|
26587
|
+
return concat$4([typeParams, "(", indent$2(concat$4([softline$1, concat$4(printed)])), ifBreak$1(canHaveTrailingComma && shouldPrintComma(options, "all") ? "," : ""), softline$1, ")"]);
|
|
26544
26588
|
}
|
|
26545
26589
|
|
|
26546
26590
|
function shouldPrintParamsWithoutParens(path$$1, options) {
|
|
@@ -26655,7 +26699,7 @@ function printExportDeclaration(path$$1, options, print) {
|
|
|
26655
26699
|
if (decl.declaration) {
|
|
26656
26700
|
parts.push(path$$1.call(print, "declaration"));
|
|
26657
26701
|
|
|
26658
|
-
if (isDefault && decl.declaration.type !== "ClassDeclaration" && decl.declaration.type !== "FunctionDeclaration" && decl.declaration.type !== "
|
|
26702
|
+
if (isDefault && decl.declaration.type !== "ClassDeclaration" && decl.declaration.type !== "FunctionDeclaration" && decl.declaration.type !== "TSInterfaceDeclaration" && decl.declaration.type !== "DeclareClass" && decl.declaration.type !== "DeclareFunction" && decl.declaration.type !== "TSDeclareFunction") {
|
|
26659
26703
|
parts.push(semi);
|
|
26660
26704
|
}
|
|
26661
26705
|
} else {
|
|
@@ -26766,7 +26810,7 @@ function printClass(path$$1, options, print) {
|
|
|
26766
26810
|
var n = path$$1.getValue();
|
|
26767
26811
|
var parts = [];
|
|
26768
26812
|
|
|
26769
|
-
if (n.
|
|
26813
|
+
if (n.abstract) {
|
|
26770
26814
|
parts.push("abstract ");
|
|
26771
26815
|
}
|
|
26772
26816
|
|
|
@@ -27067,27 +27111,23 @@ function printMemberChain(path$$1, options, print) {
|
|
|
27067
27111
|
return firstNode.type === "ThisExpression" || firstNode.type === "Identifier" && (isFactory(firstNode.name) || isExpression && isShort(firstNode.name) || hasComputed);
|
|
27068
27112
|
}
|
|
27069
27113
|
|
|
27070
|
-
var lastNode = getLast$
|
|
27114
|
+
var lastNode = getLast$3(groups[0]).node;
|
|
27071
27115
|
return (lastNode.type === "MemberExpression" || lastNode.type === "OptionalMemberExpression") && lastNode.property.type === "Identifier" && (isFactory(lastNode.property.name) || hasComputed);
|
|
27072
27116
|
}
|
|
27073
27117
|
|
|
27074
27118
|
var shouldMerge = groups.length >= 2 && !groups[1][0].node.comments && shouldNotWrap(groups);
|
|
27075
27119
|
|
|
27076
27120
|
function printGroup(printedGroup) {
|
|
27077
|
-
var
|
|
27121
|
+
var printed = printedGroup.map(function (tuple) {
|
|
27122
|
+
return tuple.printed;
|
|
27123
|
+
}); // Checks if the last node (i.e. the parent node) needs parens and print
|
|
27124
|
+
// accordingly
|
|
27078
27125
|
|
|
27079
|
-
|
|
27080
|
-
|
|
27081
|
-
// and print accordingly
|
|
27082
|
-
if (printedGroup[_i3 + 1] && printedGroup[_i3 + 1].needsParens) {
|
|
27083
|
-
result.push("(", printedGroup[_i3].printed, printedGroup[_i3 + 1].printed, ")");
|
|
27084
|
-
_i3++;
|
|
27085
|
-
} else {
|
|
27086
|
-
result.push(printedGroup[_i3].printed);
|
|
27087
|
-
}
|
|
27126
|
+
if (printedGroup.length > 0 && printedGroup[printedGroup.length - 1].needsParens) {
|
|
27127
|
+
return concat$4(["("].concat(_toConsumableArray(printed), [")"]));
|
|
27088
27128
|
}
|
|
27089
27129
|
|
|
27090
|
-
return concat$4(
|
|
27130
|
+
return concat$4(printed);
|
|
27091
27131
|
}
|
|
27092
27132
|
|
|
27093
27133
|
function printIndentedGroup(groups) {
|
|
@@ -27117,7 +27157,7 @@ function printMemberChain(path$$1, options, print) {
|
|
|
27117
27157
|
// empty line after
|
|
27118
27158
|
|
|
27119
27159
|
|
|
27120
|
-
var lastNodeBeforeIndent = getLast$
|
|
27160
|
+
var lastNodeBeforeIndent = getLast$3(shouldMerge ? groups.slice(1, 2)[0] : groups[0]).node;
|
|
27121
27161
|
var shouldHaveEmptyLineBeforeIndent = lastNodeBeforeIndent.type !== "CallExpression" && lastNodeBeforeIndent.type !== "OptionalCallExpression" && shouldInsertEmptyLineAfter(lastNodeBeforeIndent);
|
|
27122
27162
|
var expanded = concat$4([printGroup(groups[0]), shouldMerge ? concat$4(groups.slice(1, 2).map(printGroup)) : "", shouldHaveEmptyLineBeforeIndent ? hardline$3 : "", printIndentedGroup(groups.slice(shouldMerge ? 2 : 1))]);
|
|
27123
27163
|
var callExpressions = printedNodes.map(function (_ref) {
|
|
@@ -27137,7 +27177,7 @@ function printMemberChain(path$$1, options, print) {
|
|
|
27137
27177
|
*/
|
|
27138
27178
|
function (lastGroupDoc, lastGroupNode) {
|
|
27139
27179
|
return isCallOrOptionalCallExpression(lastGroupNode) && willBreak$1(lastGroupDoc);
|
|
27140
|
-
}(getLast$
|
|
27180
|
+
}(getLast$3(printedGroups), getLast$3(getLast$3(groups)).node) && callExpressions.slice(0, -1).some(function (n) {
|
|
27141
27181
|
return n.arguments.some(isFunctionOrArrowExpression);
|
|
27142
27182
|
})) {
|
|
27143
27183
|
return group$1(expanded);
|
|
@@ -27348,7 +27388,7 @@ function printJSXChildren(path$$1, options, print, jsxWhitespace, isFacebookTran
|
|
|
27348
27388
|
|
|
27349
27389
|
var endWhitespace; // Ends with whitespace
|
|
27350
27390
|
|
|
27351
|
-
if (getLast$
|
|
27391
|
+
if (getLast$3(words) === "") {
|
|
27352
27392
|
words.pop();
|
|
27353
27393
|
endWhitespace = words.pop();
|
|
27354
27394
|
} // This was whitespace only without a new line.
|
|
@@ -27369,13 +27409,13 @@ function printJSXChildren(path$$1, options, print, jsxWhitespace, isFacebookTran
|
|
|
27369
27409
|
if (endWhitespace !== undefined) {
|
|
27370
27410
|
if (/\n/.test(endWhitespace)) {
|
|
27371
27411
|
var _next = n.children[i + 1];
|
|
27372
|
-
children.push(separatorWithWhitespace(isFacebookTranslationTag, getLast$
|
|
27412
|
+
children.push(separatorWithWhitespace(isFacebookTranslationTag, getLast$3(children), child, _next));
|
|
27373
27413
|
} else {
|
|
27374
27414
|
children.push(jsxWhitespace);
|
|
27375
27415
|
}
|
|
27376
27416
|
} else {
|
|
27377
27417
|
var _next2 = n.children[i + 1];
|
|
27378
|
-
children.push(separatorNoWhitespace(isFacebookTranslationTag, getLast$
|
|
27418
|
+
children.push(separatorNoWhitespace(isFacebookTranslationTag, getLast$3(children), child, _next2));
|
|
27379
27419
|
}
|
|
27380
27420
|
} else if (/\n/.test(text)) {
|
|
27381
27421
|
// Keep (up to one) blank line between tags/expressions/text.
|
|
@@ -27484,7 +27524,7 @@ function printJSXElement(path$$1, options, print) {
|
|
|
27484
27524
|
} // Trim trailing lines (or empty strings)
|
|
27485
27525
|
|
|
27486
27526
|
|
|
27487
|
-
while (children.length && (isLineNext$1(getLast$
|
|
27527
|
+
while (children.length && (isLineNext$1(getLast$3(children)) || isEmpty$1(getLast$3(children)))) {
|
|
27488
27528
|
children.pop();
|
|
27489
27529
|
} // Trim leading lines (or empty strings)
|
|
27490
27530
|
|
|
@@ -28031,7 +28071,7 @@ function needsHardlineAfterDanglingComment(node) {
|
|
|
28031
28071
|
return false;
|
|
28032
28072
|
}
|
|
28033
28073
|
|
|
28034
|
-
var lastDanglingComment = getLast$
|
|
28074
|
+
var lastDanglingComment = getLast$3(node.comments.filter(function (comment) {
|
|
28035
28075
|
return !comment.leading && !comment.trailing;
|
|
28036
28076
|
}));
|
|
28037
28077
|
return lastDanglingComment && !comments$3.isBlockComment(lastDanglingComment);
|
|
@@ -28041,6 +28081,10 @@ function isLiteral(node) {
|
|
|
28041
28081
|
return node.type === "BooleanLiteral" || node.type === "DirectiveLiteral" || node.type === "Literal" || node.type === "NullLiteral" || node.type === "NumericLiteral" || node.type === "RegExpLiteral" || node.type === "StringLiteral" || node.type === "TemplateLiteral" || node.type === "TSTypeLiteral" || node.type === "JSXText";
|
|
28042
28082
|
}
|
|
28043
28083
|
|
|
28084
|
+
function isStringPropSafeToCoerceToIdentifier(node, options) {
|
|
28085
|
+
return isStringLiteral(node.key) && isIdentifierName(node.key.value) && !node.computed && options.parser !== "json" && !(options.parser === "typescript" && node.type === "ClassProperty");
|
|
28086
|
+
}
|
|
28087
|
+
|
|
28044
28088
|
function isNumericLiteral(node) {
|
|
28045
28089
|
return node.type === "NumericLiteral" || node.type === "Literal" && typeof node.value === "number";
|
|
28046
28090
|
}
|
|
@@ -28131,7 +28175,7 @@ function willPrintOwnComments(path$$1) {
|
|
|
28131
28175
|
}
|
|
28132
28176
|
|
|
28133
28177
|
function canAttachComment(node) {
|
|
28134
|
-
return node.type && node.type !== "CommentBlock" && node.type !== "CommentLine" && node.type !== "Line" && node.type !== "Block" && node.type !== "EmptyStatement" && node.type !== "TemplateElement" && node.type !== "Import"
|
|
28178
|
+
return node.type && node.type !== "CommentBlock" && node.type !== "CommentLine" && node.type !== "Line" && node.type !== "Block" && node.type !== "EmptyStatement" && node.type !== "TemplateElement" && node.type !== "Import";
|
|
28135
28179
|
}
|
|
28136
28180
|
|
|
28137
28181
|
function printComment$1(commentPath, options) {
|
|
@@ -28383,6 +28427,23 @@ var options$4 = {
|
|
|
28383
28427
|
default: false,
|
|
28384
28428
|
description: "Use single quotes in JSX."
|
|
28385
28429
|
},
|
|
28430
|
+
quoteProps: {
|
|
28431
|
+
since: "1.17.0",
|
|
28432
|
+
category: CATEGORY_JAVASCRIPT,
|
|
28433
|
+
type: "choice",
|
|
28434
|
+
default: "as-needed",
|
|
28435
|
+
description: "Change when properties in objects are quoted.",
|
|
28436
|
+
choices: [{
|
|
28437
|
+
value: "as-needed",
|
|
28438
|
+
description: "Only add quotes around object properties where required."
|
|
28439
|
+
}, {
|
|
28440
|
+
value: "consistent",
|
|
28441
|
+
description: "If at least one property in an object requires quotes, quote all properties."
|
|
28442
|
+
}, {
|
|
28443
|
+
value: "preserve",
|
|
28444
|
+
description: "Respect the input use of quotes in object properties."
|
|
28445
|
+
}]
|
|
28446
|
+
},
|
|
28386
28447
|
trailingComma: {
|
|
28387
28448
|
since: "0.0.0",
|
|
28388
28449
|
category: CATEGORY_JAVASCRIPT,
|
|
@@ -30536,7 +30597,7 @@ function genericPrint$3(path$$1, options, print) {
|
|
|
30536
30597
|
|
|
30537
30598
|
case "FragmentDefinition":
|
|
30538
30599
|
{
|
|
30539
|
-
return concat$11(["fragment ", path$$1.call(print, "name"), " on ", path$$1.call(print, "typeCondition"), printDirectives(path$$1, print, n), " ", path$$1.call(print, "selectionSet")]);
|
|
30600
|
+
return concat$11(["fragment ", path$$1.call(print, "name"), n.variableDefinitions && n.variableDefinitions.length ? group$12(concat$11(["(", indent$7(concat$11([softline$5, join$8(concat$11([ifBreak$4("", ", "), softline$5]), path$$1.map(print, "variableDefinitions"))])), softline$5, ")"])) : "", " on ", path$$1.call(print, "typeCondition"), printDirectives(path$$1, print, n), " ", path$$1.call(print, "selectionSet")]);
|
|
30540
30601
|
}
|
|
30541
30602
|
|
|
30542
30603
|
case "SelectionSet":
|
|
@@ -30619,7 +30680,7 @@ function genericPrint$3(path$$1, options, print) {
|
|
|
30619
30680
|
|
|
30620
30681
|
case "VariableDefinition":
|
|
30621
30682
|
{
|
|
30622
|
-
return concat$11([path$$1.call(print, "variable"), ": ", path$$1.call(print, "type"), n.defaultValue ? concat$11([" = ", path$$1.call(print, "defaultValue")]) : ""]);
|
|
30683
|
+
return concat$11([path$$1.call(print, "variable"), ": ", path$$1.call(print, "type"), n.defaultValue ? concat$11([" = ", path$$1.call(print, "defaultValue")]) : "", printDirectives(path$$1, print, n)]);
|
|
30623
30684
|
}
|
|
30624
30685
|
|
|
30625
30686
|
case "TypeExtensionDefinition":
|
|
@@ -30852,7 +30913,7 @@ var json$6 = {"cjkPattern":"[\\u02ea-\\u02eb\\u1100-\\u11ff\\u2e80-\\u2e99\\u2e9
|
|
|
30852
30913
|
var cjkPattern = json$6.cjkPattern;
|
|
30853
30914
|
var kPattern = json$6.kPattern;
|
|
30854
30915
|
var punctuationPattern$1 = json$6.punctuationPattern;
|
|
30855
|
-
var getLast$
|
|
30916
|
+
var getLast$4 = util$1.getLast;
|
|
30856
30917
|
var INLINE_NODE_TYPES$1 = ["liquidNode", "inlineCode", "emphasis", "strong", "delete", "link", "linkReference", "image", "imageReference", "footnote", "footnoteReference", "sentence", "whitespace", "word", "break", "inlineMath"];
|
|
30857
30918
|
var INLINE_NODE_WRAPPER_TYPES$1 = INLINE_NODE_TYPES$1.concat(["tableCell", "paragraph", "heading"]);
|
|
30858
30919
|
var kRegex = new RegExp(kPattern);
|
|
@@ -30897,7 +30958,7 @@ function splitText$1(text, options) {
|
|
|
30897
30958
|
value: innerToken,
|
|
30898
30959
|
kind: KIND_NON_CJK,
|
|
30899
30960
|
hasLeadingPunctuation: punctuationRegex.test(innerToken[0]),
|
|
30900
|
-
hasTrailingPunctuation: punctuationRegex.test(getLast$
|
|
30961
|
+
hasTrailingPunctuation: punctuationRegex.test(getLast$4(innerToken))
|
|
30901
30962
|
});
|
|
30902
30963
|
}
|
|
30903
30964
|
|
|
@@ -30923,7 +30984,7 @@ function splitText$1(text, options) {
|
|
|
30923
30984
|
return nodes;
|
|
30924
30985
|
|
|
30925
30986
|
function appendNode(node) {
|
|
30926
|
-
var lastNode = getLast$
|
|
30987
|
+
var lastNode = getLast$4(nodes);
|
|
30927
30988
|
|
|
30928
30989
|
if (lastNode && lastNode.type === "word") {
|
|
30929
30990
|
if (lastNode.kind === KIND_NON_CJK && node.kind === KIND_CJ_LETTER && !lastNode.hasTrailingPunctuation || lastNode.kind === KIND_CJ_LETTER && node.kind === KIND_NON_CJK && !node.hasLeadingPunctuation) {
|
|
@@ -31385,6 +31446,7 @@ function markAlignedList(ast, options) {
|
|
|
31385
31446
|
var preprocess_1$2 = preprocess$2;
|
|
31386
31447
|
|
|
31387
31448
|
var _require$$0$builders$6 = doc.builders;
|
|
31449
|
+
var breakParent$3 = _require$$0$builders$6.breakParent;
|
|
31388
31450
|
var concat$12 = _require$$0$builders$6.concat;
|
|
31389
31451
|
var join$9 = _require$$0$builders$6.join;
|
|
31390
31452
|
var line$8 = _require$$0$builders$6.line;
|
|
@@ -31392,6 +31454,7 @@ var literalline$4 = _require$$0$builders$6.literalline;
|
|
|
31392
31454
|
var markAsRoot$2 = _require$$0$builders$6.markAsRoot;
|
|
31393
31455
|
var hardline$10 = _require$$0$builders$6.hardline;
|
|
31394
31456
|
var softline$6 = _require$$0$builders$6.softline;
|
|
31457
|
+
var ifBreak$5 = _require$$0$builders$6.ifBreak;
|
|
31395
31458
|
var fill$4 = _require$$0$builders$6.fill;
|
|
31396
31459
|
var align$2 = _require$$0$builders$6.align;
|
|
31397
31460
|
var indent$8 = _require$$0$builders$6.indent;
|
|
@@ -31744,6 +31807,7 @@ function printLine(path$$1, value, options) {
|
|
|
31744
31807
|
}
|
|
31745
31808
|
|
|
31746
31809
|
function printTable(path$$1, options, print) {
|
|
31810
|
+
var hardlineWithoutBreakParent = hardline$10.parts[0];
|
|
31747
31811
|
var node = path$$1.getValue();
|
|
31748
31812
|
var contents = []; // { [rowIndex: number]: { [columnIndex: number]: string } }
|
|
31749
31813
|
|
|
@@ -31753,7 +31817,8 @@ function printTable(path$$1, options, print) {
|
|
|
31753
31817
|
rowContents.push(printDocToString$3(cellPath.call(print), options).formatted);
|
|
31754
31818
|
}, "children");
|
|
31755
31819
|
contents.push(rowContents);
|
|
31756
|
-
}, "children");
|
|
31820
|
+
}, "children"); // Get the width of each column
|
|
31821
|
+
|
|
31757
31822
|
var columnMaxWidths = contents.reduce(function (currentWidths, rowContents) {
|
|
31758
31823
|
return currentWidths.map(function (width, columnIndex) {
|
|
31759
31824
|
return Math.max(width, util$1.getStringWidth(rowContents[columnIndex]));
|
|
@@ -31762,28 +31827,48 @@ function printTable(path$$1, options, print) {
|
|
|
31762
31827
|
return 3;
|
|
31763
31828
|
}) // minimum width = 3 (---, :--, :-:, --:)
|
|
31764
31829
|
);
|
|
31765
|
-
|
|
31766
|
-
|
|
31767
|
-
|
|
31830
|
+
var alignedTable = join$9(hardlineWithoutBreakParent, [printRow(contents[0]), printSeparator(), join$9(hardlineWithoutBreakParent, contents.slice(1).map(function (rowContents) {
|
|
31831
|
+
return printRow(rowContents);
|
|
31832
|
+
}))]);
|
|
31833
|
+
|
|
31834
|
+
if (options.proseWrap !== "never") {
|
|
31835
|
+
return concat$12([breakParent$3, alignedTable]);
|
|
31836
|
+
} // Only if the --prose-wrap never is set and it exceeds the print width.
|
|
31837
|
+
|
|
31838
|
+
|
|
31839
|
+
var compactTable = join$9(hardlineWithoutBreakParent, [printRow(contents[0],
|
|
31840
|
+
/* isCompact */
|
|
31841
|
+
true), printSeparator(
|
|
31842
|
+
/* isCompact */
|
|
31843
|
+
true), join$9(hardlineWithoutBreakParent, contents.slice(1).map(function (rowContents) {
|
|
31844
|
+
return printRow(rowContents,
|
|
31845
|
+
/* isCompact */
|
|
31846
|
+
true);
|
|
31847
|
+
}))]);
|
|
31848
|
+
return concat$12([breakParent$3, group$13(ifBreak$5(compactTable, alignedTable))]);
|
|
31849
|
+
|
|
31850
|
+
function printSeparator(isCompact) {
|
|
31768
31851
|
return concat$12(["| ", join$9(" | ", columnMaxWidths.map(function (width, index) {
|
|
31852
|
+
var spaces = isCompact ? 3 : width;
|
|
31853
|
+
|
|
31769
31854
|
switch (node.align[index]) {
|
|
31770
31855
|
case "left":
|
|
31771
|
-
return ":" + "-".repeat(
|
|
31856
|
+
return ":" + "-".repeat(spaces - 1);
|
|
31772
31857
|
|
|
31773
31858
|
case "right":
|
|
31774
|
-
return "-".repeat(
|
|
31859
|
+
return "-".repeat(spaces - 1) + ":";
|
|
31775
31860
|
|
|
31776
31861
|
case "center":
|
|
31777
|
-
return ":" + "-".repeat(
|
|
31862
|
+
return ":" + "-".repeat(spaces - 2) + ":";
|
|
31778
31863
|
|
|
31779
31864
|
default:
|
|
31780
|
-
return "-".repeat(
|
|
31865
|
+
return "-".repeat(spaces);
|
|
31781
31866
|
}
|
|
31782
31867
|
})), " |"]);
|
|
31783
31868
|
}
|
|
31784
31869
|
|
|
31785
|
-
function printRow(rowContents) {
|
|
31786
|
-
return concat$12(["| ", join$9(" | ", rowContents.map(function (rowContent, columnIndex) {
|
|
31870
|
+
function printRow(rowContents, isCompact) {
|
|
31871
|
+
return concat$12(["| ", join$9(" | ", isCompact ? rowContents : rowContents.map(function (rowContent, columnIndex) {
|
|
31787
31872
|
switch (node.align[columnIndex]) {
|
|
31788
31873
|
case "right":
|
|
31789
31874
|
return alignRight(rowContent, columnMaxWidths[columnIndex]);
|
|
@@ -31798,11 +31883,13 @@ function printTable(path$$1, options, print) {
|
|
|
31798
31883
|
}
|
|
31799
31884
|
|
|
31800
31885
|
function alignLeft(text, width) {
|
|
31801
|
-
|
|
31886
|
+
var spaces = width - util$1.getStringWidth(text);
|
|
31887
|
+
return concat$12([text, " ".repeat(spaces)]);
|
|
31802
31888
|
}
|
|
31803
31889
|
|
|
31804
31890
|
function alignRight(text, width) {
|
|
31805
|
-
|
|
31891
|
+
var spaces = width - util$1.getStringWidth(text);
|
|
31892
|
+
return concat$12([" ".repeat(spaces), text]);
|
|
31806
31893
|
}
|
|
31807
31894
|
|
|
31808
31895
|
function alignCenter(text, width) {
|
|
@@ -33827,7 +33914,7 @@ var parseSrcset = createCommonjsModule(function (module) {
|
|
|
33827
33914
|
|
|
33828
33915
|
var _require$$0$builders$9 = doc.builders;
|
|
33829
33916
|
var concat$16 = _require$$0$builders$9.concat;
|
|
33830
|
-
var ifBreak$
|
|
33917
|
+
var ifBreak$7 = _require$$0$builders$9.ifBreak;
|
|
33831
33918
|
var join$11 = _require$$0$builders$9.join;
|
|
33832
33919
|
var line$10 = _require$$0$builders$9.line;
|
|
33833
33920
|
|
|
@@ -33885,7 +33972,7 @@ function printImgSrcset$1(value) {
|
|
|
33885
33972
|
var urlPadding = maxUrlLength - url.length + 1;
|
|
33886
33973
|
var descriptorPadding = maxDescriptorLeftLength - descriptorLeftLengths[index];
|
|
33887
33974
|
var alignment = " ".repeat(urlPadding + descriptorPadding);
|
|
33888
|
-
parts.push(ifBreak$
|
|
33975
|
+
parts.push(ifBreak$7(alignment, " "), descriptor + unit);
|
|
33889
33976
|
}
|
|
33890
33977
|
|
|
33891
33978
|
return concat$16(parts);
|
|
@@ -33900,12 +33987,12 @@ var builders = doc.builders;
|
|
|
33900
33987
|
var _require$$0$utils = doc.utils;
|
|
33901
33988
|
var stripTrailingHardline$2 = _require$$0$utils.stripTrailingHardline;
|
|
33902
33989
|
var mapDoc$7 = _require$$0$utils.mapDoc;
|
|
33903
|
-
var breakParent$
|
|
33990
|
+
var breakParent$4 = builders.breakParent;
|
|
33904
33991
|
var dedentToRoot$2 = builders.dedentToRoot;
|
|
33905
33992
|
var fill$5 = builders.fill;
|
|
33906
33993
|
var group$14 = builders.group;
|
|
33907
33994
|
var hardline$12 = builders.hardline;
|
|
33908
|
-
var ifBreak$
|
|
33995
|
+
var ifBreak$6 = builders.ifBreak;
|
|
33909
33996
|
var indent$9 = builders.indent;
|
|
33910
33997
|
var join$10 = builders.join;
|
|
33911
33998
|
var line$9 = builders.line;
|
|
@@ -33952,7 +34039,7 @@ function embed$6(path$$1, print, textToDoc, options) {
|
|
|
33952
34039
|
|
|
33953
34040
|
if (parser) {
|
|
33954
34041
|
var value = parser === "markdown" ? dedentString(node.value.replace(/^[^\S\n]*?\n/, "")) : node.value;
|
|
33955
|
-
return builders.concat([concat$14([breakParent$
|
|
34042
|
+
return builders.concat([concat$14([breakParent$4, printOpeningTagPrefix(node, options), stripTrailingHardline$2(textToDoc(value, {
|
|
33956
34043
|
parser
|
|
33957
34044
|
})), printClosingTagSuffix(node, options)])]);
|
|
33958
34045
|
}
|
|
@@ -33982,6 +34069,15 @@ function embed$6(path$$1, print, textToDoc, options) {
|
|
|
33982
34069
|
|
|
33983
34070
|
if (/^PRETTIER_HTML_PLACEHOLDER_\d+_IN_JS$/.test(options.originalText.slice(node.valueSpan.start.offset, node.valueSpan.end.offset))) {
|
|
33984
34071
|
return concat$14([node.rawName, "=", node.value]);
|
|
34072
|
+
} // lwc: html`<my-element data-for={value}></my-elememt>`
|
|
34073
|
+
|
|
34074
|
+
|
|
34075
|
+
if (options.parser === "lwc") {
|
|
34076
|
+
var interpolationRegex = /^\{[\s\S]*\}$/;
|
|
34077
|
+
|
|
34078
|
+
if (interpolationRegex.test(options.originalText.slice(node.valueSpan.start.offset, node.valueSpan.end.offset))) {
|
|
34079
|
+
return concat$14([node.rawName, "=", node.value]);
|
|
34080
|
+
}
|
|
33985
34081
|
}
|
|
33986
34082
|
|
|
33987
34083
|
var embeddedAttributeValueDoc = printEmbeddedAttributeValue(node, function (code, opts) {
|
|
@@ -34043,13 +34139,13 @@ function genericPrint$5(path$$1, options, print) {
|
|
|
34043
34139
|
var attrGroupId = Symbol("element-attr-group-id");
|
|
34044
34140
|
return concat$14([group$14(concat$14([group$14(printOpeningTag(path$$1, options, print), {
|
|
34045
34141
|
id: attrGroupId
|
|
34046
|
-
}), node.children.length === 0 ? node.hasDanglingSpaces && node.isDanglingSpaceSensitive ? line$9 : "" : concat$14([forceBreakContent(node) ? breakParent$
|
|
34047
|
-
return shouldHugContent ? ifBreak$
|
|
34142
|
+
}), node.children.length === 0 ? node.hasDanglingSpaces && node.isDanglingSpaceSensitive ? line$9 : "" : concat$14([forceBreakContent(node) ? breakParent$4 : "", function (childrenDoc) {
|
|
34143
|
+
return shouldHugContent ? ifBreak$6(indent$9(childrenDoc), childrenDoc, {
|
|
34048
34144
|
groupId: attrGroupId
|
|
34049
34145
|
}) : isScriptLikeTag(node) && node.parent.type === "root" && options.parser === "vue" ? childrenDoc : indent$9(childrenDoc);
|
|
34050
|
-
}(concat$14([shouldHugContent ? ifBreak$
|
|
34146
|
+
}(concat$14([shouldHugContent ? ifBreak$6(softline$7, "", {
|
|
34051
34147
|
groupId: attrGroupId
|
|
34052
|
-
}) : node.firstChild.hasLeadingSpaces && node.firstChild.isLeadingSpaceSensitive ? line$9 : node.firstChild.type === "text" && node.isWhitespaceSensitive && node.isIndentationSensitive ? dedentToRoot$2(softline$7) : softline$7, printChildren$1(path$$1, options, print)])), (node.next ? needsToBorrowPrevClosingTagEndMarker(node.next) : needsToBorrowLastChildClosingTagEndMarker(node.parent)) ? node.lastChild.hasTrailingSpaces && node.lastChild.isTrailingSpaceSensitive ? " " : "" : shouldHugContent ? ifBreak$
|
|
34148
|
+
}) : node.firstChild.hasLeadingSpaces && node.firstChild.isLeadingSpaceSensitive ? line$9 : node.firstChild.type === "text" && node.isWhitespaceSensitive && node.isIndentationSensitive ? dedentToRoot$2(softline$7) : softline$7, printChildren$1(path$$1, options, print)])), (node.next ? needsToBorrowPrevClosingTagEndMarker(node.next) : needsToBorrowLastChildClosingTagEndMarker(node.parent)) ? node.lastChild.hasTrailingSpaces && node.lastChild.isTrailingSpaceSensitive ? " " : "" : shouldHugContent ? ifBreak$6(softline$7, "", {
|
|
34053
34149
|
groupId: attrGroupId
|
|
34054
34150
|
}) : node.lastChild.hasTrailingSpaces && node.lastChild.isTrailingSpaceSensitive ? line$9 : (node.lastChild.type === "comment" || node.lastChild.type === "text" && node.isWhitespaceSensitive && node.isIndentationSensitive) && new RegExp(`\\n\\s{${options.tabWidth * countParents(path$$1, function (n) {
|
|
34055
34151
|
return n.parent && n.parent.type !== "root";
|
|
@@ -34120,7 +34216,7 @@ function printChildren$1(path$$1, options, print) {
|
|
|
34120
34216
|
var node = path$$1.getValue();
|
|
34121
34217
|
|
|
34122
34218
|
if (forceBreakChildren(node)) {
|
|
34123
|
-
return concat$14([breakParent$
|
|
34219
|
+
return concat$14([breakParent$4, concat$14(path$$1.map(function (childPath) {
|
|
34124
34220
|
var childNode = childPath.getValue();
|
|
34125
34221
|
var prevBetweenLine = !childNode.prev ? "" : printBetweenLine(childNode.prev, childNode);
|
|
34126
34222
|
return concat$14([!prevBetweenLine ? "" : concat$14([prevBetweenLine, forceNextEmptyLine(childNode.prev) ? hardline$12 : ""]), printChild(childPath)]);
|
|
@@ -34165,7 +34261,7 @@ function printChildren$1(path$$1, options, print) {
|
|
|
34165
34261
|
if (isTextLikeNode(childNode.prev)) {
|
|
34166
34262
|
leadingParts.push(prevBetweenLine);
|
|
34167
34263
|
} else {
|
|
34168
|
-
leadingParts.push(ifBreak$
|
|
34264
|
+
leadingParts.push(ifBreak$6("", softline$7, {
|
|
34169
34265
|
groupId: groupIds[childIndex - 1]
|
|
34170
34266
|
}));
|
|
34171
34267
|
}
|
|
@@ -34762,6 +34858,15 @@ var languages$5 = [createLanguage(require$$0$31, {
|
|
|
34762
34858
|
extensions: [".mjml" // MJML is considered XML in Linguist but it should be formatted as HTML
|
|
34763
34859
|
]
|
|
34764
34860
|
}
|
|
34861
|
+
}), createLanguage(require$$0$31, {
|
|
34862
|
+
override: {
|
|
34863
|
+
name: "Lightning Web Components",
|
|
34864
|
+
since: "1.17.0",
|
|
34865
|
+
parsers: ["lwc"],
|
|
34866
|
+
vscodeLanguageIds: ["html"],
|
|
34867
|
+
extensions: [],
|
|
34868
|
+
filenames: []
|
|
34869
|
+
}
|
|
34765
34870
|
}), createLanguage(require$$1$11, {
|
|
34766
34871
|
override: {
|
|
34767
34872
|
since: "1.10.0",
|
|
@@ -34796,7 +34901,7 @@ var pragma$11 = {
|
|
|
34796
34901
|
insertPragma: insertPragma$9
|
|
34797
34902
|
};
|
|
34798
34903
|
|
|
34799
|
-
var getLast$
|
|
34904
|
+
var getLast$6 = util$1.getLast;
|
|
34800
34905
|
|
|
34801
34906
|
function getAncestorCount$1(path$$1, filter) {
|
|
34802
34907
|
var counter = 0;
|
|
@@ -34885,7 +34990,7 @@ function isLastDescendantNode$1(path$$1) {
|
|
|
34885
34990
|
}
|
|
34886
34991
|
|
|
34887
34992
|
function getLastDescendantNode$2(node) {
|
|
34888
|
-
return "children" in node && node.children.length !== 0 ? getLastDescendantNode$2(getLast$
|
|
34993
|
+
return "children" in node && node.children.length !== 0 ? getLastDescendantNode$2(getLast$6(node.children)) : node;
|
|
34889
34994
|
}
|
|
34890
34995
|
|
|
34891
34996
|
function isPrettierIgnore$2(comment) {
|
|
@@ -34897,10 +35002,10 @@ function hasPrettierIgnore$5(path$$1) {
|
|
|
34897
35002
|
|
|
34898
35003
|
if (node.type === "documentBody") {
|
|
34899
35004
|
var document = path$$1.getParentNode();
|
|
34900
|
-
return hasEndComments$1(document.head) && isPrettierIgnore$2(getLast$
|
|
35005
|
+
return hasEndComments$1(document.head) && isPrettierIgnore$2(getLast$6(document.head.endComments));
|
|
34901
35006
|
}
|
|
34902
35007
|
|
|
34903
|
-
return hasLeadingComments$1(node) && isPrettierIgnore$2(getLast$
|
|
35008
|
+
return hasLeadingComments$1(node) && isPrettierIgnore$2(getLast$6(node.leadingComments));
|
|
34904
35009
|
}
|
|
34905
35010
|
|
|
34906
35011
|
function isEmptyNode$1(node) {
|
|
@@ -35000,7 +35105,7 @@ function getFlowScalarLineContents$1(nodeType, content, options) {
|
|
|
35000
35105
|
return lineContent.length === 0 ? [] : splitWithSingleSpace(lineContent);
|
|
35001
35106
|
}).reduce(function (reduced, lineContentWords, index) {
|
|
35002
35107
|
return index !== 0 && rawLineContents[index - 1].length !== 0 && lineContentWords.length !== 0 && !( // trailing backslash in quoteDouble should be preserved
|
|
35003
|
-
nodeType === "quoteDouble" && getLast$
|
|
35108
|
+
nodeType === "quoteDouble" && getLast$6(getLast$6(reduced)).endsWith("\\")) ? reduced.concat([reduced.pop().concat(lineContentWords)]) : reduced.concat([lineContentWords]);
|
|
35004
35109
|
}, []).map(function (lineContentWords) {
|
|
35005
35110
|
return options.proseWrap === "never" ? [lineContentWords.join(" ")] : lineContentWords;
|
|
35006
35111
|
});
|
|
@@ -35028,11 +35133,11 @@ function getBlockValueLineContents$1(node, _ref) {
|
|
|
35028
35133
|
return removeUnnecessaryTrailingNewlines(rawLineContents.map(function (lineContent) {
|
|
35029
35134
|
return lineContent.length === 0 ? [] : splitWithSingleSpace(lineContent);
|
|
35030
35135
|
}).reduce(function (reduced, lineContentWords, index) {
|
|
35031
|
-
return index !== 0 && rawLineContents[index - 1].length !== 0 && lineContentWords.length !== 0 && !/^\s/.test(lineContentWords[0]) && !/^\s|\s$/.test(getLast$
|
|
35136
|
+
return index !== 0 && rawLineContents[index - 1].length !== 0 && lineContentWords.length !== 0 && !/^\s/.test(lineContentWords[0]) && !/^\s|\s$/.test(getLast$6(reduced)) ? reduced.concat([reduced.pop().concat(lineContentWords)]) : reduced.concat([lineContentWords]);
|
|
35032
35137
|
}, []).map(function (lineContentWords) {
|
|
35033
35138
|
return lineContentWords.reduce(function (reduced, word) {
|
|
35034
35139
|
return (// disallow trailing spaces
|
|
35035
|
-
reduced.length !== 0 && /\s$/.test(getLast$
|
|
35140
|
+
reduced.length !== 0 && /\s$/.test(getLast$6(reduced)) ? reduced.concat(reduced.pop() + " " + word) : reduced.concat(word)
|
|
35036
35141
|
);
|
|
35037
35142
|
}, []);
|
|
35038
35143
|
}).map(function (lineContentWords) {
|
|
@@ -35041,7 +35146,7 @@ function getBlockValueLineContents$1(node, _ref) {
|
|
|
35041
35146
|
|
|
35042
35147
|
function removeUnnecessaryTrailingNewlines(lineContents) {
|
|
35043
35148
|
if (node.chomping === "keep") {
|
|
35044
|
-
return getLast$
|
|
35149
|
+
return getLast$6(lineContents).length === 0 ? lineContents.slice(0, -1) : lineContents;
|
|
35045
35150
|
}
|
|
35046
35151
|
|
|
35047
35152
|
var trailingNewlineCount = 0;
|
|
@@ -35060,7 +35165,7 @@ function getBlockValueLineContents$1(node, _ref) {
|
|
|
35060
35165
|
}
|
|
35061
35166
|
|
|
35062
35167
|
var utils$12 = {
|
|
35063
|
-
getLast: getLast$
|
|
35168
|
+
getLast: getLast$6,
|
|
35064
35169
|
getAncestorCount: getAncestorCount$1,
|
|
35065
35170
|
isNode: isNode$2,
|
|
35066
35171
|
isEmptyNode: isEmptyNode$1,
|
|
@@ -35084,7 +35189,7 @@ var isPragma = pragma$11.isPragma;
|
|
|
35084
35189
|
var getAncestorCount = utils$12.getAncestorCount;
|
|
35085
35190
|
var getBlockValueLineContents = utils$12.getBlockValueLineContents;
|
|
35086
35191
|
var getFlowScalarLineContents = utils$12.getFlowScalarLineContents;
|
|
35087
|
-
var getLast$
|
|
35192
|
+
var getLast$5 = utils$12.getLast;
|
|
35088
35193
|
var getLastDescendantNode$1 = utils$12.getLastDescendantNode;
|
|
35089
35194
|
var hasLeadingComments = utils$12.hasLeadingComments;
|
|
35090
35195
|
var hasMiddleComments = utils$12.hasMiddleComments;
|
|
@@ -35100,14 +35205,14 @@ var defineShortcut = utils$12.defineShortcut;
|
|
|
35100
35205
|
var mapNode = utils$12.mapNode;
|
|
35101
35206
|
var docBuilders$3 = doc.builders;
|
|
35102
35207
|
var conditionalGroup$2 = docBuilders$3.conditionalGroup;
|
|
35103
|
-
var breakParent$
|
|
35208
|
+
var breakParent$5 = docBuilders$3.breakParent;
|
|
35104
35209
|
var concat$17 = docBuilders$3.concat;
|
|
35105
35210
|
var dedent$4 = docBuilders$3.dedent;
|
|
35106
35211
|
var dedentToRoot$3 = docBuilders$3.dedentToRoot;
|
|
35107
35212
|
var fill$6 = docBuilders$3.fill;
|
|
35108
35213
|
var group$16 = docBuilders$3.group;
|
|
35109
35214
|
var hardline$13 = docBuilders$3.hardline;
|
|
35110
|
-
var ifBreak$
|
|
35215
|
+
var ifBreak$8 = docBuilders$3.ifBreak;
|
|
35111
35216
|
var join$12 = docBuilders$3.join;
|
|
35112
35217
|
var line$11 = docBuilders$3.line;
|
|
35113
35218
|
var lineSuffix$2 = docBuilders$3.lineSuffix;
|
|
@@ -35161,7 +35266,7 @@ function genericPrint$6(path$$1, options, print) {
|
|
|
35161
35266
|
var tag = !node.tag ? "" : path$$1.call(print, "tag");
|
|
35162
35267
|
var anchor = !node.anchor ? "" : path$$1.call(print, "anchor");
|
|
35163
35268
|
var nextEmptyLine = isNode$1(node, ["mapping", "sequence", "comment", "directive", "mappingItem", "sequenceItem"]) && !isLastDescendantNode(path$$1) ? printNextEmptyLine(path$$1, options.originalText) : "";
|
|
35164
|
-
return concat$17([node.type !== "mappingValue" && hasLeadingComments(node) ? concat$17([join$12(hardline$13, path$$1.map(print, "leadingComments")), hardline$13]) : "", tag, tag && anchor ? " " : "", anchor, tag || anchor ? isNode$1(node, ["sequence", "mapping"]) && !hasMiddleComments(node) ? hardline$13 : " " : "", hasMiddleComments(node) ? concat$17([node.middleComments.length === 1 ? "" : hardline$13, join$12(hardline$13, path$$1.map(print, "middleComments")), hardline$13]) : "", hasPrettierIgnore$4(path$$1) ? concat$17(replaceEndOfLineWith$3(options.originalText.slice(node.position.start.offset, node.position.end.offset), literalline$7)) : group$16(_print(node, parentNode, path$$1, options, print)), hasTrailingComment$1(node) && !isNode$1(node, ["document", "documentHead"]) ? lineSuffix$2(concat$17([node.type === "mappingValue" && !node.content ? "" : " ", parentNode.type === "mappingKey" && path$$1.getParentNode(2).type === "mapping" && isInlineNode(node) ? "" : breakParent$
|
|
35269
|
+
return concat$17([node.type !== "mappingValue" && hasLeadingComments(node) ? concat$17([join$12(hardline$13, path$$1.map(print, "leadingComments")), hardline$13]) : "", tag, tag && anchor ? " " : "", anchor, tag || anchor ? isNode$1(node, ["sequence", "mapping"]) && !hasMiddleComments(node) ? hardline$13 : " " : "", hasMiddleComments(node) ? concat$17([node.middleComments.length === 1 ? "" : hardline$13, join$12(hardline$13, path$$1.map(print, "middleComments")), hardline$13]) : "", hasPrettierIgnore$4(path$$1) ? concat$17(replaceEndOfLineWith$3(options.originalText.slice(node.position.start.offset, node.position.end.offset), literalline$7)) : group$16(_print(node, parentNode, path$$1, options, print)), hasTrailingComment$1(node) && !isNode$1(node, ["document", "documentHead"]) ? lineSuffix$2(concat$17([node.type === "mappingValue" && !node.content ? "" : " ", parentNode.type === "mappingKey" && path$$1.getParentNode(2).type === "mapping" && isInlineNode(node) ? "" : breakParent$5, path$$1.call(print, "trailingComment")])) : "", nextEmptyLine, hasEndComments(node) && !isNode$1(node, ["documentHead", "documentBody"]) ? align$3(node.type === "sequenceItem" ? 2 : 0, concat$17([hardline$13, join$12(hardline$13, path$$1.map(print, "endComments"))])) : ""]);
|
|
35165
35270
|
}
|
|
35166
35271
|
|
|
35167
35272
|
function _print(node, parentNode, path$$1, options, print) {
|
|
@@ -35297,9 +35402,9 @@ function _print(node, parentNode, path$$1, options, print) {
|
|
|
35297
35402
|
return forceExplicitKey ? concat$17(["? ", align$3(2, key), hardline$13, join$12("", path$$1.map(print, "value", "leadingComments").map(function (comment) {
|
|
35298
35403
|
return concat$17([comment, hardline$13]);
|
|
35299
35404
|
})), ": ", align$3(2, value)]) : // force singleline
|
|
35300
|
-
isSingleLineNode(node.key.content) && !hasLeadingComments(node.key.content) && !hasMiddleComments(node.key.content) && !hasTrailingComment$1(node.key.content) && !hasEndComments(node.key) && !hasLeadingComments(node.value.content) && !hasMiddleComments(node.value.content) && !hasEndComments(node.value) && isAbsolutelyPrintedAsSingleLineNode(node.value.content, options) ? concat$17([key, needsSpaceInFrontOfMappingValue(node) ? " " : "", ": ", value]) : conditionalGroup$2([concat$17([group$16(concat$17([ifBreak$
|
|
35405
|
+
isSingleLineNode(node.key.content) && !hasLeadingComments(node.key.content) && !hasMiddleComments(node.key.content) && !hasTrailingComment$1(node.key.content) && !hasEndComments(node.key) && !hasLeadingComments(node.value.content) && !hasMiddleComments(node.value.content) && !hasEndComments(node.value) && isAbsolutelyPrintedAsSingleLineNode(node.value.content, options) ? concat$17([key, needsSpaceInFrontOfMappingValue(node) ? " " : "", ": ", value]) : conditionalGroup$2([concat$17([group$16(concat$17([ifBreak$8("? "), group$16(align$3(2, key), {
|
|
35301
35406
|
id: groupId
|
|
35302
|
-
})])), ifBreak$
|
|
35407
|
+
})])), ifBreak$8(concat$17([hardline$13, ": ", align$3(2, value)]), indent(concat$17([needsSpaceInFrontOfMappingValue(node) ? " " : "", ":", hasLeadingComments(node.value.content) || hasEndComments(node.value) && node.value.content && !isNode$1(node.value.content, ["mapping", "sequence"]) || parentNode.type === "mapping" && hasTrailingComment$1(node.key.content) && isInlineNode(node.value.content) || isNode$1(node.value.content, ["mapping", "sequence"]) && node.value.content.tag === null && node.value.content.anchor === null ? hardline$13 : !node.value.content ? "" : line$11, value])), {
|
|
35303
35408
|
groupId
|
|
35304
35409
|
})])]);
|
|
35305
35410
|
}
|
|
@@ -35313,11 +35418,11 @@ function _print(node, parentNode, path$$1, options, print) {
|
|
|
35313
35418
|
|
|
35314
35419
|
var isLastItemEmptyMappingItem = node.children.length !== 0 && function (lastItem) {
|
|
35315
35420
|
return lastItem.type === "flowMappingItem" && isEmptyNode(lastItem.key) && isEmptyNode(lastItem.value);
|
|
35316
|
-
}(getLast$
|
|
35421
|
+
}(getLast$5(node.children));
|
|
35317
35422
|
|
|
35318
35423
|
return concat$17([openMarker, indent(concat$17([bracketSpacing, concat$17(path$$1.map(function (childPath, index) {
|
|
35319
35424
|
return concat$17([print(childPath), index === node.children.length - 1 ? "" : concat$17([",", line$11, node.children[index].position.start.line !== node.children[index + 1].position.start.line ? printNextEmptyLine(childPath, options.originalText) : ""])]);
|
|
35320
|
-
}, "children")), ifBreak$
|
|
35425
|
+
}, "children")), ifBreak$8(",", "")])), isLastItemEmptyMappingItem ? "" : bracketSpacing, closeMarker]);
|
|
35321
35426
|
}
|
|
35322
35427
|
|
|
35323
35428
|
case "flowSequenceItem":
|
|
@@ -35735,6 +35840,11 @@ languageMarkdown, {
|
|
|
35735
35840
|
// Angular
|
|
35736
35841
|
get angular() {
|
|
35737
35842
|
return require("./parser-html").parsers.angular;
|
|
35843
|
+
},
|
|
35844
|
+
|
|
35845
|
+
// Lightning Web Components
|
|
35846
|
+
get lwc() {
|
|
35847
|
+
return require("./parser-html").parsers.lwc;
|
|
35738
35848
|
}
|
|
35739
35849
|
|
|
35740
35850
|
}
|
|
@@ -35808,12 +35918,14 @@ function loadPlugins(plugins, pluginSearchDirs) {
|
|
|
35808
35918
|
});
|
|
35809
35919
|
var externalAutoLoadPluginInfos = pluginSearchDirs.map(function (pluginSearchDir) {
|
|
35810
35920
|
var resolvedPluginSearchDir = path.resolve(process.cwd(), pluginSearchDir);
|
|
35921
|
+
var nodeModulesDir = path.resolve(resolvedPluginSearchDir, "node_modules"); // In some fringe cases (ex: files "mounted" as virtual directories), the
|
|
35922
|
+
// isDirectory(resolvedPluginSearchDir) check might be false even though
|
|
35923
|
+
// the node_modules actually exists.
|
|
35811
35924
|
|
|
35812
|
-
if (!isDirectory(resolvedPluginSearchDir)) {
|
|
35925
|
+
if (!isDirectory(nodeModulesDir) && !isDirectory(resolvedPluginSearchDir)) {
|
|
35813
35926
|
throw new Error(`${pluginSearchDir} does not exist or is not a directory`);
|
|
35814
35927
|
}
|
|
35815
35928
|
|
|
35816
|
-
var nodeModulesDir = path.resolve(resolvedPluginSearchDir, "node_modules");
|
|
35817
35929
|
return findPluginsInNodeModules(nodeModulesDir).map(function (pluginName) {
|
|
35818
35930
|
return {
|
|
35819
35931
|
name: pluginName,
|
|
@@ -35834,7 +35946,7 @@ function loadPlugins(plugins, pluginSearchDirs) {
|
|
|
35834
35946
|
}
|
|
35835
35947
|
|
|
35836
35948
|
function findPluginsInNodeModules(nodeModulesDir) {
|
|
35837
|
-
var pluginPackageJsonPaths = globby.sync(["prettier-plugin-*/package.json", "@prettier/plugin-*/package.json"], {
|
|
35949
|
+
var pluginPackageJsonPaths = globby.sync(["prettier-plugin-*/package.json", "@*/prettier-plugin-*/package.json", "@prettier/plugin-*/package.json"], {
|
|
35838
35950
|
cwd: nodeModulesDir
|
|
35839
35951
|
});
|
|
35840
35952
|
return pluginPackageJsonPaths.map(path.dirname);
|
|
@@ -42220,6 +42332,13 @@ var resolveConfig_1 = createCommonjsModule(function (module) {
|
|
|
42220
42332
|
cache: opts.cache,
|
|
42221
42333
|
transform: function transform(result) {
|
|
42222
42334
|
if (result && result.config) {
|
|
42335
|
+
if (typeof result.config === "string") {
|
|
42336
|
+
var modulePath = resolve$1.sync(result.config, {
|
|
42337
|
+
basedir: path.dirname(result.filepath)
|
|
42338
|
+
});
|
|
42339
|
+
result.config = require(modulePath);
|
|
42340
|
+
}
|
|
42341
|
+
|
|
42223
42342
|
if (typeof result.config !== "object") {
|
|
42224
42343
|
throw new Error(`Config is only allowed to be an object, ` + `but received ${typeof result.config} in "${result.filepath}"`);
|
|
42225
42344
|
}
|