Skip to content

Commit 78b7de1

Browse files
committedMar 22, 2024
chore: introduce eslint
1 parent 106f918 commit 78b7de1

File tree

23 files changed

+322
-108
lines changed

23 files changed

+322
-108
lines changed
 

‎.eslintrc.cjs

-12
This file was deleted.

‎.eslintrc.json

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{
2+
"root": true,
3+
"extends": [
4+
"eslint:recommended",
5+
"@remix-run/eslint-config",
6+
"@remix-run/eslint-config/node"
7+
],
8+
"parser": "@typescript-eslint/parser",
9+
"parserOptions": {
10+
"project": ["./tsconfig.json"]
11+
},
12+
"rules": {
13+
"@typescript-eslint/consistent-type-imports": "error",
14+
"@typescript-eslint/no-redeclare": "error",
15+
"@typescript-eslint/no-floating-promises": "warn",
16+
"@typescript-eslint/consistent-type-definitions": ["error", "type"],
17+
"@typescript-eslint/naming-convention": [
18+
"error",
19+
{
20+
"selector": "variable",
21+
"types": ["boolean"],
22+
"format": ["PascalCase"],
23+
"prefix": ["is", "should", "has", "are", "can", "was"]
24+
}
25+
],
26+
"no-restricted-syntax": [
27+
"error",
28+
{
29+
"selector": "TSEnumDeclaration",
30+
"message": "Don't declare enums"
31+
}
32+
],
33+
"@typescript-eslint/array-type": ["error", { "default": "generic" }],
34+
"@typescript-eslint/no-misused-promises": [
35+
"error",
36+
{
37+
"checksVoidReturn": true,
38+
"checksConditionals": true,
39+
"checksSpreads": true
40+
}
41+
],
42+
"no-await-in-loop": "error",
43+
"import/order": [
44+
"error",
45+
{
46+
"newlines-between": "always",
47+
"groups": [
48+
"type",
49+
"builtin",
50+
"external",
51+
["parent", "sibling"],
52+
"index"
53+
],
54+
"alphabetize": {
55+
"order": "asc",
56+
"caseInsensitive": true
57+
}
58+
}
59+
]
60+
},
61+
"ignorePatterns": [
62+
"**/node_modules/**",
63+
"**/dist/**",
64+
"**/build/**",
65+
"remix.config.js"
66+
]
67+
}

‎app/auth/auth.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import type { LoaderFunctionArgs } from '@vercel/remix'
2+
23
import { createCookie, redirect } from '@vercel/remix'
4+
35
import { env } from '~/helpers/env'
46

57
let secret = env.COOKIE_SECRET || 'default'

‎app/components/cursor/Cursor.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { LinksFunction } from '@vercel/remix'
2+
23
import cursorStyles from './Cursor.css'
34

45
type Props = {
@@ -35,7 +36,7 @@ export function Cursor({ color, name, x, y }: Props) {
3536
}
3637

3738
declare module 'react' {
38-
interface CSSProperties {
39+
type CSSProperties = {
3940
[key: `--${string}`]: string | number
4041
}
4142
}

‎app/components/navigation/Navigation.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import type { LinksFunction } from '@vercel/remix'
2+
3+
import { Link, useLocation } from '@remix-run/react'
4+
25
import navigationStyles from './Navigation.css'
6+
37
import { Kakashi } from '~/icons'
4-
import { Link, useLocation } from '@remix-run/react'
58

69
export const NAVIGATION_PORTAL_ID = 'navigation-portal'
710

‎app/helpers/liveblocks.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Liveblocks } from '@liveblocks/node'
2+
23
import { env } from './env'
34

45
export const liveblocks = new Liveblocks({

‎app/liveblocks.config.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import type { CardType } from './helpers'
12
import type { LiveList, LiveObject } from '@liveblocks/client'
3+
24
import { createClient } from '@liveblocks/client'
35
import { createRoomContext } from '@liveblocks/react'
4-
import type { CardType } from './helpers'
56

67
const client = createClient({
78
authEndpoint: '/api/liveblocks-auth',

‎app/root.tsx

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import overpassFont from '@fontsource-variable/overpass/index.css'
12
import { cssBundleHref } from '@remix-run/css-bundle'
23
import {
34
Links,
@@ -9,20 +10,20 @@ import {
910
useLoaderData,
1011
} from '@remix-run/react'
1112
import { Analytics } from '@vercel/analytics/react'
12-
import rootStyles from './styles/root.css'
13-
import overpassFont from '@fontsource-variable/overpass/index.css'
1413
import {
1514
type LinksFunction,
1615
type LoaderFunctionArgs,
1716
type MetaFunction,
1817
json,
1918
} from '@vercel/remix'
20-
import { getAuthFromRequest } from './auth/auth'
21-
import { Navigation, navigationLinks } from './components'
22-
import { getToast } from 'remix-toast'
2319
import { useEffect } from 'react'
2420
import { ToastContainer, toast as notify } from 'react-toastify'
2521
import toastStyles from 'react-toastify/dist/ReactToastify.css'
22+
import { getToast } from 'remix-toast'
23+
24+
import { getAuthFromRequest } from './auth/auth'
25+
import { Navigation, navigationLinks } from './components'
26+
import rootStyles from './styles/root.css'
2627

2728
export const links: LinksFunction = () => [
2829
...(cssBundleHref ? [{ rel: 'stylesheet', href: cssBundleHref }] : []),

‎app/routes/api_.liveblocks-auth/route.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { requireAuthCookie } from '~/auth'
2-
import { prisma } from '~/db/prisma'
31
import { invariant } from '@epic-web/invariant'
42
import { redirect, type ActionFunctionArgs } from '@vercel/remix'
3+
4+
import { requireAuthCookie } from '~/auth'
5+
import { prisma } from '~/db/prisma'
56
import { liveblocks } from '~/helpers/liveblocks'
67

78
export const action = async ({ request }: ActionFunctionArgs) => {

‎app/routes/boards/route.tsx

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1+
import type { LoaderFunctionArgs, LinksFunction } from '@vercel/remix'
2+
13
import { Form, Link, useLoaderData, useNavigation } from '@remix-run/react'
2-
import { FORM_INTENTS, INTENT } from '~/helpers'
3-
import { Plus } from '~/icons'
4+
import { redirect, json } from '@vercel/remix'
45

6+
import { createBoard, getBoardsForUser } from './queries'
57
import styles from './styles.css'
6-
import { redirect, json } from '@vercel/remix'
7-
import type { LoaderFunctionArgs, LinksFunction } from '@vercel/remix'
8+
89
import { requireAuthCookie } from '~/auth'
9-
import { createBoard, getBoardsForUser } from './queries'
10+
import { FORM_INTENTS, INTENT } from '~/helpers'
11+
import { Plus } from '~/icons'
1012

1113
export const links: LinksFunction = () => [{ rel: 'stylesheet', href: styles }]
1214

‎app/routes/boards_.$id.delete/route.tsx

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
1-
import { Dialog } from '@headlessui/react'
2-
import { Form, Link, useNavigate, useNavigation } from '@remix-run/react'
3-
import { FORM_INTENTS, INTENT, liveblocks } from '~/helpers'
4-
import { json } from '@vercel/remix'
51
import type {
62
LoaderFunctionArgs,
73
ActionFunctionArgs,
84
LinksFunction,
95
} from '@vercel/remix'
10-
import styles from './styles.css'
11-
import { Close } from '~/icons'
12-
import { requireAuthCookie } from '~/auth'
6+
import type { RoomEvent } from '~/liveblocks.config'
7+
138
import { invariant } from '@epic-web/invariant'
9+
import { Dialog } from '@headlessui/react'
10+
import { Form, Link, useNavigate, useNavigation } from '@remix-run/react'
11+
import { json } from '@vercel/remix'
1412
import { redirectWithError, redirectWithSuccess } from 'remix-toast'
13+
1514
import { checkIsUserOwnerOfBoard, deleteBoard } from './queries'
16-
import type { RoomEvent } from '~/liveblocks.config'
15+
import styles from './styles.css'
16+
17+
import { requireAuthCookie } from '~/auth'
18+
import { FORM_INTENTS, INTENT, liveblocks } from '~/helpers'
19+
import { Close } from '~/icons'
20+
1721

1822
export const links: LinksFunction = () => [{ rel: 'stylesheet', href: styles }]
1923

‎app/routes/boards_.$id.share/route.tsx

+21-18
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
import type { SubmissionResult } from '@conform-to/react'
2+
import type {
3+
LoaderFunctionArgs,
4+
ActionFunctionArgs,
5+
LinksFunction,
6+
} from '@vercel/remix'
7+
8+
import { getFormProps, getInputProps, useForm } from '@conform-to/react'
9+
import { parseWithZod } from '@conform-to/zod'
10+
import { invariant } from '@epic-web/invariant'
111
import { Dialog } from '@headlessui/react'
212
import {
313
Form,
@@ -7,26 +17,19 @@ import {
717
useNavigate,
818
useNavigation,
919
} from '@remix-run/react'
10-
import { z } from 'zod'
11-
import { parseWithZod } from '@conform-to/zod'
12-
import { FORM_INTENTS, INTENT } from '~/helpers'
13-
import type { SubmissionResult } from '@conform-to/react'
14-
import { getFormProps, getInputProps, useForm } from '@conform-to/react'
20+
import { useCopyToClipboard } from '@uidotdev/usehooks'
1521
import { json } from '@vercel/remix'
16-
import type {
17-
LoaderFunctionArgs,
18-
ActionFunctionArgs,
19-
LinksFunction,
20-
} from '@vercel/remix'
22+
import { useEffect } from 'react'
23+
import { jsonWithSuccess, redirectWithError } from 'remix-toast'
24+
import { z } from 'zod'
25+
26+
import { addNewBoardMember, getAllBoardRoles, getBoardById } from './queries'
2127
import styles from './styles.css'
22-
import { Close, Link as LinkIcon } from '~/icons'
28+
2329
import { requireAuthCookie } from '~/auth'
24-
import { invariant } from '@epic-web/invariant'
25-
import { addNewBoardMember, getAllBoardRoles, getBoardById } from './queries'
2630
import { checkUserAllowedToEditBoard } from '~/db'
27-
import { jsonWithSuccess, redirectWithError } from 'remix-toast'
28-
import { useEffect } from 'react'
29-
import { useCopyToClipboard } from '@uidotdev/usehooks'
31+
import { FORM_INTENTS, INTENT } from '~/helpers'
32+
import { Close, Link as LinkIcon } from '~/icons'
3033

3134
export const links: LinksFunction = () => [{ rel: 'stylesheet', href: styles }]
3235

@@ -74,7 +77,7 @@ export default function BoardShareRoute() {
7477
const [form, fields] = useForm({
7578
// We throw 403 json from action if user is not allowed to edit board
7679
// Happens only on API requests
77-
lastResult: lastResult as SubmissionResult<string[]>,
80+
lastResult: lastResult as SubmissionResult<Array<string>>,
7881
onValidate({ formData }) {
7982
return parseWithZod(formData, { schema })
8083
},
@@ -150,11 +153,11 @@ export default function BoardShareRoute() {
150153

151154
<div className="panel-footer">
152155
<div className="copy-link-wrapper">
156+
{/* eslint-disable-next-line @typescript-eslint/no-misused-promises */}
153157
<button type="button" onClick={() => copyToClipboard(shareLink)}>
154158
<LinkIcon />
155159
<span>Copy link</span>
156160
</button>
157-
158161
<p>
159162
{hasCopiedText
160163
? 'Copied to clipboard!'

‎app/routes/boards_.$id/route.tsx

+30-27
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,36 @@ import type {
33
LinksFunction,
44
LoaderFunctionArgs,
55
} from '@vercel/remix'
6-
import { json } from '@vercel/remix'
7-
import { requireAuthCookie } from '~/auth'
6+
import type { CardType } from '~/helpers'
7+
8+
import { parseWithZod } from '@conform-to/zod'
89
import { invariant } from '@epic-web/invariant'
10+
import { LiveList, LiveObject } from '@liveblocks/client'
11+
import { ClientSideSuspense } from '@liveblocks/react'
912
import {
1013
Link,
1114
Outlet,
1215
useFetcher,
1316
useLoaderData,
1417
useNavigate,
1518
} from '@remix-run/react'
19+
import { json } from '@vercel/remix'
20+
import { useEffect, type MouseEvent, useRef } from 'react'
21+
import { createPortal } from 'react-dom'
22+
import { toast } from 'react-toastify'
23+
import { redirectWithError } from 'remix-toast'
24+
import { v1 } from 'uuid'
25+
import { z } from 'zod'
26+
1627
import {
17-
RoomProvider,
18-
useEventListener,
19-
useMutation,
20-
useMyPresence,
21-
useOthers,
22-
useStorage,
23-
} from '~/liveblocks.config'
24-
import { LiveList, LiveObject } from '@liveblocks/client'
25-
import { ClientSideSuspense } from '@liveblocks/react'
28+
updateBoardLastOpenedAt,
29+
updateBoardName,
30+
upsertUserBoardRole,
31+
} from './queries'
2632
import styles from './styles.css'
27-
import { Kakashi, People, Trash } from '~/icons'
33+
import { checkUserAllowedToEnterBoardWithSecretId } from './validate'
34+
35+
import { requireAuthCookie } from '~/auth'
2836
import {
2937
CARD_DIMENSIONS,
3038
Card,
@@ -33,27 +41,22 @@ import {
3341
cursorLinks,
3442
Cursor,
3543
} from '~/components'
36-
import { createPortal } from 'react-dom'
37-
import {
38-
updateBoardLastOpenedAt,
39-
updateBoardName,
40-
upsertUserBoardRole,
41-
} from './queries'
42-
import type { CardType } from '~/helpers'
43-
import { FORM_INTENTS, INTENT } from '~/helpers'
44-
import { z } from 'zod'
45-
import { parseWithZod } from '@conform-to/zod'
46-
import { useEffect, type MouseEvent, useRef } from 'react'
47-
import { v1 } from 'uuid'
4844
import {
4945
checkUserAllowedToEditBoard,
5046
getUserFromDB,
5147
getUserRoleForBoard,
5248
} from '~/db'
53-
import { toast } from 'react-toastify'
54-
import { redirectWithError } from 'remix-toast'
55-
import { checkUserAllowedToEnterBoardWithSecretId } from './validate'
49+
import { FORM_INTENTS, INTENT } from '~/helpers'
5650
import { getColorWithId } from '~/helpers/functions'
51+
import { Kakashi, People, Trash } from '~/icons'
52+
import {
53+
RoomProvider,
54+
useEventListener,
55+
useMutation,
56+
useMyPresence,
57+
useOthers,
58+
useStorage,
59+
} from '~/liveblocks.config'
5760

5861
export const handle = {
5962
shouldHideRootNavigation: true,

‎app/routes/login/queries.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { prisma } from '~/db/prisma'
21
import crypto from 'crypto'
32

3+
import { prisma } from '~/db/prisma'
4+
45
export async function login(email: string, password: string) {
56
let user = await prisma.user.findUnique({
67
where: { email: email },

0 commit comments

Comments
 (0)
Please sign in to comment.