Skip to content

Commit

Permalink
M2-5381: Lint files
Browse files Browse the repository at this point in the history
  • Loading branch information
sultanofcardio committed Apr 26, 2024
1 parent 7776f86 commit f672316
Show file tree
Hide file tree
Showing 78 changed files with 307 additions and 341 deletions.
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion jest.components.jsx
Original file line number Diff line number Diff line change
@@ -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: () => <></>,
Expand Down
6 changes: 3 additions & 3 deletions src/abstract/lib/utils/progressConvert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/app/model/migrations/MigrationProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)!;

Check warning on line 69 in src/app/model/migrations/MigrationProcessor.ts

View workflow job for this annotation

GitHub Actions / ESLint

src/app/model/migrations/MigrationProcessor.ts#L69

Forbidden non-null assertion (@typescript-eslint/no-non-null-assertion)
regularStorage.set(key, value);
}
Expand All @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/model/migrations/MigrationRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class MigrationRunner implements IMigrationRunner {
currentVersion: number,
inboundVersion: number,
): Promise<MigrationOutput> {
let migrationKeys = this.getMigrationKeys(currentVersion, inboundVersion);
const migrationKeys = this.getMigrationKeys(currentVersion, inboundVersion);

Logger.log(
`[MigrationRunner]: migrationKeys: [${migrationKeys}]${

Check warning on line 35 in src/app/model/migrations/MigrationRunner.ts

View workflow job for this annotation

GitHub Actions / ESLint

src/app/model/migrations/MigrationRunner.ts#L35

Invalid type "number[]" of template literal expression (@typescript-eslint/restrict-template-expressions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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,
);
Expand Down Expand Up @@ -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 = '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -153,7 +153,7 @@ export const getUpdatedReduxState = (
},
};

for (let flow of progressFlowsTo) {
for (const flow of progressFlowsTo) {
result = {
...result,
applets: {
Expand Down
4 changes: 2 additions & 2 deletions src/entities/abTrail/ui/AbShapes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const AbShapes: FC<Props> = props => {

const endOffset = getEndOffset();

let errorMiddlePoint: Point | null = errorPath
const errorMiddlePoint: Point | null = errorPath
? getEquidistantPoint(errorPath)
: null;

Expand All @@ -119,7 +119,7 @@ const AbShapes: FC<Props> = props => {
x={errorMiddlePoint.x + CrossOffsetX}
y={errorMiddlePoint.y}
text={'x'}
font={fontCross!}
font={fontCross}
color={colors.red}
/>
</Group>
Expand Down
Original file line number Diff line number Diff line change
@@ -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();

Expand Down
21 changes: 7 additions & 14 deletions src/entities/activity/lib/services/AnswersUploadService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
);
}
}
Expand Down Expand Up @@ -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}`,
);
}

Expand Down Expand Up @@ -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}`,
);
}

Expand Down Expand Up @@ -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}`,
);
}

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

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

Expand Down Expand Up @@ -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}`,
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/entities/activity/lib/services/MediaFilesCleaner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ 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) {
urlsToProcess.push(record.uri);
}
}

for (let fileUrl of urlsToProcess) {
for (const fileUrl of urlsToProcess) {
try {
const fileExists = await FileSystem.exists(fileUrl);

Expand Down
3 changes: 1 addition & 2 deletions src/entities/activity/lib/services/QueueProcessingService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const createEntityActivitiesCollector = (): EntityActivitiesCollector => {

const activityIds: string[] = flowDto!.activityIds;

for (let activityId of activityIds) {
for (const activityId of activityIds) {
addActivity(activityId);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/entities/activity/ui/ActivityFlowStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const ActivityFlowStep: FC<Props> = props => {
accessibilityLabel="activity-card-flow"
opacity={hasOpacity ? 0.5 : 1}
>
{`(${activityPositionInFlow!} of ${numberOfActivitiesInFlow!}) ${activityFlowName}`}
{`(${activityPositionInFlow} of ${numberOfActivitiesInFlow}) ${activityFlowName}`}
</Text>
</XStack>
);
Expand Down
8 changes: 4 additions & 4 deletions src/entities/applet/model/hooks/useStartEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,14 @@ function useStartEntity({
'regular',
);

let isActivityInProgress = await evaluateProgressWithAutocompletion(
const isActivityInProgress = await evaluateProgressWithAutocompletion(
appletId,
activityId,
eventId,
'regular',
);

return new Promise<StartResult>(async resolve => {
return new Promise<StartResult>(resolve => {
if (!MigrationValidator.allMigrationHaveBeenApplied()) {
onMigrationsNotApplied();
resolve({
Expand Down Expand Up @@ -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;
};
Expand All @@ -378,7 +378,7 @@ function useStartEntity({
'flow',
);

let isFlowInProgress = await evaluateProgressWithAutocompletion(
const isFlowInProgress = await evaluateProgressWithAutocompletion(
appletId,
flowId,
eventId,
Expand Down
6 changes: 3 additions & 3 deletions src/entities/applet/model/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions src/entities/applet/model/services/RefreshAppletService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions src/entities/applet/model/services/RefreshService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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();
Expand Down
Loading

0 comments on commit f672316

Please sign in to comment.