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
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/doc.d.ts ADDED
@@ -0,0 +1,248 @@
1
+ // https://github.com/prettier/prettier/blob/next/src/document/index.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 debug {
187
+ function printDocToDebug(doc: builders.Doc): string;
188
+ }
189
+
190
+ export namespace printer {
191
+ function printDocToString(
192
+ doc: builders.Doc,
193
+ options: Options
194
+ ): {
195
+ formatted: string;
196
+ cursorNodeStart?: number | undefined;
197
+ cursorNodeText?: string | undefined;
198
+ };
199
+ interface Options {
200
+ /**
201
+ * Specify the line length that the printer will wrap on.
202
+ * @default 80
203
+ */
204
+ printWidth: number;
205
+ /**
206
+ * Specify the number of spaces per indentation-level.
207
+ * @default 2
208
+ */
209
+ tabWidth: number;
210
+ /**
211
+ * Indent lines with tabs instead of spaces
212
+ * @default false
213
+ */
214
+ useTabs: boolean;
215
+ parentParser?: string | undefined;
216
+ __embeddedInHtml?: boolean | undefined;
217
+ }
218
+ }
219
+
220
+ export namespace utils {
221
+ function getDocParts(doc: builders.Doc): builders.Doc;
222
+ function willBreak(doc: builders.Doc): boolean;
223
+ function traverseDoc(
224
+ doc: builders.Doc,
225
+ onEnter?: (doc: builders.Doc) => void | boolean,
226
+ onExit?: (doc: builders.Doc) => void,
227
+ shouldTraverseConditionalGroups?: boolean
228
+ ): void;
229
+ function findInDoc<T = builders.Doc>(
230
+ doc: builders.Doc,
231
+ callback: (doc: builders.Doc) => T,
232
+ defaultValue: T
233
+ ): T;
234
+ function mapDoc<T = builders.Doc>(
235
+ doc: builders.Doc,
236
+ callback: (doc: builders.Doc) => T
237
+ ): T;
238
+ function propagateBreaks(doc: builders.Doc): void;
239
+ function removeLines(doc: builders.Doc): builders.Doc;
240
+ function stripTrailingHardline(doc: builders.Doc): builders.Doc;
241
+ function cleanDoc(doc: builders.Doc): builders.Doc;
242
+ function replaceEndOfLine(
243
+ doc: builders.Doc,
244
+ replacement?: builders.Doc
245
+ ): builders.Doc;
246
+ function canBreak(doc: builders.Doc): boolean;
247
+ function getDocType(doc: builders.Doc): string;
248
+ }