prettier 3.7.3 → 3.8.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/index.mjs CHANGED
@@ -10312,7 +10312,7 @@ var ArgExpansionBailout = class extends Error {
10312
10312
  name = "ArgExpansionBailout";
10313
10313
  };
10314
10314
 
10315
- // src/utils/create-mockable.js
10315
+ // src/utilities/create-mockable.js
10316
10316
  function createMockable(implementations) {
10317
10317
  const mocked = {
10318
10318
  ...implementations
@@ -10361,7 +10361,7 @@ var isUrl = (urlOrPath) => isUrlInstance(urlOrPath) || isUrlString(urlOrPath);
10361
10361
  var toPath = (urlOrPath) => isUrl(urlOrPath) ? url.fileURLToPath(urlOrPath) : urlOrPath;
10362
10362
  var toAbsolutePath = (urlOrPath) => urlOrPath ? path.resolve(isUrl(urlOrPath) ? url.fileURLToPath(urlOrPath) : urlOrPath) : urlOrPath;
10363
10363
 
10364
- // src/utils/partition.js
10364
+ // src/utilities/partition.js
10365
10365
  function partition2(array2, predicate) {
10366
10366
  const result = [[], []];
10367
10367
  for (const value of array2) {
@@ -12536,7 +12536,7 @@ function parse4(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
12536
12536
  return res;
12537
12537
  }
12538
12538
 
12539
- // src/utils/read-file.js
12539
+ // src/utilities/read-file.js
12540
12540
  import fs2 from "fs/promises";
12541
12541
  async function readFile(file) {
12542
12542
  if (isUrlString(file)) {
@@ -12689,7 +12689,7 @@ var config_searcher_default = getSearcher;
12689
12689
  // src/config/prettier-config/load-config.js
12690
12690
  import path8 from "path";
12691
12691
 
12692
- // src/utils/import-from-file.js
12692
+ // src/utilities/import-from-file.js
12693
12693
  import { pathToFileURL as pathToFileURL4 } from "url";
12694
12694
 
12695
12695
  // node_modules/import-meta-resolve/lib/resolve.js
@@ -14068,14 +14068,14 @@ function resolve2(specifier, parent) {
14068
14068
  }
14069
14069
  }
14070
14070
 
14071
- // src/utils/import-from-file.js
14071
+ // src/utilities/import-from-file.js
14072
14072
  function importFromFile(specifier, parent) {
14073
14073
  const url3 = resolve2(specifier, pathToFileURL4(parent).href);
14074
14074
  return import(url3);
14075
14075
  }
14076
14076
  var import_from_file_default = importFromFile;
14077
14077
 
14078
- // src/utils/require-from-file.js
14078
+ // src/utilities/require-from-file.js
14079
14079
  import { createRequire } from "module";
14080
14080
  function requireFromFile(id, parent) {
14081
14081
  const require2 = createRequire(parent);
@@ -14276,49 +14276,44 @@ var method_replace_all_default = replaceAll;
14276
14276
  // src/main/core.js
14277
14277
  import { builders as __doc_builders4, printer as __doc_printer } from "./doc.mjs";
14278
14278
 
14279
+ // src/universal/assert.js
14280
+ import { equal, ok, strictEqual } from "assert";
14281
+
14279
14282
  // src/common/end-of-line.js
14283
+ var OPTION_CR = "cr";
14284
+ var OPTION_CRLF = "crlf";
14285
+ var OPTION_LF = "lf";
14286
+ var DEFAULT_OPTION = OPTION_LF;
14287
+ var CHARACTER_CR = "\r";
14288
+ var CHARACTER_CRLF = "\r\n";
14289
+ var CHARACTER_LF = "\n";
14290
+ var DEFAULT_EOL = CHARACTER_LF;
14280
14291
  function guessEndOfLine(text) {
14281
- const index = text.indexOf("\r");
14292
+ const index = text.indexOf(CHARACTER_CR);
14282
14293
  if (index !== -1) {
14283
- return text.charAt(index + 1) === "\n" ? "crlf" : "cr";
14294
+ return text.charAt(index + 1) === CHARACTER_LF ? OPTION_CRLF : OPTION_CR;
14284
14295
  }
14285
- return "lf";
14296
+ return DEFAULT_OPTION;
14286
14297
  }
14287
- function convertEndOfLineToChars(value) {
14288
- switch (value) {
14289
- case "cr":
14290
- return "\r";
14291
- case "crlf":
14292
- return "\r\n";
14293
- default:
14294
- return "\n";
14295
- }
14298
+ function convertEndOfLineOptionToCharacter(endOfLineOption) {
14299
+ return endOfLineOption === OPTION_CR ? CHARACTER_CR : endOfLineOption === OPTION_CRLF ? CHARACTER_CRLF : DEFAULT_EOL;
14296
14300
  }
14297
- function countEndOfLineChars(text, eol) {
14298
- let regex;
14299
- switch (eol) {
14300
- case "\n":
14301
- regex = /\n/gu;
14302
- break;
14303
- case "\r":
14304
- regex = /\r/gu;
14305
- break;
14306
- case "\r\n":
14307
- regex = /\r\n/gu;
14308
- break;
14309
- default:
14310
- throw new Error(`Unexpected "eol" ${JSON.stringify(eol)}.`);
14301
+ var regexps = /* @__PURE__ */ new Map([[CHARACTER_LF, /\n/gu], [CHARACTER_CR, /\r/gu], [CHARACTER_CRLF, /\r\n/gu]]);
14302
+ function countEndOfLineCharacters(text, endOfLineCharacter) {
14303
+ const regex = regexps.get(endOfLineCharacter);
14304
+ if (false) {
14305
+ ok(regex, `Unexpected 'endOfLineCharacter': ${JSON.stringify(endOfLineCharacter)}.`);
14311
14306
  }
14312
- const endOfLines = text.match(regex);
14313
- return endOfLines ? endOfLines.length : 0;
14307
+ return text.match(regex)?.length ?? 0;
14314
14308
  }
14309
+ var END_OF_LINE_REGEXP = /\r\n?/gu;
14315
14310
  function normalizeEndOfLine(text) {
14316
14311
  return method_replace_all_default(
14317
14312
  /* OPTIONAL_OBJECT: false */
14318
14313
  0,
14319
14314
  text,
14320
- /\r\n?/gu,
14321
- "\n"
14315
+ END_OF_LINE_REGEXP,
14316
+ CHARACTER_LF
14322
14317
  );
14323
14318
  }
14324
14319
 
@@ -14333,7 +14328,7 @@ var at = createMethodShim("at", function() {
14333
14328
  });
14334
14329
  var method_at_default = at;
14335
14330
 
14336
- // src/utils/noop.js
14331
+ // src/utilities/noop.js
14337
14332
  var noop = () => {
14338
14333
  };
14339
14334
  var noop_default = noop;
@@ -14555,10 +14550,10 @@ function isWide(x) {
14555
14550
  return x >= 4352 && x <= 4447 || x === 8986 || x === 8987 || x === 9001 || x === 9002 || x >= 9193 && x <= 9196 || x === 9200 || x === 9203 || x === 9725 || x === 9726 || x === 9748 || x === 9749 || x >= 9776 && x <= 9783 || x >= 9800 && x <= 9811 || x === 9855 || x >= 9866 && x <= 9871 || x === 9875 || x === 9889 || x === 9898 || x === 9899 || x === 9917 || x === 9918 || x === 9924 || x === 9925 || x === 9934 || x === 9940 || x === 9962 || x === 9970 || x === 9971 || x === 9973 || x === 9978 || x === 9981 || x === 9989 || x === 9994 || x === 9995 || x === 10024 || x === 10060 || x === 10062 || x >= 10067 && x <= 10069 || x === 10071 || x >= 10133 && x <= 10135 || x === 10160 || x === 10175 || x === 11035 || x === 11036 || x === 11088 || x === 11093 || x >= 11904 && x <= 11929 || x >= 11931 && x <= 12019 || x >= 12032 && x <= 12245 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12353 && x <= 12438 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12773 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 42124 || x >= 42128 && x <= 42182 || x >= 43360 && x <= 43388 || x >= 44032 && x <= 55203 || x >= 63744 && x <= 64255 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 94176 && x <= 94180 || x >= 94192 && x <= 94198 || x >= 94208 && x <= 101589 || x >= 101631 && x <= 101662 || x >= 101760 && x <= 101874 || x >= 110576 && x <= 110579 || x >= 110581 && x <= 110587 || x === 110589 || x === 110590 || x >= 110592 && x <= 110882 || x === 110898 || x >= 110928 && x <= 110930 || x === 110933 || x >= 110948 && x <= 110951 || x >= 110960 && x <= 111355 || x >= 119552 && x <= 119638 || x >= 119648 && x <= 119670 || x === 126980 || x === 127183 || x === 127374 || x >= 127377 && x <= 127386 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x === 127568 || x === 127569 || x >= 127584 && x <= 127589 || x >= 127744 && x <= 127776 || x >= 127789 && x <= 127797 || x >= 127799 && x <= 127868 || x >= 127870 && x <= 127891 || x >= 127904 && x <= 127946 || x >= 127951 && x <= 127955 || x >= 127968 && x <= 127984 || x === 127988 || x >= 127992 && x <= 128062 || x === 128064 || x >= 128066 && x <= 128252 || x >= 128255 && x <= 128317 || x >= 128331 && x <= 128334 || x >= 128336 && x <= 128359 || x === 128378 || x === 128405 || x === 128406 || x === 128420 || x >= 128507 && x <= 128591 || x >= 128640 && x <= 128709 || x === 128716 || x >= 128720 && x <= 128722 || x >= 128725 && x <= 128728 || x >= 128732 && x <= 128735 || x === 128747 || x === 128748 || x >= 128756 && x <= 128764 || x >= 128992 && x <= 129003 || x === 129008 || x >= 129292 && x <= 129338 || x >= 129340 && x <= 129349 || x >= 129351 && x <= 129535 || x >= 129648 && x <= 129660 || x >= 129664 && x <= 129674 || x >= 129678 && x <= 129734 || x === 129736 || x >= 129741 && x <= 129756 || x >= 129759 && x <= 129770 || x >= 129775 && x <= 129784 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
14556
14551
  }
14557
14552
 
14558
- // src/utils/narrow-emojis.evaluate.js
14553
+ // src/utilities/narrow-emojis.evaluate.js
14559
14554
  var narrow_emojis_evaluate_default = "\xA9\xAE\u203C\u2049\u2122\u2139\u2194\u2195\u2196\u2197\u2198\u2199\u21A9\u21AA\u2328\u23CF\u23F1\u23F2\u23F8\u23F9\u23FA\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600\u2601\u2602\u2603\u2604\u260E\u2611\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638\u2639\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694\u2695\u2696\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F1\u26F7\u26F8\u26F9\u2702\u2708\u2709\u270C\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u2764\u27A1\u2934\u2935\u2B05\u2B06\u2B07";
14560
14555
 
14561
- // src/utils/get-string-width.js
14556
+ // src/utilities/get-string-width.js
14562
14557
  var notAsciiRegex = /[^\x20-\x7F]/u;
14563
14558
  var narrowEmojisSet = new Set(narrow_emojis_evaluate_default);
14564
14559
  function getStringWidth(text) {
@@ -14590,7 +14585,7 @@ function getStringWidth(text) {
14590
14585
  }
14591
14586
  var get_string_width_default = getStringWidth;
14592
14587
 
14593
- // src/utils/get-alignment-size.js
14588
+ // src/utilities/get-alignment-size.js
14594
14589
  function getAlignmentSize(text, tabWidth, startIndex = 0) {
14595
14590
  let size = 0;
14596
14591
  for (let i = startIndex; i < text.length; ++i) {
@@ -14909,10 +14904,13 @@ var AstPath = class {
14909
14904
  };
14910
14905
  var ast_path_default = AstPath;
14911
14906
 
14912
- // src/universal/assert.js
14913
- import { equal, ok, strictEqual } from "assert";
14907
+ // src/utilities/is-object.js
14908
+ function isObject(object) {
14909
+ return object !== null && typeof object === "object";
14910
+ }
14911
+ var is_object_default = isObject;
14914
14912
 
14915
- // src/utils/skip.js
14913
+ // src/utilities/skip.js
14916
14914
  function skip(characters) {
14917
14915
  return (text, startIndex, options8) => {
14918
14916
  const backwards = Boolean(options8?.backwards);
@@ -14943,7 +14941,7 @@ var skipSpaces = skip(" ");
14943
14941
  var skipToLineEnd = skip(",; ");
14944
14942
  var skipEverythingButNewLine = skip(/[^\n\r]/u);
14945
14943
 
14946
- // src/utils/skip-newline.js
14944
+ // src/utilities/skip-newline.js
14947
14945
  var isNewlineCharacter = (character) => character === "\n" || character === "\r" || character === "\u2028" || character === "\u2029";
14948
14946
  function skipNewline(text, startIndex, options8) {
14949
14947
  const backwards = Boolean(options8?.backwards);
@@ -14970,7 +14968,7 @@ function skipNewline(text, startIndex, options8) {
14970
14968
  }
14971
14969
  var skip_newline_default = skipNewline;
14972
14970
 
14973
- // src/utils/has-newline.js
14971
+ // src/utilities/has-newline.js
14974
14972
  function hasNewline(text, startIndex, options8 = {}) {
14975
14973
  const idx = skipSpaces(
14976
14974
  text,
@@ -14982,19 +14980,13 @@ function hasNewline(text, startIndex, options8 = {}) {
14982
14980
  }
14983
14981
  var has_newline_default = hasNewline;
14984
14982
 
14985
- // src/utils/is-non-empty-array.js
14983
+ // src/utilities/is-non-empty-array.js
14986
14984
  function isNonEmptyArray(object) {
14987
14985
  return Array.isArray(object) && object.length > 0;
14988
14986
  }
14989
14987
  var is_non_empty_array_default = isNonEmptyArray;
14990
14988
 
14991
- // src/utils/is-object.js
14992
- function isObject(object) {
14993
- return object !== null && typeof object === "object";
14994
- }
14995
- var is_object_default = isObject;
14996
-
14997
- // src/utils/ast-utils.js
14989
+ // src/utilities/ast.js
14998
14990
  function* getChildren(node, options8) {
14999
14991
  const { getVisitorKeys, filter: filter2 = () => true } = options8;
15000
14992
  const isMatchedNode = (node2) => is_object_default(node2) && filter2(node2);
@@ -15051,7 +15043,7 @@ function getSortedChildNodes(node, ancestors, options8) {
15051
15043
  }
15052
15044
  var get_sorted_child_nodes_default = getSortedChildNodes;
15053
15045
 
15054
- // src/main/comments/utils.js
15046
+ // src/main/comments/utilities.js
15055
15047
  function describeNodeForDebugging(node) {
15056
15048
  const nodeType = node.type || node.kind || "(unknown type)";
15057
15049
  let nodeName = String(
@@ -15329,7 +15321,7 @@ function findExpressionIndexForComment(quasis, comment, options8) {
15329
15321
  // src/main/comments/print.js
15330
15322
  import { builders as __doc_builders } from "./doc.mjs";
15331
15323
 
15332
- // src/utils/is-previous-line-empty.js
15324
+ // src/utilities/is-previous-line-empty.js
15333
15325
  function isPreviousLineEmpty(text, startIndex) {
15334
15326
  let idx = startIndex - 1;
15335
15327
  idx = skipSpaces(text, idx, { backwards: true });
@@ -15820,7 +15812,7 @@ var method_to_reversed_default = toReversed;
15820
15812
  // src/universal/index.js
15821
15813
  import path11 from "path";
15822
15814
 
15823
- // src/utils/get-interpreter.js
15815
+ // src/utilities/get-interpreter.js
15824
15816
  var import_n_readlines = __toESM(require_readlines(), 1);
15825
15817
  function getInterpreter(file) {
15826
15818
  try {
@@ -15854,7 +15846,7 @@ var getFileBasename = (file) => {
15854
15846
  }
15855
15847
  };
15856
15848
 
15857
- // src/utils/infer-parser.js
15849
+ // src/utilities/infer-parser.js
15858
15850
  function getLanguageByFileName(languages2, file) {
15859
15851
  if (!file) {
15860
15852
  return;
@@ -16612,7 +16604,7 @@ async function printAstToDoc(ast, options8) {
16612
16604
  if (value === void 0 || value === null) {
16613
16605
  return "";
16614
16606
  }
16615
- const shouldCache = value && typeof value === "object" && args === void 0;
16607
+ const shouldCache = is_object_default(value) && args === void 0;
16616
16608
  if (shouldCache && cache3.has(value)) {
16617
16609
  return cache3.get(value);
16618
16610
  }
@@ -16981,7 +16973,7 @@ async function coreFormat(originalText, opts, addAlignmentSize = 0) {
16981
16973
  result.cursorNodeText = result.cursorNodeText.trimEnd();
16982
16974
  }
16983
16975
  }
16984
- result.formatted = trimmed + convertEndOfLineToChars(opts.endOfLine);
16976
+ result.formatted = trimmed + convertEndOfLineOptionToCharacter(opts.endOfLine);
16985
16977
  }
16986
16978
  const comments = opts[Symbol.for("comments")];
16987
16979
  if (opts.cursorOffset >= 0) {
@@ -17073,9 +17065,9 @@ async function formatRange(originalText, opts) {
17073
17065
  }
17074
17066
  let formatted = text.slice(0, rangeStart) + rangeTrimmed + text.slice(rangeEnd);
17075
17067
  if (opts.endOfLine !== "lf") {
17076
- const eol = convertEndOfLineToChars(opts.endOfLine);
17068
+ const eol = convertEndOfLineOptionToCharacter(opts.endOfLine);
17077
17069
  if (cursorOffset >= 0 && eol === "\r\n") {
17078
- cursorOffset += countEndOfLineChars(formatted.slice(0, cursorOffset), "\n");
17070
+ cursorOffset += countEndOfLineCharacters(formatted.slice(0, cursorOffset), "\n");
17079
17071
  }
17080
17072
  formatted = method_replace_all_default(
17081
17073
  /* OPTIONAL_OBJECT: false */
@@ -17131,7 +17123,7 @@ function normalizeInputAndOptions(text, options8) {
17131
17123
  endOfLine = guessEndOfLine(text);
17132
17124
  }
17133
17125
  if (text.includes("\r")) {
17134
- const countCrlfBefore = (index) => countEndOfLineChars(text.slice(0, Math.max(index, 0)), "\r\n");
17126
+ const countCrlfBefore = (index) => countEndOfLineCharacters(text.slice(0, Math.max(index, 0)), "\r\n");
17135
17127
  cursorOffset -= countCrlfBefore(cursorOffset);
17136
17128
  rangeStart -= countCrlfBefore(rangeStart);
17137
17129
  rangeEnd -= countCrlfBefore(rangeEnd);
@@ -18316,7 +18308,7 @@ var load_builtin_plugins_default = loadBuiltinPlugins;
18316
18308
  import path13 from "path";
18317
18309
  import { pathToFileURL as pathToFileURL5 } from "url";
18318
18310
 
18319
- // src/utils/import-from-directory.js
18311
+ // src/utilities/import-from-directory.js
18320
18312
  import path12 from "path";
18321
18313
  function importFromDirectory(specifier, directory) {
18322
18314
  return import_from_file_default(specifier, path12.join(directory, "noop.js"));
@@ -18365,7 +18357,7 @@ function loadPlugins(plugins = []) {
18365
18357
  }
18366
18358
  var load_plugins_default = loadPlugins;
18367
18359
 
18368
- // src/utils/ignore.js
18360
+ // src/utilities/ignore.js
18369
18361
  var import_ignore = __toESM(require_ignore(), 1);
18370
18362
  import path14 from "path";
18371
18363
  import url2 from "url";
@@ -18418,7 +18410,7 @@ async function isIgnored(file, options8) {
18418
18410
  return isIgnored2(file);
18419
18411
  }
18420
18412
 
18421
- // src/utils/object-omit.js
18413
+ // src/utilities/object-omit.js
18422
18414
  function omit(object, keys) {
18423
18415
  keys = new Set(keys);
18424
18416
  return Object.fromEntries(
@@ -18469,9 +18461,9 @@ var get_file_info_default = getFileInfo;
18469
18461
  import * as doc from "./doc.mjs";
18470
18462
 
18471
18463
  // src/main/version.evaluate.js
18472
- var version_evaluate_default = "3.7.3";
18464
+ var version_evaluate_default = "3.8.0";
18473
18465
 
18474
- // src/utils/public.js
18466
+ // src/utilities/public.js
18475
18467
  var public_exports = {};
18476
18468
  __export(public_exports, {
18477
18469
  addDanglingComment: () => addDanglingComment,
@@ -18501,7 +18493,7 @@ __export(public_exports, {
18501
18493
  skipWhitespace: () => skipWhitespace
18502
18494
  });
18503
18495
 
18504
- // src/utils/skip-inline-comment.js
18496
+ // src/utilities/skip-inline-comment.js
18505
18497
  function skipInlineComment(text, startIndex) {
18506
18498
  if (startIndex === false) {
18507
18499
  return false;
@@ -18517,7 +18509,7 @@ function skipInlineComment(text, startIndex) {
18517
18509
  }
18518
18510
  var skip_inline_comment_default = skipInlineComment;
18519
18511
 
18520
- // src/utils/skip-trailing-comment.js
18512
+ // src/utilities/skip-trailing-comment.js
18521
18513
  function skipTrailingComment(text, startIndex) {
18522
18514
  if (startIndex === false) {
18523
18515
  return false;
@@ -18529,7 +18521,7 @@ function skipTrailingComment(text, startIndex) {
18529
18521
  }
18530
18522
  var skip_trailing_comment_default = skipTrailingComment;
18531
18523
 
18532
- // src/utils/get-next-non-space-non-comment-character-index.js
18524
+ // src/utilities/get-next-non-space-non-comment-character-index.js
18533
18525
  function getNextNonSpaceNonCommentCharacterIndex(text, startIndex) {
18534
18526
  let oldIdx = null;
18535
18527
  let nextIdx = startIndex;
@@ -18544,7 +18536,7 @@ function getNextNonSpaceNonCommentCharacterIndex(text, startIndex) {
18544
18536
  }
18545
18537
  var get_next_non_space_non_comment_character_index_default = getNextNonSpaceNonCommentCharacterIndex;
18546
18538
 
18547
- // src/utils/is-next-line-empty.js
18539
+ // src/utilities/is-next-line-empty.js
18548
18540
  function isNextLineEmpty(text, startIndex) {
18549
18541
  let oldIdx = null;
18550
18542
  let idx = startIndex;
@@ -18560,7 +18552,7 @@ function isNextLineEmpty(text, startIndex) {
18560
18552
  }
18561
18553
  var is_next_line_empty_default = isNextLineEmpty;
18562
18554
 
18563
- // src/utils/get-indent-size.js
18555
+ // src/utilities/get-indent-size.js
18564
18556
  function getIndentSize(value, tabWidth) {
18565
18557
  const lastNewlineIndex = value.lastIndexOf("\n");
18566
18558
  if (lastNewlineIndex === -1) {
@@ -18582,7 +18574,7 @@ function escapeStringRegexp(string) {
18582
18574
  return string.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
18583
18575
  }
18584
18576
 
18585
- // src/utils/get-max-continuous-count.js
18577
+ // src/utilities/get-max-continuous-count.js
18586
18578
  function getMaxContinuousCount(text, searchString) {
18587
18579
  let results = text.matchAll(
18588
18580
  new RegExp(`(?:${escapeStringRegexp(searchString)})+`, "gu")
@@ -18597,33 +18589,50 @@ function getMaxContinuousCount(text, searchString) {
18597
18589
  }
18598
18590
  var get_max_continuous_count_default = getMaxContinuousCount;
18599
18591
 
18600
- // src/utils/get-next-non-space-non-comment-character.js
18592
+ // src/utilities/get-next-non-space-non-comment-character.js
18601
18593
  function getNextNonSpaceNonCommentCharacter(text, startIndex) {
18602
18594
  const index = get_next_non_space_non_comment_character_index_default(text, startIndex);
18603
18595
  return index === false ? "" : text.charAt(index);
18604
18596
  }
18605
18597
  var get_next_non_space_non_comment_character_default = getNextNonSpaceNonCommentCharacter;
18606
18598
 
18607
- // src/utils/get-preferred-quote.js
18599
+ // src/utilities/get-preferred-quote.js
18608
18600
  var SINGLE_QUOTE = "'";
18609
18601
  var DOUBLE_QUOTE = '"';
18602
+ var SINGLE_QUOTE_DATA = Object.freeze({
18603
+ character: SINGLE_QUOTE,
18604
+ codePoint: 39
18605
+ });
18606
+ var DOUBLE_QUOTE_DATA = Object.freeze({
18607
+ character: DOUBLE_QUOTE,
18608
+ codePoint: 34
18609
+ });
18610
+ var SINGLE_QUOTE_SETTINGS = Object.freeze({
18611
+ preferred: SINGLE_QUOTE_DATA,
18612
+ alternate: DOUBLE_QUOTE_DATA
18613
+ });
18614
+ var DOUBLE_QUOTE_SETTINGS = Object.freeze({
18615
+ preferred: DOUBLE_QUOTE_DATA,
18616
+ alternate: SINGLE_QUOTE_DATA
18617
+ });
18610
18618
  function getPreferredQuote(text, preferredQuoteOrPreferSingleQuote) {
18611
- const preferred = preferredQuoteOrPreferSingleQuote === true || preferredQuoteOrPreferSingleQuote === SINGLE_QUOTE ? SINGLE_QUOTE : DOUBLE_QUOTE;
18612
- const alternate = preferred === SINGLE_QUOTE ? DOUBLE_QUOTE : SINGLE_QUOTE;
18619
+ const { preferred, alternate } = preferredQuoteOrPreferSingleQuote === true || preferredQuoteOrPreferSingleQuote === SINGLE_QUOTE ? SINGLE_QUOTE_SETTINGS : DOUBLE_QUOTE_SETTINGS;
18620
+ const { length } = text;
18613
18621
  let preferredQuoteCount = 0;
18614
18622
  let alternateQuoteCount = 0;
18615
- for (const character of text) {
18616
- if (character === preferred) {
18623
+ for (let index = 0; index < length; index++) {
18624
+ const codePoint = text.charCodeAt(index);
18625
+ if (codePoint === preferred.codePoint) {
18617
18626
  preferredQuoteCount++;
18618
- } else if (character === alternate) {
18627
+ } else if (codePoint === alternate.codePoint) {
18619
18628
  alternateQuoteCount++;
18620
18629
  }
18621
18630
  }
18622
- return preferredQuoteCount > alternateQuoteCount ? alternate : preferred;
18631
+ return (preferredQuoteCount > alternateQuoteCount ? alternate : preferred).character;
18623
18632
  }
18624
18633
  var get_preferred_quote_default = getPreferredQuote;
18625
18634
 
18626
- // src/utils/has-newline-in-range.js
18635
+ // src/utilities/has-newline-in-range.js
18627
18636
  function hasNewlineInRange(text, startIndex, endIndex) {
18628
18637
  for (let i = startIndex; i < endIndex; ++i) {
18629
18638
  if (text.charAt(i) === "\n") {
@@ -18634,7 +18643,7 @@ function hasNewlineInRange(text, startIndex, endIndex) {
18634
18643
  }
18635
18644
  var has_newline_in_range_default = hasNewlineInRange;
18636
18645
 
18637
- // src/utils/has-spaces.js
18646
+ // src/utilities/has-spaces.js
18638
18647
  function hasSpaces(text, startIndex, options8 = {}) {
18639
18648
  const idx = skipSpaces(
18640
18649
  text,
@@ -18645,7 +18654,7 @@ function hasSpaces(text, startIndex, options8 = {}) {
18645
18654
  }
18646
18655
  var has_spaces_default = hasSpaces;
18647
18656
 
18648
- // src/utils/public.js
18657
+ // src/utilities/public.js
18649
18658
  function legacyGetNextNonSpaceNonCommentCharacterIndex(text, node, locEnd) {
18650
18659
  return get_next_non_space_non_comment_character_index_default(text, locEnd(node));
18651
18660
  }
@@ -18752,7 +18761,7 @@ var sharedWithCli = {
18752
18761
  createTwoFilesPatch,
18753
18762
  picocolors: import_picocolors5.default,
18754
18763
  closetLevenshteinMatch: closestMatch,
18755
- utils: {
18764
+ utilities: {
18756
18765
  omit: object_omit_default,
18757
18766
  createMockable: create_mockable_default
18758
18767
  }
@@ -2147,7 +2147,7 @@ var init_constants_evaluate = __esm({
2147
2147
  "angular",
2148
2148
  "lwc"
2149
2149
  ];
2150
- PRETTIER_VERSION = "3.7.3";
2150
+ PRETTIER_VERSION = "3.8.0";
2151
2151
  }
2152
2152
  });
2153
2153
 
@@ -1229,7 +1229,7 @@ function camelCase(input, options) {
1229
1229
  return leadingPrefix + postProcess(input, toUpperCase, options);
1230
1230
  }
1231
1231
 
1232
- // src/cli/utils.js
1232
+ // src/cli/utilities.js
1233
1233
  import fs from "fs/promises";
1234
1234
  import path from "path";
1235
1235
 
@@ -1262,7 +1262,7 @@ sdbm.bigint = function(input, options) {
1262
1262
  return BigInt.asUintN(64, sdbmHash(input, options));
1263
1263
  };
1264
1264
 
1265
- // src/cli/utils.js
1265
+ // src/cli/utilities.js
1266
1266
  import { __internal as sharedWithCli2 } from "../index.mjs";
1267
1267
  var printToScreen = console.log.bind(console);
1268
1268
  function groupBy(array, iteratee) {
@@ -1319,7 +1319,7 @@ var normalizeToPosix = path.sep === "\\" ? (filepath) => method_replace_all_defa
1319
1319
  ) : (filepath) => filepath;
1320
1320
  var {
1321
1321
  omit
1322
- } = sharedWithCli2.utils;
1322
+ } = sharedWithCli2.utilities;
1323
1323
 
1324
1324
  // src/cli/options/create-minimist-options.js
1325
1325
  function createMinimistOptions(detailedOptions) {
@@ -5441,7 +5441,7 @@ function clearStreamText(stream, text) {
5441
5441
  var clear_stream_text_default = clearStreamText;
5442
5442
 
5443
5443
  // src/cli/mockable.js
5444
- var mockable = sharedWithCli3.utils.createMockable({
5444
+ var mockable = sharedWithCli3.utilities.createMockable({
5445
5445
  clearStreamText: clear_stream_text_default,
5446
5446
  getTimestamp: performance.now.bind(performance),
5447
5447
  isCI: () => import_ci_info.isCI,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prettier",
3
- "version": "3.7.3",
3
+ "version": "3.8.0",
4
4
  "description": "Prettier is an opinionated code formatter",
5
5
  "bin": "./bin/prettier.cjs",
6
6
  "repository": "prettier/prettier",