You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 4, 2017. It is now read-only.
Copy file name to clipboardExpand all lines: public/docs/ts/latest/guide/style-guide.jade
+53-35Lines changed: 53 additions & 35 deletions
Original file line number
Diff line number
Diff line change
@@ -75,11 +75,7 @@ a(id='toc')
75
75
76
76
<ahref="#toc">Back to top</a>
77
77
:marked
78
-
## File Naming
79
-
80
-
### File Naming Guidelines
81
-
<a id="02-01"></a>
82
-
#### Style 02-01
78
+
## Naming
83
79
84
80
- Use consistent names for all components following a pattern that describes the component's feature then (optionally) its type. My recommended pattern is `feature.type.js`. There are 2 names for most assets:
85
81
* the file name (`avengers.component.ts`)
@@ -93,7 +89,7 @@ a(id='toc')
93
89
94
90
<ahref="#toc">Back to top</a>
95
91
:marked
96
-
### Separate with Dots and Dashes
92
+
### Separate File Names with Dots and Dashes
97
93
<a id="02-01"></a>
98
94
#### Style 02-01
99
95
@@ -111,58 +107,80 @@ a(id='toc')
111
107
112
108
<ahref="#toc">Back to top</a>
113
109
:marked
114
-
### Component Names
115
-
<a id="02-03"></a>
116
-
#### Style 02-03
110
+
### Names
111
+
<a id="02-02"></a>
112
+
#### Style 02-02
117
113
118
-
- Use consistent names for all components named after their feature. Use UpperCamelCase for components' symbols. Match the name of the component to the naming of the file
114
+
- Use consistent names for all assets named after what they represent.
115
+
116
+
- Use UpperCamelCase for symbols. Match the name of the symbol to the naming of the file.
119
117
120
-
**Why?** Provides a consistent way to quickly identify and reference components.
118
+
- Append the symbol name with a suffix that it represents.
119
+
120
+
**Why?** Provides a consistent way to quickly identify and reference assets.
121
121
122
122
**Why?** UpperCamelCase is conventional for identifying object that can be instantiated using a constructor.
123
123
124
+
**Why?** The `Component` suffix is more commonly used and is more explicitly descriptive.
125
+
124
126
```typescript
125
-
AppComponent //app.component.ts
126
-
HeroesComponent //heroes.component.ts
127
-
HeroListComponent //hero-list.component.ts
128
-
HeroDetailComponent //hero-detail.component.ts
127
+
/* recommended */
128
+
AppComponent // app.component.ts
129
+
HeroesComponent // heroes.component.ts
130
+
HeroListComponent // hero-list.component.ts
131
+
HeroDetailComponent // hero-detail.component.ts
132
+
133
+
/* recommended */
134
+
ValidationDirective // validation.directive.ts
129
135
```
130
136
131
137
<ahref="#toc">Back to top</a>
132
138
:marked
133
-
### Suffixes
134
-
<a id="02-04"></a>
135
-
#### Style 02-04
139
+
### Service Names
140
+
<a id="02-03"></a>
141
+
#### Style 02-03
136
142
137
-
- Append the component name with the suffix `Component`.
143
+
- Use consistent names for all services named after their feature. Use UpperCamelCase for services. Suffix services with `Service` when it is not clear what they are (e.g. when they are nouns).
138
144
139
-
**Why?** The `Component` suffix is more commonly used and is more explicitly descriptive.
145
+
**Why?** Provides a consistent way to quickly identify and reference services.
140
146
141
-
```typescript
142
-
// recommended
147
+
**Why?** Clear service names such as `logger` do not require a suffix.
148
+
149
+
**Why?** Service names such as `Credit` are nouns and require a suffix and should be named with a suffix when it is not obvious if it is a service or something else.
143
150
144
-
// hero-list.component.ts
145
-
export class HeroListComponent { }
151
+
```typescript
152
+
HeroDataService // hero-data.service.ts
153
+
CreditService // credit.service.ts
154
+
LoggerService // logger.service.ts
146
155
```
147
156
148
157
<ahref="#toc">Back to top</a>
149
158
:marked
150
-
### Service Names
151
-
<a id="02-10"></a>
152
-
#### Style 02-10
159
+
### Bootstrapping
160
+
<a id="02-04"></a>
161
+
#### Style 02-04
153
162
154
-
- Use consistent names for all services named after their feature. Use UpperCamelCase for services. Suffix services with `Service` when it is not clear what they are (e.g. when they are nouns).
163
+
- Place bootstrapping and platform logic for the app in a file named `main.ts`.
164
+
165
+
- Do not put app logic in the `main.ts`. Instead consider placing it in a Component or Service.
166
+
167
+
**Why?** Follows a consistent convention for the startup logic of an app.
155
168
156
-
**Why?** Provides a consistent way to quickly identify and reference services.
169
+
**Why?** Follows a familar convention from other technology platforms.
157
170
158
-
**Why?** Clear service names such as `logger` do not require a suffix.
171
+
<ahref="#toc">Back to top</a>
172
+
:marked
173
+
### Pipe Names
174
+
<a id="02-10"></a>
175
+
#### Style 02-10
159
176
160
-
**Why?** Service names such as `Credit` are nouns and require a suffix and should be named with a suffix when it is not obvious if it is a service or something else.
177
+
- Use consistent names for all pipes named after their feature.
178
+
179
+
**Why?** Provides a consistent way to quickly identify and reference pipes.
161
180
162
181
```typescript
163
-
HeroService // hero.service.ts
164
-
CreditService // credit.service.ts
165
-
Logger // logger.service.ts
182
+
EllipsisPipe // ellipsis.pipe.ts
183
+
InitCapsPipe // init-caps.pipe.ts
166
184
```
167
185
168
186
<ahref="#toc">Back to top</a>
@@ -171,7 +189,7 @@ a(id='toc')
171
189
<a id="02-12"></a>
172
190
#### Style 02-12
173
191
174
-
- Name test specifications similar to the component they test with a suffix of `spec`.
192
+
- Name test specifications similar to the component they test with a suffix of `.spec`.
175
193
176
194
**Why?** Provides a consistent way to quickly identify components.
0 commit comments