1package prettier
2
3// Schema for .prettierrc
4#Schema: {
5 @jsonschema(schema="http://json-schema.org/draft-07/schema#")
6 @jsonschema(id="https://www.schemastore.org/prettierrc.json")
7 matchN(1, [matchN(2, [#optionsDefinition & {...}, #overridesDefinition & {...}]), string])
8
9 #optionsDefinition: {
10 // Include parentheses around a sole arrow function parameter.
11 "arrowParens"?: matchN(1, ["always", "avoid"])
12
13 // Put > of opening tags on the last line instead of on a new line.
14 "bracketSameLine"?: bool
15
16 // Print spaces between brackets.
17 "bracketSpacing"?: bool
18
19 // Check whether the file's first docblock comment contains '@noprettier' or
20 // '@noformat' to determine if it should be formatted.
21 "checkIgnorePragma"?: bool
22
23 // Print (to stderr) where a cursor at the given position would move to after formatting.
24 "cursorOffset"?: int
25
26 // Control how Prettier formats quoted code embedded in the file.
27 "embeddedLanguageFormatting"?: matchN(1, ["auto", "off"])
28
29 // Which end of line characters to apply.
30 "endOfLine"?: matchN(1, ["lf", "crlf", "cr", "auto"])
31
32 // Where to print operators when binary expressions wrap lines.
33 "experimentalOperatorPosition"?: matchN(1, ["start", "end"])
34
35 // Use curious ternaries, with the question mark after the condition.
36 "experimentalTernaries"?: bool
37
38 // Specify the input filepath. This will be used to do parser inference.
39 "filepath"?: string
40
41 // How to handle whitespaces in HTML.
42 "htmlWhitespaceSensitivity"?: matchN(1, ["css", "strict", "ignore"])
43
44 // Insert @format pragma into file's first docblock comment.
45 "insertPragma"?: bool
46
47 // Use single quotes in JSX.
48 "jsxSingleQuote"?: bool
49
50 // How to wrap object literals.
51 "objectWrap"?: matchN(1, ["preserve", "collapse"])
52
53 // Which parser to use.
54 "parser"?: matchN(>=1, [
55 "flow",
56 "babel",
57 "babel-flow",
58 "babel-ts",
59 "typescript",
60 "acorn",
61 "espree",
62 "meriyah",
63 "css",
64 "less",
65 "scss",
66 "json",
67 "json5",
68 "jsonc",
69 "json-stringify",
70 "graphql",
71 "markdown",
72 "mdx",
73 "vue",
74 "yaml",
75 "glimmer",
76 "html",
77 "angular",
78 "lwc",
79 "mjml",
80 string,
81 ])
82
83 // Add a plugin. Multiple plugins can be passed as separate `--plugin`s.
84 "plugins"?: [...string]
85
86 // The line length where Prettier will try wrap.
87 "printWidth"?: int
88
89 // How to wrap prose.
90 "proseWrap"?: matchN(1, ["always", "never", "preserve"])
91
92 // Change when properties in objects are quoted.
93 "quoteProps"?: matchN(1, ["as-needed", "consistent", "preserve"])
94
95 // Format code ending at a given character offset (exclusive).
96 // The range will extend forwards to the end of the selected statement.
97 "rangeEnd"?: int
98
99 // Format code starting at a given character offset.
100 // The range will extend backwards to the start of the first line containing the selected statement.
101 "rangeStart"?: int
102
103 // Require either '@prettier' or '@format' to be present in the file's first
104 // docblock comment in order for it to be formatted.
105 "requirePragma"?: bool
106
107 // Print semicolons.
108 "semi"?: bool
109
110 // Enforce single attribute per line in HTML, Vue and JSX.
111 "singleAttributePerLine"?: bool
112
113 // Use single quotes instead of double quotes.
114 "singleQuote"?: bool
115
116 // Number of spaces per indentation level.
117 "tabWidth"?: int
118
119 // Print trailing commas wherever possible when multi-line.
120 "trailingComma"?: matchN(1, ["all", "es5", "none"])
121
122 // Indent with tabs instead of spaces.
123 "useTabs"?: bool
124
125 // Indent script and style tags in Vue files.
126 "vueIndentScriptAndStyle"?: bool
127 ...
128 }
129
130 #overridesDefinition: {
131 // Provide a list of patterns to override prettier configuration.
132 "overrides"?: [...close({
133 // Include these files in this override.
134 "files"!: matchN(1, [string, [...string]])
135
136 // Exclude these files from this override.
137 "excludeFiles"?: matchN(1, [string, [...string]])
138 "options"?: #optionsDefinition
139 })]
140 ...
141 }
142}