Skip to content

Commit b96a68a

Browse files
authored
upgrade to ESLint 9 and flat config (#1606)
1 parent 3d85b91 commit b96a68a

28 files changed

+299
-154
lines changed

.eslintrc.cjs

Lines changed: 0 additions & 14 deletions
This file was deleted.

bun.lock

Lines changed: 58 additions & 50 deletions
Large diffs are not rendered by default.

components/CompatibilityTags.tsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,18 @@ export function CompatibilityTags({ library }: Props) {
5252
/>
5353
) : null}
5454
{!library.dev && !library.template && <NewArchitectureTag library={library} />}
55-
{platforms.map(platform => (
56-
<Tag
57-
label={platform}
58-
key={`${platform}-platform`}
59-
tagStyle={{
60-
backgroundColor: isDark ? darkColors.dark : colors.gray1,
61-
borderColor: isDark ? darkColors.border : colors.gray2,
62-
}}
63-
/>
64-
))}
55+
{platforms.map(platform =>
56+
platform ? (
57+
<Tag
58+
label={platform}
59+
key={`${platform}-platform`}
60+
tagStyle={{
61+
backgroundColor: isDark ? darkColors.dark : colors.gray1,
62+
borderColor: isDark ? darkColors.border : colors.gray2,
63+
}}
64+
/>
65+
) : null
66+
)}
6567
{(library.expoGo || library.fireos) && (
6668
<Tooltip
6769
side="bottom"

components/Icons/index.tsx

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ type Props = {
1010

1111
export function Search({ width, height, fill = colors.black }: Props) {
1212
return (
13-
<Svg width={width || 19} height={height || 19} viewBox="0 0 19 19" fill="none">
13+
<Svg width={width ?? 19} height={height ?? 19} viewBox="0 0 19 19" fill="none">
1414
<Path
1515
fillRule="evenodd"
1616
clipRule="evenodd"
@@ -23,7 +23,7 @@ export function Search({ width, height, fill = colors.black }: Props) {
2323

2424
export function Star({ width, height, fill = colors.black }: Props) {
2525
return (
26-
<Svg width={width || 20} height={height || 19} viewBox="0 0 20 19" fill="none">
26+
<Svg width={width ?? 20} height={height ?? 19} viewBox="0 0 20 19" fill="none">
2727
<Path
2828
fillRule="evenodd"
2929
clipRule="evenodd"
@@ -36,7 +36,7 @@ export function Star({ width, height, fill = colors.black }: Props) {
3636

3737
export function Web({ width, height, fill = colors.black }: Props) {
3838
return (
39-
<Svg width={width || 18} height={height || 19} viewBox="0 0 18 19" fill="none">
39+
<Svg width={width ?? 18} height={height ?? 19} viewBox="0 0 18 19" fill="none">
4040
<Path
4141
fillRule="evenodd"
4242
clipRule="evenodd"
@@ -61,7 +61,7 @@ export function Web({ width, height, fill = colors.black }: Props) {
6161

6262
export function Arrow({ width, height, fill = colors.black }: Props) {
6363
return (
64-
<Svg width={width || 9} height={height || 16} viewBox="0 0 9 16" fill="none">
64+
<Svg width={width ?? 9} height={height ?? 16} viewBox="0 0 9 16" fill="none">
6565
<Path
6666
fillRule="evenodd"
6767
clipRule="evenodd"
@@ -74,7 +74,7 @@ export function Arrow({ width, height, fill = colors.black }: Props) {
7474

7575
export function Badge({ width, height, fill = colors.black }: Props) {
7676
return (
77-
<Svg width={width || 20} height={height || 26} viewBox="0 0 20 26" fill="none">
77+
<Svg width={width ?? 20} height={height ?? 26} viewBox="0 0 20 26" fill="none">
7878
<Path
7979
fillRule="evenodd"
8080
clipRule="evenodd"
@@ -93,7 +93,7 @@ export function Badge({ width, height, fill = colors.black }: Props) {
9393

9494
export function Calendar({ width, height, fill = colors.black }: Props) {
9595
return (
96-
<Svg width={width || 16} height={height || 18} viewBox="0 0 16 18" fill="none">
96+
<Svg width={width ?? 16} height={height ?? 18} viewBox="0 0 16 18" fill="none">
9797
<Path
9898
fillRule="evenodd"
9999
clipRule="evenodd"
@@ -106,7 +106,7 @@ export function Calendar({ width, height, fill = colors.black }: Props) {
106106

107107
export function Check({ width, height, fill = colors.black }: Props) {
108108
return (
109-
<Svg width={width || 19} height={height || 13} viewBox="0 0 19 13" fill="none">
109+
<Svg width={width ?? 19} height={height ?? 13} viewBox="0 0 19 13" fill="none">
110110
<Path
111111
fillRule="evenodd"
112112
clipRule="evenodd"
@@ -119,7 +119,7 @@ export function Check({ width, height, fill = colors.black }: Props) {
119119

120120
export function Download({ width, height, fill = colors.black }: Props) {
121121
return (
122-
<Svg width={width || 13} height={height || 16} viewBox="0 0 13 16" fill="none">
122+
<Svg width={width ?? 13} height={height ?? 16} viewBox="0 0 13 16" fill="none">
123123
<Path
124124
fillRule="evenodd"
125125
clipRule="evenodd"
@@ -132,7 +132,7 @@ export function Download({ width, height, fill = colors.black }: Props) {
132132

133133
export function Filter({ width, height, fill = colors.black }: Props) {
134134
return (
135-
<Svg width={width || 21} height={height || 18} viewBox="0 0 21 18" fill="none">
135+
<Svg width={width ?? 21} height={height ?? 18} viewBox="0 0 21 18" fill="none">
136136
<Path
137137
fillRule="evenodd"
138138
clipRule="evenodd"
@@ -145,7 +145,7 @@ export function Filter({ width, height, fill = colors.black }: Props) {
145145

146146
export function Issue({ width, height, fill = colors.black }: Props) {
147147
return (
148-
<Svg width={width || 19} height={height || 19} viewBox="0 0 19 19" fill="none">
148+
<Svg width={width ?? 19} height={height ?? 19} viewBox="0 0 19 19" fill="none">
149149
<Path
150150
fillRule="evenodd"
151151
clipRule="evenodd"
@@ -164,7 +164,7 @@ export function Issue({ width, height, fill = colors.black }: Props) {
164164

165165
export function Eye({ width, height, fill = colors.black }: Props) {
166166
return (
167-
<Svg width={width || 22} height={height || 22} viewBox="0 0 24 24" fill="none">
167+
<Svg width={width ?? 22} height={height ?? 22} viewBox="0 0 24 24" fill="none">
168168
<Path
169169
fill={fill}
170170
d="M11.9,7.1c4.6,0,7.8,2.9,9.2,4.5c-1.4,1.8-4.6,5.2-9.2,5.2c-4.3,0-7.7-3.4-9.2-5.3C4.1,10,7.3,7.1,11.9,7.1z M12,5 C4.4,5,0,11.6,0,11.6S4.8,19,12,19c7.7,0,12-7.4,12-7.4S19.7,5,12,5z M11.9,8.5c-1.9,0-3.5,1.6-3.5,3.5s1.6,3.5,3.5,3.5 c1.9,0,3.5-1.6,3.5-3.5S13.8,8.5,11.9,8.5z M11.9,12c-0.5,0.5-1.3,0.5-1.8,0c-0.5-0.5-0.5-1.3,0-1.8c0.5-0.5,1.3-0.5,1.8,0 C12.4,10.7,12.4,11.5,11.9,12z"
@@ -175,7 +175,7 @@ export function Eye({ width, height, fill = colors.black }: Props) {
175175

176176
export function Logo({ width, height, fill = colors.black }: Props) {
177177
return (
178-
<Svg width={width || 25} height={height || 22} viewBox="0 0 25 22" fill="none">
178+
<Svg width={width ?? 25} height={height ?? 22} viewBox="0 0 25 22" fill="none">
179179
<Path
180180
d="M12.029 13.03a2.334 2.334 0 002.343-2.325 2.334 2.334 0 00-2.343-2.326 2.334 2.334 0 00-2.343 2.325 2.334 2.334 0 002.343 2.326zM18.88 1.794c-.16-.74-.466-1.183-.851-1.404-.385-.22-.926-.262-1.65-.03-.725.234-1.571.723-2.485 1.46-.35.283-.708.6-1.068.947a27.206 27.206 0 012.225 2.743c1.246.114 2.424.298 3.505.54.123-.483.221-.948.293-1.391.186-1.154.19-2.125.03-2.865zM10.163 1.82c.351.283.708.6 1.068.947A27.215 27.215 0 009.007 5.51a27.564 27.564 0 00-3.506.54c-.123-.483-.22-.948-.292-1.391-.186-1.153-.19-2.125-.031-2.865.16-.74.466-1.183.85-1.403C6.415.17 6.955.128 7.68.36s1.57.722 2.484 1.459zM19.354 7.421a27.05 27.05 0 01-1.281 3.284 27.04 27.04 0 011.28 3.283c.484-.136.939-.284 1.361-.444 1.1-.417 1.95-.9 2.515-1.406.566-.507.8-.992.8-1.433 0-.442-.234-.927-.8-1.434-.565-.506-1.415-.988-2.515-1.405-.422-.16-.877-.309-1.36-.445zM15.05 15.9a27.207 27.207 0 01-2.224 2.742c.36.348.718.664 1.069.947.913.737 1.759 1.227 2.483 1.46.725.232 1.266.19 1.65-.03.386-.221.693-.665.852-1.404.16-.74.155-1.711-.031-2.864-.072-.444-.17-.909-.293-1.392a27.56 27.56 0 01-3.505.54zM9.007 15.9a27.21 27.21 0 002.224 2.742c-.36.348-.717.664-1.068.947-.913.737-1.759 1.227-2.484 1.46-.725.232-1.265.19-1.65-.03-.385-.221-.692-.665-.851-1.404-.16-.74-.155-1.711.031-2.864.071-.444.17-.909.292-1.392a27.56 27.56 0 003.506.54zM4.704 13.988c.329-1.05.758-2.155 1.28-3.283a27.043 27.043 0 01-1.28-3.284c-.483.136-.938.285-1.36.445-1.1.417-1.95.899-2.516 1.405-.565.507-.8.992-.8 1.434 0 .441.235.926.8 1.433.566.507 1.416.989 2.515 1.405.423.16.877.31 1.36.445z"
181181
fill={fill}
@@ -186,7 +186,7 @@ export function Logo({ width, height, fill = colors.black }: Props) {
186186

187187
export function GitHub({ width, height, fill = colors.black }: Props) {
188188
return (
189-
<Svg width={width || 24} height={height || 24} viewBox="0 0 24 24" fill="none">
189+
<Svg width={width ?? 24} height={height ?? 24} viewBox="0 0 24 24" fill="none">
190190
<Path
191191
fill={fill}
192192
d="M12 1.60205C5.9225 1.60205 1 6.41965 1 12.3676C1 17.1314 4.14875 21.155 8.52125 22.5815C9.07125 22.6757 9.2775 22.3527 9.2775 22.0701C9.2775 21.8144 9.26375 20.9666 9.26375 20.065C6.5 20.5629 5.785 19.4056 5.565 18.8001C5.44125 18.4906 4.905 17.5351 4.4375 17.2794C4.0525 17.0776 3.5025 16.5797 4.42375 16.5662C5.29 16.5528 5.90875 17.3467 6.115 17.6697C7.105 19.298 8.68625 18.8404 9.31875 18.5578C9.415 17.8581 9.70375 17.3871 10.02 17.1179C7.5725 16.8488 5.015 15.9203 5.015 11.8024C5.015 10.6317 5.44125 9.66278 6.1425 8.90919C6.0325 8.64005 5.6475 7.53658 6.2525 6.05631C6.2525 6.05631 7.17375 5.77372 9.2775 7.15978C10.1575 6.91756 11.0925 6.79645 12.0275 6.79645C12.9625 6.79645 13.8975 6.91756 14.7775 7.15978C16.8813 5.76026 17.8025 6.05631 17.8025 6.05631C18.4075 7.53658 18.0225 8.64005 17.9125 8.90919C18.6138 9.66278 19.04 10.6182 19.04 11.8024C19.04 15.9337 16.4688 16.8488 14.0213 17.1179C14.42 17.4544 14.7638 18.1003 14.7638 19.1096C14.7638 20.5495 14.75 21.7068 14.75 22.0701C14.75 22.3527 14.9563 22.6891 15.5063 22.5815C17.69 21.86 19.5875 20.4865 20.9318 18.6542C22.2761 16.822 22.9994 14.6233 23 12.3676C23 6.41965 18.0775 1.60205 12 1.60205Z"
@@ -197,7 +197,7 @@ export function GitHub({ width, height, fill = colors.black }: Props) {
197197

198198
export function Plus({ width, height, fill = colors.black }: Props) {
199199
return (
200-
<Svg width={width || 16} height={height || 16} viewBox="0 0 16 16" fill="none">
200+
<Svg width={width ?? 16} height={height ?? 16} viewBox="0 0 16 16" fill="none">
201201
<Path fillRule="evenodd" clipRule="evenodd" d="M.114 7.12H15.57v2H.114v-2z" fill={fill} />
202202
<Path fillRule="evenodd" clipRule="evenodd" d="M6.842 15.848V.393h2v15.455h-2z" fill={fill} />
203203
</Svg>
@@ -207,8 +207,8 @@ export function Plus({ width, height, fill = colors.black }: Props) {
207207
export function XIcon({ width, height, fill = colors.black }: Props) {
208208
return (
209209
<Svg
210-
width={width || 16}
211-
height={height || 16}
210+
width={width ?? 16}
211+
height={height ?? 16}
212212
viewBox="0 0 16 16"
213213
fill="none"
214214
style={{ transform: 'rotate(45deg)' }}>
@@ -220,7 +220,7 @@ export function XIcon({ width, height, fill = colors.black }: Props) {
220220

221221
export function Question({ width, height, fill = colors.black }: Props) {
222222
return (
223-
<Svg width={width || 16} height={height || 16} viewBox="0 0 24 24" fill="none">
223+
<Svg width={width ?? 16} height={height ?? 16} viewBox="0 0 24 24" fill="none">
224224
<Path
225225
d="M9.88849 16.0515H13.0629V15.8036C13.082 13.7826 13.7398 12.858 15.2936 11.9047C17.0477 10.8561 18.144 9.42612 18.144 7.24309C18.144 4.02097 15.6368 2 11.9953 2C8.65875 2 5.95141 3.84938 5.85608 7.47188H9.24979C9.33558 5.67969 10.6321 4.82173 11.9762 4.82173C13.4347 4.82173 14.6073 5.79409 14.6073 7.29075C14.6073 8.62536 13.7207 9.54051 12.5672 10.265C10.8799 11.3136 9.90756 12.3718 9.88849 15.8036V16.0515ZM11.5567 22C12.6816 22 13.6444 21.0658 13.654 19.9028C13.6444 18.7588 12.6816 17.8246 11.5567 17.8246C10.3937 17.8246 9.44998 18.7588 9.45951 19.9028C9.44998 21.0658 10.3937 22 11.5567 22Z"
226226
fill={fill}
@@ -231,7 +231,7 @@ export function Question({ width, height, fill = colors.black }: Props) {
231231

232232
export function Sort({ width, height, fill = colors.black }: Props) {
233233
return (
234-
<Svg width={width || 16} height={height || 16} viewBox="0 0 16 16" fill="none">
234+
<Svg width={width ?? 16} height={height ?? 16} viewBox="0 0 16 16" fill="none">
235235
<Path
236236
fillRule="evenodd"
237237
clipRule="evenodd"

components/Library/NewArchitectureTag.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ function getTagColor(status: NewArchSupportStatus, isDark: boolean) {
9595
default:
9696
return {
9797
borderColor: isDark ? darkColors.border : colors.gray2,
98-
borderStyle: 'dashed' as 'dashed',
98+
borderStyle: 'dashed' as const,
9999
};
100100
}
101101
}

components/Library/UnmaintainedLabel.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useContext } from 'react';
1+
import { Fragment, useContext } from 'react';
22
import { StyleSheet, View } from 'react-native';
33

44
import { A, colors, darkColors, Label, useLayout } from '~/common/styleguide';
@@ -22,7 +22,7 @@ const UnmaintainedLabel = ({ alternatives }) => {
2222
flexDirection: isSmallScreen ? 'column' : 'row',
2323
backgroundColor: isDark ? darkColors.dark : colors.gray1,
2424
borderColor: isDark ? darkColors.border : colors.gray2,
25-
// @ts-expect-error
25+
// @ts-expect-error Correct, but too complex background definition
2626
backgroundImage: `repeating-linear-gradient(45deg, transparent, transparent 20px, ${isDark ? '#18181f' : '#f0f0f0'} 20px, ${isDark ? '#18181f' : '#f0f0f0'} 40px)`,
2727
},
2828
]}>
@@ -42,17 +42,16 @@ const UnmaintainedLabel = ({ alternatives }) => {
4242
}}>
4343
You can use{' '}
4444
{alternatives.map((alternative, index) => (
45-
<>
45+
<Fragment key={alternative}>
4646
<A
47-
key={alternative}
4847
href={`/?search=${encodeURIComponent(alternative)}`}
4948
style={{ backgroundColor: 'transparent' }}
5049
hoverStyle={linkHoverStyle}>
5150
{alternative}
5251
</A>
5352
{index < alternatives.length - 1 && alternatives.length > 2 ? ', ' : ' '}
5453
{index === alternatives.length - 2 && 'or '}
55-
</>
54+
</Fragment>
5655
))}{' '}
5756
instead.
5857
</Label>

components/Pagination.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ type Props = {
2020

2121
const Pagination = ({ query, total, style, basePath = '/' }: Props) => {
2222
const { isDark } = useContext(CustomAppearanceContext);
23-
const totalPages = Math.ceil(total / NUM_PER_PAGE);
2423
const currentOffset = query.offset ? parseInt(query.offset.toString(), 10) : 0;
2524
const currentPage = Math.floor(currentOffset / NUM_PER_PAGE) + 1;
2625

27-
if (total < 1 || currentOffset >= total) return null;
26+
if (!total || total < 1 || currentOffset >= total) {
27+
return null;
28+
}
2829

2930
const backDisabled = currentPage <= 1;
31+
const totalPages = Math.ceil(total / NUM_PER_PAGE);
3032
const forwardDisabled = currentPage >= totalPages;
3133

3234
const pageQuery = getPageQuery(basePath, query);

components/Search.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ const Search = ({ query, total }: Props) => {
4545
}, [isApple]);
4646

4747
const typingCallback = useDebouncedCallback((text: string) => {
48-
Router.replace(urlWithQuery('/', { ...query, search: text, offset: null }));
48+
void Router.replace(urlWithQuery('/', { ...query, search: text, offset: null }));
4949
}, 200);
5050

51-
const handleClearAllPress = () => {
52-
Router.replace(urlWithQuery('/', { search: query.search, offset: null }));
53-
};
51+
function handleClearAllPress() {
52+
void Router.replace(urlWithQuery('/', { search: query.search, offset: undefined }));
53+
}
5454

5555
return (
5656
<>
@@ -80,11 +80,11 @@ const Search = ({ query, total }: Props) => {
8080
if (search) {
8181
event.preventDefault();
8282
inputRef.current.value = '';
83-
Router.replace(
83+
void Router.replace(
8484
urlWithQuery('/', {
8585
...query,
86-
search: null,
87-
offset: null,
86+
search: undefined,
87+
offset: undefined,
8888
})
8989
);
9090
} else {

components/Sort.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ const sorts = [
5252
];
5353

5454
export const SortButton = ({ query: { order, direction, offset }, query }: SortButtonProps) => {
55-
const [sortValue, setSortValue] = useState<QueryOrder>(order);
56-
const [sortDirection, setSortDirection] = useState<QueryOrderDirection>(direction);
57-
const [paginationOffset, setPaginationOffset] = useState<number | null>(
55+
const [sortValue, setSortValue] = useState<QueryOrder | undefined>(order);
56+
const [sortDirection, setSortDirection] = useState<QueryOrderDirection | undefined>(direction);
57+
const [paginationOffset, setPaginationOffset] = useState<number | undefined>(
5858
typeof offset === 'string' ? parseInt(offset, 10) : offset
5959
);
6060
const { isDark } = useContext(CustomAppearanceContext);
@@ -70,7 +70,7 @@ export const SortButton = ({ query: { order, direction, offset }, query }: SortB
7070
offset: paginationOffset,
7171
});
7272
if (url !== Router.pathname) {
73-
Router.push(url);
73+
void Router.push(url);
7474
}
7575
}, [sortValue, sortDirection]);
7676

components/Tag.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ReactElement, useContext } from 'react';
1+
import { ReactNode, useContext } from 'react';
22
import { StyleSheet, View, ViewStyle } from 'react-native';
33

44
import { colors, darkColors, Label } from '~/common/styleguide';
@@ -9,7 +9,7 @@ import { Check } from './Icons';
99
type Props = {
1010
label: string;
1111
tagStyle: ViewStyle;
12-
icon?: ReactElement;
12+
icon?: ReactNode;
1313
};
1414

1515
export const Tag = ({

0 commit comments

Comments
 (0)