prettier 3.0.0-alpha.3 → 3.0.0-alpha.5

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.
Files changed (50) hide show
  1. package/LICENSE +875 -677
  2. package/README.md +3 -3
  3. package/doc.d.ts +248 -0
  4. package/doc.js +314 -246
  5. package/doc.mjs +309 -241
  6. package/index.cjs +399 -229
  7. package/index.d.ts +903 -0
  8. package/index.mjs +18131 -16873
  9. package/internal/cli.mjs +3958 -10433
  10. package/internal/third-party.mjs +2948 -5593
  11. package/package.json +32 -1
  12. package/plugins/acorn-and-espree.d.ts +10 -0
  13. package/plugins/acorn-and-espree.js +12 -12
  14. package/plugins/acorn-and-espree.mjs +12 -12
  15. package/plugins/angular.d.ts +11 -0
  16. package/plugins/angular.js +2 -2
  17. package/plugins/angular.mjs +2 -2
  18. package/plugins/babel.d.ts +16 -0
  19. package/plugins/babel.js +12 -12
  20. package/plugins/babel.mjs +12 -12
  21. package/plugins/flow.d.ts +8 -0
  22. package/plugins/flow.js +20 -20
  23. package/plugins/flow.mjs +20 -20
  24. package/plugins/glimmer.d.ts +8 -0
  25. package/plugins/glimmer.js +18 -18
  26. package/plugins/glimmer.mjs +18 -18
  27. package/plugins/graphql.d.ts +8 -0
  28. package/plugins/graphql.js +7 -7
  29. package/plugins/graphql.mjs +7 -7
  30. package/plugins/html.d.ts +11 -0
  31. package/plugins/html.js +17 -28
  32. package/plugins/html.mjs +17 -28
  33. package/plugins/markdown.d.ts +10 -0
  34. package/plugins/markdown.js +28 -29
  35. package/plugins/markdown.mjs +28 -29
  36. package/plugins/meriyah.d.ts +8 -0
  37. package/plugins/meriyah.js +5 -6
  38. package/plugins/meriyah.mjs +5 -6
  39. package/plugins/postcss.d.ts +10 -0
  40. package/plugins/postcss.js +32 -43
  41. package/plugins/postcss.mjs +32 -43
  42. package/plugins/typescript.d.ts +8 -0
  43. package/plugins/typescript.js +18 -231
  44. package/plugins/typescript.mjs +18 -231
  45. package/plugins/yaml.d.ts +8 -0
  46. package/plugins/yaml.js +108 -108
  47. package/plugins/yaml.mjs +108 -108
  48. package/standalone.d.ts +33 -0
  49. package/standalone.js +77 -83
  50. package/standalone.mjs +77 -83
@@ -0,0 +1,33 @@
1
+ import { CursorOptions, CursorResult, Options, SupportInfo } from "./index.js";
2
+
3
+ /**
4
+ * formatWithCursor both formats the code, and translates a cursor position from unformatted code to formatted code.
5
+ * This is useful for editor integrations, to prevent the cursor from moving when code is formatted
6
+ *
7
+ * The cursorOffset option should be provided, to specify where the cursor is. This option cannot be used with rangeStart and rangeEnd.
8
+ *
9
+ * ```js
10
+ * await prettier.formatWithCursor(" 1", { cursorOffset: 2, parser: "babel" });
11
+ * ```
12
+ * `-> { formatted: "1;\n", cursorOffset: 1 }`
13
+ */
14
+ export function formatWithCursor(
15
+ source: string,
16
+ options: CursorOptions
17
+ ): Promise<CursorResult>;
18
+
19
+ /**
20
+ * `format` is used to format text using Prettier. [Options](https://prettier.io/docs/en/options.html) may be provided to override the defaults.
21
+ */
22
+ export function format(source: string, options?: Options): Promise<string>;
23
+
24
+ /**
25
+ * `check` checks to see if the file has been formatted with Prettier given those options and returns a `Boolean`.
26
+ * This is similar to the `--list-different` parameter in the CLI and is useful for running Prettier in CI scenarios.
27
+ */
28
+ export function check(source: string, options?: Options): Promise<boolean>;
29
+
30
+ /**
31
+ * Returns an object representing the parsers, languages and file types Prettier supports for the current version.
32
+ */
33
+ export function getSupportInfo(): Promise<SupportInfo>;