diff --git a/.eslintrc.js b/.eslintrc.js index 8a4f5246f5034f96f455c4bc9a6c6d92d109d269..e4f98e3f85ee456e7f9ef51c9f4b6b5befbc403c 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 038a6dd206fee247504430ae81e435a579e305b0..f377200ae1ac9975b1c0611ae2401f70bda628eb 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 2e8f36c8ddac42c65c619b5b89b5a9f6d234ba07..37e94eda6c1e803758c3574930f5a831d1fb9a30 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 25bd7eef03a284e261ef00572d1eab1f1d20a43e..a6d116988944097f46dbc9fcf1b80896b0fdc12e 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 62845a52f0cebe1be5cba0856bd46af2285133bc..18ccf5ee69556c50ba5e8ce37743a21a8f3eef66 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 ec7e9511042657b725442790da1133df0c10e116..f174bacde00861ab29e4f91befb7e4079148f24f 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 95d25f0f6ad5a180b1859385e33b80f73b1ffe14..6110f52d758899b5ef695230a7eb7f90580466ca 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 f4825300a48bdda50d2ff32104a254aaca806a28..989c92034e5d09f8569b48831ba6376fb7f8d0c2 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 1c094a952788b64c16f803b22e305dbdf17c6369..aea83c8f9988c6f7207b6c50fb7ef7089efea679 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 d02503c690b73319c86aee791c6279877c05bf2a..99ed04a63287af471dcb82c5f20411a1bc1a5025 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 185dd4bdbdb8ea6d456972a8a0106ed14c6795f0..fd12330c01ad87beaed3e3b1bc43fd42a21cd073 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 8cb9c8bb0363de72c8d0abfff8243b9301abce37..3941573aaa347b5f3b67dcd605e9d9b883bdeccd 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 78b2dc508218534047f0cde124a05df356038db7..3ffa25603c8e63bbbe5fdc34d66d4fb0d5050a56 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 09d06751951cf026faba5835fd1c3c13ad34b78f..d78072dfc3ce56f080b1b1c5edba2cd9cf1c3714 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 f6d849de2d72211b5663408005fdf22e2f96f41c..f6aa3af5b01b22aba90ac4d28f55f3ca37c471ec 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 111456ecb5c280068e07928dbedfe1e66b91a0bc..3a59ea931847bb7002ce5011b90495a0efd06de2 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 e0afcdfbd52fa876d4cb2a597f6d8055a1021657..72f8920ca8e556d755e766cfc62b8b47869cc575 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 a362aa740509e42e6792918e7353cada49f2e520..f3eb6da60b24e005fbff339b7cc2eedac4c7edac 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 c9ff69e6525aa1d2e4a0dbf18c4f52017af31b9c..87dbacbb311b85ccedc09f0a03b1c62364506cf7 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 d7f34079a2df5cf59dbaedfec0d3d826af3eaac7..29f83296380f5c16c5c913ba90c6e36beba16723 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 5e94655971924fe66cf8e420851f53cec0072d66..781ef84c653535a11162acf724ba689268c81caf 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 199878a12050aecaccad580936213290144de33a..c73a61c4cc3e5caaa0a790da0dc238a7118ecbd9 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 d512de1a43de39e438432c03f18509d0537eca23..1e7f223c9b4436f8eb7dd1b6c1a7e9979d048c19 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 2ca68993812bf704ba4c9caa6ca2024f649beb1b..7ae9d83388a642af0afa226befd9d44c17467d89 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 f7140298cd585f51a9e7d82a45099c20d4287217..c19a04ed6a29efe0a5df3c71adfaf7212de62498 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 716342473d720cc91fc9ac1f7f7078854e54a14e..5c3111db45fee5fe8e898f9f7b8d4847276226f1 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 8cd8520a132205f8173e82b6ce502490c945a1bb..a60db8c120a72cd988cd862249a154a3137b604d 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 1f30811639ed24790739b49eed3625682118ead8..82ec1fe642adf423f7ab5b75fac72f5635dbd77e 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 58927624825967be1dca7a1e1463fcf2ab61aebc..1f80029664e3e6c673aa235ed04c58c0fe716fdb 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 77251e88230f53ba66b4eb48a65737c1c0d120fd..ab25fa0ef054088f668adbf8f7ec414cc5e77381 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 df533231dde079eb02c17eace6b677f7e7cd1c17..73eef4e582a5c55bfa35ddc126c0ad730fc1b095 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 99f6356d30f55c48b0893bfb0772fa09f27a73f7..9665182bca271f7e9b8075da3cb4ff39b336854a 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 bd2f5cacac53519318ffdbdbc6cc4952b35729b3..32d0a9b8bad35cfaba93c98984b7e483e1d38bbc 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 d1b3e7928c956e147b4925c503bd2f3710306cce..ec1693348682457abc3d37507be0785984157e98 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 747eb7aa3384e0e9c2c486a6ee2245c4bfb9c210..ff979961be610940b17fc79bc0c10b065714caaa 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 129114f86fac29eaba1d227ef002015e062b966e..7c697496455ff16cdba2c8e3a05572b776a743a8 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 0b4d386c5eb7da75cddb76107b5d482f6cbd7844..b3f119d22801b8db2a6b0ffb2e42588239d01f7c 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 c2b25bde8fbdf246856f7f925deb83c96ecd31d3..93bf18196d0beb418f7972788b0070d55df3b93c 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 3f57b513afae955128380a203e95c612e23b5b07..710e35610f799a1c78a8450de3e00b4812446428 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 0a4cd8b72bcd6eed32f8d10ab9843876844c627b..e6aa2b0f90bca5441c7bdfc73494d0e182cbb2e4 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 14a653d821ed18d7f326dbcd8880f0e3d5df9164..b1fdea23c244792b15525c0951ef1675d336ac79 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 45dc38472c502ef7b50b720863b44fd9b2df7fa4..69286484daba1de698d362feb0a69ff8163bc641 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 c865c5d7adff26fcd6ee1131e4f6f751a3ac0a6c..ade8d9556fd312b63756b8ee55d1dcce3fb255bb 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 03ae98d6611370f73800a205c7c26fea9b5aae44..a7535b3301b7fb48831633adf5f2e18d9fada632 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 05fa3685fc0ba9629f125248b70630e22fbf8787..e79d15e3084d57328d0c3a83012b4e384a3c3d9e 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 c168aeb842885ca9d3c248cb876d6e8d7b90d560..dca5840cc02c01d7360d652ee1ecbc3e9972d0c8 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 412b0955e2d8c2aeb8e0cf4c349ecf94c863bf80..7fa566503377b5e606400e56d7b1c64ed32ee754 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 d7ec39709a219a70a68148e4d140345db1c5b1b4..b15f55d06e6057b81b3ba12a99bad8493367a4dd 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 2c07788f299d6ea224d3b7d0bb93a5f43c52a2c5..f73ee0939489837f11662a6e7089bd09d0e9fd84 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 59c9d2d5b8cad3a3e4f8b7e347809c057cc24a2c..d799abd280316dafccc2756fe95cc660db705535 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 d04e0116ba03cc6c37e8374d7974f7a9cda2d8c6..8511c0c081d43b60f88a85aa840923031a7f6fa0 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 4b747400619f7c59534ccfaf0cb749a3a3610ea8..7dc4afb27efb7c1570dd7823f5e8f1ca668b2779 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 da61c3b29e4a2336430934e3faaaeb7a711c53c3..1a4fe2acb0a5e4035e2c4270cafce140efc2a69b 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 1e425524b7d7e39e1eb68e9ba873d4f726bbe7dc..534cfa4365b824709743b32b0a733e9b16daf7c7 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 abc6455fb1c27f99e61c5091ffd234a929f2193e..674c75a36f5084a0e8f95df6014af39915a25f83 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 617b9b3e3b709e42295a9c5850e339560ff85e6d..263b793784686d92e266e29b34c58186c01c57df 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,