fix lint errors

This commit is contained in:
Sylver 2024-01-07 12:31:37 +08:00
parent 62b91a8316
commit 805ebcd4b4
12 changed files with 37 additions and 29 deletions

View File

@ -3,5 +3,9 @@ module.exports = {
parserOptions: {
project: './tsconfig.json',
},
rules: {},
rules: {
'@typescript-eslint/no-floating-promises': 'off',
'jsx-a11y/no-autofocus': 'off',
'jsx-a11y/media-has-caption': 'off',
},
};

View File

@ -14,9 +14,9 @@ let globalClient: ApolloClient<NormalizedCacheObject> | undefined;
const errorLink = onError(({ graphQLErrors, networkError }) => {
if (graphQLErrors) {
graphQLErrors.forEach(({ message, locations, path }) =>
console.log(`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`)
);
for (const { message, locations, path } of graphQLErrors) {
console.log(`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`);
}
}
if (networkError) {
console.log(`[Network error]: ${networkError.message}`);

View File

@ -1,3 +1,5 @@
/* eslint-disable jsx-a11y/no-static-element-interactions */
/* eslint-disable jsx-a11y/click-events-have-key-events */
import { Menu } from '@headlessui/react';
import clsx from 'clsx';
import type { FC, ReactNode } from 'react';

View File

@ -39,9 +39,11 @@ EmbedImage.embeddable = (data: Embeddable) => {
case 'image/svg+xml':
case 'image/webp':
case 'image/bmp':
case 'image/tiff':
case 'image/tiff': {
return true;
default:
}
default: {
return false;
}
}
};

View File

@ -23,9 +23,11 @@ EmbedVideo.embeddable = (data: Embeddable) => {
switch (data.type) {
case 'video/mp4':
case 'video/webm':
case 'video/ogg':
case 'video/ogg': {
return true;
default:
}
default: {
return false;
}
}
};

View File

@ -52,21 +52,17 @@ export const FileList: FC = () => {
{!source.data && <PageLoader />}
{filter === 'files' && (
<div className="grid grid-cols-2 gap-4 md:grid-cols-4 lg:grid-cols-6">
{files.data?.user.files.edges.map(({ node }) => (
<FileCard key={node.id} file={node} />
))}
{files.data?.user.files.edges.map(({ node }) => <FileCard key={node.id} file={node} />)}
</div>
)}
{filter === 'pastes' && (
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
{pastes.data?.user.pastes.edges.map(({ node }) => (
<PasteCard key={node.id} paste={node} />
))}
{pastes.data?.user.pastes.edges.map(({ node }) => <PasteCard key={node.id} paste={node} />)}
</div>
)}
{!source.loading && !hasContent && (
<Card className="text-gray-500">
You haven't uploaded anything yet. Once you upload something, it will appear here.
You haven&apos;t uploaded anything yet. Once you upload something, it will appear here.
</Card>
)}
</div>

View File

@ -1,5 +1,6 @@
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';
export type Maybe<T> = T | null;
export type InputMaybe<T> = Maybe<T>;
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };

View File

@ -1,3 +1,4 @@
/* eslint-disable unicorn/prefer-code-point */
const ENCRYPTION_ALGORITHM = 'AES-GCM';
const ENCRYPTION_LENGTH = 256;
@ -36,7 +37,7 @@ export async function encryptContent(content: string): Promise<EncryptionResult>
length: ENCRYPTION_LENGTH,
},
true,
['encrypt', 'decrypt']
['encrypt', 'decrypt'],
);
const encryptedContent = await crypto.subtle.encrypt(
@ -45,7 +46,7 @@ export async function encryptContent(content: string): Promise<EncryptionResult>
iv,
},
key,
new TextEncoder().encode(content)
new TextEncoder().encode(content),
);
const ivString = arrayBufferToBase64(iv);
@ -68,7 +69,7 @@ export async function decryptContent(data: EncryptionResult): Promise<string> {
name: ENCRYPTION_ALGORITHM,
},
true,
['encrypt', 'decrypt']
['encrypt', 'decrypt'],
);
const decryptedContent = await crypto.subtle.decrypt(
@ -77,7 +78,7 @@ export async function decryptContent(data: EncryptionResult): Promise<string> {
iv: base64ToArrayBuffer(iv),
},
key,
base64ToArrayBuffer(encryptedContent)
base64ToArrayBuffer(encryptedContent),
);
return new TextDecoder().decode(decryptedContent);

View File

@ -120,7 +120,7 @@ export default function Generate() {
such as Google Authenticator and Authy.
</p>
<p className="text-xs text-gray-600">
If you can't scan the QR code, you can enter the code{' '}
If you can&apos;t scan the QR code, you can enter the code{' '}
<code className="text-purple-400">{result.generateOTP.secret}</code> manually.
</p>
</div>
@ -148,7 +148,7 @@ export default function Generate() {
disabled={currentStep === 0}
className={clsx(
`text-gray-400 flex items-center gap-1 hover:underline`,
currentStep === 0 && 'opacity-0 pointer-events-none'
currentStep === 0 && 'opacity-0 pointer-events-none',
)}
>
<ChevronLeft className="h-4 w-4" /> Back

View File

@ -22,13 +22,13 @@ const FileOption: FC<{ children: ReactNode; className?: string; onClick: () => v
}) => {
const classes = clsx(
'flex items-center gap-2 shrink-0 transition-colors duration-100 hover:text-gray-300',
className
className,
);
return (
<span className={classes} onClick={onClick}>
<button className={classes} onClick={onClick}>
{children}
</span>
</button>
);
};

View File

@ -157,15 +157,15 @@ export default function Paste() {
placeholder="Markdown, code or plain text"
/>
<div className="flex gap-2 justify-end flex-wrap">
<label className="flex gap-2 items-center">
<label className="flex gap-2 items-center" htmlFor="burn">
<Checkbox id="burn" />
<span className="truncate">Destroy after viewing</span>
</label>
<label className="flex gap-2 items-center">
<label className="flex gap-2 items-center" htmlFor="paranoid">
<Checkbox id="paranoid" />
Long ID
</label>
<label className="flex gap-2 items-center">
<label className="flex gap-2 items-center" htmlFor="encrypt">
<Checkbox id="encrypt" />
Encrypt
</label>

View File

@ -133,14 +133,14 @@ export default function Upload() {
</Select>
<Button onClick={handleUpload}>Upload</Button>
</div>
<span
<button
className="mt-4 cursor-pointer text-primary"
onClick={() => {
setFile(null);
}}
>
Cancel
</span>
</button>
</Card>
</Container>
);