prettier 3.0.0-alpha.9-for-vscode → 3.0.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/LICENSE +66 -149
- package/README.md +2 -2
- package/bin/prettier.cjs +0 -0
- package/doc.d.ts +7 -7
- package/doc.js +35 -86
- package/doc.mjs +48 -94
- package/index.cjs +440 -20576
- package/index.d.ts +55 -55
- package/index.mjs +7272 -6575
- package/internal/cli.mjs +52 -45
- package/internal/internal.mjs +171 -77
- package/package.json +4 -7
- package/plugins/acorn.js +12 -12
- package/plugins/acorn.mjs +12 -12
- package/plugins/angular.d.ts +1 -1
- package/plugins/angular.js +2 -2
- package/plugins/angular.mjs +2 -2
- package/plugins/babel.js +12 -12
- package/plugins/babel.mjs +12 -12
- package/plugins/estree.d.ts +1 -0
- package/plugins/estree.js +30 -30
- package/plugins/estree.mjs +30 -30
- package/plugins/flow.js +17 -17
- package/plugins/flow.mjs +17 -17
- package/plugins/glimmer.js +22 -22
- package/plugins/glimmer.mjs +22 -22
- package/plugins/graphql.js +26 -15
- package/plugins/graphql.mjs +26 -15
- package/plugins/html.d.ts +2 -2
- package/plugins/html.js +16 -16
- package/plugins/html.mjs +16 -16
- package/plugins/markdown.d.ts +1 -1
- package/plugins/markdown.js +49 -49
- package/plugins/markdown.mjs +49 -49
- package/plugins/meriyah.js +5 -5
- package/plugins/meriyah.mjs +5 -5
- package/plugins/postcss.js +46 -46
- package/plugins/postcss.mjs +46 -46
- package/plugins/typescript.js +20 -22
- package/plugins/typescript.mjs +20 -22
- package/plugins/yaml.js +104 -104
- package/plugins/yaml.mjs +104 -104
- package/standalone.d.ts +1 -1
- package/standalone.js +31 -30
- package/standalone.mjs +31 -30
- package/internal/internal.cjs +0 -6430
package/index.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ type ArrayElement<T> = T extends Array<infer E> ? E : never;
|
|
|
33
33
|
|
|
34
34
|
// A union of the properties of the given object that are arrays.
|
|
35
35
|
type ArrayProperties<T> = {
|
|
36
|
-
[K in keyof T]: NonNullable<T[K]> extends any[] ? K : never;
|
|
36
|
+
[K in keyof T]: NonNullable<T[K]> extends readonly any[] ? K : never;
|
|
37
37
|
}[keyof T];
|
|
38
38
|
|
|
39
39
|
// A union of the properties of the given array T that can be used to index it.
|
|
@@ -72,12 +72,12 @@ type CallCallback<T, U> = (path: AstPath<T>, index: number, value: any) => U;
|
|
|
72
72
|
type EachCallback<T> = (
|
|
73
73
|
path: AstPath<ArrayElement<T>>,
|
|
74
74
|
index: number,
|
|
75
|
-
value: any
|
|
75
|
+
value: any,
|
|
76
76
|
) => void;
|
|
77
77
|
type MapCallback<T, U> = (
|
|
78
78
|
path: AstPath<ArrayElement<T>>,
|
|
79
79
|
index: number,
|
|
80
|
-
value: any
|
|
80
|
+
value: any,
|
|
81
81
|
) => U;
|
|
82
82
|
|
|
83
83
|
// https://github.com/prettier/prettier/blob/next/src/common/ast-path.js
|
|
@@ -136,18 +136,18 @@ export class AstPath<T = any> {
|
|
|
136
136
|
call<U>(callback: CallCallback<T, U>): U;
|
|
137
137
|
call<U, P1 extends CallProperties<T>>(
|
|
138
138
|
callback: CallCallback<IndexValue<T, P1>, U>,
|
|
139
|
-
prop1: P1
|
|
139
|
+
prop1: P1,
|
|
140
140
|
): U;
|
|
141
141
|
call<U, P1 extends keyof T, P2 extends CallProperties<T[P1]>>(
|
|
142
142
|
callback: CallCallback<IndexValue<IndexValue<T, P1>, P2>, U>,
|
|
143
143
|
prop1: P1,
|
|
144
|
-
prop2: P2
|
|
144
|
+
prop2: P2,
|
|
145
145
|
): U;
|
|
146
146
|
call<
|
|
147
147
|
U,
|
|
148
148
|
P1 extends keyof T,
|
|
149
149
|
P2 extends CallProperties<T[P1]>,
|
|
150
|
-
P3 extends CallProperties<IndexValue<T[P1], P2
|
|
150
|
+
P3 extends CallProperties<IndexValue<T[P1], P2>>,
|
|
151
151
|
>(
|
|
152
152
|
callback: CallCallback<
|
|
153
153
|
IndexValue<IndexValue<IndexValue<T, P1>, P2>, P3>,
|
|
@@ -155,14 +155,14 @@ export class AstPath<T = any> {
|
|
|
155
155
|
>,
|
|
156
156
|
prop1: P1,
|
|
157
157
|
prop2: P2,
|
|
158
|
-
prop3: P3
|
|
158
|
+
prop3: P3,
|
|
159
159
|
): U;
|
|
160
160
|
call<
|
|
161
161
|
U,
|
|
162
162
|
P1 extends keyof T,
|
|
163
163
|
P2 extends CallProperties<T[P1]>,
|
|
164
164
|
P3 extends CallProperties<IndexValue<T[P1], P2>>,
|
|
165
|
-
P4 extends CallProperties<IndexValue<IndexValue<T[P1], P2>, P3
|
|
165
|
+
P4 extends CallProperties<IndexValue<IndexValue<T[P1], P2>, P3>>,
|
|
166
166
|
>(
|
|
167
167
|
callback: CallCallback<
|
|
168
168
|
IndexValue<IndexValue<IndexValue<IndexValue<T, P1>, P2>, P3>, P4>,
|
|
@@ -171,7 +171,7 @@ export class AstPath<T = any> {
|
|
|
171
171
|
prop1: P1,
|
|
172
172
|
prop2: P2,
|
|
173
173
|
prop3: P3,
|
|
174
|
-
prop4: P4
|
|
174
|
+
prop4: P4,
|
|
175
175
|
): U;
|
|
176
176
|
call<U, P extends PropertyKey>(
|
|
177
177
|
callback: CallCallback<any, U>,
|
|
@@ -185,28 +185,28 @@ export class AstPath<T = any> {
|
|
|
185
185
|
each(callback: EachCallback<T>): void;
|
|
186
186
|
each<P1 extends IterProperties<T>>(
|
|
187
187
|
callback: EachCallback<IndexValue<T, P1>>,
|
|
188
|
-
prop1: P1
|
|
188
|
+
prop1: P1,
|
|
189
189
|
): void;
|
|
190
190
|
each<P1 extends keyof T, P2 extends IterProperties<T[P1]>>(
|
|
191
191
|
callback: EachCallback<IndexValue<IndexValue<T, P1>, P2>>,
|
|
192
192
|
prop1: P1,
|
|
193
|
-
prop2: P2
|
|
193
|
+
prop2: P2,
|
|
194
194
|
): void;
|
|
195
195
|
each<
|
|
196
196
|
P1 extends keyof T,
|
|
197
197
|
P2 extends IterProperties<T[P1]>,
|
|
198
|
-
P3 extends IterProperties<IndexValue<T[P1], P2
|
|
198
|
+
P3 extends IterProperties<IndexValue<T[P1], P2>>,
|
|
199
199
|
>(
|
|
200
200
|
callback: EachCallback<IndexValue<IndexValue<IndexValue<T, P1>, P2>, P3>>,
|
|
201
201
|
prop1: P1,
|
|
202
202
|
prop2: P2,
|
|
203
|
-
prop3: P3
|
|
203
|
+
prop3: P3,
|
|
204
204
|
): void;
|
|
205
205
|
each<
|
|
206
206
|
P1 extends keyof T,
|
|
207
207
|
P2 extends IterProperties<T[P1]>,
|
|
208
208
|
P3 extends IterProperties<IndexValue<T[P1], P2>>,
|
|
209
|
-
P4 extends IterProperties<IndexValue<IndexValue<T[P1], P2>, P3
|
|
209
|
+
P4 extends IterProperties<IndexValue<IndexValue<T[P1], P2>, P3>>,
|
|
210
210
|
>(
|
|
211
211
|
callback: EachCallback<
|
|
212
212
|
IndexValue<IndexValue<IndexValue<IndexValue<T, P1>, P2>, P3>, P4>
|
|
@@ -214,7 +214,7 @@ export class AstPath<T = any> {
|
|
|
214
214
|
prop1: P1,
|
|
215
215
|
prop2: P2,
|
|
216
216
|
prop3: P3,
|
|
217
|
-
prop4: P4
|
|
217
|
+
prop4: P4,
|
|
218
218
|
): void;
|
|
219
219
|
each(
|
|
220
220
|
callback: EachCallback<any[]>,
|
|
@@ -228,30 +228,30 @@ export class AstPath<T = any> {
|
|
|
228
228
|
map<U>(callback: MapCallback<T, U>): U[];
|
|
229
229
|
map<U, P1 extends IterProperties<T>>(
|
|
230
230
|
callback: MapCallback<IndexValue<T, P1>, U>,
|
|
231
|
-
prop1: P1
|
|
231
|
+
prop1: P1,
|
|
232
232
|
): U[];
|
|
233
233
|
map<U, P1 extends keyof T, P2 extends IterProperties<T[P1]>>(
|
|
234
234
|
callback: MapCallback<IndexValue<IndexValue<T, P1>, P2>, U>,
|
|
235
235
|
prop1: P1,
|
|
236
|
-
prop2: P2
|
|
236
|
+
prop2: P2,
|
|
237
237
|
): U[];
|
|
238
238
|
map<
|
|
239
239
|
U,
|
|
240
240
|
P1 extends keyof T,
|
|
241
241
|
P2 extends IterProperties<T[P1]>,
|
|
242
|
-
P3 extends IterProperties<IndexValue<T[P1], P2
|
|
242
|
+
P3 extends IterProperties<IndexValue<T[P1], P2>>,
|
|
243
243
|
>(
|
|
244
244
|
callback: MapCallback<IndexValue<IndexValue<IndexValue<T, P1>, P2>, P3>, U>,
|
|
245
245
|
prop1: P1,
|
|
246
246
|
prop2: P2,
|
|
247
|
-
prop3: P3
|
|
247
|
+
prop3: P3,
|
|
248
248
|
): U[];
|
|
249
249
|
map<
|
|
250
250
|
U,
|
|
251
251
|
P1 extends keyof T,
|
|
252
252
|
P2 extends IterProperties<T[P1]>,
|
|
253
253
|
P3 extends IterProperties<IndexValue<T[P1], P2>>,
|
|
254
|
-
P4 extends IterProperties<IndexValue<IndexValue<T[P1], P2>, P3
|
|
254
|
+
P4 extends IterProperties<IndexValue<IndexValue<T[P1], P2>, P3>>,
|
|
255
255
|
>(
|
|
256
256
|
callback: MapCallback<
|
|
257
257
|
IndexValue<IndexValue<IndexValue<IndexValue<T, P1>, P2>, P3>, P4>,
|
|
@@ -260,7 +260,7 @@ export class AstPath<T = any> {
|
|
|
260
260
|
prop1: P1,
|
|
261
261
|
prop2: P2,
|
|
262
262
|
prop3: P3,
|
|
263
|
-
prop4: P4
|
|
263
|
+
prop4: P4,
|
|
264
264
|
): U[];
|
|
265
265
|
map<U>(
|
|
266
266
|
callback: MapCallback<any[], U>,
|
|
@@ -304,7 +304,7 @@ export type BuiltInParsers = Record<BuiltInParserName, BuiltInParser>;
|
|
|
304
304
|
|
|
305
305
|
export type CustomParser = (
|
|
306
306
|
text: string,
|
|
307
|
-
options: Options
|
|
307
|
+
options: Options,
|
|
308
308
|
) => AST | Promise<AST>;
|
|
309
309
|
|
|
310
310
|
/**
|
|
@@ -405,10 +405,6 @@ export interface RequiredOptions extends doc.printer.Options {
|
|
|
405
405
|
* Provide ability to support new languages to prettier.
|
|
406
406
|
*/
|
|
407
407
|
plugins: Array<string | Plugin>;
|
|
408
|
-
/**
|
|
409
|
-
* Specify plugin directory paths to search for plugins if not installed in the same `node_modules` where prettier is located.
|
|
410
|
-
*/
|
|
411
|
-
pluginSearchDirs: string[] | false;
|
|
412
408
|
/**
|
|
413
409
|
* How to handle whitespaces in HTML.
|
|
414
410
|
* @default "css"
|
|
@@ -449,9 +445,7 @@ export interface ParserOptions<T = any> extends RequiredOptions {
|
|
|
449
445
|
|
|
450
446
|
export interface Plugin<T = any> {
|
|
451
447
|
languages?: SupportLanguage[] | undefined;
|
|
452
|
-
parsers?:
|
|
453
|
-
| { [parserName: string]: Parser<T> | (() => Promise<Parser<T>>) }
|
|
454
|
-
| undefined;
|
|
448
|
+
parsers?: { [parserName: string]: Parser<T> } | undefined;
|
|
455
449
|
printers?: { [astFormat: string]: Printer<T> } | undefined;
|
|
456
450
|
options?: SupportOptions | undefined;
|
|
457
451
|
defaultOptions?: Partial<RequiredOptions> | undefined;
|
|
@@ -473,24 +467,27 @@ export interface Printer<T = any> {
|
|
|
473
467
|
path: AstPath<T>,
|
|
474
468
|
options: ParserOptions<T>,
|
|
475
469
|
print: (path: AstPath<T>) => Doc,
|
|
476
|
-
args?: unknown
|
|
470
|
+
args?: unknown,
|
|
477
471
|
): Doc;
|
|
478
472
|
embed?:
|
|
479
473
|
| ((
|
|
480
474
|
path: AstPath,
|
|
481
|
-
options: Options
|
|
475
|
+
options: Options,
|
|
482
476
|
) =>
|
|
483
477
|
| ((
|
|
484
478
|
textToDoc: (text: string, options: Options) => Promise<Doc>,
|
|
485
479
|
print: (
|
|
486
|
-
selector?: string | number | Array<string | number> | AstPath
|
|
480
|
+
selector?: string | number | Array<string | number> | AstPath,
|
|
487
481
|
) => Doc,
|
|
488
482
|
path: AstPath,
|
|
489
|
-
options: Options
|
|
483
|
+
options: Options,
|
|
490
484
|
) => Promise<Doc | undefined> | Doc | undefined)
|
|
491
485
|
| Doc
|
|
492
486
|
| null)
|
|
493
487
|
| undefined;
|
|
488
|
+
preprocess?:
|
|
489
|
+
| ((ast: T, options: ParserOptions<T>) => T | Promise<T>)
|
|
490
|
+
| undefined;
|
|
494
491
|
insertPragma?: (text: string) => string;
|
|
495
492
|
/**
|
|
496
493
|
* @returns `null` if you want to remove this node
|
|
@@ -523,7 +520,7 @@ export interface Printer<T = any> {
|
|
|
523
520
|
text: string,
|
|
524
521
|
options: ParserOptions<T>,
|
|
525
522
|
ast: T,
|
|
526
|
-
isLastComment: boolean
|
|
523
|
+
isLastComment: boolean,
|
|
527
524
|
) => boolean)
|
|
528
525
|
| undefined;
|
|
529
526
|
endOfLine?:
|
|
@@ -532,7 +529,7 @@ export interface Printer<T = any> {
|
|
|
532
529
|
text: string,
|
|
533
530
|
options: ParserOptions<T>,
|
|
534
531
|
ast: T,
|
|
535
|
-
isLastComment: boolean
|
|
532
|
+
isLastComment: boolean,
|
|
536
533
|
) => boolean)
|
|
537
534
|
| undefined;
|
|
538
535
|
remaining?:
|
|
@@ -541,11 +538,14 @@ export interface Printer<T = any> {
|
|
|
541
538
|
text: string,
|
|
542
539
|
options: ParserOptions<T>,
|
|
543
540
|
ast: T,
|
|
544
|
-
isLastComment: boolean
|
|
541
|
+
isLastComment: boolean,
|
|
545
542
|
) => boolean)
|
|
546
543
|
| undefined;
|
|
547
544
|
}
|
|
548
545
|
| undefined;
|
|
546
|
+
getVisitorKeys?:
|
|
547
|
+
| ((node: T, nonTraversableKeys: Set<string>) => string[])
|
|
548
|
+
| undefined;
|
|
549
549
|
}
|
|
550
550
|
|
|
551
551
|
export interface CursorOptions extends Options {
|
|
@@ -581,7 +581,7 @@ export function check(source: string, options?: Options): Promise<boolean>;
|
|
|
581
581
|
*/
|
|
582
582
|
export function formatWithCursor(
|
|
583
583
|
source: string,
|
|
584
|
-
options: CursorOptions
|
|
584
|
+
options: CursorOptions,
|
|
585
585
|
): Promise<CursorResult>;
|
|
586
586
|
|
|
587
587
|
export function formatAST(ast: any, options?: Options): Promise<string>;
|
|
@@ -622,7 +622,7 @@ export interface ResolveConfigOptions {
|
|
|
622
622
|
*/
|
|
623
623
|
export function resolveConfig(
|
|
624
624
|
filePath: string,
|
|
625
|
-
options?: ResolveConfigOptions
|
|
625
|
+
options?: ResolveConfigOptions,
|
|
626
626
|
): Promise<Options | null>;
|
|
627
627
|
|
|
628
628
|
/**
|
|
@@ -798,7 +798,7 @@ export interface FileInfoResult {
|
|
|
798
798
|
|
|
799
799
|
export function getFileInfo(
|
|
800
800
|
filePath: string,
|
|
801
|
-
options?: FileInfoOptions
|
|
801
|
+
options?: FileInfoOptions,
|
|
802
802
|
): Promise<FileInfoResult>;
|
|
803
803
|
|
|
804
804
|
/**
|
|
@@ -826,7 +826,7 @@ export namespace util {
|
|
|
826
826
|
function getAlignmentSize(
|
|
827
827
|
text: string,
|
|
828
828
|
tabWidth: number,
|
|
829
|
-
startIndex?: number | undefined
|
|
829
|
+
startIndex?: number | undefined,
|
|
830
830
|
): number;
|
|
831
831
|
|
|
832
832
|
function getIndentSize(value: string, tabWidth: number): number;
|
|
@@ -834,83 +834,83 @@ export namespace util {
|
|
|
834
834
|
function skipNewline(
|
|
835
835
|
text: string,
|
|
836
836
|
startIndex: number | false,
|
|
837
|
-
options?: SkipOptions | undefined
|
|
837
|
+
options?: SkipOptions | undefined,
|
|
838
838
|
): number | false;
|
|
839
839
|
|
|
840
840
|
function skipInlineComment(
|
|
841
841
|
text: string,
|
|
842
|
-
startIndex: number | false
|
|
842
|
+
startIndex: number | false,
|
|
843
843
|
): number | false;
|
|
844
844
|
|
|
845
845
|
function skipTrailingComment(
|
|
846
846
|
text: string,
|
|
847
|
-
startIndex: number | false
|
|
847
|
+
startIndex: number | false,
|
|
848
848
|
): number | false;
|
|
849
849
|
|
|
850
850
|
function skipTrailingComment(
|
|
851
851
|
text: string,
|
|
852
|
-
startIndex: number | false
|
|
852
|
+
startIndex: number | false,
|
|
853
853
|
): number | false;
|
|
854
854
|
|
|
855
855
|
function hasNewline(
|
|
856
856
|
text: string,
|
|
857
857
|
startIndex: number,
|
|
858
|
-
options?: SkipOptions | undefined
|
|
858
|
+
options?: SkipOptions | undefined,
|
|
859
859
|
): boolean;
|
|
860
860
|
|
|
861
861
|
function hasNewlineInRange(
|
|
862
862
|
text: string,
|
|
863
863
|
startIndex: number,
|
|
864
|
-
endIndex: number
|
|
864
|
+
endIndex: number,
|
|
865
865
|
): boolean;
|
|
866
866
|
|
|
867
867
|
function hasSpaces(
|
|
868
868
|
text: string,
|
|
869
869
|
startIndex: number,
|
|
870
|
-
options?: SkipOptions | undefined
|
|
870
|
+
options?: SkipOptions | undefined,
|
|
871
871
|
): boolean;
|
|
872
872
|
|
|
873
873
|
function getNextNonSpaceNonCommentCharacter(
|
|
874
874
|
text: string,
|
|
875
|
-
startIndex: number
|
|
875
|
+
startIndex: number,
|
|
876
876
|
): string;
|
|
877
877
|
|
|
878
878
|
function makeString(
|
|
879
879
|
rawText: string,
|
|
880
880
|
enclosingQuote: Quote,
|
|
881
|
-
unescapeUnnecessaryEscapes?: boolean | undefined
|
|
881
|
+
unescapeUnnecessaryEscapes?: boolean | undefined,
|
|
882
882
|
): string;
|
|
883
883
|
|
|
884
884
|
function skip(
|
|
885
|
-
characters: string | RegExp
|
|
885
|
+
characters: string | RegExp,
|
|
886
886
|
): (
|
|
887
887
|
text: string,
|
|
888
888
|
startIndex: number | false,
|
|
889
|
-
options?: SkipOptions
|
|
889
|
+
options?: SkipOptions,
|
|
890
890
|
) => number | false;
|
|
891
891
|
|
|
892
892
|
const skipWhitespace: (
|
|
893
893
|
text: string,
|
|
894
894
|
startIndex: number | false,
|
|
895
|
-
options?: SkipOptions
|
|
895
|
+
options?: SkipOptions,
|
|
896
896
|
) => number | false;
|
|
897
897
|
|
|
898
898
|
const skipSpaces: (
|
|
899
899
|
text: string,
|
|
900
900
|
startIndex: number | false,
|
|
901
|
-
options?: SkipOptions
|
|
901
|
+
options?: SkipOptions,
|
|
902
902
|
) => number | false;
|
|
903
903
|
|
|
904
904
|
const skipToLineEnd: (
|
|
905
905
|
text: string,
|
|
906
906
|
startIndex: number | false,
|
|
907
|
-
options?: SkipOptions
|
|
907
|
+
options?: SkipOptions,
|
|
908
908
|
) => number | false;
|
|
909
909
|
|
|
910
910
|
const skipEverythingButNewLine: (
|
|
911
911
|
text: string,
|
|
912
912
|
startIndex: number | false,
|
|
913
|
-
options?: SkipOptions
|
|
913
|
+
options?: SkipOptions,
|
|
914
914
|
) => number | false;
|
|
915
915
|
|
|
916
916
|
function addLeadingComment(node: any, comment: any): void;
|