@@ -11,17 +11,29 @@ interface State {
1111 printWidth ?: number ;
1212 tabWidth ?: number ;
1313 useTabs ?: boolean ;
14+ arrowParens ?: ArrowParens ;
1415 trailingComma ?: TrailingComma ;
16+ experimentalOperatorPosition ?: ExperimentalOperatorPosition ;
1517 requirePragma ?: boolean ;
1618 code ?: string ;
1719}
1820
21+ enum ArrowParens {
22+ Always = "always" ,
23+ Avoid = "avoid"
24+ }
25+
1926enum TrailingComma {
2027 All = "all" ,
2128 Es5 = "es5" ,
2229 None = "none"
2330}
2431
32+ enum ExperimentalOperatorPosition {
33+ Start = "start" ,
34+ End = "end"
35+ }
36+
2537const codeSample = `public interface MyInterface {
2638 String foo();
2739 int[] bar();
@@ -63,9 +75,17 @@ function Inner() {
6375 const [ printWidth , setPrintWidth ] = useState ( initialState . printWidth ?? 80 ) ;
6476 const [ tabWidth , setTabWidth ] = useState ( initialState . tabWidth ?? 2 ) ;
6577 const [ useTabs , setUseTabs ] = useState ( initialState . useTabs ?? false ) ;
66- const [ trailingComma , setTrailingComma ] = useState < TrailingComma > (
78+ const [ arrowParens , setArrowParens ] = useState (
79+ initialState . arrowParens ?? ArrowParens . Avoid
80+ ) ;
81+ const [ trailingComma , setTrailingComma ] = useState (
6782 initialState . trailingComma ?? TrailingComma . All
6883 ) ;
84+ const [ experimentalOperatorPosition , setExperimentalOperatorPosition ] =
85+ useState (
86+ initialState . experimentalOperatorPosition ??
87+ ExperimentalOperatorPosition . End
88+ ) ;
6989 const [ requirePragma , setRequirePragma ] = useState (
7090 initialState . requirePragma ?? false
7191 ) ;
@@ -82,7 +102,9 @@ function Inner() {
82102 printWidth,
83103 tabWidth,
84104 useTabs,
105+ arrowParens,
85106 trailingComma,
107+ experimentalOperatorPosition,
86108 requirePragma,
87109 code
88110 } ) ;
@@ -96,12 +118,23 @@ function Inner() {
96118 printWidth,
97119 tabWidth,
98120 useTabs,
121+ arrowParens,
99122 trailingComma,
123+ experimentalOperatorPosition,
100124 requirePragma
101125 } )
102126 . then ( setFormattedCode )
103127 . catch ( error => setFormattedCode ( error . message ) ) ;
104- } , [ printWidth , tabWidth , useTabs , trailingComma , requirePragma , code ] ) ;
128+ } , [
129+ printWidth ,
130+ tabWidth ,
131+ useTabs ,
132+ arrowParens ,
133+ trailingComma ,
134+ experimentalOperatorPosition ,
135+ requirePragma ,
136+ code
137+ ] ) ;
105138
106139 return (
107140 < div className = { styles . playground } >
@@ -137,6 +170,19 @@ function Inner() {
137170 </ details >
138171 < details open >
139172 < summary > Java</ summary >
173+ < label title = "Include parentheses around a sole arrow function parameter." >
174+ --arrow-parens{ " " }
175+ < select
176+ value = { arrowParens }
177+ onChange = { event =>
178+ setArrowParens ( event . target . value as ArrowParens )
179+ }
180+ >
181+ { Object . values ( ArrowParens ) . map ( option => (
182+ < option key = { option } > { option } </ option >
183+ ) ) }
184+ </ select >
185+ </ label >
140186 < label title = "Print trailing commas wherever possible when multi-line." >
141187 --trailing-comma{ " " }
142188 < select
@@ -150,6 +196,21 @@ function Inner() {
150196 ) ) }
151197 </ select >
152198 </ label >
199+ < label title = "Where to print operators when binary expressions wrap lines." >
200+ --experimental-operator-position{ " " }
201+ < select
202+ value = { experimentalOperatorPosition }
203+ onChange = { event =>
204+ setExperimentalOperatorPosition (
205+ event . target . value as ExperimentalOperatorPosition
206+ )
207+ }
208+ >
209+ { Object . values ( ExperimentalOperatorPosition ) . map ( option => (
210+ < option key = { option } > { option } </ option >
211+ ) ) }
212+ </ select >
213+ </ label >
153214 </ details >
154215 < details open >
155216 < summary > Special</ summary >
0 commit comments