From 62ab0da97357cbcf71be53bb3330f2a424a1eaa8 Mon Sep 17 00:00:00 2001 From: Bastien DUMONT <bdumont@grandlyon.com> Date: Wed, 25 Sep 2024 15:02:42 +0000 Subject: [PATCH] chore:(lint): remove unnecessary async --- .eslintrc.js | 4 ++ .../Action/ActionDone/ActionDone.spec.tsx | 2 +- .../Action/ActionModal/ActionModal.spec.tsx | 2 +- src/components/Action/ActionView.spec.tsx | 8 ++-- .../ProfileComparatorRow.spec.tsx | 14 +++--- .../ChallengeCardDone.spec.tsx | 8 ++-- .../ChallengeCardDone/ChallengeCardDone.tsx | 2 +- .../ChallengeCardLast.spec.tsx | 2 +- .../ChallengeCardOnGoing.tsx | 4 +- .../ChallengeCardUnlocked.spec.tsx | 2 +- .../GRDFConnect/GrdfWaitConsent.tsx | 2 +- .../SGEConnect/SgeConnectView.spec.tsx | 6 +-- .../ConsumptionDetails.spec.tsx | 2 +- .../FluidButtons/FluidButton.spec.tsx | 2 +- .../Consumption/FluidButtons/FluidButton.tsx | 2 +- .../FluidButtons/FluidButtons.spec.tsx | 2 +- .../DataloadConsumptionVisualizer.spec.tsx | 10 ++-- .../EstimatedConsumptionModal.spec.tsx | 2 +- .../NoDataModal.spec.tsx | 2 +- .../DateNavigator/DateNavigator.spec.tsx | 4 +- .../Duel/DuelOngoing/DuelOngoing.spec.tsx | 2 +- .../DuelResultModal/DuelResultModal.spec.tsx | 2 +- .../EcogestureList/EcogestureList.spec.tsx | 2 +- .../EcogestureNotFound.spec.tsx | 2 +- .../EcogestureResetModal.spec.tsx | 2 +- .../EcogestureFormEquipment.spec.tsx | 4 +- .../EcogestureFormSingleChoice.spec.tsx | 4 +- .../EcogestureFormView.spec.tsx | 8 ++-- src/components/FluidChart/FluidChart.tsx | 2 +- .../TimeStepSelector.spec.tsx | 2 +- src/components/Hooks/useExploration.tsx | 2 +- .../ConnectionResult/ConnectionResult.tsx | 2 +- .../Konnector/KonnectorModal.spec.tsx | 6 +-- .../Konnector/KonnectorViewerList.spec.tsx | 2 +- .../ReportOptions/ReportOptions.spec.tsx | 2 +- .../ProfileTypeFinished.spec.tsx | 2 +- .../ProfileTypeFormNumberSelection.spec.tsx | 2 +- .../Quiz/QuizQuestion/QuizQuestion.spec.tsx | 2 +- src/components/Splash/SplashRoot.spec.tsx | 2 +- src/components/Splash/SplashRoot.tsx | 12 ++--- src/components/WelcomeModal/WelcomeModal.tsx | 2 +- src/migrations/migration.data.ts | 48 +++++++++---------- src/migrations/migration.service.spec.ts | 12 ++--- src/migrations/migration.spec.ts | 8 ++-- src/migrations/migration.ts | 5 +- src/migrations/migration.type.ts | 2 +- src/services/account.service.ts | 5 +- src/services/challenge.service.ts | 9 ++-- .../consumptionFormatter.service.spec.ts | 2 +- src/services/dateChart.service.spec.ts | 4 +- src/services/ecogesture.service.spec.ts | 14 +++--- src/services/environement.service.spec.ts | 6 +-- src/services/exploration.service.spec.ts | 2 +- src/services/mail.service.ts | 2 +- src/services/timePeriod.service.spec.ts | 8 ++-- src/services/timePeriod.service.ts | 2 +- 56 files changed, 142 insertions(+), 135 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 8a4f5246f..e4f98e3f8 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -51,6 +51,10 @@ module.exports = { // a11y label fix, nesting is enough 'jsx-a11y/label-has-associated-control': 0, + + // Note: you must disable the base rule as it can report incorrect errors + 'require-await': 'off', + '@typescript-eslint/require-await': 'error', }, }, { diff --git a/src/components/Action/ActionDone/ActionDone.spec.tsx b/src/components/Action/ActionDone/ActionDone.spec.tsx index 038a6dd20..f377200ae 100644 --- a/src/components/Action/ActionDone/ActionDone.spec.tsx +++ b/src/components/Action/ActionDone/ActionDone.spec.tsx @@ -16,7 +16,7 @@ jest.mock('services/challenge.service', () => { describe('ActionDone component', () => { const store = createMockEcolyoStore() - it('should be rendered correctly', async () => { + it('should be rendered correctly', () => { const { container } = render( <Provider store={store}> <ActionDone currentChallenge={userChallengeData[1]} /> diff --git a/src/components/Action/ActionModal/ActionModal.spec.tsx b/src/components/Action/ActionModal/ActionModal.spec.tsx index 2e8f36c8d..37e94eda6 100644 --- a/src/components/Action/ActionModal/ActionModal.spec.tsx +++ b/src/components/Action/ActionModal/ActionModal.spec.tsx @@ -17,7 +17,7 @@ jest.mock('services/challenge.service', () => { describe('ActionModal component', () => { const store = createMockEcolyoStore() - it('should render correctly', async () => { + it('should render correctly', () => { const { baseElement } = render( <Provider store={store}> <ActionModal diff --git a/src/components/Action/ActionView.spec.tsx b/src/components/Action/ActionView.spec.tsx index 25bd7eef0..a6d116988 100644 --- a/src/components/Action/ActionView.spec.tsx +++ b/src/components/Action/ActionView.spec.tsx @@ -26,7 +26,7 @@ jest.mock( ) describe('ActionView component', () => { - it('should render match snapshot with "Unstarted" state', async () => { + it('should render match snapshot with "Unstarted" state', () => { const store = createMockEcolyoStore({ challenge: { ...mockChallengeState, @@ -46,7 +46,7 @@ describe('ActionView component', () => { ) expect(container).toMatchSnapshot() }) - it('should render match snapshot with "onGoing" state', async () => { + it('should render match snapshot with "onGoing" state', () => { const store = createMockEcolyoStore({ challenge: { ...mockChallengeState, @@ -66,7 +66,7 @@ describe('ActionView component', () => { ) expect(container).toMatchSnapshot() }) - it('should render match snapshot with "Notification" state', async () => { + it('should render match snapshot with "Notification" state', () => { const store = createMockEcolyoStore({ challenge: { ...mockChallengeState, @@ -86,7 +86,7 @@ describe('ActionView component', () => { ) expect(container).toMatchSnapshot() }) - it('should render match snapshot with default case', async () => { + it('should render match snapshot with default case', () => { const store = createMockEcolyoStore({ challenge: { ...mockChallengeState, diff --git a/src/components/Analysis/ProfileComparator/ProfileComparatorRow.spec.tsx b/src/components/Analysis/ProfileComparator/ProfileComparatorRow.spec.tsx index 62845a52f..18ccf5ee6 100644 --- a/src/components/Analysis/ProfileComparator/ProfileComparatorRow.spec.tsx +++ b/src/components/Analysis/ProfileComparator/ProfileComparatorRow.spec.tsx @@ -11,7 +11,7 @@ describe('AnalysisConsumptionRow component', () => { const performanceValue = 25 describe('Multifluid row', () => { - it('should be rendered correctly for Multifluid and at least fluid connected', async () => { + it('should be rendered correctly for Multifluid and at least fluid connected', () => { const { container } = render( <ProfileComparatorRow fluidType={FluidType.MULTIFLUID} @@ -34,7 +34,7 @@ describe('AnalysisConsumptionRow component', () => { ).toBeFalsy() }) - it('should be rendered correctly for Multifluid and at none fluid connected', async () => { + it('should be rendered correctly for Multifluid and at none fluid connected', () => { const mockConnected = false const { container } = render( <ProfileComparatorRow @@ -62,7 +62,7 @@ describe('AnalysisConsumptionRow component', () => { }) describe('Single fluid row', () => { - it('should be rendered correctly for singleFluid connected for average', async () => { + it('should be rendered correctly for singleFluid connected for average', () => { const { container } = render( <ProfileComparatorRow fluidType={FluidType.ELECTRICITY} @@ -90,7 +90,7 @@ describe('AnalysisConsumptionRow component', () => { ).toBeFalsy() }) - it('should be rendered correctly for singleFluid not connected', async () => { + it('should be rendered correctly for singleFluid not connected', () => { const mockConnected = false const { container } = render( <ProfileComparatorRow @@ -119,8 +119,8 @@ describe('AnalysisConsumptionRow component', () => { ).toBeTruthy() }) - it('should be rendered correctly for singleFluid with none performance value', async () => { - const mockPerformanceValue: number | null = null + it('should be rendered correctly for singleFluid with none performance value', () => { + const mockPerformanceValue = null const { container } = render( <ProfileComparatorRow fluidType={FluidType.ELECTRICITY} @@ -146,7 +146,7 @@ describe('AnalysisConsumptionRow component', () => { ).toBeFalsy() }) - it('should be rendered correctly with unit', async () => { + it('should be rendered correctly with unit', () => { const mockForecast: MonthlyForecast = { ...mockMonthlyForecastJanuaryTestProfile1, fluidForecast: [ diff --git a/src/components/Challenge/ChallengeCardDone/ChallengeCardDone.spec.tsx b/src/components/Challenge/ChallengeCardDone/ChallengeCardDone.spec.tsx index ec7e95110..f174bacde 100644 --- a/src/components/Challenge/ChallengeCardDone/ChallengeCardDone.spec.tsx +++ b/src/components/Challenge/ChallengeCardDone/ChallengeCardDone.spec.tsx @@ -24,7 +24,7 @@ describe('ChallengeCardDone component', () => { challenge: { currentChallenge: null }, }, }) - it('should be rendered correctly', async () => { + it('should be rendered correctly', () => { const { container } = render( <Provider store={storeNoCurrentChallenge}> <ChallengeCardDone userChallenge={userChallengeData[0]} /> @@ -53,7 +53,7 @@ describe('ChallengeCardDone component', () => { }) expect(mockUpdateUserChallenge).toHaveBeenCalledTimes(1) }) - it('should not reset challenge if another challenge is on going', async () => { + it('should not reset challenge if another challenge is on going', () => { mockAppDispatch.mockImplementationOnce(() => mockDispatch) const store = mockStore({ ecolyo: { @@ -72,7 +72,7 @@ describe('ChallengeCardDone component', () => { expect(mockDispatch).toHaveBeenCalledTimes(0) expect(mockUpdateUserChallenge).toHaveBeenCalledTimes(0) }) - it('should be primary button is challenge is lost', async () => { + it('should be primary button is challenge is lost', () => { render( <Provider store={storeNoCurrentChallenge}> <ChallengeCardDone userChallenge={userChallengeData[1]} /> @@ -83,7 +83,7 @@ describe('ChallengeCardDone component', () => { }) expect(resetBtn).toHaveClass('btnPrimaryNegative') }) - it('should be secondary button is challenge is won', async () => { + it('should be secondary button is challenge is won', () => { render( <Provider store={storeNoCurrentChallenge}> <ChallengeCardDone userChallenge={userChallengeData[0]} /> diff --git a/src/components/Challenge/ChallengeCardDone/ChallengeCardDone.tsx b/src/components/Challenge/ChallengeCardDone/ChallengeCardDone.tsx index 95d25f0f6..6110f52d7 100644 --- a/src/components/Challenge/ChallengeCardDone/ChallengeCardDone.tsx +++ b/src/components/Challenge/ChallengeCardDone/ChallengeCardDone.tsx @@ -32,7 +32,7 @@ const ChallengeCardDone = ({ const isSuccess = userChallenge.success === UserChallengeSuccess.WIN - const goDuel = async () => { + const goDuel = () => { navigate('/challenges/duel?id=' + userChallenge.id) } diff --git a/src/components/Challenge/ChallengeCardLast/ChallengeCardLast.spec.tsx b/src/components/Challenge/ChallengeCardLast/ChallengeCardLast.spec.tsx index f4825300a..989c92034 100644 --- a/src/components/Challenge/ChallengeCardLast/ChallengeCardLast.spec.tsx +++ b/src/components/Challenge/ChallengeCardLast/ChallengeCardLast.spec.tsx @@ -7,7 +7,7 @@ import ChallengeCardLast from './ChallengeCardLast' declare let __SAU_IDEA_DIRECT_LINK__: string describe('ChallengeCardLast component', () => { - it('should be rendered correctly', async () => { + it('should be rendered correctly', () => { const { container } = render(<ChallengeCardLast />) expect(container).toMatchSnapshot() }) diff --git a/src/components/Challenge/ChallengeCardOnGoing/ChallengeCardOnGoing.tsx b/src/components/Challenge/ChallengeCardOnGoing/ChallengeCardOnGoing.tsx index 1c094a952..aea83c8f9 100644 --- a/src/components/Challenge/ChallengeCardOnGoing/ChallengeCardOnGoing.tsx +++ b/src/components/Challenge/ChallengeCardOnGoing/ChallengeCardOnGoing.tsx @@ -101,7 +101,7 @@ const ChallengeCardOnGoing = ({ useEffect(() => { let subscribed = true - async function importIcon() { + function importIcon() { importIconById(userChallenge.id, 'challenge').then(icon => { icon ? setChallengeIcon(icon) : setChallengeIcon(defaultChallengeIcon) }) @@ -114,7 +114,7 @@ const ChallengeCardOnGoing = ({ useEffect(() => { let subscribed = true - async function setChallengeResult() { + function setChallengeResult() { const isChallengeDone = challengeService.isChallengeDone( userChallenge, currentDataload diff --git a/src/components/Challenge/ChallengeCardUnlocked/ChallengeCardUnlocked.spec.tsx b/src/components/Challenge/ChallengeCardUnlocked/ChallengeCardUnlocked.spec.tsx index d02503c69..99ed04a63 100644 --- a/src/components/Challenge/ChallengeCardUnlocked/ChallengeCardUnlocked.spec.tsx +++ b/src/components/Challenge/ChallengeCardUnlocked/ChallengeCardUnlocked.spec.tsx @@ -73,7 +73,7 @@ describe('ChallengeCardUnlocked component', () => { expect(mockStartUserChallenge).toHaveBeenCalledWith(userChallengeData[0]) }) - it('should not be able to launch challenge if another one is active', async () => { + it('should not be able to launch challenge if another one is active', () => { mockStartUserChallenge.mockResolvedValue(userChallengeData[0]) const store = createMockEcolyoStore({ global: mockGlobalState, diff --git a/src/components/Connection/GRDFConnect/GrdfWaitConsent.tsx b/src/components/Connection/GRDFConnect/GrdfWaitConsent.tsx index 185dd4bdb..fd12330c0 100644 --- a/src/components/Connection/GRDFConnect/GrdfWaitConsent.tsx +++ b/src/components/Connection/GRDFConnect/GrdfWaitConsent.tsx @@ -17,7 +17,7 @@ export const GrdfWaitConsent = () => { const authData = currentFluidStatus.connection.account ?.auth as AccountGRDFData - const updateKonnector = async () => { + const updateKonnector = () => { const updatedConnection: FluidConnection = { ...currentFluidStatus.connection, shouldLaunchKonnector: true, diff --git a/src/components/Connection/SGEConnect/SgeConnectView.spec.tsx b/src/components/Connection/SGEConnect/SgeConnectView.spec.tsx index 8cb9c8bb0..3941573aa 100644 --- a/src/components/Connection/SGEConnect/SgeConnectView.spec.tsx +++ b/src/components/Connection/SGEConnect/SgeConnectView.spec.tsx @@ -33,7 +33,7 @@ describe('SgeConnectView component', () => { expect(container).toMatchSnapshot() }) - it('should be on stepIdentity by default with button disabled', async () => { + it('should be on stepIdentity by default with button disabled', () => { render( <Provider store={store}> <BrowserRouter> @@ -56,7 +56,7 @@ describe('SgeConnectView component', () => { }) describe('should test methods from useKonnectorAuth hook', () => { - it('should launch account and trigger creation process', async () => { + it('should launch account and trigger creation process', () => { const store = createMockEcolyoStore({ global: { ...mockGlobalState, @@ -74,7 +74,7 @@ describe('SgeConnectView component', () => { ) expect(mockConnect).toHaveBeenCalled() }) - it('should launch existing account update process', async () => { + it('should launch existing account update process', () => { const store = createMockEcolyoStore({ global: { ...mockGlobalState, diff --git a/src/components/Consumption/ConsumptionDetails/ConsumptionDetails.spec.tsx b/src/components/Consumption/ConsumptionDetails/ConsumptionDetails.spec.tsx index 78b2dc508..3ffa25603 100644 --- a/src/components/Consumption/ConsumptionDetails/ConsumptionDetails.spec.tsx +++ b/src/components/Consumption/ConsumptionDetails/ConsumptionDetails.spec.tsx @@ -8,7 +8,7 @@ import ConsumptionDetails from './ConsumptionDetails' describe('ConsumptionDetails component', () => { const store = createMockEcolyoStore() - it('should be rendered correctly', async () => { + it('should be rendered correctly', () => { const { container } = render( <Provider store={store}> <ConsumptionDetails fluidType={FluidType.ELECTRICITY} /> diff --git a/src/components/Consumption/FluidButtons/FluidButton.spec.tsx b/src/components/Consumption/FluidButtons/FluidButton.spec.tsx index 09d067519..d78072dfc 100644 --- a/src/components/Consumption/FluidButtons/FluidButton.spec.tsx +++ b/src/components/Consumption/FluidButtons/FluidButton.spec.tsx @@ -9,7 +9,7 @@ import FluidButton from './FluidButton' describe('FluidButton component', () => { const store = createMockEcolyoStore() - it('should be rendered correctly', async () => { + it('should be rendered correctly', () => { const { container } = render( <Provider store={store}> <FluidButton fluidType={FluidType.ELECTRICITY} isActive={false} /> diff --git a/src/components/Consumption/FluidButtons/FluidButton.tsx b/src/components/Consumption/FluidButtons/FluidButton.tsx index f6d849de2..f6aa3af5b 100644 --- a/src/components/Consumption/FluidButtons/FluidButton.tsx +++ b/src/components/Consumption/FluidButtons/FluidButton.tsx @@ -42,7 +42,7 @@ const FluidButton = ({ fluidType, isActive }: FluidButtonProps) => { const iconType = getNavPicto(fluidType, isActive, isConnected()) - const goToFluid = useCallback(async () => { + const goToFluid = useCallback(() => { navigate(isMulti ? '/consumption' : `/consumption/${fluidName}`) }, [navigate, isMulti, fluidName]) diff --git a/src/components/Consumption/FluidButtons/FluidButtons.spec.tsx b/src/components/Consumption/FluidButtons/FluidButtons.spec.tsx index 111456ecb..3a59ea931 100644 --- a/src/components/Consumption/FluidButtons/FluidButtons.spec.tsx +++ b/src/components/Consumption/FluidButtons/FluidButtons.spec.tsx @@ -8,7 +8,7 @@ import FluidButtons from './FluidButtons' describe('FluidButtons component', () => { const store = createMockEcolyoStore() - it('should be rendered correctly', async () => { + it('should be rendered correctly', () => { const { container } = render( <Provider store={store}> <FluidButtons activeFluid={FluidType.ELECTRICITY} /> diff --git a/src/components/ConsumptionVisualizer/DataloadConsumptionVisualizer.spec.tsx b/src/components/ConsumptionVisualizer/DataloadConsumptionVisualizer.spec.tsx index e0afcdfbd..72f8920ca 100644 --- a/src/components/ConsumptionVisualizer/DataloadConsumptionVisualizer.spec.tsx +++ b/src/components/ConsumptionVisualizer/DataloadConsumptionVisualizer.spec.tsx @@ -44,7 +44,7 @@ const dataLoadWithValueDetail: Dataload = { describe('Dataload consumption visualizer component', () => { const store = createMockEcolyoStore() - it('should render with single fluid', async () => { + it('should render with single fluid', () => { const { container } = render( <Provider store={store}> <DataloadConsumptionVisualizer @@ -120,7 +120,7 @@ describe('Dataload consumption visualizer component', () => { expect(links.length).toBe(3) }) - it('should render with no value to compare available', async () => { + it('should render with no value to compare available', () => { const store = createMockEcolyoStore({ chart: { ...mockChartState, showCompare: true }, }) @@ -138,7 +138,7 @@ describe('Dataload consumption visualizer component', () => { .item(0) expect(element).toBeInTheDocument() }) - it('should render with water comparison data', async () => { + it('should render with water comparison data', () => { const store = createMockEcolyoStore({ chart: { ...mockChartState, showCompare: true }, }) @@ -154,7 +154,7 @@ describe('Dataload consumption visualizer component', () => { const element = container.getElementsByClassName('water-compare').item(0) expect(element).toBeInTheDocument() }) - it('should render multifluid with no compare and display estimation modal', async () => { + it('should render multifluid with no compare and display estimation modal', () => { const { container } = render( <Provider store={store}> <DataloadConsumptionVisualizer @@ -169,7 +169,7 @@ describe('Dataload consumption visualizer component', () => { .item(0) expect(element).toBeInTheDocument() }) - it('should render multifluid with euro conversions', async () => { + it('should render multifluid with euro conversions', () => { jest.mock('services/converter.service', () => { return jest.fn(() => ({ LoadToEuro: jest.fn(), diff --git a/src/components/ConsumptionVisualizer/EstimatedConsumptionModal.spec.tsx b/src/components/ConsumptionVisualizer/EstimatedConsumptionModal.spec.tsx index a362aa740..f3eb6da60 100644 --- a/src/components/ConsumptionVisualizer/EstimatedConsumptionModal.spec.tsx +++ b/src/components/ConsumptionVisualizer/EstimatedConsumptionModal.spec.tsx @@ -10,7 +10,7 @@ jest.mock('services/fluidsPrices.service', () => { }) describe('EstimatedConsumptionModal component', () => { - it('should render correctly', async () => { + it('should render correctly', () => { const { baseElement } = render( <EstimatedConsumptionModal open={true} handleCloseClick={jest.fn()} /> ) diff --git a/src/components/ConsumptionVisualizer/NoDataModal.spec.tsx b/src/components/ConsumptionVisualizer/NoDataModal.spec.tsx index c9ff69e65..87dbacbb3 100644 --- a/src/components/ConsumptionVisualizer/NoDataModal.spec.tsx +++ b/src/components/ConsumptionVisualizer/NoDataModal.spec.tsx @@ -3,7 +3,7 @@ import React from 'react' import NoDataModal from './NoDataModal' describe('NoDataModal component', () => { - it('should render correctly', async () => { + it('should render correctly', () => { const { baseElement } = render( <NoDataModal open={true} handleCloseClick={jest.fn()} /> ) diff --git a/src/components/DateNavigator/DateNavigator.spec.tsx b/src/components/DateNavigator/DateNavigator.spec.tsx index d7f34079a..29f832963 100644 --- a/src/components/DateNavigator/DateNavigator.spec.tsx +++ b/src/components/DateNavigator/DateNavigator.spec.tsx @@ -12,7 +12,7 @@ const mockedDate = DateTime.local(2021, 7, 1) .startOf('day') describe('DateNavigator component', () => { - it('should be rendered correctly', async () => { + it('should be rendered correctly', () => { const { container } = render( <DateNavigator disableNext={false} @@ -53,7 +53,7 @@ describe('DateNavigator component', () => { expect(mockHandleNextDate).toHaveBeenCalledTimes(1) }) - it('should not be able to click nav buttons', async () => { + it('should not be able to click nav buttons', () => { render( <DateNavigator disableNext={true} diff --git a/src/components/Duel/DuelOngoing/DuelOngoing.spec.tsx b/src/components/Duel/DuelOngoing/DuelOngoing.spec.tsx index 5e9465597..781ef84c6 100644 --- a/src/components/Duel/DuelOngoing/DuelOngoing.spec.tsx +++ b/src/components/Duel/DuelOngoing/DuelOngoing.spec.tsx @@ -21,7 +21,7 @@ jest.mock('components/Duel/DuelChart/DuelChart', () => 'mock-duelchart') describe('DuelOngoing component', () => { const store = createMockEcolyoStore() - it('should be rendered correctly', async () => { + it('should be rendered correctly', () => { mockIsChallengeDone.mockReturnValue({ isDone: false, isWin: false, diff --git a/src/components/Duel/DuelResultModal/DuelResultModal.spec.tsx b/src/components/Duel/DuelResultModal/DuelResultModal.spec.tsx index 199878a12..c73a61c4c 100644 --- a/src/components/Duel/DuelResultModal/DuelResultModal.spec.tsx +++ b/src/components/Duel/DuelResultModal/DuelResultModal.spec.tsx @@ -15,7 +15,7 @@ describe('DuelResultModal component', () => { ) expect(baseElement).toMatchSnapshot() }) - it('should render a loss modal', async () => { + it('should render a loss modal', () => { render( <DuelResultModal open={true} diff --git a/src/components/Ecogesture/EcogestureList/EcogestureList.spec.tsx b/src/components/Ecogesture/EcogestureList/EcogestureList.spec.tsx index d512de1a4..1e7f223c9 100644 --- a/src/components/Ecogesture/EcogestureList/EcogestureList.spec.tsx +++ b/src/components/Ecogesture/EcogestureList/EcogestureList.spec.tsx @@ -29,7 +29,7 @@ describe('EcogesturesList component', () => { beforeAll(() => { mockAppDispatch.mockClear() }) - it('should be rendered correctly', async () => { + it('should be rendered correctly', () => { const { container } = render( <Provider store={store}> <BrowserRouter> diff --git a/src/components/Ecogesture/EcogestureNotFound/EcogestureNotFound.spec.tsx b/src/components/Ecogesture/EcogestureNotFound/EcogestureNotFound.spec.tsx index 2ca689938..7ae9d8338 100644 --- a/src/components/Ecogesture/EcogestureNotFound/EcogestureNotFound.spec.tsx +++ b/src/components/Ecogesture/EcogestureNotFound/EcogestureNotFound.spec.tsx @@ -14,7 +14,7 @@ jest.mock('components/Header/CozyBar', () => 'mock-cozybar') jest.mock('components/Content/Content', () => 'mock-content') describe('EcogestureNotFound component', () => { - it('should be rendered correctly', async () => { + it('should be rendered correctly', () => { const { container } = render( <EcogestureNotFound text="test" returnPage="ecogestures" /> ) diff --git a/src/components/Ecogesture/EcogestureResetModal/EcogestureResetModal.spec.tsx b/src/components/Ecogesture/EcogestureResetModal/EcogestureResetModal.spec.tsx index f7140298c..c19a04ed6 100644 --- a/src/components/Ecogesture/EcogestureResetModal/EcogestureResetModal.spec.tsx +++ b/src/components/Ecogesture/EcogestureResetModal/EcogestureResetModal.spec.tsx @@ -3,7 +3,7 @@ import React from 'react' import EcogestureResetModal from './EcogestureResetModal' describe('EcogestureResetModal component', () => { - it('should be rendered correctly', async () => { + it('should be rendered correctly', () => { const { baseElement } = render( <EcogestureResetModal open={true} diff --git a/src/components/EcogestureForm/EcogestureFormEquipment/EcogestureFormEquipment.spec.tsx b/src/components/EcogestureForm/EcogestureFormEquipment/EcogestureFormEquipment.spec.tsx index 716342473..5c3111db4 100644 --- a/src/components/EcogestureForm/EcogestureFormEquipment/EcogestureFormEquipment.spec.tsx +++ b/src/components/EcogestureForm/EcogestureFormEquipment/EcogestureFormEquipment.spec.tsx @@ -10,7 +10,7 @@ jest.mock('../EquipmentIcon/EquipmentIcon', () => 'mock-equipment-icon') describe('EcogestureFormEquipment component', () => { const store = createMockEcolyoStore() - it('should be rendered correctly', async () => { + it('should be rendered correctly', () => { const { container } = render( <Provider store={store}> <EcogestureFormEquipment @@ -40,7 +40,7 @@ describe('EcogestureFormEquipment component', () => { expect(equipments.length).toBe(Object.keys(EquipmentType).length) }) - it('should click on disabled back button', async () => { + it('should click on disabled back button', () => { const { container } = render( <Provider store={store}> <EcogestureFormEquipment diff --git a/src/components/EcogestureForm/EcogestureFormSingleChoice/EcogestureFormSingleChoice.spec.tsx b/src/components/EcogestureForm/EcogestureFormSingleChoice/EcogestureFormSingleChoice.spec.tsx index 8cd8520a1..a60db8c12 100644 --- a/src/components/EcogestureForm/EcogestureFormSingleChoice/EcogestureFormSingleChoice.spec.tsx +++ b/src/components/EcogestureForm/EcogestureFormSingleChoice/EcogestureFormSingleChoice.spec.tsx @@ -19,7 +19,7 @@ const mockHandlePreviousStep = jest.fn() describe('EcogestureFormSingleChoice component', () => { const store = createMockEcolyoStore() - it('should be rendered correctly', async () => { + it('should be rendered correctly', () => { const { container } = render( <Provider store={store}> <EcogestureFormSingleChoice @@ -76,7 +76,7 @@ describe('EcogestureFormSingleChoice component', () => { }) expect(mockHandlePreviousStep).toHaveBeenCalledTimes(1) }) - it('should keep previous answer', async () => { + it('should keep previous answer', () => { render( <Provider store={store}> <EcogestureFormSingleChoice diff --git a/src/components/EcogestureForm/EcogestureFormView.spec.tsx b/src/components/EcogestureForm/EcogestureFormView.spec.tsx index 1f3081163..82ec1fe64 100644 --- a/src/components/EcogestureForm/EcogestureFormView.spec.tsx +++ b/src/components/EcogestureForm/EcogestureFormView.spec.tsx @@ -31,7 +31,7 @@ describe('EcogestureFormView component', () => { jest.clearAllMocks() }) - it('should be rendered correctly', async () => { + it('should be rendered correctly', () => { const { container } = render( <Provider store={store}> <EcogestureFormView /> @@ -39,7 +39,7 @@ describe('EcogestureFormView component', () => { ) expect(container).toMatchSnapshot() }) - it('should render singleChoice', async () => { + it('should render singleChoice', () => { const { container } = render( <Provider store={store}> <EcogestureFormView /> @@ -49,7 +49,7 @@ describe('EcogestureFormView component', () => { container.getElementsByClassName('ecogesture-form-single').length ).toBeTruthy() }) - it('should render profiletype form step because profiletype is completed', async () => { + it('should render profiletype form step because profiletype is completed', () => { const store = createMockEcolyoStore({ profile: { ...mockProfileState, isProfileTypeCompleted: true }, profileEcogesture: mockProfileEcogesture, @@ -80,7 +80,7 @@ describe('EcogestureFormView component', () => { ).toBeTruthy() }) - it('should handle form end', async () => { + it('should handle form end', () => { mockAppDispatch.mockReturnValue(jest.fn()) jest .spyOn(React, 'useState') diff --git a/src/components/FluidChart/FluidChart.tsx b/src/components/FluidChart/FluidChart.tsx index 589276248..1f8002966 100644 --- a/src/components/FluidChart/FluidChart.tsx +++ b/src/components/FluidChart/FluidChart.tsx @@ -42,7 +42,7 @@ const FluidChart = ({ fluidType }: { fluidType: FluidType }) => { const lowercaseTimeStep = TimeStep[currentTimeStep].toLowerCase() const lowercaseFluidType = getFluidName(fluidType) - const handleChangeSwitch = async () => { + const handleChangeSwitch = () => { dispatch(setShowCompare(!showCompare)) } diff --git a/src/components/FluidChart/TimeStepSelector/TimeStepSelector.spec.tsx b/src/components/FluidChart/TimeStepSelector/TimeStepSelector.spec.tsx index 77251e882..ab25fa0ef 100644 --- a/src/components/FluidChart/TimeStepSelector/TimeStepSelector.spec.tsx +++ b/src/components/FluidChart/TimeStepSelector/TimeStepSelector.spec.tsx @@ -17,7 +17,7 @@ describe('TimeStepSelector component', () => { jest.clearAllMocks() }) - it('should render component properly with 4 timesteps', async () => { + it('should render component properly with 4 timesteps', () => { const store = createMockEcolyoStore({ chart: { ...mockChartState, diff --git a/src/components/Hooks/useExploration.tsx b/src/components/Hooks/useExploration.tsx index df533231d..73eef4e58 100644 --- a/src/components/Hooks/useExploration.tsx +++ b/src/components/Hooks/useExploration.tsx @@ -23,7 +23,7 @@ const useExploration = (): [string, Dispatch<SetStateAction<string>>] => { currentChallenge?.exploration.id === explorationID && currentChallenge?.exploration.state === UserExplorationState.ONGOING ) { - const checkExplo = async () => { + const checkExplo = () => { const explorationService = new ExplorationService(client) explorationService .checkExploration(currentChallenge, explorationID) diff --git a/src/components/Konnector/ConnectionResult/ConnectionResult.tsx b/src/components/Konnector/ConnectionResult/ConnectionResult.tsx index 99f6356d3..9665182bc 100644 --- a/src/components/Konnector/ConnectionResult/ConnectionResult.tsx +++ b/src/components/Konnector/ConnectionResult/ConnectionResult.tsx @@ -44,7 +44,7 @@ const ConnectionResult = ({ const [status, setStatus] = useState<string>('') const [outDatedDataDays, setOutDatedDataDays] = useState<number | null>(null) - const updateKonnector = async () => { + const updateKonnector = () => { setStatus('') setLastExecutionDate('-') setKonnectorError('') diff --git a/src/components/Konnector/KonnectorModal.spec.tsx b/src/components/Konnector/KonnectorModal.spec.tsx index bd2f5caca..32d0a9b8b 100644 --- a/src/components/Konnector/KonnectorModal.spec.tsx +++ b/src/components/Konnector/KonnectorModal.spec.tsx @@ -69,7 +69,7 @@ describe('KonnectorModal component', () => { }) expect(mockHandleCloseClick).toHaveBeenCalled() }) - it('should render login error', async () => { + it('should render login error', () => { const { baseElement } = render( <Provider store={store}> <KonnectorModal @@ -88,7 +88,7 @@ describe('KonnectorModal component', () => { baseElement.getElementsByClassName('headerError')[0] ).toBeInTheDocument() }) - it('should render unknown error', async () => { + it('should render unknown error', () => { render( <Provider store={store}> <KonnectorModal @@ -105,7 +105,7 @@ describe('KonnectorModal component', () => { ) expect(screen.getByText('konnector_modal.error_data_2')).toBeInTheDocument() }) - it('should render update error', async () => { + it('should render update error', () => { const { baseElement } = render( <Provider store={store}> <KonnectorModal diff --git a/src/components/Konnector/KonnectorViewerList.spec.tsx b/src/components/Konnector/KonnectorViewerList.spec.tsx index d1b3e7928..ec1693348 100644 --- a/src/components/Konnector/KonnectorViewerList.spec.tsx +++ b/src/components/Konnector/KonnectorViewerList.spec.tsx @@ -14,7 +14,7 @@ jest.mock('react-router-dom', () => ({ describe('KonnectorViewerList component', () => { const store = createMockEcolyoStore() - it('should be rendered correctly', async () => { + it('should be rendered correctly', () => { const { container } = render( <Provider store={store}> <KonnectorViewerList /> diff --git a/src/components/Options/ReportOptions/ReportOptions.spec.tsx b/src/components/Options/ReportOptions/ReportOptions.spec.tsx index 747eb7aa3..ff979961b 100644 --- a/src/components/Options/ReportOptions/ReportOptions.spec.tsx +++ b/src/components/Options/ReportOptions/ReportOptions.spec.tsx @@ -89,7 +89,7 @@ describe('ReportOptions component', () => { }) }) - it('should render waterLimit to 100', async () => { + it('should render waterLimit to 100', () => { const storeWaterAlert = createMockEcolyoStore({ global: { ...mockGlobalState, fluidStatus: fluidStatusConnectedData }, profile: { diff --git a/src/components/ProfileType/ProfileTypeFinished/ProfileTypeFinished.spec.tsx b/src/components/ProfileType/ProfileTypeFinished/ProfileTypeFinished.spec.tsx index 129114f86..7c6974964 100644 --- a/src/components/ProfileType/ProfileTypeFinished/ProfileTypeFinished.spec.tsx +++ b/src/components/ProfileType/ProfileTypeFinished/ProfileTypeFinished.spec.tsx @@ -29,7 +29,7 @@ jest.mock('services/profileTypeEntity.service', () => { describe('ProfileTypeFinished component', () => { const store = createMockEcolyoStore() - it('should be rendered correctly', async () => { + it('should be rendered correctly', () => { const { container } = render( <Provider store={store}> <ProfileTypeFinished profileType={mockProfileType} /> diff --git a/src/components/ProfileType/ProfileTypeFormNumberSelection/ProfileTypeFormNumberSelection.spec.tsx b/src/components/ProfileType/ProfileTypeFormNumberSelection/ProfileTypeFormNumberSelection.spec.tsx index 0b4d386c5..b3f119d22 100644 --- a/src/components/ProfileType/ProfileTypeFormNumberSelection/ProfileTypeFormNumberSelection.spec.tsx +++ b/src/components/ProfileType/ProfileTypeFormNumberSelection/ProfileTypeFormNumberSelection.spec.tsx @@ -12,7 +12,7 @@ import ProfileTypeFormNumberSelection from './ProfileTypeFormNumberSelection' describe('ProfileTypeFormNumberSelection component', () => { const store = createMockEcolyoStore() - it('should be rendered correctly', async () => { + it('should be rendered correctly', () => { const { container } = render( <Provider store={store}> <ProfileTypeFormNumberSelection diff --git a/src/components/Quiz/QuizQuestion/QuizQuestion.spec.tsx b/src/components/Quiz/QuizQuestion/QuizQuestion.spec.tsx index c2b25bde8..93bf18196 100644 --- a/src/components/Quiz/QuizQuestion/QuizQuestion.spec.tsx +++ b/src/components/Quiz/QuizQuestion/QuizQuestion.spec.tsx @@ -27,7 +27,7 @@ jest.mock( describe('QuizQuestion component', () => { const store = createMockEcolyoStore() - it('should be rendered correctly with question', async () => { + it('should be rendered correctly with question', () => { const { container } = render( <Provider store={store}> <QuizQuestion userChallenge={userChallengeData[0]} /> diff --git a/src/components/Splash/SplashRoot.spec.tsx b/src/components/Splash/SplashRoot.spec.tsx index 3f57b513a..710e35610 100644 --- a/src/components/Splash/SplashRoot.spec.tsx +++ b/src/components/Splash/SplashRoot.spec.tsx @@ -12,7 +12,7 @@ jest.mock('@sentry/react', () => ({ describe('SplashRoot component', () => { const store = createMockEcolyoStore() - it('should be rendered correctly', async () => { + it('should be rendered correctly', () => { const { container } = render( <Provider store={store}> <SplashRoot>children</SplashRoot> diff --git a/src/components/Splash/SplashRoot.tsx b/src/components/Splash/SplashRoot.tsx index 0a4cd8b72..e6aa2b0f9 100644 --- a/src/components/Splash/SplashRoot.tsx +++ b/src/components/Splash/SplashRoot.tsx @@ -104,7 +104,7 @@ const SplashRoot = ({ fadeTimer = 1000, children }: SplashRootProps) => { /** Process customPopup and enable it if activated */ const processCustomPopup = useCallback( - async (profile: Profile, customPopup: CustomPopup) => { + (profile: Profile, customPopup: CustomPopup) => { try { if ( today !== profile?.customPopupDate.toISO() && @@ -123,7 +123,7 @@ const SplashRoot = ({ fadeTimer = 1000, children }: SplashRootProps) => { * For each fluid, set partnersIssue to true if notification is activated and seenDate < today */ const processPartnersStatus = useCallback( - async (profile: Profile, partnersInfo: PartnersInfo) => { + (profile: Profile, partnersInfo: PartnersInfo) => { try { if ( partnersInfo.notification_activated && @@ -181,7 +181,7 @@ const SplashRoot = ({ fadeTimer = 1000, children }: SplashRootProps) => { useEffect(() => { let subscribed = true - async function loadData() { + function loadData() { const startTime = performance.now() Sentry.startSpan({ name: 'Initialize app' }, async () => { const initializationService = new InitializationService( @@ -338,15 +338,15 @@ const SplashRoot = ({ fadeTimer = 1000, children }: SplashRootProps) => { /** * Load custom popup and partners info synchronously so these treatments don't block the loading */ - customPopupService.getCustomPopup().then(async customPopup => { + customPopupService.getCustomPopup().then(customPopup => { if (profile && customPopup) { - await processCustomPopup(profile, customPopup) + processCustomPopup(profile, customPopup) } }) partnersInfoService.getPartnersInfo().then(async partnersInfo => { if (profile && partnersInfo) { await processFluidsStatus(profile, partnersInfo) - await processPartnersStatus(profile, partnersInfo) + processPartnersStatus(profile, partnersInfo) } }) diff --git a/src/components/WelcomeModal/WelcomeModal.tsx b/src/components/WelcomeModal/WelcomeModal.tsx index 14a653d82..b1fdea23c 100644 --- a/src/components/WelcomeModal/WelcomeModal.tsx +++ b/src/components/WelcomeModal/WelcomeModal.tsx @@ -22,7 +22,7 @@ const WelcomeModal = ({ open }: { open: boolean }) => { const dispatch = useAppDispatch() const { instanceSettings } = useUserInstanceSettings() - const setWelcomeModalViewed = useCallback(async () => { + const setWelcomeModalViewed = useCallback(() => { const mailService = new MailService() let username = '' diff --git a/src/migrations/migration.data.ts b/src/migrations/migration.data.ts index a5ec647e7..4f2a4e8fe 100644 --- a/src/migrations/migration.data.ts +++ b/src/migrations/migration.data.ts @@ -43,7 +43,7 @@ export const migrations: Migration[] = [ 'Removes old profileType artifacts from users database : \n - Oldest profileType is deleted \n - Removes insulation work form fields that were prone to errors \n - Changes area and outsideFacingWalls form field to strings \n - Changes updateDate values of all existing profileType to match "created_at" entry (former updateDate values got corrupted and hold no meanings).', releaseNotes: null, docTypes: PROFILETYPE_DOCTYPE, - run: async (_client: Client, docs: any[]): Promise<ProfileType[]> => { + run: (_client: Client, docs: any[]): ProfileType[] => { docs.sort(function (a, b) { const c = DateTime.fromISO(a.cozyMetadata.createdAt, { zone: 'utc', @@ -103,7 +103,7 @@ export const migrations: Migration[] = [ description: 'Removes old profileType and GCUApprovalDate from profile.', docTypes: PROFILE_DOCTYPE, releaseNotes: null, - run: async (_client: Client, docs: any[]): Promise<Profile[]> => { + run: (_client: Client, docs: any[]): Profile[] => { return docs.map(doc => { if (doc.GCUApprovalDate) { delete doc.GCUApprovalDate @@ -123,7 +123,7 @@ export const migrations: Migration[] = [ 'Updates userChallenges to make sure no quiz results are overflowing.', releaseNotes: null, docTypes: USERCHALLENGE_DOCTYPE, - run: async (_client: Client, docs: any[]): Promise<UserChallenge[]> => { + run: (_client: Client, docs: any[]): UserChallenge[] => { return docs.map(doc => { if (doc.quiz.result > 5) { doc.quiz.result = 5 @@ -155,7 +155,7 @@ export const migrations: Migration[] = [ tag: 'day', limit: 120, }, - run: async (_client: Client, docs: any[]): Promise<any[]> => { + run: (_client: Client, docs: any[]): any[] => { return docs.map(doc => { doc.deleteAction = true return doc @@ -174,7 +174,7 @@ export const migrations: Migration[] = [ tag: 'month', limit: 4, }, - run: async (_client: Client, docs: any[]): Promise<any[]> => { + run: (_client: Client, docs: any[]): any[] => { return docs.map(doc => { doc.deleteAction = true return doc @@ -193,7 +193,7 @@ export const migrations: Migration[] = [ tag: 'year', limit: 1, }, - run: async (_client: Client, docs: any[]): Promise<any[]> => { + run: (_client: Client, docs: any[]): any[] => { return docs.map(doc => { doc.deleteAction = true return doc @@ -207,7 +207,7 @@ export const migrations: Migration[] = [ description: 'Corrects individual insulation work field on profileType.', releaseNotes: null, docTypes: PROFILETYPE_DOCTYPE, - run: async (_client: Client, docs: any[]): Promise<ProfileType[]> => { + run: (_client: Client, docs: any[]): ProfileType[] => { return docs.map(doc => { if (!Array.isArray(doc.individualInsulationWork)) { doc.individualInsulationWork = [doc.individualInsulationWork] @@ -256,7 +256,7 @@ export const migrations: Migration[] = [ 'ProfileTypes start now at the begining of the month, no duplications can exist over the same month.', releaseNotes: null, docTypes: PROFILETYPE_DOCTYPE, - run: async (_client: Client, docs: any[]): Promise<any[]> => { + run: (_client: Client, docs: any[]): any[] => { function checkDate(d1: string, d2: string) { const dtd1 = DateTime.fromISO(d1) const dtd2 = DateTime.fromISO(d2) @@ -289,7 +289,7 @@ export const migrations: Migration[] = [ docTypes: FLUIDSPRICES_DOCTYPE, isCreate: true, isDeprecated: true, - run: async (): Promise<any> => { + run: (): any => { return [] }, }, @@ -301,7 +301,7 @@ export const migrations: Migration[] = [ "Profil now contains partnersIssueDate in order to handle partners' issue display", releaseNotes: null, docTypes: PROFILE_DOCTYPE, - run: async (_client: Client, docs: any[]): Promise<Profile[]> => { + run: (_client: Client, docs: any[]): Profile[] => { return docs.map(doc => { doc.partnersIssueDate = DateTime.local() .minus({ day: 1 }) @@ -318,7 +318,7 @@ export const migrations: Migration[] = [ 'Rename tutorial to onboaring in ecolyo profile, remove isLastTermAccepted', releaseNotes: null, docTypes: PROFILE_DOCTYPE, - run: async (_client: Client, docs: any[]): Promise<ProfileType[]> => { + run: (_client: Client, docs: any[]): ProfileType[] => { return docs.map(doc => { if (doc.tutorial) { doc.onboarding = { ...doc.tutorial } @@ -343,7 +343,7 @@ export const migrations: Migration[] = [ tag: 'day', limit: 1000, }, - run: async (_client: Client, docs: any[]): Promise<DataloadEntity[]> => { + run: (_client: Client, docs: any[]): DataloadEntity[] => { let prevData: DataloadEntity = { id: '', day: 0, @@ -381,7 +381,7 @@ export const migrations: Migration[] = [ tag: 'day', limit: 1000, }, - run: async (_client: Client, docs: any[]): Promise<DataloadEntity[]> => { + run: (_client: Client, docs: any[]): DataloadEntity[] => { let prevData: DataloadEntity = { id: '', day: 0, @@ -419,7 +419,7 @@ export const migrations: Migration[] = [ tag: 'month', limit: 17, }, - run: async (_client: Client, docs: any[]): Promise<DataloadEntity[]> => { + run: (_client: Client, docs: any[]): DataloadEntity[] => { return docs.map(doc => { if (doc.price) { delete doc.price @@ -440,7 +440,7 @@ export const migrations: Migration[] = [ tag: 'year', limit: 3, }, - run: async (_client: Client, docs: any[]): Promise<DataloadEntity[]> => { + run: (_client: Client, docs: any[]): DataloadEntity[] => { return docs.map(doc => { if (doc.price) { delete doc.price @@ -461,7 +461,7 @@ export const migrations: Migration[] = [ tag: 'month', limit: 17, }, - run: async (_client: Client, docs: any[]): Promise<DataloadEntity[]> => { + run: (_client: Client, docs: any[]): DataloadEntity[] => { return docs.map(doc => { if (doc.price) { delete doc.price @@ -482,7 +482,7 @@ export const migrations: Migration[] = [ tag: 'year', limit: 3, }, - run: async (_client: Client, docs: any[]): Promise<DataloadEntity[]> => { + run: (_client: Client, docs: any[]): DataloadEntity[] => { return docs.map(doc => { if (doc.price) { delete doc.price @@ -499,7 +499,7 @@ export const migrations: Migration[] = [ releaseNotes: null, docTypes: FLUIDSPRICES_DOCTYPE, isDeprecated: true, - run: async (): Promise<any> => { + run: (): any => { return [] }, }, @@ -510,7 +510,7 @@ export const migrations: Migration[] = [ description: 'Replace old minCons with the new calculation', releaseNotes: null, docTypes: ENEDIS_MONTHLY_ANALYSIS_DATA_DOCTYPE, - run: async (_client: Client, docs: any[]): Promise<any> => { + run: (_client: Client, docs: any[]): any => { return docs.map(doc => { if (doc.minLoad) { const numberofDaysInMonth = DateTime.fromObject({ @@ -532,7 +532,7 @@ export const migrations: Migration[] = [ 'Empty fluidPrices db so it can be fetched with right format from remote doctype', releaseNotes: null, docTypes: FLUIDSPRICES_DOCTYPE, - run: async (_client: Client, docs: any[]): Promise<any> => { + run: (_client: Client, docs: any[]): any => { return docs.map(doc => { doc.deleteAction = true return doc @@ -552,7 +552,7 @@ export const migrations: Migration[] = [ }, redirectLink: '/consumption/electricity', docTypes: '', - run: async (): Promise<any> => undefined, + run: (): any => undefined, isEmpty: true, }, { @@ -563,7 +563,7 @@ export const migrations: Migration[] = [ 'Profil now contains partnersIssueSeenDates in order to handle each partners issue date. Also removes previous partnersIssueDate', releaseNotes: null, docTypes: PROFILE_DOCTYPE, - run: async (_client: Client, docs: any[]): Promise<Profile[]> => { + run: (_client: Client, docs: any[]): Profile[] => { return docs.map(doc => { doc.partnersIssueSeenDate = { enedis: DateTime.local().minus({ day: 1 }).startOf('day'), @@ -584,7 +584,7 @@ export const migrations: Migration[] = [ description: 'Fix apartment typo', releaseNotes: null, docTypes: PROFILETYPE_DOCTYPE, - run: async (_client: Client, docs: any[]) => { + run: (_client: Client, docs: any[]) => { return docs.map(doc => { if (doc.housingType === 'appartment') { doc.housingType = 'apartment' @@ -600,7 +600,7 @@ export const migrations: Migration[] = [ description: 'Add garden room & equipment type', releaseNotes: null, docTypes: ECOGESTURE_DOCTYPE, - run: async (_client: Client, ecogestures: Ecogesture[]) => { + run: (_client: Client, ecogestures: Ecogesture[]) => { return ecogestures.map(ecogesture => { const ecData = ecogestureData.find( ec => ec._id === ecogesture.id diff --git a/src/migrations/migration.service.spec.ts b/src/migrations/migration.service.spec.ts index c865c5d7a..ade8d9556 100644 --- a/src/migrations/migration.service.spec.ts +++ b/src/migrations/migration.service.spec.ts @@ -36,7 +36,7 @@ describe('Migration service', () => { description: 'Removing mailToken from profil', docTypes: PROFILE_DOCTYPE, releaseNotes: releaseNotes, - run: async (client: Client, docs: any[]): Promise<Profile[]> => { + run: (client: Client, docs: any[]): Profile[] => { return docs.map(doc => { if (doc.mailToken) { delete doc.mailToken @@ -67,7 +67,7 @@ describe('Migration service', () => { description: 'Removing mailToken from profil', docTypes: PROFILE_DOCTYPE, releaseNotes: releaseNotes, - run: async (client: Client, docs: any[]): Promise<Profile[]> => { + run: (client: Client, docs: any[]): Profile[] => { return [] }, }, @@ -99,7 +99,7 @@ describe('Migration service', () => { description: 'Removing mailToken from profil', docTypes: PROFILE_DOCTYPE, releaseNotes: releaseNotes, - run: async (client: Client, docs: any[]): Promise<Profile[]> => { + run: (client: Client, docs: any[]): Profile[] => { return [] }, }, @@ -135,7 +135,7 @@ describe('Migration service', () => { description: 'Removing mailToken from profil', docTypes: PROFILE_DOCTYPE, releaseNotes: releaseNotes, - run: async (client: Client, docs: any[]): Promise<Profile[]> => { + run: (client: Client, docs: any[]): Profile[] => { return [] }, }, @@ -161,7 +161,7 @@ describe('Migration service', () => { description: 'Removing mailToken from profil', docTypes: PROFILE_DOCTYPE, releaseNotes: releaseNotes, - run: async (client: Client, docs: any[]): Promise<Profile[]> => { + run: (client: Client, docs: any[]): Profile[] => { return [] }, }, @@ -172,7 +172,7 @@ describe('Migration service', () => { description: 'Removing mailToken from profil', docTypes: PROFILE_DOCTYPE, releaseNotes: releaseNotes, - run: async (client: Client, docs: any[]): Promise<Profile[]> => { + run: (client: Client, docs: any[]): Profile[] => { return [] }, }, diff --git a/src/migrations/migration.spec.ts b/src/migrations/migration.spec.ts index 03ae98d66..a7535b330 100644 --- a/src/migrations/migration.spec.ts +++ b/src/migrations/migration.spec.ts @@ -20,7 +20,7 @@ describe('migration logger', () => { description: 'Removing mailToken from profil', docTypes: PROFILE_DOCTYPE, releaseNotes: null, - run: async (mockClient, docs: any[]): Promise<Profile[]> => { + run: (mockClient, docs: any[]): Profile[] => { return docs.map(doc => { if (doc.mailToken) { delete doc.mailToken @@ -63,7 +63,7 @@ describe('migration', () => { description: 'Removing mailToken from profil', docTypes: PROFILE_DOCTYPE, releaseNotes: null, - run: async (mockClient, docs: any[]): Promise<Profile[]> => { + run: (mockClient, docs: any[]): Profile[] => { return docs.map(doc => { if (doc.GCUApprovalDate) { delete doc.GCUApprovalDate @@ -160,7 +160,7 @@ describe('migration', () => { description: 'Removing mailToken from profil', docTypes: PROFILE_DOCTYPE, releaseNotes: null, - run: async (mockClient, docs: any[]): Promise<Profile[]> => { + run: (mockClient, docs: any[]): Profile[] => { return [] }, } @@ -206,7 +206,7 @@ describe('migration create', () => { docTypes: FLUIDSPRICES_DOCTYPE, releaseNotes: null, isCreate: true, - run: async (): Promise<FluidPrice[]> => { + run: (): FluidPrice[] => { return [] }, } diff --git a/src/migrations/migration.ts b/src/migrations/migration.ts index 05fa3685f..e79d15e30 100644 --- a/src/migrations/migration.ts +++ b/src/migrations/migration.ts @@ -74,6 +74,7 @@ async function updateSchemaVersion( * Save updated docs * @returns Promise<MigrationResult> */ +// eslint-disable-next-line @typescript-eslint/require-await async function save(_client: Client, docs: any[]): Promise<MigrationResult> { logApp.info('[Migration] Saving docs...') const migrationResult = migrationNoop() @@ -149,7 +150,7 @@ export async function migrate( if (migration.isDeprecated) { result = migrationNoop() } else if (docToUpdate.length && !migration.isCreate) { - const migratedDocs = await migration.run(_client, docToUpdate) + const migratedDocs = migration.run(_client, docToUpdate) if (migratedDocs.length) { result = await save(_client, migratedDocs) } else { @@ -161,7 +162,7 @@ export async function migrate( // Handle new doctype creation if (migration.isCreate && !migration.isDeprecated) { - await migration.run(_client, docToUpdate) + migration.run(_client, docToUpdate) result = { type: MIGRATION_RESULT_COMPLETE, errors: [] } } diff --git a/src/migrations/migration.type.ts b/src/migrations/migration.type.ts index c168aeb84..dca5840cc 100644 --- a/src/migrations/migration.type.ts +++ b/src/migrations/migration.type.ts @@ -33,7 +33,7 @@ export interface Migration { queryOptions?: MigrationQueryOptions isEmpty?: boolean appVersion: string - run: (_client: Client, docs: any[]) => Promise<any[]> + run: (_client: Client, docs: any[]) => any[] } export interface MigrationQueryOptions { diff --git a/src/services/account.service.ts b/src/services/account.service.ts index 412b0955e..7fa566503 100644 --- a/src/services/account.service.ts +++ b/src/services/account.service.ts @@ -36,7 +36,10 @@ export default class AccountService { konnector: Konnector, authData: AccountEGLData | AccountSgeData | AccountGRDFData ): Promise<Account> { - const accountAttributes: AccountAttributes = build(konnector, authData) + const accountAttributes: AccountAttributes = await build( + konnector, + authData + ) return createAccount(this._client, konnector, accountAttributes) } diff --git a/src/services/challenge.service.ts b/src/services/challenge.service.ts index d7ec39709..b15f55d06 100644 --- a/src/services/challenge.service.ts +++ b/src/services/challenge.service.ts @@ -169,12 +169,11 @@ export default class ChallengeService { } /** - * * @param {ChallengeEntity} challenge - get all relations entities of a challenge */ - public async getRelationEntities( + public getRelationEntities( challenge: ChallengeEntity - ): Promise<RelationEntitiesObject> { + ): RelationEntitiesObject { const duelEntityRelation = getRelationship(challenge, 'duel') const quizEntityRelation = getRelationship(challenge, 'quiz') const explorationEntityRelation = getRelationshipHasMany( @@ -343,7 +342,7 @@ export default class ChallengeService { // Case UserChallengeList is empty if (challengeEntityList.length > 0 && userChallengeList.length === 0) { for (const challenge of challengeEntityList) { - const relationEntities = await this.getRelationEntities(challenge) + const relationEntities = this.getRelationEntities(challenge) const duel = duelService.getDuelFromDuelEntities( duelEntities || [], relationEntities.duelEntityRelation._id @@ -397,7 +396,7 @@ export default class ChallengeService { ) buildList.push(userChallenge) } else { - const relationEntities = await this.getRelationEntities(challenge) + const relationEntities = this.getRelationEntities(challenge) const duel = duelService.getDuelFromDuelEntities( duelEntities || [], relationEntities.duelEntityRelation._id diff --git a/src/services/consumptionFormatter.service.spec.ts b/src/services/consumptionFormatter.service.spec.ts index 2c07788f2..f73ee0939 100644 --- a/src/services/consumptionFormatter.service.spec.ts +++ b/src/services/consumptionFormatter.service.spec.ts @@ -251,7 +251,7 @@ describe('ConsumptionFormatter service', () => { expect(result).toEqual(mockResult) }) it('should return an error because of unknown TimeStep', async () => { - const error = await getError(async () => + const error = await getError(() => consumptionFormatterService.formatGraphData( mockDataLoad, mockTimePeriod, diff --git a/src/services/dateChart.service.spec.ts b/src/services/dateChart.service.spec.ts index 59c9d2d5b..d799abd28 100644 --- a/src/services/dateChart.service.spec.ts +++ b/src/services/dateChart.service.spec.ts @@ -296,7 +296,7 @@ describe('dateChart service', () => { }) it('should throw error for unknown TimeStep', async () => { - const error = await getError(async () => + const error = await getError(() => dateChartService.defineTimePeriod(refDate, unknownTimeStep, -1) ) expect(error).toEqual(new Error('TimeStep unknown')) @@ -693,7 +693,7 @@ describe('dateChart service', () => { const secondDate = DateTime.fromISO('2020-10-31T00:30:00.000Z', { zone: 'utc', }) - const error = await getError(async () => + const error = await getError(() => dateChartService.compareStepDate(unknownTimeStep, firstDate, secondDate) ) expect(error).toEqual(new Error('TimeStep unknown')) diff --git a/src/services/ecogesture.service.spec.ts b/src/services/ecogesture.service.spec.ts index d04e0116b..8511c0c08 100644 --- a/src/services/ecogesture.service.spec.ts +++ b/src/services/ecogesture.service.spec.ts @@ -113,7 +113,7 @@ describe('Ecogesture service', () => { }) describe('filterByUsage', () => { - it('should return ecogesture list including ECS ecogestures', async () => { + it('should return ecogesture list including ECS ecogestures', () => { const mockEcogestureList: Ecogesture[] = ecogesturesECSData const mockProfileEcogesture1: ProfileEcogesture = { ...mockProfileEcogesture, @@ -125,7 +125,7 @@ describe('Ecogesture service', () => { ) expect(result.includes(ecogesturesECSData[0])).toBeTruthy() }) - it('should return ecogesture list excluding ECS ecogestures', async () => { + it('should return ecogesture list excluding ECS ecogestures', () => { const mockEcogestureList: Ecogesture[] = ecogesturesECSData const mockProfileEcogesture1: ProfileEcogesture = { ...mockProfileEcogesture, @@ -137,7 +137,7 @@ describe('Ecogesture service', () => { ) expect(result.includes(ecogesturesECSData[1])).toBeFalsy() }) - it('should return ecogesture list including HEATING ecogestures', async () => { + it('should return ecogesture list including HEATING ecogestures', () => { const mockEcogestureList: Ecogesture[] = ecogesturesHeatingData const mockProfileEcogesture2: ProfileEcogesture = { ...mockProfileEcogesture, @@ -150,7 +150,7 @@ describe('Ecogesture service', () => { ) expect(result.includes(ecogesturesHeatingData[0])).toBeTruthy() }) - it('should return ecogesture list excluding HEATING ecogestures', async () => { + it('should return ecogesture list excluding HEATING ecogestures', () => { const mockEcogestureList: Ecogesture[] = ecogesturesHeatingData const mockProfileEcogesture2: ProfileEcogesture = { ...mockProfileEcogesture, @@ -164,7 +164,7 @@ describe('Ecogesture service', () => { }) }) describe('filterByEquipment', () => { - it('should return ecogesture list including BOILER equipment and equipment verification to true', async () => { + it('should return ecogesture list including BOILER equipment and equipment verification to true', () => { const mockProfileEcogestureBOILER: ProfileEcogesture = { ...mockProfileEcogesture, equipments: [EquipmentType.BOILER], @@ -175,7 +175,7 @@ describe('Ecogesture service', () => { ) expect(result.includes(BoilerEcogesture[0])).toBeTruthy() }) - it('should return ecogesture list excluding BOILER equipment and equipment verification to true', async () => { + it('should return ecogesture list excluding BOILER equipment and equipment verification to true', () => { const mockProfileEcogestureBOILER: ProfileEcogesture = { ...mockProfileEcogesture, } @@ -185,7 +185,7 @@ describe('Ecogesture service', () => { ) expect(result.includes(BoilerEcogesture[0])).toBeFalsy() }) - it('should return ecogesture list including BOILER equipment with equipment verification to false but equipment to BOILER', async () => { + it('should return ecogesture list including BOILER equipment with equipment verification to false but equipment to BOILER', () => { const mockProfileEcogestureBOILER: ProfileEcogesture = { ...mockProfileEcogesture, equipments: [EquipmentType.BOILER], diff --git a/src/services/environement.service.spec.ts b/src/services/environement.service.spec.ts index 4b7474006..7dc4afb27 100644 --- a/src/services/environement.service.spec.ts +++ b/src/services/environement.service.spec.ts @@ -5,11 +5,11 @@ declare const global: { __DEVELOPMENT__: boolean } -describe('Environement service', () => { +describe('Environment service', () => { const environmentService = new EnvironmentService() describe('isProduction()', () => { - it('should return true and prod url', async () => { + it('should return true and prod url', () => { global.__IS_ALPHA__ = false const result = environmentService.isProduction() expect(result).toEqual(true) @@ -17,7 +17,7 @@ describe('Environement service', () => { expect(url).toEqual('https://ecolyo-agent.apps.grandlyon.com') }) - it('should return false and rec url, alpha case', async () => { + it('should return false and rec url, alpha case', () => { global.__IS_ALPHA__ = true const result = environmentService.isProduction() expect(result).toEqual(false) diff --git a/src/services/exploration.service.spec.ts b/src/services/exploration.service.spec.ts index da61c3b29..1a4fe2acb 100644 --- a/src/services/exploration.service.spec.ts +++ b/src/services/exploration.service.spec.ts @@ -118,7 +118,7 @@ describe('Exploration service', () => { }) }) describe('endUserExploration Method', () => { - it('should return the finished userExploration', async () => { + it('should return the finished userExploration', () => { const result = explorationService.endUserExploration( userExplorationStarted ) diff --git a/src/services/mail.service.ts b/src/services/mail.service.ts index 1e425524b..534cfa436 100644 --- a/src/services/mail.service.ts +++ b/src/services/mail.service.ts @@ -11,7 +11,7 @@ export default class MailService { ): Promise<void> { try { const jobCollection = client.collection('io.cozy.jobs') - jobCollection.create('sendmail', mailInfo) + await jobCollection.create('sendmail', mailInfo) } catch (error) { const errorMessage = `Failed to send mail` logStack('error', errorMessage) diff --git a/src/services/timePeriod.service.spec.ts b/src/services/timePeriod.service.spec.ts index abc6455fb..674c75a36 100644 --- a/src/services/timePeriod.service.spec.ts +++ b/src/services/timePeriod.service.spec.ts @@ -263,7 +263,7 @@ describe('timePeriod service', () => { zone: 'utc', }), } - const error = await getError(async () => + const error = await getError(() => timePeriodService.getComparisonTimePeriod(timePeriod, unknownTimeStep) ) expect(error).toEqual(new Error('TimeStep unknown')) @@ -322,7 +322,7 @@ describe('timePeriod service', () => { expect(result).toEqual(expectedDate) }) it('should return an error because of unknown TimeStep', async () => { - const error = await getError(async () => + const error = await getError(() => timePeriodService.getLastDayOfCompletePeriod( randomDate, unknownTimeStep @@ -384,7 +384,7 @@ describe('timePeriod service', () => { expect(result).toEqual(expectedDate) }) it('should return unknown timestep', async () => { - const error = await getError(async () => + const error = await getError(() => timePeriodService.getLastDayOfTimePeriod(randomDate, unknownTimeStep) ) expect(error).toEqual(new Error('TimeStep unknown')) @@ -443,7 +443,7 @@ describe('timePeriod service', () => { expect(result).toEqual(expectedDate) }) it('should return the date of the last day of current period', async () => { - const error = await getError(async () => + const error = await getError(() => timePeriodService.getStartDateFromEndDateByTimeStep( randomDate, unknownTimeStep diff --git a/src/services/timePeriod.service.ts b/src/services/timePeriod.service.ts index 617b9b3e3..263b79378 100644 --- a/src/services/timePeriod.service.ts +++ b/src/services/timePeriod.service.ts @@ -194,7 +194,7 @@ export default class TimePeriodService { lastDay: DateTime, timeStep: TimeStep ): TimePeriod { - // calculate last day of the tobe coimpleted period + // calculate last day of the to be completed period const lastCompleteTimePeriod = { startDate: this.getStartDateFromEndDateByTimeStep(lastDay, timeStep), endDate: lastDay, -- GitLab