prettier 3.0.0-alpha.11 → 3.0.0-alpha.12
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 +25 -53
- package/bin/prettier.cjs +0 -0
- package/doc.js +35 -86
- package/doc.mjs +48 -94
- package/index.cjs +43 -90
- package/index.d.ts +0 -4
- package/index.mjs +500 -453
- package/internal/cli.mjs +41 -40
- 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.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 +18 -18
- package/plugins/glimmer.mjs +1 -1
- package/plugins/graphql.js +12 -12
- package/plugins/graphql.mjs +1 -1
- package/plugins/html.js +15 -15
- package/plugins/html.mjs +1 -1
- package/plugins/markdown.js +45 -45
- package/plugins/markdown.mjs +45 -45
- package/plugins/meriyah.js +5 -5
- package/plugins/meriyah.mjs +5 -5
- package/plugins/postcss.js +26 -26
- package/plugins/postcss.mjs +6 -6
- package/plugins/typescript.js +7 -7
- package/plugins/typescript.mjs +17 -17
- package/plugins/yaml.js +55 -55
- package/plugins/yaml.mjs +1 -1
- package/standalone.js +26 -28
- package/standalone.mjs +27 -29
package/internal/cli.mjs
CHANGED
|
@@ -5251,6 +5251,7 @@ var cli_options_evaluate_default = {
|
|
|
5251
5251
|
"default": [
|
|
5252
5252
|
{
|
|
5253
5253
|
"value": [
|
|
5254
|
+
".gitignore",
|
|
5254
5255
|
".prettierignore"
|
|
5255
5256
|
]
|
|
5256
5257
|
}
|
|
@@ -5281,10 +5282,6 @@ var cli_options_evaluate_default = {
|
|
|
5281
5282
|
"description": "What level of logs to report.",
|
|
5282
5283
|
"type": "choice"
|
|
5283
5284
|
},
|
|
5284
|
-
"pluginSearch": {
|
|
5285
|
-
"oppositeDescription": "Disable plugin autoloading.",
|
|
5286
|
-
"type": "boolean"
|
|
5287
|
-
},
|
|
5288
5285
|
"supportInfo": {
|
|
5289
5286
|
"description": "Print support information as JSON.",
|
|
5290
5287
|
"type": "boolean"
|
|
@@ -5356,11 +5353,10 @@ function supportInfoToContextOptions({ options: supportOptions, languages }) {
|
|
|
5356
5353
|
detailedOptions
|
|
5357
5354
|
};
|
|
5358
5355
|
}
|
|
5359
|
-
async function getContextOptions(plugins
|
|
5356
|
+
async function getContextOptions(plugins) {
|
|
5360
5357
|
const supportInfo = await getSupportInfo({
|
|
5361
5358
|
showDeprecated: true,
|
|
5362
|
-
plugins
|
|
5363
|
-
pluginSearchDirs
|
|
5359
|
+
plugins
|
|
5364
5360
|
});
|
|
5365
5361
|
return supportInfoToContextOptions(supportInfo);
|
|
5366
5362
|
}
|
|
@@ -5495,6 +5491,15 @@ async function statSafe(filePath) {
|
|
|
5495
5491
|
}
|
|
5496
5492
|
}
|
|
5497
5493
|
}
|
|
5494
|
+
async function lstatSafe(filePath) {
|
|
5495
|
+
try {
|
|
5496
|
+
return await fs.lstat(filePath);
|
|
5497
|
+
} catch (error) {
|
|
5498
|
+
if (error.code !== "ENOENT") {
|
|
5499
|
+
throw error;
|
|
5500
|
+
}
|
|
5501
|
+
}
|
|
5502
|
+
}
|
|
5498
5503
|
function isJson(value) {
|
|
5499
5504
|
try {
|
|
5500
5505
|
JSON.parse(value);
|
|
@@ -5547,7 +5552,7 @@ function createMinimistOptions(detailedOptions) {
|
|
|
5547
5552
|
if (alias) {
|
|
5548
5553
|
names.push(alias);
|
|
5549
5554
|
}
|
|
5550
|
-
if (!option.deprecated && (!option.forwardToApi || name === "plugin"
|
|
5555
|
+
if (!option.deprecated && (!option.forwardToApi || name === "plugin") && option.default !== void 0) {
|
|
5551
5556
|
defaultValues[option.name] = option.default;
|
|
5552
5557
|
}
|
|
5553
5558
|
}
|
|
@@ -5659,9 +5664,6 @@ function parseArgv(rawArguments, detailedOptions, logger, keys) {
|
|
|
5659
5664
|
const minimistOptions = createMinimistOptions(detailedOptions);
|
|
5660
5665
|
let argv = minimistParse(rawArguments, minimistOptions);
|
|
5661
5666
|
if (keys) {
|
|
5662
|
-
if (keys.includes("plugin-search-dir") && !keys.includes("plugin-search")) {
|
|
5663
|
-
keys.push("plugin-search");
|
|
5664
|
-
}
|
|
5665
5667
|
detailedOptions = detailedOptions.filter(
|
|
5666
5668
|
(option) => keys.includes(option.name)
|
|
5667
5669
|
);
|
|
@@ -5708,20 +5710,18 @@ var Context = class {
|
|
|
5708
5710
|
logger
|
|
5709
5711
|
} = this;
|
|
5710
5712
|
const {
|
|
5711
|
-
plugins
|
|
5712
|
-
|
|
5713
|
-
|
|
5714
|
-
await this.pushContextPlugins(plugins, pluginSearchDirs);
|
|
5713
|
+
plugins
|
|
5714
|
+
} = parseArgvWithoutPlugins(rawArguments, logger, ["plugin"]);
|
|
5715
|
+
await this.pushContextPlugins(plugins);
|
|
5715
5716
|
const argv = parseArgv(rawArguments, this.detailedOptions, logger);
|
|
5716
5717
|
this.argv = argv;
|
|
5717
5718
|
this.filePatterns = argv._;
|
|
5718
5719
|
}
|
|
5719
5720
|
/**
|
|
5720
5721
|
* @param {string[]} plugins
|
|
5721
|
-
* @param {string[]=} pluginSearchDirs
|
|
5722
5722
|
*/
|
|
5723
|
-
async pushContextPlugins(plugins
|
|
5724
|
-
const options = await getContextOptions(plugins
|
|
5723
|
+
async pushContextPlugins(plugins) {
|
|
5724
|
+
const options = await getContextOptions(plugins);
|
|
5725
5725
|
__privateGet(this, _stack).push(options);
|
|
5726
5726
|
Object.assign(this, options);
|
|
5727
5727
|
}
|
|
@@ -5937,7 +5937,8 @@ async function* expandPatternsInternal(context) {
|
|
|
5937
5937
|
}
|
|
5938
5938
|
const globOptions = {
|
|
5939
5939
|
dot: true,
|
|
5940
|
-
ignore: silentlyIgnoredDirs.map((dir) => "**/" + dir)
|
|
5940
|
+
ignore: silentlyIgnoredDirs.map((dir) => "**/" + dir),
|
|
5941
|
+
followSymbolicLinks: false
|
|
5941
5942
|
};
|
|
5942
5943
|
let supportedFilesGlob;
|
|
5943
5944
|
const cwd2 = process.cwd();
|
|
@@ -5947,9 +5948,13 @@ async function* expandPatternsInternal(context) {
|
|
|
5947
5948
|
if (containsIgnoredPathSegment(absolutePath, cwd2, silentlyIgnoredDirs)) {
|
|
5948
5949
|
continue;
|
|
5949
5950
|
}
|
|
5950
|
-
const stat = await
|
|
5951
|
+
const stat = await lstatSafe(absolutePath);
|
|
5951
5952
|
if (stat) {
|
|
5952
|
-
if (stat.
|
|
5953
|
+
if (stat.isSymbolicLink()) {
|
|
5954
|
+
yield {
|
|
5955
|
+
error: `Explicitly specified pattern "${pattern}" is a symbolic link.`
|
|
5956
|
+
};
|
|
5957
|
+
} else if (stat.isFile()) {
|
|
5953
5958
|
entries.push({
|
|
5954
5959
|
type: "file",
|
|
5955
5960
|
glob: escapePathForGlob(fixWindowsSlashes(pattern)),
|
|
@@ -6269,7 +6274,12 @@ function locatePathSync(paths, {
|
|
|
6269
6274
|
const statFunction = allowSymlinks ? fs2.statSync : fs2.lstatSync;
|
|
6270
6275
|
for (const path_ of paths) {
|
|
6271
6276
|
try {
|
|
6272
|
-
const stat = statFunction(path3.resolve(cwd2, path_)
|
|
6277
|
+
const stat = statFunction(path3.resolve(cwd2, path_), {
|
|
6278
|
+
throwIfNoEntry: false
|
|
6279
|
+
});
|
|
6280
|
+
if (!stat) {
|
|
6281
|
+
continue;
|
|
6282
|
+
}
|
|
6273
6283
|
if (matchType(type, stat)) {
|
|
6274
6284
|
return path_;
|
|
6275
6285
|
}
|
|
@@ -6482,10 +6492,15 @@ function diff(a, b) {
|
|
|
6482
6492
|
var DebugError = class extends Error {
|
|
6483
6493
|
};
|
|
6484
6494
|
function handleError(context, filename, error, printedFilename) {
|
|
6485
|
-
|
|
6486
|
-
|
|
6495
|
+
const errorIsUndefinedParseError = error instanceof errors.UndefinedParserError;
|
|
6496
|
+
if (printedFilename) {
|
|
6497
|
+
if ((context.argv.write || context.argv.ignoreUnknown) && errorIsUndefinedParseError) {
|
|
6487
6498
|
printedFilename.clear();
|
|
6499
|
+
} else {
|
|
6500
|
+
process.stdout.write("\n");
|
|
6488
6501
|
}
|
|
6502
|
+
}
|
|
6503
|
+
if (errorIsUndefinedParseError) {
|
|
6489
6504
|
if (context.argv.ignoreUnknown) {
|
|
6490
6505
|
return;
|
|
6491
6506
|
}
|
|
@@ -6495,9 +6510,6 @@ function handleError(context, filename, error, printedFilename) {
|
|
|
6495
6510
|
context.logger.error(error.message);
|
|
6496
6511
|
return;
|
|
6497
6512
|
}
|
|
6498
|
-
if (context.argv.write) {
|
|
6499
|
-
process.stdout.write("\n");
|
|
6500
|
-
}
|
|
6501
6513
|
const isParseError = Boolean(error == null ? void 0 : error.loc);
|
|
6502
6514
|
const isValidationError = /^Invalid \S+ value\./.test(error == null ? void 0 : error.message);
|
|
6503
6515
|
if (isParseError) {
|
|
@@ -6746,6 +6758,7 @@ ${error.message}`
|
|
|
6746
6758
|
continue;
|
|
6747
6759
|
}
|
|
6748
6760
|
if (isFileIgnored) {
|
|
6761
|
+
printedFilename == null ? void 0 : printedFilename.clear();
|
|
6749
6762
|
writeOutput(context, { formatted: input }, options);
|
|
6750
6763
|
continue;
|
|
6751
6764
|
}
|
|
@@ -6769,9 +6782,7 @@ ${error.message}`
|
|
|
6769
6782
|
}
|
|
6770
6783
|
const isDifferent = output !== input;
|
|
6771
6784
|
let shouldSetCache = !isDifferent;
|
|
6772
|
-
|
|
6773
|
-
printedFilename.clear();
|
|
6774
|
-
}
|
|
6785
|
+
printedFilename == null ? void 0 : printedFilename.clear();
|
|
6775
6786
|
if (performanceTestFlag) {
|
|
6776
6787
|
context.logger.log(
|
|
6777
6788
|
`'${performanceTestFlag.name}' option found, skipped print code or write files.`
|
|
@@ -6849,14 +6860,12 @@ async function logFileInfoOrDie(context) {
|
|
|
6849
6860
|
ignorePath,
|
|
6850
6861
|
withNodeModules,
|
|
6851
6862
|
plugins,
|
|
6852
|
-
pluginSearchDirs,
|
|
6853
6863
|
config
|
|
6854
6864
|
} = context.argv;
|
|
6855
6865
|
const fileInfo = await getFileInfo(file, {
|
|
6856
6866
|
ignorePath,
|
|
6857
6867
|
withNodeModules,
|
|
6858
6868
|
plugins,
|
|
6859
|
-
pluginSearchDirs,
|
|
6860
6869
|
resolveConfig: config !== false
|
|
6861
6870
|
});
|
|
6862
6871
|
printToScreen(await format3((0, import_fast_json_stable_stringify2.default)(fileInfo), { parser: "json" }));
|
|
@@ -6918,14 +6927,6 @@ async function run(rawArguments) {
|
|
|
6918
6927
|
}
|
|
6919
6928
|
async function main(context) {
|
|
6920
6929
|
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
6930
|
if (context.argv.check && context.argv.listDifferent) {
|
|
6930
6931
|
throw new Error("Cannot use --check and --list-different together.");
|
|
6931
6932
|
}
|