-
Notifications
You must be signed in to change notification settings - Fork 16
/
prettier.node_cli.txt
376 lines (281 loc) · 21.1 KB
/
prettier.node_cli.txt
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
PRETTIER
ALTERNATIVES ==> #For:
# - JavaScript:
# - eslint --fix (prefered):
# - very maintained, big ecosystem
# - not only focused on formatting but also on code errors
# - very flexible, lots of features
# - prettier (prefered):
# - very maintained, big ecosystem
# - very opinionated
# - js-beautify: more flexible
# - uglify: less features
# - esformatter (and jsfmt): not maintained
# - es-beautifier: not maintained
# - Deno (preferred with Deno):
# - Deno core
# - fewer features
# - fewer supported formats
VERSION ==> #3.0.3
OPINIONATED ==> #By design prettier does not allow configuration.
#There are only few configuration options available for JavaScript
CORRECTNESS ==> #Is very conservative in transformations, e.g. does not add keywords, braces, etc.
GLOB #Uses minimatch (see its doc)
/=+===============================+=\
/ : : \
)==: CONF :==(
\ :_______________________________: /
\=+===============================+=/
CONF #Uses Cosmiconfig, i.e.
# - prettier --config JSON|YAML|JS_FILE
# - ./[../.../]package.json "prettier" CONF|'PACKAGE'
# - ./[../.../].prettierrc JSON|YAML_FILE
# - ./[../.../].prettierrc.json|json5|y[a]ml|toml|js|mjs JSON|YAML|TOML|JS_FILE
# - .prettierrc.json JSON can be just 'PACKAGE'
# - ./[../.../]prettier.config.js|cjs|mjs JS_FILE
#CONF_FILE properties:
# - camelCase
# - PROPs ARR if property can be added several times
# - BOOL 'PROP' if --no-PROP
--config-precedence STR #Priority order among:
# - 'cli-override' (def): --CONF, CONF_FILE
# - 'file-override': CONF_FILE, --CONF
# - 'prefer-file': CONF_FILE only, or --CONF only
--no-config #
CONF.overrides #Sub-CONF for specific files, with OBJ_ARR:
# - files 'GLOB'[_ARR]
# - excludedFiles 'GLOB'[_ARR]
# - options CONF
--find-config-path FILE #Find which CONF_FILE will be picked for this FILE
--no-editorconfig #Otherwise .editorconfig will be used for --print-width, --tab-width, --use-tabs, --single-quote
#and --end-of-line
/=+===============================+=\
/ : : \
)==: IGNORE :==(
\ :_______________________________: /
\=+===============================+=/
.prettierignore #Like .gitignore but for prettier
--ignore-path FILE #Instead of '.prettierignore' + '.gitignore'
--with-node-modules #Do not ignore node_modules/**
// prettier-ignore[-start|end]
/* prettier-ignore[-start|end] */
<!--
prettier-ignore[-start|end] --> #In comments, for next line or for a range
--require-pragma #Only beautify files that start with comment @prettier or @format
#In JavaScript, must be JSDoc
--insert-pragma #Add comment @format in beginning of files
--range-start|end NUM #Only beautify part of the files, from specific character offsets
#For IDE plugins
--cursor-offset NUM #Prints offset where character at offset NUM would be after beautification
--file-info FILE #Instead of beautifying, prints OBJ: ignored BOOL, inferredParser 'PARSER'
/=+===============================+=\
/ : : \
)==: RUN :==(
\ :_______________________________: /
\=+===============================+=/
prettier [FILE|DIR|'GLOB'...] #Prints to stdout
#Def: stdin
--no-error-on-unmatched-pattern #No error when no input files
--stdin-filepath FILE #
--write|w #Edit in-place
--cache #Cache each file. Invalidated if one of the following changes:
--cache-strategy=STR # - (if cache-strategy 'content' (def)): file contents
# - (if cache-strategy 'metadata'): file timestamps
# - CONF
# - Prettier version
# - Node.js version
--cache-location=PATH #Def: ./node_modules/.cache/prettier/.prettier-cache
-l #Dry-run printing files that can be beautified
--list-different #Exit code 1 if there are some files.
--check #Same with more human-friendly output
--debug-check #Dry-run printing whether beautification might change code correctness
--no-color #
--log-level STR #Can be 'silent', 'error', 'warn', 'log' (def), 'debug'
/=+===============================+=\
/ : : \
)==: PROGRAMMATIC :==(
\ :_______________________________: /
\=+===============================+=/
CONF.filepath #Must be specified with the following
PRETTIER.format('SOURCE'[, CONF])
->>'SOURCE' #Beautifies
PRETTIER.formatWithCursor #Same but must use CONF.cursorOffset NUM and will return
('SOURCE', CONF)->>OBJ #OBJ: formatted 'SOURCE', cursorOffset NUM
PRETTIER.check('SOURCE'[, CONF])
->>BOOL #Whether is already beautified, similar to --list-different
PRETTIER.resolveConfig #Similar to --find-config-file but returning CONF object
('FILE'[, CONF])->>CONF|null #PROMISE is rejected on parsing errors.
#Can also use CONF: useCache BOOL (def: true)
PRETTIER.clearConfigCache()->> #
PRETTIER.getFileInfo
('PATH'[, CONF])->>OBJ #Like --file-info
/=+===============================+=\
/ : : \
)==: LANGUAGES :==(
\ :_______________________________: /
\=+===============================+=/
--parser STR|MODULE #Can be:
# - 'babel' (def) (@babel/parser)
# - 'typescript' (@typescript-eslint/parser)
# - 'espree'
# - 'meriyah'
# - 'acorn'
# - '[babel-]flow'
# - "babel-flow" parsed ambiguous syntax as JavaScript, "flow" as Flow
# - 'json'
# - 'json5'
# - 'json-stringify' (like JSON.stringify()) (used for package.json)
# - 'yaml'
# - 'css'
# - 'less'
# - 'scss'
# - 'graphql'
# - 'markdown'
# - 'vue'
# - 'angular'
# - 'lwc' (Salesforce "Lightning Web Components")
# - 'glimmer' (Handlebars)
--ignore-unknown|u #Do not error if no parser can be found
--plugin NAME|FILE #A plugin is responsible for beautifying some specific syntax, by parsing then
#reprinting it.
#It reprints to an intermediary format (called "doc") not to a string.
#Can be added several times.
#Looked in node_modules/ under @prettier/plugin-NAME or prettier-plugin-NAME
#See online doc for how to develop own plugin
##In my docs: see the one for Prisma
--plugin-search-dir DIR #Def: node_modules
--no-plugin-search #
--embedded-language-formatting=STR#'auto' (def) or 'off'
#Whether to format code inside strings
/=+===============================+=\
/ : : \
)==: COMMON OPTIONS :==(
\ :_______________________________: /
\=+===============================+=/
--print-width NUM #Def: 80
--tab-width NUM #Def: 2
--use-tabs #Def: false
--end-of-line auto|[cr][lf] #Def: lf
--single-quote #Def: double quote except if STR contains double quotes
--no-bracket-spacing #{ ... } instead of {...}
--trailing-comma STR #Can be 'none', 'es5' (only if ES5), 'all' (def)
/=+===============================+=\
/ : : \
)==: JAVASCRIPT :==(
\ :_______________________________: /
\=+===============================+=/
GENERAL ==> #Parser is @babel/parser
--no-semi #Instead of always. Except when needed
--arrow-parens STR #Can be:
# - 'avoid': VAL => {...}
# - 'always' (def): (VAL) => {...}
--quote-props STR #Quotes around { VAR }. Can be:
# - 'as-needed' (def): only when required
# - 'preserve': do not change
# - 'consistent': must all have same quoting
--jsx-single-quote #In JSX, instead of double quotes
ESLINT-CONFIG-PRETTIER ==> ##ESLint config that:
## - turns off all ESLint rules of things handled by Prettier.
## - should be last in CONF.extends to make sure it is not overridden
## - also contains files specific for ESLint rules with eslint-plugin-flowtype,
## eslint-plugin-react, eslint-plugin-standard, eslint-plugin-unicorn, eslint-plugin-vue,
## eslint-plugin-babel, @typescript-eslint/eslint-plugin
##Also contains a CLI which checks if current ESLint config might conflict with Prettier.
##Version 9.0.0
ESLINT-PLUGIN-PRETTIER ==> ##Can also use { extends: 'prettier/recommended' } as a shortcut for
##{ extends: ['prettier'], plugins: 'prettier', rules: { prettier/prettier: 2 } }
##Version 5.0.1
prettier/prettier [CONF] [OBJ] ##ESLint rule that lints against prettier rules.
##Can use --fix
##CONF is prettier CONF
##OBJ:
## - usePrettierrc BOOL (def: true)
## - fileInfoOptions CONF: passed to PRETTIER.getFileInfo()
PRETTIER-ESLINT ==> ##Node module that performs prettier then eslint --fix (or inverse order)
##Version 8.8.1
PRETTIER-ESLINT-CLI ==> ##CLI wrapping prettier-eslint
##Version 4.7.1
PRETTIER-STANDARD ==> ##CLI/Node module that performs prettier-eslint --fix using eslint-config-standard
##(only the rules that are fixable)
##Version 8.0.1
/=+===============================+=\
/ : : \
)==: JSON :==(
\ :_______________________________: /
\=+===============================+=/
GENERAL ==> #Actually uses same as JavaScript
/=+===============================+=\
/ : : \
)==: YAML :==(
\ :_______________________________: /
\=+===============================+=/
GENERAL ==> #Parser is eemeli's yaml
#Can also be as front-matter in CSS/Markdown
--prose-wrap STR #See Markdown
/=+===============================+=\
/ : : \
)==: HTML :==(
\ :_______________________________: /
\=+===============================+=/
GENERAL ==> #Parser is parse5
#Also applies in JavaScript html`STR` (template string function)
--html-whitespace-sensitivity STR #Tries to keep whitespaces when CSS display is `inline`
# - 'css' (def): use the default CSS display of the HTML tag
# - 'strict': always keep whitespaces
# - 'ignore': never keep whitespaces
#Can also use <!-- display: block|inline --> HTML comment
--bracket-same-line #closing > not a newline
--single-attribute-per-line #
/=+===============================+=\
/ : : \
)==: MARKDOWN :==(
\ :_______________________________: /
\=+===============================+=/
GENERAL ==> #Parser is remark
#Supports MDX
--prose-wrap STR #Newlines for max width
#Can be:
# - 'preserve' (def)
# - 'always'
# - 'never'
/=+===============================+=\
/ : : \
)==: GRAPHQL :==(
\ :_______________________________: /
\=+===============================+=/
GENERAL ==> #Parser is GraphQL-js
#Influenced by --no-bracket-spacing
/=+===============================+=\
/ : : \
)==: CSS :==(
\ :_______________________________: /
\=+===============================+=/
GENERAL ==> #Parsers are postcss-selector|values|media-query-parser, postcss-less and postcss-scss
#Influenced by --single-quote
#Can use PostCSS, Less and Sass (depending on --parser)
STYLELINT-CONFIG-PRETTIER ==> ##Stylelint config that:
## - turns off all Stylelint rules of things handled by Prettier.
## - should be last in CONF.extends to make sure it is not overridden
##Also contains a CLI which checks if current ESLint config might conflict with Prettier.
##Version 3.2.0
/=+===============================+=\
/ : : \
)==: VUE :==(
\ :_______________________________: /
\=+===============================+=/
--vue-indent-script-and-style #BOOL (def: false). Whether to indent code inside <script> and <style>
/=+===============================+=\
/ : : \
)==: HANDLEBARS :==(
\ :_______________________________: /
\=+===============================+=/
GENERAL ==> #Parser is glimmer
/=+===============================+=\
/ : : \
)==: GULP :==(
\ :_______________________________: /
\=+===============================+=/
GULP-PRETTIER[.check]([CONF]) ##Version 5.0.0
##Adds VINYL.isPrettier true if modified