From 92ac697a46456cfa6f56c2dc478c415f27ba934b Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Wed, 4 Sep 2024 12:51:13 +0200 Subject: [PATCH] Fix lint errors following dev-deps upgrade in Frontend --- .../cypress/e2e/sidebars/custom_zones.spec.ts | 2 +- .../e2e/sidebars/regulatory_layers.spec.ts | 6 ++--- frontend/src/api/alert.ts | 4 ++-- .../entities/beaconMalfunction/index.ts | 6 ++--- .../controlUnits/__tests__/utils.test.ts | 2 +- frontend/src/domain/entities/controls.ts | 16 +++++++------- .../ExportActivityReportsDialog/csvMap.ts | 6 ++--- .../regulatory_text/RegulatoryText.tsx | 2 +- .../FleetSegmentsBackoffice/index.tsx | 8 +++---- .../useCases/computeFleetSegments.ts | 6 ++--- .../EditInterestPoint.tsx | 2 +- .../InterestPointMapButton/index.tsx | 2 +- .../features/Logbook/__tests__/utils.test.ts | 14 ++++++------ .../LogbookMessageResumeHeader.tsx | 4 ++-- .../VesselLogbook/LogbookSummary/utils.ts | 2 +- frontend/src/features/MainWindow/index.tsx | 2 +- .../components/MeasurementMapButton/index.tsx | 4 ++-- frontend/src/features/Mission/features.ts | 4 ++-- .../SelectedMissionActionsLayer/index.tsx | 6 ++--- .../IdentificationDisplayed.tsx | 10 ++++----- .../SpeciesRegulationDisplayed.tsx | 8 +++---- .../PendingAlertRow.tsx | 4 ++-- .../SilencedAlerts/fields/VesselField.tsx | 22 +++++++++---------- .../SideWindow/Alert/SilencedAlerts/index.tsx | 8 +++---- .../SideWindow/Alert/SilencedAlerts/utils.ts | 8 +++---- .../VesselStatusSelect.tsx | 6 ++--- .../resume/BeaconMalfunctionCard.tsx | 2 +- .../features/VesselSidebar/Identity/index.tsx | 4 ++-- .../actions/TrackRequest/DateRange.tsx | 2 +- .../actions/TrackRequest/index.tsx | 2 +- .../actions/VesselSidebarActionButton.tsx | 8 +++---- .../risk_factor/RiskFactorBox.tsx | 2 +- .../commonStyles/Backoffice.style.tsx | 2 +- .../src/features/map/layers/styles/utils.ts | 2 +- frontend/src/hooks/useTable/TableHead.tsx | 6 ++--- frontend/src/hooks/useTable/TableHeadNext.tsx | 2 +- frontend/src/hooks/useTable/index.tsx | 8 +++---- frontend/src/utils.ts | 2 +- .../src/workers/hooks/useGetServiceWorker.tsx | 2 +- 39 files changed, 104 insertions(+), 104 deletions(-) diff --git a/frontend/cypress/e2e/sidebars/custom_zones.spec.ts b/frontend/cypress/e2e/sidebars/custom_zones.spec.ts index 5ccb4d710c..c2e2e6dfcd 100644 --- a/frontend/cypress/e2e/sidebars/custom_zones.spec.ts +++ b/frontend/cypress/e2e/sidebars/custom_zones.spec.ts @@ -26,7 +26,7 @@ context('Sidebars > Custom Zones', () => { cy.get('*[data-cy="custom-zone-display-button"]') .click() .then(() => { - const customZonesItem = JSON.parse(localStorage.getItem(CUSTOM_ZONES_LOCALSTORAGE_KEY) || '') + const customZonesItem = JSON.parse(localStorage.getItem(CUSTOM_ZONES_LOCALSTORAGE_KEY) ?? '') const zones = JSON.parse(customZonesItem.zones) expect(zones['b2f8aea3-7814-4247-98fa-ddc58c922d09'].isShown).equal(false) }) diff --git a/frontend/cypress/e2e/sidebars/regulatory_layers.spec.ts b/frontend/cypress/e2e/sidebars/regulatory_layers.spec.ts index c2594cbc9c..f0e3c94b4b 100644 --- a/frontend/cypress/e2e/sidebars/regulatory_layers.spec.ts +++ b/frontend/cypress/e2e/sidebars/regulatory_layers.spec.ts @@ -373,7 +373,7 @@ context('Sidebars > Regulatory Layers', () => { cy.cleanScreenshots(1) cy.getAllLocalStorage().then(localStorage => { - expect(localStorage.homepagelayersShowedOnMap || '').to.be.empty + expect(localStorage.homepagelayersShowedOnMap ?? '').to.be.empty }) // When @@ -383,7 +383,7 @@ context('Sidebars > Regulatory Layers', () => { .eq(0) .click({ force: true, timeout: 10000 }) .then(() => { - const showedLayers = JSON.parse(localStorage.getItem('homepagelayersShowedOnMap') || '') + const showedLayers = JSON.parse(localStorage.getItem('homepagelayersShowedOnMap') ?? '') expect(showedLayers).length(1) expect(showedLayers[0].type).equal('eez_areas') }) @@ -409,7 +409,7 @@ context('Sidebars > Regulatory Layers', () => { cy.get('*[data-cy="administrative-zones-open"]') .click({ force: true, timeout: 10000 }) .then(() => { - const showedLayers = JSON.parse(localStorage.getItem('homepagelayersShowedOnMap') || '') + const showedLayers = JSON.parse(localStorage.getItem('homepagelayersShowedOnMap') ?? '') expect(showedLayers).length(1) expect(showedLayers[0].type).equal('eez_areas') }) diff --git a/frontend/src/api/alert.ts b/frontend/src/api/alert.ts index 1b8acf892e..8b4ccde27a 100644 --- a/frontend/src/api/alert.ts +++ b/frontend/src/api/alert.ts @@ -84,8 +84,8 @@ async function silenceAlertFromAPI( silencedAlertPeriodRequest: SilencedAlertPeriodRequest ): Promise { // TODO Normalize this data before calling the api service rather than here. - const silencedAlertPeriod = silencedAlertPeriodRequest.silencedAlertPeriod || '' - const beforeDateTime = silencedAlertPeriodRequest.beforeDateTime?.toISOString() || '' + const silencedAlertPeriod = silencedAlertPeriodRequest.silencedAlertPeriod ?? '' + const beforeDateTime = silencedAlertPeriodRequest.beforeDateTime?.toISOString() ?? '' try { return await monitorfishApiKy diff --git a/frontend/src/domain/entities/beaconMalfunction/index.ts b/frontend/src/domain/entities/beaconMalfunction/index.ts index 006c0c2377..a58025bcfd 100644 --- a/frontend/src/domain/entities/beaconMalfunction/index.ts +++ b/frontend/src/domain/entities/beaconMalfunction/index.ts @@ -26,7 +26,7 @@ function getYearsToBeaconMalfunctions( if (beaconMalfunction.beaconMalfunction?.malfunctionStartDateTime) { const year = new Date(beaconMalfunction.beaconMalfunction?.malfunctionStartDateTime).getUTCFullYear() - nextYearsToBeaconMalfunctions[year] = nextYearsToBeaconMalfunctions[year]?.concat(beaconMalfunction) || [ + nextYearsToBeaconMalfunctions[year] = nextYearsToBeaconMalfunctions[year]?.concat(beaconMalfunction) ?? [ beaconMalfunction ] } @@ -118,12 +118,12 @@ const getMalfunctionStartDateText = (beaconMalfunction: BeaconMalfunction) => { switch (beaconMalfunction.endOfBeaconMalfunctionReason) { case END_OF_MALFUNCTION_REASON_RECORD.RESUMED_TRANSMISSION.value: return `Reprise des émissions ${ - (beaconMalfunction.malfunctionEndDateTime && getReducedTimeAgo(beaconMalfunction.malfunctionEndDateTime)) || + (beaconMalfunction.malfunctionEndDateTime && getReducedTimeAgo(beaconMalfunction.malfunctionEndDateTime)) ?? '' }`.trim() case END_OF_MALFUNCTION_REASON_RECORD.BEACON_DEACTIVATED_OR_UNEQUIPPED.value: return `Balise désactivée ${ - (beaconMalfunction.malfunctionEndDateTime && getReducedTimeAgo(beaconMalfunction.malfunctionEndDateTime)) || + (beaconMalfunction.malfunctionEndDateTime && getReducedTimeAgo(beaconMalfunction.malfunctionEndDateTime)) ?? '' }`.trim() default: diff --git a/frontend/src/domain/entities/controlUnits/__tests__/utils.test.ts b/frontend/src/domain/entities/controlUnits/__tests__/utils.test.ts index ac837c7ed3..fa926183d5 100644 --- a/frontend/src/domain/entities/controlUnits/__tests__/utils.test.ts +++ b/frontend/src/domain/entities/controlUnits/__tests__/utils.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from '@jest/globals' -import { dummyControlUnits } from './__mock__/controlUnits' import { getControlUnitsOptionsFromControlUnits } from '../utils' +import { dummyControlUnits } from './__mock__/controlUnits' describe('controlUnits/utils', () => { it('getControlUnitsOptionsFromControlUnits Should return active control units', async () => { diff --git a/frontend/src/domain/entities/controls.ts b/frontend/src/domain/entities/controls.ts index e7241e6e72..e8b1d18ccd 100644 --- a/frontend/src/domain/entities/controls.ts +++ b/frontend/src/domain/entities/controls.ts @@ -81,10 +81,10 @@ export const getNumberOfInfractions = ( } return ( - (control.gearInfractions?.length || 0) + - (control.logbookInfractions?.length || 0) + - (control.speciesInfractions?.length || 0) + - (control.otherInfractions?.length || 0) + (control.gearInfractions?.length ?? 0) + + (control.logbookInfractions?.length ?? 0) + + (control.speciesInfractions?.length ?? 0) + + (control.otherInfractions?.length ?? 0) ) } @@ -101,10 +101,10 @@ export const getNumberOfInfractionsWithRecord = ( const infractionWithRecordFilter = infraction => infraction.infractionType === InfractionType.WITH_RECORD return ( - (control.gearInfractions?.filter(infractionWithRecordFilter).length || 0) + - (control.logbookInfractions?.filter(infractionWithRecordFilter).length || 0) + - (control.speciesInfractions?.filter(infractionWithRecordFilter).length || 0) + - (control.otherInfractions?.filter(infractionWithRecordFilter).length || 0) + (control.gearInfractions?.filter(infractionWithRecordFilter).length ?? 0) + + (control.logbookInfractions?.filter(infractionWithRecordFilter).length ?? 0) + + (control.speciesInfractions?.filter(infractionWithRecordFilter).length ?? 0) + + (control.otherInfractions?.filter(infractionWithRecordFilter).length ?? 0) ) } diff --git a/frontend/src/features/ActivityReport/components/ExportActivityReportsDialog/csvMap.ts b/frontend/src/features/ActivityReport/components/ExportActivityReportsDialog/csvMap.ts index 25750dc6db..fb1f7fc93a 100644 --- a/frontend/src/features/ActivityReport/components/ExportActivityReportsDialog/csvMap.ts +++ b/frontend/src/features/ActivityReport/components/ExportActivityReportsDialog/csvMap.ts @@ -71,7 +71,7 @@ export const JDP_CSV_MAP_BASE: DownloadAsCsvMap = { }, objectState: { label: 'OBJECT_STATE', - transform: activity => toAlpha3(activity.vessel.flagState) || 'UNK' + transform: activity => toAlpha3(activity.vessel.flagState) ?? 'UNK' }, vesselNationalIdentifier: 'OBJECT_NATIONAL_ID', 'vessel.ircs': 'RC', @@ -80,12 +80,12 @@ export const JDP_CSV_MAP_BASE: DownloadAsCsvMap = { activityCode: 'ACTIVITY_CODE', gearCode: { label: 'GEAR_CODE', - transform: activity => activity.action.gearOnboard[0]?.gearCode || '' + transform: activity => activity.action.gearOnboard[0]?.gearCode ?? '' }, meshSize: { label: 'MESH_SIZE', transform: activity => - activity.action.gearOnboard[0]?.controlledMesh ?? (activity.action.gearOnboard[0]?.declaredMesh || '') + activity.action.gearOnboard[0]?.controlledMesh ?? activity.action.gearOnboard[0]?.declaredMesh ?? '' }, faoArea: { label: 'FAO_AREA_CODE', diff --git a/frontend/src/features/BackOffice/edit_regulation/regulatory_text/RegulatoryText.tsx b/frontend/src/features/BackOffice/edit_regulation/regulatory_text/RegulatoryText.tsx index 50c4a12c7f..9cc5fed458 100644 --- a/frontend/src/features/BackOffice/edit_regulation/regulatory_text/RegulatoryText.tsx +++ b/frontend/src/features/BackOffice/edit_regulation/regulatory_text/RegulatoryText.tsx @@ -173,7 +173,7 @@ export function RegulatoryText({  ou { set('endDate', isChecked ? INFINITE : '') diff --git a/frontend/src/features/FleetSegment/components/FleetSegmentsBackoffice/index.tsx b/frontend/src/features/FleetSegment/components/FleetSegmentsBackoffice/index.tsx index a17e2d06d8..18571c69d1 100644 --- a/frontend/src/features/FleetSegment/components/FleetSegmentsBackoffice/index.tsx +++ b/frontend/src/features/FleetSegment/components/FleetSegmentsBackoffice/index.tsx @@ -45,7 +45,7 @@ export function FleetSegmentsBackoffice() { async (_year?: number) => { const { data: nextFleetSegments } = await dispatch(fleetSegmentApi.endpoints.getFleetSegments.initiate(_year)) - setFleetSegments(nextFleetSegments || []) + setFleetSegments(nextFleetSegments ?? []) if (_year) { setYear(_year) } @@ -95,7 +95,7 @@ export function FleetSegmentsBackoffice() { async newFleetSegmentData => { const nextFleetSegments = await dispatch(createFleetSegment(newFleetSegmentData, fleetSegments)) - setFleetSegments(nextFleetSegments || []) + setFleetSegments(nextFleetSegments ?? []) closeCreateOrEditFleetSegmentModal() }, [dispatch, fleetSegments, closeCreateOrEditFleetSegmentModal] @@ -145,11 +145,11 @@ export function FleetSegmentsBackoffice() {