prettier 3.5.3 → 3.6.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/bin/prettier.cjs CHANGED
@@ -60,9 +60,21 @@ if (typeof nodeModule.enableCompileCache === "function") {
60
60
  var pleaseUpgradeNode = require_please_upgrade_node();
61
61
  var packageJson = require("../package.json");
62
62
  pleaseUpgradeNode(packageJson);
63
- function runCli(cli) {
64
- return cli.run();
65
- }
66
63
  var dynamicImport = new Function("module", "return import(module)");
67
- var promise = dynamicImport("../internal/cli.mjs").then(runCli);
64
+ var promise;
65
+ var index = process.argv.indexOf("--experimental-cli");
66
+ if (process.env.PRETTIER_EXPERIMENTAL_CLI || index !== -1) {
67
+ if (index !== -1) {
68
+ process.argv.splice(index, 1);
69
+ }
70
+ promise = dynamicImport("../internal/experimental-cli.mjs").then(
71
+ function(cli) {
72
+ return cli.__promise;
73
+ }
74
+ );
75
+ } else {
76
+ promise = dynamicImport("../internal/legacy-cli.mjs").then(function runCli(cli) {
77
+ return cli.run();
78
+ });
79
+ }
68
80
  module.exports.__promise = promise;
package/doc.js CHANGED
@@ -91,6 +91,15 @@
91
91
  };
92
92
  var at_default = at;
93
93
 
94
+ // node_modules/trim-newlines/index.js
95
+ function trimNewlinesEnd(string) {
96
+ let end = string.length;
97
+ while (end > 0 && (string[end - 1] === "\r" || string[end - 1] === "\n")) {
98
+ end--;
99
+ }
100
+ return end < string.length ? string.slice(0, end) : string;
101
+ }
102
+
94
103
  // src/document/utils/get-doc-type.js
95
104
  function getDocType(doc) {
96
105
  if (typeof doc === "string") {
@@ -390,7 +399,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
390
399
  case DOC_TYPE_ARRAY:
391
400
  return stripTrailingHardlineFromParts(doc);
392
401
  case DOC_TYPE_STRING:
393
- return doc.replace(/[\n\r]*$/u, "");
402
+ return trimNewlinesEnd(doc);
394
403
  case DOC_TYPE_ALIGN:
395
404
  case DOC_TYPE_CURSOR:
396
405
  case DOC_TYPE_TRIM:
package/doc.mjs CHANGED
@@ -56,6 +56,15 @@ var at = (isOptionalObject, object, index) => {
56
56
  };
57
57
  var at_default = at;
58
58
 
59
+ // node_modules/trim-newlines/index.js
60
+ function trimNewlinesEnd(string) {
61
+ let end = string.length;
62
+ while (end > 0 && (string[end - 1] === "\r" || string[end - 1] === "\n")) {
63
+ end--;
64
+ }
65
+ return end < string.length ? string.slice(0, end) : string;
66
+ }
67
+
59
68
  // src/document/utils/get-doc-type.js
60
69
  function getDocType(doc) {
61
70
  if (typeof doc === "string") {
@@ -355,7 +364,7 @@ function stripTrailingHardlineFromDoc(doc) {
355
364
  case DOC_TYPE_ARRAY:
356
365
  return stripTrailingHardlineFromParts(doc);
357
366
  case DOC_TYPE_STRING:
358
- return doc.replace(/[\n\r]*$/u, "");
367
+ return trimNewlinesEnd(doc);
359
368
  case DOC_TYPE_ALIGN:
360
369
  case DOC_TYPE_CURSOR:
361
370
  case DOC_TYPE_TRIM:
package/index.cjs CHANGED
@@ -8,9 +8,6 @@ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
8
  var __esm = (fn, res) => function __init() {
9
9
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
10
  };
11
- var __commonJS = (cb, mod) => function __require() {
12
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
13
- };
14
11
  var __export = (target, all) => {
15
12
  for (var name in all)
16
13
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -608,10 +605,15 @@ var init_public = __esm({
608
605
  }
609
606
  });
610
607
 
611
- // src/main/version.evaluate.cjs
612
- var require_version_evaluate = __commonJS({
613
- "src/main/version.evaluate.cjs"(exports2, module2) {
614
- module2.exports = "3.5.3";
608
+ // src/main/version.evaluate.js
609
+ var version_evaluate_exports = {};
610
+ __export(version_evaluate_exports, {
611
+ default: () => version_evaluate_default
612
+ });
613
+ var version_evaluate_default;
614
+ var init_version_evaluate = __esm({
615
+ "src/main/version.evaluate.js"() {
616
+ version_evaluate_default = "3.6.1";
615
617
  }
616
618
  });
617
619
 
@@ -652,6 +654,7 @@ prettier.__debug = debugApis;
652
654
  if (true) {
653
655
  prettier.util = (init_public(), __toCommonJS(public_exports));
654
656
  prettier.doc = require("./doc.js");
657
+ prettier.version = (init_version_evaluate(), __toCommonJS(version_evaluate_exports)).default;
655
658
  } else {
656
659
  Object.defineProperties(prettier, {
657
660
  util: {
@@ -677,6 +680,6 @@ if (true) {
677
680
  }
678
681
  }
679
682
  });
683
+ prettier.version = null.version;
680
684
  }
681
- prettier.version = require_version_evaluate();
682
685
  module.exports = prettier;
package/index.d.ts CHANGED
@@ -296,6 +296,7 @@ export type BuiltInParserName =
296
296
  | "markdown"
297
297
  | "mdx"
298
298
  | "meriyah"
299
+ | "mjml"
299
300
  | "scss"
300
301
  | "typescript"
301
302
  | "vue"
@@ -384,6 +385,11 @@ export interface RequiredOptions extends doc.printer.Options {
384
385
  * @default false
385
386
  */
386
387
  insertPragma: boolean;
388
+ /**
389
+ * Prettier can allow individual files to opt out of formatting if they contain a special comment, called a pragma, at the top of the file.
390
+ * @default false
391
+ */
392
+ checkIgnorePragma: boolean;
387
393
  /**
388
394
  * By default, Prettier will wrap markdown text as-is since some services use a linebreak-sensitive renderer.
389
395
  * In some cases you may want to rely on editor/viewer soft wrapping instead, so this option allows you to opt out.
@@ -398,7 +404,7 @@ export interface RequiredOptions extends doc.printer.Options {
398
404
  /**
399
405
  * Provide ability to support new languages to prettier.
400
406
  */
401
- plugins: Array<string | Plugin>;
407
+ plugins: Array<string | URL | Plugin>;
402
408
  /**
403
409
  * How to handle whitespaces in HTML.
404
410
  * @default "css"
@@ -470,6 +476,7 @@ export interface Parser<T = any> {
470
476
  parse: (text: string, options: ParserOptions<T>) => T | Promise<T>;
471
477
  astFormat: string;
472
478
  hasPragma?: ((text: string) => boolean) | undefined;
479
+ hasIgnorePragma?: ((text: string) => boolean) | undefined;
473
480
  locStart: (node: T) => number;
474
481
  locEnd: (node: T) => number;
475
482
  preprocess?:
@@ -607,7 +614,7 @@ export interface ResolveConfigOptions {
607
614
  /**
608
615
  * Pass directly the path of the config file if you don't wish to search for it.
609
616
  */
610
- config?: string | undefined;
617
+ config?: string | URL | undefined;
611
618
  /**
612
619
  * If set to `true` and an `.editorconfig` file is in your project,
613
620
  * Prettier will parse it and convert its properties to the corresponding prettier configuration.
@@ -660,7 +667,6 @@ export function clearConfigCache(): Promise<void>;
660
667
 
661
668
  export interface SupportLanguage {
662
669
  name: string;
663
- since?: string | undefined;
664
670
  parsers: BuiltInParserName[] | string[];
665
671
  group?: string | undefined;
666
672
  tmScope?: string | undefined;
@@ -673,6 +679,7 @@ export interface SupportLanguage {
673
679
  linguistLanguageId?: number | undefined;
674
680
  vscodeLanguageIds?: string[] | undefined;
675
681
  interpreters?: string[] | undefined;
682
+ isSupported?: ((options: { filepath: string }) => boolean) | undefined;
676
683
  }
677
684
 
678
685
  export interface SupportOptionRange {
@@ -764,7 +771,6 @@ export interface ChoiceSupportOption<Value = any>
764
771
  default?: Value | Array<{ value: Value }> | undefined;
765
772
  description: string;
766
773
  choices: Array<{
767
- since?: string | undefined;
768
774
  value: Value;
769
775
  description: string;
770
776
  }>;
@@ -801,7 +807,7 @@ export interface SupportInfo {
801
807
  export interface FileInfoOptions {
802
808
  ignorePath?: string | URL | (string | URL)[] | undefined;
803
809
  withNodeModules?: boolean | undefined;
804
- plugins?: Array<string | Plugin> | undefined;
810
+ plugins?: Array<string | URL | Plugin> | undefined;
805
811
  resolveConfig?: boolean | undefined;
806
812
  }
807
813
 
@@ -816,7 +822,7 @@ export function getFileInfo(
816
822
  ): Promise<FileInfoResult>;
817
823
 
818
824
  export interface SupportInfoOptions {
819
- plugins?: Array<string | Plugin> | undefined;
825
+ plugins?: Array<string | URL | Plugin> | undefined;
820
826
  showDeprecated?: boolean | undefined;
821
827
  }
822
828