-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
Copy pathprettier_v1.x.x.js
178 lines (158 loc) · 4.81 KB
/
prettier_v1.x.x.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
// flow-typed signature: 066c92e9ccb5f0711df8d73cbca837d6
// flow-typed version: 9e32affdbd/prettier_v1.x.x/flow_>=v0.56.x
declare module "prettier" {
declare export type AST = Object;
declare export type Doc = Object;
declare export type FastPath = Object;
declare export type PrettierParserName =
| "babylon"
| "flow"
| "typescript"
| "postcss"
| "css"
| "less"
| "scss"
| "json"
| "graphql"
| "markdown"
| "vue";
declare export type PrettierParser = {
[name: PrettierParserName]: (text: string, options?: Object) => AST
};
declare export type CustomParser = (
text: string,
parsers: PrettierParser,
options: Options
) => AST;
declare export type Options = {|
printWidth?: number,
tabWidth?: number,
useTabs?: boolean,
semi?: boolean,
singleQuote?: boolean,
trailingComma?: "none" | "es5" | "all",
bracketSpacing?: boolean,
jsxBracketSameLine?: boolean,
arrowParens?: "avoid" | "always",
rangeStart?: number,
rangeEnd?: number,
parser?: PrettierParserName | CustomParser,
filepath?: string,
requirePragma?: boolean,
insertPragma?: boolean,
proseWrap?: "always" | "never" | "preserve",
plugins?: Array<string | Plugin>
|};
declare export type Plugin = {
languages: SupportLanguage,
parsers: { [parserName: string]: Parser },
printers: { [astFormat: string]: Printer }
};
declare export type Parser = {
parse: (
text: string,
parsers: { [parserName: string]: Parser },
options: Object
) => AST,
astFormat: string
};
declare export type Printer = {
print: (
path: FastPath,
options: Object,
print: (path: FastPath) => Doc
) => Doc,
embed: (
path: FastPath,
print: (path: FastPath) => Doc,
textToDoc: (text: string, options: Object) => Doc,
options: Object
) => ?Doc
};
declare export type CursorOptions = {|
cursorOffset: number,
printWidth?: $PropertyType<Options, "printWidth">,
tabWidth?: $PropertyType<Options, "tabWidth">,
useTabs?: $PropertyType<Options, "useTabs">,
semi?: $PropertyType<Options, "semi">,
singleQuote?: $PropertyType<Options, "singleQuote">,
trailingComma?: $PropertyType<Options, "trailingComma">,
bracketSpacing?: $PropertyType<Options, "bracketSpacing">,
jsxBracketSameLine?: $PropertyType<Options, "jsxBracketSameLine">,
arrowParens?: $PropertyType<Options, "arrowParens">,
parser?: $PropertyType<Options, "parser">,
filepath?: $PropertyType<Options, "filepath">,
requirePragma?: $PropertyType<Options, "requirePragma">,
insertPragma?: $PropertyType<Options, "insertPragma">,
proseWrap?: $PropertyType<Options, "proseWrap">,
plugins?: $PropertyType<Options, "plugins">
|};
declare export type CursorResult = {|
formatted: string,
cursorOffset: number
|};
declare export type ResolveConfigOptions = {|
useCache?: boolean,
config?: string,
editorconfig?: boolean
|};
declare export type SupportLanguage = {
name: string,
since: string,
parsers: Array<string>,
group?: string,
tmScope: string,
aceMode: string,
codemirrorMode: string,
codemirrorMimeType: string,
aliases?: Array<string>,
extensions: Array<string>,
filenames?: Array<string>,
linguistLanguageId: number,
vscodeLanguageIds: Array<string>
};
declare export type SupportOption = {|
since: string,
type: "int" | "boolean" | "choice" | "path",
deprecated?: string,
redirect?: SupportOptionRedirect,
description: string,
oppositeDescription?: string,
default: SupportOptionValue,
range?: SupportOptionRange,
choices?: SupportOptionChoice
|};
declare export type SupportOptionRedirect = {|
options: string,
value: SupportOptionValue
|};
declare export type SupportOptionRange = {|
start: number,
end: number,
step: number
|};
declare export type SupportOptionChoice = {|
value: boolean | string,
description?: string,
since?: string,
deprecated?: string,
redirect?: SupportOptionValue
|};
declare export type SupportOptionValue = number | boolean | string;
declare export type SupportInfo = {|
languages: Array<SupportLanguage>,
options: Array<SupportOption>
|};
declare export type Prettier = {|
format: (source: string, options?: Options) => string,
check: (source: string, options?: Options) => boolean,
formatWithCursor: (source: string, options: CursorOptions) => CursorResult,
resolveConfig: {
(filePath: string, options?: ResolveConfigOptions): Promise<?Options>,
sync(filePath: string, options?: ResolveConfigOptions): ?Options
},
clearConfigCache: () => void,
getSupportInfo: (version?: string) => SupportInfo
|};
declare export default Prettier;
}