prettier 3.0.0-alpha.9-for-vscode → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +66 -149
- package/README.md +2 -2
- package/bin/prettier.cjs +0 -0
- package/doc.d.ts +7 -7
- package/doc.js +35 -86
- package/doc.mjs +48 -94
- package/index.cjs +440 -20576
- package/index.d.ts +55 -55
- package/index.mjs +7272 -6575
- package/internal/cli.mjs +52 -45
- package/internal/internal.mjs +171 -77
- package/package.json +4 -7
- package/plugins/acorn.js +12 -12
- package/plugins/acorn.mjs +12 -12
- package/plugins/angular.d.ts +1 -1
- package/plugins/angular.js +2 -2
- package/plugins/angular.mjs +2 -2
- package/plugins/babel.js +12 -12
- package/plugins/babel.mjs +12 -12
- package/plugins/estree.d.ts +1 -0
- package/plugins/estree.js +30 -30
- package/plugins/estree.mjs +30 -30
- package/plugins/flow.js +17 -17
- package/plugins/flow.mjs +17 -17
- package/plugins/glimmer.js +22 -22
- package/plugins/glimmer.mjs +22 -22
- package/plugins/graphql.js +26 -15
- package/plugins/graphql.mjs +26 -15
- package/plugins/html.d.ts +2 -2
- package/plugins/html.js +16 -16
- package/plugins/html.mjs +16 -16
- package/plugins/markdown.d.ts +1 -1
- package/plugins/markdown.js +49 -49
- package/plugins/markdown.mjs +49 -49
- package/plugins/meriyah.js +5 -5
- package/plugins/meriyah.mjs +5 -5
- package/plugins/postcss.js +46 -46
- package/plugins/postcss.mjs +46 -46
- package/plugins/typescript.js +20 -22
- package/plugins/typescript.mjs +20 -22
- package/plugins/yaml.js +104 -104
- package/plugins/yaml.mjs +104 -104
- package/standalone.d.ts +1 -1
- package/standalone.js +31 -30
- package/standalone.mjs +31 -30
- package/internal/internal.cjs +0 -6430
package/internal/cli.mjs
CHANGED
|
@@ -16,7 +16,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
16
16
|
}) : x)(function(x) {
|
|
17
17
|
if (typeof require !== "undefined")
|
|
18
18
|
return require.apply(this, arguments);
|
|
19
|
-
throw
|
|
19
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
20
20
|
});
|
|
21
21
|
var __commonJS = (cb, mod) => function __require2() {
|
|
22
22
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
@@ -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)",
|
|
@@ -5016,11 +5016,12 @@ function ansiRegex({ onlyFirst = false } = {}) {
|
|
|
5016
5016
|
}
|
|
5017
5017
|
|
|
5018
5018
|
// node_modules/strip-ansi/index.js
|
|
5019
|
+
var regex = ansiRegex();
|
|
5019
5020
|
function stripAnsi(string) {
|
|
5020
5021
|
if (typeof string !== "string") {
|
|
5021
5022
|
throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
|
|
5022
5023
|
}
|
|
5023
|
-
return string.replace(
|
|
5024
|
+
return string.replace(regex, "");
|
|
5024
5025
|
}
|
|
5025
5026
|
|
|
5026
5027
|
// src/cli/logger.js
|
|
@@ -5251,6 +5252,7 @@ var cli_options_evaluate_default = {
|
|
|
5251
5252
|
"default": [
|
|
5252
5253
|
{
|
|
5253
5254
|
"value": [
|
|
5255
|
+
".gitignore",
|
|
5254
5256
|
".prettierignore"
|
|
5255
5257
|
]
|
|
5256
5258
|
}
|
|
@@ -5281,10 +5283,6 @@ var cli_options_evaluate_default = {
|
|
|
5281
5283
|
"description": "What level of logs to report.",
|
|
5282
5284
|
"type": "choice"
|
|
5283
5285
|
},
|
|
5284
|
-
"pluginSearch": {
|
|
5285
|
-
"oppositeDescription": "Disable plugin autoloading.",
|
|
5286
|
-
"type": "boolean"
|
|
5287
|
-
},
|
|
5288
5286
|
"supportInfo": {
|
|
5289
5287
|
"description": "Print support information as JSON.",
|
|
5290
5288
|
"type": "boolean"
|
|
@@ -5356,11 +5354,10 @@ function supportInfoToContextOptions({ options: supportOptions, languages }) {
|
|
|
5356
5354
|
detailedOptions
|
|
5357
5355
|
};
|
|
5358
5356
|
}
|
|
5359
|
-
async function getContextOptions(plugins
|
|
5357
|
+
async function getContextOptions(plugins) {
|
|
5360
5358
|
const supportInfo = await getSupportInfo({
|
|
5361
5359
|
showDeprecated: true,
|
|
5362
|
-
plugins
|
|
5363
|
-
pluginSearchDirs
|
|
5360
|
+
plugins
|
|
5364
5361
|
});
|
|
5365
5362
|
return supportInfoToContextOptions(supportInfo);
|
|
5366
5363
|
}
|
|
@@ -5495,6 +5492,15 @@ async function statSafe(filePath) {
|
|
|
5495
5492
|
}
|
|
5496
5493
|
}
|
|
5497
5494
|
}
|
|
5495
|
+
async function lstatSafe(filePath) {
|
|
5496
|
+
try {
|
|
5497
|
+
return await fs.lstat(filePath);
|
|
5498
|
+
} catch (error) {
|
|
5499
|
+
if (error.code !== "ENOENT") {
|
|
5500
|
+
throw error;
|
|
5501
|
+
}
|
|
5502
|
+
}
|
|
5503
|
+
}
|
|
5498
5504
|
function isJson(value) {
|
|
5499
5505
|
try {
|
|
5500
5506
|
JSON.parse(value);
|
|
@@ -5547,7 +5553,7 @@ function createMinimistOptions(detailedOptions) {
|
|
|
5547
5553
|
if (alias) {
|
|
5548
5554
|
names.push(alias);
|
|
5549
5555
|
}
|
|
5550
|
-
if (!option.deprecated && (!option.forwardToApi || name === "plugin"
|
|
5556
|
+
if (!option.deprecated && (!option.forwardToApi || name === "plugin") && option.default !== void 0) {
|
|
5551
5557
|
defaultValues[option.name] = option.default;
|
|
5552
5558
|
}
|
|
5553
5559
|
}
|
|
@@ -5659,9 +5665,6 @@ function parseArgv(rawArguments, detailedOptions, logger, keys) {
|
|
|
5659
5665
|
const minimistOptions = createMinimistOptions(detailedOptions);
|
|
5660
5666
|
let argv = minimistParse(rawArguments, minimistOptions);
|
|
5661
5667
|
if (keys) {
|
|
5662
|
-
if (keys.includes("plugin-search-dir") && !keys.includes("plugin-search")) {
|
|
5663
|
-
keys.push("plugin-search");
|
|
5664
|
-
}
|
|
5665
5668
|
detailedOptions = detailedOptions.filter(
|
|
5666
5669
|
(option) => keys.includes(option.name)
|
|
5667
5670
|
);
|
|
@@ -5708,20 +5711,18 @@ var Context = class {
|
|
|
5708
5711
|
logger
|
|
5709
5712
|
} = this;
|
|
5710
5713
|
const {
|
|
5711
|
-
plugins
|
|
5712
|
-
|
|
5713
|
-
|
|
5714
|
-
await this.pushContextPlugins(plugins, pluginSearchDirs);
|
|
5714
|
+
plugins
|
|
5715
|
+
} = parseArgvWithoutPlugins(rawArguments, logger, ["plugin"]);
|
|
5716
|
+
await this.pushContextPlugins(plugins);
|
|
5715
5717
|
const argv = parseArgv(rawArguments, this.detailedOptions, logger);
|
|
5716
5718
|
this.argv = argv;
|
|
5717
5719
|
this.filePatterns = argv._;
|
|
5718
5720
|
}
|
|
5719
5721
|
/**
|
|
5720
5722
|
* @param {string[]} plugins
|
|
5721
|
-
* @param {string[]=} pluginSearchDirs
|
|
5722
5723
|
*/
|
|
5723
|
-
async pushContextPlugins(plugins
|
|
5724
|
-
const options = await getContextOptions(plugins
|
|
5724
|
+
async pushContextPlugins(plugins) {
|
|
5725
|
+
const options = await getContextOptions(plugins);
|
|
5725
5726
|
__privateGet(this, _stack).push(options);
|
|
5726
5727
|
Object.assign(this, options);
|
|
5727
5728
|
}
|
|
@@ -5937,7 +5938,8 @@ async function* expandPatternsInternal(context) {
|
|
|
5937
5938
|
}
|
|
5938
5939
|
const globOptions = {
|
|
5939
5940
|
dot: true,
|
|
5940
|
-
ignore: silentlyIgnoredDirs.map((dir) => "**/" + dir)
|
|
5941
|
+
ignore: silentlyIgnoredDirs.map((dir) => "**/" + dir),
|
|
5942
|
+
followSymbolicLinks: false
|
|
5941
5943
|
};
|
|
5942
5944
|
let supportedFilesGlob;
|
|
5943
5945
|
const cwd2 = process.cwd();
|
|
@@ -5947,9 +5949,13 @@ async function* expandPatternsInternal(context) {
|
|
|
5947
5949
|
if (containsIgnoredPathSegment(absolutePath, cwd2, silentlyIgnoredDirs)) {
|
|
5948
5950
|
continue;
|
|
5949
5951
|
}
|
|
5950
|
-
const stat = await
|
|
5952
|
+
const stat = await lstatSafe(absolutePath);
|
|
5951
5953
|
if (stat) {
|
|
5952
|
-
if (stat.
|
|
5954
|
+
if (stat.isSymbolicLink()) {
|
|
5955
|
+
yield {
|
|
5956
|
+
error: `Explicitly specified pattern "${pattern}" is a symbolic link.`
|
|
5957
|
+
};
|
|
5958
|
+
} else if (stat.isFile()) {
|
|
5953
5959
|
entries.push({
|
|
5954
5960
|
type: "file",
|
|
5955
5961
|
glob: escapePathForGlob(fixWindowsSlashes(pattern)),
|
|
@@ -6269,7 +6275,12 @@ function locatePathSync(paths, {
|
|
|
6269
6275
|
const statFunction = allowSymlinks ? fs2.statSync : fs2.lstatSync;
|
|
6270
6276
|
for (const path_ of paths) {
|
|
6271
6277
|
try {
|
|
6272
|
-
const stat = statFunction(path3.resolve(cwd2, path_)
|
|
6278
|
+
const stat = statFunction(path3.resolve(cwd2, path_), {
|
|
6279
|
+
throwIfNoEntry: false
|
|
6280
|
+
});
|
|
6281
|
+
if (!stat) {
|
|
6282
|
+
continue;
|
|
6283
|
+
}
|
|
6273
6284
|
if (matchType(type, stat)) {
|
|
6274
6285
|
return path_;
|
|
6275
6286
|
}
|
|
@@ -6480,12 +6491,18 @@ function diff(a, b) {
|
|
|
6480
6491
|
return (0, import_diff.createTwoFilesPatch)("", "", a, b, "", "", { context: 2 });
|
|
6481
6492
|
}
|
|
6482
6493
|
var DebugError = class extends Error {
|
|
6494
|
+
name = "DebugError";
|
|
6483
6495
|
};
|
|
6484
6496
|
function handleError(context, filename, error, printedFilename) {
|
|
6485
|
-
|
|
6486
|
-
|
|
6497
|
+
const errorIsUndefinedParseError = error instanceof errors.UndefinedParserError;
|
|
6498
|
+
if (printedFilename) {
|
|
6499
|
+
if ((context.argv.write || context.argv.ignoreUnknown) && errorIsUndefinedParseError) {
|
|
6487
6500
|
printedFilename.clear();
|
|
6501
|
+
} else {
|
|
6502
|
+
process.stdout.write("\n");
|
|
6488
6503
|
}
|
|
6504
|
+
}
|
|
6505
|
+
if (errorIsUndefinedParseError) {
|
|
6489
6506
|
if (context.argv.ignoreUnknown) {
|
|
6490
6507
|
return;
|
|
6491
6508
|
}
|
|
@@ -6495,9 +6512,6 @@ function handleError(context, filename, error, printedFilename) {
|
|
|
6495
6512
|
context.logger.error(error.message);
|
|
6496
6513
|
return;
|
|
6497
6514
|
}
|
|
6498
|
-
if (context.argv.write) {
|
|
6499
|
-
process.stdout.write("\n");
|
|
6500
|
-
}
|
|
6501
6515
|
const isParseError = Boolean(error == null ? void 0 : error.loc);
|
|
6502
6516
|
const isValidationError = /^Invalid \S+ value\./.test(error == null ? void 0 : error.message);
|
|
6503
6517
|
if (isParseError) {
|
|
@@ -6632,7 +6646,11 @@ async function format2(context, input, opt) {
|
|
|
6632
6646
|
ms: averageMs
|
|
6633
6647
|
};
|
|
6634
6648
|
context.logger.debug(
|
|
6635
|
-
`'${performanceTestFlag.name}' measurements for formatWithCursor: ${JSON.stringify(
|
|
6649
|
+
`'${performanceTestFlag.name}' measurements for formatWithCursor: ${JSON.stringify(
|
|
6650
|
+
results,
|
|
6651
|
+
null,
|
|
6652
|
+
2
|
|
6653
|
+
)}`
|
|
6636
6654
|
);
|
|
6637
6655
|
}
|
|
6638
6656
|
return prettier.formatWithCursor(input, opt);
|
|
@@ -6746,6 +6764,7 @@ ${error.message}`
|
|
|
6746
6764
|
continue;
|
|
6747
6765
|
}
|
|
6748
6766
|
if (isFileIgnored) {
|
|
6767
|
+
printedFilename == null ? void 0 : printedFilename.clear();
|
|
6749
6768
|
writeOutput(context, { formatted: input }, options);
|
|
6750
6769
|
continue;
|
|
6751
6770
|
}
|
|
@@ -6769,9 +6788,7 @@ ${error.message}`
|
|
|
6769
6788
|
}
|
|
6770
6789
|
const isDifferent = output !== input;
|
|
6771
6790
|
let shouldSetCache = !isDifferent;
|
|
6772
|
-
|
|
6773
|
-
printedFilename.clear();
|
|
6774
|
-
}
|
|
6791
|
+
printedFilename == null ? void 0 : printedFilename.clear();
|
|
6775
6792
|
if (performanceTestFlag) {
|
|
6776
6793
|
context.logger.log(
|
|
6777
6794
|
`'${performanceTestFlag.name}' option found, skipped print code or write files.`
|
|
@@ -6849,14 +6866,12 @@ async function logFileInfoOrDie(context) {
|
|
|
6849
6866
|
ignorePath,
|
|
6850
6867
|
withNodeModules,
|
|
6851
6868
|
plugins,
|
|
6852
|
-
pluginSearchDirs,
|
|
6853
6869
|
config
|
|
6854
6870
|
} = context.argv;
|
|
6855
6871
|
const fileInfo = await getFileInfo(file, {
|
|
6856
6872
|
ignorePath,
|
|
6857
6873
|
withNodeModules,
|
|
6858
6874
|
plugins,
|
|
6859
|
-
pluginSearchDirs,
|
|
6860
6875
|
resolveConfig: config !== false
|
|
6861
6876
|
});
|
|
6862
6877
|
printToScreen(await format3((0, import_fast_json_stable_stringify2.default)(fileInfo), { parser: "json" }));
|
|
@@ -6918,14 +6933,6 @@ async function run(rawArguments) {
|
|
|
6918
6933
|
}
|
|
6919
6934
|
async function main(context) {
|
|
6920
6935
|
context.logger.debug(`normalized argv: ${JSON.stringify(context.argv)}`);
|
|
6921
|
-
if (context.argv.pluginSearch === false) {
|
|
6922
|
-
const rawPluginSearchDirs = context.argv.__raw["plugin-search-dir"];
|
|
6923
|
-
if (typeof rawPluginSearchDirs === "string" || isNonEmptyArray(rawPluginSearchDirs)) {
|
|
6924
|
-
throw new Error(
|
|
6925
|
-
"Cannot use --no-plugin-search and --plugin-search-dir together."
|
|
6926
|
-
);
|
|
6927
|
-
}
|
|
6928
|
-
}
|
|
6929
6936
|
if (context.argv.check && context.argv.listDifferent) {
|
|
6930
6937
|
throw new Error("Cannot use --check and --list-different together.");
|
|
6931
6938
|
}
|