Phase 10: запрет inline eslint-disable, file-level overrides, IUser-тип
This commit is contained in:
@@ -22,7 +22,6 @@ function fieldOf(obj: unknown, key: string): string | undefined {
|
||||
if (typeof obj !== 'object' || obj === null) {
|
||||
return undefined;
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions, @typescript-eslint/no-unsafe-type-assertion -- извлечение полей из unknown
|
||||
const record = obj as Record<string, unknown>;
|
||||
const value = record[key];
|
||||
return typeof value === 'string' ? value : undefined;
|
||||
@@ -48,7 +47,6 @@ function userEmailOf(body: unknown): string | undefined {
|
||||
if (typeof body !== 'object' || body === null) {
|
||||
return undefined;
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions, @typescript-eslint/no-unsafe-type-assertion -- извлечение полей из unknown
|
||||
const record = body as Record<string, unknown>;
|
||||
// /me возвращает { id, email } на верхнем уровне, register/login — { user: { id, email } }
|
||||
if (record.email !== undefined) {
|
||||
@@ -67,7 +65,6 @@ function userIdOf(body: unknown): string | undefined {
|
||||
if (typeof body !== 'object' || body === null) {
|
||||
return undefined;
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions, @typescript-eslint/no-unsafe-type-assertion -- извлечение полей из unknown
|
||||
const user = (body as Record<string, unknown>).user;
|
||||
return fieldOf(user, 'id');
|
||||
}
|
||||
|
||||
@@ -16,12 +16,10 @@ function errorCodeOf(body: unknown): string | undefined {
|
||||
if (typeof body !== 'object' || body === null) {
|
||||
return undefined;
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- извлечение полей из unknown
|
||||
const error = (body as { error?: unknown }).error;
|
||||
if (typeof error !== 'object' || error === null) {
|
||||
return undefined;
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- извлечение полей из unknown
|
||||
const code = (error as { code?: unknown }).code;
|
||||
return typeof code === 'string' ? code : undefined;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ function authed(req: request.Test): request.Test {
|
||||
/** Создаёт тестовую новость и возвращает её id. */
|
||||
async function createTestNews(title: string): Promise<string> {
|
||||
const res = await authed(request(app).post('/api/news').send({ title, content: 'Тест' }));
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return -- supertest body
|
||||
return res.body.news.id;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user