diff --git a/.eslintrc.js b/.eslintrc.js index ecbdf8bed73adb95b3afc85268186afbfa9439dd..88b5bcd2da30e71fc6f341274fcf999c65197e13 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,14 +1,37 @@ module.exports = { - parser: '@typescript-eslint/parser', // Specifies the ESLint parser extends: [ 'eslint:recommended', 'plugin:react/recommended', // Uses the recommended rules from @eslint-plugin-react 'plugin:react-hooks/recommended', - 'plugin:@typescript-eslint/eslint-recommended', // Uses the recommended rules from @typescript-eslint/eslint-plugin 'prettier', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier 'plugin:prettier/recommended', // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array. ], - plugins: ['@typescript-eslint'], + overrides: [ + { + extends: [ + 'plugin:@typescript-eslint/recommended', + 'plugin:@typescript-eslint/eslint-recommended', // Uses the recommended rules from @typescript-eslint/eslint-plugin + // This enables a lot of type checking + // 'plugin:@typescript-eslint/recommended-requiring-type-checking', // Uses the recommended rules from @typescript-eslint/eslint-plugin + ], + files: ['**/*.{ts,tsx}'], + parserOptions: { + tsconfigRootDir: __dirname, + project: ['./tsconfig.json'], + }, + rules: { + '@typescript-eslint/explicit-function-return-type': 'off', + '@typescript-eslint/no-unused-vars': 'warn', + '@typescript-eslint/no-explicit-any': 'warn', + '@typescript-eslint/prefer-optional-chain': 'warn', + '@typescript-eslint/prefer-as-const': 'error', + '@typescript-eslint/await-thenable': 'error', + '@typescript-eslint/no-var-requires': 'off', + }, + }, + ], + plugins: ['@typescript-eslint', 'react', 'react-hooks'], + parser: '@typescript-eslint/parser', // Specifies the ESLint parser parserOptions: { ecmaVersion: 2020, // Allows for the parsing of modern ECMAScript features sourceType: 'module', // Allows for the use of imports @@ -18,21 +41,17 @@ module.exports = { }, rules: { // Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs - '@typescript-eslint/explicit-function-return-type': 'off', // Note: you must disable the base rule as it can report incorrect errors 'no-unused-vars': 'off', - '@typescript-eslint/no-unused-vars': 'warn', - 'no-case-declarations': 'warn', camelcase: 'warn', 'react/prop-types': 'warn', 'no-console': 'off', - '@typescript-eslint/no-explicit-any': 'warn', - '@typescript-eslint/prefer-optional-chain': 'warn', 'no-param-reassign': 'warn', 'spaced-comment': ['error', 'always', { block: { exceptions: ['*'] } }], 'react/self-closing-comp': 'warn', }, + root: true, settings: { react: { version: 'detect', // Tells eslint-plugin-react to automatically detect the version of React to use diff --git a/src/components/Charts/Bar.tsx b/src/components/Charts/Bar.tsx index cff62d808a3f8a4202478845fd89689bdddaca28..498d72b1200941a2cbef29bf5ccd5a36c68c80d9 100644 --- a/src/components/Charts/Bar.tsx +++ b/src/components/Charts/Bar.tsx @@ -189,7 +189,7 @@ const Bar = ({ className="barContainer" > <rect - onClick={!weekdays ? handleClick : () => {}} + onClick={!weekdays ? handleClick : () => undefined} x="0" y="0" width={showCompare ? getBandWidth() * 2 : getBandWidth()} @@ -252,7 +252,7 @@ const Bar = ({ : 'url(#diagonalHatch)' } // className={isDuel ? 'bar-duel' : barClass} - onClick={!weekdays ? handleClick : () => {}} + onClick={!weekdays ? handleClick : () => undefined} onAnimationEnd={onAnimationEnd} /> </g> @@ -283,7 +283,7 @@ const Bar = ({ )} fill="url(#gradient)" className={isDuel ? 'bar-duel' : barClass} - onClick={!weekdays ? handleClick : () => {}} + onClick={!weekdays ? handleClick : () => undefined} onAnimationEnd={onAnimationEnd} /> </g> diff --git a/src/components/Connection/ConnectionResult.tsx b/src/components/Connection/ConnectionResult.tsx index 9d24e0a0946ccad8efcef0b85eeed225753ea61e..31201f2f77350723a1515d99ca7825c02da392b1 100644 --- a/src/components/Connection/ConnectionResult.tsx +++ b/src/components/Connection/ConnectionResult.tsx @@ -31,7 +31,7 @@ import './connectionResult.scss' interface ConnectionResultProps { fluidStatus: FluidStatus - handleAccountDeletion: Function + handleAccountDeletion: () => Promise<void> fluidType: FluidType } diff --git a/src/components/Connection/FormOAuth.tsx b/src/components/Connection/FormOAuth.tsx index a732fd9602217b91a113405a21be2da274c86e63..af38519e33e05d339147c3ac45297089af4ccae1 100644 --- a/src/components/Connection/FormOAuth.tsx +++ b/src/components/Connection/FormOAuth.tsx @@ -12,7 +12,7 @@ import { setShouldRefreshConsent } from 'store/global/global.actions' interface FormOAuthProps { konnector: Konnector | null - onSuccess: Function + onSuccess: (accountId: string) => Promise<void> fluidStatus: FluidStatus } diff --git a/src/components/Connection/GRDFConnect/GrdfInit.tsx b/src/components/Connection/GRDFConnect/GrdfInit.tsx index 3e580a9f40ee3796252fc15d69e75ddc39ca17bd..4200ad87061c3062113894dbe33deffa7c2111a1 100644 --- a/src/components/Connection/GRDFConnect/GrdfInit.tsx +++ b/src/components/Connection/GRDFConnect/GrdfInit.tsx @@ -15,7 +15,7 @@ import GrdfForm from './GrdfForm' interface GrdfInitProps { fluidStatus: FluidStatus - onSuccess: Function + onSuccess: () => Promise<void> } const GrdfInit: React.FC<GrdfInitProps> = ({ diff --git a/src/components/Ecogesture/EcogestureView.tsx b/src/components/Ecogesture/EcogestureView.tsx index 626ddc4635e43da3dd48983843c89421a9a1c5cb..7b5342b7dadab6fdaacd7fcc741ae00bcee9783d 100644 --- a/src/components/Ecogesture/EcogestureView.tsx +++ b/src/components/Ecogesture/EcogestureView.tsx @@ -110,8 +110,9 @@ const EcogestureView: React.FC = () => { }, []) const handleChange = useCallback( - (event: React.ChangeEvent<{}>, newValue: any) => { + (event: React.ChangeEvent<object>, newValue: number) => { event.preventDefault() + console.log(event) const params = new URLSearchParams() params.append('tab', newValue.toString()) navigate({ search: params.toString() }) diff --git a/src/components/EcogestureForm/EcogestureFormEquipment.tsx b/src/components/EcogestureForm/EcogestureFormEquipment.tsx index 83a2009cadea5160deca61d7eda4fd5f862adb9c..323d4969e2a99263ef24a72a8ef2928c4c372622 100644 --- a/src/components/EcogestureForm/EcogestureFormEquipment.tsx +++ b/src/components/EcogestureForm/EcogestureFormEquipment.tsx @@ -14,13 +14,13 @@ import { newProfileEcogestureEntry, updateProfileEcogesture, } from 'store/profileEcogesture/profileEcogesture.actions' -import './ecogestureFormEquipment.scss' import EquipmentIcon from './EquipmentIcon' +import './ecogestureFormEquipment.scss' interface EcogestureFormEquipmentProps { profileEcogesture: ProfileEcogesture - setPreviousStep: Function - setNextStep?: Function + setPreviousStep: (_profileEcogesture: ProfileEcogesture) => void + setNextStep?: (_profileEcogesture: ProfileEcogesture) => void step: ProfileTypeStepForm | EcogestureStepForm } diff --git a/src/components/EcogestureForm/EcogestureFormSingleChoice.tsx b/src/components/EcogestureForm/EcogestureFormSingleChoice.tsx index dbf9b2fe1956dcfe5ed5cc9c71312f57e7e0abb0..be00ef2afd0dcb148cdc2bbe0bc3cbcd106c7550 100644 --- a/src/components/EcogestureForm/EcogestureFormSingleChoice.tsx +++ b/src/components/EcogestureForm/EcogestureFormSingleChoice.tsx @@ -17,8 +17,8 @@ interface EcogestureFormSingleChoiceProps { viewedStep: EcogestureStepForm profileEcogesture: ProfileEcogesture answerType: ProfileEcogestureAnswer - setNextStep: Function - setPreviousStep: Function + setNextStep: (_profileEcogesture: ProfileEcogesture) => void + setPreviousStep: (_profileEcogesture: ProfileEcogesture) => void } const EcogestureFormSingleChoice: React.FC<EcogestureFormSingleChoiceProps> = ({ diff --git a/src/components/Export/exportDoneModal.spec.tsx b/src/components/Export/exportDoneModal.spec.tsx index ea6d5625d2f9570ca37c5b5486d1f71ff9cf3ed4..b8d12e0a2c8561aea26f48e50859272502084683 100644 --- a/src/components/Export/exportDoneModal.spec.tsx +++ b/src/components/Export/exportDoneModal.spec.tsx @@ -37,7 +37,7 @@ describe('exportDoneModal component', () => { expect(toJson(wrapper)).toMatchSnapshot() }) - it('should display error message', () => {}) + it('should display error message', () => undefined) it('should close modal ', () => { const wrapper = mount( diff --git a/src/components/FormGlobal/FormNavigation.tsx b/src/components/FormGlobal/FormNavigation.tsx index dc4fd447dfefce259af2e3a477d0d9dd5f94688b..00bdd37a0eddc3f13dd6ef1d8873c6b0273f16a3 100644 --- a/src/components/FormGlobal/FormNavigation.tsx +++ b/src/components/FormGlobal/FormNavigation.tsx @@ -10,8 +10,8 @@ import { useNavigate } from 'react-router-dom' interface FormNavigationProps { step: ProfileTypeStepForm | EcogestureStepForm | SgeStep - handlePrevious: Function - handleNext: Function + handlePrevious: () => void + handleNext: () => void disableNextButton: boolean disablePrevButton?: boolean isEcogesture?: boolean diff --git a/src/components/Header/CozyBar.tsx b/src/components/Header/CozyBar.tsx index a05b4b974e3c412a827b5fb1d0867cf05d3be538..add88e786a33ded68d9b21d14db58126f914e862 100644 --- a/src/components/Header/CozyBar.tsx +++ b/src/components/Header/CozyBar.tsx @@ -11,9 +11,9 @@ import { openFeedbackModal } from 'store/modal/modal.slice' declare const cozy: { bar: { - BarLeft: Function - BarCenter: Function - BarRight: Function + BarLeft: React.FC + BarCenter: React.FC + BarRight: React.FC } } diff --git a/src/components/ProfileType/ProfileTypeFormDateSelection.tsx b/src/components/ProfileType/ProfileTypeFormDateSelection.tsx index fecc5e5d6cbe18d3931285a4e7524da678092889..025d2993252d4288bc18949b496b082a6db77016 100644 --- a/src/components/ProfileType/ProfileTypeFormDateSelection.tsx +++ b/src/components/ProfileType/ProfileTypeFormDateSelection.tsx @@ -17,8 +17,8 @@ interface ProfileTypeFormDateSelectionProps { viewedStep: ProfileTypeStepForm profileType: ProfileType answerType: ProfileTypeAnswer - setNextStep: Function - setPreviousStep: Function + setNextStep: (_profileType?: ProfileType) => void + setPreviousStep: (_profileType: ProfileType) => void isProfileTypeComplete: boolean } diff --git a/src/components/ProfileType/ProfileTypeFormMultiChoice.tsx b/src/components/ProfileType/ProfileTypeFormMultiChoice.tsx index ecfac832dd8004cf46fa9366cd7661528c48f067..f1210185c28b2880619f23c54be80c1ef5617264 100644 --- a/src/components/ProfileType/ProfileTypeFormMultiChoice.tsx +++ b/src/components/ProfileType/ProfileTypeFormMultiChoice.tsx @@ -20,8 +20,8 @@ interface ProfileTypeFormMultiChoiceProps { viewedStep: ProfileTypeStepForm profileType: ProfileType answerType: ProfileTypeAnswer - setNextStep: Function - setPreviousStep: Function + setNextStep: (_profileType?: ProfileType) => void + setPreviousStep: (_profileType: ProfileType) => void isProfileTypeComplete: boolean } diff --git a/src/components/ProfileType/ProfileTypeFormNumber.tsx b/src/components/ProfileType/ProfileTypeFormNumber.tsx index 21ee84d9d2716e884a4805971546be7d3f2bdb9c..66e36f2bbe30b49ace38ddbafbedf5e20b75e2c4 100644 --- a/src/components/ProfileType/ProfileTypeFormNumber.tsx +++ b/src/components/ProfileType/ProfileTypeFormNumber.tsx @@ -15,8 +15,8 @@ interface ProfileTypeFormNumberProps { viewedStep: ProfileTypeStepForm profileType: ProfileType answerType: ProfileTypeAnswer - setNextStep: Function - setPreviousStep: Function + setNextStep: (_profileType?: ProfileType) => void + setPreviousStep: (_profileType: ProfileType) => void isProfileTypeComplete: boolean } diff --git a/src/components/ProfileType/ProfileTypeFormNumberSelection.tsx b/src/components/ProfileType/ProfileTypeFormNumberSelection.tsx index 2e3dff0c83fe16508bbca270b0910a702a6e95aa..6a5b5dfd022d0c53522fa168efedb45697ded4ce 100644 --- a/src/components/ProfileType/ProfileTypeFormNumberSelection.tsx +++ b/src/components/ProfileType/ProfileTypeFormNumberSelection.tsx @@ -15,8 +15,8 @@ interface ProfileTypeFormNumberSelectionProps { viewedStep: ProfileTypeStepForm profileType: ProfileType answerType: ProfileTypeAnswer - setNextStep: Function - setPreviousStep: Function + setNextStep: (_profileType?: ProfileType) => void + setPreviousStep: (_profileType: ProfileType) => void isProfileTypeComplete: boolean } diff --git a/src/components/ProfileType/ProfileTypeFormSingleChoice.tsx b/src/components/ProfileType/ProfileTypeFormSingleChoice.tsx index a436afe8191a23b5e7e05a8bcec4d9ba22fffa77..a4fc88272aa457a315d9bbdcc5b450affbe58552 100644 --- a/src/components/ProfileType/ProfileTypeFormSingleChoice.tsx +++ b/src/components/ProfileType/ProfileTypeFormSingleChoice.tsx @@ -16,8 +16,8 @@ interface ProfileTypeFormSingleChoiceProps { viewedStep: ProfileTypeStepForm profileType: ProfileType answerType: ProfileTypeAnswer - setNextStep: Function - setPreviousStep: Function + setNextStep: (_profileType?: ProfileType) => void + setPreviousStep: (_profileType: ProfileType) => void isProfileTypeComplete: boolean } diff --git a/src/migrations/migration.data.ts b/src/migrations/migration.data.ts index 1eb80f0c71c6e1f8d809148a1111ad0fc5d7e59e..ada83c237aafcf36dbcbb8aaca076b2e5e37312d 100644 --- a/src/migrations/migration.data.ts +++ b/src/migrations/migration.data.ts @@ -544,7 +544,7 @@ export const migrations: Migration[] = [ }, redirectLink: '/consumption/electricity', docTypes: '', - run: async (): Promise<any> => {}, + run: async (): Promise<any> => undefined, isEmpty: true, }, { diff --git a/src/targets/services/service.ts b/src/targets/services/service.ts index b9cad1f0e22ab95c13ebbc8f3885a79bf55ffcd7..006947691b5397c0a999736630fbf1a70ed35b2c 100644 --- a/src/targets/services/service.ts +++ b/src/targets/services/service.ts @@ -10,7 +10,7 @@ const assertEnvVar = (varName: string) => { } } -export const runService = (service: Function) => { +export const runService = (service: ({ client }: any) => Promise<void>) => { assertEnvVar('COZY_URL') assertEnvVar('COZY_CREDENTIALS')