Skip to content

Commit

Permalink
Fix lint errors following dev-deps upgrade in Frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
ivangabriele committed Sep 4, 2024
1 parent b633382 commit 92ac697
Show file tree
Hide file tree
Showing 39 changed files with 104 additions and 104 deletions.
2 changes: 1 addition & 1 deletion frontend/cypress/e2e/sidebars/custom_zones.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down
6 changes: 3 additions & 3 deletions frontend/cypress/e2e/sidebars/regulatory_layers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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')
})
Expand All @@ -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')
})
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/api/alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ async function silenceAlertFromAPI(
silencedAlertPeriodRequest: SilencedAlertPeriodRequest
): Promise<LEGACY_SilencedAlert> {
// 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
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/domain/entities/beaconMalfunction/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
}
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -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 () => {
Expand Down
16 changes: 8 additions & 8 deletions frontend/src/domain/entities/controls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
}

Expand All @@ -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)
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const JDP_CSV_MAP_BASE: DownloadAsCsvMap<ActivityReportWithId> = {
},
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',
Expand All @@ -80,12 +80,12 @@ export const JDP_CSV_MAP_BASE: DownloadAsCsvMap<ActivityReportWithId> = {
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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export function RegulatoryText({
<Or>&nbsp;ou</Or>
<StyledCheckbox
checked={endDate === INFINITE}
label={"jusqu'à nouvel ordre"}
label="jusqu'à nouvel ordre"
name="endDate"
onChange={isChecked => {
set('endDate', isChecked ? INFINITE : '')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -95,7 +95,7 @@ export function FleetSegmentsBackoffice() {
async newFleetSegmentData => {
const nextFleetSegments = await dispatch(createFleetSegment(newFleetSegmentData, fleetSegments))

setFleetSegments(nextFleetSegments || [])
setFleetSegments(nextFleetSegments ?? [])
closeCreateOrEditFleetSegmentModal()
},
[dispatch, fleetSegments, closeCreateOrEditFleetSegmentModal]
Expand Down Expand Up @@ -145,11 +145,11 @@ export function FleetSegmentsBackoffice() {
<Select
cleanable={false}
isLabelHidden
label={"l'année"}
label="l'année"
name="fleet-segments-add-year"
onChange={_year => addYearEntry(Number(_year))}
options={yearsToAdd}
placeholder={"l'année"}
placeholder="l'année"
value={undefined}
/>
</AddYearBox>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ export const computeFleetSegments =

const { data: fleetSegments } = await dispatch(
fleetSegmentApi.endpoints.computeFleetSegments.initiate({
faoAreas: faoAreas || [],
gears: gears || [],
species: species || []
faoAreas: faoAreas ?? [],
gears: gears ?? [],
species: species ?? []
})
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export function EditInterestPoint({ close, isOpen }: EditInterestPointProps) {
coordinatesFormat={coordinatesFormat}
defaultValue={coordinates}
isLabelHidden
label={"Coordonnées du point d'intérêt"}
label="Coordonnées du point d'intérêt"
name="interest-point-coordinates"
onChange={updateCoordinates}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function InterestPointMapButton() {
isActive={isOpen}
onClick={openOrCloseInterestPoint}
style={{ top: 364 }}
title={"Créer un point d'intérêt"}
title="Créer un point d'intérêt"
>
<InterestPointIcon $isRightMenuShrinked={isRightMenuShrinked} />
</InterestPointButton>
Expand Down
14 changes: 7 additions & 7 deletions frontend/src/features/Logbook/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import { expect } from '@jest/globals'

import {
correctedLANMessage,
correctedPNOMessage,
dummyCpsMessage,
dummyLogbookMessages,
dummyLanMessageWithLVRCPresentationSpecies
} from './__mocks__/logbookMessages'
import {
buildCatchArray,
getCPSDistinctSpecies,
Expand All @@ -21,6 +14,13 @@ import {
getTotalLANWeight,
getTotalPNOWeight
} from '../utils'
import {
correctedLANMessage,
correctedPNOMessage,
dummyCpsMessage,
dummyLogbookMessages,
dummyLanMessageWithLVRCPresentationSpecies
} from './__mocks__/logbookMessages'

describe('Logbook/utils.tsx', () => {
it('getPNOMessage Should get the first valid PNO message', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ export function LogbookMessageResumeHeader({
<LogbookMessageName
hasNoMessage={hasNoMessage || noContent}
isNotAcknowledged={isNotAcknowledged}
title={rejectionCause || (isDeleted ? 'Message supprimé' : '')}
title={rejectionCause ?? (isDeleted ? 'Message supprimé' : '')}
>
{(isNotAcknowledged || isDeleted) && (
<NotAcknowledgedOrDeleted data-cy="fishing-resume-not-acknowledged-icon" />
)}
{LogbookMessageTypeEnum[messageType].name}
</LogbookMessageName>
<LogbookMessageResumeText data-cy="vessel-fishing-resume-title" title={onHoverText || ''}>
<LogbookMessageResumeText data-cy="vessel-fishing-resume-title" title={onHoverText ?? ''}>
{hasNoMessage ? (
<Gray>Aucun message</Gray>
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function getTripSegments(
}

export function getSegmentInfo(segment: Partial<FleetSegment>): string {
if (segment.gears || segment.faoAreas || segment.targetSpecies || segment.bycatchSpecies) {
if (segment.gears ?? segment.faoAreas ?? segment.targetSpecies ?? segment.bycatchSpecies) {
const gears = segment.gears?.length ? segment.gears.join(', ') : 'aucun'
const faoAreas = segment.faoAreas?.length ? segment.faoAreas.join(', ') : 'aucune'

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/features/MainWindow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import styled from 'styled-components'
import { LegacyRsuiteComponentsWrapper } from 'ui/LegacyRsuiteComponentsWrapper'

import { MapButtons } from './components/MapButtons'
import { RightMenuOnHoverArea } from './components/MapButtons/shared/RightMenuOnHoverArea'
import { APIWorker } from '../../api/APIWorker'
import { Notifier } from '../../components/Notifier'
import { RightMenuOnHoverArea } from './components/MapButtons/shared/RightMenuOnHoverArea'
import { SideWindowStatus } from '../../domain/entities/sideWindow/constants'
import { useMainAppSelector } from '../../hooks/useMainAppSelector'
import { ErrorToastNotification } from '../commonComponents/ErrorToastNotification'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ export function MeasurementMapButton() {
className=".map-menu"
data-cy="measurement-multiline"
onClick={() => makeMeasurement(MeasurementType.MULTILINE)}
title={"Mesure d'une distance avec lignes brisées"}
title="Mesure d'une distance avec lignes brisées"
>
<MultiLineIcon />
</MeasurementItem>
<MeasurementItem
className=".map-menu"
data-cy="measurement-circle-range"
onClick={() => makeMeasurement(MeasurementType.CIRCLE_RANGE)}
title={"Rayon d'action"}
title="Rayon d'action"
>
<CircleRangeIcon />
</MeasurementItem>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/features/Mission/features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export const getMissionActionFeature = (
const infractions = getMissionActionInfractionsFromMissionActionFormValues(action)
const infractionsNatinfs = infractions.map(({ natinf }) => natinf)

const actionId = action.id || random(1000)
const actionId = action.id ?? random(1000)
const feature = new Feature({
actionType: action.actionType,
dateTime: getDateTime(action.actionDatetimeUtc, true),
Expand Down Expand Up @@ -159,7 +159,7 @@ export const getMissionActionFeatureZone = (
return undefined
}

const actionId = action.id || random(1000)
const actionId = action.id ?? random(1000)
const feature = new Feature({
geometry: circular([action.longitude, action.latitude], CONTROL_ZONE_RADIUS, 64).transform(
WSG84_PROJECTION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function UnmemoizedSelectedMissionActionsLayer() {
missionsAndAction.id === (selectedMissionGeoJSON as GeoJSON.Feature).properties?.missionId
)
?.actions?.map(action => getMissionActionFeature(action))
.filter((feature): feature is Feature => Boolean(feature)) || []
.filter((feature): feature is Feature => Boolean(feature)) ?? []
)
}, [selectedMissionGeoJSON, missions])

Expand All @@ -55,7 +55,7 @@ export function UnmemoizedSelectedMissionActionsLayer() {
missionsAndAction.id === (selectedMissionGeoJSON as GeoJSON.Feature).properties?.missionId
)
?.actions?.map(action => getMissionActionFeatureZone(action))
.filter((feature): feature is Feature => Boolean(feature)) || []
.filter((feature): feature is Feature => Boolean(feature)) ?? []
)
}, [selectedMissionGeoJSON, missions])

Expand Down Expand Up @@ -111,7 +111,7 @@ export function UnmemoizedSelectedMissionActionsLayer() {
}

const actionFeatures = draft.actionsFormValues
.map(action => getMissionActionFeature({ ...action, missionId: missionId || NEW_MISSION_ID }))
.map(action => getMissionActionFeature({ ...action, missionId: missionId ?? NEW_MISSION_ID }))
.filter((action): action is Feature => !!action)

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@ import { Key, Value, Fields, Field } from '../RegulatoryMetadata.style'
export function IdentificationDisplayed() {
const regulatory = useMainAppSelector(state => state.regulatory)

const { lawType, region, topic, zone } = regulatory.regulatoryZoneMetadata || {}
const { lawType, region, topic, zone } = regulatory.regulatoryZoneMetadata ?? {}

return (
<Zone>
<Fields>
<Body>
<Field>
<Key>Ensemble reg.</Key>
<Value data-cy="regulatory-layers-metadata-lawtype">{lawType || <NoValue>-</NoValue>}</Value>
<Value data-cy="regulatory-layers-metadata-lawtype">{lawType ?? <NoValue>-</NoValue>}</Value>
</Field>
<Field>
<Key>Thématique</Key>
<Value data-cy="regulatory-layers-metadata-topic">{`${topic}` || <NoValue>-</NoValue>}</Value>
<Value data-cy="regulatory-layers-metadata-topic">{`${topic}` ?? <NoValue>-</NoValue>}</Value>
</Field>
<Field>
<Key>Zone</Key>
<Value data-cy="regulatory-layers-metadata-zone">{`${zone}` || <NoValue>-</NoValue>}</Value>
<Value data-cy="regulatory-layers-metadata-zone">{`${zone}` ?? <NoValue>-</NoValue>}</Value>
</Field>
<Field>
<Key>Région</Key>
<Value data-cy="regulatory-layers-metadata-region">{region || <NoValue>-</NoValue>}</Value>
<Value data-cy="regulatory-layers-metadata-region">{region ?? <NoValue>-</NoValue>}</Value>
</Field>
</Body>
</Fields>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import type { RegulatedSpecies as RegulatedSpeciesType } from '../../../types'
export function SpeciesRegulationDisplayed() {
const regulatory = useMainAppSelector(state => state.regulatory)

const { speciesRegulation } = regulatory.regulatoryZoneMetadata || {}
const { authorized, otherInfo, unauthorized } = speciesRegulation || {}
const { speciesRegulation } = regulatory.regulatoryZoneMetadata ?? {}
const { authorized, otherInfo, unauthorized } = speciesRegulation ?? {}
const hasAuthorizedContent = !isRegulatedSpeciesEmpty(authorized)
const hasUnauthorizedContent = !isRegulatedSpeciesEmpty(unauthorized)
const areSpeciesRegulationEmpty = !hasAuthorizedContent && !hasUnauthorizedContent && !otherInfo
Expand All @@ -25,13 +25,13 @@ export function SpeciesRegulationDisplayed() {
<>
<Section>
{hasAuthorizedContent && (
<RegulatedSpecies authorized regulatedSpecies={authorized || DEFAULT_AUTHORIZED_REGULATED_SPECIES} />
<RegulatedSpecies authorized regulatedSpecies={authorized ?? DEFAULT_AUTHORIZED_REGULATED_SPECIES} />
)}
{hasUnauthorizedContent && (
<RegulatedSpecies
authorized={false}
hasPreviousRegulatedSpeciesBloc={hasAuthorizedContent}
regulatedSpecies={unauthorized || DEFAULT_UNAUTHORIZED_REGULATED_SPECIES}
regulatedSpecies={unauthorized ?? DEFAULT_UNAUTHORIZED_REGULATED_SPECIES}
/>
)}
{otherInfo && (
Expand Down
Loading

0 comments on commit 92ac697

Please sign in to comment.