Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove eslint rule deactivations #290

Merged
merged 1 commit into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions src/components/MangaCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,7 @@ const MangaCard = React.forwardRef<HTMLDivElement, IProps>((props: IProps, ref)
const { t } = useTranslation();

const {
manga: {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
id,
title,
thumbnailUrl,
downloadCount,
unreadCount: unread,
inLibrary,
},
manga: { id, title, thumbnailUrl, downloadCount, unreadCount: unread, inLibrary },
gridLayout,
dimensions,
inLibraryIndicator,
Expand Down
4 changes: 1 addition & 3 deletions src/components/library/LibraryMangaGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ const filterManga = (
return matchesSearch && matchesFilters;
});

const sortByUnread = (a: IMangaCard, b: IMangaCard): number =>
// eslint-disable-next-line implicit-arrow-linebreak
(a.unreadCount ?? 0) - (b.unreadCount ?? 0);
const sortByUnread = (a: IMangaCard, b: IMangaCard): number => (a.unreadCount ?? 0) - (b.unreadCount ?? 0);

const sortByTitle = (a: IMangaCard, b: IMangaCard): number => a.title.localeCompare(b.title);

Expand Down
4 changes: 1 addition & 3 deletions src/components/manga/util.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@ const defaultChapterOptions: ChapterListOptions = {
function chapterOptionsReducer(state: ChapterListOptions, actions: ChapterOptionsReducerAction): ChapterListOptions {
switch (actions.type) {
case 'filter':
// eslint-disable-next-line no-case-declarations
const active = state.unread !== false && state.downloaded !== false && state.bookmarked !== false;
return {
...state,
active,
active: state.unread !== false && state.downloaded !== false && state.bookmarked !== false,
[actions.filterType!]: actions.filterValue,
};
case 'sortBy':
Expand Down
1 change: 0 additions & 1 deletion src/components/molecules/DownloadStateIndicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ interface DownloadStateIndicatorProps {
download: IDownloadChapter;
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const DOWNLOAD_STATE_TO_TRANSLATION_KEY_MAP: { [state in IDownloadChapter['state']]: TranslationKey } = {
Downloading: 'download.state.label.downloading',
Error: 'download.state.label.error',
Expand Down
2 changes: 0 additions & 2 deletions src/components/navbar/ReaderNavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,6 @@ export default function ReaderNavBar(props: IProps) {
{Array(Math.max(0, chapter.chapterCount))
.fill(1)
.map((ignoreValue, index) => (
// eslint-disable-next-line max-len
// eslint-disable-next-line react/no-array-index-key
<MenuItem key={`Chapter#${index + 1}`} value={index + 1}>{`${t(
'chapter.title',
)} ${index + 1}`}</MenuItem>
Expand Down
25 changes: 11 additions & 14 deletions src/components/navbar/navigation/DesktopSideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,17 @@ export default function DesktopSideBar({ navBarItems }: IProps) {

return (
<SideNavBarContainer>
{
// eslint-disable-next-line react/destructuring-assignment
navBarItems.map(({ path, title, IconComponent, SelectedIconComponent }: NavbarItem) => (
<Link to={path} style={{ color: 'inherit', textDecoration: 'none' }} key={path}>
<ListItem disableRipple button key={title}>
<ListItemIcon sx={{ minWidth: '0' }}>
<Tooltip placement="right" title={t(title)}>
{iconFor(path, IconComponent, SelectedIconComponent)}
</Tooltip>
</ListItemIcon>
</ListItem>
</Link>
))
}
{navBarItems.map(({ path, title, IconComponent, SelectedIconComponent }: NavbarItem) => (
<Link to={path} style={{ color: 'inherit', textDecoration: 'none' }} key={path}>
<ListItem disableRipple button key={title}>
<ListItemIcon sx={{ minWidth: '0' }}>
<Tooltip placement="right" title={t(title)}>
{iconFor(path, IconComponent, SelectedIconComponent)}
</Tooltip>
</ListItemIcon>
</ListItem>
</Link>
))}
</SideNavBarContainer>
);
}
21 changes: 9 additions & 12 deletions src/screens/DownloadQueue.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable @typescript-eslint/no-shadow */
/* eslint-disable react/destructuring-assignment */
/*
* Copyright (C) Contributors to the Suwayomi project
*
Expand All @@ -16,7 +14,7 @@ import IconButton from '@mui/material/IconButton';
import NavbarContext from 'components/context/NavbarContext';
import EmptyView from 'components/util/EmptyView';
import React, { useContext, useEffect } from 'react';
import { DragDropContext, Draggable, Droppable, DropResult } from 'react-beautiful-dnd';
import { DragDropContext, Draggable, Droppable } from 'react-beautiful-dnd';
import client from 'util/client';

import Typography from '@mui/material/Typography';
Expand Down Expand Up @@ -55,8 +53,7 @@ const DownloadQueue: React.FC = () => {
setAction(null);
}, [t]);

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const onDragEnd = (result: DropResult) => {};
const onDragEnd = () => {};

if (queue.length === 0) {
return <EmptyView message={t('download.queue.label.no_downloads')} />;
Expand Down Expand Up @@ -84,19 +81,19 @@ const DownloadQueue: React.FC = () => {
</NavbarToolbar>
<DragDropContext onDragEnd={onDragEnd}>
<Droppable droppableId="droppable">
{(provided) => (
<Box ref={provided.innerRef} sx={{ pt: 1 }}>
{(droppableProvided) => (
<Box ref={droppableProvided.innerRef} sx={{ pt: 1 }}>
{queue.map((item, index) => (
<Draggable
key={`${item.mangaId}-${item.chapterIndex}`}
draggableId={`${item.mangaId}-${item.chapterIndex}`}
index={index}
>
{(provided, snapshot) => (
{(draggableProvided, snapshot) => (
<Box
{...provided.draggableProps}
{...provided.dragHandleProps}
ref={provided.innerRef}
{...draggableProvided.draggableProps}
{...draggableProvided.dragHandleProps}
ref={draggableProvided.innerRef}
sx={{ p: 1, pb: 2 }}
>
<Card
Expand Down Expand Up @@ -142,7 +139,7 @@ const DownloadQueue: React.FC = () => {
)}
</Draggable>
))}
{provided.placeholder}
{droppableProvided.placeholder}
</Box>
)}
</Droppable>
Expand Down
2 changes: 0 additions & 2 deletions src/screens/SearchAll.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ const SearchAll: React.FC = () => {
}
setFetched({});
setMangas({});
// eslint-disable-next-line max-len
doIT(
sources
.filter(({ lang }) => shownLangs.indexOf(lang) !== -1)
Expand Down Expand Up @@ -167,7 +166,6 @@ const SearchAll: React.FC = () => {
if (query) {
return (
<>
{/* eslint-disable-next-line max-len */}
{sources
.filter(({ lang }) => shownLangs.indexOf(lang) !== -1)
.filter((source) => showNsfw || !source.isNsfw)
Expand Down
1 change: 0 additions & 1 deletion src/screens/Sources.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ export default function Sources() {

return (
<>
{/* eslint-disable-next-line max-len */}
{Object.entries(groupByLang(sources ?? []))
.sort((a, b) => langSortCmp(a[0], b[0]))
.map(
Expand Down
20 changes: 9 additions & 11 deletions src/screens/settings/Categories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable @typescript-eslint/no-shadow */
/* eslint-disable react/destructuring-assignment */
/*
* Copyright (C) Contributors to the Suwayomi project
*
Expand Down Expand Up @@ -140,21 +138,21 @@ export default function Categories() {
<>
<DragDropContext onDragEnd={onDragEnd}>
<Droppable droppableId="droppable">
{(provided) => (
<List ref={provided.innerRef}>
{(droppableProvided) => (
<List ref={droppableProvided.innerRef}>
{categories.map((item, index) => (
<Draggable key={item.id} draggableId={item.id.toString()} index={index}>
{(provided, snapshot) => (
{(draggableProvided, snapshot) => (
<ListItem
ContainerProps={{ ref: provided.innerRef } as any}
{...provided.draggableProps}
{...provided.dragHandleProps}
ContainerProps={{ ref: draggableProvided.innerRef } as any}
{...draggableProvided.draggableProps}
{...draggableProvided.dragHandleProps}
style={getItemStyle(
snapshot.isDragging,
provided.draggableProps.style,
draggableProvided.draggableProps.style,
theme.palette,
)}
ref={provided.innerRef}
ref={draggableProvided.innerRef}
>
<ListItemIcon>
<DragHandleIcon />
Expand All @@ -180,7 +178,7 @@ export default function Categories() {
)}
</Draggable>
))}
{provided.placeholder}
{droppableProvided.placeholder}
</List>
)}
</Droppable>
Expand Down
2 changes: 0 additions & 2 deletions src/screens/settings/DefaultReaderSettings.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable @typescript-eslint/no-shadow */
/* eslint-disable react/destructuring-assignment */
/*
* Copyright (C) Contributors to the Suwayomi project
*
Expand Down
22 changes: 6 additions & 16 deletions src/util/localStorage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,18 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

function getItem<T>(key: string, defaultValue: T): T {
try {
const item = window.localStorage.getItem(key);
const item = window.localStorage.getItem(key);

if (item !== null) {
return JSON.parse(item);
}

window.localStorage.setItem(key, JSON.stringify(defaultValue));

/* eslint-disable no-empty */
} finally {
if (item !== null) {
return JSON.parse(item);
}

window.localStorage.setItem(key, JSON.stringify(defaultValue));
return defaultValue;
}

function setItem<T>(key: string, value: T): void {
try {
window.localStorage.setItem(key, JSON.stringify(value));

// eslint-disable-next-line no-empty
} finally {
}
window.localStorage.setItem(key, JSON.stringify(value));
}

export default { getItem, setItem };
1 change: 0 additions & 1 deletion src/util/useLocalStorage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import React, { useState, Dispatch, SetStateAction, useReducer, Reducer, useCallback } from 'react';
import storage from 'util/localStorage';

// eslint-disable-next-line max-len
export default function useLocalStorage<T>(key: string, defaultValue: T | (() => T)): [T, Dispatch<SetStateAction<T>>] {
const initialState = defaultValue instanceof Function ? defaultValue() : defaultValue;
const [storedValue, setStoredValue] = useState<T>(storage.getItem(key, initialState));
Expand Down