From cc48730782be7bdf668016573b591eaeaa903884 Mon Sep 17 00:00:00 2001 From: Emil Johansson Date: Sat, 11 Mar 2023 10:02:16 -0700 Subject: [PATCH] fix lint errors and change character limit to 80 --- .prettierrc | 2 +- apps/code-not-found/pages/api/hello.ts | 5 +- apps/code-not-found/pages/index.tsx | 16 ++++- apps/code-not-found/pages/page-a.tsx | 12 +++- apps/code-not-found/styles/globals.css | 4 +- apps/design/pages/api/hello.ts | 5 +- apps/design/pages/index.tsx | 19 ++++-- apps/games/lib/deck.ts | 11 +++- apps/games/pages/api/hello.ts | 5 +- apps/games/pages/idiot.tsx | 32 ++++++++-- apps/games/pages/index.tsx | 4 +- apps/games/pages/spider.tsx | 51 ++++++++++++---- apps/games/pages/wordle.tsx | 11 +++- apps/next/app/encryption/page.tsx | 42 +++++++++++-- apps/next/app/layout.tsx | 11 +++- apps/next/app/page.tsx | 21 ++++++- apps/next/components/MineSweaper.tsx | 60 +++++++++++++++---- apps/next/components/TwoWayAuthEnter.tsx | 9 ++- apps/next/pages/_document.tsx | 20 ++++++- apps/next/pages/api/random-words.ts | 4 +- apps/next/pages/api/two-factor/[fn].ts | 16 ++++- apps/next/pages/hooks.tsx | 10 +++- apps/next/pages/index-old.tsx | 26 ++++++-- apps/next/pages/ms.tsx | 7 ++- apps/next/pages/password-generator.tsx | 30 ++++++++-- apps/next/pages/random-string.tsx | 4 +- apps/next/ui/DefaultTags.tsx | 20 ++++++- apps/password-manager/pages/accounts.tsx | 19 +++++- apps/password-manager/pages/add-account.tsx | 27 +++++++-- apps/password-manager/pages/api/plaintext.ts | 5 +- apps/password-manager/pages/login.tsx | 12 +++- apps/svelte/.eslintrc.cjs | 3 + .../password-generator/memorable/+page.svelte | 5 +- .../src/routes/progress-bar/+page.svelte | 2 +- cypress/e2e/home.cy.ts | 5 +- packages/config/eslint-preset.js | 30 ++++++---- packages/lib/utils/lang.ts | 3 +- packages/lib/utils/string.ts | 6 +- packages/shared/ThemeToggle.tsx | 5 +- packages/shared/globals.css | 25 ++++---- 40 files changed, 476 insertions(+), 128 deletions(-) diff --git a/.prettierrc b/.prettierrc index c239ad7..8d82fce 100644 --- a/.prettierrc +++ b/.prettierrc @@ -3,7 +3,7 @@ "useTabs": true, "singleQuote": true, "trailingComma": "all", - "printWidth": 100, + "printWidth": 80, "plugins": [], "pluginSearchDirs": ["."], "overrides": [] diff --git a/apps/code-not-found/pages/api/hello.ts b/apps/code-not-found/pages/api/hello.ts index ce9023c..ec8c286 100644 --- a/apps/code-not-found/pages/api/hello.ts +++ b/apps/code-not-found/pages/api/hello.ts @@ -5,6 +5,9 @@ type Data = { name: string } -export default function handler(req: NextApiRequest, res: NextApiResponse) { +export default function handler( + req: NextApiRequest, + res: NextApiResponse, +) { res.status(200).json({ name: 'John Doe' }) } diff --git a/apps/code-not-found/pages/index.tsx b/apps/code-not-found/pages/index.tsx index b52ea0f..c488cd8 100644 --- a/apps/code-not-found/pages/index.tsx +++ b/apps/code-not-found/pages/index.tsx @@ -34,7 +34,10 @@ const HomePage: NextPage = () => {
- + @@ -55,7 +58,9 @@ const HomePage: NextPage = () => { className={styles.card} >

Deploy →

-

Instantly deploy your Next.js site to a public URL with Vercel.

+

+ Instantly deploy your Next.js site to a public URL with Vercel. +

@@ -68,7 +73,12 @@ const HomePage: NextPage = () => { > Powered by{' '} - Vercel Logo + Vercel Logo diff --git a/apps/code-not-found/pages/page-a.tsx b/apps/code-not-found/pages/page-a.tsx index dba4053..d259b6b 100644 --- a/apps/code-not-found/pages/page-a.tsx +++ b/apps/code-not-found/pages/page-a.tsx @@ -16,7 +16,8 @@ const PageAPage: NextPage = () => {

Welcome to Page A

- Get started by editing pages/index.tsx + Get started by editing{' '} + pages/index.tsx

@@ -30,7 +31,10 @@ const PageAPage: NextPage = () => {

Learn about Next.js in an interactive course with quizzes!

- +

Examples →

Discover and deploy boilerplate example Next.js projects.

@@ -40,7 +44,9 @@ const PageAPage: NextPage = () => { className={styles.card} >

Deploy →

-

Instantly deploy your Next.js site to a public URL with Vercel.

+

+ Instantly deploy your Next.js site to a public URL with Vercel. +

diff --git a/apps/code-not-found/styles/globals.css b/apps/code-not-found/styles/globals.css index 67f28bb..037ae79 100644 --- a/apps/code-not-found/styles/globals.css +++ b/apps/code-not-found/styles/globals.css @@ -2,8 +2,8 @@ html, body { padding: 0; margin: 0; - font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, - Fira Sans, Droid Sans, Helvetica Neue, sans-serif; + font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, + Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif; } a { diff --git a/apps/design/pages/api/hello.ts b/apps/design/pages/api/hello.ts index ce9023c..ec8c286 100644 --- a/apps/design/pages/api/hello.ts +++ b/apps/design/pages/api/hello.ts @@ -5,6 +5,9 @@ type Data = { name: string } -export default function handler(req: NextApiRequest, res: NextApiResponse) { +export default function handler( + req: NextApiRequest, + res: NextApiResponse, +) { res.status(200).json({ name: 'John Doe' }) } diff --git a/apps/design/pages/index.tsx b/apps/design/pages/index.tsx index e6c581c..bf1a242 100644 --- a/apps/design/pages/index.tsx +++ b/apps/design/pages/index.tsx @@ -6,7 +6,13 @@ import * as RadioGroupPrimitive from '@radix-ui/react-radio-group' import { BorderSolidIcon } from '@radix-ui/react-icons' import { Label } from '@radix-ui/react-label' import { motion } from 'framer-motion' -import { Select, SelectGroup, SelectLabel, SelectItem, SelectSeparator } from 'shared/Select' +import { + Select, + SelectGroup, + SelectLabel, + SelectItem, + SelectSeparator, +} from 'shared/Select' import { Progress } from 'shared/Progress' import { ThemeToggle } from 'shared/ThemeToggle' import { Slider } from 'shared/Slider' @@ -91,13 +97,14 @@ const Home: NextPage = () => {

Components / Design System

- For years parents have espoused the health benefits of eating garlic bread with cheese - to their children, with the food earning such an iconic status in our culture that kids - will often dress up as warm, cheesy loaf for Halloween. + For years parents have espoused the health benefits of eating garlic + bread with cheese to their children, with the food earning such an + iconic status in our culture that kids will often dress up as warm, + cheesy loaf for Halloween.

- But a recent study shows that the celebrated appetizer may be linked to a series of - rabies cases springing up around the country. + But a recent study shows that the celebrated appetizer may be linked + to a series of rabies cases springing up around the country.

diff --git a/apps/games/lib/deck.ts b/apps/games/lib/deck.ts index f662494..9b75afe 100644 --- a/apps/games/lib/deck.ts +++ b/apps/games/lib/deck.ts @@ -12,5 +12,12 @@ export const createCard = (rank: Rank, suit: Suit, value: number): Card => ({ hidden: false, }) -export const createDeck = (suits: Suit[], getCardValue: (rank: Rank) => number) => - ranks.map((rank) => suits.map((suit) => createCard(rank, suit, getCardValue(rank)))).flat() +export const createDeck = ( + suits: Suit[], + getCardValue: (rank: Rank) => number, +) => + ranks + .map((rank) => + suits.map((suit) => createCard(rank, suit, getCardValue(rank))), + ) + .flat() diff --git a/apps/games/pages/api/hello.ts b/apps/games/pages/api/hello.ts index ce9023c..ec8c286 100644 --- a/apps/games/pages/api/hello.ts +++ b/apps/games/pages/api/hello.ts @@ -5,6 +5,9 @@ type Data = { name: string } -export default function handler(req: NextApiRequest, res: NextApiResponse) { +export default function handler( + req: NextApiRequest, + res: NextApiResponse, +) { res.status(200).json({ name: 'John Doe' }) } diff --git a/apps/games/pages/idiot.tsx b/apps/games/pages/idiot.tsx index de67f0a..da567a0 100644 --- a/apps/games/pages/idiot.tsx +++ b/apps/games/pages/idiot.tsx @@ -10,7 +10,12 @@ import Header from 'shared/Header' import HeaderAction from 'shared/HeaderAction' import type { Card, Deck, Piles, Rank, Suit } from '@/types/card-games' import { createDeck } from '@/lib/deck' -import { deselectAll, moveCardsToPiles, removeEmptyLeadingCards, scaleGame } from '@/lib/game' +import { + deselectAll, + moveCardsToPiles, + removeEmptyLeadingCards, + scaleGame, +} from '@/lib/game' import { usePreloadCards } from '@/lib/hooks' enum RankValue { @@ -21,12 +26,18 @@ enum RankValue { } const suits: Suit[] = ['C', 'D', 'H', 'S'] -const getCardValue = (rank: Rank) => (typeof rank === 'number' ? rank : RankValue[rank]) +const getCardValue = (rank: Rank) => + typeof rank === 'number' ? rank : RankValue[rank] const baseDeck = createDeck(suits, getCardValue) export async function getServerSideProps() { const deck = shuffle(baseDeck) - const initPiles = [deck.splice(0, 1), deck.splice(0, 1), deck.splice(0, 1), deck.splice(0, 1)] + const initPiles = [ + deck.splice(0, 1), + deck.splice(0, 1), + deck.splice(0, 1), + deck.splice(0, 1), + ] return { props: { @@ -62,7 +73,9 @@ const IdiotPage: NextPage = ({ if (!current) { const selectedIndex = getSelectedCardIndex() if (isDefined(selectedIndex)) { - const moveCard = first(piles[selectedIndex].splice(lastIndex(piles[selectedIndex]), 1)) + const moveCard = first( + piles[selectedIndex].splice(lastIndex(piles[selectedIndex]), 1), + ) piles[index].splice(lastIndex(piles[index]), 1, moveCard) if (piles[selectedIndex].length < 1) { piles[selectedIndex].push(undefined) @@ -82,7 +95,9 @@ const IdiotPage: NextPage = ({ deselectAll(piles) if (shouldBeRemoved) { const pileIndex = currentCards - .map((card, index) => (card?.combined === current.combined ? index : undefined)) + .map((card, index) => + card?.combined === current.combined ? index : undefined, + ) .filter(isDefined)[0] const newPiles = [...piles] newPiles[pileIndex].splice(lastIndex(newPiles[pileIndex]), 1) @@ -102,7 +117,12 @@ const IdiotPage: NextPage = ({ .filter(isDefined)[0] } - const getCurrentCards = () => [last(piles[0]), last(piles[1]), last(piles[2]), last(piles[3])] + const getCurrentCards = () => [ + last(piles[0]), + last(piles[1]), + last(piles[2]), + last(piles[3]), + ] return ( <> diff --git a/apps/games/pages/index.tsx b/apps/games/pages/index.tsx index 7a55409..2c1803b 100644 --- a/apps/games/pages/index.tsx +++ b/apps/games/pages/index.tsx @@ -17,7 +17,9 @@ const HomePage: NextPage = () => { Spider Solitaire
  • - The Idiot Solitaire (from swedish "Idioten") + + The Idiot Solitaire (from swedish "Idioten") +
  • Bad Wordle "clone" diff --git a/apps/games/pages/spider.tsx b/apps/games/pages/spider.tsx index 395609f..53977ef 100644 --- a/apps/games/pages/spider.tsx +++ b/apps/games/pages/spider.tsx @@ -10,7 +10,12 @@ import Header from 'shared/Header' import HeaderAction from 'shared/HeaderAction' import type { Card, Deck, Piles, Rank, Suit } from '@/types/card-games' import { createDeck } from '@/lib/deck' -import { deselectAll, moveCardsToPiles, removeEmptyLeadingCards, scaleGame } from '@/lib/game' +import { + deselectAll, + moveCardsToPiles, + removeEmptyLeadingCards, + scaleGame, +} from '@/lib/game' import { usePreloadCards } from '@/lib/hooks' enum RankValue { @@ -21,12 +26,18 @@ enum RankValue { } const suits: Suit[] = ['H', 'S'] -const getCardValue = (rank: Rank) => (typeof rank === 'number' ? rank : RankValue[rank]) +const getCardValue = (rank: Rank) => + typeof rank === 'number' ? rank : RankValue[rank] const createBaseDeck = () => createDeck(suits, getCardValue) export async function getServerSideProps() { const deck = shuffle( - [createBaseDeck(), createBaseDeck(), createBaseDeck(), createBaseDeck()].flat(), + [ + createBaseDeck(), + createBaseDeck(), + createBaseDeck(), + createBaseDeck(), + ].flat(), ) const initPiles = [ @@ -107,12 +118,18 @@ const SpiderPage: NextPage = ({ function handleSelectedCard(current: Card, currentPileIndex: number) { console.log(current) - const [selectedCard, selectedPileIndex, selectedCardIndex] = getSelectedCard() + const [selectedCard, selectedPileIndex, selectedCardIndex] = + getSelectedCard() if (!current) { if (!isDefined(selectedCard)) { return } - moveCard(selectedCard, selectedPileIndex, selectedCardIndex, currentPileIndex) + moveCard( + selectedCard, + selectedPileIndex, + selectedCardIndex, + currentPileIndex, + ) return } const shouldBeMoved = @@ -123,7 +140,12 @@ const SpiderPage: NextPage = ({ current.id === last(piles[currentPileIndex]).id if (shouldBeMoved) { - moveCard(selectedCard, selectedPileIndex, selectedCardIndex, currentPileIndex) + moveCard( + selectedCard, + selectedPileIndex, + selectedCardIndex, + currentPileIndex, + ) return } deselectAll(piles) @@ -146,16 +168,24 @@ const SpiderPage: NextPage = ({ if (newPiles[selectedPileIndex].length < 1) { newPiles[selectedPileIndex].push(undefined) } else { - newPiles[selectedPileIndex][newPiles[selectedPileIndex].length - 1].hidden = false + newPiles[selectedPileIndex][ + newPiles[selectedPileIndex].length - 1 + ].hidden = false } if (isDefined(first(newPiles[currentPileIndex]))) { - newPiles[currentPileIndex].splice(newPiles[currentPileIndex].length, 0, ...removedCards) + newPiles[currentPileIndex].splice( + newPiles[currentPileIndex].length, + 0, + ...removedCards, + ) } else { newPiles[currentPileIndex] = removedCards } selectedCard.selected = false - const clickableIndexes = getClickableIndexesFromPile(newPiles[currentPileIndex]).reverse() + const clickableIndexes = getClickableIndexesFromPile( + newPiles[currentPileIndex], + ).reverse() if (clickableIndexes.length >= 13) { newPiles[currentPileIndex].splice( clickableIndexes[0], @@ -195,7 +225,8 @@ const SpiderPage: NextPage = ({
    {pile.map((card, cardIndex) => { const clickableIndexes = getClickableIndexesFromPile(pile) - const clickable = !isDefined(card) || clickableIndexes.indexOf(cardIndex) > -1 + const clickable = + !isDefined(card) || clickableIndexes.indexOf(cardIndex) > -1 const cardImage = !isDefined(card) ? 'blank' : !card.hidden diff --git a/apps/games/pages/wordle.tsx b/apps/games/pages/wordle.tsx index ceab5bd..fcf531f 100644 --- a/apps/games/pages/wordle.tsx +++ b/apps/games/pages/wordle.tsx @@ -16,7 +16,8 @@ interface Guess { colors: Color[] } -const from = (length: number, value: T): T[] => Array.from({ length }, () => value) +const from = (length: number, value: T): T[] => + Array.from({ length }, () => value) const dictionary = [ faker.locales.en.word.adjective.filter((word) => word.length === 5), @@ -80,7 +81,9 @@ const Field = ({ letters }: { letters: string[] }) => { {fixedList.map((letter, index) => (
    {letter}
    @@ -98,7 +101,9 @@ const BlankRow = () => { {fixedList.map((_, index) => (
    ))}
    diff --git a/apps/next/app/encryption/page.tsx b/apps/next/app/encryption/page.tsx index 344f3fb..65e6dee 100644 --- a/apps/next/app/encryption/page.tsx +++ b/apps/next/app/encryption/page.tsx @@ -32,15 +32,30 @@ const Encrypt = () => { - + - + - +
    ) @@ -71,15 +86,30 @@ const Decrypt = () => { - + - + - + ) diff --git a/apps/next/app/layout.tsx b/apps/next/app/layout.tsx index dd6d321..795a3d4 100644 --- a/apps/next/app/layout.tsx +++ b/apps/next/app/layout.tsx @@ -138,7 +138,13 @@ const Command = ({ onClose }: { onClose: () => void }) => { return } event.preventDefault() - console.log('key', event.key, selectedIndex, selectedIndex - 1, selectedIndex + 1) + console.log( + 'key', + event.key, + selectedIndex, + selectedIndex - 1, + selectedIndex + 1, + ) if (event.key === 'ArrowUp') { let newIndex = selectedIndex - 1 if (newIndex < 0) newIndex = list.length - 1 @@ -173,7 +179,8 @@ const Command = ({ onClose }: { onClose: () => void }) => { setSelectedIndex(0) setList( projects.filter( - ({ text }) => text.toLowerCase().indexOf(event.currentTarget.value) > -1, + ({ text }) => + text.toLowerCase().indexOf(event.currentTarget.value) > -1, ), ) }} diff --git a/apps/next/app/page.tsx b/apps/next/app/page.tsx index 49d5bf3..fc6f1e0 100644 --- a/apps/next/app/page.tsx +++ b/apps/next/app/page.tsx @@ -116,11 +116,20 @@ export default function Page() { rel="noreferrer" > - + {' '}