diff --git a/.eslintignore b/.eslintignore index 6c5b60674..b517ffe86 100644 --- a/.eslintignore +++ b/.eslintignore @@ -10,5 +10,9 @@ !/*.ts !/*.tsx +# Except for the ESLint & Prettier configs. We can ignore those +.eslintrc.js +.prettierrc.js + # This looks like a generated file src/entities/flanker/ui/HtmlFlanker/visual-stimulus-response.html diff --git a/.eslintrc.js b/.eslintrc.js index 5550e4a64..847feb273 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,52 +1,134 @@ module.exports = { root: true, - extends: '@react-native', - parser: '@typescript-eslint/parser', - plugins: ['@typescript-eslint', 'import'], + parser: '@babel/eslint-parser', + extends: [ + 'eslint:recommended', + '@react-native-community', + 'plugin:react/recommended', + 'prettier' + ], + plugins: ['import', 'react', 'react-hooks', 'unused-imports', 'jest'], + rules: { + 'react/react-in-jsx-scope': 'off', + 'react/no-unstable-nested-components': 'off', + 'react/jsx-newline': [2, { prevent: true, allowMultilines: true }], + 'import/order': [ + 'error', + { + groups: [ + ['external', 'builtin'], + 'internal', + ['sibling', 'parent'], + 'index', + ], + pathGroups: [ + { + pattern: '@(react|react-native)', + group: 'external', + position: 'before', + }, + { + pattern: + '@(@app|@shared|@features|@screens|@entities|@assets|@jobs|@widgets)/**', + group: 'internal', + }, + { + pattern: '@(@images)', + group: 'internal', + position: 'after', + }, + ], + pathGroupsExcludedImportTypes: ['internal', 'react'], + 'newlines-between': 'always', + alphabetize: { + order: 'asc', + caseInsensitive: true, + }, + }, + ], + 'react-hooks/rules-of-hooks': 'warn', + 'import/no-cycle': 'warn', + 'constructor-super': 'warn', + 'no-var': 'warn', + 'no-caller': 'warn', + 'array-callback-return': 'warn', + 'no-eval': 'warn', + 'no-extend-native': 'warn', + eqeqeq: ['warn', 'always'], + 'no-script-url': 'warn', + 'no-self-compare': 'warn', + 'no-sequences': 'warn', + 'no-nested-ternary': 'warn', + 'no-unneeded-ternary': 'warn', + 'no-debugger': 'warn', + 'no-empty': 'warn', + 'no-unused-labels': 'warn', + 'prefer-const': 'warn', + + // Required for unused-imports + 'no-unused-vars': 'off', + 'unused-imports/no-unused-imports': 'warn', + 'unused-imports/no-unused-vars': [ + 'warn', + { + vars: 'all', + varsIgnorePattern: '^_', + args: 'after-used', + argsIgnorePattern: '^_', + }, + ], + 'react-hooks/exhaustive-deps': 'warn', + 'no-case-declarations': 'warn', + 'no-unsafe-optional-chaining': 'warn', + 'react/prop-types': 'warn', + 'react/jsx-key': 'warn', + 'react/jsx-no-duplicate-props': 'warn', + 'react/jsx-no-target-blank': 'warn', + 'react/jsx-no-undef': 'warn', + 'react/no-danger-with-children': 'warn', + 'react/no-deprecated': 'warn', + 'react/no-direct-mutation-state': 'warn', + 'react/no-find-dom-node': 'warn', + 'react/no-is-mounted': 'warn', + 'react/no-unescaped-entities': 'warn', + 'react/no-unknown-property': 'warn', + 'react/no-unsafe': 'warn', + 'react/require-render-return': 'warn', + 'react/display-name': 'off', + }, overrides: [ { files: ['*.ts', '*.tsx'], + parser: '@typescript-eslint/parser', + parserOptions: { + project: './tsconfig.json', + }, + plugins: ['@typescript-eslint'], + extends: [ + 'plugin:@typescript-eslint/eslint-recommended', + 'plugin:@typescript-eslint/recommended-requiring-type-checking', + 'prettier', + ], rules: { - '@typescript-eslint/no-shadow': ['error'], 'no-shadow': 'off', 'no-undef': 'off', - 'react/react-in-jsx-scope': 'off', - 'react/no-unstable-nested-components': 'off', - 'react/jsx-newline': [2, { prevent: true, allowMultilines: true }], - 'import/order': [ - 'error', - { - groups: [ - ['external', 'builtin'], - 'internal', - ['sibling', 'parent'], - 'index', - ], - pathGroups: [ - { - pattern: '@(react|react-native)', - group: 'external', - position: 'before', - }, - { - pattern: - '@(@app|@shared|@features|@screens|@entities|@assets|@jobs|@widgets)/**', - group: 'internal', - }, - { - pattern: '@(@images)', - group: 'internal', - position: 'after', - }, - ], - pathGroupsExcludedImportTypes: ['internal', 'react'], - 'newlines-between': 'always', - alphabetize: { - order: 'asc', - caseInsensitive: true, - }, - }, - ], + '@typescript-eslint/no-shadow': ['error'], + '@typescript-eslint/no-non-null-assertion': 'warn', + '@typescript-eslint/no-explicit-any': 'warn', + '@typescript-eslint/no-duplicate-enum-values': 'warn', + '@typescript-eslint/no-floating-promises': 'warn', + '@typescript-eslint/no-unsafe-argument': 'warn', + '@typescript-eslint/no-unsafe-assignment': 'warn', + '@typescript-eslint/no-unsafe-member-access': 'warn', + '@typescript-eslint/no-unsafe-call': 'warn', + '@typescript-eslint/require-await': 'warn', + '@typescript-eslint/no-misused-promises': 'warn', + '@typescript-eslint/await-thenable': 'warn', + '@typescript-eslint/unbound-method': 'warn', + '@typescript-eslint/restrict-plus-operands': 'warn', + '@typescript-eslint/no-unsafe-return': 'warn', + '@typescript-eslint/restrict-template-expressions': 'warn', + '@typescript-eslint/no-unused-vars': 'off', }, }, ], diff --git a/.prettierignore b/.prettierignore index 898d6dcfa..c1a7cb47e 100644 --- a/.prettierignore +++ b/.prettierignore @@ -8,5 +8,8 @@ !/*.js !/*.ts +# Except for the ESLint config itself. We can ignore that +.eslintrc.js + # This looks like a generated file src/entities/flanker/ui/HtmlFlanker/visual-stimulus-response.html diff --git a/index.js b/index.js index c6680611e..7a2038dd8 100644 --- a/index.js +++ b/index.js @@ -2,14 +2,14 @@ import 'react-native-gesture-handler'; import { AppRegistry } from 'react-native'; -import { jobRunner } from './src/shared/lib'; +import { name as appName } from './app.json'; +import App from './src/app'; +import displayRemoteNotifications from './src/jobs/display-remote-notifications'; +import localization from './src/jobs/localization'; import requestInterception from './src/jobs/request-interception'; import responseInterception from './src/jobs/response-interception'; import setBackgroundTask from './src/jobs/set-background-task'; -import displayRemoteNotifications from './src/jobs/display-remote-notifications'; -import localization from './src/jobs/localization'; -import App from './src/app'; -import { name as appName } from './app.json'; +import { jobRunner } from './src/shared/lib'; jobRunner.runAll([ requestInterception, diff --git a/jest.components.jsx b/jest.components.jsx index b967de778..34ed4d9b2 100644 --- a/jest.components.jsx +++ b/jest.components.jsx @@ -1,6 +1,7 @@ -import { jest } from '@jest/globals'; import React from 'react'; +import { jest } from '@jest/globals'; + jest.mock('@georstat/react-native-image-cache', () => { return { CachedImage: () => <>, diff --git a/package.json b/package.json index c878bf0a1..57cd8ae5c 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,10 @@ "start": "react-native start", "test": "jest --noStackTrace", "lint": "eslint . --ext .js,.jsx,.ts,.tsx", + "lint:check": "yarn lint", + "lint:fix": "yarn lint --fix", + "prettier:check": "prettier '**/*.{js,jsx,ts,tsx}' --check", + "prettier:fix": "prettier '**/*.{js,jsx,ts,tsx}' --write", "pods": "bundle exec pod install --project-directory=ios", "prepare": "husky install", "postinstall": "yarn patch-package", @@ -123,6 +127,7 @@ }, "devDependencies": { "@babel/core": "^7.20.0", + "@babel/eslint-parser": "^7.23.10", "@babel/plugin-proposal-export-namespace-from": "^7.18.9", "@babel/preset-env": "^7.20.0", "@babel/runtime": "^7.20.0", @@ -146,12 +151,18 @@ "babel-jest": "^29.6.3", "babel-plugin-module-resolver": "^5.0.0", "babel-plugin-transform-inline-environment-variables": "^0.4.4", - "eslint": "^8.19.0", + "eslint": "^8.50.0", "eslint-plugin-import": "^2.29.1", + "eslint-plugin-jest": "^27.6.3", + "eslint-plugin-only-warn": "^1.1.0", + "eslint-plugin-prettier": "^5.1.3", + "eslint-plugin-react": "^7.33.2", + "eslint-plugin-react-hooks": "^4.6.0", + "eslint-plugin-unused-imports": "^3.0.0", "husky": "^8.0.3", "jest": "^29.6.3", "lint-staged": "^15.2.0", - "prettier": "2.8.8", + "prettier": "^3.2.5", "react-native-mmkv-flipper-plugin": "^1.0.0", "react-query-native-devtools": "^4.0.0", "react-test-renderer": "18.2.0", @@ -173,4 +184,4 @@ "resolutions": { "react": "18.2.0" } -} \ No newline at end of file +} diff --git a/src/abstract/lib/utils/progressConvert.ts b/src/abstract/lib/utils/progressConvert.ts index 6ae2d423c..119585b2a 100644 --- a/src/abstract/lib/utils/progressConvert.ts +++ b/src/abstract/lib/utils/progressConvert.ts @@ -13,20 +13,20 @@ import { export const convertProgress = (storeProgress: StoreProgress): Progress => { const result: Progress = {}; - for (let appletId in storeProgress) { + for (const appletId in storeProgress) { if (!result[appletId]) { result[appletId] = {}; } const entitiesProgress: StoreEntitiesProgress = storeProgress[appletId]; - for (let entityId in entitiesProgress) { + for (const entityId in entitiesProgress) { if (!result[appletId][entityId]) { result[appletId][entityId] = {}; } const eventsProgress: StoreEventsProgress = entitiesProgress[entityId]; - for (let eventId in eventsProgress) { + for (const eventId in eventsProgress) { const storePayload: StoreProgressPayload = eventsProgress[eventId]; const flowProgress = storePayload as FlowProgress; diff --git a/src/app/model/migrations/MigrationProcessor.ts b/src/app/model/migrations/MigrationProcessor.ts index d2a2981ed..1bbc2b1c0 100644 --- a/src/app/model/migrations/MigrationProcessor.ts +++ b/src/app/model/migrations/MigrationProcessor.ts @@ -41,7 +41,7 @@ export class MigrationProcessor { private getMigrationInput(): MigrationInput { // @ts-ignore - // eslint-disable-next-line @typescript-eslint/no-unused-vars + const { _persist, ...reduxState } = this.reduxStore.getState(); return { @@ -60,12 +60,12 @@ export class MigrationProcessor { private updateStorages() { const storageNames = StoragesArray; - for (let storageName of storageNames) { + for (const storageName of storageNames) { const migrationStorage = createMigrationStorage(storageName); const regularStorage = createRegularStorage(storageName); const keys = migrationStorage.getAllKeys(); - for (let key of keys) { + for (const key of keys) { const value = migrationStorage.getString(key)!; regularStorage.set(key, value); } @@ -81,7 +81,7 @@ export class MigrationProcessor { private prepareStorages() { const storageNames = StoragesArray; - for (let storageName of storageNames) { + for (const storageName of storageNames) { const storage = createMigrationStorage(storageName); storage.clearAll(); } diff --git a/src/app/model/migrations/MigrationRunner.ts b/src/app/model/migrations/MigrationRunner.ts index 12f4db068..dbe4422a8 100644 --- a/src/app/model/migrations/MigrationRunner.ts +++ b/src/app/model/migrations/MigrationRunner.ts @@ -29,7 +29,7 @@ export class MigrationRunner implements IMigrationRunner { currentVersion: number, inboundVersion: number, ): Promise { - let migrationKeys = this.getMigrationKeys(currentVersion, inboundVersion); + const migrationKeys = this.getMigrationKeys(currentVersion, inboundVersion); Logger.log( `[MigrationRunner]: migrationKeys: [${migrationKeys}]${ diff --git a/src/app/model/migrations/migrations/to0001/MigrationToVersion0001.ts b/src/app/model/migrations/migrations/to0001/MigrationToVersion0001.ts index ec29a8886..137894d9e 100644 --- a/src/app/model/migrations/migrations/to0001/MigrationToVersion0001.ts +++ b/src/app/model/migrations/migrations/to0001/MigrationToVersion0001.ts @@ -105,7 +105,7 @@ export class MigrationToVersion0001 implements IMigration { const eventDto = eventDtos.find(e => e.id === eventId); - flowStateTo.flowName = activityFlowDto!.name; + flowStateTo.flowName = activityFlowDto.name; if (eventDto) { flowStateTo.scheduledDate = @@ -114,7 +114,7 @@ export class MigrationToVersion0001 implements IMigration { Logger.warn("'[MigrationToVersion0001]: Event doesn't exist: " + eventId); } - for (let pipelineItem of flowStateTo.pipeline) { + for (const pipelineItem of flowStateTo.pipeline) { const activityDto = appletDto.activities.find( a => a.id === pipelineItem.payload.activityId, ); @@ -150,7 +150,7 @@ export class MigrationToVersion0001 implements IMigration { const progressFlowsFrom = selectNotCompletedFlows(reduxRootStateFrom); - for (let progressFlowFrom of progressFlowsFrom) { + for (const progressFlowFrom of progressFlowsFrom) { const { appletId, flowId: entityId, eventId, payload } = progressFlowFrom; let logAppletName = '', diff --git a/src/app/model/migrations/migrations/to0001/MigrationUtils0001.ts b/src/app/model/migrations/migrations/to0001/MigrationUtils0001.ts index bd1e1579f..dd17755b9 100644 --- a/src/app/model/migrations/migrations/to0001/MigrationUtils0001.ts +++ b/src/app/model/migrations/migrations/to0001/MigrationUtils0001.ts @@ -51,17 +51,17 @@ export const selectNotCompletedFlows = ( const appletIds = Object.keys(inProgressApplets); - for (let appletId of appletIds) { + for (const appletId of appletIds) { const progressEntities = inProgressApplets[appletId] ?? {}; const entityIds = Object.keys(progressEntities); - for (let entityId of entityIds) { + for (const entityId of entityIds) { const progressEvents = progressEntities[entityId] ?? {}; const eventIds = Object.keys(progressEvents); - for (let eventId of eventIds) { + for (const eventId of eventIds) { const payload = progressEvents[eventId] ?? {}; if ( @@ -153,7 +153,7 @@ export const getUpdatedReduxState = ( }, }; - for (let flow of progressFlowsTo) { + for (const flow of progressFlowsTo) { result = { ...result, applets: { diff --git a/src/entities/abTrail/ui/AbShapes.tsx b/src/entities/abTrail/ui/AbShapes.tsx index e4922e095..20f9ea445 100644 --- a/src/entities/abTrail/ui/AbShapes.tsx +++ b/src/entities/abTrail/ui/AbShapes.tsx @@ -92,7 +92,7 @@ const AbShapes: FC = props => { const endOffset = getEndOffset(); - let errorMiddlePoint: Point | null = errorPath + const errorMiddlePoint: Point | null = errorPath ? getEquidistantPoint(errorPath) : null; @@ -119,7 +119,7 @@ const AbShapes: FC = props => { x={errorMiddlePoint.x + CrossOffsetX} y={errorMiddlePoint.y} text={'x'} - font={fontCross!} + font={fontCross} color={colors.red} /> diff --git a/src/entities/activity/lib/services/AnswersUploadService.test.js b/src/entities/activity/lib/services/AnswersUploadService.test.js index e9f2cb373..2ef368c28 100644 --- a/src/entities/activity/lib/services/AnswersUploadService.test.js +++ b/src/entities/activity/lib/services/AnswersUploadService.test.js @@ -1,9 +1,10 @@ -import { AnswerService } from '@shared/api'; import { FileSystem } from 'react-native-file-access'; +import { AnswerService } from '@shared/api'; + import AnswersUploadService from './AnswersUploadService'; -import { UserPrivateKeyRecord } from '../../../identity'; import MediaFilesCleaner from './MediaFilesCleaner'; +import { UserPrivateKeyRecord } from '../../../identity'; const MOCK_CREATED_AT = +new Date(); diff --git a/src/entities/activity/lib/services/AnswersUploadService.ts b/src/entities/activity/lib/services/AnswersUploadService.ts index 53a693710..9876de0f6 100644 --- a/src/entities/activity/lib/services/AnswersUploadService.ts +++ b/src/entities/activity/lib/services/AnswersUploadService.ts @@ -180,8 +180,7 @@ class AnswersUploadService implements IAnswersUploadService { return remoteUrl!; } catch (error) { throw new Error( - `[UploadAnswersService.processFileUpload]: Error occurred while file ${logFileInfo} uploading\n\n` + - error!.toString(), + `[UploadAnswersService.processFileUpload]: Error occurred while file ${logFileInfo} uploading\n\n${error}`, ); } } @@ -211,8 +210,7 @@ class AnswersUploadService implements IAnswersUploadService { uploadChecks = await this.checkIfFilesUploaded(fileIds, body.appletId); } catch (error) { throw new Error( - '[UploadAnswersService.uploadAllMediaFiles]: Error occurred on 1st files upload check\n\n' + - error!.toString(), + `[UploadAnswersService.uploadAllMediaFiles]: Error occurred on 1st files upload check\n\n${error}`, ); } @@ -266,8 +264,7 @@ class AnswersUploadService implements IAnswersUploadService { uploadChecks = await this.checkIfFilesUploaded(fileIds, body.appletId); } catch (error) { throw new Error( - '[uploadAnswerMediaFiles.uploadAllMediaFiles]: Error occurred while 2nd files upload check\n\n' + - error!.toString(), + `[uploadAnswerMediaFiles.uploadAllMediaFiles]: Error occurred while 2nd files upload check\n\n${error}`, ); } @@ -298,8 +295,7 @@ class AnswersUploadService implements IAnswersUploadService { }); } catch (error) { throw new Error( - '[UploadAnswersService.uploadAnswers]: Error occurred while 1st check if answers uploaded\n\n' + - error!.toString(), + `[UploadAnswersService.uploadAnswers]: Error occurred while 1st check if answers uploaded\n\n${error}`, ); } @@ -318,8 +314,7 @@ class AnswersUploadService implements IAnswersUploadService { await AnswerService.sendActivityAnswers(encryptedData); } catch (error) { throw new Error( - '[UploadAnswersService.uploadAnswers]: Error occurred while sending answers\n\n' + - error!.toString(), + `[UploadAnswersService.uploadAnswers]: Error occurred while sending answers\n\n${error}`, ); } @@ -332,8 +327,7 @@ class AnswersUploadService implements IAnswersUploadService { }); } catch (error) { throw new Error( - '[UploadAnswersService.uploadAnswers]: Error occurred while 2nd check if answers uploaded\n\n' + - error!.toString(), + `[UploadAnswersService.uploadAnswers]: Error occurred while 2nd check if answers uploaded\n\n${error}`, ); } @@ -453,8 +447,7 @@ class AnswersUploadService implements IAnswersUploadService { return processUserActions(); } catch (error) { throw new Error( - '[UploadAnswersService.assignRemoteUrlsToUserActions]: Error occurred while mapping user actions with media files\n\n' + - error!.toString(), + `[UploadAnswersService.assignRemoteUrlsToUserActions]: Error occurred while mapping user actions with media files\n\n${error}`, ); } } diff --git a/src/entities/activity/lib/services/MediaFilesCleaner.ts b/src/entities/activity/lib/services/MediaFilesCleaner.ts index 69fdea0b0..330ea6b1d 100644 --- a/src/entities/activity/lib/services/MediaFilesCleaner.ts +++ b/src/entities/activity/lib/services/MediaFilesCleaner.ts @@ -30,7 +30,7 @@ const createMediaFilesCleaner = (): Result => { const urlsToProcess: string[] = []; - for (let recordId in entityRecord.answers) { + for (const recordId in entityRecord.answers) { const record = entityRecord.answers[recordId]?.answer; if (record?.uri) { @@ -38,7 +38,7 @@ const createMediaFilesCleaner = (): Result => { } } - for (let fileUrl of urlsToProcess) { + for (const fileUrl of urlsToProcess) { try { const fileExists = await FileSystem.exists(fileUrl); diff --git a/src/entities/activity/lib/services/QueueProcessingService.ts b/src/entities/activity/lib/services/QueueProcessingService.ts index 435866b13..fc645026d 100644 --- a/src/entities/activity/lib/services/QueueProcessingService.ts +++ b/src/entities/activity/lib/services/QueueProcessingService.ts @@ -119,8 +119,7 @@ class QueueProcessingService implements IPushToQueue { return success; } catch (error) { this.logger.warn( - '[QueueProcessingService.process]: Error in processInternal occurred\n\n' + - error!.toString(), + `[QueueProcessingService.process]: Error in processInternal occurred\n\n${error}`, ); this.uploadStatusObservable.isError = true; } finally { diff --git a/src/entities/activity/model/services/EntityActivitiesCollector.ts b/src/entities/activity/model/services/EntityActivitiesCollector.ts index 9a1603fdc..39e16ebc9 100644 --- a/src/entities/activity/model/services/EntityActivitiesCollector.ts +++ b/src/entities/activity/model/services/EntityActivitiesCollector.ts @@ -50,7 +50,7 @@ const createEntityActivitiesCollector = (): EntityActivitiesCollector => { const activityIds: string[] = flowDto!.activityIds; - for (let activityId of activityIds) { + for (const activityId of activityIds) { addActivity(activityId); } } diff --git a/src/entities/activity/ui/ActivityFlowStep.tsx b/src/entities/activity/ui/ActivityFlowStep.tsx index 9d55dd5bf..a68514c23 100644 --- a/src/entities/activity/ui/ActivityFlowStep.tsx +++ b/src/entities/activity/ui/ActivityFlowStep.tsx @@ -33,7 +33,7 @@ const ActivityFlowStep: FC = props => { accessibilityLabel="activity-card-flow" opacity={hasOpacity ? 0.5 : 1} > - {`(${activityPositionInFlow!} of ${numberOfActivitiesInFlow!}) ${activityFlowName}`} + {`(${activityPositionInFlow} of ${numberOfActivitiesInFlow}) ${activityFlowName}`} ); diff --git a/src/entities/applet/model/hooks/useStartEntity.ts b/src/entities/applet/model/hooks/useStartEntity.ts index 85f43f9c4..fe171d9b5 100644 --- a/src/entities/applet/model/hooks/useStartEntity.ts +++ b/src/entities/applet/model/hooks/useStartEntity.ts @@ -230,14 +230,14 @@ function useStartEntity({ 'regular', ); - let isActivityInProgress = await evaluateProgressWithAutocompletion( + const isActivityInProgress = await evaluateProgressWithAutocompletion( appletId, activityId, eventId, 'regular', ); - return new Promise(async resolve => { + return new Promise(resolve => { if (!MigrationValidator.allMigrationHaveBeenApplied()) { onMigrationsNotApplied(); resolve({ @@ -355,7 +355,7 @@ function useStartEntity({ const getFlowActivities = (): string[] => { const activityFlowDtos: ActivityFlowRecordDto[] = detailsResponse.result.activityFlows; - const flow = activityFlowDtos!.find(x => x.id === flowId)!; + const flow = activityFlowDtos.find(x => x.id === flowId)!; return flow.activityIds; }; @@ -378,7 +378,7 @@ function useStartEntity({ 'flow', ); - let isFlowInProgress = await evaluateProgressWithAutocompletion( + const isFlowInProgress = await evaluateProgressWithAutocompletion( appletId, flowId, eventId, diff --git a/src/entities/applet/model/selectors.ts b/src/entities/applet/model/selectors.ts index 8dc41a976..ec3a9746a 100644 --- a/src/entities/applet/model/selectors.ts +++ b/src/entities/applet/model/selectors.ts @@ -57,18 +57,18 @@ export const selectNotCompletedEntities = createSelector( const appletIds = Object.keys(inProgressApplets); - for (let appletId of appletIds) { + for (const appletId of appletIds) { const progressEntities: StoreEntitiesProgress = inProgressApplets[appletId]; const entityIds = Object.keys(progressEntities); - for (let entityId of entityIds) { + for (const entityId of entityIds) { const progressEvents: StoreEventsProgress = progressEntities[entityId]; const eventIds = Object.keys(progressEvents); - for (let eventId of eventIds) { + for (const eventId of eventIds) { const payload: StoreProgressPayload = progressEvents[eventId]; if (payload.endAt) { diff --git a/src/entities/applet/model/services/RefreshAppletService.ts b/src/entities/applet/model/services/RefreshAppletService.ts index 12baa39b6..63a9c51fe 100644 --- a/src/entities/applet/model/services/RefreshAppletService.ts +++ b/src/entities/applet/model/services/RefreshAppletService.ts @@ -59,7 +59,7 @@ class RefreshAppletService implements IRefreshAppletService { }; private cacheImages(urls: ImageUrl[]) { - for (let url of urls) { + for (const url of urls) { try { if (!this.isUrlValid(url)) { continue; @@ -102,7 +102,7 @@ class RefreshAppletService implements IRefreshAppletService { ) { this.resetAppletDetailsQuery(appletInternalDtos.appletId); - for (let activityDto of appletInternalDtos.activities) { + for (const activityDto of appletInternalDtos.activities) { this.resetActivityDetailsQuery(activityDto.id); const activityKey = getActivityDetailsKey(activityDto.id); diff --git a/src/entities/applet/model/services/RefreshService.ts b/src/entities/applet/model/services/RefreshService.ts index f77d7e91c..4d45b59d2 100644 --- a/src/entities/applet/model/services/RefreshService.ts +++ b/src/entities/applet/model/services/RefreshService.ts @@ -150,7 +150,7 @@ class RefreshService implements IRefreshService { const unsuccessfulApplets: UnsuccessfulApplet[] = []; - for (let appletDto of appletDtos) { + for (const appletDto of appletDtos) { try { await this.refreshAppletService.refreshApplet( appletDto, @@ -222,8 +222,7 @@ class RefreshService implements IRefreshService { this.logger.log('[RefreshService.refresh]: Completed'); } catch (error) { this.logger.warn( - '[RefreshService.process]: Error occurred:\nInternal error:\n\n' + - error!.toString(), + `[RefreshService.process]: Error occurred:\nInternal error:\n\n${error}`, ); } finally { RefreshService.mutex.release(); diff --git a/src/entities/drawer/lib/utils/helpers.ts b/src/entities/drawer/lib/utils/helpers.ts index 9183d29b7..867044dce 100644 --- a/src/entities/drawer/lib/utils/helpers.ts +++ b/src/entities/drawer/lib/utils/helpers.ts @@ -10,9 +10,9 @@ export const getChunkedPointsAsStrings = (lines: DrawLine[]) => { const results: string[] = []; const chunkSize: number = 50; - for (let line of lines) { + for (const line of lines) { const { points } = line; - let { length } = points; + const { length } = points; for (let index = 0; index < length; index += chunkSize) { const myChunk = line.points.slice(index, index + chunkSize + 1); diff --git a/src/entities/drawer/ui/DrawingBoard.tsx b/src/entities/drawer/ui/DrawingBoard.tsx index f32f4eac5..8d37d7c69 100644 --- a/src/entities/drawer/ui/DrawingBoard.tsx +++ b/src/entities/drawer/ui/DrawingBoard.tsx @@ -48,7 +48,7 @@ const DrawingBoard: FC = props => { startTime: Date.now(), points: [drawPoint], }; - const logPoint = drawPoint.scale(vector) as DrawPoint; + const logPoint = drawPoint.scale(vector); onLog({ ...logPoint, lineNumber: value?.length, type: 'DrawingTest' }); }; diff --git a/src/entities/drawer/ui/DrawingTest.tsx b/src/entities/drawer/ui/DrawingTest.tsx index 9dd83aa52..1dae6639b 100644 --- a/src/entities/drawer/ui/DrawingTest.tsx +++ b/src/entities/drawer/ui/DrawingTest.tsx @@ -32,7 +32,7 @@ const DrawingTest: FC = props => { const { value, backgroundImageUrl, imageUrl, onLog } = props; const onResult = async (result: DrawResult) => { - let fileName = value.fileName; + const fileName = value.fileName; const fileMeta = SvgFileManager.getFileMeta(fileName); @@ -87,7 +87,7 @@ const canvasStyles = (canvasSize: number) => position: 'absolute', width: canvasSize, height: canvasSize, - } as const); + }) as const; const styles = StyleSheet.create({ exampleImage: { diff --git a/src/entities/event/model/operations/ScheduledDateCalculator.test.js b/src/entities/event/model/operations/ScheduledDateCalculator.test.js index 250e6232b..eaa6c428d 100644 --- a/src/entities/event/model/operations/ScheduledDateCalculator.test.js +++ b/src/entities/event/model/operations/ScheduledDateCalculator.test.js @@ -1,4 +1,5 @@ import { addDays, startOfDay, subDays } from 'date-fns'; + import ScheduledDateCalculator from './ScheduledDateCalculator'; const now = new Date(2024, 0, 25); @@ -564,7 +565,7 @@ describe('ScheduledDateCalculator', () => { event.availability.startDate = new Date(wednesday); event.availability.endDate = addDays(wednesday, 30); - let getNowMock = jest.fn(() => { + const getNowMock = jest.fn(() => { return new Date(wednesday); }); @@ -592,7 +593,7 @@ describe('ScheduledDateCalculator', () => { event.availability.startDate = new subDays(new Date(wednesday), 30); event.availability.endDate = new Date(wednesday); - let getNowMock = jest.fn(() => { + const getNowMock = jest.fn(() => { return new Date(wednesday); }); @@ -620,7 +621,7 @@ describe('ScheduledDateCalculator', () => { event.availability.startDate = new addDays(new Date(wednesday), 10); event.availability.endDate = addDays(wednesday, 30); - let getNowMock = jest.fn(() => { + const getNowMock = jest.fn(() => { return new Date(wednesday); }); @@ -649,7 +650,7 @@ describe('ScheduledDateCalculator', () => { event.availability.startDate = new subDays(new Date(wednesday), 30); event.availability.endDate = subDays(wednesday, 10); - let getNowMock = jest.fn(() => { + const getNowMock = jest.fn(() => { return new Date(wednesday); }); diff --git a/src/entities/event/model/operations/ScheduledDateCalculator.ts b/src/entities/event/model/operations/ScheduledDateCalculator.ts index 7559292ac..ea11cba20 100644 --- a/src/entities/event/model/operations/ScheduledDateCalculator.ts +++ b/src/entities/event/model/operations/ScheduledDateCalculator.ts @@ -40,7 +40,7 @@ export class ScheduledDateCalculator { ): Date | null { const today = startOfDay(this.getNow()); - let date = new Date(selectedDate!); + let date = new Date(selectedDate); if (selectedDate > today) { let months = 0; @@ -82,13 +82,13 @@ export class ScheduledDateCalculator { const selectedMonth = specificDay.getMonth(); const selectedDay = specificDay.getDate(); - const result = new Date(selectedYear!, selectedMonth!, selectedDay!); + const result = new Date(selectedYear, selectedMonth, selectedDay); this.setTime(result, availability); return result; } private calculateScheduledAt(event: ScheduleEvent): Date | null { - let { availability, selectedDate } = event; + const { availability, selectedDate } = event; const now = this.getNow(); @@ -116,7 +116,7 @@ export class ScheduledDateCalculator { return this.calculateForMonthly(selectedDate!, availability); } - let parseInput: EventParseInput = {}; + const parseInput: EventParseInput = {}; if (availability.periodicityType === PeriodicityType.Weekly) { const dayOfWeek = selectedDate!.getDay(); @@ -134,7 +134,7 @@ export class ScheduledDateCalculator { parseInput.end = endOfDay.getTime(); } - const parsedSchedule = Parse.schedule(parseInput!); + const parsedSchedule = Parse.schedule(parseInput); const fromDate = Day.fromDate(now); diff --git a/src/entities/flanker/lib/utils/helpers.ts b/src/entities/flanker/lib/utils/helpers.ts index 3d86a16c6..6402e1712 100644 --- a/src/entities/flanker/lib/utils/helpers.ts +++ b/src/entities/flanker/lib/utils/helpers.ts @@ -24,8 +24,8 @@ export const parseResponse = (data: { responseTouchTimestamp: !isWebView ? record.response_touch_timestamp : record.rt - ? record.start_timestamp + record.rt - : null, + ? record.start_timestamp + record.rt + : null, }; return parseResponseResult; diff --git a/src/entities/notification/lib/services/filterNotifications.ts b/src/entities/notification/lib/services/filterNotifications.ts index e912e9b2e..0f7631cd6 100644 --- a/src/entities/notification/lib/services/filterNotifications.ts +++ b/src/entities/notification/lib/services/filterNotifications.ts @@ -7,10 +7,10 @@ import { export const filterNotifications = ( appletNotifications: AppletNotificationDescribers, ): Array => { - let result: Array = []; + const result: Array = []; - for (let eventNotifications of appletNotifications.events) { - for (let notification of eventNotifications.notifications) { + for (const eventNotifications of appletNotifications.events) { + for (const notification of eventNotifications.notifications) { if (notification.isActive) { result.push(notification); } @@ -39,7 +39,7 @@ export const filterAppletNotifications = ( events: [], }; - for (let eventNotifications of appletNotifications.events) { + for (const eventNotifications of appletNotifications.events) { const eventsClone: EventNotificationDescribers = { ...eventNotifications, notifications: [], diff --git a/src/entities/notification/model/NotificationManager.ts b/src/entities/notification/model/NotificationManager.ts index 55c27630a..fba360a0a 100644 --- a/src/entities/notification/model/NotificationManager.ts +++ b/src/entities/notification/model/NotificationManager.ts @@ -37,7 +37,7 @@ function NotificationManager() { notificationsToSchedule, ); - for (let notification of triggerNotifications) { + for (const notification of triggerNotifications) { await NotificationScheduler.scheduleLocalNotification(notification); } @@ -126,7 +126,7 @@ function NotificationManager() { } }; - for (let notification of notificationsForEventId) { + for (const notification of notificationsForEventId) { cancelNotificationForEventEntityInTimeInterval(notification); } } diff --git a/src/entities/notification/model/NotificationRefreshService.ts b/src/entities/notification/model/NotificationRefreshService.ts index 8d66efdc5..3d25ea60b 100644 --- a/src/entities/notification/model/NotificationRefreshService.ts +++ b/src/entities/notification/model/NotificationRefreshService.ts @@ -93,7 +93,7 @@ const createNotificationRefreshService = ( const allNotificationDescribers: NotificationDescriber[] = []; - for (let applet of applets) { + for (const applet of applets) { const detailsResponse = getDataFromQuery( getAppletDetailsKey(applet.id), queryClient, @@ -141,7 +141,7 @@ const createNotificationRefreshService = ( const calculator = EventModel.ScheduledDateCalculator; - for (let eventEntity of entityEvents) { + for (const eventEntity of entityEvents) { const date = calculator.calculate(eventEntity.event); eventEntity.event.scheduledAt = date; } @@ -214,8 +214,7 @@ const createNotificationRefreshService = ( ); } catch (error) { logger.log( - '[NotificationRefreshService.refresh]: Notifications rescheduling failed\n\n' + - error!.toString(), + `[NotificationRefreshService.refresh]: Notifications rescheduling failed\n\n${error}`, ); } finally { NotificationManager.mutex.release(); diff --git a/src/entities/notification/model/factory/NotificationBuilder.ts b/src/entities/notification/model/factory/NotificationBuilder.ts index 4e873e0d0..3bd07afa4 100644 --- a/src/entities/notification/model/factory/NotificationBuilder.ts +++ b/src/entities/notification/model/factory/NotificationBuilder.ts @@ -102,7 +102,7 @@ class NotificationBuilder implements INotificationBuilder { const isSpread = this.utility.isSpreadToNextDay(event); - for (let eventNotification of eventNotifications) { + for (const eventNotification of eventNotifications) { const { from, to, at, triggerType } = eventNotification; let triggerAt: Date; @@ -124,7 +124,7 @@ class NotificationBuilder implements INotificationBuilder { day, from!, to!, - randomBorderType!, + randomBorderType, ); if (!triggerAt) { @@ -306,7 +306,7 @@ class NotificationBuilder implements INotificationBuilder { ...reminderFromPastDays.map(x => x.reminder), ); - for (let day of eventDays) { + for (const day of eventDays) { const notifications = this.processEventDay(day, event, entity); eventResult.notifications.push(...notifications); @@ -319,7 +319,7 @@ class NotificationBuilder implements INotificationBuilder { } if (this.keepDebugData) { - for (let notification of eventResult.notifications) { + for (const notification of eventResult.notifications) { notification.toString_Debug = JSON.stringify(notification, null, 2); notification.scheduledEvent_Debug = event; notification.scheduledEventString_Debug = JSON.stringify( @@ -338,7 +338,7 @@ class NotificationBuilder implements INotificationBuilder { public build(): AppletNotificationDescribers { const eventNotificationsResult: Array = []; - for (let eventEntity of this.eventEntities) { + for (const eventEntity of this.eventEntities) { try { const eventNotifications = this.processEvent( eventEntity.event, @@ -347,8 +347,7 @@ class NotificationBuilder implements INotificationBuilder { eventNotificationsResult.push(eventNotifications); } catch (error: any) { console.error( - `[NotificationBuilder.build] Error occurred during process event: "${eventEntity.event.id}", entity: "${eventEntity.entity?.name}" :\n\n` + - error.toString(), + `[NotificationBuilder.build] Error occurred during process event: "${eventEntity.event.id}", entity: "${eventEntity.entity?.name}" :\n\n${error}`, ); } } diff --git a/src/entities/notification/model/factory/NotificationUtility.ts b/src/entities/notification/model/factory/NotificationUtility.ts index a7fb1e40d..0f2a55537 100644 --- a/src/entities/notification/model/factory/NotificationUtility.ts +++ b/src/entities/notification/model/factory/NotificationUtility.ts @@ -189,7 +189,7 @@ export class NotificationUtility { bordersType === 'both-in-current-day' || bordersType === 'both-in-next-day' ) { - let diff = getDiff(from, to); + const diff = getDiff(from, to); const randomValueToAdd = this.getRandomInt(diff); @@ -205,7 +205,7 @@ export class NotificationUtility { } if (bordersType === 'from-current-to-next') { - let diff = getDiff(from!, to!); + let diff = getDiff(from, to); diff = getMsFromHours(24) + diff; diff --git a/src/entities/notification/model/factory/ReminderCreator.ts b/src/entities/notification/model/factory/ReminderCreator.ts index a998bd744..730a1a1bf 100644 --- a/src/entities/notification/model/factory/ReminderCreator.ts +++ b/src/entities/notification/model/factory/ReminderCreator.ts @@ -156,7 +156,7 @@ export class ReminderCreator { event, ); - for (let day of reminderDays) { + for (const day of reminderDays) { const reminder: NotificationDescriber = this.createReminder( day, entity, diff --git a/src/entities/notification/model/factory/tests/NotificationBuilder.alwaysAvailable.test.ts b/src/entities/notification/model/factory/tests/NotificationBuilder.alwaysAvailable.test.ts index bcfd2187f..ee5cfd111 100644 --- a/src/entities/notification/model/factory/tests/NotificationBuilder.alwaysAvailable.test.ts +++ b/src/entities/notification/model/factory/tests/NotificationBuilder.alwaysAvailable.test.ts @@ -119,8 +119,8 @@ const addReminder = ( activityIncompleteDays === 0 ? 'current-day' : activityIncompleteDays === 1 - ? 'next-day' - : 'in-future', + ? 'next-day' + : 'in-future', type: NotificationType.Reminder, notificationBody: 'Just a kindly reminder to complete the activity', }; @@ -133,8 +133,8 @@ const addReminder = ( inactiveReason === 'invalid-period' ? InactiveReason.FallOnInvalidPeriod : inactiveReason === 'outdated' - ? InactiveReason.Outdated - : InactiveReason.NotDefined, + ? InactiveReason.Outdated + : InactiveReason.NotDefined, }; } diff --git a/src/entities/notification/model/factory/tests/NotificationBuilder.daily.test.ts b/src/entities/notification/model/factory/tests/NotificationBuilder.daily.test.ts index 2c77656e2..d3c897a5f 100644 --- a/src/entities/notification/model/factory/tests/NotificationBuilder.daily.test.ts +++ b/src/entities/notification/model/factory/tests/NotificationBuilder.daily.test.ts @@ -141,8 +141,8 @@ const addReminder = ( activityIncompleteDays === 0 ? 'current-day' : activityIncompleteDays === 1 - ? 'next-day' - : 'in-future', + ? 'next-day' + : 'in-future', type: NotificationType.Reminder, isSpreadInEventSet: isCrossDay, notificationBody: 'Just a kindly reminder to complete the activity', @@ -156,8 +156,8 @@ const addReminder = ( inactiveReason === 'invalid-period' ? InactiveReason.FallOnInvalidPeriod : inactiveReason === 'outdated' - ? InactiveReason.Outdated - : InactiveReason.NotDefined, + ? InactiveReason.Outdated + : InactiveReason.NotDefined, }; } diff --git a/src/entities/notification/model/factory/tests/NotificationBuilder.monthly.test.ts b/src/entities/notification/model/factory/tests/NotificationBuilder.monthly.test.ts index 4253d3d99..91b791148 100644 --- a/src/entities/notification/model/factory/tests/NotificationBuilder.monthly.test.ts +++ b/src/entities/notification/model/factory/tests/NotificationBuilder.monthly.test.ts @@ -152,8 +152,8 @@ const addReminder = ( inactiveReason === 'invalid-period' ? InactiveReason.FallOnInvalidPeriod : inactiveReason === 'outdated' - ? InactiveReason.Outdated - : InactiveReason.NotDefined, + ? InactiveReason.Outdated + : InactiveReason.NotDefined, }; } @@ -196,8 +196,8 @@ const addNotification = ( inactiveReason === 'outdated' ? InactiveReason.Outdated : inactiveReason === 'completed' - ? InactiveReason.ActivityCompleted - : InactiveReason.NotDefined, + ? InactiveReason.ActivityCompleted + : InactiveReason.NotDefined, }; } @@ -237,8 +237,8 @@ const addCrossDayNotification = ( inactiveReason === 'outdated' ? InactiveReason.Outdated : inactiveReason === 'completed' - ? InactiveReason.ActivityCompleted - : InactiveReason.NotDefined, + ? InactiveReason.ActivityCompleted + : InactiveReason.NotDefined, }; } diff --git a/src/entities/notification/model/factory/tests/NotificationBuilder.weekly.test.ts b/src/entities/notification/model/factory/tests/NotificationBuilder.weekly.test.ts index 57eee1ea3..9a2431c65 100644 --- a/src/entities/notification/model/factory/tests/NotificationBuilder.weekly.test.ts +++ b/src/entities/notification/model/factory/tests/NotificationBuilder.weekly.test.ts @@ -140,8 +140,8 @@ const addReminder = ( activityIncompleteDays === 0 ? 'current-day' : activityIncompleteDays === 1 - ? 'next-day' - : 'in-future', + ? 'next-day' + : 'in-future', type: NotificationType.Reminder, isSpreadInEventSet: isCrossDay, notificationBody: 'Just a kindly reminder to complete the activity', @@ -155,8 +155,8 @@ const addReminder = ( inactiveReason === 'invalid-period' ? InactiveReason.FallOnInvalidPeriod : inactiveReason === 'outdated' - ? InactiveReason.Outdated - : InactiveReason.NotDefined, + ? InactiveReason.Outdated + : InactiveReason.NotDefined, }; } @@ -192,8 +192,8 @@ const addNotification = ( inactiveReason === 'outdated' ? InactiveReason.Outdated : inactiveReason === 'completed' - ? InactiveReason.ActivityCompleted - : InactiveReason.NotDefined, + ? InactiveReason.ActivityCompleted + : InactiveReason.NotDefined, }; } @@ -233,8 +233,8 @@ const addCrossDayNotification = ( inactiveReason === 'outdated' ? InactiveReason.Outdated : inactiveReason === 'completed' - ? InactiveReason.ActivityCompleted - : InactiveReason.NotDefined, + ? InactiveReason.ActivityCompleted + : InactiveReason.NotDefined, }; } diff --git a/src/entities/notification/model/factory/tests/NotificationDaysExtractor.test.ts b/src/entities/notification/model/factory/tests/NotificationDaysExtractor.test.ts index ea478385c..88b2a353a 100644 --- a/src/entities/notification/model/factory/tests/NotificationDaysExtractor.test.ts +++ b/src/entities/notification/model/factory/tests/NotificationDaysExtractor.test.ts @@ -119,7 +119,7 @@ describe('NotificationDaysExtractor tests. Extract days for regular notification scheduledDay, ); - let expected = [ + const expected = [ Yesterday, CurrentDay, addDays(CurrentDay, 1), @@ -314,7 +314,7 @@ describe('NotificationDaysExtractor tests. Extract days for regular notification scheduledDay, ); - let expected = [ + const expected = [ Yesterday, CurrentDay, addDays(CurrentDay, 1), @@ -514,7 +514,7 @@ describe('NotificationDaysExtractor tests. Extract days for regular notification scheduledDay, ); - let expected = [addDays(scheduledDay, 7)]; + const expected = [addDays(scheduledDay, 7)]; expect(result).toEqual(expected); }); @@ -538,7 +538,7 @@ describe('NotificationDaysExtractor tests. Extract days for regular notification scheduledDay, ); - let expected = [addDays(scheduledDay, 7), addDays(scheduledDay, 14)]; + const expected = [addDays(scheduledDay, 7), addDays(scheduledDay, 14)]; expect(result).toEqual(expected); }); @@ -562,7 +562,7 @@ describe('NotificationDaysExtractor tests. Extract days for regular notification scheduledDay, ); - let expected = [scheduledDay, addDays(scheduledDay, 7)]; + const expected = [scheduledDay, addDays(scheduledDay, 7)]; expect(result).toEqual(expected); }); @@ -586,7 +586,7 @@ describe('NotificationDaysExtractor tests. Extract days for regular notification scheduledDay, ); - let expected = [addDays(scheduledDay, 7)]; + const expected = [addDays(scheduledDay, 7)]; expect(result).toEqual(expected); }); @@ -636,7 +636,7 @@ describe('NotificationDaysExtractor tests. Extract days for regular notification scheduledDay, ); - let expected = [CurrentDay, Tomorrow, addDays(Tomorrow, 1)]; + const expected = [CurrentDay, Tomorrow, addDays(Tomorrow, 1)]; expect(result).toEqual(expected); }); @@ -998,7 +998,7 @@ describe('NotificationDaysExtractor tests. Extract days for reminder notificatio scheduledDay, ); - let expected = [ + const expected = [ subDays(CurrentDay, 2), subDays(CurrentDay, 1), CurrentDay, @@ -1166,7 +1166,7 @@ describe('NotificationDaysExtractor tests. Extract days for reminder notificatio scheduledDay, ); - let expected = [ + const expected = [ subDays(CurrentDay, 2), subDays(CurrentDay, 1), CurrentDay, @@ -1342,7 +1342,7 @@ describe('NotificationDaysExtractor tests. Extract days for reminder notificatio scheduledDay, ); - let expected = [addDays(scheduledDay, 7)]; + const expected = [addDays(scheduledDay, 7)]; expect(result).toEqual(expected); }); @@ -1365,7 +1365,7 @@ describe('NotificationDaysExtractor tests. Extract days for reminder notificatio scheduledDay, ); - let expected = [addDays(scheduledDay, 7), addDays(scheduledDay, 14)]; + const expected = [addDays(scheduledDay, 7), addDays(scheduledDay, 14)]; expect(result).toEqual(expected); }); @@ -1388,7 +1388,7 @@ describe('NotificationDaysExtractor tests. Extract days for reminder notificatio scheduledDay, ); - let expected = [ + const expected = [ subWeeks(scheduledDay, 4), subWeeks(scheduledDay, 3), subWeeks(scheduledDay, 2), @@ -1418,7 +1418,7 @@ describe('NotificationDaysExtractor tests. Extract days for reminder notificatio scheduledDay, ); - let expected = [addDays(scheduledDay, 7)]; + const expected = [addDays(scheduledDay, 7)]; expect(result).toEqual(expected); }); diff --git a/src/entities/notification/model/factory/tests/NotificationUtility.getTriggerAt.test.ts b/src/entities/notification/model/factory/tests/NotificationUtility.getTriggerAt.test.ts index 6221c3164..1749133c8 100644 --- a/src/entities/notification/model/factory/tests/NotificationUtility.getTriggerAt.test.ts +++ b/src/entities/notification/model/factory/tests/NotificationUtility.getTriggerAt.test.ts @@ -95,7 +95,7 @@ describe('NotificationUtility: test getTriggerAt methods with taking into accoun 'both-in-current-day', ); - let expected = new Date(scheduledDay); + const expected = new Date(scheduledDay); expected.setHours(18); expected.setMinutes(45); diff --git a/src/features/pass-survey/model/AlertsExtractor.ts b/src/features/pass-survey/model/AlertsExtractor.ts index 73ff16e1d..3bb053c99 100644 --- a/src/features/pass-survey/model/AlertsExtractor.ts +++ b/src/features/pass-survey/model/AlertsExtractor.ts @@ -42,7 +42,7 @@ export class AlertsExtractor { if (alertOption) { alerts.push({ activityItemId: radioItem.id!, - message: alertOption!.alert!.message, + message: alertOption.alert!.message, }); } @@ -124,12 +124,12 @@ export class AlertsExtractor { stackedRadioAnswer.forEach(itemAnswer => { if ( itemAnswer?.rowId === row.rowId && - itemAnswer.id === option.optionId! + itemAnswer.id === option.optionId ) { option.alert && alerts.push({ activityItemId: stackedRadioItem.id!, - message: option.alert!.message, + message: option.alert.message, }); } }); @@ -157,11 +157,11 @@ export class AlertsExtractor { if (columnAnswers?.length) { row.options.forEach(option => { columnAnswers.forEach(cellAnswer => { - if (cellAnswer.id === option.optionId!) { + if (cellAnswer.id === option.optionId) { option.alert && alerts.push({ activityItemId: stackedCheckboxItem.id!, - message: option.alert!.message, + message: option.alert.message, }); } }); @@ -261,8 +261,7 @@ export class AlertsExtractor { return this.extractInternal(pipelineItems, answers); } catch (error) { this.logger.warn( - '[AlertsExtractor.extractForSummary]: Error occurred: \n\n' + - error!.toString(), + `[AlertsExtractor.extractForSummary]: Error occurred: \n\n${error}`, ); return [ { diff --git a/src/features/pass-survey/model/ScoreConditionsEvaluator.ts b/src/features/pass-survey/model/ScoreConditionsEvaluator.ts index 453f3b800..8dc179223 100644 --- a/src/features/pass-survey/model/ScoreConditionsEvaluator.ts +++ b/src/features/pass-survey/model/ScoreConditionsEvaluator.ts @@ -53,8 +53,7 @@ export class ScoreConditionsEvaluator implements IScoreConditionsEvaluator { return this.evaluateInternal(settings, score); } catch (error) { throw new Error( - '[ScoreConditionsEvaluator.evaluate]: Error occurred:\n\n' + - error!.toString(), + `[ScoreConditionsEvaluator.evaluate]: Error occurred:\n\n${error}`, ); } } diff --git a/src/features/pass-survey/model/ScoresCalculator.ts b/src/features/pass-survey/model/ScoresCalculator.ts index 7c027653f..936899a3a 100644 --- a/src/features/pass-survey/model/ScoresCalculator.ts +++ b/src/features/pass-survey/model/ScoresCalculator.ts @@ -184,8 +184,7 @@ export class ScoresCalculator implements IScoresCalculator { return this.collectMaxScoresInternal(pipelineItems, selectedItems); } catch (error) { throw new Error( - '[ScoresCalculator:collectMaxScores]: Error occurred:\n\n' + - error!.toString(), + `[ScoresCalculator:collectMaxScores]: Error occurred:\n\n${error}`, ); } } @@ -205,8 +204,7 @@ export class ScoresCalculator implements IScoresCalculator { ); } catch (error) { throw new Error( - '[ScoresCalculator.calculate]: Error occurred during collecting actual scores:\n\n' + - error!.toString(), + `[ScoresCalculator.calculate]: Error occurred during collecting actual scores:\n\n${error}`, ); } diff --git a/src/features/pass-survey/model/ScoresExtractor.ts b/src/features/pass-survey/model/ScoresExtractor.ts index 09e24e2b1..585bae9ca 100644 --- a/src/features/pass-survey/model/ScoresExtractor.ts +++ b/src/features/pass-survey/model/ScoresExtractor.ts @@ -64,7 +64,7 @@ export class ScoresExtractor { `[ScoresExtractor.extract]: Extracting scores for activity '${logActivityName}'`, ); - for (let scoreSettings of settings) { + for (const scoreSettings of settings) { const logScore = `'${scoreSettings.name}' for settings with index '${settingsIndex}'`; try { @@ -83,8 +83,7 @@ export class ScoresExtractor { } } catch (error) { this.logger.warn( - `[ScoresExtractor.extract]: Error occurred during extracting score ${logScore}\n\nInternal Error:\n\n` + - error!.toString(), + `[ScoresExtractor.extract]: Error occurred during extracting score ${logScore}\n\nInternal Error:\n\n${error}`, ); result.push({ name: '[Error occurred]', diff --git a/src/features/pass-survey/model/ShiftCalculator.ts b/src/features/pass-survey/model/ShiftCalculator.ts index b4d37d48d..fab420300 100644 --- a/src/features/pass-survey/model/ShiftCalculator.ts +++ b/src/features/pass-survey/model/ShiftCalculator.ts @@ -19,7 +19,7 @@ class ShiftCalculator { const exceedRangeShift = this.arrayLength - inputStep; while (true) { - let nextStep = inputStep + shift; + const nextStep = inputStep + shift; if (nextStep >= this.arrayLength) { result = exceedRangeShift; @@ -45,7 +45,7 @@ class ShiftCalculator { const noShift = 0; while (true) { - let previousStep = inputStep - shift; + const previousStep = inputStep - shift; if (previousStep < 0) { result = noShift; diff --git a/src/features/pass-survey/model/flankerNextStepEvaluator.ts b/src/features/pass-survey/model/flankerNextStepEvaluator.ts index 70174b33d..da9a6a915 100644 --- a/src/features/pass-survey/model/flankerNextStepEvaluator.ts +++ b/src/features/pass-survey/model/flankerNextStepEvaluator.ts @@ -31,7 +31,7 @@ export const evaluateFlankerNextStep = ( let totalCount: number = 0; - for (let logRecord of gameResult.records) { + for (const logRecord of gameResult.records) { if (logRecord.tag !== 'trial') { continue; } diff --git a/src/features/pass-survey/model/hooks/useActivityState.ts b/src/features/pass-survey/model/hooks/useActivityState.ts index 9da6d7e07..e8b62ade3 100644 --- a/src/features/pass-survey/model/hooks/useActivityState.ts +++ b/src/features/pass-survey/model/hooks/useActivityState.ts @@ -172,9 +172,10 @@ function useActivityState({ upsertActivityStorageRecord({ ...currentStorageRecord, - actions: userActionsPostProcessorService.postProcessUserActions( - currentStorageRecord!, - ), + actions: + userActionsPostProcessorService.postProcessUserActions( + currentStorageRecord, + ), }); } diff --git a/src/features/pass-survey/model/hooks/useIdleTimer.ts b/src/features/pass-survey/model/hooks/useIdleTimer.ts index afb5f01a8..073b6360a 100644 --- a/src/features/pass-survey/model/hooks/useIdleTimer.ts +++ b/src/features/pass-survey/model/hooks/useIdleTimer.ts @@ -33,7 +33,7 @@ const useIdleTimer = (input: UseIdleTimerInput): UseIdleTimerResult => { timerRef.current = new AppTimer(onIdleElapsed, false, duration); - timerRef.current!.start(); + timerRef.current.start(); return () => { timerRef.current!.stop(); diff --git a/src/features/pass-survey/model/tests/AlertsExtractor.test.ts b/src/features/pass-survey/model/tests/AlertsExtractor.test.ts index 0705dcefe..d007f5ef6 100644 --- a/src/features/pass-survey/model/tests/AlertsExtractor.test.ts +++ b/src/features/pass-survey/model/tests/AlertsExtractor.test.ts @@ -32,7 +32,7 @@ jest.mock('@app/shared/lib/constants', () => ({ })); describe('AlertsExtractor: penetration tests', () => { - let extractor: AlertsExtractor = new AlertsExtractor({ + const extractor: AlertsExtractor = new AlertsExtractor({ log: jest.fn(), warn: jest.fn(), error: jest.fn(), diff --git a/src/features/pass-survey/model/tests/AnswerValidator.test.ts b/src/features/pass-survey/model/tests/AnswerValidator.test.ts index 78711882f..8550e719b 100644 --- a/src/features/pass-survey/model/tests/AnswerValidator.test.ts +++ b/src/features/pass-survey/model/tests/AnswerValidator.test.ts @@ -76,7 +76,7 @@ describe('AnswerValidator tests', () => { step: 0, }); - let result = imitateValidate(validator, t); + const result = imitateValidate(validator, t); expect(result).toEqual(false); }); @@ -100,7 +100,7 @@ describe('AnswerValidator tests', () => { step: 0, }); - let result = imitateValidate(validator, t); + const result = imitateValidate(validator, t); expect(result).toEqual(false); }); @@ -121,7 +121,7 @@ describe('AnswerValidator tests', () => { step: 0, }); - let result = imitateValidate(validator, t); + const result = imitateValidate(validator, t); expect(result).toEqual(false); }); @@ -145,7 +145,7 @@ describe('AnswerValidator tests', () => { step: 0, }); - let result = imitateValidate(validator, t); + const result = imitateValidate(validator, t); expect(result).toEqual(false); }); @@ -175,7 +175,7 @@ describe('AnswerValidator tests', () => { step: 1, }); - let result = validator.isCorrect(); + const result = validator.isCorrect(); expect(result).toEqual(true); }); @@ -204,7 +204,7 @@ describe('AnswerValidator tests', () => { step: 1, }); - let result = validator.isCorrect(); + const result = validator.isCorrect(); expect(result).toEqual(false); }); diff --git a/src/features/pass-survey/model/tests/PipelineVisibilityChecker.test.ts b/src/features/pass-survey/model/tests/PipelineVisibilityChecker.test.ts index c851a1880..4ea9d36f3 100644 --- a/src/features/pass-survey/model/tests/PipelineVisibilityChecker.test.ts +++ b/src/features/pass-survey/model/tests/PipelineVisibilityChecker.test.ts @@ -25,7 +25,7 @@ describe('PipelineVisibilityChecker: penetration tests', () => { }); }; - let setCondition = ( + const setCondition = ( itemSetTo: PipelineItem, itemPointedTo: PipelineItem, match: Match, diff --git a/src/features/pass-survey/model/tests/ScoresExtractor.test.ts b/src/features/pass-survey/model/tests/ScoresExtractor.test.ts index 1459e0513..8fba6825a 100644 --- a/src/features/pass-survey/model/tests/ScoresExtractor.test.ts +++ b/src/features/pass-survey/model/tests/ScoresExtractor.test.ts @@ -195,7 +195,7 @@ describe('ScoresCalculator: test collectScoreForRadio', () => { ); }); - let simpleTestParameters = [ + const simpleTestParameters = [ { expectedValue: 517, calculationType: 'sum' }, { expectedValue: 517 / 3, calculationType: 'average' }, { expectedValue: 80.78125, calculationType: 'percentage' }, diff --git a/src/shared/lib/encryption/encryption.test.js b/src/shared/lib/encryption/encryption.test.js index a20d43f54..54e4bde1c 100644 --- a/src/shared/lib/encryption/encryption.test.js +++ b/src/shared/lib/encryption/encryption.test.js @@ -1,6 +1,7 @@ +import { Buffer } from 'buffer'; + import { encryption } from './encryption'; import { answerRequestExample } from './mockData'; -import { Buffer } from 'buffer'; jest.mock('@shared/lib', () => ({ IV_LENGTH: 16 })); diff --git a/src/shared/lib/markDownRules.tsx b/src/shared/lib/markDownRules.tsx index bdc3c4128..ed286adb0 100644 --- a/src/shared/lib/markDownRules.tsx +++ b/src/shared/lib/markDownRules.tsx @@ -526,7 +526,7 @@ const parseNodeContent = (content: string) => { }; const checkIfContainerTypeIsHljs = (parents: ASTNode[]) => { - for (let parent of parents) { + for (const parent of parents) { const { type } = parent; if (type.includes('container_hljs')) { return true; diff --git a/src/shared/lib/permissions/microphonePermissions.ts b/src/shared/lib/permissions/microphonePermissions.ts index f69a59634..0a1aeaf60 100644 --- a/src/shared/lib/permissions/microphonePermissions.ts +++ b/src/shared/lib/permissions/microphonePermissions.ts @@ -57,7 +57,7 @@ const getMicrophoneAndroidPermissions = async (): Promise => { }; const getMicrophoneIOSPermissions = async (): Promise => { - const result = await Permissions.request(PERMISSIONS.IOS.MICROPHONE!); + const result = await Permissions.request(PERMISSIONS.IOS.MICROPHONE); return result === RESULTS.GRANTED; }; diff --git a/src/shared/lib/services/Logger.ts b/src/shared/lib/services/Logger.ts index ec2716a48..517411bb9 100644 --- a/src/shared/lib/services/Logger.ts +++ b/src/shared/lib/services/Logger.ts @@ -69,7 +69,7 @@ export class Logger implements ILogger { const result: Array = []; - for (let path of filePaths) { + for (const path of filePaths) { const fileInfo = await FileSystem.stat(path); result.push({ fileName: fileInfo.filename, @@ -100,7 +100,7 @@ export class Logger implements ILogger { const result: FileExists[] = []; - for (let existRecord of checkResult.data.result) { + for (const existRecord of checkResult.data.result) { const fileInfo = files.find(x => x.fileName === existRecord.fileId)!; result.push({ @@ -166,10 +166,7 @@ export class Logger implements ILogger { try { logFiles = await this.getLogFiles(); } catch (error) { - console.warn( - '[Logger.getLogFiles]: Error occurred\n\n', - error!.toString(), - ); + console.warn(`[Logger.getLogFiles]: Error occurred\n\n${error}`); return false; } @@ -187,16 +184,13 @@ export class Logger implements ILogger { })), ); } catch (error) { - console.warn( - '[Logger.checkIfFilesExist]: Error occurred\n\n', - error!.toString(), - ); + console.warn(`[Logger.checkIfFilesExist]: Error occurred\n\n${error}`); return false; } let success = true; - for (let checkRecord of checkResult) { + for (const checkRecord of checkResult) { if (this.isAborted) { return false; } @@ -236,8 +230,7 @@ export class Logger implements ILogger { }); } catch (error) { console.warn( - `[Logger.upload]: Error occurred while sending file "${checkRecord.fileName}"\n\n`, - error!.toString(), + `[Logger.upload]: Error occurred while sending file "${checkRecord.fileName}"\n\n${error}`, ); success = false; } @@ -267,10 +260,7 @@ export class Logger implements ILogger { try { await callWithMutexAsync(this.mutex, FileLogger.deleteLogFiles); } catch (error) { - console.warn( - 'Logger.clearAllLogFiles]: Error occurred\n\n', - error!.toString(), - ); + console.warn(`Logger.clearAllLogFiles]: Error occurred\n\n${error}`); } } @@ -338,10 +328,7 @@ export class Logger implements ILogger { return result; } catch (error) { - console.warn( - '[Logger.sendInternal]: Error occurred: \n\n', - error!.toString(), - ); + console.warn(`[Logger.sendInternal]: Error occurred: \n\n${error}`); } finally { this.mutex.release(); } diff --git a/src/shared/lib/services/collectImageUrls.ts b/src/shared/lib/services/collectImageUrls.ts index b043bdb69..a818a31bd 100644 --- a/src/shared/lib/services/collectImageUrls.ts +++ b/src/shared/lib/services/collectImageUrls.ts @@ -16,7 +16,7 @@ export const collectAppletRecordImageUrls = ( return result; } catch (error) { throw new Error( - '[collectAppletRecordImageUrls]: Error occurred:\n\n' + error!.toString(), + `[collectAppletRecordImageUrls]: Error occurred:\n\n${error}`, ); } }; @@ -34,7 +34,7 @@ export const collectAppletDetailsImageUrls = ( applet.theme.backgroundImage && result.push(applet.theme.backgroundImage); - for (let activity of applet.activities) { + for (const activity of applet.activities) { activity.splashScreen && result.push(activity.splashScreen); activity.image && result.push(activity.image); } @@ -42,8 +42,7 @@ export const collectAppletDetailsImageUrls = ( return result; } catch (error) { throw new Error( - '[collectAppletDetailsImageUrls]: Error occurred:\n\n' + - error!.toString(), + `[collectAppletDetailsImageUrls]: Error occurred:\n\n${error}`, ); } }; @@ -54,16 +53,16 @@ const collectActivityDetailsImageUrlsInternal = (activity: ActivityDto) => { activity.image && result.push(activity.image); activity.splashScreen && result.push(activity.splashScreen); - for (let item of activity.items) { + for (const item of activity.items) { switch (item.responseType) { case 'singleSelect': { - for (let option of item.responseValues.options) { + for (const option of item.responseValues.options) { option.image && result.push(option.image); } break; } case 'multiSelect': { - for (let option of item.responseValues.options) { + for (const option of item.responseValues.options) { option.image && result.push(option.image); } break; @@ -83,26 +82,26 @@ const collectActivityDetailsImageUrlsInternal = (activity: ActivityDto) => { break; } case 'sliderRows': { - for (let responseValue of item.responseValues.rows) { + for (const responseValue of item.responseValues.rows) { responseValue.minImage && result.push(responseValue.minImage); responseValue.maxImage && result.push(responseValue.maxImage); } break; } case 'singleSelectRows': { - for (let row of item.responseValues.rows) { + for (const row of item.responseValues.rows) { row.rowImage && result.push(row.rowImage); } - for (let option of item.responseValues.options) { + for (const option of item.responseValues.options) { option.image && result.push(option.image); } break; } case 'multiSelectRows': { - for (let row of item.responseValues.rows) { + for (const row of item.responseValues.rows) { row.rowImage && result.push(row.rowImage); } - for (let option of item.responseValues.options) { + for (const option of item.responseValues.options) { option.image && result.push(option.image); } break; @@ -117,8 +116,7 @@ export const collectActivityDetailsImageUrls = (activity: ActivityDto) => { return collectActivityDetailsImageUrlsInternal(activity); } catch (error) { throw new Error( - '[collectActivityDetailsImageUrls]: Error occurred:\n\n' + - error!.toString(), + `[collectActivityDetailsImageUrls]: Error occurred:\n\n${error}`, ); } }; diff --git a/src/shared/lib/timers/hooks/useInterval.ts b/src/shared/lib/timers/hooks/useInterval.ts index 17ea0dfec..cac310f0a 100644 --- a/src/shared/lib/timers/hooks/useInterval.ts +++ b/src/shared/lib/timers/hooks/useInterval.ts @@ -5,7 +5,7 @@ const useInterval = ( interval: number, ) => { const callbacksRef = useRef({ onIntervalPass }); - let intervalRef = useRef(); + const intervalRef = useRef(); callbacksRef.current = { onIntervalPass }; diff --git a/src/shared/lib/utils/networkHelpers.ts b/src/shared/lib/utils/networkHelpers.ts index 9060a1ea1..592a9d365 100644 --- a/src/shared/lib/utils/networkHelpers.ts +++ b/src/shared/lib/utils/networkHelpers.ts @@ -56,6 +56,7 @@ export const watchForConnectionLoss = ( mode: 'ping' | 'checkNetworkStatus' = 'ping', ) => { const abortController = new AbortController(); + // eslint-disable-next-line prefer-const let intervalId: TimeoutId; const checkWithAbort = () => { diff --git a/src/shared/ui/SketchCanvas/SketchCanvas.tsx b/src/shared/ui/SketchCanvas/SketchCanvas.tsx index 8c6ba49c1..953e7274f 100644 --- a/src/shared/ui/SketchCanvas/SketchCanvas.tsx +++ b/src/shared/ui/SketchCanvas/SketchCanvas.tsx @@ -98,7 +98,7 @@ const SketchCanvas = forwardRef((props, ref) => { tempPath.value = activePath.value; - const lastPoint = activePath.value!.getLastPt(); + const lastPoint = activePath.value.getLastPt(); const newPath = createLine(points, lastPoint); activePath.value = newPath; diff --git a/src/shared/ui/Stepper/NavigationPanel.tsx b/src/shared/ui/Stepper/NavigationPanel.tsx index 8745a2144..909a09821 100644 --- a/src/shared/ui/Stepper/NavigationPanel.tsx +++ b/src/shared/ui/Stepper/NavigationPanel.tsx @@ -6,7 +6,7 @@ type Props = PropsWithChildren; function NavigationPanel({ children, ...styledProps }: Props) { const buttons = useMemo(() => { - let allChildren: ReactNode[] = []; + const allChildren: ReactNode[] = []; Children.forEach(children, child => { allChildren.push(child); diff --git a/src/shared/ui/survey/RadioActivityItem/RadioItem.tsx b/src/shared/ui/survey/RadioActivityItem/RadioItem.tsx index 416e24322..6a90235a3 100644 --- a/src/shared/ui/survey/RadioActivityItem/RadioItem.tsx +++ b/src/shared/ui/survey/RadioActivityItem/RadioItem.tsx @@ -54,12 +54,8 @@ const RadioItem: FC = ({ } const hasColor = color && setPalette; - const invertedColor = hasColor - ? invertColor(color as string) - : colors.primary; - const invertedTextColor = hasColor - ? invertColor(color as string) - : colors.darkerGrey; + const invertedColor = hasColor ? invertColor(color) : colors.primary; + const invertedTextColor = hasColor ? invertColor(color) : colors.darkerGrey; return ( { const startAt = new Date(2023, 8, 1, 0, 0, 0); const endAt = new Date(2023, 8, 1, 15, 30, 0); - let progress: Progress = getProgress(startAt, endAt); + const progress: Progress = getProgress(startAt, endAt); - let input: GroupsBuildContext = { + const input: GroupsBuildContext = { allAppletActivities: [], progress, appletId: 'test-applet-id-1', applyInProgressFilter: true, }; - let builder = createActivityGroupsBuilder(input); + const builder = createActivityGroupsBuilder(input); const eventEntity: EventEntity = getAlwaysAvailableEventEntity({ scheduledAt: startAt, }); - let result = builder.buildInProgress([eventEntity]); + const result = builder.buildInProgress([eventEntity]); const expectedResult: ActivityListGroup = { name: 'additional:in_progress', @@ -289,20 +289,20 @@ describe('ActivityGroupsBuilder', () => { const progress = getEmptyProgress(); - let input: GroupsBuildContext = { + const input: GroupsBuildContext = { allAppletActivities: [], progress, appletId: 'test-applet-id-1', applyInProgressFilter: true, }; - let builder = createActivityGroupsBuilder(input); + const builder = createActivityGroupsBuilder(input); const eventEntity: EventEntity = getAlwaysAvailableEventEntity({ scheduledAt: startAt, }); - let result = builder.buildInProgress([eventEntity]); + const result = builder.buildInProgress([eventEntity]); const expectedResult: ActivityListGroup = { name: 'additional:in_progress', @@ -370,13 +370,13 @@ describe('ActivityGroupsBuilder', () => { }); eventEntity.event.timers.timer = { hours: 5, minutes: 20 }; - let mockedNowDate = new Date(date); + const mockedNowDate = new Date(date); mockedNowDate.setHours(date.getHours() + 3); mockedNowDate.setMinutes(date.getMinutes() + 12); mockGetNow(builder, mockedNowDate); - let result = builder.buildInProgress([eventEntity]); + const result = builder.buildInProgress([eventEntity]); const expectedItem: ActivityListItem = getExpectedInProgressItem(); expectedItem.isTimerSet = true; @@ -420,7 +420,7 @@ describe('ActivityGroupsBuilder', () => { mockGetNow(builder, mockedNowDate); - let result = builder.buildInProgress([eventEntity]); + const result = builder.buildInProgress([eventEntity]); const expectedItem: ActivityListItem = getExpectedInProgressItem(); expectedItem.isTimerSet = true; @@ -458,13 +458,13 @@ describe('ActivityGroupsBuilder', () => { }); eventEntity.event.timers.timer = { hours: 5, minutes: 20 }; - let mockedNowDate = new Date(date); + const mockedNowDate = new Date(date); mockedNowDate.setHours(date.getHours() + 5); mockedNowDate.setMinutes(date.getMinutes() + 20); mockGetNow(builder, mockedNowDate); - let result = builder.buildInProgress([eventEntity]); + const result = builder.buildInProgress([eventEntity]); const expectedItem: ActivityListItem = getExpectedInProgressItem(); expectedItem.isTimerSet = true; @@ -486,16 +486,16 @@ describe('ActivityGroupsBuilder', () => { const startAt = new Date(2023, 8, 1, 15, 0, 0); const endAt = addHours(startAt, 1); - let progress: Progress = getProgress(startAt, endAt); + const progress: Progress = getProgress(startAt, endAt); - let input: GroupsBuildContext = { + const input: GroupsBuildContext = { allAppletActivities: [], progress, appletId: 'test-applet-id-1', applyInProgressFilter: true, }; - let builder = createActivityGroupsBuilder(input); + const builder = createActivityGroupsBuilder(input); const eventEntity: EventEntity = getAlwaysAvailableEventEntity({ scheduledAt: startAt, @@ -507,7 +507,7 @@ describe('ActivityGroupsBuilder', () => { mockGetNow(builder, now); - let result = builder.buildAvailable([eventEntity]); + const result = builder.buildAvailable([eventEntity]); const expectedItem: ActivityListItem = getExpectedAvailableItem(); expectedItem.availableTo = MIDNIGHT_DATE; @@ -527,14 +527,14 @@ describe('ActivityGroupsBuilder', () => { const progress = getEmptyProgress(); - let input: GroupsBuildContext = { + const input: GroupsBuildContext = { allAppletActivities: [], progress, appletId: 'test-applet-id-1', applyInProgressFilter: true, }; - let builder = createActivityGroupsBuilder(input); + const builder = createActivityGroupsBuilder(input); const eventEntity: EventEntity = getAlwaysAvailableEventEntity({ scheduledAt: startAt, @@ -546,7 +546,7 @@ describe('ActivityGroupsBuilder', () => { mockGetNow(builder, now); - let result = builder.buildAvailable([eventEntity]); + const result = builder.buildAvailable([eventEntity]); const expectedItem: ActivityListItem = getExpectedAvailableItem(); expectedItem.availableTo = MIDNIGHT_DATE; @@ -564,16 +564,16 @@ describe('ActivityGroupsBuilder', () => { const startAt = new Date(2023, 8, 1, 15, 0, 0); const endAt = addHours(startAt, 1); - let progress: Progress = getProgress(startAt, endAt); + const progress: Progress = getProgress(startAt, endAt); - let input: GroupsBuildContext = { + const input: GroupsBuildContext = { allAppletActivities: [], progress, appletId: 'test-applet-id-1', applyInProgressFilter: true, }; - let builder = createActivityGroupsBuilder(input); + const builder = createActivityGroupsBuilder(input); const eventEntity: EventEntity = getAlwaysAvailableEventEntity({ scheduledAt: startAt, @@ -585,7 +585,7 @@ describe('ActivityGroupsBuilder', () => { mockGetNow(builder, now); - let result = builder.buildAvailable([eventEntity]); + const result = builder.buildAvailable([eventEntity]); const expectedResult: ActivityListGroup = { name: 'additional:available', @@ -606,16 +606,16 @@ describe('ActivityGroupsBuilder', () => { it(`Should return group-item for scheduled event when periodicity is ${periodicity} and allowAccessBeforeFromTime is false and current time is is allowed time window`, () => { const scheduledAt = new Date(2023, 8, 1, 15, 0, 0); - let progress: Progress = getEmptyProgress(); + const progress: Progress = getEmptyProgress(); - let input: GroupsBuildContext = { + const input: GroupsBuildContext = { allAppletActivities: [], progress, appletId: 'test-applet-id-1', applyInProgressFilter: true, }; - let builder = createActivityGroupsBuilder(input); + const builder = createActivityGroupsBuilder(input); const eventEntity: EventEntity = getScheduledEventEntity({ scheduledAt, @@ -632,7 +632,7 @@ describe('ActivityGroupsBuilder', () => { mockGetNow(builder, new Date(now)); - let result = builder.buildAvailable([eventEntity]); + const result = builder.buildAvailable([eventEntity]); const expectedItem = getExpectedAvailableItem(); expectedItem.availableTo = new Date(startOfDay(scheduledAt)); @@ -652,16 +652,16 @@ describe('ActivityGroupsBuilder', () => { it('Should return empty for scheduled event when periodicity is Daily and allowAccessBeforeFromTime is false and current time is is allowed time window and start/end dates are in the future in 2-3 months', () => { const scheduledAt = new Date(2023, 8, 1, 15, 0, 0); - let progress: Progress = getEmptyProgress(); + const progress: Progress = getEmptyProgress(); - let input: GroupsBuildContext = { + const input: GroupsBuildContext = { allAppletActivities: [], progress, appletId: 'test-applet-id-1', applyInProgressFilter: true, }; - let builder = createActivityGroupsBuilder(input); + const builder = createActivityGroupsBuilder(input); const eventEntity: EventEntity = getScheduledEventEntity({ scheduledAt, @@ -701,16 +701,16 @@ describe('ActivityGroupsBuilder', () => { it('Should return empty for scheduled event when periodicity is Daily and allowAccessBeforeFromTime is false and current time is is allowed time window and start/end dates are in the past 2-3 months', () => { const scheduledAt = new Date(2023, 8, 1, 15, 0, 0); - let progress: Progress = getEmptyProgress(); + const progress: Progress = getEmptyProgress(); - let input: GroupsBuildContext = { + const input: GroupsBuildContext = { allAppletActivities: [], progress, appletId: 'test-applet-id-1', applyInProgressFilter: true, }; - let builder = createActivityGroupsBuilder(input); + const builder = createActivityGroupsBuilder(input); const eventEntity: EventEntity = getScheduledEventEntity({ scheduledAt, @@ -729,7 +729,7 @@ describe('ActivityGroupsBuilder', () => { mockGetNow(builder, new Date(now)); - let result = builder.buildAvailable([eventEntity]); + const result = builder.buildAvailable([eventEntity]); const expectedItem = getExpectedAvailableItem(); expectedItem.availableTo = new Date(startOfDay(scheduledAt)); @@ -760,7 +760,7 @@ describe('ActivityGroupsBuilder', () => { applyInProgressFilter: true, }; - let builder = createActivityGroupsBuilder(input); + const builder = createActivityGroupsBuilder(input); const eventEntity: EventEntity = getScheduledEventEntity({ scheduledAt, @@ -779,7 +779,7 @@ describe('ActivityGroupsBuilder', () => { mockGetNow(builder, new Date(now)); - let result = builder.buildAvailable([eventEntity]); + const result = builder.buildAvailable([eventEntity]); const expectedItem = getExpectedAvailableItem(); expectedItem.availableTo = new Date(startOfDay(scheduledAt)); @@ -798,16 +798,16 @@ describe('ActivityGroupsBuilder', () => { it('Should not return group-item for scheduled event and periodicity is Weekly and allowAccessBeforeFromTime is false when scheduledToday is false', () => { const scheduledAt = new Date(2023, 8, 1, 15, 0, 0); - let progress: Progress = getEmptyProgress(); + const progress: Progress = getEmptyProgress(); - let input: GroupsBuildContext = { + const input: GroupsBuildContext = { allAppletActivities: [], progress, appletId: 'test-applet-id-1', applyInProgressFilter: true, }; - let builder = createActivityGroupsBuilder(input); + const builder = createActivityGroupsBuilder(input); const eventEntity: EventEntity = getScheduledEventEntity({ scheduledAt, @@ -820,11 +820,11 @@ describe('ActivityGroupsBuilder', () => { eventEntity.event.availability.timeFrom = { hours: 15, minutes: 0 }; eventEntity.event.availability.timeTo = { hours: 16, minutes: 30 }; - let now = subDays(scheduledAt, 1); + const now = subDays(scheduledAt, 1); mockGetNow(builder, new Date(now)); - let result = builder.buildAvailable([eventEntity]); + const result = builder.buildAvailable([eventEntity]); const expectedResult: ActivityListGroup = { name: 'additional:available', @@ -838,16 +838,16 @@ describe('ActivityGroupsBuilder', () => { it('Should not return group-item for scheduled event and periodicity is Weekly and allowAccessBeforeFromTime is false when now time is less than timeFrom', () => { const scheduledAt = new Date(2023, 8, 1, 15, 0, 0); - let progress: Progress = getEmptyProgress(); + const progress: Progress = getEmptyProgress(); - let input: GroupsBuildContext = { + const input: GroupsBuildContext = { allAppletActivities: [], progress, appletId: 'test-applet-id-1', applyInProgressFilter: true, }; - let builder = createActivityGroupsBuilder(input); + const builder = createActivityGroupsBuilder(input); const eventEntity: EventEntity = getScheduledEventEntity({ scheduledAt, @@ -877,16 +877,16 @@ describe('ActivityGroupsBuilder', () => { it('Should not return group-item for scheduled event and periodicity is Weekly and allowAccessBeforeFromTime is false when now time is more than timeTo', () => { const scheduledAt = new Date(2023, 8, 1, 15, 0, 0); - let progress: Progress = getEmptyProgress(); + const progress: Progress = getEmptyProgress(); - let input: GroupsBuildContext = { + const input: GroupsBuildContext = { allAppletActivities: [], progress, appletId: 'test-applet-id-1', applyInProgressFilter: true, }; - let builder = createActivityGroupsBuilder(input); + const builder = createActivityGroupsBuilder(input); const eventEntity: EventEntity = getScheduledEventEntity({ scheduledAt, @@ -1026,16 +1026,16 @@ describe('ActivityGroupsBuilder', () => { it(`Should return group-item for scheduled event when periodicity is ${periodicity} and allowAccessBeforeFromTime is true and current time is less than startTime`, () => { const scheduledAt = new Date(2023, 8, 1, 15, 0, 0); - let progress: Progress = getEmptyProgress(); + const progress: Progress = getEmptyProgress(); - let input: GroupsBuildContext = { + const input: GroupsBuildContext = { allAppletActivities: [], progress, appletId: 'test-applet-id-1', applyInProgressFilter: true, }; - let builder = createActivityGroupsBuilder(input); + const builder = createActivityGroupsBuilder(input); const eventEntity: EventEntity = getScheduledEventEntity({ scheduledAt, @@ -1052,7 +1052,7 @@ describe('ActivityGroupsBuilder', () => { mockGetNow(builder, new Date(now)); - let result = builder.buildAvailable([eventEntity]); + const result = builder.buildAvailable([eventEntity]); const expectedItem = getExpectedAvailableItem(); expectedItem.availableTo = new Date(startOfDay(scheduledAt)); @@ -1072,16 +1072,16 @@ describe('ActivityGroupsBuilder', () => { it('Should return group-item for scheduled event when periodicity is Daily and allowAccessBeforeFromTime is true and current time is less than startTime and start/end dates are in the future in 2/3 months', () => { const scheduledAt = new Date(2023, 8, 1, 15, 0, 0); - let progress: Progress = getEmptyProgress(); + const progress: Progress = getEmptyProgress(); - let input: GroupsBuildContext = { + const input: GroupsBuildContext = { allAppletActivities: [], progress, appletId: 'test-applet-id-1', applyInProgressFilter: true, }; - let builder = createActivityGroupsBuilder(input); + const builder = createActivityGroupsBuilder(input); const eventEntity: EventEntity = getScheduledEventEntity({ scheduledAt, @@ -1115,16 +1115,16 @@ describe('ActivityGroupsBuilder', () => { it('Should return group-item for scheduled event when periodicity is Daily and allowAccessBeforeFromTime is true and current time is less than startTime when start/end dates are in the past 3/2 months', () => { const scheduledAt = new Date(2023, 8, 1, 15, 0, 0); - let progress: Progress = getEmptyProgress(); + const progress: Progress = getEmptyProgress(); - let input: GroupsBuildContext = { + const input: GroupsBuildContext = { allAppletActivities: [], progress, appletId: 'test-applet-id-1', applyInProgressFilter: true, }; - let builder = createActivityGroupsBuilder(input); + const builder = createActivityGroupsBuilder(input); const eventEntity: EventEntity = getScheduledEventEntity({ scheduledAt, @@ -1175,7 +1175,7 @@ describe('ActivityGroupsBuilder', () => { applyInProgressFilter: true, }; - let builder = createActivityGroupsBuilder(input); + const builder = createActivityGroupsBuilder(input); const eventEntity: EventEntity = getScheduledEventEntity({ scheduledAt, @@ -1215,16 +1215,16 @@ describe('ActivityGroupsBuilder', () => { it('Should not return group-item for scheduled event when periodicity is Weekly and allowAccessBeforeFromTime is true and scheduledToday is false', () => { const scheduledAt = new Date(2023, 8, 1, 15, 0, 0); - let progress: Progress = getEmptyProgress(); + const progress: Progress = getEmptyProgress(); - let input: GroupsBuildContext = { + const input: GroupsBuildContext = { allAppletActivities: [], progress, appletId: 'test-applet-id-1', applyInProgressFilter: true, }; - let builder = createActivityGroupsBuilder(input); + const builder = createActivityGroupsBuilder(input); const eventEntity: EventEntity = getScheduledEventEntity({ scheduledAt, @@ -1237,11 +1237,11 @@ describe('ActivityGroupsBuilder', () => { eventEntity.event.availability.timeFrom = { hours: 15, minutes: 0 }; eventEntity.event.availability.timeTo = { hours: 16, minutes: 30 }; - let now = subDays(scheduledAt, 1); + const now = subDays(scheduledAt, 1); mockGetNow(builder, new Date(now)); - let result = builder.buildAvailable([eventEntity]); + const result = builder.buildAvailable([eventEntity]); const expectedResult: ActivityListGroup = { name: 'additional:available', @@ -1347,16 +1347,16 @@ describe('ActivityGroupsBuilder', () => { it(`Should return group item when event is scheduled of ${periodicity} periodicity and now is less than scheduledAt and accessBeforeTimeFrom is false and not completed today`, () => { const scheduledAt = new Date(2023, 8, 1, 15, 30, 0); - let progress: Progress = getEmptyProgress(); + const progress: Progress = getEmptyProgress(); - let input: GroupsBuildContext = { + const input: GroupsBuildContext = { allAppletActivities: [], progress, appletId: 'test-applet-id-1', applyInProgressFilter: true, }; - let builder = createActivityGroupsBuilder(input); + const builder = createActivityGroupsBuilder(input); const eventEntity: EventEntity = getScheduledEventEntity({ scheduledAt, @@ -1369,11 +1369,11 @@ describe('ActivityGroupsBuilder', () => { eventEntity.event.availability.timeFrom = { hours: 15, minutes: 0 }; eventEntity.event.availability.timeTo = { hours: 16, minutes: 30 }; - let now = subHours(scheduledAt, 1); + const now = subHours(scheduledAt, 1); mockGetNow(builder, new Date(now)); - let result = builder.buildScheduled([eventEntity]); + const result = builder.buildScheduled([eventEntity]); const expectedItem: ActivityListItem = getExpectedScheduledItem(); expectedItem.availableFrom = startOfDay(scheduledAt); @@ -1395,18 +1395,18 @@ describe('ActivityGroupsBuilder', () => { it('Should return group item when event is scheduled of Daily periodicity and now is less than scheduledAt and accessBeforeTimeFrom is false and not completed today and start/end dates in the future in 2/3 months', () => { const scheduledAt = new Date(2023, 8, 1, 15, 30, 0); - let progress: Progress = getEmptyProgress(); + const progress: Progress = getEmptyProgress(); - let input: GroupsBuildContext = { + const input: GroupsBuildContext = { allAppletActivities: [], progress, appletId: 'test-applet-id-1', applyInProgressFilter: true, }; - let builder = createActivityGroupsBuilder(input); + const builder = createActivityGroupsBuilder(input); - let now = subHours(scheduledAt, 1); + const now = subHours(scheduledAt, 1); mockGetNow(builder, new Date(now)); @@ -1446,18 +1446,18 @@ describe('ActivityGroupsBuilder', () => { it('Should return group item when event is scheduled of Daily periodicity and now is less than scheduledAt and accessBeforeTimeFrom is false and not completed today and start/end dates are in the past: 3/2 months ago', () => { const scheduledAt = new Date(2023, 8, 1, 15, 30, 0); - let progress: Progress = getEmptyProgress(); + const progress: Progress = getEmptyProgress(); - let input: GroupsBuildContext = { + const input: GroupsBuildContext = { allAppletActivities: [], progress, appletId: 'test-applet-id-1', applyInProgressFilter: true, }; - let builder = createActivityGroupsBuilder(input); + const builder = createActivityGroupsBuilder(input); - let now = subHours(scheduledAt, 1); + const now = subHours(scheduledAt, 1); mockGetNow(builder, new Date(now)); @@ -1508,7 +1508,7 @@ describe('ActivityGroupsBuilder', () => { let builder = createActivityGroupsBuilder(input); - let now = subHours(scheduledAt, 1); + const now = subHours(scheduledAt, 1); mockGetNow(builder, new Date(now)); @@ -1564,18 +1564,18 @@ describe('ActivityGroupsBuilder', () => { it('Should not return group item when event is scheduled and now is less than scheduledAt and no progress record and accessBeforeTimeFrom is true', () => { const scheduledAt = new Date(2023, 8, 1, 15, 30, 0); - let progress: Progress = getEmptyProgress(); + const progress: Progress = getEmptyProgress(); - let input: GroupsBuildContext = { + const input: GroupsBuildContext = { allAppletActivities: [], progress, appletId: 'test-applet-id-1', applyInProgressFilter: true, }; - let builder = createActivityGroupsBuilder(input); + const builder = createActivityGroupsBuilder(input); - let now = subHours(scheduledAt, 1); + const now = subHours(scheduledAt, 1); mockGetNow(builder, new Date(now)); @@ -1590,7 +1590,7 @@ describe('ActivityGroupsBuilder', () => { eventEntity.event.availability.timeFrom = { hours: 15, minutes: 0 }; eventEntity.event.availability.timeTo = { hours: 16, minutes: 30 }; - let result = builder.buildScheduled([eventEntity]); + const result = builder.buildScheduled([eventEntity]); const expectedResult: ActivityListGroup = { name: 'additional:scheduled', @@ -1618,7 +1618,7 @@ describe('ActivityGroupsBuilder', () => { const builder = createActivityGroupsBuilder(input); - let now = subHours(scheduledAt, 1); + const now = subHours(scheduledAt, 1); mockGetNow(builder, new Date(now)); @@ -1670,7 +1670,7 @@ describe('ActivityGroupsBuilder', () => { }, }; - let input: GroupsBuildContext = { + const input: GroupsBuildContext = { allAppletActivities: [ { description: 'test-description-1', diff --git a/src/widgets/activity-group/model/factories/ActivityGroupsBuilder.ts b/src/widgets/activity-group/model/factories/ActivityGroupsBuilder.ts index 6c3ac305e..2b1edf752 100644 --- a/src/widgets/activity-group/model/factories/ActivityGroupsBuilder.ts +++ b/src/widgets/activity-group/model/factories/ActivityGroupsBuilder.ts @@ -47,7 +47,7 @@ export class ActivityGroupsBuilder implements IActivityGroupsBuilder { const activityItems: Array = []; - for (let eventActivity of filtered) { + for (const eventActivity of filtered) { const item = this.itemsFactory.createProgressItem(eventActivity); activityItems.push(item); @@ -71,7 +71,7 @@ export class ActivityGroupsBuilder implements IActivityGroupsBuilder { const activityItems: Array = []; - for (let eventActivity of filtered) { + for (const eventActivity of filtered) { const item = this.itemsFactory.createAvailableItem(eventActivity); activityItems.push(item); @@ -95,7 +95,7 @@ export class ActivityGroupsBuilder implements IActivityGroupsBuilder { const activityItems: Array = []; - for (let eventActivity of filtered) { + for (const eventActivity of filtered) { const item = this.itemsFactory.createScheduledItem(eventActivity); activityItems.push(item); diff --git a/src/widgets/activity-group/model/factories/AvailableGroupEvaluator.test.ts b/src/widgets/activity-group/model/factories/AvailableGroupEvaluator.test.ts index 01fecf14e..22b67e69b 100644 --- a/src/widgets/activity-group/model/factories/AvailableGroupEvaluator.test.ts +++ b/src/widgets/activity-group/model/factories/AvailableGroupEvaluator.test.ts @@ -530,7 +530,7 @@ describe('AvailableGroupEvaluator cross-day tests when access before start time let now = buildDateTime(addDays(startAt, 1), TimeTo); - let progressAnchorDate = buildDateTime(startAt, TimeFrom); + const progressAnchorDate = buildDateTime(startAt, TimeFrom); const progress: Progress = getProgress( addMinutes(progressAnchorDate, 10), @@ -932,7 +932,7 @@ describe('AvailableGroupEvaluator cross-day tests when access before start time const evaluator = new AvailableGroupEvaluator(input); - let now = buildDateTime(startAt, { hours: 0, minutes: 0 }); + const now = buildDateTime(startAt, { hours: 0, minutes: 0 }); mockGetNow(evaluator, now); it('Test Once', () => { @@ -1360,7 +1360,7 @@ describe('AvailableGroupEvaluator cross-day tests when access before start time describe('Should not return item when now is 1 minute earlier than TimeTo in next day (Sat) and entity completed in Fri interval after TimeFrom', () => { const startAt = getFridayInSeptember(); - let progressAnchorDate = buildDateTime(startAt, TimeFrom); + const progressAnchorDate = buildDateTime(startAt, TimeFrom); const progress: Progress = getProgress( addMinutes(progressAnchorDate, 10), diff --git a/src/widgets/activity-group/model/factories/AvailableGroupEvaluator.ts b/src/widgets/activity-group/model/factories/AvailableGroupEvaluator.ts index 21a37aabf..268ab2bc6 100644 --- a/src/widgets/activity-group/model/factories/AvailableGroupEvaluator.ts +++ b/src/widgets/activity-group/model/factories/AvailableGroupEvaluator.ts @@ -28,7 +28,7 @@ export class AvailableGroupEvaluator implements IEvaluator { ): boolean { const { event } = eventEntity; - const isScheduledToday = this.utility.isToday(event.scheduledAt!); + const isScheduledToday = this.utility.isToday(event.scheduledAt); const now = this.utility.getNow(); @@ -58,7 +58,7 @@ export class AvailableGroupEvaluator implements IEvaluator { ): boolean { const { event } = eventEntity; - const isScheduledToday = this.utility.isToday(event.scheduledAt!); + const isScheduledToday = this.utility.isToday(event.scheduledAt); const isScheduledYesterday = this.utility.isScheduledYesterday(event); @@ -89,7 +89,7 @@ export class AvailableGroupEvaluator implements IEvaluator { ): boolean { const { event } = eventEntity; - const isScheduledToday = this.utility.isToday(event.scheduledAt!); + const isScheduledToday = this.utility.isToday(event.scheduledAt); const isScheduledYesterday = this.utility.isScheduledYesterday(event); @@ -116,7 +116,7 @@ export class AvailableGroupEvaluator implements IEvaluator { public evaluate(eventsEntities: Array): Array { const result: Array = []; - for (let eventEntity of eventsEntities) { + for (const eventEntity of eventsEntities) { const { event } = eventEntity; if (!this.utility.isInsideValidDatesInterval(event)) { diff --git a/src/widgets/activity-group/model/factories/GroupUtility.ts b/src/widgets/activity-group/model/factories/GroupUtility.ts index 51122e6f6..07ffc97b0 100644 --- a/src/widgets/activity-group/model/factories/GroupUtility.ts +++ b/src/widgets/activity-group/model/factories/GroupUtility.ts @@ -44,7 +44,7 @@ export class GroupUtility { private getStartedAt(eventActivity: EventEntity): Date { const record = this.getProgressRecord(eventActivity)!; - return record.startAt!; + return record.startAt; } private getAllowedTimeInterval( @@ -169,7 +169,7 @@ export class GroupUtility { ): DatesFromTo { const buildFrom = considerSpread && this.isSpreadToNextDay(event); - const { timeFrom, timeTo } = event.availability!; + const { timeFrom, timeTo } = event.availability; let from = this.getToday(); diff --git a/src/widgets/activity-group/model/factories/ScheduledGroupEvaluator.ts b/src/widgets/activity-group/model/factories/ScheduledGroupEvaluator.ts index 515eb04bf..df2804e53 100644 --- a/src/widgets/activity-group/model/factories/ScheduledGroupEvaluator.ts +++ b/src/widgets/activity-group/model/factories/ScheduledGroupEvaluator.ts @@ -20,7 +20,7 @@ export class ScheduledGroupEvaluator implements IEvaluator { const now = this.utility.getNow(); - for (let eventEntity of eventsEntities) { + for (const eventEntity of eventsEntities) { const { event } = eventEntity; if (!this.utility.isInsideValidDatesInterval(event)) { @@ -36,7 +36,7 @@ export class ScheduledGroupEvaluator implements IEvaluator { const isCompletedToday = this.utility.isCompletedToday(eventEntity); - const isScheduledToday = this.utility.isToday(event.scheduledAt!); + const isScheduledToday = this.utility.isToday(event.scheduledAt); const isSpreadToNextDay = this.utility.isSpreadToNextDay(event); @@ -59,7 +59,7 @@ export class ScheduledGroupEvaluator implements IEvaluator { const isMonday = now.getDay() === 1; - let doSimpleSpreadCheck: boolean = + const doSimpleSpreadCheck: boolean = periodicity === PeriodicityType.Weekly || periodicity === PeriodicityType.Monthly || periodicity === PeriodicityType.Once || diff --git a/src/widgets/activity-group/model/hooks/mocks/mocksForItems.ts b/src/widgets/activity-group/model/hooks/mocks/mocksForItems.ts index 62968482b..bbd3e93c8 100644 --- a/src/widgets/activity-group/model/hooks/mocks/mocksForItems.ts +++ b/src/widgets/activity-group/model/hooks/mocks/mocksForItems.ts @@ -10,10 +10,10 @@ import { ActivityListGroup, } from '../../../lib'; -let groupMocks: ActivityListGroup[] = []; +const groupMocks: ActivityListGroup[] = []; for (let i = 0; i < 3; i++) { - let activities: ActivityListItem[] = []; + const activities: ActivityListItem[] = []; groupMocks.push({ activities, diff --git a/src/widgets/activity-group/model/services/ActivityGroupsBuildManager.ts b/src/widgets/activity-group/model/services/ActivityGroupsBuildManager.ts index aaf6d0c7c..521395ae4 100644 --- a/src/widgets/activity-group/model/services/ActivityGroupsBuildManager.ts +++ b/src/widgets/activity-group/model/services/ActivityGroupsBuildManager.ts @@ -125,7 +125,7 @@ const createActivityGroupsBuildManager = (logger: ILogger) => { const calculator = EventModel.ScheduledDateCalculator; - for (let eventActivity of entityEvents) { + for (const eventActivity of entityEvents) { const date = calculator.calculate(eventActivity.event); eventActivity.event.scheduledAt = date; @@ -147,17 +147,16 @@ const createActivityGroupsBuildManager = (logger: ILogger) => { try { logInfo = 'building in-progress'; - result.groups.push(builder!.buildInProgress(entityEvents)); + result.groups.push(builder.buildInProgress(entityEvents)); logInfo = 'building available'; - result.groups.push(builder!.buildAvailable(entityEvents)); + result.groups.push(builder.buildAvailable(entityEvents)); logInfo = 'building scheduled'; - result.groups.push(builder!.buildScheduled(entityEvents)); + result.groups.push(builder.buildScheduled(entityEvents)); } catch (error) { logger.warn( - `[ActivityGroupsBuildManager.processInternal]: Build error occurred while ${logInfo}:\n\n` + - error!.toString(), + `[ActivityGroupsBuildManager.processInternal]: Build error occurred while ${logInfo}:\n\n${error}`, ); result.otherError = true; } @@ -186,8 +185,7 @@ const createActivityGroupsBuildManager = (logger: ILogger) => { return result; } catch (error) { logger.warn( - '[ActivityGroupsBuildManager.process] Error occurred\nInternal error:\n' + - error!.toString(), + `[ActivityGroupsBuildManager.process] Error occurred\nInternal error:\n${error}`, ); return { groups: [], otherError: true }; } diff --git a/src/widgets/activity-group/ui/ActivityGroups.tsx b/src/widgets/activity-group/ui/ActivityGroups.tsx index 998518758..6138fabc2 100644 --- a/src/widgets/activity-group/ui/ActivityGroups.tsx +++ b/src/widgets/activity-group/ui/ActivityGroups.tsx @@ -35,7 +35,7 @@ const ActivityGroups: FC = props => { queryKey: getAppletCompletedEntitiesKey(props.appletId), }) > 0; - let { groups, isSuccess, error } = useActivityGroups(props.appletId); + const { groups, isSuccess, error } = useActivityGroups(props.appletId); const hasError = !isSuccess; diff --git a/src/widgets/survey/model/hooks/useAutoCompletion.ts b/src/widgets/survey/model/hooks/useAutoCompletion.ts index a7b235fc9..a95125bdd 100644 --- a/src/widgets/survey/model/hooks/useAutoCompletion.ts +++ b/src/widgets/survey/model/hooks/useAutoCompletion.ts @@ -112,14 +112,14 @@ const useAutoCompletion = (): Result => { '[useAutoCompletion.completeEntityIntoUploadToQueue] Started', ); - let collectOutputs = collectService.collectForEntity(entityPath); + const collectOutputs = collectService.collectForEntity(entityPath); Logger.log( '[useAutoCompletion.completeEntityIntoUploadToQueue] collectOutputs: \n' + JSON.stringify(collectOutputs, null, 2), ); - for (let collectOutput of collectOutputs) { + for (const collectOutput of collectOutputs) { await constructInternal(collectOutput, constructService); } @@ -153,7 +153,7 @@ const useAutoCompletion = (): Result => { Logger.log('[useAutoCompletion.processAutocompletion] Started'); - let collectOutputs = collectAllInternal(collectService, exclude); + const collectOutputs = collectAllInternal(collectService, exclude); completionsCollected = !!collectOutputs.length; @@ -162,7 +162,7 @@ const useAutoCompletion = (): Result => { JSON.stringify(collectOutputs, null, 2), ); - for (let collectOutput of collectOutputs) { + for (const collectOutput of collectOutputs) { await constructInternal(collectOutput, constructService); } diff --git a/src/widgets/survey/model/hooks/useFlowStateActions.ts b/src/widgets/survey/model/hooks/useFlowStateActions.ts index 6d7175982..4256a3fb4 100644 --- a/src/widgets/survey/model/hooks/useFlowStateActions.ts +++ b/src/widgets/survey/model/hooks/useFlowStateActions.ts @@ -58,7 +58,7 @@ export function useFlowStateActions({ const step = getStep(record); upsertFlowStorageRecord({ - ...record!, + ...record, step: step + 1, }); } @@ -66,7 +66,7 @@ export function useFlowStateActions({ function saveActivitySummary(activitySummary: ActivitySummaryData) { const record: FlowState = getCurrentFlowStorageRecord()!; - let updatedContext: Record = { + const updatedContext: Record = { ...(record.context ?? {}), }; @@ -139,7 +139,7 @@ export function useFlowStateActions({ upsertFlowStorageRecord({ ...record, - step: pipeline!.length - 1, + step: pipeline.length - 1, isCompletedDueToTimer: true, }); } diff --git a/src/widgets/survey/model/hooks/useSummaryData.ts b/src/widgets/survey/model/hooks/useSummaryData.ts index 3c9ae763b..269ac691a 100644 --- a/src/widgets/survey/model/hooks/useSummaryData.ts +++ b/src/widgets/survey/model/hooks/useSummaryData.ts @@ -103,7 +103,7 @@ export const useSummaryData = ({ const fullAlertsList: AnswerAlerts = []; const fullScoresList: ActivityScores[] = []; - for (let aid of activityIds) { + for (const aid of activityIds) { const { alerts, scores } = flowSummaryData[aid]; fullAlertsList.push(...alerts); fullScoresList.push(scores); diff --git a/src/widgets/survey/model/mappers.ts b/src/widgets/survey/model/mappers.ts index b98b77cea..4a95f294d 100644 --- a/src/widgets/survey/model/mappers.ts +++ b/src/widgets/survey/model/mappers.ts @@ -26,7 +26,6 @@ import { GeolocationAnswerDto, NumberSelectAnswerDto, PhotoAnswerDto, - RadioAnswerDto, SliderAnswerDto, StackedCheckboxAnswerDto, StackedRadioAnswerDto, @@ -116,7 +115,7 @@ const mapFlankerAnswersToDto = ( .filter(x => !!answers[x]) .map(x => convertToAnswerDto('Flanker', answers[x])); - for (let practiceAnswerDto of restOfAnswerDtos) { + for (const practiceAnswerDto of restOfAnswerDtos) { const records = (practiceAnswerDto as ObjectAnswerDto) .value as Array; @@ -149,7 +148,7 @@ function convertToSingleSelectAnswer(answer: Answer): AnswerDto { return { ...(radioValue && { - value: radioValue.value as RadioAnswerDto, + value: radioValue.value, }), ...(answer.additionalAnswer && { text: answer.additionalAnswer, @@ -521,9 +520,7 @@ export function mapAnswersToAlerts( return alerts as AnswerAlertsDto; } catch (error) { - Logger.warn( - '[mapAnswersToAlerts]: Error occurred: \n\n' + error!.toString(), - ); + Logger.warn(`[mapAnswersToAlerts]: Error occurred: \n\n${error}`); throw error; } } diff --git a/src/widgets/survey/model/operations.ts b/src/widgets/survey/model/operations.ts index 1351b18af..9018cdd3a 100644 --- a/src/widgets/survey/model/operations.ts +++ b/src/widgets/survey/model/operations.ts @@ -19,7 +19,7 @@ export const getScheduledDate = (event: ScheduleEvent) => { if ( event.availability.availabilityType !== AvailabilityType.AlwaysAvailable ) { - return EventModel.ScheduledDateCalculator.calculate(event!)!.valueOf(); + return EventModel.ScheduledDateCalculator.calculate(event)!.valueOf(); } }; diff --git a/src/widgets/survey/model/services/CollectCompletionsService.ts b/src/widgets/survey/model/services/CollectCompletionsService.ts index e553a1ad4..77539bd35 100644 --- a/src/widgets/survey/model/services/CollectCompletionsService.ts +++ b/src/widgets/survey/model/services/CollectCompletionsService.ts @@ -172,7 +172,7 @@ export class CollectCompletionsService implements ICollectCompletionsService { ); } - for (let notCompletedEntity of filtered) { + for (const notCompletedEntity of filtered) { const { appletId, entityId, diff --git a/src/widgets/survey/model/services/ConstructCompletionsService.ts b/src/widgets/survey/model/services/ConstructCompletionsService.ts index 5f1b27624..e78ebdf4a 100644 --- a/src/widgets/survey/model/services/ConstructCompletionsService.ts +++ b/src/widgets/survey/model/services/ConstructCompletionsService.ts @@ -182,7 +182,7 @@ export class ConstructCompletionsService { activityName, ); - this.saveActivitySummary!({ + this.saveActivitySummary({ activityId, order, alerts: summaryAlerts, diff --git a/src/widgets/survey/model/services/tests/CollectCompletionsService.collectForEntity.test.ts b/src/widgets/survey/model/services/tests/CollectCompletionsService.collectForEntity.test.ts index 6bdee8e7c..b78c006bc 100644 --- a/src/widgets/survey/model/services/tests/CollectCompletionsService.collectForEntity.test.ts +++ b/src/widgets/survey/model/services/tests/CollectCompletionsService.collectForEntity.test.ts @@ -34,7 +34,7 @@ describe('Test CollectCompletionsService: collectForEntity', () => { }); it('Should return empty array when entity progress exist, but availableTo is null', () => { - let progress = getRegularProgressRecord(pathOne); + const progress = getRegularProgressRecord(pathOne); progress.payload.availableTo = null; const service = new CollectCompletionsService([progress]); @@ -45,7 +45,7 @@ describe('Test CollectCompletionsService: collectForEntity', () => { }); it('Should return empty array when entity progress exist, but availableTo is undefined', () => { - let progress = getRegularProgressRecord(pathOne); + const progress = getRegularProgressRecord(pathOne); progress.payload.availableTo = null; const service = new CollectCompletionsService([progress]); @@ -60,7 +60,7 @@ describe('Test CollectCompletionsService: collectForEntity', () => { .spyOn(survey, 'isEntityExpired') .mockReturnValue(false); - let progress = getRegularProgressRecord(pathOne); + const progress = getRegularProgressRecord(pathOne); progress.payload.availableTo = new Date(2023, 2, 5).getTime(); const service = new CollectCompletionsService([progress]); diff --git a/src/widgets/survey/model/services/tests/testHelpers.ts b/src/widgets/survey/model/services/tests/testHelpers.ts index 4691a4057..5fb7a2892 100644 --- a/src/widgets/survey/model/services/tests/testHelpers.ts +++ b/src/widgets/survey/model/services/tests/testHelpers.ts @@ -146,7 +146,7 @@ export const getMultipleActivityFlowState = (path: EntityPath): FlowState => { export const deleteLogAvailableTo = ( collected: CollectCompletionOutput[], ): CollectCompletionOutput[] => { - for (let item of collected) { + for (const item of collected) { delete item.logAvailableTo; } return collected; diff --git a/src/widgets/survey/ui/Finish.tsx b/src/widgets/survey/ui/Finish.tsx index 8e30c2a9b..ebbc332f9 100644 --- a/src/widgets/survey/ui/Finish.tsx +++ b/src/widgets/survey/ui/Finish.tsx @@ -62,7 +62,7 @@ function FinishItem({ const { process: processWithAutocompletion } = useAutoCompletion(); - let finishReason: FinishReason = isTimerElapsed ? 'time-is-up' : 'regular'; + const finishReason: FinishReason = isTimerElapsed ? 'time-is-up' : 'regular'; async function completeActivity() { const constructCompletionService = new ConstructCompletionsService( diff --git a/src/widgets/survey/ui/FlowSurvey.tsx b/src/widgets/survey/ui/FlowSurvey.tsx index 1fa1b9371..b15fa6059 100644 --- a/src/widgets/survey/ui/FlowSurvey.tsx +++ b/src/widgets/survey/ui/FlowSurvey.tsx @@ -92,7 +92,7 @@ function FlowSurvey({ return (