prettier 3.0.0 → 3.0.2
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/LICENSE +43 -98
- package/README.md +2 -2
- package/doc.d.ts +7 -7
- package/index.cjs +1 -1
- package/index.d.ts +54 -48
- package/index.mjs +8260 -8597
- package/internal/cli.mjs +27 -5
- package/internal/internal.mjs +61 -37
- package/package.json +1 -1
- package/plugins/acorn.js +11 -11
- package/plugins/acorn.mjs +11 -11
- package/plugins/angular.js +2 -2
- package/plugins/angular.mjs +2 -2
- package/plugins/babel.js +11 -11
- package/plugins/babel.mjs +11 -11
- package/plugins/estree.d.ts +1 -0
- package/plugins/estree.js +23 -23
- package/plugins/estree.mjs +23 -23
- package/plugins/flow.js +17 -17
- package/plugins/flow.mjs +17 -17
- package/plugins/glimmer.js +13 -13
- package/plugins/glimmer.mjs +14 -14
- package/plugins/graphql.js +9 -9
- package/plugins/graphql.mjs +9 -9
- package/plugins/html.js +15 -15
- package/plugins/html.mjs +15 -15
- package/plugins/markdown.js +38 -38
- package/plugins/markdown.mjs +38 -38
- package/plugins/meriyah.js +5 -5
- package/plugins/meriyah.mjs +5 -5
- package/plugins/postcss.js +28 -28
- package/plugins/postcss.mjs +29 -29
- package/plugins/typescript.js +20 -22
- package/plugins/typescript.mjs +20 -22
- package/plugins/yaml.js +38 -38
- package/plugins/yaml.mjs +39 -39
- package/standalone.d.ts +1 -1
- package/standalone.js +30 -27
- package/standalone.mjs +30 -27
package/internal/cli.mjs
CHANGED
|
@@ -4777,7 +4777,7 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
|
4777
4777
|
return 1;
|
|
4778
4778
|
}
|
|
4779
4779
|
if ("CI" in env) {
|
|
4780
|
-
if ("GITHUB_ACTIONS" in env) {
|
|
4780
|
+
if ("GITHUB_ACTIONS" in env || "GITEA_ACTIONS" in env) {
|
|
4781
4781
|
return 3;
|
|
4782
4782
|
}
|
|
4783
4783
|
if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
|
|
@@ -5006,7 +5006,7 @@ var chalk = createChalk();
|
|
|
5006
5006
|
var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
5007
5007
|
var source_default = chalk;
|
|
5008
5008
|
|
|
5009
|
-
// node_modules/
|
|
5009
|
+
// node_modules/ansi-regex/index.js
|
|
5010
5010
|
function ansiRegex({ onlyFirst = false } = {}) {
|
|
5011
5011
|
const pattern = [
|
|
5012
5012
|
"[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
|
|
@@ -5404,12 +5404,30 @@ var preserveCamelCase = (string, toLowerCase, toUpperCase, preserveConsecutiveUp
|
|
|
5404
5404
|
};
|
|
5405
5405
|
var preserveConsecutiveUppercase = (input, toLowerCase) => {
|
|
5406
5406
|
LEADING_CAPITAL.lastIndex = 0;
|
|
5407
|
-
return
|
|
5407
|
+
return string_replace_all_default(
|
|
5408
|
+
/* isOptionalObject*/
|
|
5409
|
+
false,
|
|
5410
|
+
input,
|
|
5411
|
+
LEADING_CAPITAL,
|
|
5412
|
+
(match) => toLowerCase(match)
|
|
5413
|
+
);
|
|
5408
5414
|
};
|
|
5409
5415
|
var postProcess = (input, toUpperCase) => {
|
|
5410
5416
|
SEPARATORS_AND_IDENTIFIER.lastIndex = 0;
|
|
5411
5417
|
NUMBERS_AND_IDENTIFIER.lastIndex = 0;
|
|
5412
|
-
return
|
|
5418
|
+
return string_replace_all_default(
|
|
5419
|
+
/* isOptionalObject*/
|
|
5420
|
+
false,
|
|
5421
|
+
string_replace_all_default(
|
|
5422
|
+
/* isOptionalObject*/
|
|
5423
|
+
false,
|
|
5424
|
+
input,
|
|
5425
|
+
NUMBERS_AND_IDENTIFIER,
|
|
5426
|
+
(match, pattern, offset) => ["_", "-"].includes(input.charAt(offset + match.length)) ? match : toUpperCase(match)
|
|
5427
|
+
),
|
|
5428
|
+
SEPARATORS_AND_IDENTIFIER,
|
|
5429
|
+
(_, identifier) => toUpperCase(identifier)
|
|
5430
|
+
);
|
|
5413
5431
|
};
|
|
5414
5432
|
function camelCase(input, options) {
|
|
5415
5433
|
if (!(typeof input === "string" || Array.isArray(input))) {
|
|
@@ -6646,7 +6664,11 @@ async function format2(context, input, opt) {
|
|
|
6646
6664
|
ms: averageMs
|
|
6647
6665
|
};
|
|
6648
6666
|
context.logger.debug(
|
|
6649
|
-
`'${performanceTestFlag.name}' measurements for formatWithCursor: ${JSON.stringify(
|
|
6667
|
+
`'${performanceTestFlag.name}' measurements for formatWithCursor: ${JSON.stringify(
|
|
6668
|
+
results,
|
|
6669
|
+
null,
|
|
6670
|
+
2
|
|
6671
|
+
)}`
|
|
6650
6672
|
);
|
|
6651
6673
|
}
|
|
6652
6674
|
return prettier.formatWithCursor(input, opt);
|
package/internal/internal.mjs
CHANGED
|
@@ -673,9 +673,9 @@ var require_lib = __commonJS({
|
|
|
673
673
|
}
|
|
674
674
|
});
|
|
675
675
|
|
|
676
|
-
// node_modules/@babel/
|
|
676
|
+
// node_modules/@babel/code-frame/node_modules/escape-string-regexp/index.js
|
|
677
677
|
var require_escape_string_regexp = __commonJS({
|
|
678
|
-
"node_modules/@babel/
|
|
678
|
+
"node_modules/@babel/code-frame/node_modules/escape-string-regexp/index.js"(exports, module) {
|
|
679
679
|
"use strict";
|
|
680
680
|
var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
|
|
681
681
|
module.exports = function(str) {
|
|
@@ -1829,9 +1829,9 @@ var require_ansi_styles = __commonJS({
|
|
|
1829
1829
|
}
|
|
1830
1830
|
});
|
|
1831
1831
|
|
|
1832
|
-
// node_modules/@babel/
|
|
1832
|
+
// node_modules/@babel/code-frame/node_modules/has-flag/index.js
|
|
1833
1833
|
var require_has_flag = __commonJS({
|
|
1834
|
-
"node_modules/@babel/
|
|
1834
|
+
"node_modules/@babel/code-frame/node_modules/has-flag/index.js"(exports, module) {
|
|
1835
1835
|
"use strict";
|
|
1836
1836
|
module.exports = (flag, argv) => {
|
|
1837
1837
|
argv = argv || process.argv;
|
|
@@ -1843,9 +1843,9 @@ var require_has_flag = __commonJS({
|
|
|
1843
1843
|
}
|
|
1844
1844
|
});
|
|
1845
1845
|
|
|
1846
|
-
// node_modules/@babel/
|
|
1846
|
+
// node_modules/@babel/code-frame/node_modules/supports-color/index.js
|
|
1847
1847
|
var require_supports_color = __commonJS({
|
|
1848
|
-
"node_modules/@babel/
|
|
1848
|
+
"node_modules/@babel/code-frame/node_modules/supports-color/index.js"(exports, module) {
|
|
1849
1849
|
"use strict";
|
|
1850
1850
|
var os = __require("os");
|
|
1851
1851
|
var hasFlag = require_has_flag();
|
|
@@ -1938,9 +1938,9 @@ var require_supports_color = __commonJS({
|
|
|
1938
1938
|
}
|
|
1939
1939
|
});
|
|
1940
1940
|
|
|
1941
|
-
// node_modules/@babel/
|
|
1941
|
+
// node_modules/@babel/code-frame/node_modules/chalk/templates.js
|
|
1942
1942
|
var require_templates = __commonJS({
|
|
1943
|
-
"node_modules/@babel/
|
|
1943
|
+
"node_modules/@babel/code-frame/node_modules/chalk/templates.js"(exports, module) {
|
|
1944
1944
|
"use strict";
|
|
1945
1945
|
var TEMPLATE_REGEX = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
|
|
1946
1946
|
var STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
|
|
@@ -2049,9 +2049,9 @@ var require_templates = __commonJS({
|
|
|
2049
2049
|
}
|
|
2050
2050
|
});
|
|
2051
2051
|
|
|
2052
|
-
// node_modules/@babel/
|
|
2052
|
+
// node_modules/@babel/code-frame/node_modules/chalk/index.js
|
|
2053
2053
|
var require_chalk = __commonJS({
|
|
2054
|
-
"node_modules/@babel/
|
|
2054
|
+
"node_modules/@babel/code-frame/node_modules/chalk/index.js"(exports, module) {
|
|
2055
2055
|
"use strict";
|
|
2056
2056
|
var escapeStringRegexp = require_escape_string_regexp();
|
|
2057
2057
|
var ansiStyles = require_ansi_styles();
|
|
@@ -2224,23 +2224,23 @@ var require_lib2 = __commonJS({
|
|
|
2224
2224
|
value: true
|
|
2225
2225
|
});
|
|
2226
2226
|
exports.default = highlight;
|
|
2227
|
-
exports.getChalk = getChalk;
|
|
2228
2227
|
exports.shouldHighlight = shouldHighlight;
|
|
2229
2228
|
var _jsTokens = require_js_tokens();
|
|
2230
2229
|
var _helperValidatorIdentifier = require_lib();
|
|
2231
|
-
var
|
|
2230
|
+
var _chalk2 = require_chalk();
|
|
2231
|
+
var chalk = _chalk2;
|
|
2232
2232
|
var sometimesKeywords = /* @__PURE__ */ new Set(["as", "async", "from", "get", "of", "set"]);
|
|
2233
|
-
function getDefs(
|
|
2233
|
+
function getDefs(chalk2) {
|
|
2234
2234
|
return {
|
|
2235
|
-
keyword:
|
|
2236
|
-
capitalized:
|
|
2237
|
-
jsxIdentifier:
|
|
2238
|
-
punctuator:
|
|
2239
|
-
number:
|
|
2240
|
-
string:
|
|
2241
|
-
regex:
|
|
2242
|
-
comment:
|
|
2243
|
-
invalid:
|
|
2235
|
+
keyword: chalk2.cyan,
|
|
2236
|
+
capitalized: chalk2.yellow,
|
|
2237
|
+
jsxIdentifier: chalk2.yellow,
|
|
2238
|
+
punctuator: chalk2.yellow,
|
|
2239
|
+
number: chalk2.magenta,
|
|
2240
|
+
string: chalk2.green,
|
|
2241
|
+
regex: chalk2.magenta,
|
|
2242
|
+
comment: chalk2.grey,
|
|
2243
|
+
invalid: chalk2.white.bgRed.bold
|
|
2244
2244
|
};
|
|
2245
2245
|
}
|
|
2246
2246
|
var NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
|
|
@@ -2295,18 +2295,28 @@ var require_lib2 = __commonJS({
|
|
|
2295
2295
|
return highlighted;
|
|
2296
2296
|
}
|
|
2297
2297
|
function shouldHighlight(options) {
|
|
2298
|
-
return !!
|
|
2298
|
+
return !!chalk.supportsColor || options.forceColor;
|
|
2299
|
+
}
|
|
2300
|
+
var chalkWithForcedColor = void 0;
|
|
2301
|
+
function getChalk(forceColor) {
|
|
2302
|
+
if (forceColor) {
|
|
2303
|
+
var _chalkWithForcedColor;
|
|
2304
|
+
(_chalkWithForcedColor = chalkWithForcedColor) != null ? _chalkWithForcedColor : chalkWithForcedColor = new chalk.constructor({
|
|
2305
|
+
enabled: true,
|
|
2306
|
+
level: 1
|
|
2307
|
+
});
|
|
2308
|
+
return chalkWithForcedColor;
|
|
2309
|
+
}
|
|
2310
|
+
return chalk;
|
|
2299
2311
|
}
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
}) : _chalk;
|
|
2312
|
+
{
|
|
2313
|
+
{
|
|
2314
|
+
exports.getChalk = (options) => getChalk(options.forceColor);
|
|
2315
|
+
}
|
|
2305
2316
|
}
|
|
2306
2317
|
function highlight(code, options = {}) {
|
|
2307
2318
|
if (code !== "" && shouldHighlight(options)) {
|
|
2308
|
-
const
|
|
2309
|
-
const defs = getDefs(chalk);
|
|
2319
|
+
const defs = getDefs(getChalk(options.forceColor));
|
|
2310
2320
|
return highlightTokens(defs, code);
|
|
2311
2321
|
} else {
|
|
2312
2322
|
return code;
|
|
@@ -2325,12 +2335,26 @@ var require_lib3 = __commonJS({
|
|
|
2325
2335
|
exports.codeFrameColumns = codeFrameColumns;
|
|
2326
2336
|
exports.default = _default;
|
|
2327
2337
|
var _highlight = require_lib2();
|
|
2338
|
+
var _chalk2 = require_chalk();
|
|
2339
|
+
var chalk = _chalk2;
|
|
2340
|
+
var chalkWithForcedColor = void 0;
|
|
2341
|
+
function getChalk(forceColor) {
|
|
2342
|
+
if (forceColor) {
|
|
2343
|
+
var _chalkWithForcedColor;
|
|
2344
|
+
(_chalkWithForcedColor = chalkWithForcedColor) != null ? _chalkWithForcedColor : chalkWithForcedColor = new chalk.constructor({
|
|
2345
|
+
enabled: true,
|
|
2346
|
+
level: 1
|
|
2347
|
+
});
|
|
2348
|
+
return chalkWithForcedColor;
|
|
2349
|
+
}
|
|
2350
|
+
return chalk;
|
|
2351
|
+
}
|
|
2328
2352
|
var deprecationWarningShown = false;
|
|
2329
|
-
function getDefs(
|
|
2353
|
+
function getDefs(chalk2) {
|
|
2330
2354
|
return {
|
|
2331
|
-
gutter:
|
|
2332
|
-
marker:
|
|
2333
|
-
message:
|
|
2355
|
+
gutter: chalk2.grey,
|
|
2356
|
+
marker: chalk2.red.bold,
|
|
2357
|
+
message: chalk2.red.bold
|
|
2334
2358
|
};
|
|
2335
2359
|
}
|
|
2336
2360
|
var NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
|
|
@@ -2392,8 +2416,8 @@ var require_lib3 = __commonJS({
|
|
|
2392
2416
|
}
|
|
2393
2417
|
function codeFrameColumns(rawLines, loc, opts = {}) {
|
|
2394
2418
|
const highlighted = (opts.highlightCode || opts.forceColor) && (0, _highlight.shouldHighlight)(opts);
|
|
2395
|
-
const
|
|
2396
|
-
const defs = getDefs(
|
|
2419
|
+
const chalk2 = getChalk(opts.forceColor);
|
|
2420
|
+
const defs = getDefs(chalk2);
|
|
2397
2421
|
const maybeHighlight = (chalkFn, string) => {
|
|
2398
2422
|
return highlighted ? chalkFn(string) : string;
|
|
2399
2423
|
};
|
|
@@ -2432,7 +2456,7 @@ var require_lib3 = __commonJS({
|
|
|
2432
2456
|
${frame}`;
|
|
2433
2457
|
}
|
|
2434
2458
|
if (highlighted) {
|
|
2435
|
-
return
|
|
2459
|
+
return chalk2.reset(frame);
|
|
2436
2460
|
} else {
|
|
2437
2461
|
return frame;
|
|
2438
2462
|
}
|