Skip to content

Commit

Permalink
#362: fixed linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
basmasking committed Jan 3, 2025
1 parent 85b2c1e commit 21ae14b
Show file tree
Hide file tree
Showing 45 changed files with 97 additions and 113 deletions.
File renamed without changes.
37 changes: 0 additions & 37 deletions eslint.config.mjs

This file was deleted.

4 changes: 2 additions & 2 deletions src/domain/creator/definitions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import type { Validation } from '^/integrations/validation/module';

import { SortOrder } from '../definitions';
import { SortOrder, SortOrderEnum } from '../definitions';

export const RECORD_TYPE = 'creator';
export const IMAGE_TYPE = 'portrait';
Expand All @@ -18,4 +18,4 @@ export const fullNameValidation: Validation = {
}
};

export { SortOrder };
export { SortOrderEnum, type SortOrder };
4 changes: 2 additions & 2 deletions src/domain/creator/getOthers/feature.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import database, { QueryStatement, RecordQuery, RecordSort, SortDirections } from '^/integrations/database/module';

import { RECORD_TYPE, SortOrder } from '../definitions';
import { RECORD_TYPE, SortOrder, SortOrderEnum } from '../definitions';
import type { DataModel } from '../types';

export default async function feature(ids: string[], order: SortOrder, search: string | undefined = undefined, limit: number, offset: number): Promise<DataModel[]>
Expand All @@ -14,7 +14,7 @@ export default async function feature(ids: string[], order: SortOrder, search: s
]
};

const sortField = order === SortOrder.POPULAR ? 'popularity' : 'joinedAt';
const sortField = order === SortOrderEnum.POPULAR ? 'popularity' : 'joinedAt';

const query: QueryStatement = search !== undefined ? { ...defaultQuery, ...searchQuery } : defaultQuery;
const recordSort: RecordSort = { [sortField]: SortDirections.ASCENDING };
Expand Down
6 changes: 3 additions & 3 deletions src/domain/definitions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import type { Validation } from '^/integrations/validation/module';

export const SortOrder = {
export const SortOrderEnum = {
POPULAR: 'popular',
RECENT: 'recent'
} as const;
Expand All @@ -26,6 +26,6 @@ export const optionalIdValidation: Validation =
}
};

type SortOrderKeys = keyof typeof SortOrder;
type SortOrderKeys = keyof typeof SortOrderEnum;

export type SortOrder = typeof SortOrder[SortOrderKeys];
export type SortOrder = typeof SortOrderEnum[SortOrderKeys];
6 changes: 3 additions & 3 deletions src/domain/notification/definitions.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

export const RECORD_TYPE = 'notification';

export const Types = {
export const TypesEnum = {
STARTED_FOLLOWING: 'started-following',
RATED_POST: 'rated-post',
RATED_REACTION: 'rated-reaction',
ADDED_REACTION: 'added-reaction'
} as const;

type TypeKeys = keyof typeof Types;
type TypeKeys = keyof typeof TypesEnum;

export type Types = typeof Types[TypeKeys];
export type Types = typeof TypesEnum[TypeKeys];
4 changes: 2 additions & 2 deletions src/domain/post/toggleRating/feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import logger from '^/integrations/logging/module';

import type { Requester } from '^/domain/authentication/types';
import createNotification from '^/domain/notification/create/feature';
import { Types } from '^/domain/notification/definitions';
import { TypesEnum } from '^/domain/notification/definitions';
import getPost from '^/domain/post/getById/feature';
import updateRating from '^/domain/rating/update/feature';

Expand All @@ -28,7 +28,7 @@ export default async function feature(requester: Requester, postId: string): Pro

const post = await getPost(postId);

await createNotification(Types.RATED_POST, requester.id, post.creatorId, postId);
await createNotification(TypesEnum.RATED_POST, requester.id, post.creatorId, postId);

return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/domain/reaction/create/feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import logger from '^/integrations/logging/module';
import updateReactionCount from '^/domain/post/updateReactionCount/feature';

import createNotification from '^/domain/notification/create/feature';
import { Types } from '^/domain/notification/definitions';
import { TypesEnum } from '^/domain/notification/definitions';
import retrievePost from '^/domain/post/getById/feature';
import createData from './createData';
import eraseData from './eraseData';
Expand All @@ -27,7 +27,7 @@ export default async function feature(creatorId: string, postId: string, comicId

const post = await retrievePost(postId);

await createNotification(Types.ADDED_REACTION, creatorId, post.creatorId, postId, id);
await createNotification(TypesEnum.ADDED_REACTION, creatorId, post.creatorId, postId, id);

return id;
}
Expand Down
4 changes: 2 additions & 2 deletions src/domain/reaction/toggleRating/feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import logger from '^/integrations/logging/module';

import type { Requester } from '^/domain/authentication/types';
import createNotification from '^/domain/notification/create/feature';
import { Types } from '^/domain/notification/definitions';
import { TypesEnum } from '^/domain/notification/definitions';
import updateRating from '^/domain/rating/update/feature';
import getReaction from '^/domain/reaction/getById/feature';

Expand All @@ -28,7 +28,7 @@ export default async function feature(requester: Requester, reactionId: string):

const reaction = await getReaction(reactionId);

await createNotification(Types.RATED_REACTION, requester.id, reaction.creatorId, undefined, reactionId);
await createNotification(TypesEnum.RATED_REACTION, requester.id, reaction.creatorId, undefined, reactionId);

return true;
}
Expand Down
5 changes: 3 additions & 2 deletions src/domain/relation/definitions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

import { SortOrder } from '../definitions';
import { SortOrder, SortOrderEnum } from '../definitions';

export const RECORD_TYPE = 'relation';

export { SortOrder };
export { SortOrderEnum, type SortOrder };

4 changes: 2 additions & 2 deletions src/domain/relation/establish/feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import updateFollowerCount from '^/domain/creator/updateFollowerCount/feature';
import updateFollowingCount from '^/domain/creator/updateFollowingCount/feature';

import createNotification from '^/domain/notification/create/feature';
import { Types } from '^/domain/notification/definitions';
import { TypesEnum } from '^/domain/notification/definitions';
import createData from './createData';
import dataExists from './dataExists';
import eraseData from './eraseData';
Expand Down Expand Up @@ -37,7 +37,7 @@ export default async function feature(requester: Requester, followingId: string)

await updateFollowingCount(requester.id, 'increase');

await createNotification(Types.STARTED_FOLLOWING, requester.id, followingId);
await createNotification(TypesEnum.STARTED_FOLLOWING, requester.id, followingId);
}
catch (error: unknown)
{
Expand Down
1 change: 1 addition & 0 deletions src/integrations/authentication/definitions/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type Identity = {
email_verified: boolean;
};

// eslint-disable-next-line sonarjs/redundant-type-aliases
type Token = string;

type Session = {
Expand Down
2 changes: 2 additions & 0 deletions src/integrations/database/definitions/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

/* eslint sonarjs/redundant-type-aliases: "off" */

import { QueryOperators, SortDirections } from './constants';

export type RecordType = string;
Expand Down
3 changes: 2 additions & 1 deletion src/integrations/database/implementations/memory/Memory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const LOGICAL_OPERATORS =

export default class Memory implements Driver
{
#memory: Map<string, RecordData[]> = new Map();
#memory = new Map<string, RecordData[]>();
#connected = false;
recordId = 0;

Expand Down Expand Up @@ -168,6 +168,7 @@ export default class Memory implements Driver
const statementCode = this.#buildStatementCode(query);
const functionCode = statementCode === '' ? 'true' : statementCode;

// eslint-disable-next-line sonarjs/code-eval
return new Function('record', `return ${functionCode}`) as FilterFunction;
}

Expand Down
6 changes: 2 additions & 4 deletions src/integrations/database/implementations/mongodb/MongoDb.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

/* eslint-disable @typescript-eslint/no-explicit-any */

import { Collection, Db, Document, Filter, MongoClient, Sort } from 'mongodb';

import { ID, LogicalOperators, QueryOperators, SortDirections } from '../../definitions/constants.js';
Expand Down Expand Up @@ -182,10 +184,8 @@ export default class MongoDB implements Driver
return; // Deliberately not implemented
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any, sonarjs/cognitive-complexity
#buildMongoQuery(query: RecordQuery): Filter<any>
{
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const mongoQuery: Filter<any> = {};
const multiStatements = query as QueryMultiExpressionStatement;
const singleStatements = query as QuerySingleExpressionStatement;
Expand All @@ -195,7 +195,6 @@ export default class MongoDB implements Driver
if (key === 'AND' || key === 'OR')
{
const singleMultiStatements = multiStatements[key] ?? [];
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const multiMongoQuery: Filter<any>[] = [];

for (const statement of singleMultiStatements)
Expand Down Expand Up @@ -246,7 +245,6 @@ export default class MongoDB implements Driver
return mongoSort;
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
async #getCollection<T>(name: RecordType): Promise<Collection<T extends Document ? any : any>>
{
if (this.#database === undefined)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import NotConnected from '../../errors/NotConnected.js';

export default class Memory implements FileStore
{
#files: Map<string, Buffer> = new Map();
#files = new Map<string, Buffer>();
#connected = false;

get connected() { return this.#connected; }
Expand Down
2 changes: 1 addition & 1 deletion src/integrations/logging/Logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default class Logger implements LogProcessor
#processor: LogProcessor;
#debugEnabled: boolean;

constructor(processor: LogProcessor, debugEnabled: boolean = false)
constructor(processor: LogProcessor, debugEnabled = false)
{
this.#processor = processor;
this.#debugEnabled = debugEnabled;
Expand Down
6 changes: 4 additions & 2 deletions src/integrations/runtime/healthchecks/DatabaseHealthCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ import type { Database } from '^/integrations/database/module';
export default class DatabaseHealthCheck implements HealthCheck
{
#database: Database;
#name = 'database';
#timeout = 5000;

constructor(database: Database)
{
this.#database = database;
}

get name() { return 'database'; }
get name() { return this.#name; }

get timeout() { return 5000; }
get timeout() { return this.#timeout; }

async isHealthy(): Promise<boolean>
{
Expand Down
6 changes: 4 additions & 2 deletions src/integrations/runtime/healthchecks/FileStoreHealthCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ import { FileStore } from '^/integrations/filestore/definitions/interfaces';
export default class FileStoreHealthCheck implements HealthCheck
{
#fileStore: FileStore;
#name = 'filestore';
#timeout = 5000;

constructor(fileStore: FileStore)
{
this.#fileStore = fileStore;
}

get name() { return 'filestore'; }
get name() { return this.#name; }

get timeout() { return 5000; }
get timeout() { return this.#timeout; }

async isHealthy(): Promise<boolean>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ import { NotificationService } from '^/integrations/notification/definitions/int
export default class NotificationHealthCheck implements HealthCheck
{
#notificationService: NotificationService;
#name = 'notifications';
#timeout = 5000;

constructor(notificationService: NotificationService)
{
this.#notificationService = notificationService;
}

get name() { return 'notifications'; }
get name() { return this.#name; }

get timeout() { return 5000; }
get timeout() { return this.#timeout; }

async isHealthy(): Promise<boolean>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export default class AuthenticationMiddleware implements Middleware

return newSession;
}
catch (error)
catch
{
throw new Unauthorized('Session expired');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default class ValidationResult
#invalid: boolean;
#messages: Map<string, string>;

constructor(invalid: boolean, messages: Map<string, string> = new Map())
constructor(invalid: boolean, messages = new Map<string, string>())
{
this.#invalid = invalid;
this.#messages = messages;
Expand Down
2 changes: 2 additions & 0 deletions src/integrations/validation/definitions/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

/* eslint sonarjs/redundant-type-aliases: "off" */

import { FieldTypes } from './constants';

export type ValidationType = keyof typeof FieldTypes;
Expand Down
2 changes: 1 addition & 1 deletion src/integrations/validation/implementations/zod/Zod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type ValidatorFunction = (value: ValidationTypes[keyof ValidationTypes]) => z.Zo

export default class Zod implements Validator
{
#validations: Map<string, ValidatorFunction> = new Map();
#validations = new Map<string, ValidatorFunction>();

constructor()
{
Expand Down
1 change: 1 addition & 0 deletions src/webui/components/common/hooks/useLoadOnScroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default function useLoadOnScroll(onLoad: LoadHandler, isLoading: boolean,
}
};

// eslint-disable-next-line @typescript-eslint/no-unused-expressions
isFinished
? container.removeEventListener('scroll', handleScroll)
: container.addEventListener('scroll', handleScroll);
Expand Down
1 change: 1 addition & 0 deletions src/webui/components/rating/hooks/useEngagement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default function useEngagement(isEngaged: boolean, count: number, engage:
{
const isRated = await engage();

// eslint-disable-next-line @typescript-eslint/no-unused-expressions
isRated
? setRatingCount(ratingCount + 1)
: setRatingCount(ratingCount - 1);
Expand Down
1 change: 1 addition & 0 deletions src/webui/components/relation/elementary/FollowRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default function Component({ isFollowing, isSelf, onFollowClick, onEditCl
return <Row alignX='justify' alignY='top'>
{children}
{isSelf
// eslint-disable-next-line sonarjs/no-nested-conditional
? onEditClick !== undefined
? <EditButton onClick={onEditClick} />
: <></>
Expand Down
1 change: 1 addition & 0 deletions src/webui/designsystem/elements/modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default function Element({ open, sizing = 'content', children }: Props)

useEffect(() =>
{
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
open
? ref.current?.showModal()
: ref.current?.close();
Expand Down
Loading

0 comments on commit 21ae14b

Please sign in to comment.