From 01deaf6dc2a3687edbaf96af07f16c9a8a67f3de Mon Sep 17 00:00:00 2001 From: Bastien Dumont <bdumont@grandlyon.com> Date: Thu, 16 Nov 2023 16:52:51 +0100 Subject: [PATCH 01/13] deps: remove tslint --- package-lock.json | 18 +++++++++++++++--- package.json | 1 - 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2c7a25c5a..a7e0a1c2b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -75,7 +75,6 @@ "standard-version": "^9.3.2", "storybook": "^7.5.3", "ts-node": "~8.10.0", - "tslint": "~6.1.0", "typescript": "~4.9.4" } }, @@ -27973,6 +27972,7 @@ "integrity": "sha512-IbR4nkT96EQOvKE2PW/djGz8iGNeJ4rF2mBfiYaR/nvUWYKJhLwimoJKgjIFEIDibBtOevj7BqCRL4oHeWWUCg==", "deprecated": "TSLint has been deprecated in favor of ESLint. Please see https://github.com/palantir/tslint/issues/4534 for more information.", "dev": true, + "peer": true, "dependencies": { "@babel/code-frame": "^7.0.0", "builtin-modules": "^1.1.1", @@ -28003,6 +28003,7 @@ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, + "peer": true, "dependencies": { "color-convert": "^1.9.0" }, @@ -28015,6 +28016,7 @@ "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", "integrity": "sha512-wxXCdllwGhI2kCC0MnvTGYTMvnVZTvqgypkiTI8Pa5tcz2i6VqsqwYGgqwXji+4RgCzms6EajE4IxiUH6HH8nQ==", "dev": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -28024,6 +28026,7 @@ "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", "dev": true, + "peer": true, "dependencies": { "ansi-styles": "^3.2.1", "escape-string-regexp": "^1.0.5", @@ -28038,6 +28041,7 @@ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", "dev": true, + "peer": true, "dependencies": { "color-name": "1.1.3" } @@ -28046,13 +28050,15 @@ "version": "1.1.3", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", - "dev": true + "dev": true, + "peer": true }, "node_modules/tslint/node_modules/glob": { "version": "7.2.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", "dev": true, + "peer": true, "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -28073,6 +28079,7 @@ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", "dev": true, + "peer": true, "engines": { "node": ">=4" } @@ -28082,6 +28089,7 @@ "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", "dev": true, + "peer": true, "dependencies": { "minimist": "^1.2.6" }, @@ -28094,6 +28102,7 @@ "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", "dev": true, + "peer": true, "bin": { "semver": "bin/semver" } @@ -28103,6 +28112,7 @@ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", "dev": true, + "peer": true, "dependencies": { "has-flag": "^3.0.0" }, @@ -28114,13 +28124,15 @@ "version": "1.14.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", - "dev": true + "dev": true, + "peer": true }, "node_modules/tslint/node_modules/tsutils": { "version": "2.29.0", "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", "dev": true, + "peer": true, "dependencies": { "tslib": "^1.8.1" }, diff --git a/package.json b/package.json index 4b6d30fda..390a209bb 100644 --- a/package.json +++ b/package.json @@ -84,7 +84,6 @@ "standard-version": "^9.3.2", "storybook": "^7.5.3", "ts-node": "~8.10.0", - "tslint": "~6.1.0", "typescript": "~4.9.4" } } -- GitLab From b4ccd9254b42ad8275c0f3c2378332e8189d275e Mon Sep 17 00:00:00 2001 From: Bastien Dumont <bdumont@grandlyon.com> Date: Tue, 21 Nov 2023 15:51:55 +0100 Subject: [PATCH 02/13] tslint --fix --- .../claim-structure.component.ts | 62 +++++++++---------- .../deleted-structures.component.ts | 52 ++++++++-------- .../manage-users/manage-users.component.ts | 8 +-- .../admin-structures-list.component.ts | 34 +++++----- src/app/config/http-interceptor.ts | 2 +- src/app/form/form-view/form-view.component.ts | 3 +- .../structure-contact.component.ts | 2 +- .../orientation-form-view.component.ts | 2 +- src/app/guards/role.guard.ts | 2 +- src/app/models/address.model.ts | 2 +- src/app/models/structure.model.ts | 10 +-- src/app/post/components/utils/NewsUtils.ts | 2 +- .../profile-structure.component.ts | 3 +- .../reset-password.component.ts | 2 +- src/app/services/notification.service.ts | 4 +- src/app/services/structure.service.ts | 4 +- .../address-autocomplete.component.ts | 2 +- .../modal-join-confirmation.component.ts | 2 +- .../password-form/password-form.component.ts | 2 +- .../components/v3/button/button.component.ts | 4 +- .../icon-button/icon-button.component.ts | 2 +- .../components/v3/input/input.component.ts | 2 +- .../v3/tag/tag-item/tag-item.component.ts | 8 +-- .../v3/textarea/textarea.component.ts | 4 +- .../structure-list-search.component.ts | 2 +- src/app/structure-list/models/module.model.ts | 2 +- .../structure-list/services/search.service.ts | 4 +- .../structure-join.component.ts | 6 +- tslint.json | 1 - 29 files changed, 118 insertions(+), 117 deletions(-) diff --git a/src/app/admin/components/claim-structure/claim-structure.component.ts b/src/app/admin/components/claim-structure/claim-structure.component.ts index ca49f70f5..9655fe3ef 100644 --- a/src/app/admin/components/claim-structure/claim-structure.component.ts +++ b/src/app/admin/components/claim-structure/claim-structure.component.ts @@ -11,43 +11,13 @@ import { AdminService } from '../../services/admin.service'; styleUrls: ['../../admin.scss'], }) export class ClaimStructureComponent implements OnInit { - public demandsAttachment: StructureAdminInfo[]; constructor( private adminService: AdminService, private notificationService: NotificationService, private datePipe: DatePipe ) {} - - ngOnInit(): void { - this.adminService.getPendingStructure().subscribe((demands) => { - this.demandsAttachment = demands; - }); - } - - public acceptDemand(demand: StructureAdminInfo): void { - this.adminService.acceptStructureClaim(demand.userEmail, demand.structureId, demand.structureName).subscribe({ - next: (data) => { - this.demandsAttachment = data; - this.notificationService.showSuccess('Demande acceptée avec succès'); - }, - error: () => { - this.notificationService.showError('Une erreur est survenue'); - }, - }); - } - - public refuseDemand(demand: StructureAdminInfo): void { - this.adminService.refuseStructureClaim(demand.userEmail, demand.structureId, demand.structureName).subscribe({ - next: (data) => { - this.demandsAttachment = data; - this.notificationService.showSuccess('Demande refusée avec succès'); - }, - error: () => { - this.notificationService.showError('Une erreur est survenue'); - }, - }); - } + public demandsAttachment: StructureAdminInfo[]; public columnsDefs: ColDef<StructureAdminInfo>[] = [ { @@ -81,4 +51,34 @@ export class ClaimStructureComponent implements OnInit { }, }, ]; + + ngOnInit(): void { + this.adminService.getPendingStructure().subscribe((demands) => { + this.demandsAttachment = demands; + }); + } + + public acceptDemand(demand: StructureAdminInfo): void { + this.adminService.acceptStructureClaim(demand.userEmail, demand.structureId, demand.structureName).subscribe({ + next: (data) => { + this.demandsAttachment = data; + this.notificationService.showSuccess('Demande acceptée avec succès'); + }, + error: () => { + this.notificationService.showError('Une erreur est survenue'); + }, + }); + } + + public refuseDemand(demand: StructureAdminInfo): void { + this.adminService.refuseStructureClaim(demand.userEmail, demand.structureId, demand.structureName).subscribe({ + next: (data) => { + this.demandsAttachment = data; + this.notificationService.showSuccess('Demande refusée avec succès'); + }, + error: () => { + this.notificationService.showError('Une erreur est survenue'); + }, + }); + } } diff --git a/src/app/admin/components/deleted-structures/deleted-structures.component.ts b/src/app/admin/components/deleted-structures/deleted-structures.component.ts index d6f56b36c..be8acf6a3 100644 --- a/src/app/admin/components/deleted-structures/deleted-structures.component.ts +++ b/src/app/admin/components/deleted-structures/deleted-structures.component.ts @@ -11,36 +11,12 @@ import { AdminService } from '../../services/admin.service'; styleUrls: ['../../admin.scss'], }) export class DeletedStructuresComponent implements OnInit { + + constructor(private adminService: AdminService, private datePipe: DatePipe) {} public deletedStructures: Structure[]; public selectedStructure: Structure; public isLoading = true; - constructor(private adminService: AdminService, private datePipe: DatePipe) {} - - ngOnInit(): void { - this.loadDeletedStructures(); - } - - private loadDeletedStructures(): void { - this.adminService - .getDeletedStructures() - .pipe(finalize(() => (this.isLoading = false))) - .subscribe((structures) => { - this.deletedStructures = structures; - }); - } - - private renderLink(structure: Structure) { - return `<a href="/acteurs?id=${structure._id}" target="_blank">${structure.structureName}</a>`; - } - - private restoreStructure(structureId: string): void { - this.adminService.restoreDeletedStructure(structureId).subscribe(() => { - this.isLoading = true; - this.loadDeletedStructures(); - }); - } - public columnDefs: ColDef<Structure>[] = [ { headerName: 'Structure', @@ -72,4 +48,28 @@ export class DeletedStructuresComponent implements OnInit { }, }, ]; + + ngOnInit(): void { + this.loadDeletedStructures(); + } + + private loadDeletedStructures(): void { + this.adminService + .getDeletedStructures() + .pipe(finalize(() => (this.isLoading = false))) + .subscribe((structures) => { + this.deletedStructures = structures; + }); + } + + private renderLink(structure: Structure) { + return `<a href="/acteurs?id=${structure._id}" target="_blank">${structure.structureName}</a>`; + } + + private restoreStructure(structureId: string): void { + this.adminService.restoreDeletedStructure(structureId).subscribe(() => { + this.isLoading = true; + this.loadDeletedStructures(); + }); + } } diff --git a/src/app/admin/components/manage-users/manage-users.component.ts b/src/app/admin/components/manage-users/manage-users.component.ts index 2edddabf1..34ab0cb3e 100644 --- a/src/app/admin/components/manage-users/manage-users.component.ts +++ b/src/app/admin/components/manage-users/manage-users.component.ts @@ -151,7 +151,7 @@ export class ManageUsersComponent { minWidth: 50, headerName: 'Demande de rattachement envoyée le', field: 'updatedAt', - valueGetter: function (params) { + valueGetter(params) { return new Date(params.data?.updatedAt).toLocaleDateString(); }, }, @@ -346,7 +346,7 @@ export class ManageUsersComponent { this.adminService.getAttachedUsers().subscribe((users) => { this.attachedUsers = users; this.attachedUsers.forEach((user) => { - user._id = user['id']; + user._id = user.id; }); }); } @@ -355,7 +355,7 @@ export class ManageUsersComponent { this.adminService.getUnAttachedUsers().subscribe((users) => { this.unAttachedUsers = users; this.unAttachedUsers.forEach((user) => { - user._id = user['id']; + user._id = user.id; }); }); } @@ -364,7 +364,7 @@ export class ManageUsersComponent { this.adminService.getUnVerifiedUsers().subscribe((users) => { this.unVerifiedUsers = users; this.unVerifiedUsers.forEach((user) => { - user._id = user['id']; + user._id = user.id; }); }); } diff --git a/src/app/admin/components/structures-list/admin-structures-list.component.ts b/src/app/admin/components/structures-list/admin-structures-list.component.ts index 950ca81dc..6a139eea5 100644 --- a/src/app/admin/components/structures-list/admin-structures-list.component.ts +++ b/src/app/admin/components/structures-list/admin-structures-list.component.ts @@ -12,6 +12,7 @@ import { AdminService } from '../../services/admin.service'; styleUrls: ['../../admin.scss'], }) export class AdminStructuresListComponent implements OnInit { + constructor(private adminService: AdminService, private datePipe: DatePipe, private router: Router) {} public structuresClaimed: AdminStructure[]; public structuresInClaim: AdminStructure[]; public structuresToClaim: AdminStructure[]; @@ -19,23 +20,6 @@ export class AdminStructuresListComponent implements OnInit { public isAll = false; public isLoading = true; public rowHeight = 25; - constructor(private adminService: AdminService, private datePipe: DatePipe, private router: Router) {} - - ngOnInit(): void { - this.adminService - .getAllStructureAdmin() - .pipe(finalize(() => (this.isLoading = false))) - .subscribe((response) => { - this.structuresClaimed = response.claimed; - this.structuresInClaim = response.inClaim; - this.structuresToClaim = response.toClaim; - this.structuresIncomplete = response.incomplete; - }); - } - - private renderLink(structureId: string, structureName: string) { - return `<a href="/acteurs?id=${structureId}" target="_blank">${structureName}</a>`; - } public columnDefs: ColDef<AdminStructure>[] = [ { @@ -58,4 +42,20 @@ export class AdminStructuresListComponent implements OnInit { sortable: true, }, ]; + + ngOnInit(): void { + this.adminService + .getAllStructureAdmin() + .pipe(finalize(() => (this.isLoading = false))) + .subscribe((response) => { + this.structuresClaimed = response.claimed; + this.structuresInClaim = response.inClaim; + this.structuresToClaim = response.toClaim; + this.structuresIncomplete = response.incomplete; + }); + } + + private renderLink(structureId: string, structureName: string) { + return `<a href="/acteurs?id=${structureId}" target="_blank">${structureName}</a>`; + } } diff --git a/src/app/config/http-interceptor.ts b/src/app/config/http-interceptor.ts index b51caa249..5555f61cb 100644 --- a/src/app/config/http-interceptor.ts +++ b/src/app/config/http-interceptor.ts @@ -21,7 +21,7 @@ export class CustomHttpInterceptor implements HttpInterceptor { headerSettings[key] = request.headers.getAll(key); } if (token) { - headerSettings['Authorization'] = 'Bearer ' + token; + headerSettings.Authorization = 'Bearer ' + token; } headerSettings['Content-Type'] = 'application/json'; const newHeader = new HttpHeaders(headerSettings); diff --git a/src/app/form/form-view/form-view.component.ts b/src/app/form/form-view/form-view.component.ts index f00392a45..51ea81fff 100644 --- a/src/app/form/form-view/form-view.component.ts +++ b/src/app/form/form-view/form-view.component.ts @@ -267,8 +267,9 @@ export class FormViewComponent implements OnInit, AfterViewInit { } } public displayFooterForm(): boolean { - if (this.currentPage === profileFormStep.profileBeginningInfo && formType[this.routeParam] === formType.profile) + if (this.currentPage === profileFormStep.profileBeginningInfo && formType[this.routeParam] === formType.profile) { return false; + } return true; } diff --git a/src/app/form/form-view/structure-form/structure-contact/structure-contact.component.ts b/src/app/form/form-view/structure-form/structure-contact/structure-contact.component.ts index 0bfe25eec..0dac3d4a1 100644 --- a/src/app/form/form-view/structure-form/structure-contact/structure-contact.component.ts +++ b/src/app/form/form-view/structure-form/structure-contact/structure-contact.component.ts @@ -23,7 +23,7 @@ export class StructureContactComponent implements OnInit { } public isRequirePhoneOrMailNotValid(): boolean { - return this.structureForm.errors?.['requirePhoneOrMail'] ?? false; + return this.structureForm.errors.requirePhoneOrMail ?? false; } public isContactMailValid(): boolean { diff --git a/src/app/form/orientation-form-view/orientation-form-view.component.ts b/src/app/form/orientation-form-view/orientation-form-view.component.ts index 281720e4f..c516b88fd 100644 --- a/src/app/form/orientation-form-view/orientation-form-view.component.ts +++ b/src/app/form/orientation-form-view/orientation-form-view.component.ts @@ -223,7 +223,7 @@ export class OrientationFormViewComponent implements OnInit, AfterContentChecked }; // pmrAccess filter must not be send in the onlineDemarcheType array of the appointment - appointment.onlineDemarcheType = appointment.onlineDemarcheType.filter((item) => item['name'] != 'pmrAccess'); + appointment.onlineDemarcheType = appointment.onlineDemarcheType.filter((item) => item.name != 'pmrAccess'); await lastValueFrom(this.orientationService.createAppointment(appointment)); this.canDeactivate = true; diff --git a/src/app/guards/role.guard.ts b/src/app/guards/role.guard.ts index 86ebe58ea..ae8e00615 100644 --- a/src/app/guards/role.guard.ts +++ b/src/app/guards/role.guard.ts @@ -12,7 +12,7 @@ export class RoleGuard implements CanActivate { constructor(private router: Router, private profileService: ProfileService, private authService: AuthService) {} canActivate(route: ActivatedRouteSnapshot): UrlTree | boolean { - const allowedRoles = route.data['allowedRoles']; + const allowedRoles = route.data.allowedRoles; if (this.authService.isLoggedIn()) { if (this.profileService.isAdmin()) return true; diff --git a/src/app/models/address.model.ts b/src/app/models/address.model.ts index 8ef6bc349..0b1c37af5 100644 --- a/src/app/models/address.model.ts +++ b/src/app/models/address.model.ts @@ -3,5 +3,5 @@ export class Address { street: string = null; commune: string = null; postcode?: number = null; - coordinates? = []; + coordinates ? = []; } diff --git a/src/app/models/structure.model.ts b/src/app/models/structure.model.ts index d027aad00..6bd5fa508 100644 --- a/src/app/models/structure.model.ts +++ b/src/app/models/structure.model.ts @@ -58,7 +58,7 @@ export class Structure { public personalOffers: PersonalOffer[] = []; - public alreadySelected? = false; + public alreadySelected ? = false; public hasNoUserDN?: boolean = null; public hasUserWithAppointmentDN?: boolean = null; @@ -192,13 +192,13 @@ export class Structure { public getTypeStructureIcon(): StructureCategoryIconEnum { switch (this.structureType?.category) { case StructureCategoryEnum.public: - return StructureCategoryIconEnum['public']; + return StructureCategoryIconEnum.public; case StructureCategoryEnum.private: - return StructureCategoryIconEnum['private']; + return StructureCategoryIconEnum.private; case StructureCategoryEnum.privateLucrative: - return StructureCategoryIconEnum['privateLucrative']; + return StructureCategoryIconEnum.privateLucrative; default: - return StructureCategoryIconEnum['public']; + return StructureCategoryIconEnum.public; } } diff --git a/src/app/post/components/utils/NewsUtils.ts b/src/app/post/components/utils/NewsUtils.ts index 4bb4eea6b..9376c0660 100644 --- a/src/app/post/components/utils/NewsUtils.ts +++ b/src/app/post/components/utils/NewsUtils.ts @@ -3,7 +3,7 @@ import { Tag } from '../../models/tag.model'; export function parseSlugToTag(data: Tag[] | string): Tag[] { let otherTags = []; if (Array.isArray(data)) { - otherTags = data.map((slug) => new Tag({ slug: slug })); + otherTags = data.map((slug) => new Tag({ slug })); } else if (data) { otherTags = [new Tag({ slug: data })]; } diff --git a/src/app/profile/profile-structure/profile-structure.component.ts b/src/app/profile/profile-structure/profile-structure.component.ts index 3eaef27af..5a882ae4a 100644 --- a/src/app/profile/profile-structure/profile-structure.component.ts +++ b/src/app/profile/profile-structure/profile-structure.component.ts @@ -69,8 +69,9 @@ export class ProfileStructureComponent implements OnInit { !this.userProfile?.personalOffers || !this.userProfile?.job?.hasPersonalOffer || this.userProfile?.personalOffers?.length === 0 - ) + ) { return null; + } // Check if structure has personal offers if (this.structure.personalOffers.length === 0) return null; diff --git a/src/app/reset-password/reset-password.component.ts b/src/app/reset-password/reset-password.component.ts index 82a8f0404..eb46ce98b 100644 --- a/src/app/reset-password/reset-password.component.ts +++ b/src/app/reset-password/reset-password.component.ts @@ -30,7 +30,7 @@ export class ResetPasswordComponent implements OnInit { ngOnInit(): void { this.activatedRoute.queryParams.subscribe((params) => { - this.token = params['token']; + this.token = params.token; }); this.resetForm = this.formBuilder.group({ email: ['', Validators.required], diff --git a/src/app/services/notification.service.ts b/src/app/services/notification.service.ts index e022e272a..a4008ad25 100644 --- a/src/app/services/notification.service.ts +++ b/src/app/services/notification.service.ts @@ -9,14 +9,14 @@ export class NotificationService { public showSuccess(message: string, title = '', timeOut = 10000): void { this.toastr.success(message, title, { - timeOut: timeOut, + timeOut, }); } // Par défaut, l'erreur reste affichée jusqu'à ce qu'on clique dessus public showError(message: string, title = '', timeOut = 0): void { this.toastr.error(message, title, { - timeOut: timeOut, + timeOut, disableTimeOut: timeOut ? false : true, }); } diff --git a/src/app/services/structure.service.ts b/src/app/services/structure.service.ts index 5fee112f9..1511902bd 100644 --- a/src/app/services/structure.service.ts +++ b/src/app/services/structure.service.ts @@ -84,8 +84,8 @@ export class StructureService { const orFormatedFilters = this.formatFilters(filters.filter((e) => e.orOperator)); requestFilters = { filters: [andFormatedFilters, orFormatedFilters], - onlyOffersWithAppointment: onlyOffersWithAppointment, - limit: limit, + onlyOffersWithAppointment, + limit, }; } return this.http diff --git a/src/app/shared/components/address-autocomplete/address-autocomplete.component.ts b/src/app/shared/components/address-autocomplete/address-autocomplete.component.ts index c2ba5fcbe..db0d5c699 100644 --- a/src/app/shared/components/address-autocomplete/address-autocomplete.component.ts +++ b/src/app/shared/components/address-autocomplete/address-autocomplete.component.ts @@ -48,7 +48,7 @@ export class AddressAutocompleteComponent implements OnInit, OnChanges { return el; }); // Filtering duplicate displayed string. This duplication is caused by the API used for gathering addresse info. - this.data = [...new Map(data.features.map((item) => [item['displayedName'], item])).values()]; + this.data = [...new Map(data.features.map((item) => [item.displayedName, item])).values()]; this.isAlreadySearching = false; }); } diff --git a/src/app/shared/components/modal-join-confirmation/modal-join-confirmation.component.ts b/src/app/shared/components/modal-join-confirmation/modal-join-confirmation.component.ts index 1bf7679fc..5d5d5756a 100644 --- a/src/app/shared/components/modal-join-confirmation/modal-join-confirmation.component.ts +++ b/src/app/shared/components/modal-join-confirmation/modal-join-confirmation.component.ts @@ -12,7 +12,7 @@ export class ModalJoinConfirmationComponent { @Input() public primaryContent: string; @Input() public secondaryContent?: string; @Input() public customConfirmationText?: string; - @Input() public displayCancelButton?: boolean = true; + @Input() public displayCancelButton = true; @Output() closed = new EventEmitter<boolean>(); public buttonTypeEnum = ButtonType; diff --git a/src/app/shared/components/password-form/password-form.component.ts b/src/app/shared/components/password-form/password-form.component.ts index 42bfc4736..d5ef82b6b 100644 --- a/src/app/shared/components/password-form/password-form.component.ts +++ b/src/app/shared/components/password-form/password-form.component.ts @@ -37,7 +37,7 @@ export class PasswordFormComponent implements OnInit { ngOnInit(): void { this.activatedRoute.queryParams.subscribe((params) => { - this.token = params['token']; + this.token = params.token; }); if (this.auth.isLoggedIn()) { this.oldPasswordNeeded = true; diff --git a/src/app/shared/components/v3/button/button.component.ts b/src/app/shared/components/v3/button/button.component.ts index beaeda33f..a5c26cec4 100644 --- a/src/app/shared/components/v3/button/button.component.ts +++ b/src/app/shared/components/v3/button/button.component.ts @@ -20,10 +20,10 @@ export class ButtonV3Component { @Input() size?: 'small' | 'medium' | 'large' = 'small'; /** Should the button be wide ? (250px) */ - @Input() wide?: boolean = false; + @Input() wide = false; /** Should the button be disabled ? */ - @Input() disabled?: boolean = false; + @Input() disabled = false; /** Sets the position of the icon if one provided */ @Input() iconPosition: 'left' | 'right' = 'left'; diff --git a/src/app/shared/components/v3/button/icon-button/icon-button.component.ts b/src/app/shared/components/v3/button/icon-button/icon-button.component.ts index aaca13807..e09e640fe 100644 --- a/src/app/shared/components/v3/button/icon-button/icon-button.component.ts +++ b/src/app/shared/components/v3/button/icon-button/icon-button.component.ts @@ -14,7 +14,7 @@ export class IconButtonV3Component { @Input() variant?: ButtonTypeV3 = ButtonTypeV3.Primary; /** Should the button be disabled ? */ - @Input() disabled?: boolean = false; + @Input() disabled = false; /** Folder of the icon ex: assets/ico */ @Input() iconFolder = 'ico'; diff --git a/src/app/shared/components/v3/input/input.component.ts b/src/app/shared/components/v3/input/input.component.ts index 6db9c4cad..dca54ffd7 100644 --- a/src/app/shared/components/v3/input/input.component.ts +++ b/src/app/shared/components/v3/input/input.component.ts @@ -11,7 +11,7 @@ export class InputV3Component { @Input() type: 'text' | 'password' = 'text'; - @Input() disabled?: boolean = false; + @Input() disabled = false; /** Label for the radio */ @Input() label?: string; diff --git a/src/app/shared/components/v3/tag/tag-item/tag-item.component.ts b/src/app/shared/components/v3/tag/tag-item/tag-item.component.ts index e9eb68e4f..dbef38b91 100644 --- a/src/app/shared/components/v3/tag/tag-item/tag-item.component.ts +++ b/src/app/shared/components/v3/tag/tag-item/tag-item.component.ts @@ -13,19 +13,19 @@ export class TagItemV3Component { @Input() size?: 'small' | 'medium' = 'medium'; /** Is the tag selected ? */ - @Input() selected?: boolean = false; + @Input() selected = false; /** Should the button be clickable ? */ - @Input() clickable?: boolean = true; + @Input() clickable = true; /** Should the button be disabled */ - @Input() disabled?: boolean = false; + @Input() disabled = false; /** Sets the position of the icon if one provided */ @Input() iconPosition?: 'left' | 'right' = 'left'; /** Folder of the icon ex: assets/ico */ - @Input() iconFolder?: string = 'ico'; + @Input() iconFolder = 'ico'; /** Icon name */ @Input() iconName?: string; diff --git a/src/app/shared/components/v3/textarea/textarea.component.ts b/src/app/shared/components/v3/textarea/textarea.component.ts index c717ff08c..a5ad8024a 100644 --- a/src/app/shared/components/v3/textarea/textarea.component.ts +++ b/src/app/shared/components/v3/textarea/textarea.component.ts @@ -9,7 +9,7 @@ export class TextareaV3Component { /** HTML id associated with for */ @Input() id: string; - @Input() disabled?: boolean = false; + @Input() disabled = false; /** Label for the radio */ @Input() label?: string; @@ -18,7 +18,7 @@ export class TextareaV3Component { @Input() description?: string; /** Max length of the input */ - @Input() maxLength?: number = 500; + @Input() maxLength = 500; /** What additional data should be displayed ? */ @Input() status?: 'error' | 'success' | 'info' | 'warning'; diff --git a/src/app/structure-list/components/structure-list-search/structure-list-search.component.ts b/src/app/structure-list/components/structure-list-search/structure-list-search.component.ts index 6d9053894..e1091c6be 100644 --- a/src/app/structure-list/components/structure-list-search/structure-list-search.component.ts +++ b/src/app/structure-list/components/structure-list-search/structure-list-search.component.ts @@ -111,7 +111,7 @@ export class StructureListSearchComponent implements OnInit { public updateUrlParams(filters: Filter[]): void { // No url update if the page is displaying structure details, because it must keep the url with the structure id, neither for orientation if ( - (this.activatedRoute.snapshot.queryParams['id'] && filters.length === 0) || + (this.activatedRoute.snapshot.queryParams.id && filters.length === 0) || this.router.url.startsWith('/orientation') ) { return; diff --git a/src/app/structure-list/models/module.model.ts b/src/app/structure-list/models/module.model.ts index 5ed3af44a..c7ce17ccd 100644 --- a/src/app/structure-list/models/module.model.ts +++ b/src/app/structure-list/models/module.model.ts @@ -2,7 +2,7 @@ export class Module { id: string; name: string; displayText?: string; - disabled?: boolean = false; + disabled = false; constructor(id: string, name: string, displayText?: string) { this.id = id; diff --git a/src/app/structure-list/services/search.service.ts b/src/app/structure-list/services/search.service.ts index 7900067f2..221a5c801 100644 --- a/src/app/structure-list/services/search.service.ts +++ b/src/app/structure-list/services/search.service.ts @@ -36,9 +36,9 @@ export class SearchService { ): Promise<SearchResults> { return lastValueFrom( this.http.post<SearchResults>(`/api/userRegistry/?search=${searchTerm}`, { - jobsGroup: jobsGroup, + jobsGroup, employer: employers, - page: page, + page, }) ); } diff --git a/src/app/structure/structure-join/structure-join.component.ts b/src/app/structure/structure-join/structure-join.component.ts index 02e293e89..50170699c 100644 --- a/src/app/structure/structure-join/structure-join.component.ts +++ b/src/app/structure/structure-join/structure-join.component.ts @@ -13,7 +13,7 @@ import { UserService } from '../../services/user.service'; styleUrls: ['./structure-join.component.scss'], }) export class StructureJoinComponent implements OnInit { - public structureName?: string = ''; + public structureName = ''; public isClaimed: boolean = null; public structureFormStepEnum = structureFormStep; public formTypeEnum = formType; @@ -48,8 +48,8 @@ export class StructureJoinComponent implements OnInit { } public handleStructureJoin(): void { this.route.queryParams.subscribe((params) => { - this.isStructureJoinValidated = params['status']; - this.validationToken = params['token']; + this.isStructureJoinValidated = params.status; + this.validationToken = params.token; }); if (this.isStructureJoinValidated !== null && this.validationToken) { this.usersService.validateJoinStructure(this.validationToken, this.isStructureJoinValidated).subscribe({ diff --git a/tslint.json b/tslint.json index b89375a85..86bf29a2c 100644 --- a/tslint.json +++ b/tslint.json @@ -33,7 +33,6 @@ "no-switch-case-fall-through": true, "no-var-requires": false, "object-literal-key-quotes": [true, "as-needed"], - "quotemark": [true, "single"], "semicolon": { "options": ["always"] }, -- GitLab From e9440a93ed38e2904f377a301cce3fc5e446801b Mon Sep 17 00:00:00 2001 From: Bastien Dumont <bdumont@grandlyon.com> Date: Tue, 21 Nov 2023 16:12:17 +0100 Subject: [PATCH 03/13] fix some linting errors --- .eslintrc.json | 5 ++++- .../lockdown-info/manage-lockdown-info.component.ts | 2 +- src/app/map/components/map.component.ts | 2 +- .../structure-add-member-modal.component.ts | 2 +- .../structures-management/structures-management.component.ts | 4 ++-- src/app/services/notification.service.ts | 2 +- .../structure-details/structure-details.component.ts | 2 +- 7 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 9cff1b443..57ea0340f 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -38,6 +38,10 @@ "@typescript-eslint/prefer-optional-chain": "warn", + // TSLINT rules migration + "@typescript-eslint/no-explicit-any": "off", // TO DELETE + // "@typescript-eslint/explicit-function-return-type": "error" + // JSDOC extends overrides: disable some of extends rules // JSdoc is not always needed "jsdoc/require-jsdoc": 0, @@ -46,7 +50,6 @@ "jsdoc/require-returns-type": 0, "jsdoc/require-param": 0, "jsdoc/require-param-type": 0, - // Allow some params to be described and some to be omitted "jsdoc/check-param-names": 0 } diff --git a/src/app/admin/components/lockdown-info/manage-lockdown-info.component.ts b/src/app/admin/components/lockdown-info/manage-lockdown-info.component.ts index 6a81decee..778127f3b 100644 --- a/src/app/admin/components/lockdown-info/manage-lockdown-info.component.ts +++ b/src/app/admin/components/lockdown-info/manage-lockdown-info.component.ts @@ -22,7 +22,7 @@ export class ManageLockdownInfoComponent implements OnInit { public toggleLockdownInfo() { this.lockdownInfoDisplay = !this.lockdownInfoDisplay; this.parametersService.SetLockdownInfoDisplay(this.lockdownInfoDisplay).subscribe( - () => {}, + () => null, () => { this.error = true; } diff --git a/src/app/map/components/map.component.ts b/src/app/map/components/map.component.ts index 86be3dbdd..c4f30ca5f 100644 --- a/src/app/map/components/map.component.ts +++ b/src/app/map/components/map.component.ts @@ -138,7 +138,7 @@ export class MapComponent implements OnChanges { this.map.fitBounds(bounds); } }, - (err) => { + () => { this.map.flyTo(this.mapOptions.center, this.mapOptions.zoom, this.zoomOptions); } ); diff --git a/src/app/profile/structure-add-member-modal/structure-add-member-modal.component.ts b/src/app/profile/structure-add-member-modal/structure-add-member-modal.component.ts index 460e3e75b..8fa5a3f8b 100644 --- a/src/app/profile/structure-add-member-modal/structure-add-member-modal.component.ts +++ b/src/app/profile/structure-add-member-modal/structure-add-member-modal.component.ts @@ -57,7 +57,7 @@ export class StructureAddMemberModalComponent implements OnInit { } this.closed.emit(true); }, - (err) => { + () => { this.ownerAlreadyLinked = true; } ); diff --git a/src/app/profile/structures-management/structures-management.component.ts b/src/app/profile/structures-management/structures-management.component.ts index ae3a5ee01..61fe17b2e 100644 --- a/src/app/profile/structures-management/structures-management.component.ts +++ b/src/app/profile/structures-management/structures-management.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit } from '@angular/core'; import { Router } from '@angular/router'; -import { forkJoin, Observable } from 'rxjs'; +import { Observable, forkJoin } from 'rxjs'; import { tap } from 'rxjs/operators'; import { Structure } from '../../models/structure.model'; import { StructureWithOwners } from '../../models/structureWithOwners.model'; @@ -109,7 +109,7 @@ export class StructuresManagementComponent implements OnInit { public cancelDelete(structure: Structure, shouldCancel: boolean): void { this.cancelDeleteModalOpened = false; if (shouldCancel) { - this.structureService.cancelDelete(structure._id).subscribe((res) => { + this.structureService.cancelDelete(structure._id).subscribe(() => { this.getStructures(); }); } diff --git a/src/app/services/notification.service.ts b/src/app/services/notification.service.ts index a4008ad25..052072b18 100644 --- a/src/app/services/notification.service.ts +++ b/src/app/services/notification.service.ts @@ -34,7 +34,7 @@ export class NotificationService { } ); - update.onTap.subscribe((_action) => { + update.onTap.subscribe(() => { window.location.reload(); }); } diff --git a/src/app/structure-list/components/structure-details/structure-details.component.ts b/src/app/structure-list/components/structure-details/structure-details.component.ts index 2a5cc4217..001395674 100644 --- a/src/app/structure-list/components/structure-details/structure-details.component.ts +++ b/src/app/structure-list/components/structure-details/structure-details.component.ts @@ -284,7 +284,7 @@ export class StructureDetailsComponent implements OnInit { public sendErrorEmail(modalValue: { shouldSend: boolean; content: string }): void { this.displayModalError(); if (modalValue.shouldSend) { - this.structureService.sendMailOnStructureError(this.structure._id, modalValue.content).subscribe(() => {}); + this.structureService.sendMailOnStructureError(this.structure._id, modalValue.content).subscribe(() => null); } } -- GitLab From e7411d4e83f4a4668aa50655cbfeb2b099741643 Mon Sep 17 00:00:00 2001 From: Bastien Dumont <bdumont@grandlyon.com> Date: Tue, 21 Nov 2023 16:20:04 +0100 Subject: [PATCH 04/13] fix start --- .../orientation-form-view/interfaces/appointment.interface.ts | 2 +- src/app/models/user.model.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/form/orientation-form-view/interfaces/appointment.interface.ts b/src/app/form/orientation-form-view/interfaces/appointment.interface.ts index 0a43eb127..5f83b2148 100644 --- a/src/app/form/orientation-form-view/interfaces/appointment.interface.ts +++ b/src/app/form/orientation-form-view/interfaces/appointment.interface.ts @@ -1,7 +1,7 @@ export interface IAppointment { structureOrientator: { structureName: string; structureMail: string; structurePhone: string }; structureRDV: string; - onlineDemarcheType: string[]; + onlineDemarcheType: { name: string }[]; socialWorkerId: string; details: string; name: string; diff --git a/src/app/models/user.model.ts b/src/app/models/user.model.ts index 5efb37d6a..e35d02e67 100644 --- a/src/app/models/user.model.ts +++ b/src/app/models/user.model.ts @@ -5,6 +5,7 @@ import { PersonalOffer } from './personalOffer.model'; export class User { _id: string; + id: string; createdAt: Date; email: string; name: string; -- GitLab From 4518d6685b2b9c4acffd52e78316db7550013174 Mon Sep 17 00:00:00 2001 From: Bastien Dumont <bdumont@grandlyon.com> Date: Tue, 21 Nov 2023 16:29:43 +0100 Subject: [PATCH 05/13] add some return types --- .eslintrc.json | 2 +- .../claim-structure/claim-structure.component.ts | 11 +++++------ .../deleted-structures.component.ts | 13 ++++++------- .../espace-coop-cnfs.component.ts | 4 ++-- .../manage-lockdown-info.component.ts | 2 +- .../attached-users/attached-users.component.ts | 2 +- .../jobPersonalOffer/job-personal-offer.ts | 2 +- .../admin-structures-list.component.ts | 10 +++++----- src/app/admin/services/admin.service.ts | 4 ++-- .../orientation-form-view.component.ts | 16 ++++++++-------- 10 files changed, 32 insertions(+), 34 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 57ea0340f..256dd23f0 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -40,7 +40,7 @@ // TSLINT rules migration "@typescript-eslint/no-explicit-any": "off", // TO DELETE - // "@typescript-eslint/explicit-function-return-type": "error" + "@typescript-eslint/explicit-function-return-type": "error", // JSDOC extends overrides: disable some of extends rules // JSdoc is not always needed diff --git a/src/app/admin/components/claim-structure/claim-structure.component.ts b/src/app/admin/components/claim-structure/claim-structure.component.ts index 9655fe3ef..61181d076 100644 --- a/src/app/admin/components/claim-structure/claim-structure.component.ts +++ b/src/app/admin/components/claim-structure/claim-structure.component.ts @@ -11,7 +11,6 @@ import { AdminService } from '../../services/admin.service'; styleUrls: ['../../admin.scss'], }) export class ClaimStructureComponent implements OnInit { - constructor( private adminService: AdminService, private notificationService: NotificationService, @@ -32,21 +31,21 @@ export class ClaimStructureComponent implements OnInit { { headerName: 'Date de demande', field: 'createdAt', - valueFormatter: (params) => this.datePipe.transform(params.value, 'mediumDate'), + valueFormatter: (params): string => this.datePipe.transform(params.value, 'mediumDate'), }, { headerName: 'Valider', width: 100, - cellRenderer: () => '<button type="button">Valider</button>', - onCellClicked: (params) => { + cellRenderer: (): string => '<button type="button">Valider</button>', + onCellClicked: (params): void => { this.acceptDemand(params.data); }, }, { headerName: 'Refuser', width: 100, - cellRenderer: () => '<button type="button">Refuser</button>', - onCellClicked: (params) => { + cellRenderer: (): string => '<button type="button">Refuser</button>', + onCellClicked: (params): void => { this.refuseDemand(params.data); }, }, diff --git a/src/app/admin/components/deleted-structures/deleted-structures.component.ts b/src/app/admin/components/deleted-structures/deleted-structures.component.ts index be8acf6a3..b7d02a07a 100644 --- a/src/app/admin/components/deleted-structures/deleted-structures.component.ts +++ b/src/app/admin/components/deleted-structures/deleted-structures.component.ts @@ -11,7 +11,6 @@ import { AdminService } from '../../services/admin.service'; styleUrls: ['../../admin.scss'], }) export class DeletedStructuresComponent implements OnInit { - constructor(private adminService: AdminService, private datePipe: DatePipe) {} public deletedStructures: Structure[]; public selectedStructure: Structure; @@ -23,14 +22,14 @@ export class DeletedStructuresComponent implements OnInit { field: 'structureName', flex: 1, sortable: true, - cellRenderer: (params) => this.renderLink(params.data), + cellRenderer: (params): string => this.renderLink(params.data), }, { headerName: 'Date de création', field: 'createdAt', width: 190, sortable: true, - valueFormatter: (params) => this.datePipe.transform(params.value, 'yyyy-MM-dd'), + valueFormatter: (params): string => this.datePipe.transform(params.value, 'yyyy-MM-dd'), }, { headerName: 'Date de suppression', @@ -38,12 +37,12 @@ export class DeletedStructuresComponent implements OnInit { width: 190, sortable: true, sort: 'desc', - valueFormatter: (params) => this.datePipe.transform(params.value, 'yyyy-MM-dd'), + valueFormatter: (params): string => this.datePipe.transform(params.value, 'yyyy-MM-dd'), }, { headerName: 'Restaurer', - cellRenderer: () => '<button type="button">Restaurer</button>', - onCellClicked: (params) => { + cellRenderer: (): string => '<button type="button">Restaurer</button>', + onCellClicked: (params): void => { this.restoreStructure(params.data._id); }, }, @@ -62,7 +61,7 @@ export class DeletedStructuresComponent implements OnInit { }); } - private renderLink(structure: Structure) { + private renderLink(structure: Structure): string { return `<a href="/acteurs?id=${structure._id}" target="_blank">${structure.structureName}</a>`; } diff --git a/src/app/admin/components/espace-coop-cnfs/espace-coop-cnfs.component.ts b/src/app/admin/components/espace-coop-cnfs/espace-coop-cnfs.component.ts index 39d13ae11..b1d3b1d7f 100644 --- a/src/app/admin/components/espace-coop-cnfs/espace-coop-cnfs.component.ts +++ b/src/app/admin/components/espace-coop-cnfs/espace-coop-cnfs.component.ts @@ -24,14 +24,14 @@ export class EspaceCoopCNFSComponent implements OnInit { field: 'employer', sortable: true, // Case insensitive alphabetical order - comparator: (a, b) => a.toLowerCase().localeCompare(b.toLowerCase()), + comparator: (a, b): number => a.toLowerCase().localeCompare(b.toLowerCase()), flex: 1, resizable: true, }, { headerName: 'Structures', field: 'structures', - cellRenderer: (param) => param.data.structures.join('<br/>'), + cellRenderer: (param): string => param.data.structures.join('<br/>'), flex: 1, resizable: true, }, diff --git a/src/app/admin/components/lockdown-info/manage-lockdown-info.component.ts b/src/app/admin/components/lockdown-info/manage-lockdown-info.component.ts index 778127f3b..183bc5992 100644 --- a/src/app/admin/components/lockdown-info/manage-lockdown-info.component.ts +++ b/src/app/admin/components/lockdown-info/manage-lockdown-info.component.ts @@ -19,7 +19,7 @@ export class ManageLockdownInfoComponent implements OnInit { }); } - public toggleLockdownInfo() { + public toggleLockdownInfo(): void { this.lockdownInfoDisplay = !this.lockdownInfoDisplay; this.parametersService.SetLockdownInfoDisplay(this.lockdownInfoDisplay).subscribe( () => null, diff --git a/src/app/admin/components/manage-jobs/attached-users/attached-users.component.ts b/src/app/admin/components/manage-jobs/attached-users/attached-users.component.ts index 0796f51b5..8cdd91bf3 100644 --- a/src/app/admin/components/manage-jobs/attached-users/attached-users.component.ts +++ b/src/app/admin/components/manage-jobs/attached-users/attached-users.component.ts @@ -13,7 +13,7 @@ export class AttachedUsersComponent { constructor(private router: Router) {} - public goToManageUsers() { + public goToManageUsers(): void { this.router.navigateByUrl(AdminRoutes.manageUsers.link); } diff --git a/src/app/admin/components/manage-jobs/jobPersonalOffer/job-personal-offer.ts b/src/app/admin/components/manage-jobs/jobPersonalOffer/job-personal-offer.ts index c992e82e4..8609cf8fb 100644 --- a/src/app/admin/components/manage-jobs/jobPersonalOffer/job-personal-offer.ts +++ b/src/app/admin/components/manage-jobs/jobPersonalOffer/job-personal-offer.ts @@ -19,7 +19,7 @@ export class JobPersonalOfferComponent implements ICellRendererAngularComp { } } - refresh() { + refresh(): false { return false; } } diff --git a/src/app/admin/components/structures-list/admin-structures-list.component.ts b/src/app/admin/components/structures-list/admin-structures-list.component.ts index 6a139eea5..2410d987a 100644 --- a/src/app/admin/components/structures-list/admin-structures-list.component.ts +++ b/src/app/admin/components/structures-list/admin-structures-list.component.ts @@ -24,8 +24,8 @@ export class AdminStructuresListComponent implements OnInit { public columnDefs: ColDef<AdminStructure>[] = [ { headerName: 'Structure', - cellRenderer: (params) => this.renderLink(params.data.structureId, params.data.structureName), - comparator(_, __, nodeA, nodeB) { + cellRenderer: (params): string => this.renderLink(params.data.structureId, params.data.structureName), + comparator(_, __, nodeA, nodeB): number { return nodeA.data.structureName.toLowerCase() > nodeB.data.structureName.toLocaleLowerCase() ? -1 : 1; }, sortable: true, @@ -34,8 +34,8 @@ export class AdminStructuresListComponent implements OnInit { { headerName: 'Date de mise à jour', field: 'updatedAt', - valueFormatter: ({ value }) => this.datePipe.transform(value, 'mediumDate'), - cellClass: (params) => { + valueFormatter: ({ value }): string => this.datePipe.transform(value, 'mediumDate'), + cellClass: (params): string => { return params.data.isOutdated ? 'red' : ''; }, flex: 1, @@ -55,7 +55,7 @@ export class AdminStructuresListComponent implements OnInit { }); } - private renderLink(structureId: string, structureName: string) { + private renderLink(structureId: string, structureName: string): string { return `<a href="/acteurs?id=${structureId}" target="_blank">${structureName}</a>`; } } diff --git a/src/app/admin/services/admin.service.ts b/src/app/admin/services/admin.service.ts index 805b79d83..5cdaad69b 100644 --- a/src/app/admin/services/admin.service.ts +++ b/src/app/admin/services/admin.service.ts @@ -210,11 +210,11 @@ export class AdminService { return this.http.post<void>(`${this.baseUrl}/restoreDeletedStructure/${structureId}`, {}); } - public getAllEspaceCoopCNFS() { + public getAllEspaceCoopCNFS(): Observable<EspaceCoopCNFS[]> { return this.http.get<EspaceCoopCNFS[]>(`${this.baseUrl}/espaceCoopCNFS`); } - public getAllResinCNFS() { + public getAllResinCNFS(): Observable<User[]> { return this.http.get<User[]>(`${this.baseUrl}/resinCNFS`); } } diff --git a/src/app/form/orientation-form-view/orientation-form-view.component.ts b/src/app/form/orientation-form-view/orientation-form-view.component.ts index c516b88fd..ff8275596 100644 --- a/src/app/form/orientation-form-view/orientation-form-view.component.ts +++ b/src/app/form/orientation-form-view/orientation-form-view.component.ts @@ -124,7 +124,7 @@ export class OrientationFormViewComponent implements OnInit, AfterContentChecked ) { this.setCategories(); } - async ngOnInit() { + async ngOnInit(): Promise<void> { this.orientationService.rdvUser = null; if (history.state.rdvUser) { this.orientationService.rdvUser = new User(history.state.rdvUser); @@ -160,15 +160,15 @@ export class OrientationFormViewComponent implements OnInit, AfterContentChecked } } - ngAfterContentChecked() { + ngAfterContentChecked(): void { this.cdref.detectChanges(); } - public validatePage(event: boolean) { + public validatePage(event: boolean): void { this.isPageValid = event; } - public validateStructureRDV(event: Structure) { + public validateStructureRDV(event: Structure): void { this.onlineDemarcheForm.get('structureRDV').patchValue(event._id); this.nextPage(); } @@ -242,7 +242,7 @@ export class OrientationFormViewComponent implements OnInit, AfterContentChecked this.canDeactivate = true; this.notificationService.showSuccess('Votre démarche en ligne a bien été enregistrée'); }) - .catch((error) => { + .catch(() => { this.notificationService.showErrorPleaseRetry('Echec de la création de votre démarche en ligne'); }) .finally(() => this.printForm()); @@ -258,7 +258,7 @@ export class OrientationFormViewComponent implements OnInit, AfterContentChecked }, 100); } - public setOnlineEquipmentsForm() { + public setOnlineEquipmentsForm(): void { this.currentType = OnlineDemarche.structureList; this.currentStep = StructuresListSteps.pmrAccess; // first filter screen + regular StructureList form @@ -269,7 +269,7 @@ export class OrientationFormViewComponent implements OnInit, AfterContentChecked ); } - public setOnlineProceduresForm() { + public setOnlineProceduresForm(): void { switch (this.onlineDemarcheForm.get('accompanimentType').value) { case OnlineDemarche.structureList: this.currentType = OnlineDemarche.structureList; @@ -327,7 +327,7 @@ export class OrientationFormViewComponent implements OnInit, AfterContentChecked }); } - private skipStructureOrientator(isNextPage: boolean) { + private skipStructureOrientator(isNextPage: boolean): void { if (this.profile?.structuresLink?.length === 1) { // skip structureOrientator if user with only one structure if (isNextPage) { -- GitLab From 587ef225eae2af9d1e1d9faa3837f6ec6b569723 Mon Sep 17 00:00:00 2001 From: Bastien Dumont <bdumont@grandlyon.com> Date: Tue, 21 Nov 2023 16:50:11 +0100 Subject: [PATCH 06/13] infer function return type --- .../admin/components/manage-jobs/manage-jobs.component.ts | 2 +- .../employer-renderer/employer-renderer.component.ts | 2 +- .../manage-users/job-renderer/job-renderer.component.ts | 2 +- .../admin/components/manage-users/manage-users.component.ts | 2 +- src/app/annuaire/result-list/result-list.component.ts | 2 +- src/app/app-routing.module.ts | 2 +- .../account-credentials/account-credentials.component.ts | 4 ++-- .../account-form/account-info/account-info.component.ts | 2 +- .../account-newsletter/account-newsletter.component.ts | 2 +- .../personal-offer-training-type.component.ts | 2 +- .../profile-employer-selection.component.ts | 2 +- .../profile-structure-choice.component.ts | 2 +- .../structure-access-modality.component.ts | 4 ++-- .../structure-digital-helping-accompaniment.component.ts | 4 ++-- .../structure-equipments/structure-equipments.component.ts | 2 +- .../structure-hours/structure-hours.component.ts | 4 ++-- .../structure-labels/structure-labels.component.ts | 2 +- .../structure-name-and-address.component.ts | 4 ++-- .../structure-public-target.component.ts | 2 +- .../structure-solidarity-material.component.ts | 2 +- .../structure-training-type.component.ts | 2 +- .../structure-type/structure-type.component.ts | 2 +- .../structure-web-and-social-network.component.ts | 4 ++-- .../multi-radio-form/multi-radio-form.component.ts | 2 +- .../global-components/navigation/navigation.component.ts | 4 ++-- .../needs-selection/needs-selection.component.ts | 4 ++-- .../structure-orientator/structure-orientator.component.ts | 2 +- .../mediation-beneficiary-info.component.ts | 2 +- .../online-demarch/onlineDemarch-form.component.ts | 4 ++-- .../orientation-comments/orientation-comments.component.ts | 2 +- .../orientation-structure-address.component.ts | 2 +- src/app/models/week.model.ts | 2 +- src/app/profile/edit/edit.component.ts | 4 ++-- .../personal-offer-edition.component.ts | 4 ++-- src/app/profile/profile.component.ts | 4 ++-- .../structure-edition-summary.component.ts | 2 +- src/app/services/update.service.ts | 4 ++-- .../accompaniment-picker/accompaniment-picker.component.ts | 2 +- .../address-autocomplete/address-autocomplete.component.ts | 2 +- .../structure-type-picker.component.ts | 2 +- .../text-input-modal/text-input-modal.component.ts | 2 +- .../training-type-picker/training-type-picker.component.ts | 4 ++-- src/app/shared/components/v3/input/input.component.ts | 2 +- .../shared/components/v3/tag/tag-item/tag-item.component.ts | 2 +- src/app/shared/components/v3/textarea/textarea.component.ts | 2 +- src/app/shared/directives/modalOutside.directive.ts | 2 +- src/app/shared/validator/form.ts | 2 +- src/app/structure-list/structure-list.component.ts | 2 +- src/app/utils/orientationUtils.ts | 6 +++++- src/app/utils/utils.ts | 6 +++--- 50 files changed, 70 insertions(+), 66 deletions(-) diff --git a/src/app/admin/components/manage-jobs/manage-jobs.component.ts b/src/app/admin/components/manage-jobs/manage-jobs.component.ts index 686866528..726ee6716 100644 --- a/src/app/admin/components/manage-jobs/manage-jobs.component.ts +++ b/src/app/admin/components/manage-jobs/manage-jobs.component.ts @@ -273,7 +273,7 @@ export class ManageJobsComponent implements OnInit { } } - public translateBoolean(params: ValueGetterParams) { + public translateBoolean(params: ValueGetterParams): '✔ï¸' | 'âŒ' { return params.data.hasPersonalOffer ? '✔ï¸' : 'âŒ'; } diff --git a/src/app/admin/components/manage-users/employer-renderer/employer-renderer.component.ts b/src/app/admin/components/manage-users/employer-renderer/employer-renderer.component.ts index e1e7cd52e..c29053407 100644 --- a/src/app/admin/components/manage-users/employer-renderer/employer-renderer.component.ts +++ b/src/app/admin/components/manage-users/employer-renderer/employer-renderer.component.ts @@ -25,7 +25,7 @@ export class EmployerRendererComponent implements ICellRendererAngularComp { } } - refresh() { + refresh(): false { return false; } } diff --git a/src/app/admin/components/manage-users/job-renderer/job-renderer.component.ts b/src/app/admin/components/manage-users/job-renderer/job-renderer.component.ts index b1721cf3c..867f94267 100644 --- a/src/app/admin/components/manage-users/job-renderer/job-renderer.component.ts +++ b/src/app/admin/components/manage-users/job-renderer/job-renderer.component.ts @@ -25,7 +25,7 @@ export class JobRendererComponent implements ICellRendererAngularComp { } } - refresh() { + refresh(): false { return false; } } diff --git a/src/app/admin/components/manage-users/manage-users.component.ts b/src/app/admin/components/manage-users/manage-users.component.ts index 34ab0cb3e..38a01454d 100644 --- a/src/app/admin/components/manage-users/manage-users.component.ts +++ b/src/app/admin/components/manage-users/manage-users.component.ts @@ -151,7 +151,7 @@ export class ManageUsersComponent { minWidth: 50, headerName: 'Demande de rattachement envoyée le', field: 'updatedAt', - valueGetter(params) { + valueGetter(params): string { return new Date(params.data?.updatedAt).toLocaleDateString(); }, }, diff --git a/src/app/annuaire/result-list/result-list.component.ts b/src/app/annuaire/result-list/result-list.component.ts index d3bbeb7f9..e62c052eb 100644 --- a/src/app/annuaire/result-list/result-list.component.ts +++ b/src/app/annuaire/result-list/result-list.component.ts @@ -30,7 +30,7 @@ export class ResultListComponent implements OnChanges, AfterViewInit { this.windowScrollService.scrollY.next(event.target.scrollTop); } - ngOnChanges(changes: SimpleChanges) { + ngOnChanges(changes: SimpleChanges): void { if (changes.totalUserResult?.currentValue > this.maxPerPage) { this.showPagination = true; } diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index ecf235087..13d477e9d 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -27,7 +27,7 @@ const footerOutletRoute: Route = { component: FooterComponent, }; -function buildTitle(pageTitle = '') { +function buildTitle(pageTitle = ''): string { let title = "Réseau des acteurs de l'inclusion numérique de la métropole de Lyon"; if (pageTitle) { title = pageTitle + ' | ' + title; diff --git a/src/app/form/form-view/account-form/account-credentials/account-credentials.component.ts b/src/app/form/form-view/account-form/account-credentials/account-credentials.component.ts index d94b3b0ab..fa2b963a6 100644 --- a/src/app/form/form-view/account-form/account-credentials/account-credentials.component.ts +++ b/src/app/form/form-view/account-form/account-credentials/account-credentials.component.ts @@ -44,10 +44,10 @@ export class AccountCredentialsComponent { if (password.match(CustomRegExp.LOWERCASE)) return true; return false; } - public setValidationsForm() { + public setValidationsForm(): void { this.validateForm.emit(); } - public verifyUserExist(target: EventTarget) { + public verifyUserExist(target: EventTarget): void { const value = (target as HTMLInputElement).value; this.userExists.emit(value); } diff --git a/src/app/form/form-view/account-form/account-info/account-info.component.ts b/src/app/form/form-view/account-form/account-info/account-info.component.ts index baea5a57f..abe92e1e0 100644 --- a/src/app/form/form-view/account-form/account-info/account-info.component.ts +++ b/src/app/form/form-view/account-form/account-info/account-info.component.ts @@ -15,7 +15,7 @@ export class AccountInfoComponent { constructor(public utils: Utils) {} - public setValidationsForm() { + public setValidationsForm(): void { this.validateForm.emit(); } } diff --git a/src/app/form/form-view/account-form/account-newsletter/account-newsletter.component.ts b/src/app/form/form-view/account-form/account-newsletter/account-newsletter.component.ts index 283bc3bfc..0d7986356 100644 --- a/src/app/form/form-view/account-form/account-newsletter/account-newsletter.component.ts +++ b/src/app/form/form-view/account-form/account-newsletter/account-newsletter.component.ts @@ -12,7 +12,7 @@ export class AccountNewsletterComponent { @Output() acceptNewsletter = new EventEmitter<any>(); public userAcceptNewsletter = false; - public acceptReceiveNewsletter(accepts: boolean) { + public acceptReceiveNewsletter(accepts: boolean): void { this.acceptNewsletter.emit(accepts); } } diff --git a/src/app/form/form-view/personal-offer-form/personal-offer-training-type/personal-offer-training-type.component.ts b/src/app/form/form-view/personal-offer-form/personal-offer-training-type/personal-offer-training-type.component.ts index c88bf56e9..dee1bbd08 100644 --- a/src/app/form/form-view/personal-offer-form/personal-offer-training-type/personal-offer-training-type.component.ts +++ b/src/app/form/form-view/personal-offer-form/personal-offer-training-type/personal-offer-training-type.component.ts @@ -12,7 +12,7 @@ export class PersonalOfferTrainingTypeComponent { @Input() personalOfferForm: UntypedFormGroup; @Input() trainingCategories: CategoriesToggle[]; - public setTrainingsFromCategories(categories: Category[]) { + public setTrainingsFromCategories(categories: Category[]): void { for (const categorie of categories) { const moduleIds: string[] = categorie.modules.map((module) => module.id); if (this.personalOfferForm.get('categories').get(categorie.id)) { diff --git a/src/app/form/form-view/profile-form/profile-employer-selection/profile-employer-selection.component.ts b/src/app/form/form-view/profile-form/profile-employer-selection/profile-employer-selection.component.ts index 1f73a36d9..4eb5c9f18 100644 --- a/src/app/form/form-view/profile-form/profile-employer-selection/profile-employer-selection.component.ts +++ b/src/app/form/form-view/profile-form/profile-employer-selection/profile-employer-selection.component.ts @@ -40,7 +40,7 @@ export class ProfileEmployerSelectionComponent { this.validateForm.emit(); } - private getEmployers(searchString = '') { + private getEmployers(searchString = ''): void { if (!this.isAlreadySearching) { this.isAlreadySearching = true; this.profileService.getEmployers(searchString).subscribe((employers) => { diff --git a/src/app/form/form-view/profile-form/profile-structure-choice/profile-structure-choice.component.ts b/src/app/form/form-view/profile-form/profile-structure-choice/profile-structure-choice.component.ts index 21b343b6e..48b9f0e2c 100644 --- a/src/app/form/form-view/profile-form/profile-structure-choice/profile-structure-choice.component.ts +++ b/src/app/form/form-view/profile-form/profile-structure-choice/profile-structure-choice.component.ts @@ -95,7 +95,7 @@ export class ProfileStructureChoiceComponent implements OnInit { } } - private sortStructures(structures: Structure[]) { + private sortStructures(structures: Structure[]): Structure[] { if (this.searchString === '') structures.sort((a, b) => a.structureName.localeCompare(b.structureName)); structures.sort((a, b) => Number(b.alreadySelected) - Number(a.alreadySelected)); return structures; diff --git a/src/app/form/form-view/structure-form/structure-access-modality/structure-access-modality.component.ts b/src/app/form/form-view/structure-form/structure-access-modality/structure-access-modality.component.ts index fb59cf6bd..c22736f7a 100644 --- a/src/app/form/form-view/structure-form/structure-access-modality/structure-access-modality.component.ts +++ b/src/app/form/form-view/structure-form/structure-access-modality/structure-access-modality.component.ts @@ -20,7 +20,7 @@ export class StructureAccessModalityComponent implements OnInit { this.validateForm.emit(); } - public onCheckChange(event: boolean, formControlName: string, modality: string) { + public onCheckChange(event: boolean, formControlName: string, modality: string): void { this.checkChange.emit({ event, formControlName, @@ -28,7 +28,7 @@ export class StructureAccessModalityComponent implements OnInit { }); } - public isInArray(formControlName: string, term: string) { + public isInArray(formControlName: string, term: string): boolean { return this.formUtils.isInCategoryArray(term, formControlName, this.structureForm); } diff --git a/src/app/form/form-view/structure-form/structure-digital-helping-accompaniment/structure-digital-helping-accompaniment.component.ts b/src/app/form/form-view/structure-form/structure-digital-helping-accompaniment/structure-digital-helping-accompaniment.component.ts index e89ef6b91..8bc10c094 100644 --- a/src/app/form/form-view/structure-form/structure-digital-helping-accompaniment/structure-digital-helping-accompaniment.component.ts +++ b/src/app/form/form-view/structure-form/structure-digital-helping-accompaniment/structure-digital-helping-accompaniment.component.ts @@ -20,11 +20,11 @@ export class StructureDigitalHelpingAccompanimentComponent implements OnInit { this.validateForm.emit(); } - public updateChoiceAccompaniment(choice: string) { + public updateChoiceAccompaniment(choice: string): void { this.updateChoice.emit({ formControlName: 'categories.onlineProcedures', choice }); } - public isInArray(choice: string) { + public isInArray(choice: string): boolean { if (this.structureForm.get('categories').get('onlineProcedures')?.value.includes(choice)) return true; return false; } diff --git a/src/app/form/form-view/structure-form/structure-equipments/structure-equipments.component.ts b/src/app/form/form-view/structure-form/structure-equipments/structure-equipments.component.ts index 4e68395b5..da5810917 100644 --- a/src/app/form/form-view/structure-form/structure-equipments/structure-equipments.component.ts +++ b/src/app/form/form-view/structure-form/structure-equipments/structure-equipments.component.ts @@ -38,7 +38,7 @@ export class StructureEquipmentsComponent implements OnInit { this.validateForm.emit(); } - public setValidationsForm() { + public setValidationsForm(): void { this.validateForm.emit(); } diff --git a/src/app/form/form-view/structure-form/structure-hours/structure-hours.component.ts b/src/app/form/form-view/structure-form/structure-hours/structure-hours.component.ts index 2b9465ba8..3be5fa8d9 100644 --- a/src/app/form/form-view/structure-form/structure-hours/structure-hours.component.ts +++ b/src/app/form/form-view/structure-form/structure-hours/structure-hours.component.ts @@ -18,10 +18,10 @@ export class StructureHoursComponent implements OnInit { this.validateForm.emit(); } - public updateHours(value) { + public updateHours(value): void { this.hours.emit(value); } - public setHoursError() { + public setHoursError(): void { this.hoursError.emit(); } public goBack(): void { diff --git a/src/app/form/form-view/structure-form/structure-labels/structure-labels.component.ts b/src/app/form/form-view/structure-form/structure-labels/structure-labels.component.ts index 32d9087c2..33ba19f48 100644 --- a/src/app/form/form-view/structure-form/structure-labels/structure-labels.component.ts +++ b/src/app/form/form-view/structure-form/structure-labels/structure-labels.component.ts @@ -23,7 +23,7 @@ export class StructureLabelsComponent implements OnInit { public isInArray(term: string, formControlName: string): boolean { return this.formUtils.isInCategoryArray(term, formControlName, this.structureForm); } - public onCheckChange(event: boolean, formControlName: string, modality: string) { + public onCheckChange(event: boolean, formControlName: string, modality: string): void { this.checkChange.emit({ event, formControlName, diff --git a/src/app/form/form-view/structure-form/structure-name-and-address/structure-name-and-address.component.ts b/src/app/form/form-view/structure-form/structure-name-and-address/structure-name-and-address.component.ts index 70738dac2..8333b1e60 100644 --- a/src/app/form/form-view/structure-form/structure-name-and-address/structure-name-and-address.component.ts +++ b/src/app/form/form-view/structure-form/structure-name-and-address/structure-name-and-address.component.ts @@ -16,11 +16,11 @@ export class StructureNameAndAddressComponent implements OnInit { this.validateForm.emit(); } - public setValidationsForm() { + public setValidationsForm(): void { this.validateForm.emit(); } - public setAddressStructure(address?: Address) { + public setAddressStructure(address?: Address): void { this.addressStructure.emit(address); } public goBack(): void { diff --git a/src/app/form/form-view/structure-form/structure-public-target/structure-public-target.component.ts b/src/app/form/form-view/structure-form/structure-public-target/structure-public-target.component.ts index 2c7871bf3..79560c5ed 100644 --- a/src/app/form/form-view/structure-form/structure-public-target/structure-public-target.component.ts +++ b/src/app/form/form-view/structure-form/structure-public-target/structure-public-target.component.ts @@ -27,7 +27,7 @@ export class StructurePublicTargetComponent implements OnInit, OnChanges { if (changes.isMandatoryFields) this.validateForm.emit(); } - public updateChoicePublic(choice: string, formControlName: string) { + public updateChoicePublic(choice: string, formControlName: string): void { this.updateChoice.emit({ formControlName: `categories.${formControlName}`, choice }); } diff --git a/src/app/form/form-view/structure-form/structure-solidarity-material/structure-solidarity-material.component.ts b/src/app/form/form-view/structure-form/structure-solidarity-material/structure-solidarity-material.component.ts index c7500331b..75f31b4c5 100644 --- a/src/app/form/form-view/structure-form/structure-solidarity-material/structure-solidarity-material.component.ts +++ b/src/app/form/form-view/structure-form/structure-solidarity-material/structure-solidarity-material.component.ts @@ -21,7 +21,7 @@ export class StructureSolidarityMaterialComponent implements OnInit { this.validateForm.emit(); } - public updateChoiceSolidarityMaterial(choice: string) { + public updateChoiceSolidarityMaterial(choice: string): void { this.updateChoice.emit({ formControlName: 'categories.solidarityMaterial', choice }); } diff --git a/src/app/form/form-view/structure-form/structure-training-type/structure-training-type.component.ts b/src/app/form/form-view/structure-form/structure-training-type/structure-training-type.component.ts index b13e1a7cc..afc0ba2ee 100644 --- a/src/app/form/form-view/structure-form/structure-training-type/structure-training-type.component.ts +++ b/src/app/form/form-view/structure-form/structure-training-type/structure-training-type.component.ts @@ -17,7 +17,7 @@ export class StructureTrainingTypeComponent implements OnInit { this.validateForm.emit(); } - public setTrainingsFromCategories(categories: Category[]) { + public setTrainingsFromCategories(categories: Category[]): void { for (const categorie of categories) { const moduleIds: string[] = categorie.modules.map((module) => module.id); if (this.structureForm.get('categories').get(categorie.id)) { diff --git a/src/app/form/form-view/structure-form/structure-type/structure-type.component.ts b/src/app/form/form-view/structure-form/structure-type/structure-type.component.ts index 99340cafe..906beaa3a 100644 --- a/src/app/form/form-view/structure-form/structure-type/structure-type.component.ts +++ b/src/app/form/form-view/structure-form/structure-type/structure-type.component.ts @@ -15,7 +15,7 @@ export class StructureTypeComponent implements OnInit { this.validateForm.emit(); } - public setTypeStructure(value: string) { + public setTypeStructure(value: string): void { this.typeStructure.emit(value); } public goBack(): void { diff --git a/src/app/form/form-view/structure-form/structure-web-and-social-network/structure-web-and-social-network.component.ts b/src/app/form/form-view/structure-form/structure-web-and-social-network/structure-web-and-social-network.component.ts index d04e03881..bafe4ebb8 100644 --- a/src/app/form/form-view/structure-form/structure-web-and-social-network/structure-web-and-social-network.component.ts +++ b/src/app/form/form-view/structure-form/structure-web-and-social-network/structure-web-and-social-network.component.ts @@ -23,11 +23,11 @@ export class StructureWebAndSocialNetworkComponent implements OnInit { this.validateForm.emit(); } - public toggleSocialNetwork() { + public toggleSocialNetwork(): void { this.toggleSocials.emit(); } - public toggleWebSite() { + public toggleWebSite(): void { this.toggleWebsite.emit(); } diff --git a/src/app/form/orientation-form-view/global-components/multi-radio-form/multi-radio-form.component.ts b/src/app/form/orientation-form-view/global-components/multi-radio-form/multi-radio-form.component.ts index cd50a75f0..bd0945565 100644 --- a/src/app/form/orientation-form-view/global-components/multi-radio-form/multi-radio-form.component.ts +++ b/src/app/form/orientation-form-view/global-components/multi-radio-form/multi-radio-form.component.ts @@ -16,7 +16,7 @@ export class MultiRadioFormComponent implements OnInit { public selectedItem: NeedsType | string; - ngOnInit() { + ngOnInit(): void { if (this.selected) this.selectedItem = this.selected; } diff --git a/src/app/form/orientation-form-view/global-components/navigation/navigation.component.ts b/src/app/form/orientation-form-view/global-components/navigation/navigation.component.ts index 339854554..23514aa36 100644 --- a/src/app/form/orientation-form-view/global-components/navigation/navigation.component.ts +++ b/src/app/form/orientation-form-view/global-components/navigation/navigation.component.ts @@ -28,11 +28,11 @@ export class NavigationComponent { public buttonTypeEnum = ButtonType; public NeedsTypeEnum = NeedsType; constructor(private router: Router, private route: ActivatedRoute) {} - public nextPage(isPrint?: boolean) { + public nextPage(isPrint?: boolean): void { this.goNext.emit(isPrint); } - public prevPage() { + public prevPage(): void { this.goPrev.emit(); } public goCarto(): void { diff --git a/src/app/form/orientation-form-view/global-components/needs-selection/needs-selection.component.ts b/src/app/form/orientation-form-view/global-components/needs-selection/needs-selection.component.ts index f37b5d7d5..262a31dc0 100644 --- a/src/app/form/orientation-form-view/global-components/needs-selection/needs-selection.component.ts +++ b/src/app/form/orientation-form-view/global-components/needs-selection/needs-selection.component.ts @@ -18,7 +18,7 @@ export class NeedsSelectionComponent implements OnInit { constructor(public orientationService: OrientationService, private personalOfferService: PersonalOfferService) {} - ngOnInit() { + ngOnInit(): void { if (this.orientationService.rdvUser || this.orientationService.rdvStructure) { this.needsList = this.needsList.filter( (item: INeedItem) => item.key == NeedsType.onlineDemarch || item.key == NeedsType.learnSkills @@ -43,7 +43,7 @@ export class NeedsSelectionComponent implements OnInit { } } - public selectNeed(event: NeedsType) { + public selectNeed(event: NeedsType): void { this.setNeedType.emit(event); } public getSelected(): string | NeedsType { diff --git a/src/app/form/orientation-form-view/global-components/structure-orientator/structure-orientator.component.ts b/src/app/form/orientation-form-view/global-components/structure-orientator/structure-orientator.component.ts index f63414f7f..d2d5bedbe 100644 --- a/src/app/form/orientation-form-view/global-components/structure-orientator/structure-orientator.component.ts +++ b/src/app/form/orientation-form-view/global-components/structure-orientator/structure-orientator.component.ts @@ -46,7 +46,7 @@ export class StructureOrientatorComponent implements OnInit { this.validatePage.emit(this.form.valid); } - public updatedForm(field: string, target: EventTarget) { + public updatedForm(field: string, target: EventTarget): void { const value = (target as HTMLInputElement).value; if (field === 'phone') { this.utils.modifyPhoneInput(this.form, 'phone', target); diff --git a/src/app/form/orientation-form-view/online-demarch/online-mediation/mediation-beneficiary-info/mediation-beneficiary-info.component.ts b/src/app/form/orientation-form-view/online-demarch/online-mediation/mediation-beneficiary-info/mediation-beneficiary-info.component.ts index 8c67872fc..eddda6a5d 100644 --- a/src/app/form/orientation-form-view/online-demarch/online-mediation/mediation-beneficiary-info/mediation-beneficiary-info.component.ts +++ b/src/app/form/orientation-form-view/online-demarch/online-mediation/mediation-beneficiary-info/mediation-beneficiary-info.component.ts @@ -26,7 +26,7 @@ export class MediationBeneficiaryInfoComponent implements OnInit { return Boolean(this.form.get('email')); } - public updatedForm(field: string, target: EventTarget) { + public updatedForm(field: string, target: EventTarget): void { const value = (target as HTMLInputElement).value; if (field === 'phone') { this.utils.modifyPhoneInput(this.form, 'phone', target); diff --git a/src/app/form/orientation-form-view/online-demarch/onlineDemarch-form.component.ts b/src/app/form/orientation-form-view/online-demarch/onlineDemarch-form.component.ts index f53e29364..d0dd6b835 100644 --- a/src/app/form/orientation-form-view/online-demarch/onlineDemarch-form.component.ts +++ b/src/app/form/orientation-form-view/online-demarch/onlineDemarch-form.component.ts @@ -111,10 +111,10 @@ export class OnlineDemarchFormComponent { } } - public getSocialWorker(item: Owner) { + public getSocialWorker(item: Owner): void { this.socialWorker = item; } - public getSelectedStructureRDV(structure: Structure) { + public getSelectedStructureRDV(structure: Structure): void { this.selectedStructureRDV = structure; } diff --git a/src/app/form/orientation-form-view/orientation-structure-list/orientation-comments/orientation-comments.component.ts b/src/app/form/orientation-form-view/orientation-structure-list/orientation-comments/orientation-comments.component.ts index b2efa8288..3fbac07de 100644 --- a/src/app/form/orientation-form-view/orientation-structure-list/orientation-comments/orientation-comments.component.ts +++ b/src/app/form/orientation-form-view/orientation-structure-list/orientation-comments/orientation-comments.component.ts @@ -18,7 +18,7 @@ export class OrientationCommentsComponent implements OnInit { return this.form.get(nameControl); } - public setComment(target?: EventTarget) { + public setComment(target?: EventTarget): void { this.checkValidation.emit((target as HTMLTextAreaElement).value); } } diff --git a/src/app/form/orientation-form-view/orientation-structure-list/orientation-structure-address/orientation-structure-address.component.ts b/src/app/form/orientation-form-view/orientation-structure-list/orientation-structure-address/orientation-structure-address.component.ts index b93635deb..52c536fdc 100644 --- a/src/app/form/orientation-form-view/orientation-structure-list/orientation-structure-address/orientation-structure-address.component.ts +++ b/src/app/form/orientation-form-view/orientation-structure-list/orientation-structure-address/orientation-structure-address.component.ts @@ -16,7 +16,7 @@ export class OrientationStructureAddressComponent implements OnInit { this.setAddressStructure(); } - public setAddressStructure(address?: Address) { + public setAddressStructure(address?: Address): void { this.form.get('address').patchValue(address); this.addressStructure.emit(address); } diff --git a/src/app/models/week.model.ts b/src/app/models/week.model.ts index 25f1d8975..94e35a67c 100644 --- a/src/app/models/week.model.ts +++ b/src/app/models/week.model.ts @@ -62,7 +62,7 @@ export class Week { } } - public hasData() { + public hasData(): boolean { if ( this.monday.time.length === 0 && this.tuesday.time.length === 0 && diff --git a/src/app/profile/edit/edit.component.ts b/src/app/profile/edit/edit.component.ts index 8f35e3f9e..93a8babcf 100644 --- a/src/app/profile/edit/edit.component.ts +++ b/src/app/profile/edit/edit.component.ts @@ -270,7 +270,7 @@ export class EditComponent implements OnInit { } // Updates initialProfile so the button "Valider" is disabled after the user sends new values - private updateInitialProfile() { + private updateInitialProfile(): void { this.initialUserProfile = { ...this.userProfile }; } @@ -360,7 +360,7 @@ export class EditComponent implements OnInit { this.isNewEmployer = false; } - private getEmployers(searchString = '') { + private getEmployers(searchString = ''): void { if (!this.isAlreadySearching) { this.isAlreadySearching = true; this.profileService.getEmployers(searchString).subscribe((employers) => { diff --git a/src/app/profile/personal-offer-edition/personal-offer-edition.component.ts b/src/app/profile/personal-offer-edition/personal-offer-edition.component.ts index c9c78300d..6d71016f1 100644 --- a/src/app/profile/personal-offer-edition/personal-offer-edition.component.ts +++ b/src/app/profile/personal-offer-edition/personal-offer-edition.component.ts @@ -108,7 +108,7 @@ export class PersonalOfferEditionComponent implements OnInit { } } - public setTrainingsFromCategories(categories: Category[]) { + public setTrainingsFromCategories(categories: Category[]): void { for (const categorie of categories) { const moduleIds: string[] = categorie.modules.map((module) => module.id); if (this.personalOfferForm.get('categories').get(categorie.id)) { @@ -125,7 +125,7 @@ export class PersonalOfferEditionComponent implements OnInit { this.deleteOfferModal = false; } - public confirmDeleteOffer() { + public confirmDeleteOffer(): void { this.personalOfferService.deletePersonalOffer(this.personalOffer._id).subscribe( () => { this.notificationService.showSuccess('Votre offre de service a bien été supprimée.'); diff --git a/src/app/profile/profile.component.ts b/src/app/profile/profile.component.ts index ccf783c71..058f9ce9c 100644 --- a/src/app/profile/profile.component.ts +++ b/src/app/profile/profile.component.ts @@ -66,7 +66,7 @@ export class ProfileComponent implements OnInit { }); } - private getStructuresFromProfile() { + private getStructuresFromProfile(): void { const structures$: Observable<any>[] = []; this.structures = []; @@ -83,7 +83,7 @@ export class ProfileComponent implements OnInit { this.structures.sort((a, b) => a.structure.structureName.localeCompare(b.structure.structureName)); }); } - private getPendingStructuresFromProfile() { + private getPendingStructuresFromProfile(): void { const structures$: Observable<any>[] = []; this.structures = []; this.userProfile.pendingStructuresLink.forEach((pending: pendingStructureLink) => { diff --git a/src/app/profile/structure-edition-summary/structure-edition-summary.component.ts b/src/app/profile/structure-edition-summary/structure-edition-summary.component.ts index 1e7fc5245..833b1ed3b 100644 --- a/src/app/profile/structure-edition-summary/structure-edition-summary.component.ts +++ b/src/app/profile/structure-edition-summary/structure-edition-summary.component.ts @@ -165,7 +165,7 @@ export class StructureEditionSummaryComponent implements OnInit { this.showAdvancedSkills = !this.showAdvancedSkills; } - public hasWifi(selfServiceMaterial: string[]) { + public hasWifi(selfServiceMaterial: string[]): boolean { return this.utils.hasWifi(selfServiceMaterial); } diff --git a/src/app/services/update.service.ts b/src/app/services/update.service.ts index a8c4ae775..a50ada752 100644 --- a/src/app/services/update.service.ts +++ b/src/app/services/update.service.ts @@ -10,7 +10,7 @@ export class UpdateService { // Ref: https://alligator.io/angular/service-worker-updates/ constructor(private swUpdate: SwUpdate, private notificationService: NotificationService) {} - subscribeUpdate() { + subscribeUpdate(): void { if (this.swUpdate.isEnabled) { this.swUpdate.available.subscribe(() => { this.showUpdateToast(); @@ -18,7 +18,7 @@ export class UpdateService { } } - private async showUpdateToast() { + private async showUpdateToast(): Promise<void> { this.notificationService.showAppNewVersion(); } } diff --git a/src/app/shared/components/accompaniment-picker/accompaniment-picker.component.ts b/src/app/shared/components/accompaniment-picker/accompaniment-picker.component.ts index 0f2e2fbac..bec6152ee 100644 --- a/src/app/shared/components/accompaniment-picker/accompaniment-picker.component.ts +++ b/src/app/shared/components/accompaniment-picker/accompaniment-picker.component.ts @@ -24,7 +24,7 @@ export class AccompanimentPickerComponent implements OnInit, OnChanges { this.initSelectedModule(); } - private initSelectedModule() { + private initSelectedModule(): void { this.selectedModules = this.onlineProcedures.modules.filter((module) => this.personalOfferForm.get('categories').get('onlineProcedures').value.includes(module.id) ); diff --git a/src/app/shared/components/address-autocomplete/address-autocomplete.component.ts b/src/app/shared/components/address-autocomplete/address-autocomplete.component.ts index db0d5c699..297b14a74 100644 --- a/src/app/shared/components/address-autocomplete/address-autocomplete.component.ts +++ b/src/app/shared/components/address-autocomplete/address-autocomplete.component.ts @@ -38,7 +38,7 @@ export class AddressAutocompleteComponent implements OnInit, OnChanges { } } - public onSearchChange(event: Event) { + public onSearchChange(event: Event): void { const searchString = (event.target as HTMLInputElement).value; if (!this.isAlreadySearching) { this.isAlreadySearching = true; diff --git a/src/app/shared/components/structure-type-picker/structure-type-picker.component.ts b/src/app/shared/components/structure-type-picker/structure-type-picker.component.ts index 7a2551c02..91f5249bb 100644 --- a/src/app/shared/components/structure-type-picker/structure-type-picker.component.ts +++ b/src/app/shared/components/structure-type-picker/structure-type-picker.component.ts @@ -29,7 +29,7 @@ export class StructureTypePickerComponent implements OnInit { constructor(private structureTypeService: StructureTypeService) {} - ngOnInit() { + ngOnInit(): void { this.structureTypeService.getStructureTypes().subscribe((types) => { // Filter "other" structure type types = types.filter((type) => type.selectable); diff --git a/src/app/shared/components/text-input-modal/text-input-modal.component.ts b/src/app/shared/components/text-input-modal/text-input-modal.component.ts index 2fc0a3c62..9762e32b2 100644 --- a/src/app/shared/components/text-input-modal/text-input-modal.component.ts +++ b/src/app/shared/components/text-input-modal/text-input-modal.component.ts @@ -15,7 +15,7 @@ export class TextInputModalComponent { public buttonTypeEnum = ButtonType; public myContent: string; - public closeModal(shouldSend: boolean, content: string) { + public closeModal(shouldSend: boolean, content: string): void { this.newContent.emit({ shouldSend, content }); } } diff --git a/src/app/shared/components/training-type-picker/training-type-picker.component.ts b/src/app/shared/components/training-type-picker/training-type-picker.component.ts index db834d618..21f1580a4 100644 --- a/src/app/shared/components/training-type-picker/training-type-picker.component.ts +++ b/src/app/shared/components/training-type-picker/training-type-picker.component.ts @@ -38,7 +38,7 @@ export class TrainingTypePickerComponent implements OnInit, OnChanges { this.initSelectedChoice(); } - private initSelectedChoice() { + private initSelectedChoice(): void { this.selectedChoices = cloneDeep(this.categories); this.selectedChoices.forEach((category) => { let selectedModulesId: string[] = []; @@ -69,7 +69,7 @@ export class TrainingTypePickerComponent implements OnInit, OnChanges { } } - public isModulePicked(categorie: Category, module: Module) { + public isModulePicked(categorie: Category, module: Module): boolean { const index = this.selectedChoices.findIndex((_categorie) => _categorie.id === categorie.id); if (index === -1) return false; return this.selectedChoices[index].modules.findIndex((_module) => _module.id === module.id) > -1; diff --git a/src/app/shared/components/v3/input/input.component.ts b/src/app/shared/components/v3/input/input.component.ts index dca54ffd7..484723782 100644 --- a/src/app/shared/components/v3/input/input.component.ts +++ b/src/app/shared/components/v3/input/input.component.ts @@ -30,7 +30,7 @@ export class InputV3Component { @Output() valueChange = new EventEmitter<Event>(); - public onValueChange(event: Event) { + public onValueChange(event: Event): void { this.valueChange.emit(event); } } diff --git a/src/app/shared/components/v3/tag/tag-item/tag-item.component.ts b/src/app/shared/components/v3/tag/tag-item/tag-item.component.ts index dbef38b91..0ed42fbbb 100644 --- a/src/app/shared/components/v3/tag/tag-item/tag-item.component.ts +++ b/src/app/shared/components/v3/tag/tag-item/tag-item.component.ts @@ -37,7 +37,7 @@ export class TagItemV3Component { return [this.size, this.selected ? 'selected' : '', this.clickable ? 'clickable' : 'unclickable']; } - public get iconSize() { + public get iconSize(): 'icon-12' | 'icon-16' { return this.size === 'small' ? 'icon-12' : 'icon-16'; } } diff --git a/src/app/shared/components/v3/textarea/textarea.component.ts b/src/app/shared/components/v3/textarea/textarea.component.ts index a5ad8024a..efb0cb024 100644 --- a/src/app/shared/components/v3/textarea/textarea.component.ts +++ b/src/app/shared/components/v3/textarea/textarea.component.ts @@ -31,7 +31,7 @@ export class TextareaV3Component { @Output() valueChange = new EventEmitter<string>(); - public onValueChange(event: Event) { + public onValueChange(event: Event): void { this.valueChange.emit((event.target as HTMLTextAreaElement).value); } } diff --git a/src/app/shared/directives/modalOutside.directive.ts b/src/app/shared/directives/modalOutside.directive.ts index 98dcf580c..418d47cd4 100644 --- a/src/app/shared/directives/modalOutside.directive.ts +++ b/src/app/shared/directives/modalOutside.directive.ts @@ -8,7 +8,7 @@ export class ModalOutsideDirective { @Output() appClickOutside = new EventEmitter<any>(); - @HostListener('document:mousedown', ['$event.target']) onMouseEnter(targetElement) { + @HostListener('document:mousedown', ['$event.target']) onMouseEnter(targetElement): void { const clickedInside = this.elementRef.nativeElement.contains(targetElement); if (!clickedInside) { this.appClickOutside.emit(null); diff --git a/src/app/shared/validator/form.ts b/src/app/shared/validator/form.ts index 9f372b438..d7c4e8870 100644 --- a/src/app/shared/validator/form.ts +++ b/src/app/shared/validator/form.ts @@ -16,7 +16,7 @@ export function MustMatch(controlName: string, matchingControlName: string): any } export function CheckHours(opening: string) { - return (control: AbstractControl) => { + return (control: AbstractControl): null | { forbiddenName: { value: any } } => { const regex = new RegExp('([0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]'); if (regex.test(control.value) && new Date('1/1/1999 ' + opening) < new Date('1/1/1999 ' + control.value)) { return null; diff --git a/src/app/structure-list/structure-list.component.ts b/src/app/structure-list/structure-list.component.ts index 768ba5a67..b307176f1 100644 --- a/src/app/structure-list/structure-list.component.ts +++ b/src/app/structure-list/structure-list.component.ts @@ -116,7 +116,7 @@ export class StructureListComponent implements OnChanges, OnInit { this.displayMapMarkerId.emit(undefined); } - public print() { + public print(): void { this.printService.printDocuments('structures-search', this.structureList); } } diff --git a/src/app/utils/orientationUtils.ts b/src/app/utils/orientationUtils.ts index 502b65571..2192da6b9 100644 --- a/src/app/utils/orientationUtils.ts +++ b/src/app/utils/orientationUtils.ts @@ -264,7 +264,11 @@ export class OrientationUtils { } } - public async rdvDisableItemsNotOffered(modules: Module[], orientationService: OrientationService, category: string) { + public async rdvDisableItemsNotOffered( + modules: Module[], + orientationService: OrientationService, + category: string + ): Promise<void> { let personalOffers: PersonalOffer[] = []; let offersEnabled: string[] = []; diff --git a/src/app/utils/utils.ts b/src/app/utils/utils.ts index d2e55b521..090f4f4a9 100644 --- a/src/app/utils/utils.ts +++ b/src/app/utils/utils.ts @@ -75,11 +75,11 @@ export class Utils { return structure.website !== null && structure.website !== ''; } - public getDigitalHelpLabel(digitalHelp: Demarches) { + public getDigitalHelpLabel(digitalHelp: Demarches): string { return Demarches[digitalHelp]; } - public hasWifi(selfServiceMaterial: string[]) { + public hasWifi(selfServiceMaterial: string[]): boolean { return selfServiceMaterial.includes('wifiEnAccesLibre'); } @@ -109,7 +109,7 @@ export class Utils { } } - public getOtherServicesLabel(otherService: OtherServices) { + public getOtherServicesLabel(otherService: OtherServices): string { return OtherServices[otherService]; } -- GitLab From b86ff36803a3bde13e2a5567e14f608f6bdd2605 Mon Sep 17 00:00:00 2001 From: Bastien Dumont <bdumont@grandlyon.com> Date: Tue, 21 Nov 2023 17:13:49 +0100 Subject: [PATCH 07/13] eqeqeq --- .eslintrc.json | 1 + src/app/form/form-view/form-view.component.ts | 2 +- .../profile-structure-choice.component.ts | 2 +- .../needs-selection/needs-selection.component.ts | 4 ++-- .../orientation-form-view.component.ts | 6 +++--- src/app/login/login.component.ts | 2 +- src/app/page/page.component.ts | 2 +- .../post/components/post-header/post-header.component.ts | 2 +- src/app/post/services/post.service.ts | 2 +- src/app/profile/edit/edit.component.ts | 8 ++++---- src/app/profile/services/profile.service.ts | 2 +- src/app/services/structure.service.ts | 2 +- .../data-share-consent/data-share-consent.component.ts | 4 ++-- .../structure-list-search.component.ts | 4 ++-- src/app/structure-list/structure-list.component.ts | 6 +++--- tslint.json | 1 - 16 files changed, 25 insertions(+), 25 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 256dd23f0..260592c0f 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -41,6 +41,7 @@ // TSLINT rules migration "@typescript-eslint/no-explicit-any": "off", // TO DELETE "@typescript-eslint/explicit-function-return-type": "error", + "eqeqeq": "error", // JSDOC extends overrides: disable some of extends rules // JSdoc is not always needed diff --git a/src/app/form/form-view/form-view.component.ts b/src/app/form/form-view/form-view.component.ts index 51ea81fff..96cba3a81 100644 --- a/src/app/form/form-view/form-view.component.ts +++ b/src/app/form/form-view/form-view.component.ts @@ -251,7 +251,7 @@ export class FormViewComponent implements OnInit, AfterViewInit { // If the user is creating personalOffer for one of his structure from his profile, we skip the structure choice step if ( this.isPersonalOfferProfile && - this.currentFormType == formType.personaloffer && + this.currentFormType === formType.personaloffer && this.currentPage === personalOfferFormStep.personalOfferStructureChoice - 1 ) { this.setHasOtherPersonalOffer(false); diff --git a/src/app/form/form-view/profile-form/profile-structure-choice/profile-structure-choice.component.ts b/src/app/form/form-view/profile-form/profile-structure-choice/profile-structure-choice.component.ts index 48b9f0e2c..0603a0c58 100644 --- a/src/app/form/form-view/profile-form/profile-structure-choice/profile-structure-choice.component.ts +++ b/src/app/form/form-view/profile-form/profile-structure-choice/profile-structure-choice.component.ts @@ -56,7 +56,7 @@ export class ProfileStructureChoiceComponent implements OnInit { if (structure.alreadySelected) { return; } - this.itemSelected = this.itemSelected == structure._id ? null : structure._id; + this.itemSelected = this.itemSelected === structure._id ? null : structure._id; if (this.itemSelected) { this.selectedStructureItem = structure; this.structureForm.patchValue({ _id: structure._id, structureName: structure.structureName }); diff --git a/src/app/form/orientation-form-view/global-components/needs-selection/needs-selection.component.ts b/src/app/form/orientation-form-view/global-components/needs-selection/needs-selection.component.ts index 262a31dc0..ff1eb19cc 100644 --- a/src/app/form/orientation-form-view/global-components/needs-selection/needs-selection.component.ts +++ b/src/app/form/orientation-form-view/global-components/needs-selection/needs-selection.component.ts @@ -21,7 +21,7 @@ export class NeedsSelectionComponent implements OnInit { ngOnInit(): void { if (this.orientationService.rdvUser || this.orientationService.rdvStructure) { this.needsList = this.needsList.filter( - (item: INeedItem) => item.key == NeedsType.onlineDemarch || item.key == NeedsType.learnSkills + (item: INeedItem) => item.key === NeedsType.onlineDemarch || item.key === NeedsType.learnSkills ); } @@ -47,7 +47,7 @@ export class NeedsSelectionComponent implements OnInit { this.setNeedType.emit(event); } public getSelected(): string | NeedsType { - const selected = this.needsList.filter((need) => need.key == this.currentNeed)[0]; + const selected = this.needsList.filter((need) => need.key === this.currentNeed)[0]; if (selected) { this.validate.emit(); return selected.key; diff --git a/src/app/form/orientation-form-view/orientation-form-view.component.ts b/src/app/form/orientation-form-view/orientation-form-view.component.ts index ff8275596..5d9b2a72a 100644 --- a/src/app/form/orientation-form-view/orientation-form-view.component.ts +++ b/src/app/form/orientation-form-view/orientation-form-view.component.ts @@ -223,7 +223,7 @@ export class OrientationFormViewComponent implements OnInit, AfterContentChecked }; // pmrAccess filter must not be send in the onlineDemarcheType array of the appointment - appointment.onlineDemarcheType = appointment.onlineDemarcheType.filter((item) => item.name != 'pmrAccess'); + appointment.onlineDemarcheType = appointment.onlineDemarcheType.filter((item) => item.name !== 'pmrAccess'); await lastValueFrom(this.orientationService.createAppointment(appointment)); this.canDeactivate = true; @@ -282,7 +282,7 @@ export class OrientationFormViewComponent implements OnInit, AfterContentChecked case OnlineDemarche.appointment: this.currentType = OnlineDemarche.appointment; // Skip first screen appointment info for learnSkills - if (this.indicatorNeedType == NeedsType.learnSkills) { + if (this.indicatorNeedType === NeedsType.learnSkills) { this.currentStep = AppointmentSteps.infoScreen + 1; } else { this.currentStep = AppointmentSteps.infoScreen; @@ -463,7 +463,7 @@ export class OrientationFormViewComponent implements OnInit, AfterContentChecked // For orientation rdv, structure categories must be ignored: we filter only on personalOffers with appointment of the structure (await lastValueFrom(this.structureService.getStructures(this.filters, 'search', true))).filter( (structure) => structure.hasUserWithAppointmentDN - ).length == 0 + ).length === 0 ) { this.sendOrientationIndicator(this.structureOrientationForm ?? this.onlineDemarcheForm); this.currentStep = AppointmentSteps.rdvEnd - 1; diff --git a/src/app/login/login.component.ts b/src/app/login/login.component.ts index e79bfc913..96154c632 100644 --- a/src/app/login/login.component.ts +++ b/src/app/login/login.component.ts @@ -101,7 +101,7 @@ export class LoginComponent implements OnInit { } } catch (e) { this.loading = false; - if (e.status == 418) { + if (e.status === 418) { this.isUnverifiedEmail = true; } else { this.authFailed = true; diff --git a/src/app/page/page.component.ts b/src/app/page/page.component.ts index 990875565..dba9dd89b 100644 --- a/src/app/page/page.component.ts +++ b/src/app/page/page.component.ts @@ -43,7 +43,7 @@ export class PageComponent implements OnInit { }); }); // Display version number in 'About' page only - this.version = this.slugPage == PageEnum.quiSommesNous ? packageJson.version : ''; + this.version = this.slugPage === PageEnum.quiSommesNous ? packageJson.version : ''; }); } } diff --git a/src/app/post/components/post-header/post-header.component.ts b/src/app/post/components/post-header/post-header.component.ts index 5d9be717d..4e713fabc 100644 --- a/src/app/post/components/post-header/post-header.component.ts +++ b/src/app/post/components/post-header/post-header.component.ts @@ -130,7 +130,7 @@ export class PostHeaderComponent implements OnInit { if (this.mainActiveTag.slug === TagEnum.aLaUne) { return ''; } - return this.mainActiveTag.slug == this.tagEnum.etudes ? this.mainActiveTag.name : this.mainActiveTag.slug; + return this.mainActiveTag.slug === this.tagEnum.etudes ? this.mainActiveTag.name : this.mainActiveTag.slug; } public togglePublishNews(): void { diff --git a/src/app/post/services/post.service.ts b/src/app/post/services/post.service.ts index ef2771e37..e95c455c9 100644 --- a/src/app/post/services/post.service.ts +++ b/src/app/post/services/post.service.ts @@ -32,7 +32,7 @@ export class PostService { // Transform tab filters to string filters tags.forEach((tag, index) => { tagsString += tag; - if (index != tags.length - 1) { + if (index !== tags.length - 1) { tagsString += '+tags:'; } }); diff --git a/src/app/profile/edit/edit.component.ts b/src/app/profile/edit/edit.component.ts index 93a8babcf..4fa400d4b 100644 --- a/src/app/profile/edit/edit.component.ts +++ b/src/app/profile/edit/edit.component.ts @@ -171,7 +171,7 @@ export class EditComponent implements OnInit { if (this.emailModal) { return this.emailValid(this.newEmail) && this.newEmail === this.newEmailConfirm; } else if (this.passwordModal) { - return this.passwordValid(this.newPassword) && this.newPassword == this.newPasswordConfirm; + return this.passwordValid(this.newPassword) && this.newPassword === this.newPasswordConfirm; } } else if (this.currentTab === tabsEnum.employer) { if (this.isNewUser) { @@ -284,12 +284,12 @@ export class EditComponent implements OnInit { } public confirmNewPassword(): void { - if (this.passwordValid(this.newPassword) && this.newPassword == this.newPasswordConfirm) { + if (this.passwordValid(this.newPassword) && this.newPassword === this.newPasswordConfirm) { this.profileService .changePassword(this.newPassword, this.oldPassword) .pipe( catchError(async (response: HttpErrorResponse) => { - if (response.error.statusCode == 401) { + if (response.error.statusCode === 401) { this.notificationService.showError('Une erreur est survenue'); throw new Error('Une erreur est survenue'); } @@ -371,7 +371,7 @@ export class EditComponent implements OnInit { } public canExit(): Promise<boolean> { - if (this.hasPersonalOffer && this.selectedRdvChoice == undefined) { + if (this.hasPersonalOffer && this.selectedRdvChoice === undefined) { return new Promise(() => this.showModal()); } } diff --git a/src/app/profile/services/profile.service.ts b/src/app/profile/services/profile.service.ts index 9ef856481..64cbf371e 100644 --- a/src/app/profile/services/profile.service.ts +++ b/src/app/profile/services/profile.service.ts @@ -58,7 +58,7 @@ export class ProfileService { const token = user.accessToken; // decode the token to get its payload const tokenPayload: User = decode(token); - if (tokenPayload.role == UserRole.admin) { + if (tokenPayload.role === UserRole.admin) { return true; } return false; diff --git a/src/app/services/structure.service.ts b/src/app/services/structure.service.ts index 1511902bd..b6b500bf1 100644 --- a/src/app/services/structure.service.ts +++ b/src/app/services/structure.service.ts @@ -77,7 +77,7 @@ export class StructureService { requestUrl += `?query=${queryString.value}`; } // Set specific PMR filter (which must be displayed in 'accessModality' category) - const filterPMR = filters.find((filter) => filter.text == 'Accessible PMR'); + const filterPMR = filters.find((filter) => filter.text === 'Accessible PMR'); if (filterPMR) filterPMR.name = 'pmrAccess'; const andFormatedFilters = this.formatFilters(filters.filter((e) => !e.orOperator)); diff --git a/src/app/shared/components/data-share-consent/data-share-consent.component.ts b/src/app/shared/components/data-share-consent/data-share-consent.component.ts index 45eb8be9d..80e66d683 100644 --- a/src/app/shared/components/data-share-consent/data-share-consent.component.ts +++ b/src/app/shared/components/data-share-consent/data-share-consent.component.ts @@ -21,7 +21,7 @@ export class DataShareConsentComponent implements OnInit { @Input() public opened = true; @Input() public dataConsentPendingStructures: Structure[]; - ngOnInit() { + ngOnInit(): void { this.consentForm = new UntypedFormGroup({}); for (const structure of this.dataConsentPendingStructures) { this.consentForm.addControl( @@ -36,7 +36,7 @@ export class DataShareConsentComponent implements OnInit { } public getPendingStructure(id: string): Structure { - const result = this.dataConsentPendingStructures.filter((structure) => structure._id == id); + const result = this.dataConsentPendingStructures.filter((structure) => structure._id === id); return result?.[0] || null; } diff --git a/src/app/structure-list/components/structure-list-search/structure-list-search.component.ts b/src/app/structure-list/components/structure-list-search/structure-list-search.component.ts index e1091c6be..7f329a2ab 100644 --- a/src/app/structure-list/components/structure-list-search/structure-list-search.component.ts +++ b/src/app/structure-list/components/structure-list-search/structure-list-search.component.ts @@ -61,7 +61,7 @@ export class StructureListSearchComponent implements OnInit { this.searchService.getCategories().subscribe((categories: Category[]) => { // manually add PMR module for More Filters modal if (!this.prmAdded) { - const index = categories.findIndex((element) => element.id == 'accessModality'); + const index = categories.findIndex((element) => element.id === 'accessModality'); if (index > -1) { categories[index].modules.push(new Module('True', 'Accessible PMR', 'Accessible PMR')); this.prmAdded = true; @@ -84,7 +84,7 @@ export class StructureListSearchComponent implements OnInit { filters.push(new Filter('query', term)); } // Add checked box filter - modules.forEach((cm) => filters.push(new Filter(cm.name, cm.id, cm.displayText, cm.name == 'ctm'))); + modules.forEach((cm) => filters.push(new Filter(cm.name, cm.id, cm.displayText, cm.name === 'ctm'))); return filters; } diff --git a/src/app/structure-list/structure-list.component.ts b/src/app/structure-list/structure-list.component.ts index b307176f1..2f08ac14c 100644 --- a/src/app/structure-list/structure-list.component.ts +++ b/src/app/structure-list/structure-list.component.ts @@ -75,10 +75,10 @@ export class StructureListComponent implements OnChanges, OnInit { } public addToList(structure: Structure): void { - const index = this.selectedStructureList.findIndex((elem) => elem._id == structure._id); + const index = this.selectedStructureList.findIndex((elem) => elem._id === structure._id); if (index > -1) { this.selectedStructureList = this.selectedStructureList.filter((elem) => { - return elem._id != structure._id; + return elem._id !== structure._id; }); } else { this.selectedStructureList.push(structure); @@ -88,7 +88,7 @@ export class StructureListComponent implements OnChanges, OnInit { } public isInPrintList(id: string): boolean { - return this.selectedStructureList.findIndex((elem) => elem._id == id) > -1 ? true : false; + return this.selectedStructureList.findIndex((elem) => elem._id === id) > -1 ? true : false; } public addStructure(): void { diff --git a/tslint.json b/tslint.json index 86bf29a2c..0387717dc 100644 --- a/tslint.json +++ b/tslint.json @@ -18,7 +18,6 @@ "options": ["spaces"] }, "max-classes-per-file": false, - "max-line-length": [true, 140], "member-ordering": [ true, { -- GitLab From f72826c3e341fc108200ffc8e496c2d6f670a119 Mon Sep 17 00:00:00 2001 From: Bastien Dumont <bdumont@grandlyon.com> Date: Tue, 21 Nov 2023 17:14:43 +0100 Subject: [PATCH 08/13] add return type of sb example --- src/stories/page.component.ts | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/stories/page.component.ts b/src/stories/page.component.ts index f3ae48685..03a30527a 100644 --- a/src/stories/page.component.ts +++ b/src/stories/page.component.ts @@ -20,18 +20,16 @@ import type { User } from './User'; process starting with atomic components and ending with pages. </p> <p> - Render pages with mock data. This makes it easy to build and review page states without - needing to navigate to them in your app. Here are some handy patterns for managing page data - in Storybook: + Render pages with mock data. This makes it easy to build and review page states without needing to navigate to + them in your app. Here are some handy patterns for managing page data in Storybook: </p> <ul> <li> - Use a higher-level connected component. Storybook helps you compose such data from the - "args" of child component stories + Use a higher-level connected component. Storybook helps you compose such data from the "args" of child + component stories </li> <li> - Assemble data in the page component from your services. You can mock these services out - using Storybook. + Assemble data in the page component from your services. You can mock these services out using Storybook. </li> </ul> <p> @@ -63,15 +61,15 @@ import type { User } from './User'; export default class PageComponent { user: User | null = null; - doLogout() { + doLogout(): void { this.user = null; } - doLogin() { + doLogin(): void { this.user = { name: 'Jane Doe' }; } - doCreateAccount() { + doCreateAccount(): void { this.user = { name: 'Jane Doe' }; } } -- GitLab From efb4e913468f4b003e543d15bdb4f5c02d4e5704 Mon Sep 17 00:00:00 2001 From: Bastien Dumont <bdumont@grandlyon.com> Date: Tue, 21 Nov 2023 17:19:29 +0100 Subject: [PATCH 09/13] jsdoc redundant annotation --- src/app/models/structure.model.ts | 1 - src/app/post/components/post-list/post-list.component.ts | 1 - .../profile-newsletter/profile-newsletter.component.ts | 4 ++-- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/app/models/structure.model.ts b/src/app/models/structure.model.ts index 6bd5fa508..c88d323ff 100644 --- a/src/app/models/structure.model.ts +++ b/src/app/models/structure.model.ts @@ -115,7 +115,6 @@ export class Structure { /** * Verify that a structure as not only equipments with 0 as value. This is mostly use for display. - * @returns {boolean} validation */ public hasNotOnlyEmptyEquipments(): boolean { if (this.nbComputers + this.nbPrinters + this.nbScanners > 0) return true; diff --git a/src/app/post/components/post-list/post-list.component.ts b/src/app/post/components/post-list/post-list.component.ts index 46162ac87..2a25b8d48 100644 --- a/src/app/post/components/post-list/post-list.component.ts +++ b/src/app/post/components/post-list/post-list.component.ts @@ -65,7 +65,6 @@ export class PostListComponent implements OnInit { /** * Fill articles list with headline handling - * @param news {PostWithMeta} */ public fillArticles(news: PostWithMeta): void { this.setNews(news); diff --git a/src/app/profile/profile-newsletter/profile-newsletter.component.ts b/src/app/profile/profile-newsletter/profile-newsletter.component.ts index 4594eddb6..4aee59027 100644 --- a/src/app/profile/profile-newsletter/profile-newsletter.component.ts +++ b/src/app/profile/profile-newsletter/profile-newsletter.component.ts @@ -24,7 +24,7 @@ export class ProfileNewsletterComponent implements OnInit { }); } - public handleSubscribe() { + public handleSubscribe(): void { this.isLoading = true; this.newsletterService.subscribe(this.userEmail).subscribe({ next: (result) => { @@ -46,7 +46,7 @@ export class ProfileNewsletterComponent implements OnInit { }); } - public handleUnsubscribe() { + public handleUnsubscribe(): void { this.isLoading = true; this.newsletterService.unsubscribe(this.userEmail).subscribe({ next: (result) => { -- GitLab From 7df2f640c22d249d24c9a1e76a648732f65137d8 Mon Sep 17 00:00:00 2001 From: Bastien Dumont <bdumont@grandlyon.com> Date: Tue, 21 Nov 2023 17:25:19 +0100 Subject: [PATCH 10/13] add words --- .vscode/settings.json | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index b966268f9..23711d0f8 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -32,10 +32,12 @@ "cSpell.words": [ "Annuary", "carto", + "categorie", "cnfs", "covid", "demarch", "facebook", + "friday", "grandlyon", "instagram", "linkedin", @@ -43,22 +45,21 @@ "metropole", "Metropole", "monday", - "tuesday", - "wednesday", - "thursday", - "friday", - "saturday", - "sunday", "NOSONAR", "onespace", "orientator", "Orientator", "personaloffer", "Rés'in", + "saturday", + "smedium", + "sunday", + "thursday", "toastr", + "tuesday", "ultrawide", "unclickable", - "smedium", + "wednesday", "xsmall", "xxsmall" ] -- GitLab From 004432c701428531195259140d8f8be10dac030d Mon Sep 17 00:00:00 2001 From: Bastien Dumont <bdumont@grandlyon.com> Date: Tue, 21 Nov 2023 17:27:26 +0100 Subject: [PATCH 11/13] remove tslint.json --- tslint.json | 91 ----------------------------------------------------- 1 file changed, 91 deletions(-) delete mode 100644 tslint.json diff --git a/tslint.json b/tslint.json deleted file mode 100644 index 0387717dc..000000000 --- a/tslint.json +++ /dev/null @@ -1,91 +0,0 @@ -{ - "extends": "tslint:recommended", - "rulesDirectory": ["codelyzer"], - "rules": { - "align": { - "options": ["parameters", "statements"] - }, - "array-type": false, - "arrow-return-shorthand": true, - "curly": [true, "ignore-same-line"], - "deprecation": { - "severity": "warning" - }, - "eofline": true, - "import-blacklist": [true, "rxjs/Rx"], - "import-spacing": true, - "indent": { - "options": ["spaces"] - }, - "max-classes-per-file": false, - "member-ordering": [ - true, - { - "order": ["static-field", "instance-field", "static-method", "instance-method"] - } - ], - "no-console": [true, "debug", "info", "time", "timeEnd", "trace"], - "no-empty": false, - "no-inferrable-types": [true, "ignore-params"], - "no-non-null-assertion": true, - "no-redundant-jsdoc": true, - "no-switch-case-fall-through": true, - "no-var-requires": false, - "object-literal-key-quotes": [true, "as-needed"], - "semicolon": { - "options": ["always"] - }, - "space-before-function-paren": { - "options": { - "anonymous": "never", - "asyncArrow": "always", - "constructor": "never", - "method": "never", - "named": "never" - } - }, - "typedef": [true, "call-signature"], - "typedef-whitespace": { - "options": [ - { - "call-signature": "nospace", - "index-signature": "nospace", - "parameter": "nospace", - "property-declaration": "nospace", - "variable-declaration": "nospace" - }, - { - "call-signature": "onespace", - "index-signature": "onespace", - "parameter": "onespace", - "property-declaration": "onespace", - "variable-declaration": "onespace" - } - ] - }, - "variable-name": { - "options": ["ban-keywords", "check-format", "allow-pascal-case"] - }, - "whitespace": { - "options": ["check-branch", "check-decl", "check-operator", "check-separator", "check-type", "check-typecast"] - }, - "component-class-suffix": true, - "contextual-lifecycle": true, - "directive-class-suffix": true, - "no-conflicting-lifecycle": true, - "no-host-metadata-property": true, - "no-input-rename": true, - "no-inputs-metadata-property": true, - "no-output-native": true, - "no-output-on-prefix": true, - "no-output-rename": true, - "no-outputs-metadata-property": true, - "template-banana-in-box": true, - "template-no-negated-async": true, - "use-lifecycle-interface": true, - "use-pipe-transform-interface": true, - "directive-selector": [true, "attribute", "app", "camelCase"], - "component-selector": [true, "element", "app", "kebab-case"], - "unnecessary-constructor": true - } -} -- GitLab From 4c519888cbc27d8b278d05f1641feba985357c1b Mon Sep 17 00:00:00 2001 From: Bastien Dumont <bdumont@grandlyon.com> Date: Tue, 21 Nov 2023 17:28:20 +0100 Subject: [PATCH 12/13] remove any rule --- .eslintrc.json | 1 - 1 file changed, 1 deletion(-) diff --git a/.eslintrc.json b/.eslintrc.json index 260592c0f..6a83d3343 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -39,7 +39,6 @@ "@typescript-eslint/prefer-optional-chain": "warn", // TSLINT rules migration - "@typescript-eslint/no-explicit-any": "off", // TO DELETE "@typescript-eslint/explicit-function-return-type": "error", "eqeqeq": "error", -- GitLab From 1171d22acd34da77ae8019bf785ff5ba58de45d5 Mon Sep 17 00:00:00 2001 From: Bastien Dumont <bdumont@grandlyon.com> Date: Wed, 29 Nov 2023 11:38:31 +0100 Subject: [PATCH 13/13] run prettier --- src/app/carto/carto.component.ts | 7 +- src/app/map/services/marker.ts | 9 +- src/app/models/address.model.ts | 14 +- src/app/models/structure.model.ts | 2 +- .../no-information.component.ts | 2 +- src/app/services/auth.service.ts | 202 +++++++++--------- src/app/utils/CustomRegExp.ts | 3 +- 7 files changed, 116 insertions(+), 123 deletions(-) diff --git a/src/app/carto/carto.component.ts b/src/app/carto/carto.component.ts index 76fd359b3..995446ec1 100644 --- a/src/app/carto/carto.component.ts +++ b/src/app/carto/carto.component.ts @@ -117,12 +117,7 @@ export class CartoComponent implements OnInit { * @param lat user latitude * @param sortByDistance if set to `true`, structures data is sort by distance. Default value is `true` */ - private updateStructuresDistance( - structures: Structure[], - lon: number, - lat: number, - sortByDistance = true - ): void { + private updateStructuresDistance(structures: Structure[], lon: number, lat: number, sortByDistance = true): void { Promise.all( structures.map(async (structure) => { if (lon && lat) { diff --git a/src/app/map/services/marker.ts b/src/app/map/services/marker.ts index 35efbc6ed..c640c4a20 100644 --- a/src/app/map/services/marker.ts +++ b/src/app/map/services/marker.ts @@ -36,8 +36,7 @@ export const userLocationIcon = divIcon({ }); export const markerIconMdm = divIcon({ className: null, - html: - '<svg width="19" height="24" fill="#D4C4A9" class="mdm"><use xlink:href="assets/ico/sprite.svg#mdm"></use></svg>', + html: '<svg width="19" height="24" fill="#D4C4A9" class="mdm"><use xlink:href="assets/ico/sprite.svg#mdm"></use></svg>', iconSize: [19, 24], iconAnchor: [9, 0], }); @@ -49,16 +48,14 @@ export const markerIconMdmActive = divIcon({ }); export const markerIconFranceService = divIcon({ className: null, - html: - '<svg width="48" height="48" fill="#ED3939" class="france-service"><use xlink:href="assets/ico/sprite.svg#conseillerFranceService"></use></svg>', + html: '<svg width="48" height="48" fill="#ED3939" class="france-service"><use xlink:href="assets/ico/sprite.svg#conseillerFranceService"></use></svg>', iconSize: [48, 48], iconAnchor: [24, 48], popupAnchor: [0, -48], }); export const markerIconFranceServiceActive = divIcon({ className: null, - html: - '<svg width="48" height="48"><use xlink:href="assets/ico/sprite.svg#conseillerFranceServiceSelected"></use></svg>', + html: '<svg width="48" height="48"><use xlink:href="assets/ico/sprite.svg#conseillerFranceServiceSelected"></use></svg>', iconSize: [48, 48], iconAnchor: [24, 48], popupAnchor: [0, -48], diff --git a/src/app/models/address.model.ts b/src/app/models/address.model.ts index 0b1c37af5..75ab6690c 100644 --- a/src/app/models/address.model.ts +++ b/src/app/models/address.model.ts @@ -1,7 +1,7 @@ -export class Address { - numero: string = null; - street: string = null; - commune: string = null; - postcode?: number = null; - coordinates ? = []; -} +export class Address { + numero: string = null; + street: string = null; + commune: string = null; + postcode?: number = null; + coordinates? = []; +} diff --git a/src/app/models/structure.model.ts b/src/app/models/structure.model.ts index c88d323ff..cb2ee1526 100644 --- a/src/app/models/structure.model.ts +++ b/src/app/models/structure.model.ts @@ -58,7 +58,7 @@ export class Structure { public personalOffers: PersonalOffer[] = []; - public alreadySelected ? = false; + public alreadySelected? = false; public hasNoUserDN?: boolean = null; public hasUserWithAppointmentDN?: boolean = null; diff --git a/src/app/profile/structure-edition-summary/no-information/no-information.component.ts b/src/app/profile/structure-edition-summary/no-information/no-information.component.ts index 7946e84e0..81c2715b7 100644 --- a/src/app/profile/structure-edition-summary/no-information/no-information.component.ts +++ b/src/app/profile/structure-edition-summary/no-information/no-information.component.ts @@ -3,6 +3,6 @@ import { Component } from '@angular/core'; @Component({ selector: 'app-no-information', templateUrl: './no-information.component.html', - styleUrls: ['./no-information.component.scss'] + styleUrls: ['./no-information.component.scss'], }) export class NoInformationComponent {} diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts index 093bfe6da..89b8dae84 100644 --- a/src/app/services/auth.service.ts +++ b/src/app/services/auth.service.ts @@ -1,101 +1,101 @@ -import { HttpClient } from '@angular/common/http'; -import { Injectable } from '@angular/core'; -import { DateTime } from 'luxon'; -import { BehaviorSubject, Observable } from 'rxjs'; -import { map } from 'rxjs/operators'; -import { UserAuth } from '../models/user-auth.model'; -import { User } from '../models/user.model'; -import { UserNamePipe } from '../shared/pipes'; -import { Utils } from '../utils/utils'; -@Injectable({ - providedIn: 'root', -}) -export class AuthService { - public userSubject: BehaviorSubject<UserAuth>; - public user: Observable<UserAuth>; - - constructor(private http: HttpClient, public utils: Utils) { - this.userSubject = new BehaviorSubject<UserAuth>(JSON.parse(localStorage.getItem('user'))); - this.user = this.userSubject.asObservable(); - } - - public get userValue(): UserAuth { - return this.userSubject.value; - } - - public get token(): string { - if (this.userSubject.value) { - return this.userSubject.value.accessToken; - } - return null; - } - - public logout(): void { - localStorage.removeItem('user'); - this.userSubject.next(null); - window.location.replace('/home'); - } - - public isLoggedIn(): boolean { - if (this.userValue) { - return DateTime.local().setZone('Europe/Paris') < this.getExpiration(); - } - return false; - } - - public getUserNameDisplay(): string { - return new UserNamePipe().transform(this.userValue.name); - } - - public getUserSurnameDisplay(): string { - return this.userValue.surname.toUpperCase(); - } - - public getUserFullNameDisplay(): string { - return `${this.getUserNameDisplay()} ${this.getUserSurnameDisplay()}`; - } - - public getUserEmailDisplay(): string { - return `${this.userValue.username}`; - } - - private getExpiration(): DateTime { - return DateTime.fromISO(this.userValue.expiresAt, { zone: 'Europe/Paris' }); - } - - public register(user: User): Observable<any> { - return this.http.post('api/users', user); - } - - public login(email: string, password: string): Observable<any> { - return this.http.post<UserAuth>('api/auth/login', { email, password }).pipe( - map((user) => { - // store user details and jwt token in local storage to keep user logged in between page refreshes - localStorage.setItem('user', JSON.stringify(user)); - this.userSubject.next(user); - return user; - }) - ); - } - - public resendEmail(email: string, password: string): Observable<User> { - return this.http.post<User>(`api/auth/resendEmail`, { email, password }); - } - - public verifyUser(userId: string, token: string): Observable<User> { - return this.http.post<User>(`api/users/verify/${userId}`, null, { - params: { token }, - }); - } - - public resetPassword(email: string): Observable<any> { - return this.http.post(`api/users/reset-password`, { email }); - } - - public resetPasswordApply(token: string, password: string): Observable<any> { - return this.http.post(`api/users/reset-password/apply`, { - token, - password, - }); - } -} +import { HttpClient } from '@angular/common/http'; +import { Injectable } from '@angular/core'; +import { DateTime } from 'luxon'; +import { BehaviorSubject, Observable } from 'rxjs'; +import { map } from 'rxjs/operators'; +import { UserAuth } from '../models/user-auth.model'; +import { User } from '../models/user.model'; +import { UserNamePipe } from '../shared/pipes'; +import { Utils } from '../utils/utils'; +@Injectable({ + providedIn: 'root', +}) +export class AuthService { + public userSubject: BehaviorSubject<UserAuth>; + public user: Observable<UserAuth>; + + constructor(private http: HttpClient, public utils: Utils) { + this.userSubject = new BehaviorSubject<UserAuth>(JSON.parse(localStorage.getItem('user'))); + this.user = this.userSubject.asObservable(); + } + + public get userValue(): UserAuth { + return this.userSubject.value; + } + + public get token(): string { + if (this.userSubject.value) { + return this.userSubject.value.accessToken; + } + return null; + } + + public logout(): void { + localStorage.removeItem('user'); + this.userSubject.next(null); + window.location.replace('/home'); + } + + public isLoggedIn(): boolean { + if (this.userValue) { + return DateTime.local().setZone('Europe/Paris') < this.getExpiration(); + } + return false; + } + + public getUserNameDisplay(): string { + return new UserNamePipe().transform(this.userValue.name); + } + + public getUserSurnameDisplay(): string { + return this.userValue.surname.toUpperCase(); + } + + public getUserFullNameDisplay(): string { + return `${this.getUserNameDisplay()} ${this.getUserSurnameDisplay()}`; + } + + public getUserEmailDisplay(): string { + return `${this.userValue.username}`; + } + + private getExpiration(): DateTime { + return DateTime.fromISO(this.userValue.expiresAt, { zone: 'Europe/Paris' }); + } + + public register(user: User): Observable<any> { + return this.http.post('api/users', user); + } + + public login(email: string, password: string): Observable<any> { + return this.http.post<UserAuth>('api/auth/login', { email, password }).pipe( + map((user) => { + // store user details and jwt token in local storage to keep user logged in between page refreshes + localStorage.setItem('user', JSON.stringify(user)); + this.userSubject.next(user); + return user; + }) + ); + } + + public resendEmail(email: string, password: string): Observable<User> { + return this.http.post<User>(`api/auth/resendEmail`, { email, password }); + } + + public verifyUser(userId: string, token: string): Observable<User> { + return this.http.post<User>(`api/users/verify/${userId}`, null, { + params: { token }, + }); + } + + public resetPassword(email: string): Observable<any> { + return this.http.post(`api/users/reset-password`, { email }); + } + + public resetPasswordApply(token: string, password: string): Observable<any> { + return this.http.post(`api/users/reset-password/apply`, { + token, + password, + }); + } +} diff --git a/src/app/utils/CustomRegExp.ts b/src/app/utils/CustomRegExp.ts index 3aec8f1ca..9175ab820 100644 --- a/src/app/utils/CustomRegExp.ts +++ b/src/app/utils/CustomRegExp.ts @@ -23,7 +23,8 @@ export class CustomRegExp { * Validate a phone number (4 or 10 digits, allowing spaces, dashes and dots as spacers) */ public static readonly PHONE: RegExp = /^(?:(?:\+|00)|0)\s*[1-9](?:[\s.-]*\d{2}){4}$|^(?:[\s.-]*\d{2}){2}$/; // NOSONAR - public static readonly WEBSITE: RegExp = /^(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.[a-zA-Z0-9]+\.[^\s]{2,}|[a-zA-Z0-9]+\.[^\s]{2,})/; // NOSONAR + public static readonly WEBSITE: RegExp = + /^(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.[a-zA-Z0-9]+\.[^\s]{2,}|[a-zA-Z0-9]+\.[^\s]{2,})/; // NOSONAR public static readonly LINKEDIN: string = '(linkedin.com/.{1,})'; public static readonly FACEBOOK: string = '(facebook.com/.{1,})'; public static readonly TWITTER: string = '(twitter.com/.{1,})'; -- GitLab