prettier 3.0.0-alpha.1 → 3.0.0-alpha.11

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 +919 -0
  9. package/index.mjs +18129 -32123
  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 +23 -18
  30. package/plugins/glimmer.mjs +23 -18
  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 +52 -32
  39. package/plugins/markdown.mjs +52 -32
  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 +146 -133
  51. package/plugins/yaml.mjs +146 -133
  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
package/README.md CHANGED
@@ -38,11 +38,11 @@
38
38
 
39
39
  <p align="center">
40
40
  <a href="https://github.com/prettier/prettier/actions?query=workflow%3AProd+branch%3Amain">
41
- <img alt="Github Actions Build Status" src="https://img.shields.io/github/workflow/status/prettier/prettier/Prod?label=Prod&style=flat-square"></a>
41
+ <img alt="Github Actions Build Status" src="https://img.shields.io/github/actions/workflow/status/prettier/prettier/prod-test.yml?label=Prod&style=flat-square"></a>
42
42
  <a href="https://github.com/prettier/prettier/actions?query=workflow%3ADev+branch%3Amain">
43
- <img alt="Github Actions Build Status" src="https://img.shields.io/github/workflow/status/prettier/prettier/Dev?label=Dev&style=flat-square"></a>
43
+ <img alt="Github Actions Build Status" src="https://img.shields.io/github/actions/workflow/status/prettier/prettier/dev-test.yml?label=Dev&style=flat-square"></a>
44
44
  <a href="https://github.com/prettier/prettier/actions?query=workflow%3ALint+branch%3Amain">
45
- <img alt="Github Actions Build Status" src="https://img.shields.io/github/workflow/status/prettier/prettier/Lint?label=Lint&style=flat-square"></a>
45
+ <img alt="Github Actions Build Status" src="https://img.shields.io/github/actions/workflow/status/prettier/prettier/lint.yml?label=Lint&style=flat-square"></a>
46
46
  <a href="https://codecov.io/gh/prettier/prettier">
47
47
  <img alt="Codecov Coverage Status" src="https://img.shields.io/codecov/c/github/prettier/prettier.svg?style=flat-square"></a>
48
48
  <a href="https://twitter.com/acdlite/status/974390255393505280">
package/bin/prettier.cjs CHANGED
File without changes
package/doc.d.ts ADDED
@@ -0,0 +1,240 @@
1
+ // https://github.com/prettier/prettier/blob/next/src/document/public.js
2
+ export namespace builders {
3
+ type DocCommand =
4
+ | Align
5
+ | BreakParent
6
+ | Cursor
7
+ | Fill
8
+ | Group
9
+ | IfBreak
10
+ | Indent
11
+ | IndentIfBreak
12
+ | Label
13
+ | Line
14
+ | LineSuffix
15
+ | LineSuffixBoundary
16
+ | Trim;
17
+ type Doc = string | Doc[] | DocCommand;
18
+
19
+ interface Align {
20
+ type: "align";
21
+ contents: Doc;
22
+ n: number | string | { type: "root" };
23
+ }
24
+
25
+ interface BreakParent {
26
+ type: "break-parent";
27
+ }
28
+
29
+ interface Cursor {
30
+ type: "cursor";
31
+ placeholder: symbol;
32
+ }
33
+
34
+ interface Fill {
35
+ type: "fill";
36
+ parts: Doc[];
37
+ }
38
+
39
+ interface Group {
40
+ type: "group";
41
+ contents: Doc;
42
+ break: boolean;
43
+ expandedStates: Doc[];
44
+ }
45
+
46
+ interface HardlineWithoutBreakParent extends Line {
47
+ hard: true;
48
+ }
49
+
50
+ interface IfBreak {
51
+ type: "if-break";
52
+ breakContents: Doc;
53
+ flatContents: Doc;
54
+ }
55
+
56
+ interface Indent {
57
+ type: "indent";
58
+ contents: Doc;
59
+ }
60
+
61
+ interface IndentIfBreak {
62
+ type: "indent-if-break";
63
+ }
64
+
65
+ interface Label {
66
+ type: "label";
67
+ }
68
+
69
+ interface Line {
70
+ type: "line";
71
+ soft?: boolean | undefined;
72
+ hard?: boolean | undefined;
73
+ literal?: boolean | undefined;
74
+ }
75
+
76
+ interface LineSuffix {
77
+ type: "line-suffix";
78
+ contents: Doc;
79
+ }
80
+
81
+ interface LineSuffixBoundary {
82
+ type: "line-suffix-boundary";
83
+ }
84
+
85
+ interface LiterallineWithoutBreakParent extends Line {
86
+ hard: true;
87
+ literal: true;
88
+ }
89
+
90
+ type LiteralLine = [LiterallineWithoutBreakParent, BreakParent];
91
+
92
+ interface Softline extends Line {
93
+ soft: true;
94
+ }
95
+
96
+ type Hardline = [HardlineWithoutBreakParent, BreakParent];
97
+
98
+ interface Trim {
99
+ type: "trim";
100
+ }
101
+
102
+ interface GroupOptions {
103
+ shouldBreak?: boolean | undefined;
104
+ id?: symbol | undefined;
105
+ }
106
+
107
+ function addAlignmentToDoc(doc: Doc, size: number, tabWidth: number): Doc;
108
+
109
+ /** @see [align](https://github.com/prettier/prettier/blob/main/commands.md#align) */
110
+ function align(widthOrString: Align["n"], doc: Doc): Align;
111
+
112
+ /** @see [breakParent](https://github.com/prettier/prettier/blob/main/commands.md#breakparent) */
113
+ const breakParent: BreakParent;
114
+
115
+ /** @see [conditionalGroup](https://github.com/prettier/prettier/blob/main/commands.md#conditionalgroup) */
116
+ function conditionalGroup(alternatives: Doc[], options?: GroupOptions): Group;
117
+
118
+ /** @see [dedent](https://github.com/prettier/prettier/blob/main/commands.md#dedent) */
119
+ function dedent(doc: Doc): Align;
120
+
121
+ /** @see [dedentToRoot](https://github.com/prettier/prettier/blob/main/commands.md#dedenttoroot) */
122
+ function dedentToRoot(doc: Doc): Align;
123
+
124
+ /** @see [fill](https://github.com/prettier/prettier/blob/main/commands.md#fill) */
125
+ function fill(docs: Doc[]): Fill;
126
+
127
+ /** @see [group](https://github.com/prettier/prettier/blob/main/commands.md#group) */
128
+ function group(doc: Doc, opts?: GroupOptions): Group;
129
+
130
+ /** @see [hardline](https://github.com/prettier/prettier/blob/main/commands.md#hardline) */
131
+ const hardline: Hardline;
132
+
133
+ /** @see [hardlineWithoutBreakParent](https://github.com/prettier/prettier/blob/main/commands.md#hardlinewithoutbreakparent-and-literallinewithoutbreakparent) */
134
+ const hardlineWithoutBreakParent: HardlineWithoutBreakParent;
135
+
136
+ /** @see [ifBreak](https://github.com/prettier/prettier/blob/main/commands.md#ifbreak) */
137
+ function ifBreak(
138
+ ifBreak: Doc,
139
+ noBreak?: Doc,
140
+ options?: { groupId?: symbol | undefined }
141
+ ): IfBreak;
142
+
143
+ /** @see [indent](https://github.com/prettier/prettier/blob/main/commands.md#indent) */
144
+ function indent(doc: Doc): Indent;
145
+
146
+ /** @see [indentIfBreak](https://github.com/prettier/prettier/blob/main/commands.md#indentifbreak) */
147
+ function indentIfBreak(
148
+ doc: Doc,
149
+ opts: { groupId: symbol; negate?: boolean | undefined }
150
+ ): IndentIfBreak;
151
+
152
+ /** @see [join](https://github.com/prettier/prettier/blob/main/commands.md#join) */
153
+ function join(sep: Doc, docs: Doc[]): Doc[];
154
+
155
+ /** @see [label](https://github.com/prettier/prettier/blob/main/commands.md#label) */
156
+ function label(label: any | undefined, contents: Doc): Doc;
157
+
158
+ /** @see [line](https://github.com/prettier/prettier/blob/main/commands.md#line) */
159
+ const line: Line;
160
+
161
+ /** @see [lineSuffix](https://github.com/prettier/prettier/blob/main/commands.md#linesuffix) */
162
+ function lineSuffix(suffix: Doc): LineSuffix;
163
+
164
+ /** @see [lineSuffixBoundary](https://github.com/prettier/prettier/blob/main/commands.md#linesuffixboundary) */
165
+ const lineSuffixBoundary: LineSuffixBoundary;
166
+
167
+ /** @see [literalline](https://github.com/prettier/prettier/blob/main/commands.md#literalline) */
168
+ const literalline: LiteralLine;
169
+
170
+ /** @see [literallineWithoutBreakParent](https://github.com/prettier/prettier/blob/main/commands.md#hardlinewithoutbreakparent-and-literallinewithoutbreakparent) */
171
+ const literallineWithoutBreakParent: LiterallineWithoutBreakParent;
172
+
173
+ /** @see [markAsRoot](https://github.com/prettier/prettier/blob/main/commands.md#markasroot) */
174
+ function markAsRoot(doc: Doc): Align;
175
+
176
+ /** @see [softline](https://github.com/prettier/prettier/blob/main/commands.md#softline) */
177
+ const softline: Softline;
178
+
179
+ /** @see [trim](https://github.com/prettier/prettier/blob/main/commands.md#trim) */
180
+ const trim: Trim;
181
+
182
+ /** @see [cursor](https://github.com/prettier/prettier/blob/main/commands.md#cursor) */
183
+ const cursor: Cursor;
184
+ }
185
+
186
+ export namespace printer {
187
+ function printDocToString(
188
+ doc: builders.Doc,
189
+ options: Options
190
+ ): {
191
+ formatted: string;
192
+ cursorNodeStart?: number | undefined;
193
+ cursorNodeText?: string | undefined;
194
+ };
195
+ interface Options {
196
+ /**
197
+ * Specify the line length that the printer will wrap on.
198
+ * @default 80
199
+ */
200
+ printWidth: number;
201
+ /**
202
+ * Specify the number of spaces per indentation-level.
203
+ * @default 2
204
+ */
205
+ tabWidth: number;
206
+ /**
207
+ * Indent lines with tabs instead of spaces
208
+ * @default false
209
+ */
210
+ useTabs?: boolean;
211
+ parentParser?: string | undefined;
212
+ __embeddedInHtml?: boolean | undefined;
213
+ }
214
+ }
215
+
216
+ export namespace utils {
217
+ function willBreak(doc: builders.Doc): boolean;
218
+ function traverseDoc(
219
+ doc: builders.Doc,
220
+ onEnter?: (doc: builders.Doc) => void | boolean,
221
+ onExit?: (doc: builders.Doc) => void,
222
+ shouldTraverseConditionalGroups?: boolean
223
+ ): void;
224
+ function findInDoc<T = builders.Doc>(
225
+ doc: builders.Doc,
226
+ callback: (doc: builders.Doc) => T,
227
+ defaultValue: T
228
+ ): T;
229
+ function mapDoc<T = builders.Doc>(
230
+ doc: builders.Doc,
231
+ callback: (doc: builders.Doc) => T
232
+ ): T;
233
+ function removeLines(doc: builders.Doc): builders.Doc;
234
+ function stripTrailingHardline(doc: builders.Doc): builders.Doc;
235
+ function replaceEndOfLine(
236
+ doc: builders.Doc,
237
+ replacement?: builders.Doc
238
+ ): builders.Doc;
239
+ function canBreak(doc: builders.Doc): boolean;
240
+ }