File tree 1 file changed +26
-2
lines changed
1 file changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -72,7 +72,31 @@ prefer sticking to a _single_ API for accomplishing something.
72
72
73
73
### 100 column limit
74
74
All code and docs in the repo should be 100 columns or fewer. This applies to TypeScript, SCSS,
75
- HTML, bash scripts, and markdown files.
75
+ HTML, bash scripts, and markdown files.
76
+
77
+ ### API Design
78
+
79
+ #### Boolean arguments
80
+ Avoid adding boolean arguments to a method in cases where that argument means "do something extra".
81
+ In these cases, prefer breaking the behavior up into different functions.
82
+
83
+ ``` ts
84
+ // AVOID
85
+ function getTargetElement(createIfNotFound = false ) {
86
+ // ...
87
+ }
88
+ ```
89
+
90
+ ``` ts
91
+ // PREFER
92
+ function getExistingTargetElement() {
93
+ // ...
94
+ }
95
+
96
+ function createTargetElement() {
97
+ // ...
98
+ }
99
+ ```
76
100
77
101
### TypeScript
78
102
@@ -121,7 +145,7 @@ Properties should have a concise description of what the property means:
121
145
``` ts
122
146
/** The label position relative to the checkbox. Defaults to 'after' */
123
147
@Input () labelPosition : ' before' | ' after' = ' after' ;
124
- ```
148
+ ```
125
149
126
150
Methods blocks should describe what the function does and provide a description for each parameter
127
151
and the return value:
You can’t perform that action at this time.
0 commit comments