prettier 3.0.0-alpha.1 → 3.0.0-alpha.10

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 (57) hide show
  1. package/LICENSE +910 -759
  2. package/README.md +3 -3
  3. package/bin/prettier.cjs +0 -0
  4. package/doc.d.ts +240 -0
  5. package/doc.js +351 -479
  6. package/doc.mjs +342 -474
  7. package/index.cjs +400 -230
  8. package/index.d.ts +921 -0
  9. package/index.mjs +17218 -32209
  10. package/internal/cli.mjs +4374 -10823
  11. package/internal/internal.mjs +6437 -0
  12. package/package.json +55 -13
  13. package/plugins/acorn.d.ts +6 -0
  14. package/plugins/acorn.js +13 -0
  15. package/plugins/acorn.mjs +13 -0
  16. package/plugins/angular.d.ts +8 -0
  17. package/plugins/angular.js +2 -2
  18. package/plugins/angular.mjs +2 -2
  19. package/plugins/babel.d.ts +17 -0
  20. package/plugins/babel.js +12 -12
  21. package/plugins/babel.mjs +12 -12
  22. package/plugins/estree.d.ts +0 -0
  23. package/plugins/estree.js +35 -0
  24. package/plugins/estree.mjs +35 -0
  25. package/plugins/flow.d.ts +5 -0
  26. package/plugins/flow.js +20 -20
  27. package/plugins/flow.mjs +20 -20
  28. package/plugins/glimmer.d.ts +5 -0
  29. package/plugins/glimmer.js +22 -17
  30. package/plugins/glimmer.mjs +22 -17
  31. package/plugins/graphql.d.ts +5 -0
  32. package/plugins/graphql.js +16 -7
  33. package/plugins/graphql.mjs +16 -7
  34. package/plugins/html.d.ts +8 -0
  35. package/plugins/html.js +19 -29
  36. package/plugins/html.mjs +19 -29
  37. package/plugins/markdown.d.ts +7 -0
  38. package/plugins/markdown.js +54 -34
  39. package/plugins/markdown.mjs +54 -34
  40. package/plugins/meriyah.d.ts +5 -0
  41. package/plugins/meriyah.js +5 -6
  42. package/plugins/meriyah.mjs +5 -6
  43. package/plugins/postcss.d.ts +7 -0
  44. package/plugins/postcss.js +45 -43
  45. package/plugins/postcss.mjs +45 -43
  46. package/plugins/typescript.d.ts +5 -0
  47. package/plugins/typescript.js +24 -239
  48. package/plugins/typescript.mjs +24 -239
  49. package/plugins/yaml.d.ts +5 -0
  50. package/plugins/yaml.js +148 -135
  51. package/plugins/yaml.mjs +148 -135
  52. package/standalone.d.ts +33 -0
  53. package/standalone.js +35 -105
  54. package/standalone.mjs +35 -105
  55. package/internal/third-party.mjs +0 -9071
  56. package/plugins/acorn-and-espree.js +0 -13
  57. package/plugins/acorn-and-espree.mjs +0 -13
@@ -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>;