Skip to content

Commit

Permalink
Merge pull request #254 from codex-team/eslint-update
Browse files Browse the repository at this point in the history
feat[eslint]: updated eslint and codex-eslint-config to latest
  • Loading branch information
e11sy authored Jun 5, 2024
2 parents 93a0530 + 6e2cc2b commit 3555d34
Show file tree
Hide file tree
Showing 100 changed files with 1,404 additions and 898 deletions.
34 changes: 0 additions & 34 deletions .eslintrc.cjs

This file was deleted.

25 changes: 25 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import CodeX from 'eslint-config-codex';
/**
* @todo connect architecture config
*/
export default [
...CodeX,
{
name: 'notex.api',
rules: {
'n/no-missing-import': ['off'],
'n/no-unpublished-import': ['error', {
allowModules: ['vitest', 'postgres-migrations', 'eslint-import-resolver-alias', 'eslint-config-codex'],
ignoreTypeImport: true,
}],
},

languageOptions: {
parserOptions: {
project: 'tsconfig.json', // Автоматически находить tsconfig.json в рабочей директории
tsconfigRootDir: './',
sourceType: 'module', // Allows for the use of imports
},
},
},
];
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"start": "node dist/index.js -c app-config.yaml -c app-config.local.yaml",
"start:dev": "yarn build && node dist/index.js -c app-config.yaml -c app-config.local.yaml",
"migrate": "node --loader ts-node/esm ./src/repository/storage/postgres/migrations/index.ts -c app-config.yaml -c app-config.local.yaml",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"lint": "eslint",
"lint:fix": "eslint --fix",
"test:dev": "vitest",
"test": "vitest run",
"coverage": "vitest run --coverage",
Expand All @@ -25,15 +25,17 @@
"@types/node": "^20.2.3",
"@types/pg": "^8.10.2",
"@vitest/coverage-v8": "^0.34.5",
"eslint": "^8.41.0",
"eslint-config-codex": "^1.9.2",
"eslint": "^9.2.0",
"eslint-config-codex": "^2.0.0",
"eslint-import-resolver-alias": "1.1.2",
"eslint-plugin-vitest": "^0.3.1",
"nodemon": "^2.0.22",
"pino-pretty": "^10.0.0",
"postgres-migrations": "^5.3.0",
"ts-node": "^10.9.1",
"tsc-alias": "^1.8.6",
"typescript": "^5.0.4",
"typescript-eslint": "^7.6.0",
"vitest": "^1.4.0"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/domain/entities/editorTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default interface EditorTool {
* Tool URL in content delivery network
*/
cdn?: string;
}
};
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/domain/entities/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export enum FileType {
/**
* File is a part of note
*/
NoteAttachment = 1,
NoteAttachment = 1
}

/**
Expand All @@ -36,7 +36,7 @@ export type TestFileLocation = Record<never, never>;
* File location, when it is a part of note
*/
export type NoteAttachmentFileLocation = {
noteId: NoteInternalId,
noteId: NoteInternalId;
};

/**
Expand All @@ -48,8 +48,8 @@ export type FileLocation = TestFileLocation | NoteAttachmentFileLocation;
* File location type, wich depends on file type
*/
export interface FileLocationByType {
[FileType.Test]: TestFileLocation,
[FileType.NoteAttachment]: NoteAttachmentFileLocation,
[FileType.Test]: TestFileLocation;
[FileType.NoteAttachment]: NoteAttachmentFileLocation;
}

/**
Expand Down
9 changes: 4 additions & 5 deletions src/domain/entities/note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ export type ToolUsedInNoteContent = {
/**
* Name of certain editor tool
*/
name: EditorTool['name'],
name: EditorTool['name'];

/**
* Id of certain editor tool (nanoid)
*/
id: EditorTool['id']
id: EditorTool['id'];
};

/**
Expand All @@ -48,8 +48,8 @@ export interface Note {
id: string;
type: string;
data: unknown;
tunes?: {[name: string]: unknown}
}>
tunes?: { [name: string]: unknown };
}>;
};

/**
Expand All @@ -73,7 +73,6 @@ export interface Note {
tools: ToolUsedInNoteContent[];
}


/**
* Part of note entity used to create new note
*/
Expand Down
2 changes: 0 additions & 2 deletions src/domain/entities/noteList.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { Note } from '@domain/entities/note.js';
import type { NotePublic } from '@domain/entities/notePublic.js';


/**
* Note list entity.
* An object with the "items" property containing a list of all existing notes created by the user
Expand All @@ -17,4 +16,3 @@ export type NoteList = {
export type NoteListPublic = {
items: NotePublic[];
};

3 changes: 1 addition & 2 deletions src/domain/entities/notePublic.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Note } from '@domain/entities/note.js';

type NotePublicProperties = 'content' | 'createdAt' | 'updatedAt'| 'creatorId';
type NotePublicProperties = 'content' | 'createdAt' | 'updatedAt' | 'creatorId';

export interface NotePublic extends Pick<Note, NotePublicProperties> {
/**
Expand All @@ -11,7 +11,6 @@ export interface NotePublic extends Pick<Note, NotePublicProperties> {

/**
*Change Note to NotePublic
*
* @param note - Note data to compose a public note
*/
export function definePublicNote(note: Note): NotePublic {
Expand Down
4 changes: 1 addition & 3 deletions src/domain/entities/noteSettings.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { Team } from './team.js';


/**
* Invitation hash. It's used to invite users to team
*/
Expand Down Expand Up @@ -55,7 +54,6 @@ export interface NoteSettingsPublic extends Pick<NoteSettings, NoteSettingsPubli

/**
* Define note settings for public usage
*
* @param noteSettings - note settings data
*/
export function definePublicNoteSettings(noteSettings: NoteSettings): NoteSettingsPublic {
Expand All @@ -71,7 +69,7 @@ export function definePublicNoteSettings(noteSettings: NoteSettings): NoteSettin
/**
* Notes settings creation attributes, omitting id, because it's generated by database, omitting cover, because it should be generated after insertion of the note
*/
type NoteSettingsCreationAttributes = Omit<NoteSettings, 'id' |'cover'>;
type NoteSettingsCreationAttributes = Omit<NoteSettings, 'id' | 'cover'>;

export type {
NoteSettingsCreationAttributes
Expand Down
10 changes: 5 additions & 5 deletions src/domain/entities/noteVisit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ export default interface NoteVisit {
/**
* Unique property identifier
*/
id: number,
id: number;

/**
* Internal id of the note
*/
noteId: NoteInternalId,
noteId: NoteInternalId;

/**
* Id of the user
*/
userId: User['id'],
userId: User['id'];

/**
* Time when note was visited for the last time (timestamp with timezone)
*/
visitedAt: string,
}
visitedAt: string;
}
2 changes: 1 addition & 1 deletion src/domain/entities/team.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export enum MemberRole {
/**
* Team member can read and write notes
*/
Write = 1,
Write = 1
}

/**
Expand Down
15 changes: 7 additions & 8 deletions src/domain/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,37 @@ export interface DomainServices {
/**
* Note service instance
*/
noteService: NoteService,
noteService: NoteService;

/**
* Note settings service instance
*/
noteSettingsService: NoteSettingsService,
noteSettingsService: NoteSettingsService;

/**
* Auth service instance
*/
authService: AuthService,
authService: AuthService;

/**
* User service instance
*/
userService: UserService,
userService: UserService;

/**
* AI service instance
*/
aiService: AIService
aiService: AIService;

/**
* Editor tools service instance
*/
editorToolsService: EditorToolsService,
editorToolsService: EditorToolsService;

/**
* File uploader service instance
*/
fileUploaderService: FileUploaderService,
fileUploaderService: FileUploaderService;

/**
* Note visits service instance
Expand All @@ -56,7 +56,6 @@ export interface DomainServices {

/**
* Initiate services
*
* @param repositories - repositories
* @param appConfig - app config
*/
Expand Down
3 changes: 0 additions & 3 deletions src/domain/service/ai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@ import type AIRepository from '@repository/ai.repository.js';
export default class AIService {
/**
* Constructs AI service instance
*
* @param repository - AI repository instance
*/
constructor(private readonly repository: AIRepository) {}


/**
* Returns predicted completion based on specified string content
*
* @param content - content to complete
*/
public async getCompletion(content: string): Promise<string> {
Expand Down
14 changes: 4 additions & 10 deletions src/domain/service/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export default class AuthService {

/**
* Creates jwt service instance
*
* @param accessSecret - access token secret key
* @param accessTokenExpiresIn - access token expiration time
* @param refreshTokenExpiresIn - refresh token expiration time
Expand All @@ -45,9 +44,8 @@ export default class AuthService {

/**
* Generates access token
*
* @param payload - payload to sign
* @returns {string} access token
* @returns access token
*/
public signAccessToken(payload: AuthPayload): string {
return jwt.sign(payload, this.accessSecret, {
Expand All @@ -57,19 +55,17 @@ export default class AuthService {

/**
* Verifies access token
*
* @param token - access token
* @returns {AuthPayload} payload
* @returns payload
*/
public verifyAccessToken(token: string): AuthPayload {
return jwt.verify(token, this.accessSecret, { complete: false }) as AuthPayload;
}

/**
* Generates refresh token
*
* @param userId - user to sign refresh token for
* @returns {Promise<string>} refresh token
* @returns refresh token
*/
public async signRefreshToken(userId: number): Promise<string> {
const tokenSize = 10;
Expand All @@ -86,9 +82,8 @@ export default class AuthService {

/**
* Check if refresh token is valid
*
* @param token - refresh token to check
* @returns {Promise<UserSession | null>} user session if session is valid
* @returns user session if session is valid
*/
public async verifyRefreshToken(token: string): Promise<UserSession | null> {
const session = await this.userSessionRepository.getUserSessionByRefreshToken(token);
Expand All @@ -114,7 +109,6 @@ export default class AuthService {

/**
* Removes session by refresh token
*
* @param token - refresh token
*/
public async removeSessionByRefreshToken(token: string): Promise<void> {
Expand Down
Loading

0 comments on commit 3555d34

Please sign in to comment.