@dsivd/prestations-ng 19.0.0-beta.3 → 19.0.0-beta.5
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/ANGULAR_SIGNALS.md +3 -9
- package/CHANGELOG.md +16 -0
- package/CONTRIBUTING.md +3 -3
- package/README.md +1 -0
- package/UPGRADING_V19.md +1142 -0
- package/dsivd-prestations-ng-19.0.0-beta.5.tgz +0 -0
- package/fesm2022/dsivd-prestations-ng.mjs +2 -2
- package/fesm2022/dsivd-prestations-ng.mjs.map +1 -1
- package/package.json +1 -1
- package/dsivd-prestations-ng-19.0.0-beta.3.tgz +0 -0
package/UPGRADING_V19.md
CHANGED
|
@@ -172,3 +172,1145 @@ mvn -U org.openrewrite.maven:rewrite-maven-plugin:run -Drewrite.activeRecipes=or
|
|
|
172
172
|
```
|
|
173
173
|
|
|
174
174
|
Take a look at Sonar to see other things that you can improve or ignore.
|
|
175
|
+
|
|
176
|
+
## PRESTATIONS-NG
|
|
177
|
+
|
|
178
|
+
For the commands in this guide, it is supposed that your are in the `front` folder of your project.
|
|
179
|
+
|
|
180
|
+
The main feature in `prestations-ng` v19 is the update of the `@angular/*` peer dependencies
|
|
181
|
+
to `^21.2.14`, using `node 22+` to build, `npm 10+` for package manager and `Foehn 2+ (Bootstrap 5+)` for our design system.
|
|
182
|
+
|
|
183
|
+
A lot of breaking because our library has migrated to **standalone** components, **signals** and **inject function** instead of constructor injection parameters.
|
|
184
|
+
|
|
185
|
+
> 🚨 **Read carefully following [PITFALLS](ANGULAR_SIGNALS.md#common_pitfalls), especially points 4, 6 & 8**
|
|
186
|
+
|
|
187
|
+
### Migrate to ESLint
|
|
188
|
+
|
|
189
|
+
(NB : you can skip this step if you already have a `front/.eslintrc.json` file, it means it is already done.)
|
|
190
|
+
|
|
191
|
+
Follow [our migration guide](ESLINT_MIGRATION_GUIDE.md) to migrate your project from TSLint to ESLint.
|
|
192
|
+
|
|
193
|
+
### Upgrade to Angular 20
|
|
194
|
+
|
|
195
|
+
Just FYI if you are curious about the details, you can find the Angular update guide at this address [https://angular.dev/update-guide?v=19.0-20.0&l=1](https://angular.dev/update-guide?v=19.0-20.0&l=1)
|
|
196
|
+
|
|
197
|
+
**NB: Commit before continuing so your repository is clean.**
|
|
198
|
+
|
|
199
|
+
Remove your `resolutions` in `package.json` before starting : if you have `resolutions` in `package.json`, remove manually the section.
|
|
200
|
+
|
|
201
|
+
In the next commands, commit before each ng update.
|
|
202
|
+
|
|
203
|
+
Unlink `@dsivd/prestations-ng` by running `yarn unlink @dsivd/prestations-ng` in your `front` folder if you have linked it before.
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
npm install
|
|
207
|
+
npm install @angular/cli@19 -g
|
|
208
|
+
ng update @angular/core@19 @angular/cli@19
|
|
209
|
+
ng update @dsivd/prestations-ng@18
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
npm install @angular/cli@20 -g
|
|
214
|
+
ng update @angular/core@20 @angular/cli@20
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
When asked the question "Select the migrations that you'd like to run",
|
|
218
|
+
|
|
219
|
+
accept **"use-application-builder"** by hitting "Space" key then "Enter".
|
|
220
|
+
|
|
221
|
+
When asked the question "Select the migrations that you'd like to run",
|
|
222
|
+
|
|
223
|
+
accept **"control-flow-migration"** by hitting "Space" key.
|
|
224
|
+
|
|
225
|
+
accept **"router-current-navigation"** by hitting "Space" key.
|
|
226
|
+
|
|
227
|
+
Then press "Enter" key.
|
|
228
|
+
|
|
229
|
+
**IMPORTANT: Search for every `@for` in your project and check that `track` statement is present and has a unique identifier**
|
|
230
|
+
|
|
231
|
+
**NB: When using `@angular/cdk` in your project**
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
ng update @angular/cdk@20
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Running with node 22+
|
|
238
|
+
|
|
239
|
+
#### Switch to node 22+
|
|
240
|
+
|
|
241
|
+
##### If you are using our `slave-apps`
|
|
242
|
+
|
|
243
|
+
Be sure to update your `slave-apps` git repository and source your `.bashrc` (or whatever file you're using).
|
|
244
|
+
|
|
245
|
+
Verify your node version in your terminal by executing:
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
node -v
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
**NB: If version is still v20+ by default, type `node22` in your terminal to switch to node v22+**
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
node22
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
##### If you are NOT using our `slave-apps`
|
|
258
|
+
|
|
259
|
+
Be sure to use a node version 22+ in your terminal:
|
|
260
|
+
|
|
261
|
+
```bash
|
|
262
|
+
node -v
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
#### In your project
|
|
266
|
+
|
|
267
|
+
Update your `package.json` file to specify the node engine:
|
|
268
|
+
|
|
269
|
+
```json
|
|
270
|
+
{
|
|
271
|
+
"engines": {
|
|
272
|
+
"node": ">=22.18.0"
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
#### Update your jenkins files
|
|
278
|
+
|
|
279
|
+
- Change `nodeVersion: 20` to use node 22
|
|
280
|
+
|
|
281
|
+
##### UT folder
|
|
282
|
+
|
|
283
|
+
```diff
|
|
284
|
+
buildAppPipelinePodmanUT([
|
|
285
|
+
- node: 20,
|
|
286
|
+
+ node: 22,
|
|
287
|
+
])
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### Upgrade to Angular 21
|
|
291
|
+
|
|
292
|
+
`prestations-ng` **v19+** now supports **Angular v21**.
|
|
293
|
+
|
|
294
|
+
Just FYI if you are curious about the details, you can find the Angular update guide at this address [https://angular.dev/update-guide?v=20.0-21.0&l=1](https://angular.dev/update-guide?v=20.0-21.0&l=1)
|
|
295
|
+
|
|
296
|
+
**NB: Commit before continuing so your repository is clean.**
|
|
297
|
+
|
|
298
|
+
```bash
|
|
299
|
+
npm install @angular/cli@21 -g
|
|
300
|
+
ng update @dsivd/prestations-ng@latest
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
When asked again the question "Select the migrations that you'd like to run",
|
|
304
|
+
|
|
305
|
+
accept **"router-current-navigation"** by hitting "Space" key then "Enter".
|
|
306
|
+
|
|
307
|
+
```bash
|
|
308
|
+
ng update @angular/cli@21
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
When asked the question "Select the migrations that you'd like to run",
|
|
312
|
+
|
|
313
|
+
accept **"use-application-builder"** by hitting "Space" key then "Enter".
|
|
314
|
+
|
|
315
|
+
```bash
|
|
316
|
+
npm install @types/node@22 ts-node@10
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
**NB: When using `@angular/cdk` in your project**
|
|
320
|
+
|
|
321
|
+
```bash
|
|
322
|
+
ng update @angular/cdk@21
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
**NB: When using `ngx-matomo-client` in your project**
|
|
326
|
+
|
|
327
|
+
```bash
|
|
328
|
+
ng update ngx-matomo-client@9
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
### Quick fix
|
|
332
|
+
|
|
333
|
+
In all custom components extending `FoehnInputComponent`, in `providers` providing `FoehnInputComponent` remove `multi: true,`
|
|
334
|
+
|
|
335
|
+
```diff
|
|
336
|
+
{
|
|
337
|
+
provide: FoehnInputComponent,
|
|
338
|
+
useExisting: forwardRef(() => ItemListComponent),
|
|
339
|
+
- multi: true,
|
|
340
|
+
}
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
In your `.eslintrc.json`, remove `"/src/main.ts",` from `ignorePatterns`
|
|
344
|
+
|
|
345
|
+
In `main.ts`, replace `platformBrowserDynamic` by `platformBrowser`
|
|
346
|
+
|
|
347
|
+
### Now fix your project before continuing
|
|
348
|
+
|
|
349
|
+
**IMPORTANT: Fix your project because our new prestations-ng v19+ is standalone, uses signals instead of observables and inject function instead of constructor injection parameter.**
|
|
350
|
+
|
|
351
|
+
Remove all your `@dsivd/prestations-ng` imports of modules and make sure you are using the new standalone components instead by adding them directly from your html file "alt+enter".
|
|
352
|
+
|
|
353
|
+
Check every `constructor` in your project, and remove useless `constructor` parameters that are not used anymore (like `ActivatedRoute` in components extending `AbstractPageComponent`).
|
|
354
|
+
|
|
355
|
+
Run the following command until you have no more errors.
|
|
356
|
+
|
|
357
|
+
```bash
|
|
358
|
+
npm run build
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
**TIP: If your IntelliJ is still showing you errors on `@if` or `@for`, close it and re-open it to fix.**
|
|
362
|
+
|
|
363
|
+
### Migrate to inject function
|
|
364
|
+
|
|
365
|
+
```bash
|
|
366
|
+
ng generate @angular/core:inject
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
✔ Which directory do you want to migrate? **./**
|
|
370
|
+
|
|
371
|
+
✔ Do you want to migrate abstract classes? Abstract classes are not migrated by default, because their parameters aren't guaranteed to be injectable. **Yes**
|
|
372
|
+
|
|
373
|
+
✔ Do you want to clean up all constructors or keep them backwards compatible? Enabling this option will include an additional signature of `constructor(...args:
|
|
374
|
+
unknown[]);` that will avoid errors for sub-classes, but will increase the amount of generated code by the migration. **No**
|
|
375
|
+
|
|
376
|
+
✔ Do you want optional inject calls to be non-nullable? Enable this option if you want the return type to be identical to @Optional(), at the expense of worse
|
|
377
|
+
type safety. **Yes**
|
|
378
|
+
|
|
379
|
+
Go through every file that has changed and fix what is broken.
|
|
380
|
+
|
|
381
|
+
Reorder public / private and remove unused imports so ESLINT is happy again.
|
|
382
|
+
|
|
383
|
+
For example, when extending `AbstractPageComponent`:
|
|
384
|
+
Before:
|
|
385
|
+
|
|
386
|
+
```ts
|
|
387
|
+
sessionInfoData: SessionInfoWithApplicationService;
|
|
388
|
+
|
|
389
|
+
constructor(
|
|
390
|
+
protected override activatedRoute: ActivatedRoute,
|
|
391
|
+
private readonly dictionaryService: SdkDictionaryService,
|
|
392
|
+
sessionInfoData: SessionInfoWithApplicationService
|
|
393
|
+
) {
|
|
394
|
+
super(activatedRoute);
|
|
395
|
+
this.sessionInfoData = sessionInfoData;
|
|
396
|
+
}
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
After:
|
|
400
|
+
|
|
401
|
+
```ts
|
|
402
|
+
sessionInfoData = inject(SessionInfoWithApplicationService);
|
|
403
|
+
|
|
404
|
+
private readonly dictionaryService = inject(SdkDictionaryService);
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
Most of the time, you can remove `activatedRoute` because it was used as a constructor parameter for `AbstractPageComponent`.
|
|
408
|
+
|
|
409
|
+
### Migrate to self-closing tags
|
|
410
|
+
|
|
411
|
+
**WARNING: The following command will work only when your application compiles without errors. If you have errors, fix them before continuing.**
|
|
412
|
+
|
|
413
|
+
```bash
|
|
414
|
+
npm run build
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
Fix remaining errors and warnings, then run the following command:
|
|
418
|
+
|
|
419
|
+
```bash
|
|
420
|
+
ng generate @angular/core:self-closing-tag
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
✔ Which directory do you want to migrate? **./**
|
|
424
|
+
|
|
425
|
+
### Migrate to standalone
|
|
426
|
+
|
|
427
|
+
**WARNING: The following command will work only when your application compiles without errors. If you have errors, fix them before continuing.**
|
|
428
|
+
|
|
429
|
+
```bash
|
|
430
|
+
npm run build
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
Fix remaining errors and warnings, then run the following command:
|
|
434
|
+
|
|
435
|
+
```bash
|
|
436
|
+
ng generate @angular/core:standalone
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
Choose **"Convert all components, directives and pipes to standalone"** then
|
|
440
|
+
|
|
441
|
+
✔ Which directory do you want to migrate? **./**
|
|
442
|
+
|
|
443
|
+
```bash
|
|
444
|
+
npm run build
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
```bash
|
|
448
|
+
ng generate @angular/core:standalone
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
Choose **"Remove unnecessary NgModule classes"** then
|
|
452
|
+
|
|
453
|
+
✔ Which directory do you want to migrate? **./**
|
|
454
|
+
|
|
455
|
+
```bash
|
|
456
|
+
npm run build
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
```bash
|
|
460
|
+
ng generate @angular/core:standalone
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
Choose **"Bootstrap the application using standalone APIs"** then
|
|
464
|
+
|
|
465
|
+
✔ Which directory do you want to migrate? **./**
|
|
466
|
+
|
|
467
|
+
#### Now check and fix manually the migration of your `app.component.ts` to standalone
|
|
468
|
+
|
|
469
|
+
It should look like that:
|
|
470
|
+
|
|
471
|
+
```diff
|
|
472
|
+
@Component({
|
|
473
|
+
selector: 'app-root',
|
|
474
|
+
templateUrl: './app.component.html',
|
|
475
|
+
imports: [
|
|
476
|
+
- // eslint-disable-next-line @angular-eslint/prefer-standalone
|
|
477
|
+
- standalone: false
|
|
478
|
+
+ RouterOutlet,
|
|
479
|
+
+ NgHttpLoaderComponent,
|
|
480
|
+
+ RedirectComponent,
|
|
481
|
+
]
|
|
482
|
+
})
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
Create a file under `src/app` called `app.routes.ts` with the following content:
|
|
486
|
+
|
|
487
|
+
```ts
|
|
488
|
+
export const routes: Routes = [
|
|
489
|
+
// Your routes found in app-routing.module.ts go here
|
|
490
|
+
];
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
Create a file under `src/app` called `app.config.ts` with the following content:
|
|
494
|
+
|
|
495
|
+
```ts
|
|
496
|
+
export const appConfig: ApplicationConfig = {
|
|
497
|
+
providers: [
|
|
498
|
+
provideZoneChangeDetection(),
|
|
499
|
+
providePrestationsNgCore(),
|
|
500
|
+
provideRouter(routes),
|
|
501
|
+
META_SERVICE_PROVIDER,
|
|
502
|
+
provideHttpClient(
|
|
503
|
+
withInterceptors([pendingRequestsInterceptor$]),
|
|
504
|
+
withXsrfConfiguration({
|
|
505
|
+
cookieName: 'XSRF-TOKEN',
|
|
506
|
+
headerName: 'X-XSRF-TOKEN',
|
|
507
|
+
}),
|
|
508
|
+
),
|
|
509
|
+
],
|
|
510
|
+
};
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
Now replace the content of `main.ts` with the following content:
|
|
514
|
+
|
|
515
|
+
```ts
|
|
516
|
+
import { bootstrapApplication } from '@angular/platform-browser';
|
|
517
|
+
|
|
518
|
+
import { AppComponent } from './app/app.component';
|
|
519
|
+
import { appConfig } from './app/app.config';
|
|
520
|
+
|
|
521
|
+
bootstrapApplication(AppComponent, appConfig).catch((err) =>
|
|
522
|
+
console.error(err),
|
|
523
|
+
);
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
Clean up your project by removing `app-routing.module.ts` and `app.module.ts` files if it has not already been done.
|
|
527
|
+
|
|
528
|
+
### Migrate from NgClass to class bindings
|
|
529
|
+
|
|
530
|
+
**WARNING: The following command will work only when your application compiles without errors. If you have errors, fix them before continuing.**
|
|
531
|
+
|
|
532
|
+
```bash
|
|
533
|
+
npm run build
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
Fix remaining errors and warnings, then run the following command:
|
|
537
|
+
|
|
538
|
+
```bash
|
|
539
|
+
ng generate @angular/core:ngclass-to-class
|
|
540
|
+
```
|
|
541
|
+
|
|
542
|
+
✔ Which directory do you want to migrate? **./**
|
|
543
|
+
|
|
544
|
+
✔ Should the migration also migrate space-separated keys? **Yes**
|
|
545
|
+
|
|
546
|
+
Check every file that has changed and fix what is broken.
|
|
547
|
+
|
|
548
|
+
Check remaining `ngClass` usage in your project and replace it with class bindings.
|
|
549
|
+
|
|
550
|
+
**Be aware that `[class]` replaces all element classes. When you have static classes, concatenate them with dynamic ones.**
|
|
551
|
+
|
|
552
|
+
Replacement example:
|
|
553
|
+
|
|
554
|
+
Before:
|
|
555
|
+
|
|
556
|
+
```html
|
|
557
|
+
[ngClass]="isLabelSrOnly ? 'visually-hidden' : 'vd-p'"
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
After:
|
|
561
|
+
|
|
562
|
+
```html
|
|
563
|
+
[class.visually-hidden]="isLabelSrOnly()" [class.vd-p]="!isLabelSrOnly()"
|
|
564
|
+
```
|
|
565
|
+
|
|
566
|
+
---
|
|
567
|
+
|
|
568
|
+
Before:
|
|
569
|
+
|
|
570
|
+
```html
|
|
571
|
+
class="modal" [ngClass]="modalSize"
|
|
572
|
+
```
|
|
573
|
+
|
|
574
|
+
After:
|
|
575
|
+
|
|
576
|
+
```html
|
|
577
|
+
[class]="'modal ' + modalSize()"
|
|
578
|
+
```
|
|
579
|
+
|
|
580
|
+
---
|
|
581
|
+
|
|
582
|
+
Before:
|
|
583
|
+
|
|
584
|
+
```html
|
|
585
|
+
class="form-label" [ngClass]="isLabelSrOnly() ? 'visually-hidden' :
|
|
586
|
+
labelStyleModifier()"
|
|
587
|
+
```
|
|
588
|
+
|
|
589
|
+
After:
|
|
590
|
+
|
|
591
|
+
```html
|
|
592
|
+
[class]="'form-label ' + (isLabelSrOnly() ? 'visually-hidden' :
|
|
593
|
+
(labelStyleModifier() ?? ''))"
|
|
594
|
+
```
|
|
595
|
+
|
|
596
|
+
### Migrate from NgStyle to style bindings
|
|
597
|
+
|
|
598
|
+
**WARNING: The following command will work only when your application compiles without errors. If you have errors, fix them before continuing.**
|
|
599
|
+
|
|
600
|
+
```bash
|
|
601
|
+
npm run build
|
|
602
|
+
```
|
|
603
|
+
|
|
604
|
+
Fix remaining errors and warnings, then run the following command:
|
|
605
|
+
|
|
606
|
+
```bash
|
|
607
|
+
ng generate @angular/core:ngstyle-to-style
|
|
608
|
+
```
|
|
609
|
+
|
|
610
|
+
✔ Which directory do you want to migrate? **./**
|
|
611
|
+
|
|
612
|
+
✔ Should the migration also migrate object references? **No**
|
|
613
|
+
|
|
614
|
+
Check every file that has changed and fix what is broken.
|
|
615
|
+
|
|
616
|
+
Check remaining `ngStyle` usage in your project and replace it with style bindings.
|
|
617
|
+
|
|
618
|
+
### Convert CommonModule usage to standalone imports
|
|
619
|
+
|
|
620
|
+
**WARNING: The following command will work only when your application compiles without errors. If you have errors, fix them before continuing.**
|
|
621
|
+
|
|
622
|
+
```bash
|
|
623
|
+
npm run build
|
|
624
|
+
```
|
|
625
|
+
|
|
626
|
+
Fix remaining errors and warnings, then run the following command:
|
|
627
|
+
|
|
628
|
+
```bash
|
|
629
|
+
ng generate @angular/core:common-to-standalone
|
|
630
|
+
```
|
|
631
|
+
|
|
632
|
+
✔ Which directory do you want to migrate? **./**
|
|
633
|
+
|
|
634
|
+
Check every file that has changed and fix what is broken.
|
|
635
|
+
|
|
636
|
+
### Migrate @HostListener
|
|
637
|
+
|
|
638
|
+
Search for `@HostListener` in your project and replace it with the `host` object in the `@Component` or `@Directive` decorator.
|
|
639
|
+
|
|
640
|
+
For example, when using `@HostListener` in a directive:
|
|
641
|
+
|
|
642
|
+
Before:
|
|
643
|
+
|
|
644
|
+
```ts
|
|
645
|
+
@Directive({
|
|
646
|
+
selector: '[numberCurrencyFormatter]',
|
|
647
|
+
})
|
|
648
|
+
export class NumberCurrencyFormatterDirective implements OnInit {
|
|
649
|
+
@HostListener('blur', ['$event.target.value'])
|
|
650
|
+
onBlur(value: string): void {
|
|
651
|
+
this.hasFocus = false;
|
|
652
|
+
this.setFormatting(value);
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
```
|
|
656
|
+
|
|
657
|
+
After:
|
|
658
|
+
|
|
659
|
+
```ts
|
|
660
|
+
@Directive({
|
|
661
|
+
selector: '[numberCurrencyFormatter]',
|
|
662
|
+
host: {
|
|
663
|
+
'(blur)': 'onBlur($event)',
|
|
664
|
+
},
|
|
665
|
+
})
|
|
666
|
+
export class NumberCurrencyFormatterDirective implements OnInit {
|
|
667
|
+
onBlur(event: FocusEvent): void {
|
|
668
|
+
this.hasFocus = false;
|
|
669
|
+
const value = (event.target as HTMLInputElement).value;
|
|
670
|
+
this.setFormatting(value);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
```
|
|
674
|
+
|
|
675
|
+
### Migrate to signal queries
|
|
676
|
+
|
|
677
|
+
**WARNING: The following command will work only when your application compiles without errors. If you have errors, fix them before continuing.**
|
|
678
|
+
|
|
679
|
+
```bash
|
|
680
|
+
npm run build
|
|
681
|
+
```
|
|
682
|
+
|
|
683
|
+
Fix remaining errors and warnings, then run the following command:
|
|
684
|
+
|
|
685
|
+
```bash
|
|
686
|
+
ng generate @angular/core:signal-queries-migration --insert-todos
|
|
687
|
+
```
|
|
688
|
+
|
|
689
|
+
✔ Which directory do you want to migrate? **./**
|
|
690
|
+
|
|
691
|
+
✔ Do you want to migrate as much as possible, even if it may break your build? **No**
|
|
692
|
+
|
|
693
|
+
Check every file that has changed and fix what is broken.
|
|
694
|
+
|
|
695
|
+
Check every remaining `@ViewChild`, `@ViewChildren`, `@ContentChild`, and `@ContentChildren` usage in your project and replace them with signal queries.
|
|
696
|
+
|
|
697
|
+
Check every **TODO** comment added by the migration and fix them.
|
|
698
|
+
|
|
699
|
+
### Migrate to output functions
|
|
700
|
+
|
|
701
|
+
**WARNING: The following command will work only when your application compiles without errors. If you have errors, fix them before continuing.**
|
|
702
|
+
|
|
703
|
+
```bash
|
|
704
|
+
npm run build
|
|
705
|
+
```
|
|
706
|
+
|
|
707
|
+
Fix remaining errors and warnings, then run the following command:
|
|
708
|
+
|
|
709
|
+
```bash
|
|
710
|
+
ng generate @angular/core:output-migration
|
|
711
|
+
```
|
|
712
|
+
|
|
713
|
+
✔ Which directory do you want to migrate? **./**
|
|
714
|
+
|
|
715
|
+
Check every remaining `@Output` usage in your project and replace them with output function.
|
|
716
|
+
|
|
717
|
+
When needing to subscribe to an output, you can use `outputToObservable` from `@angular/core/rxjs-interop`.
|
|
718
|
+
|
|
719
|
+
### Migrate to input signals
|
|
720
|
+
|
|
721
|
+
Check our [Angular signals guide](ANGULAR_SIGNALS.md) for more information about signals and input signals.
|
|
722
|
+
|
|
723
|
+
**WARNING: The following command will work only when your application compiles without errors. If you have errors, fix them before continuing.**
|
|
724
|
+
|
|
725
|
+
```bash
|
|
726
|
+
npm run build
|
|
727
|
+
```
|
|
728
|
+
|
|
729
|
+
Fix remaining errors and warnings, then run the following command:
|
|
730
|
+
|
|
731
|
+
```bash
|
|
732
|
+
ng generate @angular/core:signal-input-migration --insert-todos
|
|
733
|
+
```
|
|
734
|
+
|
|
735
|
+
✔ Which directory do you want to migrate? **./**
|
|
736
|
+
|
|
737
|
+
✔ Do you want to migrate as much as possible, even if it may break your build? **No**
|
|
738
|
+
|
|
739
|
+
Check every file that has changed and fix what is broken.
|
|
740
|
+
|
|
741
|
+
Check every remaining `@Input` usage in your project and replace them with input signals.
|
|
742
|
+
|
|
743
|
+
Check every **TODO** comment added by the migration and fix them.
|
|
744
|
+
|
|
745
|
+
### Migrate to vitest
|
|
746
|
+
|
|
747
|
+
[Angular migration guide: migrating to Vitest](https://angular.dev/guide/testing/migrating-to-vitest)
|
|
748
|
+
|
|
749
|
+
```bash
|
|
750
|
+
npm install --save-dev vitest jsdom
|
|
751
|
+
```
|
|
752
|
+
|
|
753
|
+
In your `angular.json` file, remove `"zone.js/dist/zone-error"` from `"allowedCommonJsDependencies"`
|
|
754
|
+
|
|
755
|
+
then find the `test` target for your project and change the `builder` to `@angular/build:unit-test` and add following options:
|
|
756
|
+
|
|
757
|
+
```json
|
|
758
|
+
{
|
|
759
|
+
"projects": {
|
|
760
|
+
"your-project-name": {
|
|
761
|
+
"architect": {
|
|
762
|
+
"test": {
|
|
763
|
+
"builder": "@angular/build:unit-test",
|
|
764
|
+
"options": {
|
|
765
|
+
"buildTarget": "your-project-name:build"
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
```
|
|
773
|
+
|
|
774
|
+
In your package.json file, add the following scripts:
|
|
775
|
+
|
|
776
|
+
```diff
|
|
777
|
+
{
|
|
778
|
+
"scripts": {
|
|
779
|
+
- "test": "ng test",
|
|
780
|
+
+ "test": "ng test --watch=false",
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
```
|
|
784
|
+
|
|
785
|
+
In your `tsconfig.spec.json` file, remove from `types` `jasmine` and `node` and add `vitest/globals`:
|
|
786
|
+
|
|
787
|
+
```diff
|
|
788
|
+
{
|
|
789
|
+
"compilerOptions": {
|
|
790
|
+
"types": [
|
|
791
|
+
- "jasmine",
|
|
792
|
+
- "node"
|
|
793
|
+
+ "vitest/globals"
|
|
794
|
+
]
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
```
|
|
798
|
+
|
|
799
|
+
In your `.gitignore` file, add the following line to ignore the `screenshot` folder:
|
|
800
|
+
|
|
801
|
+
```
|
|
802
|
+
__screenshots__
|
|
803
|
+
```
|
|
804
|
+
|
|
805
|
+
Now remove karma and jasmine dependencies
|
|
806
|
+
|
|
807
|
+
```bash
|
|
808
|
+
npm uninstall jasmine jasmine-core jasmine-spec-reporter
|
|
809
|
+
npm uninstall karma karma-chrome-launcher karma-coverage karma-jasmine karma-jasmine-html-reporter
|
|
810
|
+
npm uninstall puppeteer
|
|
811
|
+
npm uninstall @types/jasmine @types/jasminewd2
|
|
812
|
+
rm karma.conf.js
|
|
813
|
+
```
|
|
814
|
+
|
|
815
|
+
Now search for `karma.conf.js` in your project and remove all references to it.
|
|
816
|
+
Now search for `protractor.conf.js` in your project and remove them if they still exist.
|
|
817
|
+
|
|
818
|
+
Then run following command to migrate from jasmine to vitest:
|
|
819
|
+
|
|
820
|
+
```bash
|
|
821
|
+
ng g @schematics/angular:refactor-jasmine-vitest
|
|
822
|
+
```
|
|
823
|
+
|
|
824
|
+
Now you can run your tests with `npm test` and check that everything is up and running.
|
|
825
|
+
|
|
826
|
+
In your tests, replace `waitForAsync(() => ...)` by `async(...)` and add `await` before `TestBed.configureTestingModule`.
|
|
827
|
+
For example, replace this:
|
|
828
|
+
|
|
829
|
+
Before:
|
|
830
|
+
|
|
831
|
+
```ts
|
|
832
|
+
import {
|
|
833
|
+
provideHttpClient,
|
|
834
|
+
withInterceptorsFromDi,
|
|
835
|
+
} from '@angular/common/http';
|
|
836
|
+
import { provideHttpClientTesting } from '@angular/common/http/testing';
|
|
837
|
+
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
|
838
|
+
import { RouterModule } from '@angular/router';
|
|
839
|
+
|
|
840
|
+
import { AppComponent } from './app.component';
|
|
841
|
+
import { AppModule } from './app.module';
|
|
842
|
+
|
|
843
|
+
describe('AppComponent', () => {
|
|
844
|
+
let component: AppComponent;
|
|
845
|
+
let fixture: ComponentFixture<AppComponent>;
|
|
846
|
+
|
|
847
|
+
beforeEach(waitForAsync(() => {
|
|
848
|
+
TestBed.configureTestingModule({
|
|
849
|
+
imports: [AppModule, RouterModule.forRoot([])],
|
|
850
|
+
providers: [
|
|
851
|
+
provideHttpClient(withInterceptorsFromDi()),
|
|
852
|
+
provideHttpClientTesting(),
|
|
853
|
+
],
|
|
854
|
+
}).compileComponents();
|
|
855
|
+
}));
|
|
856
|
+
|
|
857
|
+
beforeEach(() => {
|
|
858
|
+
fixture = TestBed.createComponent(AppComponent);
|
|
859
|
+
component = fixture.componentInstance;
|
|
860
|
+
fixture.detectChanges();
|
|
861
|
+
});
|
|
862
|
+
|
|
863
|
+
it('should create', () => {
|
|
864
|
+
expect(component).toBeTruthy();
|
|
865
|
+
});
|
|
866
|
+
});
|
|
867
|
+
```
|
|
868
|
+
|
|
869
|
+
After:
|
|
870
|
+
|
|
871
|
+
```ts
|
|
872
|
+
import {
|
|
873
|
+
provideHttpClient,
|
|
874
|
+
withInterceptorsFromDi,
|
|
875
|
+
} from '@angular/common/http';
|
|
876
|
+
import { provideHttpClientTesting } from '@angular/common/http/testing';
|
|
877
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
878
|
+
import { provideRouter } from '@angular/router';
|
|
879
|
+
|
|
880
|
+
import { AppComponent } from './app.component';
|
|
881
|
+
|
|
882
|
+
describe('AppComponent', () => {
|
|
883
|
+
let component: AppComponent;
|
|
884
|
+
let fixture: ComponentFixture<AppComponent>;
|
|
885
|
+
|
|
886
|
+
beforeEach(async () => {
|
|
887
|
+
await TestBed.configureTestingModule({
|
|
888
|
+
imports: [AppComponent],
|
|
889
|
+
providers: [
|
|
890
|
+
provideHttpClient(withInterceptorsFromDi()),
|
|
891
|
+
provideHttpClientTesting(),
|
|
892
|
+
provideRouter([]),
|
|
893
|
+
],
|
|
894
|
+
}).compileComponents();
|
|
895
|
+
|
|
896
|
+
fixture = TestBed.createComponent(AppComponent);
|
|
897
|
+
component = fixture.componentInstance;
|
|
898
|
+
await fixture.whenStable();
|
|
899
|
+
});
|
|
900
|
+
|
|
901
|
+
it('should create', () => {
|
|
902
|
+
expect(component).toBeTruthy();
|
|
903
|
+
});
|
|
904
|
+
});
|
|
905
|
+
```
|
|
906
|
+
|
|
907
|
+
### Migrate to eslint flat configuration
|
|
908
|
+
|
|
909
|
+
```bash
|
|
910
|
+
npm uninstall @angular-eslint/builder @angular-eslint/eslint-plugin @angular-eslint/eslint-plugin-template @angular-eslint/template-parser
|
|
911
|
+
npm uninstall @typescript-eslint/eslint-plugin @typescript-eslint/parser @typescript-eslint/types @typescript-eslint/utils
|
|
912
|
+
npm uninstall eslint-import-resolver-typescript eslint-plugin-cypress eslint-plugin-import eslint-plugin-jasmine eslint-plugin-rxjs eslint-plugin-rxjs-angular eslint-plugin-simple-npm eslint-plugin-simple-import-sort
|
|
913
|
+
npm uninstall eslint
|
|
914
|
+
|
|
915
|
+
npm install --save-dev eslint@^9 angular-eslint@21 typescript-eslint@^8
|
|
916
|
+
npm install --save-dev @typescript-eslint/parser@8 @smarttools/eslint-plugin-rxjs@1
|
|
917
|
+
npm install --save-dev eslint-plugin-simple-import-sort@13
|
|
918
|
+
npm install --save-dev eslint-config-prettier@10
|
|
919
|
+
npm install --save-dev eslint-plugin-import-x@4
|
|
920
|
+
npm install --save-dev prettier
|
|
921
|
+
```
|
|
922
|
+
|
|
923
|
+
In your `front` folder, add a `.prettierrc` file with the following content:
|
|
924
|
+
|
|
925
|
+
```json
|
|
926
|
+
{
|
|
927
|
+
"printWidth": 100,
|
|
928
|
+
"singleQuote": true,
|
|
929
|
+
"arrowParens": "always",
|
|
930
|
+
"trailingComma": "all",
|
|
931
|
+
"htmlWhitespaceSensitivity": "css",
|
|
932
|
+
"overrides": [
|
|
933
|
+
{
|
|
934
|
+
"files": ["*.html"],
|
|
935
|
+
"options": {
|
|
936
|
+
"parser": "angular"
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
]
|
|
940
|
+
}
|
|
941
|
+
```
|
|
942
|
+
|
|
943
|
+
Add a `.prettierignore` file with the following content:
|
|
944
|
+
|
|
945
|
+
```text
|
|
946
|
+
node_modules
|
|
947
|
+
.git
|
|
948
|
+
target
|
|
949
|
+
package.json
|
|
950
|
+
package-lock.json
|
|
951
|
+
dist
|
|
952
|
+
coverage
|
|
953
|
+
.angular
|
|
954
|
+
```
|
|
955
|
+
|
|
956
|
+
Remove your old `.eslintrc.json` file in your `front` folder:
|
|
957
|
+
|
|
958
|
+
```bash
|
|
959
|
+
rm .eslintrc.json
|
|
960
|
+
```
|
|
961
|
+
|
|
962
|
+
Now search for `.eslintrc.json` in your project and remove them.
|
|
963
|
+
|
|
964
|
+
Then add a new `eslint.config.mjs` file with the following content:
|
|
965
|
+
|
|
966
|
+
```ts
|
|
967
|
+
// @ts-check
|
|
968
|
+
import eslint from '@eslint/js';
|
|
969
|
+
import tseslint from 'typescript-eslint';
|
|
970
|
+
import angular from 'angular-eslint';
|
|
971
|
+
import rxjs from '@smarttools/eslint-plugin-rxjs';
|
|
972
|
+
import simpleImportSort from 'eslint-plugin-simple-import-sort';
|
|
973
|
+
import prettier from 'eslint-config-prettier';
|
|
974
|
+
import importX from 'eslint-plugin-import-x';
|
|
975
|
+
|
|
976
|
+
export default tseslint.config(
|
|
977
|
+
{
|
|
978
|
+
ignores: ['**/coverage/**', '**/dist/**'],
|
|
979
|
+
},
|
|
980
|
+
|
|
981
|
+
// ─── TypeScript ────────────────────────────────────────────────────────────
|
|
982
|
+
{
|
|
983
|
+
files: ['**/*.ts'],
|
|
984
|
+
extends: [
|
|
985
|
+
eslint.configs.recommended,
|
|
986
|
+
...tseslint.configs.recommended, // covers: no-explicit-any, ban-ts-comment,
|
|
987
|
+
// no-unused-expressions, no-var, no-unused-vars…
|
|
988
|
+
...tseslint.configs.stylistic, // covers: array-type, consistent-type-assertions,
|
|
989
|
+
// dot-notation, no-inferrable-types (default options),
|
|
990
|
+
// no-empty-function (error), prefer-for-of,
|
|
991
|
+
// prefer-function-type…
|
|
992
|
+
...angular.configs.tsRecommended, // covers: prefer-inject, no-empty-lifecycle-method,
|
|
993
|
+
// use-lifecycle-interface…
|
|
994
|
+
],
|
|
995
|
+
languageOptions: {
|
|
996
|
+
parserOptions: {
|
|
997
|
+
projectService: true,
|
|
998
|
+
tsconfigRootDir: import.meta.dirname,
|
|
999
|
+
},
|
|
1000
|
+
},
|
|
1001
|
+
plugins: {
|
|
1002
|
+
rxjs,
|
|
1003
|
+
'simple-import-sort': simpleImportSort,
|
|
1004
|
+
'import-x': importX,
|
|
1005
|
+
},
|
|
1006
|
+
processor: angular.processInlineTemplates,
|
|
1007
|
+
rules: {
|
|
1008
|
+
// ── @angular-eslint ──────────────────────────────────────────────
|
|
1009
|
+
'@angular-eslint/component-selector': [
|
|
1010
|
+
'error',
|
|
1011
|
+
{
|
|
1012
|
+
type: 'element',
|
|
1013
|
+
prefix: 'app',
|
|
1014
|
+
style: 'kebab-case',
|
|
1015
|
+
},
|
|
1016
|
+
],
|
|
1017
|
+
'@angular-eslint/directive-selector': [
|
|
1018
|
+
'error',
|
|
1019
|
+
{
|
|
1020
|
+
type: 'attribute',
|
|
1021
|
+
prefix: 'app',
|
|
1022
|
+
style: 'camelCase',
|
|
1023
|
+
},
|
|
1024
|
+
],
|
|
1025
|
+
|
|
1026
|
+
// ── @typescript-eslint ───────────────────────────────────────────
|
|
1027
|
+
'@typescript-eslint/explicit-function-return-type': [
|
|
1028
|
+
'error',
|
|
1029
|
+
{
|
|
1030
|
+
allowExpressions: true,
|
|
1031
|
+
allowTypedFunctionExpressions: true,
|
|
1032
|
+
allowHigherOrderFunctions: true,
|
|
1033
|
+
allowDirectConstAssertionInArrowFunctions: true,
|
|
1034
|
+
},
|
|
1035
|
+
],
|
|
1036
|
+
'@typescript-eslint/explicit-member-accessibility': [
|
|
1037
|
+
'error',
|
|
1038
|
+
{ accessibility: 'no-public' },
|
|
1039
|
+
],
|
|
1040
|
+
'@typescript-eslint/member-delimiter-style': 'error',
|
|
1041
|
+
'@typescript-eslint/member-ordering': 'error',
|
|
1042
|
+
'@typescript-eslint/no-base-to-string': 'warn',
|
|
1043
|
+
// stylistic enables no-inferrable-types with default options (ignoreParameters: false);
|
|
1044
|
+
// override here to allow typed parameters explicitly
|
|
1045
|
+
'@typescript-eslint/no-inferrable-types': [
|
|
1046
|
+
'error',
|
|
1047
|
+
{ ignoreParameters: true },
|
|
1048
|
+
],
|
|
1049
|
+
// stylistic sets no-empty-function to error; downgrade to warn
|
|
1050
|
+
'@typescript-eslint/no-empty-function': 'warn',
|
|
1051
|
+
'@typescript-eslint/prefer-includes': 'warn',
|
|
1052
|
+
'@typescript-eslint/return-await': ['error', 'never'],
|
|
1053
|
+
'@typescript-eslint/typedef': ['error', { parameter: true }],
|
|
1054
|
+
'@typescript-eslint/unified-signatures': 'error',
|
|
1055
|
+
// off here — @typescript-eslint/no-shadow handles it correctly for TS
|
|
1056
|
+
'no-shadow': 'off',
|
|
1057
|
+
'@typescript-eslint/no-shadow': ['error', { hoist: 'all' }],
|
|
1058
|
+
'@typescript-eslint/no-unused-vars': [
|
|
1059
|
+
'error',
|
|
1060
|
+
{
|
|
1061
|
+
varsIgnorePattern: '^_',
|
|
1062
|
+
argsIgnorePattern: '^_',
|
|
1063
|
+
caughtErrorsIgnorePattern: '^_',
|
|
1064
|
+
},
|
|
1065
|
+
],
|
|
1066
|
+
|
|
1067
|
+
// ── eslint core ──────────────────────────────────────────────────
|
|
1068
|
+
'arrow-body-style': 'error',
|
|
1069
|
+
'arrow-parens': ['error', 'as-needed'],
|
|
1070
|
+
curly: 'error',
|
|
1071
|
+
eqeqeq: ['error', 'always'],
|
|
1072
|
+
'guard-for-in': 'error',
|
|
1073
|
+
'no-bitwise': 'error',
|
|
1074
|
+
'no-caller': 'error',
|
|
1075
|
+
'no-console': ['error', { allow: ['log', 'warn', 'error'] }],
|
|
1076
|
+
'no-eval': 'error',
|
|
1077
|
+
'no-extra-boolean-cast': 'off',
|
|
1078
|
+
'no-multiple-empty-lines': 'error',
|
|
1079
|
+
'no-new-wrappers': 'error',
|
|
1080
|
+
'no-restricted-imports': [
|
|
1081
|
+
'error',
|
|
1082
|
+
{ paths: ['rxjs/Rx', 'primeng/primeng', 'primeng'] },
|
|
1083
|
+
],
|
|
1084
|
+
'no-return-assign': 'error',
|
|
1085
|
+
'no-throw-literal': 'error',
|
|
1086
|
+
'no-undef-init': 'error',
|
|
1087
|
+
'no-useless-concat': 'error',
|
|
1088
|
+
'object-shorthand': ['error', 'always', { avoidQuotes: true }],
|
|
1089
|
+
'one-var': ['error', 'never'],
|
|
1090
|
+
'prefer-arrow-callback': 'error',
|
|
1091
|
+
'prefer-template': 'error',
|
|
1092
|
+
radix: 'error',
|
|
1093
|
+
|
|
1094
|
+
// ── rxjs ─────────────────────────────────────────────────────────
|
|
1095
|
+
'rxjs/no-implicit-any-catch': ['error', { allowExplicitAny: true }],
|
|
1096
|
+
'rxjs/no-sharereplay': 'off',
|
|
1097
|
+
|
|
1098
|
+
// ── import-x ─────────────────────────────────────────────────────
|
|
1099
|
+
'import-x/no-cycle': [
|
|
1100
|
+
'warn',
|
|
1101
|
+
{ maxDepth: 3, ignoreExternal: true },
|
|
1102
|
+
],
|
|
1103
|
+
'import-x/no-deprecated': 'warn',
|
|
1104
|
+
'import-x/first': 'error',
|
|
1105
|
+
'import-x/newline-after-import': 'error',
|
|
1106
|
+
'import-x/no-duplicates': 'error',
|
|
1107
|
+
|
|
1108
|
+
// ── simple-import-sort ───────────────────────────────────────────
|
|
1109
|
+
'simple-import-sort/imports': 'error',
|
|
1110
|
+
'simple-import-sort/exports': 'error',
|
|
1111
|
+
},
|
|
1112
|
+
},
|
|
1113
|
+
|
|
1114
|
+
// ─── HTML templates ────────────────────────────────────────────────────────
|
|
1115
|
+
{
|
|
1116
|
+
files: ['**/*.html'],
|
|
1117
|
+
extends: [
|
|
1118
|
+
...angular.configs.templateRecommended,
|
|
1119
|
+
...angular.configs.templateAccessibility,
|
|
1120
|
+
],
|
|
1121
|
+
rules: {
|
|
1122
|
+
'@angular-eslint/template/no-negated-async': 'off',
|
|
1123
|
+
'@angular-eslint/template/button-has-type': 'error',
|
|
1124
|
+
},
|
|
1125
|
+
},
|
|
1126
|
+
|
|
1127
|
+
// ─── Prettier (must be last — disables formatting rules) ───────────────────
|
|
1128
|
+
prettier,
|
|
1129
|
+
);
|
|
1130
|
+
```
|
|
1131
|
+
|
|
1132
|
+
#### Delete `typing.d.ts`
|
|
1133
|
+
|
|
1134
|
+
In `front/src/`, remove the file `typing.d.ts` if it is still there.
|
|
1135
|
+
|
|
1136
|
+
#### Update your tsconfig\*.json files
|
|
1137
|
+
|
|
1138
|
+
- Replace your `tsconfig.json` content with:
|
|
1139
|
+
|
|
1140
|
+
```json
|
|
1141
|
+
{
|
|
1142
|
+
"compileOnSave": false,
|
|
1143
|
+
"compilerOptions": {
|
|
1144
|
+
"outDir": "./dist/out-tsc",
|
|
1145
|
+
"noImplicitOverride": true,
|
|
1146
|
+
"noImplicitReturns": true,
|
|
1147
|
+
"noFallthroughCasesInSwitch": true,
|
|
1148
|
+
"skipLibCheck": true,
|
|
1149
|
+
"esModuleInterop": true,
|
|
1150
|
+
"sourceMap": true,
|
|
1151
|
+
"declaration": false,
|
|
1152
|
+
"experimentalDecorators": true,
|
|
1153
|
+
"useDefineForClassFields": false,
|
|
1154
|
+
"moduleResolution": "bundler",
|
|
1155
|
+
"importHelpers": true,
|
|
1156
|
+
"isolatedModules": true,
|
|
1157
|
+
"target": "ES2022",
|
|
1158
|
+
"module": "ES2022",
|
|
1159
|
+
"paths": {
|
|
1160
|
+
"@dsivd/prestations-ng": ["./node_modules/@dsivd/prestations-ng"]
|
|
1161
|
+
}
|
|
1162
|
+
},
|
|
1163
|
+
"angularCompilerOptions": {
|
|
1164
|
+
"enableI18nLegacyMessageIdFormat": false,
|
|
1165
|
+
"strictInjectionParameters": true,
|
|
1166
|
+
"strictInputAccessModifiers": true,
|
|
1167
|
+
"strictTemplates": true,
|
|
1168
|
+
"strictStandalone": true
|
|
1169
|
+
},
|
|
1170
|
+
"files": [],
|
|
1171
|
+
"references": [
|
|
1172
|
+
{
|
|
1173
|
+
"path": "./tsconfig.app.json"
|
|
1174
|
+
},
|
|
1175
|
+
{
|
|
1176
|
+
"path": "./tsconfig.spec.json"
|
|
1177
|
+
}
|
|
1178
|
+
]
|
|
1179
|
+
}
|
|
1180
|
+
```
|
|
1181
|
+
|
|
1182
|
+
- Replace your `tsconfig.app.json` content with:
|
|
1183
|
+
|
|
1184
|
+
```json
|
|
1185
|
+
{
|
|
1186
|
+
"extends": "./tsconfig.json",
|
|
1187
|
+
"compilerOptions": {
|
|
1188
|
+
"outDir": "../out-tsc/app",
|
|
1189
|
+
"types": []
|
|
1190
|
+
},
|
|
1191
|
+
"include": ["src/**/*.ts"],
|
|
1192
|
+
"exclude": ["src/**/*.spec.ts"]
|
|
1193
|
+
}
|
|
1194
|
+
```
|
|
1195
|
+
|
|
1196
|
+
- Update your package.json, add the following script to run eslint:
|
|
1197
|
+
|
|
1198
|
+
```diff
|
|
1199
|
+
"scripts": {
|
|
1200
|
+
- "lint": "ng lint",
|
|
1201
|
+
+ "lint": "ng lint --fix=true",
|
|
1202
|
+
+ "format:prettier": "prettier --config ./.prettierrc --write \"{,!(.scannerwork|target|coverage|node_modules|.angular)/**/}*{.ts,.js,.jsx,.json,.css,.scss,.md,.html}\"",
|
|
1203
|
+
}
|
|
1204
|
+
```
|
|
1205
|
+
|
|
1206
|
+
### Husky pre-commit hook
|
|
1207
|
+
|
|
1208
|
+
```bash
|
|
1209
|
+
npm install --save-dev husky lint-staged
|
|
1210
|
+
npx husky init
|
|
1211
|
+
echo "cd front" > .husky/pre-commit
|
|
1212
|
+
echo "npx lint-staged" >> .husky/pre-commit
|
|
1213
|
+
chmod +x .husky/pre-commit
|
|
1214
|
+
mv ./.husky ../.husky
|
|
1215
|
+
git add -A
|
|
1216
|
+
```
|
|
1217
|
+
|
|
1218
|
+
- You can manually run formating commands as well:
|
|
1219
|
+
|
|
1220
|
+
```bash
|
|
1221
|
+
npm run format:prettier
|
|
1222
|
+
npm run lint
|
|
1223
|
+
```
|
|
1224
|
+
|
|
1225
|
+
Fix your `meta.service.ts` but replacing:
|
|
1226
|
+
|
|
1227
|
+
Before:
|
|
1228
|
+
|
|
1229
|
+
```ts
|
|
1230
|
+
export const metaServiceFactory =
|
|
1231
|
+
(metaService: MetaService): Function =>
|
|
1232
|
+
() =>
|
|
1233
|
+
lastValueFrom(metaService.load());
|
|
1234
|
+
|
|
1235
|
+
export const META_SERVICE_PROVIDER = provideAppInitializer(() => {
|
|
1236
|
+
const initializerFn = metaServiceFactory(inject(MetaService));
|
|
1237
|
+
return initializerFn();
|
|
1238
|
+
});
|
|
1239
|
+
```
|
|
1240
|
+
|
|
1241
|
+
After:
|
|
1242
|
+
|
|
1243
|
+
```ts
|
|
1244
|
+
export const META_SERVICE_PROVIDER = provideAppInitializer(() => {
|
|
1245
|
+
const metaService = inject(MetaService);
|
|
1246
|
+
return lastValueFrom(metaService.load());
|
|
1247
|
+
});
|
|
1248
|
+
```
|
|
1249
|
+
|
|
1250
|
+
Run again until no more errors:
|
|
1251
|
+
|
|
1252
|
+
```bash
|
|
1253
|
+
npm run lint
|
|
1254
|
+
```
|
|
1255
|
+
|
|
1256
|
+
Then:
|
|
1257
|
+
|
|
1258
|
+
```bash
|
|
1259
|
+
npm run format:prettier
|
|
1260
|
+
```
|
|
1261
|
+
|
|
1262
|
+
### Browsers list update
|
|
1263
|
+
|
|
1264
|
+
Run update schematic:
|
|
1265
|
+
|
|
1266
|
+
```bash
|
|
1267
|
+
ng g @dsivd/prestations-ng:replace-browsers-list
|
|
1268
|
+
```
|
|
1269
|
+
|
|
1270
|
+
### Remove deprecated packages
|
|
1271
|
+
|
|
1272
|
+
```bash
|
|
1273
|
+
npm uninstall @angular/platform-browser-dynamic
|
|
1274
|
+
npm uninstall @angular/animations
|
|
1275
|
+
```
|
|
1276
|
+
|
|
1277
|
+
### Configure IntelliJ IDEA to use ESLint and Prettier on save
|
|
1278
|
+
|
|
1279
|
+
- To configure ESLint automatically in the current project, open "_File -> Settings..._" (`Ctrl+Alt+S`) and either:
|
|
1280
|
+
- Search for `ESLint` and check radio box "_Automatic ESLint configuration_" and check checkbox "_Run eslint --fix on save_"
|
|
1281
|
+
- Search for `Prettier` and check radio box "_Automatic Prettier configuration_" and check checkbox "_Run on save_"
|
|
1282
|
+
|
|
1283
|
+
### Language deprecations
|
|
1284
|
+
|
|
1285
|
+
When using `IntelliJ`, you can run code inspection on your project to fix deprecations manually. Two ways:
|
|
1286
|
+
|
|
1287
|
+
- IntelliJ window menu, go to: `Code > Analyze code > Run inspection by name...` (or **Ctrl+Alt+Maj+i**) and type `Deprecated symbol used`.
|
|
1288
|
+
- Or select your project in your project panel and `right click` on it then `Analyze > Run inspection by name...` (or **Ctrl+Alt+Maj+i**) and type `Deprecated symbol used`.
|
|
1289
|
+
|
|
1290
|
+
### Last but not least, check if your application is working!!!
|
|
1291
|
+
|
|
1292
|
+
#### Be sure your application gets a fresh start
|
|
1293
|
+
|
|
1294
|
+
```bash
|
|
1295
|
+
rm -rf .angular/
|
|
1296
|
+
rm -rf node_modules/
|
|
1297
|
+
npm install
|
|
1298
|
+
```
|
|
1299
|
+
|
|
1300
|
+
#### Build and launch your application
|
|
1301
|
+
|
|
1302
|
+
**NB: You will most probably need to fix some compilation errors such as adding `override` when needed**
|
|
1303
|
+
|
|
1304
|
+
```bash
|
|
1305
|
+
npm run build
|
|
1306
|
+
npm start
|
|
1307
|
+
```
|
|
1308
|
+
|
|
1309
|
+
You're good if no errors are remaining!
|
|
1310
|
+
Finally check if your tests run well :
|
|
1311
|
+
|
|
1312
|
+
```bash
|
|
1313
|
+
npm run test
|
|
1314
|
+
```
|
|
1315
|
+
|
|
1316
|
+
> 🚨 **Read carefully following [PITFALLS](ANGULAR_SIGNALS.md#common_pitfalls), especially points 4, 6 & 8 and check again your application**
|