Skip to content

Commit 3be1d0b

Browse files
committed
Add ConfigurationBuilder and enums.
1 parent eeb1270 commit 3be1d0b

File tree

5 files changed

+2290
-0
lines changed

5 files changed

+2290
-0
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ crate-type = ["cdylib"]
1515
[dependencies]
1616
pyo3 = { version = "0.27.2", features = ["extension-module", "experimental-inspect", ] }
1717
dprint-plugin-typescript = "0.95.15"
18+
dprint-core = "0.67.4"

python/formate_js/enums.py

Lines changed: 271 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,271 @@
1+
# stdlib
2+
from enum import Enum
3+
4+
5+
class PreferHanging(str, Enum):
6+
#: Always prefer multi-line indentation
7+
Never = "never"
8+
9+
#: Prefer hanging indentation for sequences with only a single item, but if there are multiple items then use multi-line indentation
10+
11+
OnlySingleItem = "onlySingleItem"
12+
13+
#: Always prefer hanging indentation
14+
Always = "always"
15+
16+
17+
class SemiColons(str, Enum):
18+
"""
19+
Semi colon possibilities.
20+
"""
21+
22+
#: Always uses semi-colons where applicable.
23+
Always = "always"
24+
25+
#: Prefers to use semi-colons, but doesn't add one in certain scenarios such as for the last member of a single-line type literal.
26+
Prefer = "prefer"
27+
28+
#: Uses automatic semi-colon insertion. Only adds a semi-colon at the start of some expression statements when necessary.
29+
Asi = "asi"
30+
31+
32+
class TrailingCommas(str, Enum):
33+
"""
34+
Trailing comma possibilities.
35+
"""
36+
37+
#: Trailing commas should not be used.
38+
Never = "always"
39+
40+
#: Trailing commas should always be used.
41+
Always = "never"
42+
43+
#: Trailing commas should only be used in multi-line scenarios.
44+
OnlyMultiLine = "onlyMultiLine"
45+
46+
47+
class ForceMultiLine(str, Enum):
48+
"""
49+
Force multilines possibilities.
50+
"""
51+
52+
#: Multiline imports/exports should not be forced.
53+
Never = "always"
54+
55+
#: Always force multiline imports/exports.
56+
Always = "never"
57+
58+
#: Mulitline imports/exports should be forced only when importing/exporting multiple items.
59+
WhenMultiple = "whenMultiple"
60+
61+
62+
class BracePosition(str, Enum):
63+
"""
64+
Where to place the opening brace.
65+
"""
66+
67+
#: Maintains the brace being on the next line or the same line.
68+
Maintain = "maintain"
69+
70+
#: Forces the brace to be on the same line.
71+
SameLine = "sameLine"
72+
73+
#: Forces the brace to be on the next line.
74+
NextLine = "nextLine"
75+
76+
#: Forces the brace to be on the next line if the same line is hanging, but otherwise uses the same line.
77+
SameLineUnlessHanging = "sameLineUnlessHanging"
78+
79+
80+
class MemberSpacing(str, Enum):
81+
"""
82+
How to space members.
83+
"""
84+
85+
#: Maintains whether a newline or blankline is used.
86+
Maintain = "maintain"
87+
88+
NewLine = "blankLine"
89+
90+
BlankLine = "newLine"
91+
92+
93+
class NextControlFlowPosition(str, Enum):
94+
"""
95+
Where to place the next control flow within a control flow statement.
96+
"""
97+
98+
#: Maintains the next control flow being on the next line or the same line.
99+
Maintain = "maintain"
100+
101+
#: Forces the next control flow to be on the same line.
102+
SameLine = "sameLine"
103+
104+
#: Forces the next control flow to be on the next line.
105+
NextLine = "nextLine"
106+
107+
108+
class OperatorPosition(str, Enum):
109+
"""
110+
Where to place the operator for expressions that span multiple lines.
111+
"""
112+
113+
#: Maintains the operator being on the next line or the same line.
114+
Maintain = "maintain"
115+
116+
#: Forces the operator to be on the same line.
117+
SameLine = "sameLine"
118+
119+
#: Forces the operator to be on the next line.
120+
NextLine = "nextLine"
121+
122+
123+
class SameOrNextLinePosition(str, Enum):
124+
"""
125+
Where to place a node that could be on the same line or next line.
126+
"""
127+
128+
#: Maintains the position of the expression.
129+
Maintain = "maintain"
130+
131+
#: Forces the whole statement to be on one line.
132+
SameLine = "sameLine"
133+
134+
#: Forces the expression to be on the next line.
135+
NextLine = "nextLine"
136+
137+
138+
class UseBraces(str, Enum):
139+
"""
140+
If braces should be used or not in certain scenarios.
141+
"""
142+
143+
#: Uses braces if they're used. Doesn't use braces if they're not used.
144+
Maintain = "maintain"
145+
146+
#: Uses braces when the body is on a different line.
147+
WhenNotSingleLine = "whenNotSingleLine"
148+
149+
#: Forces the use of braces. Will add them if they aren't used.
150+
Always = "always"
151+
152+
#: Forces no braces when the header is one line and body is one line. Otherwise forces braces.
153+
PreferNone = "preferNone"
154+
155+
156+
class UseParentheses(str, Enum):
157+
"""
158+
Whether to use parentheses around a single parameter in an arrow function.
159+
"""
160+
161+
#: Maintains the current state of the parentheses.
162+
Maintain = "maintain"
163+
164+
#: Forces parentheses.
165+
Force = "force"
166+
167+
#: Prefers not using parentheses when possible.
168+
PreferNone = "preferNone"
169+
170+
171+
class QuoteStyle(str, Enum):
172+
"""
173+
How to decide to use single or double quotes.
174+
"""
175+
176+
#: Always use double quotes.
177+
AlwaysDouble = "alwaysDouble"
178+
179+
#: Always use single quotes.
180+
AlwaysSingle = "alwaysSingle"
181+
182+
#: Prefer using double quotes except in scenarios where the string contains more double quotes than single quotes.
183+
PreferDouble = "preferDouble"
184+
185+
#: Prefer using single quotes except in scenarios where the string contains more single quotes than double quotes.
186+
PreferSingle = "preferSingle"
187+
188+
189+
class JsxQuoteStyle(str, Enum):
190+
"""
191+
Whether to use single or double quotes for JSX attributes.
192+
"""
193+
194+
#: Prefer using double quotes except in scenarios where the string contains more double quotes than single quotes.
195+
PreferDouble = "preferDouble"
196+
197+
#: Prefer using single quotes except in scenarios where the string contains more single quotes than double quotes.
198+
PreferSingle = "preferSingle"
199+
200+
201+
class QuoteProps(str, Enum):
202+
"""
203+
Behaviour to use for quotes on property names.
204+
"""
205+
206+
#: Remove unnecessary quotes around property names.
207+
AsNeeded = "asNeeded"
208+
209+
#: Same as `AsNeeded`, but if one property requires quotes then quote them all.
210+
Consistent = "consistent"
211+
212+
#: Preserve quotes around property names.
213+
Preserve = "preserve"
214+
215+
216+
class JsxMultiLineParens(str, Enum):
217+
"""
218+
Whether to surround a JSX element or fragment with parentheses when it's the top JSX node and it spans multiple lines.
219+
"""
220+
221+
#: Never wrap JSX with parentheses.
222+
Never = "never"
223+
224+
#: Prefer wrapping with parentheses in most scenarios, except in function arguments and JSX attributes.
225+
Prefer = "prefer"
226+
227+
#: Always wrap JSX with parentheses if it spans multiple lines.
228+
Always = "always"
229+
230+
231+
class SemiColonOrComma(str, Enum):
232+
"""
233+
Whether to use semi-colons or commas.
234+
"""
235+
#: Use semi colons (default).
236+
SemiColon = "semiColon"
237+
#: Use commas.
238+
Comma = "comma"
239+
240+
241+
class SortOrder(str, Enum):
242+
"""
243+
The kind of sort ordering to use.
244+
"""
245+
246+
#: Maintains the current ordering.
247+
Maintain = "maintain"
248+
249+
#: Alphabetically and case sensitive.
250+
CaseSensitive = "caseSensitive"
251+
252+
#: Alphabetically and case insensitive.
253+
CaseInsensitive = "caseInsensitive"
254+
255+
256+
class NamedTypeImportsExportsOrder(str, Enum):
257+
First = "first"
258+
Last = "last"
259+
_None = "none"
260+
261+
262+
class NewLineKind(str, Enum):
263+
264+
#: Decide which newline kind to use based on the last newline in the file.
265+
Auto = "auto"
266+
267+
#: Use slash n new lines.
268+
LineFeed = "lf"
269+
270+
#: Use slash r slash n new lines.
271+
CarriageReturnLineFeed = "crlf"

0 commit comments

Comments
 (0)