Skip to content

Commit

Permalink
Change eslint rule no-nested-ternary from warn to off
Browse files Browse the repository at this point in the history
  • Loading branch information
P-man2976 committed Dec 7, 2024
1 parent dadae40 commit 8281b63
Show file tree
Hide file tree
Showing 13 changed files with 60 additions and 89 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"@typescript-eslint/no-use-before-define": "off",
"no-underscore-dangle": "off",
"no-console": "warn",
"no-nested-ternary": "warn",
"no-nested-ternary": "off",
"import/extensions": "off",
"import/prefer-default-export": "off"
}
Expand Down
12 changes: 7 additions & 5 deletions src/@types/transit.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ interface DiaInfo {
interface TransitTimetable {
starting: string;
destination: string;
stations: {
name: string;
arriveAt?: string;
departAt?: string;
}[];
stations: TransitTimetableStation[];
}

interface TransitTimetableStation {
name: string;
arriveAt?: string;
departAt?: string;
}
8 changes: 0 additions & 8 deletions src/components/calendar/Calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,13 @@ const Calendar = React.memo(
>
<Text
color={
/* eslint-disable no-nested-ternary */
isSameMonth(date, day)
? isSaturday(day)
? 'blue.400'
: isSunday(day)
? 'red.400'
: 'title'
: 'description'
/* eslint-enable no-nested-ternary */
}
textStyle="title"
fontSize="xs"
Expand Down Expand Up @@ -141,37 +139,31 @@ const Calendar = React.memo(
px={{ base: 0, md: '2px' }}
py={{ base: 0, md: '1px' }}
bg={
/* eslint-disable no-nested-ternary */
event.external
? event.isAllDay
? 'green.400'
: 'green.50'
: event.isAllDay
? 'blue.400'
: 'blue.50'
/* eslint-enable no-nested-ternary */
}
color={
/* eslint-disable no-nested-ternary */
event.external
? event.isAllDay
? 'white'
: 'green.400'
: event.isAllDay
? 'white'
: 'blue.400'
/* eslint-enable no-nested-ternary */
}
_hover={{
/* eslint-disable no-nested-ternary */
bg: event.external
? event.isAllDay
? 'green.500'
: 'green.100'
: event.isAllDay
? 'blue.500'
: 'blue.100',
/* eslint-enable no-nested-ternary */
}}
transition="all .2s ease"
as={RouterLink}
Expand Down
1 change: 0 additions & 1 deletion src/components/cards/Timetable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ function Timetable() {
) : (
<Error type="userScheduleNotSet" />
)}
{/* eslint-enable no-nested-ternary */}
</VStack>
<DivisionEditor date={date} isOpen={isOpen} onClose={onClose} />
</>
Expand Down
5 changes: 0 additions & 5 deletions src/components/classmatch/MetaEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ function MetaEditor({
<Text textStyle="description" fontWeight="bold" fontSize="xs">
試合結果
</Text>
{/* eslint-disable no-nested-ternary */}
<Box w="full" pos="relative">
{!isParticipantsEditable && (
<Center
Expand Down Expand Up @@ -238,13 +237,11 @@ function ClassSelectMenu({
rightIcon={<Icon as={TbChevronDown} />}
textStyle={currentClass?.from ? 'title' : 'description'}
>
{/* eslint-disable no-nested-ternary */}
{currentClass?.from
? currentClass.type === 'teacher'
? '職員'
: `${currentClass.grade}-${currentClass.class}`
: 'クラス'}
{/* eslint-enable no-nested-ternary */}
</MenuButton>
<Box>
<MenuList rounded="xl" shadow="xl">
Expand Down Expand Up @@ -300,15 +297,13 @@ function ClassSelectMenuItem({
})
}
>
{/* eslint-disable no-nested-ternary */}
{tournament.class
? tournament.class.type === 'teacher'
? '職員'
: `${tournament.class.grade}-${tournament.class.class}`
: winner.type === 'teacher'
? '職員'
: `${winner.grade}-${winner.class}`}
{/* eslint-enable no-nested-ternary */}
</MenuItem>
);
}
Expand Down
2 changes: 0 additions & 2 deletions src/components/library/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ const SearchResult = React.memo(
}) => (
<Box w="100%" h="100%">
<Collapse in={!!result || isLoading}>
{/* eslint-disable no-nested-ternary */}
{isLoading ? (
<Loading />
) : result?.count ? (
Expand Down Expand Up @@ -178,7 +177,6 @@ const SearchResult = React.memo(
</Text>
</VStack>
)}
{/* eslint-enable no-nested-ternary */}
</Collapse>
</Box>
),
Expand Down
107 changes: 52 additions & 55 deletions src/components/nav/SideMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,66 +184,63 @@ const MenuBody = React.memo(() => {
</Heading>
)}
</HStack>
{menu.map(
(menuItem, index) =>
/* eslint-disable no-nested-ternary */
menuItem.type === 'divider' ? (
<StackDivider
// eslint-disable-next-line react/no-array-index-key
key={`${menuItem.type}-${index}`}
borderWidth="1px"
borderColor="border"
/>
) : breakPoint === 1 ? (
<IconButton
aria-label={menuItem.label}
icon={menuItem.icon}
size="lg"
variant="ghost"
isRound
{menu.map((menuItem, index) =>
menuItem.type === 'divider' ? (
<StackDivider
// eslint-disable-next-line react/no-array-index-key
key={`${menuItem.type}-${index}`}
borderWidth="1px"
borderColor="border"
/>
) : breakPoint === 1 ? (
<IconButton
aria-label={menuItem.label}
icon={menuItem.icon}
size="lg"
variant="ghost"
isRound
color={
menuItem.color ??
(location.pathname === menuItem.href ? 'blue.400' : undefined)
}
as={RouterLink}
to={menuItem.href}
onClick={
menuItem.onClick as unknown as React.MouseEventHandler<HTMLButtonElement>
}
/>
) : (
<HStack
p={2}
key={menuItem.label}
w="100%"
spacing={4}
color={
location.pathname.startsWith(menuItem.href)
? 'blue.400'
: undefined
}
layerStyle="button"
rounded="xl"
as={RouterLink}
to={menuItem.href}
{...menuItem}
>
{menuItem.icon}
<Text
color={
menuItem.color ??
(location.pathname === menuItem.href ? 'blue.400' : undefined)
}
as={RouterLink}
to={menuItem.href}
onClick={
menuItem.onClick as unknown as React.MouseEventHandler<HTMLButtonElement>
}
/>
) : (
<HStack
p={2}
key={menuItem.label}
w="100%"
spacing={4}
color={
location.pathname.startsWith(menuItem.href)
(location.pathname.startsWith(menuItem.href)
? 'blue.400'
: undefined
: undefined)
}
layerStyle="button"
rounded="xl"
as={RouterLink}
to={menuItem.href}
{...menuItem}
textStyle="title"
fontSize="lg"
>
{menuItem.icon}
<Text
color={
menuItem.color ??
(location.pathname.startsWith(menuItem.href)
? 'blue.400'
: undefined)
}
textStyle="title"
fontSize="lg"
>
{menuItem.label}
</Text>
</HStack>
),
/* eslint-enable no-nested-ternary */
{menuItem.label}
</Text>
</HStack>
),
)}
<Spacer />
<Account />
Expand Down
2 changes: 0 additions & 2 deletions src/components/posts/PDFViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ const PDFViewer = React.memo(
</DrawerHeader>
<DrawerBody p={0} position="relative" zIndex={-5}>
<Center>
{/* eslint-disable no-nested-ternary */}
{isPending ? (
<Loading />
) : error ? (
Expand Down Expand Up @@ -128,7 +127,6 @@ const PDFViewer = React.memo(
))}
</Document>
)}
{/* eslint-enable no-nested-ternary */}
</Center>
</DrawerBody>
</DrawerContent>
Expand Down
2 changes: 0 additions & 2 deletions src/components/timetable/editor/UserSubjectPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ const UserSubjectPicker = React.memo(
onClick={(e) => e.stopPropagation()}
w="full"
>
{/* eslint-disable no-nested-ternary */}
{searchPending ? (
<Loading />
) : searchResult?.length ? (
Expand All @@ -177,7 +176,6 @@ const UserSubjectPicker = React.memo(
候補がありません
</Text>
)}
{/* eslint-enable no-nested-ternary */}
</VStack>
</VStack>
</ModalBody>
Expand Down
2 changes: 0 additions & 2 deletions src/components/transit/DiaStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ const DiaStatus = React.memo(() => {
</Text>
<Skeleton w="100%" minH={8} rounded="xl" isLoaded={!isPending}>
<Center w="full">
{/* eslint-disable no-nested-ternary */}
{error ? (
<Error error={error} />
) : unstableLines?.length ? (
Expand All @@ -51,7 +50,6 @@ const DiaStatus = React.memo(() => {
全路線平常運転
</Text>
)}
{/* eslint-enable no-nested-ternary */}
</Center>
</Skeleton>
</VStack>
Expand Down
2 changes: 0 additions & 2 deletions src/pages/Timetable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ function Timetable() {
</HStack>
<Icon as={TbChevronRight} />
</HStack>
{/* eslint-disable no-nested-ternary */}
{user.userScheduleId ? (
division ? (
<TimetableTable
Expand All @@ -196,7 +195,6 @@ function Timetable() {
) : (
<Error type="userScheduleNotSet" />
)}
{/* eslint-enable no-nested-ternary */}
</VStack>
{/* <StackDivider borderWidth="1px" /> */}
<HStack w="100%">
Expand Down
2 changes: 0 additions & 2 deletions src/pages/classroom/Classroom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ export default function Classroom() {
}
>
<Box px={4} mb={24}>
{/* eslint-disable no-nested-ternary */}
{isLoading ? (
<Loading withTips initialTip={0} />
) : error ? (
Expand Down Expand Up @@ -145,7 +144,6 @@ export default function Classroom() {
useWindowScroll
/>
)}
{/* eslint-enable no-nested-ternary */}
</Box>
</ChakraPullToRefresh>
</Box>
Expand Down
2 changes: 0 additions & 2 deletions src/pages/classroom/ClassroomCourse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ export default function ClassroomCourse() {
>
<VStack p={4} mb={24}>
<CourseHeader courseId={id} />
{/* eslint-disable no-nested-ternary */}
{isLoading ? (
<Loading withTips initialTip={0} />
) : error ? (
Expand Down Expand Up @@ -107,7 +106,6 @@ export default function ClassroomCourse() {
useWindowScroll
/>
)}
{/* eslint-enable no-nested-ternary */}
</VStack>
</ChakraPullToRefresh>
</>
Expand Down

0 comments on commit 8281b63

Please sign in to comment.