From 899f948fa6779de469bb22d58409e7572acc27c1 Mon Sep 17 00:00:00 2001 From: Junseo Park Date: Sun, 28 Feb 2021 11:58:03 +0900 Subject: [PATCH] style: code style changes --- .eslintrc.js | 30 +- .github/ISSUE_TEMPLATE/bug.md | 14 +- .github/workflows/reviewdog.yml | 2 +- .github/workflows/testing.yml | 90 +-- .prettierignore | 2 + .vscode/settings.json | 12 +- app.css | 109 +-- components/Advertisement.tsx | 48 +- components/Application.tsx | 24 +- components/BotCard.tsx | 83 ++- components/Button.tsx | 57 +- components/ColorCard.tsx | 28 +- components/Container.tsx | 6 +- components/Docs.tsx | 7 +- components/Footer.tsx | 34 +- components/Form/CheckBox.tsx | 10 +- components/Form/CsrfToken.tsx | 6 +- components/Form/Input.tsx | 16 +- components/Form/Label.tsx | 71 +- components/Form/Select.tsx | 51 +- components/Loader.tsx | 24 +- components/Markdown.tsx | 117 +++- components/Message.tsx | 20 +- components/Modal.tsx | 57 +- components/Notice.tsx | 10 +- components/Owner.tsx | 34 +- components/Paginator.tsx | 98 ++- components/Search.tsx | 130 ++-- components/Segment.tsx | 6 +- components/SubmittedBotCard.tsx | 57 +- components/Tag.tsx | 75 +- components/Toggle.tsx | 29 +- components/Tooltip.tsx | 132 +++- docker-compose.yml | 4 +- eco.config.js | 23 +- github-markdown.css | 700 +++++++++---------- jest.config.js | 6 +- package.json | 170 ++--- pages/404.tsx | 24 +- pages/_document.tsx | 8 +- pages/api/[...404].ts | 7 +- pages/api/_custom/429.ts | 6 +- pages/api/auth/discord/callback.ts | 81 ++- pages/api/auth/discord/index.ts | 10 +- pages/api/auth/discord/logout.ts | 21 +- pages/api/v1/[[...deprecated]].ts | 13 +- pages/api/v2/applications/bots/[id]/index.ts | 32 +- pages/api/v2/applications/bots/[id]/reset.ts | 45 +- pages/api/v2/bots/[id].ts | 57 +- pages/api/v2/search/bots.ts | 40 +- pages/api/v2/users/[id].ts | 15 +- pages/api/widget/bots/[type]/[id].ts | 68 +- pages/bots/[id]/vote.tsx | 2 +- pages/bots/koreanbots.tsx | 4 +- pages/developers/index.tsx | 2 +- postcss.config.js | 2 +- renovate.json | 14 +- tests/utils.test.ts | 6 +- tsconfig.json | 57 +- types/global.d.ts | 2 +- types/index.ts | 37 +- utils/Csrf.ts | 25 +- utils/DiscordBot.ts | 2 +- utils/Fetch.ts | 18 +- utils/Knex.ts | 2 +- utils/Logger.ts | 4 +- utils/RateLimitHandler.ts | 20 +- utils/Regex.ts | 3 +- utils/RequestHandler.ts | 21 +- utils/ResponseWrapper.ts | 13 +- utils/Yup.ts | 188 +++-- utils/useOutsideClick.ts | 4 +- 72 files changed, 1914 insertions(+), 1331 deletions(-) create mode 100644 .prettierignore diff --git a/.eslintrc.js b/.eslintrc.js index 319a6c8..acd21b5 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -4,7 +4,7 @@ module.exports = { node: true, es6: true, browser: true, - es2021: true + es2021: true, }, ignorePatterns: ['node_modules/*', '.next/*', '.out/*', '!.prettierrc.js'], extends: [ @@ -12,20 +12,17 @@ module.exports = { 'plugin:@typescript-eslint/recommended', 'plugin:react/recommended', 'plugin:react-hooks/recommended', - 'plugin:jsx-a11y/recommended' + 'plugin:jsx-a11y/recommended', ], parser: '@typescript-eslint/parser', parserOptions: { ecmaFeatures: { - jsx: true + jsx: true, }, ecmaVersion: 12, - sourceType: 'module' + sourceType: 'module', }, - plugins: [ - 'react', - '@typescript-eslint' - ], + plugins: ['react', '@typescript-eslint'], rules: { 'jsx-quotes': ['error', 'prefer-single'], 'react/no-unescaped-entities': 'off', @@ -36,17 +33,8 @@ module.exports = { '@typescript-eslint/explicit-function-return-type': 'off', '@typescript-eslint/explicit-module-boundary-types': 'off', '@typescript-eslint/no-unused-vars': ['warn'], - indent: [ - 'error', - 'tab' - ], - quotes: [ - 'error', - 'single' - ], - semi: [ - 'error', - 'never' - ] - } + indent: ['error', 'tab'], + quotes: ['error', 'single'], + semi: ['error', 'never'], + }, } diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md index acccc8a..c2225b1 100644 --- a/.github/ISSUE_TEMPLATE/bug.md +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -1,32 +1,38 @@ --- + name: ๐Ÿ› ๋ฒ„๊ทธ ์ œ๋ณด about: ๋ฒ„๊ทธ๋ฅผ ์ œ๋ณดํ•ด์ฃผ์„ธ์š”! -title: "[๋ฒ„๊ทธ] " +title: '[๋ฒ„๊ทธ] ' labels: 'bug' assignees: '' +---## ์žฌํ˜„๋ฐฉ๋ฒ• ---- - -## ์žฌํ˜„๋ฐฉ๋ฒ• > ์–ด๋–ป๊ฒŒํ•˜๋ฉด ๋ฐœ์ƒ์‹œํ‚ฌ ์ˆ˜ ์žˆ๋‚˜์š”? ## ์˜ˆ์ƒ๋˜๋Š” ์ •์ƒ์ ์ธ ๋™์ž‘ + > ์ •์ƒ์ด๋ผ๋ฉด ์–ด๋–ป๊ฒŒ ๋˜์•ผํ•˜๋‚˜์š”? ## ๋ฐœ์ƒํ•œ ๋ฌธ์ œ + > ์–ด๋–ค ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•˜๋‚˜์š”? ## ํด๋ผ์ด์–ธํŠธ ๋ฒ„์ „ + > ํด๋ผ์ด์–ธํŠธ ๋ฒ„์ „์„ ์•Œ๋ ค์ฃผ์„ธ์š”! + + ## ์‚ฌ์–‘ + > OS ์ •๋ณด์™€ ๋ธŒ๋ผ์šฐ์ €์˜ ๋ฒ„์ „์„ ์•Œ๋ ค์ฃผ์„ธ์š”! ## ํ™•์ธ + - [ ] ์ค‘๋ณต๋˜๋Š” ์ด์Šˆ๋Š” ์—†๋‚˜์š”? - [ ] ํ•ด๋‹น ๋ฒ„๊ทธ๋ฅผ ๋‹ค์‹œ ๋ฐœ์ƒ์‹œํ‚ฌ ์ˆ˜ ์žˆ๋‚˜์š”? diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml index dda1d81..3aa55bc 100644 --- a/.github/workflows/reviewdog.yml +++ b/.github/workflows/reviewdog.yml @@ -12,4 +12,4 @@ jobs: with: reporter: github-pr-review reviewdog_version: latest - eslint_flags: --ext js,jsx,ts,tsx . \ No newline at end of file + eslint_flags: --ext js,jsx,ts,tsx . diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index ece3425..b21a091 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -7,57 +7,57 @@ jobs: name: ESLint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: install node v14 - uses: actions/setup-node@v2 - with: - node-version: 14 - - name: yarn install - run: yarn install - - name: run eslint - run: yarn lint - env: - CI: true + - uses: actions/checkout@v2 + - name: install node v14 + uses: actions/setup-node@v2 + with: + node-version: 14 + - name: yarn install + run: yarn install + - name: run eslint + run: yarn lint + env: + CI: true test: name: Run Test runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: install node v14 - uses: actions/setup-node@v2 - with: - node-version: 14 - - name: yarn install - run: yarn install - - name: run jest - run: yarn test + - uses: actions/checkout@v2 + - name: install node v14 + uses: actions/setup-node@v2 + with: + node-version: 14 + - name: yarn install + run: yarn install + - name: run jest + run: yarn test build: name: Build runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: install node v14 - uses: actions/setup-node@v2 - with: - node-version: 14 - - name: yarn install - run: yarn install - - name: Generate RSA Key Pair - run: | - ssh-keygen -b 2048 -t rsa -f key -q -P "" - ssh-keygen -b 2048 -e -m pem -f key -q -P "" > private.key - mv key public.pem - rm key.pub - - name: Setup environments - run: | - mv .env.demo.local .env.production.local - printf 'MARIADB_ROOT_PASSWORD=YOUSHALLNOTPASS\nCOMMIT_HASH=${{ github.sha }}' > .env - - name: Create needed files - run: echo '{"tester":"DEMO_KEY"}' > secret.json - - name: Build - run: yarn build - env: - CI: true + - uses: actions/checkout@v2 + - name: install node v14 + uses: actions/setup-node@v2 + with: + node-version: 14 + - name: yarn install + run: yarn install + - name: Generate RSA Key Pair + run: | + ssh-keygen -b 2048 -t rsa -f key -q -P "" + ssh-keygen -b 2048 -e -m pem -f key -q -P "" > private.key + mv key public.pem + rm key.pub + - name: Setup environments + run: | + mv .env.demo.local .env.production.local + printf 'MARIADB_ROOT_PASSWORD=YOUSHALLNOTPASS\nCOMMIT_HASH=${{ github.sha }}' > .env + - name: Create needed files + run: echo '{"tester":"DEMO_KEY"}' > secret.json + - name: Build + run: yarn build + env: + CI: true # docker: # needs: # - eslint @@ -75,7 +75,7 @@ jobs: # run: | # ssh-keygen -b 2048 -t rsa -f key -q -P "" # ssh-keygen -b 2048 -e -m pem -f key -q -P "" > private.key - # mv key public.pem + # mv key public.pem # rm key.pub # - name: Setup environments # run: | @@ -84,4 +84,4 @@ jobs: # - name: Create needed files # run: echo '{"tester":"DEMO_KEY"}' > secret.json # - name: Docker Compose - # run: docker-compose up -d \ No newline at end of file + # run: docker-compose up -d diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..9b76e35 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,2 @@ +.next/ +node_modules/ \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 3f2f5fe..eca599f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,7 @@ { - "editor.formatOnSave": false, - "editor.tabSize": 2, - "editor.codeActionsOnSave": { - "source.fixAll.eslint": true - } -} \ No newline at end of file + "editor.formatOnSave": false, + "editor.tabSize": 2, + "editor.codeActionsOnSave": { + "source.fixAll.eslint": true + } +} diff --git a/app.css b/app.css index 7dccf02..dc9135c 100644 --- a/app.css +++ b/app.css @@ -3,111 +3,114 @@ @tailwind utilities; html { - scroll-behavior: smooth; - min-height: 100%; - overflow-x: hidden; + scroll-behavior: smooth; + min-height: 100%; + overflow-x: hidden; } body { - min-height: 100vh; + min-height: 100vh; } @font-face { - font-family: "Uni Sans Heavy CAPS"; - src: url("/logofont.otf"); - font-display: swap; + font-family: 'Uni Sans Heavy CAPS'; + src: url('/logofont.otf'); + font-display: swap; } .logofont { - font-family: "Uni Sans Heavy CAPS"; + font-family: 'Uni Sans Heavy CAPS'; } .animation-dropdown { - animation: dropdown 0.1s linear; + animation: dropdown 0.1s linear; } .iu-is-the-best { - min-height: 100vh; + min-height: 100vh; } .__control--is-focused { - border: none !important; - box-shadow: none !important; + border: none !important; + box-shadow: none !important; } i { - width: 20px + width: 20px; } html * ::-webkit-scrollbar { - -webkit-appearance: none; - width: 8px; - height: 8px; + -webkit-appearance: none; + width: 8px; + height: 8px; } html * ::-webkit-scrollbar-thumb { - cursor: pointer; - border-radius: 5px; - background: #ccc; - -webkit-transition: color .2s ease; - transition: color .2s ease; + cursor: pointer; + border-radius: 5px; + background: #ccc; + -webkit-transition: color 0.2s ease; + transition: color 0.2s ease; } html .dark * ::-webkit-scrollbar-thumb { - cursor: pointer; - border-radius: 5px; - background: #202225; - -webkit-transition: color .2s ease; - transition: color .2s ease; + cursor: pointer; + border-radius: 5px; + background: #202225; + -webkit-transition: color 0.2s ease; + transition: color 0.2s ease; } html * ::-webkit-scrollbar-track { - background: #f2f2f2; - border-radius: 0; - border: 4px solid transparent; - border-radius: 8px; + background: #f2f2f2; + border-radius: 0; + border: 4px solid transparent; + border-radius: 8px; } html .dark * ::-webkit-scrollbar-track { - background: #2e3338; - border-radius: 0; + background: #2e3338; + border-radius: 0; } -.dark .__multi-value, .dark .__multi-value__label, .dark .__multi-value__remove { - background: #2e3338 !important; +.dark .__multi-value, +.dark .__multi-value__label, +.dark .__multi-value__remove { + background: #2e3338 !important; } .scroll-none { - -ms-overflow-style: none; - scrollbar-width: none; + -ms-overflow-style: none; + scrollbar-width: none; } .scroll-none ::-webkit-scrollbar { - display: none; + display: none; } button { - outline: none !important; + outline: none !important; } .emoji-selector-button { - width: 24px; - height: 24px; - display: inline-block; - background-image: url("https://unpkg.com/emoji-datasource-twitter@5.0.1/img/twitter/sheets-256/64.png"); - background-size: 5700% 5700%; - background-position: 53.5714% 62.5%; - filter: grayscale(100%); + width: 24px; + height: 24px; + display: inline-block; + background-image: url('https://unpkg.com/emoji-datasource-twitter@5.0.1/img/twitter/sheets-256/64.png'); + background-size: 5700% 5700%; + background-position: 53.5714% 62.5%; + filter: grayscale(100%); } .emoji-selector-button:hover { - filter: grayscale(0%); - transform: scale(1.1, 1.1); - opacity: 90%; - transition: ease-in 100ms; - cursor: pointer; + filter: grayscale(0%); + transform: scale(1.1, 1.1); + opacity: 90%; + transition: ease-in 100ms; + cursor: pointer; } -.emoji-mart-category-list > *, .emoji-mart-emoji > span { - cursor: pointer; -} \ No newline at end of file +.emoji-mart-category-list > *, +.emoji-mart-emoji > span { + cursor: pointer; +} diff --git a/components/Advertisement.tsx b/components/Advertisement.tsx index 19f7b0e..8680452 100644 --- a/components/Advertisement.tsx +++ b/components/Advertisement.tsx @@ -1,33 +1,45 @@ import Logger from '@utils/Logger' import { useEffect } from 'react' -const Advertisement = ({ size='short' }:AdvertisementProps): JSX.Element => { +const Advertisement = ({ size = 'short' }: AdvertisementProps): JSX.Element => { useEffect(() => { - if(process.env.NODE_ENV === 'production') { + if (process.env.NODE_ENV === 'production') { window.adsbygoogle = window.adsbygoogle || [] window.adsbygoogle.push({}) } Logger.debug('Ads Pushed') }, []) - - return
- { - process.env.NODE_ENV === 'production' ? : 'Advertisement' - }
+ + return ( +
+ {process.env.NODE_ENV === 'production' ? ( + + ) : ( + 'Advertisement' + )} +
+ ) } declare global { - interface Window { adsbygoogle: { - loaded?: boolean - push(obj: unknown): void - } } + interface Window { + adsbygoogle: { + loaded?: boolean + push(obj: unknown): void + } + } } interface AdvertisementProps { diff --git a/components/Application.tsx b/components/Application.tsx index aee440f..0b1ad41 100644 --- a/components/Application.tsx +++ b/components/Application.tsx @@ -1,19 +1,21 @@ import Link from 'next/link' import DiscordAvatar from './DiscordAvatar' -const Application = ({ type, id, name }:ApplicationProps):JSX.Element => { - return -
- -

{name}

-
- +const Application = ({ type, id, name }: ApplicationProps): JSX.Element => { + return ( + +
+ +

{name}

+
+ + ) } interface ApplicationProps { - type: 'bot' - id: string - name: string + type: 'bot' + id: string + name: string } -export default Application \ No newline at end of file +export default Application diff --git a/components/BotCard.tsx b/components/BotCard.tsx index 2219258..8261192 100644 --- a/components/BotCard.tsx +++ b/components/BotCard.tsx @@ -8,19 +8,34 @@ import Divider from '@components/Divider' import Tag from '@components/Tag' import DiscordAvatar from '@components/DiscordAvatar' -const BotCard = ({ manage=false, bot }: BotProps): JSX.Element => { +const BotCard = ({ manage = false, bot }: BotProps): JSX.Element => { return (
-
+ diff --git a/components/Button.tsx b/components/Button.tsx index 6154390..8585b61 100644 --- a/components/Button.tsx +++ b/components/Button.tsx @@ -1,24 +1,49 @@ import Link from 'next/link' import { ReactNode } from 'react' -const Button = ({ type='button', className, children, href, onClick }: ButtonProps):JSX.Element => { - return href ? - - { children } - - : onClick ? : +const Button = ({ + type = 'button', + className, + children, + href, + onClick, +}: ButtonProps): JSX.Element => { + return href ? ( + + + {children} + + + ) : onClick ? ( + + ) : ( + + ) } interface ButtonProps { - type?: 'button' | 'submit' | 'reset' - className?: string - children: ReactNode - href?: string - onClick?: () => void + type?: 'button' | 'submit' | 'reset' + className?: string + children: ReactNode + href?: string + onClick?: () => void } -export default Button \ No newline at end of file +export default Button diff --git a/components/ColorCard.tsx b/components/ColorCard.tsx index f08731e..513b3b6 100644 --- a/components/ColorCard.tsx +++ b/components/ColorCard.tsx @@ -1,18 +1,20 @@ -const ColorCard = ({ header, first, second, className }:ColorCardProps):JSX.Element => { - return
-

{header}

-

- {first}
- {second} -

-
+const ColorCard = ({ header, first, second, className }: ColorCardProps): JSX.Element => { + return ( +
+

{header}

+

+ {first}
+ {second} +

+
+ ) } interface ColorCardProps { - header: string - first: string - second: string - className: string + header: string + first: string + second: string + className: string } -export default ColorCard \ No newline at end of file +export default ColorCard diff --git a/components/Container.tsx b/components/Container.tsx index 2389a82..62c9f89 100644 --- a/components/Container.tsx +++ b/components/Container.tsx @@ -8,9 +8,9 @@ const Container = ({ }: ContainerProps): JSX.Element => { return (
{children}
diff --git a/components/Docs.tsx b/components/Docs.tsx index 4069657..1d24f7b 100644 --- a/components/Docs.tsx +++ b/components/Docs.tsx @@ -5,7 +5,10 @@ import SEO from './SEO' const Docs = ({ title, header, description, subheader, children }: DocsProps): JSX.Element => { return ( <> - +

@@ -21,7 +24,7 @@ const Docs = ({ title, header, description, subheader, children }: DocsProps): J

{children}
diff --git a/components/Footer.tsx b/components/Footer.tsx index b551bc9..cec6a06 100644 --- a/components/Footer.tsx +++ b/components/Footer.tsx @@ -5,10 +5,14 @@ import Wave from '@components/Wave' import Toggle from './Toggle' import { Theme } from '@types' -const Footer = ({ color, theme, setTheme }:FooterProps): JSX.Element => { +const Footer = ({ color, theme, setTheme }: FooterProps): JSX.Element => { return (
-