Skip to content

Connect, collaborate, and grow with a community of TypeScript developers

Fix the eslint config and remove the `void` calls for async functions (#169)

Sean Boulta3044326b0a6
diff --git a/.eslintrc.cjs b/.eslintrc.cjs
index d8342689..8a50f46b 100644
--- a/.eslintrc.cjs
+++ b/.eslintrc.cjs
@@ -1,26 +1,11 @@
-// eslint-disable-next-line @typescript-eslint/no-var-requires
-const path = require('path');
-
-/** @type {import("eslint").Linter.Config} */
+/**
+ * @type {import("eslint").Linter.Config}
+ */
const config = {
- overrides: [
- {
- extends: ['plugin:@typescript-eslint/recommended-requiring-type-checking'],
- files: ['*.ts', '*.tsx'],
- excludedFiles: ['./monaco-editor.d.ts'],
- parserOptions: {
- project: path.join(__dirname, 'tsconfig.json'),
- },
- },
- ],
parser: '@typescript-eslint/parser',
- parserOptions: {
- project: path.join(__dirname, 'tsconfig.json'),
- },
plugins: ['@typescript-eslint'],
extends: ['next/core-web-vitals', 'plugin:@typescript-eslint/recommended'],
rules: {
- quotes: ['error', 'single'],
'@typescript-eslint/consistent-type-imports': [
'warn',
{
diff --git a/src/app/create/page.tsx b/src/app/create/page.tsx
index dd0752b2..ba7dc428 100644
--- a/src/app/create/page.tsx
+++ b/src/app/create/page.tsx
@@ -39,7 +39,7 @@ export default function CreateChallenge() {
function onSubmit(prompt: string) {
if (name.length < 3) {
- return void toast({
+ return toast({
variant: 'destructive',
title: 'The title length should be longer than 3 character',
action: <ToastAction altText="Try again">Try again</ToastAction>,
@@ -47,7 +47,7 @@ export default function CreateChallenge() {
}
if (shortDescription.length < 10) {
- return void toast({
+ return toast({
variant: 'destructive',
title: 'The short description should be longer than 10 character',
action: <ToastAction altText="Try again">Try again</ToastAction>,
@@ -55,7 +55,7 @@ export default function CreateChallenge() {
}
if (description.length < 20) {
- return void toast({
+ return toast({
variant: 'destructive',
title: 'The description should be longer than 20 character',
action: <ToastAction altText="Try again">Try again</ToastAction>,
@@ -63,7 +63,7 @@ export default function CreateChallenge() {
}
if (difficulty === undefined) {
- return void toast({
+ return toast({
variant: 'destructive',
title: 'Please select a difficulty',
action: <ToastAction altText="Try again">Try again</ToastAction>,
diff --git a/src/components/admin/reports.tsx b/src/components/admin/reports.tsx
index 6933c282..17c0f5f2 100644
--- a/src/components/admin/reports.tsx
+++ b/src/components/admin/reports.tsx
@@ -271,9 +271,7 @@ export const ReportDetails = ({ data }: ReportsProps) => {
</div>
<Button
variant={'destructive'}
- onClick={() => {
- void handleUserBan();
- }}
+ onClick={handleUserBan}
className="flex items-center justify-center gap-2"
>
<Gavel className="h-4 w-4" />
@@ -284,7 +282,7 @@ export const ReportDetails = ({ data }: ReportsProps) => {
<Button
variant={'outline'}
onClick={() => {
- void handleDisableChallenge();
+ handleDisableChallenge();
}}
className="flex items-center justify-center gap-2"
>
@@ -292,9 +290,7 @@ export const ReportDetails = ({ data }: ReportsProps) => {
Disable Challenge
</Button>
<Button
- onClick={() => {
- void handleDismissReport();
- }}
+ onClick={handleDismissReport}
className="flex items-center justify-center gap-2"
>
<X className="h-4 w-4" />
diff --git a/src/components/admin/users.tsx b/src/components/admin/users.tsx
index 3e82a894..193978f7 100644
--- a/src/components/admin/users.tsx
+++ b/src/components/admin/users.tsx
@@ -93,7 +93,7 @@ export const BannedUsers = ({ data }: BannedUsersProps) => {
onChange={(item) => {
if (item.key === 'unban') {
// any better workarounds for void?
- void handleUserUnban(user);
+ handleUserUnban(user);
}
}}
/>
diff --git a/src/components/challenge/comments/index.tsx b/src/components/challenge/comments/index.tsx
index bdc5f70f..13efa859 100644
--- a/src/components/challenge/comments/index.tsx
+++ b/src/components/challenge/comments/index.tsx
@@ -96,16 +96,12 @@ const Comments = ({ challenge }: Props) => {
onChange={(e) => {
setText(e.target.value);
}}
- onKeyUp={(e) => {
- void handleEnterKey(e);
- }}
+ onKeyUp={handleEnterKey}
className="border-0 focus-visible:ring-0 focus-visible:ring-offset-0"
placeholder="Enter your comment here."
/>
<Button
- onClick={() => {
- void createChallengeComment();
- }}
+ onClick={createChallengeComment}
className="h-8 rounded-lg bg-emerald-600 px-3 py-2 hover:bg-emerald-500 dark:bg-emerald-400 dark:hover:bg-emerald-300"
>
Comment
diff --git a/src/components/challenge/description/index.tsx b/src/components/challenge/description/index.tsx
index 6755756f..ffb5b286 100644
--- a/src/components/challenge/description/index.tsx
+++ b/src/components/challenge/description/index.tsx
@@ -240,7 +240,7 @@ export function Description({ challenge }: Props) {
variant="ghost"
className="p-1"
disabled={!session?.data?.user?.id}
- onClick={(): void => {
+ onClick={() => {
let shouldBookmark = false;
if (hasBookmarked) {
shouldBookmark = false;
@@ -283,9 +283,6 @@ export function Description({ challenge }: Props) {
<DialogContent className="w-[200px]">
<DialogHeader>
<DialogTitle>Share this challenge</DialogTitle>
- <div className="pt-4">
- <ShareForm />
- </div>
</DialogHeader>
<div className="pt-4">
<ShareForm />
@@ -300,7 +297,7 @@ export function Description({ challenge }: Props) {
className="group -ml-1 w-14 gap-2 rounded-lg p-1"
variant="ghost"
disabled={!session?.data?.user?.id}
- onClick={(): void => {
+ onClick={() => {
let shouldIncrement = false;
if (hasVoted) {
setVotes((v) => v - 1);
diff --git a/src/components/challenge/share-form.tsx b/src/components/challenge/share-form.tsx
index 024725c0..cba7c2bd 100644
--- a/src/components/challenge/share-form.tsx
+++ b/src/components/challenge/share-form.tsx
@@ -33,7 +33,7 @@ export function ShareForm() {
? 'border border-green-500 text-green-500 dark:border-green-700 dark:bg-green-700 dark:text-white'
: 'border border-gray-100 text-black hover:bg-gray-100 dark:bg-white'
}`}
- onClick={() => void copyToClipboard()}
+ onClick={copyToClipboard}
>
<span>{copied ? 'Copied!' : 'Copy'}</span>
{copied ? <CheckCircle2Icon /> : <ClipboardIcon />}
diff --git a/src/components/ui/navigation.tsx b/src/components/ui/navigation.tsx
index 5c604c68..9e593661 100644
--- a/src/components/ui/navigation.tsx
+++ b/src/components/ui/navigation.tsx
@@ -95,7 +95,7 @@ export function Navigation() {
<Button
variant="ghost"
className="h-8 w-full justify-start rounded-b-lg rounded-t-sm px-2 text-red-500 hover:bg-red-500/20 hover:text-red-500"
- onClick={() => void handleSignOut()}
+ onClick={handleSignOut}
>
<span className="text-red-500">Log out</span>
</Button>
@@ -105,7 +105,7 @@ export function Navigation() {
) : (
<Button
disabled={loading || status === 'loading'}
- onClick={() => void handleSignIn()}
+ onClick={handleSignIn}
className="w-20 rounded-lg bg-white p-2 text-black duration-300 hover:bg-gray-200 focus:bg-accent focus:outline-none dark:bg-black dark:text-white hover:dark:bg-gray-800"
>
{loading || status === 'loading' ? (