From 816fc5d64c401478839673478ffd2d467fe98e7c Mon Sep 17 00:00:00 2001 From: Marshall Polaris Date: Sun, 12 Jun 2022 21:42:41 -0700 Subject: [PATCH] Revert "Revert "Turn on no unused variables linting, kill dead code (#484)"" This reverts commit 5beda1ded724f7ad1a8d95ea022cf4930ca33b21. --- web/.eslintrc.js | 9 +- web/components/answers/answers-panel.tsx | 2 +- web/components/bets-list.tsx | 8 +- web/components/charity/charity-card.tsx | 2 +- web/components/choices-toggle-group.tsx | 3 +- web/components/confirmation-button.tsx | 4 +- web/components/contract/quick-bet.tsx | 8 +- web/components/feed-create.tsx | 99 +------------------ .../feed/feed-answer-comment-group.tsx | 2 +- web/components/feed/feed-items.tsx | 28 ------ web/components/folds/create-fold-button.tsx | 1 - web/components/liquidity-panel.tsx | 8 +- web/components/nav/profile-menu.tsx | 3 +- web/components/nav/sidebar.tsx | 5 - web/components/numeric-bet-panel.tsx | 1 - web/components/page.tsx | 3 +- web/hooks/use-fold.ts | 37 ------- web/lib/firebase/notifications.ts | 2 +- web/pages/activity.tsx | 2 +- web/pages/api/v0/market/[id].ts | 1 + web/pages/api/v0/slug/[slug].ts | 1 + web/pages/create.tsx | 6 +- web/pages/fold/[...slugs]/index.tsx | 11 --- web/pages/home.tsx | 2 +- web/pages/index.tsx | 2 +- web/pages/landing-page.tsx | 24 +---- web/pages/leaderboards.tsx | 4 +- web/pages/make-predictions.tsx | 10 -- web/pages/notifications.tsx | 6 +- web/pages/stats.tsx | 1 - 30 files changed, 43 insertions(+), 252 deletions(-) diff --git a/web/.eslintrc.js b/web/.eslintrc.js index 6c34b521..2f3ac31a 100644 --- a/web/.eslintrc.js +++ b/web/.eslintrc.js @@ -8,8 +8,15 @@ module.exports = { ], rules: { '@typescript-eslint/no-empty-function': 'off', - '@typescript-eslint/no-unused-vars': 'off', '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/no-unused-vars': [ + 'error', + { + argsIgnorePattern: '^_', + varsIgnorePattern: '^_', + caughtErrorsIgnorePattern: '^_', + }, + ], '@next/next/no-img-element': 'off', '@next/next/no-typos': 'off', 'lodash/import-scope': [2, 'member'], diff --git a/web/components/answers/answers-panel.tsx b/web/components/answers/answers-panel.tsx index c711abe8..eb992fe4 100644 --- a/web/components/answers/answers-panel.tsx +++ b/web/components/answers/answers-panel.tsx @@ -116,7 +116,7 @@ export function AnswersPanel(props: { contract: FreeResponseContract }) { {!resolveOption && (
- {answerItems.map((item, activityItemIdx) => ( + {answerItems.map((item) => (
diff --git a/web/components/bets-list.tsx b/web/components/bets-list.tsx index a4e90c35..d227ac88 100644 --- a/web/components/bets-list.tsx +++ b/web/components/bets-list.tsx @@ -138,9 +138,8 @@ export function BetsList(props: { user: User; hideBetsBefore?: number }) { return !hasSoldAll }) - const [settled, unsettled] = partition( - contracts, - (c) => c.isResolved || contractsMetrics[c.id].invested === 0 + const unsettled = contracts.filter( + (c) => !c.isResolved && contractsMetrics[c.id].invested !== 0 ) const currentInvested = sumBy( @@ -261,7 +260,7 @@ function ContractBets(props: { const isBinary = outcomeType === 'BINARY' - const { payout, profit, profitPercent, invested } = getContractBetMetrics( + const { payout, profit, profitPercent } = getContractBetMetrics( contract, bets ) @@ -657,7 +656,6 @@ function SellButton(props: { contract: Contract; bet: Bet }) { return ( txn.amount) diff --git a/web/components/choices-toggle-group.tsx b/web/components/choices-toggle-group.tsx index f974d72f..61c4e4fd 100644 --- a/web/components/choices-toggle-group.tsx +++ b/web/components/choices-toggle-group.tsx @@ -24,13 +24,12 @@ export function ChoicesToggleGroup(props: { null} + onChange={setChoice} > {Object.keys(choicesMap).map((choiceKey) => ( setChoice(choicesMap[choiceKey])} className={({ active }) => clsx( active ? 'ring-2 ring-indigo-500 ring-offset-2' : '', diff --git a/web/components/confirmation-button.tsx b/web/components/confirmation-button.tsx index e895467a..57a7bafe 100644 --- a/web/components/confirmation-button.tsx +++ b/web/components/confirmation-button.tsx @@ -5,7 +5,6 @@ import { Modal } from './layout/modal' import { Row } from './layout/row' export function ConfirmationButton(props: { - id: string openModalBtn: { label: string icon?: JSX.Element @@ -22,7 +21,7 @@ export function ConfirmationButton(props: { onSubmit: () => void children: ReactNode }) { - const { id, openModalBtn, cancelBtn, submitBtn, onSubmit, children } = props + const { openModalBtn, cancelBtn, submitBtn, onSubmit, children } = props const [open, setOpen] = useState(false) @@ -67,7 +66,6 @@ export function ResolveConfirmationButton(props: { props return ( @@ -257,7 +257,7 @@ function QuickOutcomeView(props: { // If there's a preview prob, display that instead of the current prob const override = previewProb === undefined ? undefined : formatPercent(previewProb) - const textColor = `text-${getColor(contract, previewProb)}` + const textColor = `text-${getColor(contract)}` let display: string | undefined switch (outcomeType) { @@ -306,7 +306,7 @@ function getNumericScale(contract: NumericContract) { return (ev - min) / (max - min) } -export function getColor(contract: Contract, previewProb?: number) { +export function getColor(contract: Contract) { // TODO: Try injecting a gradient here // return 'primary' const { resolution } = contract diff --git a/web/components/feed-create.tsx b/web/components/feed-create.tsx index 98b56d69..0a9b77e3 100644 --- a/web/components/feed-create.tsx +++ b/web/components/feed-create.tsx @@ -1,16 +1,10 @@ -import { sample } from 'lodash' -import { SparklesIcon, XIcon } from '@heroicons/react/solid' -import { Avatar } from './avatar' -import { useEffect, useRef, useState } from 'react' +import { SparklesIcon } from '@heroicons/react/solid' import { Spacer } from './layout/spacer' -import { NewContract } from '../pages/create' -import { firebaseLogin, User } from 'web/lib/firebase/users' +import { firebaseLogin } from 'web/lib/firebase/users' import { ContractsGrid } from './contract/contracts-list' -import { Contract, MAX_QUESTION_LENGTH } from 'common/contract' +import { Contract } from 'common/contract' import { Col } from './layout/col' -import clsx from 'clsx' import { Row } from './layout/row' -import { ENV_CONFIG } from '../../common/envs/constants' import { SiteLink } from './site-link' import { formatMoney } from 'common/util/format' @@ -67,90 +61,3 @@ export function FeedPromo(props: { hotContracts: Contract[] }) { ) } - -export default function FeedCreate(props: { - user?: User - tag?: string - placeholder?: string - className?: string -}) { - const { user, tag, className } = props - const [question, setQuestion] = useState('') - const [isExpanded, setIsExpanded] = useState(false) - const inputRef = useRef() - - // Rotate through a new placeholder each day - // Easter egg idea: click your own name to shuffle the placeholder - // const daysSinceEpoch = Math.floor(Date.now() / 1000 / 60 / 60 / 24) - - // Take care not to produce a different placeholder on the server and client - const [defaultPlaceholder, setDefaultPlaceholder] = useState('') - useEffect(() => { - setDefaultPlaceholder(`e.g. ${sample(ENV_CONFIG.newQuestionPlaceholders)}`) - }, []) - - const placeholder = props.placeholder ?? defaultPlaceholder - - return ( -
{ - !isExpanded && inputRef.current?.focus() - }} - > -
- - -
- -

Ask a question...

- {isExpanded && ( - - )} -
-