Phase 10: запрет inline eslint-disable, file-level overrides, IUser-тип
This commit is contained in:
@@ -17,10 +17,8 @@ function useLoadNews(newsId: string | undefined, isNew: boolean) {
|
||||
if (isNew) {
|
||||
return;
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises -- async IIFE в useEffect
|
||||
void (async () => {
|
||||
try {
|
||||
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions -- newsId гарантированно string (проверено isNew)
|
||||
const data = await apiFetch<{ news: { title: string; content: string; status: string } }>(`/news/${newsId}`);
|
||||
setTitle(data.news.title);
|
||||
setContent(data.news.content);
|
||||
@@ -45,7 +43,6 @@ function useLoadNews(newsId: string | undefined, isNew: boolean) {
|
||||
* @param newsId — id новости или undefined для создания
|
||||
* @returns состояние и обработчики для NewsEditorPage
|
||||
*/
|
||||
/* eslint-disable max-lines-per-function -- хук-оркестратор */
|
||||
export function useNewsEditor(newsId: string | undefined) {
|
||||
const isNew = newsId === undefined;
|
||||
const { title, setTitle, content, setContent, newsStatus, loading } = useLoadNews(newsId, isNew);
|
||||
@@ -149,7 +146,6 @@ export function useNewsEditor(newsId: string | undefined) {
|
||||
if (newsId === undefined) {
|
||||
return;
|
||||
}
|
||||
// eslint-disable-next-line no-alert -- подтверждение удаления
|
||||
if (!window.confirm('Удалить новость?')) {
|
||||
return;
|
||||
}
|
||||
@@ -157,7 +153,6 @@ export function useNewsEditor(newsId: string | undefined) {
|
||||
setError('');
|
||||
try {
|
||||
await apiFetch(`/news/${newsId}`, { method: 'DELETE' });
|
||||
// eslint-disable-next-line require-atomic-updates -- navigation after await
|
||||
window.location.href = '/news';
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : 'Ошибка удаления');
|
||||
@@ -214,7 +209,6 @@ export function useNewsEditor(newsId: string | undefined) {
|
||||
if (file !== undefined) {
|
||||
handleFileUpload(file, true).catch((err: unknown) => { console.error(err); });
|
||||
}
|
||||
// eslint-disable-next-line no-param-reassign -- сброс file input
|
||||
e.target.value = '';
|
||||
}, [handleFileUpload]);
|
||||
|
||||
@@ -224,7 +218,6 @@ export function useNewsEditor(newsId: string | undefined) {
|
||||
if (file !== undefined) {
|
||||
handleFileUpload(file, false).catch((err: unknown) => { console.error(err); });
|
||||
}
|
||||
// eslint-disable-next-line no-param-reassign -- сброс file input
|
||||
e.target.value = '';
|
||||
}, [handleFileUpload]);
|
||||
|
||||
@@ -239,4 +232,3 @@ export function useNewsEditor(newsId: string | undefined) {
|
||||
onSave, onPublish, onDelete, onSchedule,
|
||||
};
|
||||
}
|
||||
/* eslint-enable max-lines-per-function */
|
||||
|
||||
Reference in New Issue
Block a user