Update eslint to 8.27.0

This commit is contained in:
Fedor Indutny 2022-11-17 16:45:19 -08:00 committed by GitHub
parent c8fb43a846
commit 98ef4c627a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
499 changed files with 8995 additions and 8494 deletions

View file

@ -21,116 +21,114 @@ export type OwnProps = {
export type Props = OwnProps;
export const StickerManager = React.memo(
({
installedPacks,
receivedPacks,
knownPacks,
blessedPacks,
downloadStickerPack,
installStickerPack,
uninstallStickerPack,
i18n,
}: Props) => {
const focusRef = React.createRef<HTMLDivElement>();
const [packToPreview, setPackToPreview] =
React.useState<StickerPackType | null>(null);
export const StickerManager = React.memo(function StickerManagerInner({
installedPacks,
receivedPacks,
knownPacks,
blessedPacks,
downloadStickerPack,
installStickerPack,
uninstallStickerPack,
i18n,
}: Props) {
const focusRef = React.createRef<HTMLDivElement>();
const [packToPreview, setPackToPreview] =
React.useState<StickerPackType | null>(null);
React.useEffect(() => {
if (!knownPacks) {
return;
React.useEffect(() => {
if (!knownPacks) {
return;
}
knownPacks.forEach(pack => {
downloadStickerPack(pack.id, pack.key);
});
// When this component is created, it's initially not part of the DOM, and then it's
// added off-screen and animated in. This ensures that the focus takes.
setTimeout(() => {
if (focusRef.current) {
focusRef.current.focus();
}
knownPacks.forEach(pack => {
downloadStickerPack(pack.id, pack.key);
});
});
// We only want to attempt downloads on initial load
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
// When this component is created, it's initially not part of the DOM, and then it's
// added off-screen and animated in. This ensures that the focus takes.
setTimeout(() => {
if (focusRef.current) {
focusRef.current.focus();
}
});
// We only want to attempt downloads on initial load
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
const clearPackToPreview = React.useCallback(() => {
setPackToPreview(null);
}, [setPackToPreview]);
const clearPackToPreview = React.useCallback(() => {
setPackToPreview(null);
}, [setPackToPreview]);
const previewPack = React.useCallback((pack: StickerPackType) => {
setPackToPreview(pack);
}, []);
const previewPack = React.useCallback((pack: StickerPackType) => {
setPackToPreview(pack);
}, []);
return (
<>
{packToPreview ? (
<StickerPreviewModal
i18n={i18n}
pack={packToPreview}
onClose={clearPackToPreview}
downloadStickerPack={downloadStickerPack}
installStickerPack={installStickerPack}
uninstallStickerPack={uninstallStickerPack}
/>
) : null}
<div className="module-sticker-manager" tabIndex={-1} ref={focusRef}>
{[
{
i18nKey: 'stickers--StickerManager--InstalledPacks',
i18nEmptyKey: 'stickers--StickerManager--InstalledPacks--Empty',
packs: installedPacks,
hideIfEmpty: false,
},
{
i18nKey: 'stickers--StickerManager--BlessedPacks',
i18nEmptyKey: 'stickers--StickerManager--BlessedPacks--Empty',
packs: blessedPacks,
hideIfEmpty: true,
},
{
i18nKey: 'stickers--StickerManager--ReceivedPacks',
i18nEmptyKey: 'stickers--StickerManager--ReceivedPacks--Empty',
packs: receivedPacks,
hideIfEmpty: false,
},
].map(section => {
if (section.hideIfEmpty && section.packs.length === 0) {
return null;
}
return (
<>
{packToPreview ? (
<StickerPreviewModal
i18n={i18n}
pack={packToPreview}
onClose={clearPackToPreview}
downloadStickerPack={downloadStickerPack}
installStickerPack={installStickerPack}
uninstallStickerPack={uninstallStickerPack}
/>
) : null}
<div className="module-sticker-manager" tabIndex={-1} ref={focusRef}>
{[
{
i18nKey: 'stickers--StickerManager--InstalledPacks',
i18nEmptyKey: 'stickers--StickerManager--InstalledPacks--Empty',
packs: installedPacks,
hideIfEmpty: false,
},
{
i18nKey: 'stickers--StickerManager--BlessedPacks',
i18nEmptyKey: 'stickers--StickerManager--BlessedPacks--Empty',
packs: blessedPacks,
hideIfEmpty: true,
},
{
i18nKey: 'stickers--StickerManager--ReceivedPacks',
i18nEmptyKey: 'stickers--StickerManager--ReceivedPacks--Empty',
packs: receivedPacks,
hideIfEmpty: false,
},
].map(section => {
if (section.hideIfEmpty && section.packs.length === 0) {
return null;
}
return (
<React.Fragment key={section.i18nKey}>
<h2
className={classNames(
'module-sticker-manager__text',
'module-sticker-manager__text--heading'
)}
>
{i18n(section.i18nKey)}
</h2>
{section.packs.length > 0 ? (
section.packs.map(pack => (
<StickerManagerPackRow
key={pack.id}
pack={pack}
i18n={i18n}
onClickPreview={previewPack}
installStickerPack={installStickerPack}
uninstallStickerPack={uninstallStickerPack}
/>
))
) : (
<div className="module-sticker-manager__empty">
{i18n(section.i18nEmptyKey)}
</div>
return (
<React.Fragment key={section.i18nKey}>
<h2
className={classNames(
'module-sticker-manager__text',
'module-sticker-manager__text--heading'
)}
</React.Fragment>
);
})}
</div>
</>
);
}
);
>
{i18n(section.i18nKey)}
</h2>
{section.packs.length > 0 ? (
section.packs.map(pack => (
<StickerManagerPackRow
key={pack.id}
pack={pack}
i18n={i18n}
onClickPreview={previewPack}
installStickerPack={installStickerPack}
uninstallStickerPack={uninstallStickerPack}
/>
))
) : (
<div className="module-sticker-manager__empty">
{i18n(section.i18nEmptyKey)}
</div>
)}
</React.Fragment>
);
})}
</div>
</>
);
});