Skip to content

Commit 52dd734

Browse files
authored
Revert "initial cleanup steps"
1 parent b6988c0 commit 52dd734

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+4267
-9275
lines changed

.eslintrc.json

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
11
{
2-
"parser": "@typescript-eslint/parser",
3-
"parserOptions": {
4-
"project": "./tsconfig.json"
5-
},
6-
"plugins": ["@typescript-eslint"],
7-
"extends": ["next/core-web-vitals", "plugin:@typescript-eslint/recommended"],
8-
"rules": {
9-
"@typescript-eslint/consistent-type-imports": "warn",
10-
"@typescript-eslint/no-non-null-assertion": "off"
11-
}
2+
"extends": "next/core-web-vitals"
123
}

.github/workflows/codeql.yml

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
name: 'CodeQL'
1+
name: "CodeQL"
22

33
on:
44
push:
5-
branches: ['main']
5+
branches: [ "main" ]
66
pull_request:
7-
branches: ['main']
7+
branches: [ "main" ]
88

99
jobs:
1010
analyze:
@@ -18,21 +18,21 @@ jobs:
1818
strategy:
1919
fail-fast: false
2020
matrix:
21-
language: ['javascript']
21+
language: [ 'javascript' ]
2222

2323
steps:
24-
- name: Checkout repository
25-
uses: actions/checkout@v3
24+
- name: Checkout repository
25+
uses: actions/checkout@v3
2626

27-
- name: Initialize CodeQL
28-
uses: github/codeql-action/init@v2
29-
with:
30-
languages: ${{ matrix.language }}
27+
- name: Initialize CodeQL
28+
uses: github/codeql-action/init@v2
29+
with:
30+
languages: ${{ matrix.language }}
3131

32-
- name: Autobuild
33-
uses: github/codeql-action/autobuild@v2
32+
- name: Autobuild
33+
uses: github/codeql-action/autobuild@v2
3434

35-
- name: Perform CodeQL Analysis
36-
uses: github/codeql-action/analyze@v2
37-
with:
38-
category: '/language:${{matrix.language}}'
35+
- name: Perform CodeQL Analysis
36+
uses: github/codeql-action/analyze@v2
37+
with:
38+
category: "/language:${{matrix.language}}"

.husky/pre-commit

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npx pretty-quick --staged

components/avatar.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export function Avatar({ size = 'md', name, src }: AvatarProps) {
3232
<Image
3333
src={src}
3434
alt={name}
35+
layout="fixed"
3536
width={dimension[size]}
3637
height={dimension[size]}
3738
className="object-cover rounded-full"
@@ -41,7 +42,8 @@ export function Avatar({ size = 'md', name, src }: AvatarProps) {
4142
) : (
4243
<div className="grid">
4344
<div className="flex col-start-1 col-end-1 row-start-1 row-end-1">
44-
<Image
45+
{/* eslint-disable-next-line @next/next/no-img-element */}
46+
<img
4547
src={`/api/avatar?name=${encodeURIComponent(name)}`}
4648
alt={name}
4749
width={dimension[size]}
@@ -50,7 +52,8 @@ export function Avatar({ size = 'md', name, src }: AvatarProps) {
5052
</div>
5153
{isCharacterALetter(initial) && (
5254
<div className="relative flex items-center justify-center col-start-1 col-end-1 row-start-1 row-end-1">
53-
<Image
55+
{/* eslint-disable-next-line @next/next/no-img-element */}
56+
<img
5457
src={`/images/letters/${initial}.svg`}
5558
className={initialSize[size]}
5659
alt=""

components/button-link.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import type { ButtonVariant } from '@/components/button'
2-
import { buttonClasses } from '@/components/button'
3-
import Link, { type LinkProps } from 'next/link'
1+
import { buttonClasses, ButtonVariant } from '@/components/button'
2+
import Link, { LinkProps } from 'next/link'
43
import * as React from 'react'
54

65
type ButtonLinkProps = {

components/icon-button.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ButtonVariant } from '@/components/button'
1+
import { ButtonVariant } from '@/components/button'
22
import { classNames } from '@/lib/classnames'
33
import * as React from 'react'
44

components/markdown-editor.tsx

+10-14
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
11
import { HtmlView } from '@/components/html-view'
22
import { BoldIcon, ItalicIcon, LinkIcon, ListIcon } from '@/components/icons'
33
import { browserEnv } from '@/env/browser'
4-
import { api } from '@/lib/api'
54
import { classNames } from '@/lib/classnames'
65
import {
76
getSuggestionData,
87
uploadImageCommandHandler,
98
markdownToHtml,
109
} from '@/lib/editor'
10+
import { trpc } from '@/lib/trpc'
1111
import { Switch } from '@headlessui/react'
1212
import { matchSorter } from 'match-sorter'
1313
import * as React from 'react'
1414
import { useDetectClickOutside } from 'react-detect-click-outside'
15-
import { useQuery } from '@tanstack/react-query'
15+
import { useQuery } from 'react-query'
1616
import TextareaAutosize, {
17-
type TextareaAutosizeProps,
17+
TextareaAutosizeProps,
1818
} from 'react-textarea-autosize'
1919
import getCaretCoordinates from 'textarea-caret'
20-
import type { TextareaMarkdownRef } from 'textarea-markdown-editor'
21-
import TextareaMarkdown from 'textarea-markdown-editor'
22-
import { useItemList, type ItemOptions } from 'use-item-list'
20+
import TextareaMarkdown, { TextareaMarkdownRef } from 'textarea-markdown-editor'
21+
import { ItemOptions, useItemList } from 'use-item-list'
2322

2423
type MarkdownEditorProps = {
2524
label?: string
@@ -358,7 +357,7 @@ function Suggestion({
358357
const isEmojiType = state.type === 'emoji'
359358

360359
const emojiListQuery = useQuery(
361-
['emojiList'],
360+
'emojiList',
362361
async () => {
363362
const gemoji = (await import('gemoji')).gemoji
364363
return gemoji
@@ -369,7 +368,7 @@ function Suggestion({
369368
}
370369
)
371370

372-
const mentionListQuery = api.user.mentionList.useQuery(undefined, {
371+
const mentionListQuery = trpc.useQuery(['user.mentionList'], {
373372
enabled: state.isOpen && isMentionType,
374373
staleTime: 5 * 60 * 1000,
375374
})
@@ -381,10 +380,7 @@ function Suggestion({
381380
keys: ['name'],
382381
})
383382
.slice(0, 5)
384-
.map((item) => ({
385-
label: item.name,
386-
value: item.id,
387-
})) as SuggestionResult[]
383+
.map((item) => ({ label: item.name!, value: item.id }))
388384
}
389385

390386
if (isEmojiType && emojiListQuery.data) {
@@ -491,13 +487,13 @@ function SuggestionResult({
491487
index: number
492488
highlight: () => void
493489
select: () => void
494-
// eslint-disable-next-line @typescript-eslint/ban-types
490+
selected: any
495491
useHighlighted: () => Boolean
496492
}
497493
suggestionResult: SuggestionResult
498494
}) {
499495
const ref = React.useRef<HTMLLIElement>(null)
500-
const { id, highlight, select, useHighlighted } = useItem({
496+
const { id, index, highlight, select, useHighlighted } = useItem({
501497
ref,
502498
value: suggestionResult,
503499
})

components/menu.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { classNames } from '@/lib/classnames'
22
import { Menu as HeadlessMenu, Transition } from '@headlessui/react'
3-
import Link, { type LinkProps } from 'next/link'
3+
import Link, { LinkProps } from 'next/link'
44
import * as React from 'react'
55

66
export function Menu({ children }: { children: React.ReactNode }) {

components/post-form.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { MarkdownEditor } from '@/components/markdown-editor'
55
import { TextField } from '@/components/text-field'
66
import { useLeaveConfirm } from '@/lib/form'
77
import * as React from 'react'
8-
import { Controller, type SubmitHandler, useForm } from 'react-hook-form'
8+
import { Controller, SubmitHandler, useForm } from 'react-hook-form'
99

1010
type FormData = {
1111
title: string

components/post-summary.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ import {
99
} from '@/components/icons'
1010
import { MAX_LIKED_BY_SHOWN } from '@/components/like-button'
1111
import { classNames } from '@/lib/classnames'
12+
import { InferQueryOutput } from '@/lib/trpc'
1213
import * as Tooltip from '@radix-ui/react-tooltip'
1314
import formatDistanceToNow from 'date-fns/formatDistanceToNow'
1415
import { useSession } from 'next-auth/react'
1516
import { summarize } from '@/lib/text'
1617
import Link from 'next/link'
1718
import * as React from 'react'
18-
import type { RouterOutputs } from '@/lib/api'
1919

2020
export type PostSummaryProps = {
21-
post: RouterOutputs['post']['feed']['posts'][number]
21+
post: InferQueryOutput<'post.feed'>['posts'][number]
2222
hideAuthor?: boolean
2323
onLike: () => void
2424
onUnlike: () => void

components/search-dialog.tsx

+12-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { SearchIcon, SpinnerIcon } from '@/components/icons'
2-
import { api, type RouterOutputs } from '@/lib/api'
32
import { classNames } from '@/lib/classnames'
3+
import { InferQueryOutput, trpc } from '@/lib/trpc'
44
import { Dialog, Transition } from '@headlessui/react'
55
import Link from 'next/link'
66
import { useRouter } from 'next/router'
77
import * as React from 'react'
88
import { useDebounce } from 'use-debounce'
9-
import { type ItemOptions, useItemList } from 'use-item-list'
9+
import { ItemOptions, useItemList } from 'use-item-list'
1010

1111
type SearchDialogProps = {
1212
isOpen: boolean
@@ -22,13 +22,13 @@ function SearchResult({
2222
index: number
2323
highlight: () => void
2424
select: () => void
25-
// eslint-disable-next-line @typescript-eslint/ban-types
25+
selected: any
2626
useHighlighted: () => Boolean
2727
}
28-
result: RouterOutputs['post']['search'][number]
28+
result: InferQueryOutput<'post.search'>[number]
2929
}) {
3030
const ref = React.useRef<HTMLLIElement>(null)
31-
const { id, highlight, select, useHighlighted } = useItem({
31+
const { id, index, highlight, select, useHighlighted } = useItem({
3232
ref,
3333
value: result,
3434
})
@@ -55,10 +55,13 @@ function SearchField({ onSelect }: { onSelect: () => void }) {
5555
const [debouncedValue] = useDebounce(value, 1000)
5656
const router = useRouter()
5757

58-
const feedQuery = api.post.search.useQuery(
59-
{
60-
query: debouncedValue,
61-
},
58+
const feedQuery = trpc.useQuery(
59+
[
60+
'post.search',
61+
{
62+
query: debouncedValue,
63+
},
64+
],
6265
{
6366
enabled: debouncedValue.trim().length > 0,
6467
}

env/browser.ts

+1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ import { bool, envsafe } from 'envsafe'
33
export const browserEnv = envsafe({
44
NEXT_PUBLIC_ENABLE_IMAGE_UPLOAD: bool({
55
input: process.env.NEXT_PUBLIC_ENABLE_IMAGE_UPLOAD,
6+
default: false,
67
}),
78
})

env/server.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1-
import { bool, envsafe, invalidEnvError, makeValidator, str } from 'envsafe'
1+
import {
2+
bool,
3+
envsafe,
4+
invalidEnvError,
5+
makeValidator,
6+
str,
7+
url,
8+
} from 'envsafe'
29
import { browserEnv } from './browser'
310

4-
if (typeof window === 'undefined') {
11+
if (process.browser) {
512
throw new Error(
613
'This should only be included on the client (but the env vars wont be exposed)'
714
)

lib/api.ts

-50
This file was deleted.

0 commit comments

Comments
 (0)