front-end-dev-standards 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/scripts/validate-package.js +10 -5
- package/standards//342/232/241 performance.md" +138 -0
- package/standards//360/237/205/260/357/270/217 angular.md" +571 -0
- package/standards//360/237/216/250 ui-ux.md" +391 -0
- package/standards//360/237/223/232 documentation.md" +127 -0
- package/standards//360/237/224/214 api-standards.md" +201 -0
- package/standards//360/237/224/220 security.md" +432 -0
- package/standards//360/237/232/200 ci-cd.md" +134 -0
- package/standards//360/237/244/226 ai-development.md" +142 -0
- package/standards//360/237/247/221/342/200/215/360/237/222/273 coding-style.md" +765 -0
- package/standards//360/237/247/252 testing.md" +399 -0
- package/standards//360/237/247/261 architecture.md" +654 -0
- package/standards/angular.md +0 -234
- package/standards/architecture.md +0 -263
- package/standards/coding-style.md +0 -223
- package/standards/security.md +0 -6
- package/standards/testing.md +0 -244
|
@@ -0,0 +1,571 @@
|
|
|
1
|
+
# Angular Engineering Standards
|
|
2
|
+
|
|
3
|
+
Version: 1.0
|
|
4
|
+
Target Framework: Angular 20+
|
|
5
|
+
Architecture: Standalone + Signals First
|
|
6
|
+
Applies To: All HRMS Frontend Applications
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# 1. Engineering Principles
|
|
11
|
+
|
|
12
|
+
## Core Principles
|
|
13
|
+
|
|
14
|
+
1. Standalone Components Only
|
|
15
|
+
2. Signals First State Management
|
|
16
|
+
3. Functional Dependency Injection
|
|
17
|
+
4. OnPush Change Detection Everywhere
|
|
18
|
+
5. Strict TypeScript
|
|
19
|
+
6. Accessibility by Default
|
|
20
|
+
7. Performance First
|
|
21
|
+
8. Testable Code
|
|
22
|
+
9. Feature-Based Architecture
|
|
23
|
+
10. Security by Design
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
# 2. Project Structure
|
|
28
|
+
|
|
29
|
+
## Feature Based Structure
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
src/
|
|
33
|
+
├── app/
|
|
34
|
+
│ ├── core/
|
|
35
|
+
│ │ ├── services/
|
|
36
|
+
│ │ ├── interceptors/
|
|
37
|
+
│ │ ├── guards/
|
|
38
|
+
│ │ └── models/
|
|
39
|
+
│ │
|
|
40
|
+
│ ├── shared/
|
|
41
|
+
│ │ ├── ui/
|
|
42
|
+
│ │ ├── pipes/
|
|
43
|
+
│ │ ├── directives/
|
|
44
|
+
│ │ └── utils/
|
|
45
|
+
│ │
|
|
46
|
+
│ ├── features/
|
|
47
|
+
│ │ ├── attendance/
|
|
48
|
+
│ │ ├── payroll/
|
|
49
|
+
│ │ ├── recruitment/
|
|
50
|
+
│ │ └── timesheet/
|
|
51
|
+
│ │
|
|
52
|
+
│ └── app.routes.ts
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Rules
|
|
56
|
+
|
|
57
|
+
* Organize by feature, never by file type.
|
|
58
|
+
* Features must not import from other features directly.
|
|
59
|
+
* Shared code belongs in shared/.
|
|
60
|
+
* Global services belong in core/.
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
# 3. Component Standards
|
|
65
|
+
|
|
66
|
+
## Required Component Pattern
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
@Component({
|
|
70
|
+
selector: 'hr-timesheet-calendar',
|
|
71
|
+
standalone: true,
|
|
72
|
+
imports: [],
|
|
73
|
+
templateUrl: './timesheet-calendar.component.html',
|
|
74
|
+
styleUrl: './timesheet-calendar.component.scss',
|
|
75
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
76
|
+
})
|
|
77
|
+
export class TimesheetCalendarComponent {
|
|
78
|
+
private readonly service = inject(TimesheetService);
|
|
79
|
+
|
|
80
|
+
readonly loading = signal(false);
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Rules
|
|
85
|
+
|
|
86
|
+
### Must
|
|
87
|
+
|
|
88
|
+
* Standalone Components
|
|
89
|
+
* OnPush Strategy
|
|
90
|
+
* Signals for Local State
|
|
91
|
+
* inject() for DI
|
|
92
|
+
* Strongly Typed APIs
|
|
93
|
+
* Accessibility Attributes
|
|
94
|
+
|
|
95
|
+
### Must Not
|
|
96
|
+
|
|
97
|
+
* Constructor Injection
|
|
98
|
+
* Any Type
|
|
99
|
+
* Business Logic in Components
|
|
100
|
+
* Direct DOM Manipulation
|
|
101
|
+
* Nested Subscriptions
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
# 4. Signals Standards
|
|
106
|
+
|
|
107
|
+
## Default State Pattern
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
readonly loading = signal(false);
|
|
111
|
+
readonly employees = signal<Employee[]>([]);
|
|
112
|
+
|
|
113
|
+
readonly activeEmployees = computed(() =>
|
|
114
|
+
this.employees().filter(e => e.active)
|
|
115
|
+
);
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Rules
|
|
119
|
+
|
|
120
|
+
Use Signals For:
|
|
121
|
+
|
|
122
|
+
* UI State
|
|
123
|
+
* Form State
|
|
124
|
+
* Loading State
|
|
125
|
+
* Selection State
|
|
126
|
+
|
|
127
|
+
Use RxJS For:
|
|
128
|
+
|
|
129
|
+
* HTTP Streams
|
|
130
|
+
* WebSockets
|
|
131
|
+
* Event Streams
|
|
132
|
+
* Complex Async Flows
|
|
133
|
+
|
|
134
|
+
Avoid:
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
new BehaviorSubject()
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
for local component state.
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
# 5. Dependency Injection
|
|
145
|
+
|
|
146
|
+
## Required
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
private readonly employeeService = inject(EmployeeService);
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Forbidden
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
constructor(
|
|
156
|
+
private employeeService: EmployeeService
|
|
157
|
+
) {}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
# 6. Routing Standards
|
|
163
|
+
|
|
164
|
+
## Route File
|
|
165
|
+
|
|
166
|
+
```
|
|
167
|
+
attendance.routes.ts
|
|
168
|
+
timesheet.routes.ts
|
|
169
|
+
payroll.routes.ts
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Rules
|
|
173
|
+
|
|
174
|
+
* Lazy Load Every Feature
|
|
175
|
+
* Use Functional Guards
|
|
176
|
+
* No Eager Feature Loading
|
|
177
|
+
* One Routes File Per Feature
|
|
178
|
+
|
|
179
|
+
Example:
|
|
180
|
+
|
|
181
|
+
```typescript
|
|
182
|
+
{
|
|
183
|
+
path: '',
|
|
184
|
+
loadComponent: () =>
|
|
185
|
+
import('./pages/list.page')
|
|
186
|
+
.then(m => m.ListPage)
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
# 7. Form Standards
|
|
193
|
+
|
|
194
|
+
## Mandatory
|
|
195
|
+
|
|
196
|
+
* Typed Reactive Forms
|
|
197
|
+
* Form Validation
|
|
198
|
+
* Error Messaging
|
|
199
|
+
* Accessibility Labels
|
|
200
|
+
|
|
201
|
+
## Example
|
|
202
|
+
|
|
203
|
+
```typescript
|
|
204
|
+
readonly form = new FormGroup<EmployeeForm>({
|
|
205
|
+
firstName: new FormControl('', {
|
|
206
|
+
nonNullable: true,
|
|
207
|
+
validators: [Validators.required]
|
|
208
|
+
})
|
|
209
|
+
});
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## Forbidden
|
|
213
|
+
|
|
214
|
+
* Template Driven Forms
|
|
215
|
+
* Untyped Forms
|
|
216
|
+
* Any Casts
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
# 8. Service Standards
|
|
221
|
+
|
|
222
|
+
## Responsibilities
|
|
223
|
+
|
|
224
|
+
Services:
|
|
225
|
+
|
|
226
|
+
* API Calls
|
|
227
|
+
* Data Transformation
|
|
228
|
+
* Business Rules
|
|
229
|
+
* State Coordination
|
|
230
|
+
|
|
231
|
+
Components:
|
|
232
|
+
|
|
233
|
+
* UI Logic Only
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
# 9. HTTP Standards
|
|
238
|
+
|
|
239
|
+
## Requirements
|
|
240
|
+
|
|
241
|
+
* Typed Responses
|
|
242
|
+
* Interceptors
|
|
243
|
+
* Error Handling
|
|
244
|
+
* Request Timeouts
|
|
245
|
+
|
|
246
|
+
Example
|
|
247
|
+
|
|
248
|
+
```typescript
|
|
249
|
+
this.http.get<Employee[]>('/api/employees');
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
Never:
|
|
253
|
+
|
|
254
|
+
```typescript
|
|
255
|
+
this.http.get<any>();
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
# 10. Error Handling
|
|
261
|
+
|
|
262
|
+
## Rules
|
|
263
|
+
|
|
264
|
+
All API errors must be handled through:
|
|
265
|
+
|
|
266
|
+
```typescript
|
|
267
|
+
NotificationService
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
Never:
|
|
271
|
+
|
|
272
|
+
```typescript
|
|
273
|
+
console.error(error);
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
without user feedback.
|
|
277
|
+
|
|
278
|
+
---
|
|
279
|
+
|
|
280
|
+
# 11. Angular Material Standards
|
|
281
|
+
|
|
282
|
+
## Approved Libraries
|
|
283
|
+
|
|
284
|
+
* Angular Material
|
|
285
|
+
* Angular CDK
|
|
286
|
+
|
|
287
|
+
## Avoid
|
|
288
|
+
|
|
289
|
+
* Bootstrap
|
|
290
|
+
* jQuery Plugins
|
|
291
|
+
* Random UI Libraries
|
|
292
|
+
|
|
293
|
+
Material should be the primary design system.
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
297
|
+
# 12. Styling Standards
|
|
298
|
+
|
|
299
|
+
## Preferred
|
|
300
|
+
|
|
301
|
+
SCSS
|
|
302
|
+
|
|
303
|
+
```scss
|
|
304
|
+
:host {
|
|
305
|
+
display: block;
|
|
306
|
+
}
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
## Naming
|
|
310
|
+
|
|
311
|
+
Use BEM
|
|
312
|
+
|
|
313
|
+
```scss
|
|
314
|
+
.employee-card {}
|
|
315
|
+
|
|
316
|
+
.employee-card__title {}
|
|
317
|
+
|
|
318
|
+
.employee-card--selected {}
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
Avoid:
|
|
322
|
+
|
|
323
|
+
```scss
|
|
324
|
+
.red-box {}
|
|
325
|
+
.bigText {}
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
---
|
|
329
|
+
|
|
330
|
+
# 13. Accessibility Standards
|
|
331
|
+
|
|
332
|
+
Every component must support:
|
|
333
|
+
|
|
334
|
+
* Keyboard Navigation
|
|
335
|
+
* Screen Readers
|
|
336
|
+
* Focus States
|
|
337
|
+
* ARIA Labels
|
|
338
|
+
|
|
339
|
+
Example
|
|
340
|
+
|
|
341
|
+
```html
|
|
342
|
+
<button
|
|
343
|
+
aria-label="Submit Timesheet">
|
|
344
|
+
</button>
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
Accessibility is not optional.
|
|
348
|
+
|
|
349
|
+
---
|
|
350
|
+
|
|
351
|
+
# 14. Security Standards
|
|
352
|
+
|
|
353
|
+
## Mandatory
|
|
354
|
+
|
|
355
|
+
* Sanitize HTML
|
|
356
|
+
* Validate Inputs
|
|
357
|
+
* Escape User Content
|
|
358
|
+
* Use Angular Security APIs
|
|
359
|
+
|
|
360
|
+
Never:
|
|
361
|
+
|
|
362
|
+
```typescript
|
|
363
|
+
element.innerHTML = userInput;
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
Never bypass Angular sanitization without review.
|
|
367
|
+
|
|
368
|
+
---
|
|
369
|
+
|
|
370
|
+
# 15. Performance Standards
|
|
371
|
+
|
|
372
|
+
## Required
|
|
373
|
+
|
|
374
|
+
* OnPush
|
|
375
|
+
* Lazy Loading
|
|
376
|
+
* Signals
|
|
377
|
+
* track in @for
|
|
378
|
+
* NgOptimizedImage
|
|
379
|
+
|
|
380
|
+
Example
|
|
381
|
+
|
|
382
|
+
```html
|
|
383
|
+
@for(item of items(); track item.id)
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
Avoid:
|
|
387
|
+
|
|
388
|
+
```html
|
|
389
|
+
*ngFor="let item of items"
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
without tracking.
|
|
393
|
+
|
|
394
|
+
---
|
|
395
|
+
|
|
396
|
+
# 16. Testing Standards
|
|
397
|
+
|
|
398
|
+
Coverage Target:
|
|
399
|
+
|
|
400
|
+
* Minimum 80%
|
|
401
|
+
|
|
402
|
+
Required:
|
|
403
|
+
|
|
404
|
+
* Component Tests
|
|
405
|
+
* Service Tests
|
|
406
|
+
* Guard Tests
|
|
407
|
+
|
|
408
|
+
Tools:
|
|
409
|
+
|
|
410
|
+
* Jasmine
|
|
411
|
+
* Karma
|
|
412
|
+
* Angular Testing Utilities
|
|
413
|
+
|
|
414
|
+
---
|
|
415
|
+
|
|
416
|
+
# 17. Logging Standards
|
|
417
|
+
|
|
418
|
+
Use:
|
|
419
|
+
|
|
420
|
+
```typescript
|
|
421
|
+
LoggerService
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
Never:
|
|
425
|
+
|
|
426
|
+
```typescript
|
|
427
|
+
console.log()
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
in production code.
|
|
431
|
+
|
|
432
|
+
---
|
|
433
|
+
|
|
434
|
+
# 18. Naming Conventions
|
|
435
|
+
|
|
436
|
+
## Components
|
|
437
|
+
|
|
438
|
+
```
|
|
439
|
+
employee-list.component.ts
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
## Services
|
|
443
|
+
|
|
444
|
+
```
|
|
445
|
+
employee.service.ts
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
## Models
|
|
449
|
+
|
|
450
|
+
```
|
|
451
|
+
employee.model.ts
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
## Interfaces
|
|
455
|
+
|
|
456
|
+
```typescript
|
|
457
|
+
interface Employee {}
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
No "IEmployee".
|
|
461
|
+
|
|
462
|
+
---
|
|
463
|
+
|
|
464
|
+
# 19. Git Standards
|
|
465
|
+
|
|
466
|
+
Branch Names
|
|
467
|
+
|
|
468
|
+
```
|
|
469
|
+
feature/timesheet-calendar
|
|
470
|
+
bugfix/attendance-submit
|
|
471
|
+
hotfix/login-issue
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
Commit Format
|
|
475
|
+
|
|
476
|
+
```
|
|
477
|
+
feat(timesheet): add weekly preview panel
|
|
478
|
+
|
|
479
|
+
fix(attendance): resolve clock-in issue
|
|
480
|
+
|
|
481
|
+
refactor(payroll): simplify calculations
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
---
|
|
485
|
+
|
|
486
|
+
# 20. Code Review Checklist
|
|
487
|
+
|
|
488
|
+
Before Merge:
|
|
489
|
+
|
|
490
|
+
* No any types
|
|
491
|
+
* No console logs
|
|
492
|
+
* No constructor injection
|
|
493
|
+
* OnPush enabled
|
|
494
|
+
* Signals used where appropriate
|
|
495
|
+
* Tests passing
|
|
496
|
+
* Accessibility verified
|
|
497
|
+
* Mobile responsive
|
|
498
|
+
* Security reviewed
|
|
499
|
+
|
|
500
|
+
---
|
|
501
|
+
|
|
502
|
+
# 21. AI Generated Code Rules
|
|
503
|
+
|
|
504
|
+
AI-generated code must:
|
|
505
|
+
|
|
506
|
+
* Follow Angular Standards
|
|
507
|
+
* Use Signals
|
|
508
|
+
* Use inject()
|
|
509
|
+
* Use Standalone Components
|
|
510
|
+
* Include Types
|
|
511
|
+
* Include Error Handling
|
|
512
|
+
* Include Loading States
|
|
513
|
+
* Include Accessibility Attributes
|
|
514
|
+
|
|
515
|
+
Reject generated code that violates standards.
|
|
516
|
+
|
|
517
|
+
---
|
|
518
|
+
|
|
519
|
+
# 22. Anti-Patterns
|
|
520
|
+
|
|
521
|
+
Never Generate:
|
|
522
|
+
|
|
523
|
+
❌ NgModules
|
|
524
|
+
|
|
525
|
+
❌ Constructor Injection
|
|
526
|
+
|
|
527
|
+
❌ Default Change Detection
|
|
528
|
+
|
|
529
|
+
❌ any Type
|
|
530
|
+
|
|
531
|
+
❌ BehaviorSubject for UI State
|
|
532
|
+
|
|
533
|
+
❌ Direct DOM Manipulation
|
|
534
|
+
|
|
535
|
+
❌ Business Logic in Components
|
|
536
|
+
|
|
537
|
+
❌ Untyped Forms
|
|
538
|
+
|
|
539
|
+
❌ Manual Subscription Management
|
|
540
|
+
|
|
541
|
+
❌ console.log in Production
|
|
542
|
+
|
|
543
|
+
❌ jQuery
|
|
544
|
+
|
|
545
|
+
❌ Inline CSS for Complex UI
|
|
546
|
+
|
|
547
|
+
❌ Feature-to-Feature Coupling
|
|
548
|
+
|
|
549
|
+
❌ Hardcoded API URLs
|
|
550
|
+
|
|
551
|
+
❌ Magic Strings
|
|
552
|
+
|
|
553
|
+
❌ Duplicate Logic
|
|
554
|
+
|
|
555
|
+
---
|
|
556
|
+
|
|
557
|
+
# 23. Definition of Done
|
|
558
|
+
|
|
559
|
+
A feature is complete only if:
|
|
560
|
+
|
|
561
|
+
* Functionality works
|
|
562
|
+
* Unit Tests pass
|
|
563
|
+
* Accessibility verified
|
|
564
|
+
* Responsive verified
|
|
565
|
+
* Error handling implemented
|
|
566
|
+
* Loading states implemented
|
|
567
|
+
* Types are strict
|
|
568
|
+
* Security reviewed
|
|
569
|
+
* Code review approved
|
|
570
|
+
* Documentation updated
|
|
571
|
+
* SonarQube quality gate passed
|