From 837516f0e61f4341852ad7dc70f21d2d2528fc2c Mon Sep 17 00:00:00 2001 From: strNophix Date: Tue, 4 Oct 2022 17:31:54 +0200 Subject: [PATCH] Updated prettier config --- client/.prettierrc | 5 ++- client/cypress.config.ts | 6 +-- client/cypress/support/component.ts | 10 ++--- client/cypress/support/e2e.ts | 2 +- client/cypress/tsconfig.json | 2 +- client/package.json | 3 +- client/src/App.tsx | 12 +++--- client/src/components/BrowseLayout.tsx | 12 +++--- client/src/components/Button.tsx | 25 +++++------ client/src/components/ChatBadge.tsx | 6 +-- client/src/components/ChatMessage.tsx | 4 +- client/src/components/FormField.tsx | 6 +-- client/src/components/InlineLink.tsx | 26 +++-------- client/src/components/Input.tsx | 32 +++++++------- client/src/components/LoginForm.tsx | 14 +++--- client/src/components/LoginModal.tsx | 25 +++++------ client/src/components/LoginModalTab.tsx | 10 ++--- client/src/components/NavBar.tsx | 28 ++++-------- client/src/components/SideNavChannel.tsx | 12 ++---- client/src/components/SignupForm.tsx | 33 +++++++------- client/src/components/SubmitButton.tsx | 11 ++--- client/src/lib/format.ts | 2 +- client/src/main.tsx | 12 +++--- client/src/pages/CategoryPage.tsx | 2 +- client/src/pages/ChannelPage.tsx | 16 +++---- client/src/pages/LoginPage.tsx | 4 +- client/src/pages/SignupPage.tsx | 4 +- client/src/placeholder/GetStreams.ts | 50 +++++++++++----------- client/src/placeholder/GetUserFollows.ts | 32 +++++++------- client/src/placeholder/SearchCategories.ts | 8 ++-- client/vite.config.ts | 8 ++-- 31 files changed, 188 insertions(+), 234 deletions(-) diff --git a/client/.prettierrc b/client/.prettierrc index 222861c..e1c6a26 100644 --- a/client/.prettierrc +++ b/client/.prettierrc @@ -1,4 +1,7 @@ { + "singleQuote": true, + "trailingComma": "es5", + "printWidth": 100, "tabWidth": 2, "useTabs": false -} +} \ No newline at end of file diff --git a/client/cypress.config.ts b/client/cypress.config.ts index 1ef916d..7ecbaa1 100644 --- a/client/cypress.config.ts +++ b/client/cypress.config.ts @@ -1,10 +1,10 @@ -import { defineConfig } from "cypress"; +import { defineConfig } from 'cypress'; export default defineConfig({ component: { devServer: { - framework: "react", - bundler: "vite", + framework: 'react', + bundler: 'vite', }, }, diff --git a/client/cypress/support/component.ts b/client/cypress/support/component.ts index 37f59ed..395d407 100644 --- a/client/cypress/support/component.ts +++ b/client/cypress/support/component.ts @@ -14,12 +14,12 @@ // *********************************************************** // Import commands.js using ES2015 syntax: -import './commands' +import './commands'; // Alternatively you can use CommonJS syntax: // require('./commands') -import { mount } from 'cypress/react18' +import { mount } from 'cypress/react18'; // Augment the Cypress namespace to include type definitions for // your custom command. @@ -28,12 +28,12 @@ import { mount } from 'cypress/react18' declare global { namespace Cypress { interface Chainable { - mount: typeof mount + mount: typeof mount; } } } -Cypress.Commands.add('mount', mount) +Cypress.Commands.add('mount', mount); // Example use: -// cy.mount() \ No newline at end of file +// cy.mount() diff --git a/client/cypress/support/e2e.ts b/client/cypress/support/e2e.ts index 6a173d6..598ab5f 100644 --- a/client/cypress/support/e2e.ts +++ b/client/cypress/support/e2e.ts @@ -14,7 +14,7 @@ // *********************************************************** // Import commands.js using ES2015 syntax: -import "./commands"; +import './commands'; // Alternatively you can use CommonJS syntax: // require('./commands') diff --git a/client/cypress/tsconfig.json b/client/cypress/tsconfig.json index 0a71bcf..3b3f8ce 100644 --- a/client/cypress/tsconfig.json +++ b/client/cypress/tsconfig.json @@ -3,4 +3,4 @@ "compilerOptions": { "isolatedModules": false } -} \ No newline at end of file +} diff --git a/client/package.json b/client/package.json index 206bb36..ef950a4 100644 --- a/client/package.json +++ b/client/package.json @@ -8,6 +8,7 @@ "build": "tsc && vite build --outDir ../dist", "preview": "vite preview", "lint": "eslint --fix --ext .js,.ts,.tsx ./src --ignore-path .gitignore", + "prettier": "prettier --ignore-path .gitignore --write \"**/*.+(js|json|ts|tsx)\"", "cypress": "cypress" }, "dependencies": { @@ -50,4 +51,4 @@ "vite": "^3.1.0" }, "proxy": "http://localhost:5000" -} \ No newline at end of file +} diff --git a/client/src/App.tsx b/client/src/App.tsx index 643bb75..2cd819b 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -1,10 +1,10 @@ -import { Routes, Route } from "react-router-dom"; +import { Routes, Route } from 'react-router-dom'; -import BrowseLayout from "./components/BrowseLayout"; -import CategoryPage from "./pages/CategoryPage"; -import ChannelPage from "./pages/ChannelPage"; -import LoginPage from "./pages/LoginPage"; -import SignupPage from "./pages/SignupPage"; +import BrowseLayout from './components/BrowseLayout'; +import CategoryPage from './pages/CategoryPage'; +import ChannelPage from './pages/ChannelPage'; +import LoginPage from './pages/LoginPage'; +import SignupPage from './pages/SignupPage'; function App() { return ( diff --git a/client/src/components/BrowseLayout.tsx b/client/src/components/BrowseLayout.tsx index f933982..65777c8 100644 --- a/client/src/components/BrowseLayout.tsx +++ b/client/src/components/BrowseLayout.tsx @@ -1,10 +1,10 @@ -import { ArrowLeftIcon } from "@heroicons/react/24/outline"; -import { Outlet, NavLink } from "react-router-dom"; +import { ArrowLeftIcon } from '@heroicons/react/24/outline'; +import { Outlet, NavLink } from 'react-router-dom'; -import Button from "../components/Button"; -import NavBar from "../components/NavBar"; -import SideNavChannel from "../components/SideNavChannel"; -import streamData from "../placeholder/GetStreams"; +import Button from '../components/Button'; +import NavBar from '../components/NavBar'; +import SideNavChannel from '../components/SideNavChannel'; +import streamData from '../placeholder/GetStreams'; function BrowseLayout() { return ( diff --git a/client/src/components/Button.tsx b/client/src/components/Button.tsx index 7f83d60..3637cf7 100644 --- a/client/src/components/Button.tsx +++ b/client/src/components/Button.tsx @@ -1,30 +1,25 @@ -import clsx from "clsx"; -import { FC } from "react"; +import clsx from 'clsx'; +import { FC } from 'react'; -type ButtonVariants = "filled" | "subtle"; +type ButtonVariants = 'filled' | 'subtle'; -interface ButtonProps extends React.ComponentPropsWithoutRef<"button"> { +interface ButtonProps extends React.ComponentPropsWithoutRef<'button'> { variant?: ButtonVariants; } const getStyling = (variant?: ButtonVariants) => { switch (variant) { - case "filled": - return "bg-neutral-700"; - case "subtle": - return "hover:bg-neutral-500"; + case 'filled': + return 'bg-neutral-700'; + case 'subtle': + return 'hover:bg-neutral-500'; default: - return "bg-neutral-700"; + return 'bg-neutral-700'; } }; const Button: FC = ({ className, variant, ...rest }) => { - return ( -
  • -
  • @@ -65,11 +59,7 @@ const NavBar: FC = () => { - setShowLogin(false)} - /> + setShowLogin(false)} /> ); }; diff --git a/client/src/components/SideNavChannel.tsx b/client/src/components/SideNavChannel.tsx index 6b0ae44..16b7e27 100644 --- a/client/src/components/SideNavChannel.tsx +++ b/client/src/components/SideNavChannel.tsx @@ -1,7 +1,7 @@ -import { FC } from "react"; +import { FC } from 'react'; -import { numFormatter } from "../lib/format"; -import { Stream } from "../types"; +import { numFormatter } from '../lib/format'; +import { Stream } from '../types'; interface SideNavChannelProps { stream: Stream; @@ -10,11 +10,7 @@ interface SideNavChannelProps { const SideNavChannel: FC = ({ stream }) => { return (
    - avatar + avatar
    {stream.user_name}
    diff --git a/client/src/components/SignupForm.tsx b/client/src/components/SignupForm.tsx index 5332abc..c1b9715 100644 --- a/client/src/components/SignupForm.tsx +++ b/client/src/components/SignupForm.tsx @@ -1,14 +1,13 @@ -import { zodResolver } from "@hookform/resolvers/zod"; -import { FC } from "react"; -import { SubmitHandler, useForm } from "react-hook-form"; -import { z } from "zod"; +import { zodResolver } from '@hookform/resolvers/zod'; +import { FC } from 'react'; +import { SubmitHandler, useForm } from 'react-hook-form'; +import { z } from 'zod'; -import FormField from "./FormField"; -import InlineLink from "./InlineLink"; -import SubmitButton from "./SubmitButton"; +import FormField from './FormField'; +import InlineLink from './InlineLink'; +import SubmitButton from './SubmitButton'; -const PASSWORD_REGEX = - /^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$ %^&*-]).{8,64}$/; +const PASSWORD_REGEX = /^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$ %^&*-]).{8,64}$/; const SignupFormSchema = z .object({ @@ -19,7 +18,7 @@ const SignupFormSchema = z }) .refine((data) => data.password === data.passwordRepeat, { message: "Passwords don't match", - path: ["passwordRepeat"], + path: ['passwordRepeat'], }); type SignupFormValues = z.infer; @@ -36,34 +35,34 @@ const SignupForm: FC = () => { return (

    - Creating an account allows you to participate in chat, follow your - favorite channels, and broadcast from your own channel. + Creating an account allows you to participate in chat, follow your favorite channels, and + broadcast from your own channel.

    - By clicking Sign Up, you are agreeing to twitch-clone's{" "} + By clicking Sign Up, you are agreeing to twitch-clone's{' '} Terms of Service diff --git a/client/src/components/SubmitButton.tsx b/client/src/components/SubmitButton.tsx index 113f784..2314bc0 100644 --- a/client/src/components/SubmitButton.tsx +++ b/client/src/components/SubmitButton.tsx @@ -1,16 +1,13 @@ -import clsx from "clsx"; -import { FC } from "react"; +import clsx from 'clsx'; +import { FC } from 'react'; -type ButtonProps = React.ComponentPropsWithoutRef<"input">; +type ButtonProps = React.ComponentPropsWithoutRef<'input'>; const SubmitButton: FC = ({ className, ...rest }) => { return ( ); diff --git a/client/src/lib/format.ts b/client/src/lib/format.ts index 021c006..910b541 100644 --- a/client/src/lib/format.ts +++ b/client/src/lib/format.ts @@ -1 +1 @@ -export const numFormatter = Intl.NumberFormat("en", { notation: "compact" }); +export const numFormatter = Intl.NumberFormat('en', { notation: 'compact' }); diff --git a/client/src/main.tsx b/client/src/main.tsx index 16bf907..0ff7988 100644 --- a/client/src/main.tsx +++ b/client/src/main.tsx @@ -1,11 +1,11 @@ -import React from "react"; -import ReactDOM from "react-dom/client"; -import { BrowserRouter } from "react-router-dom"; +import React from 'react'; +import ReactDOM from 'react-dom/client'; +import { BrowserRouter } from 'react-router-dom'; -import App from "./App"; -import "./styles/global.css"; +import App from './App'; +import './styles/global.css'; -ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render( +ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render( diff --git a/client/src/pages/CategoryPage.tsx b/client/src/pages/CategoryPage.tsx index 972ee7a..fdaa12e 100644 --- a/client/src/pages/CategoryPage.tsx +++ b/client/src/pages/CategoryPage.tsx @@ -1,4 +1,4 @@ -import { categories } from "../placeholder/SearchCategories"; +import { categories } from '../placeholder/SearchCategories'; function ChannelPage() { const category = categories.data[0]; diff --git a/client/src/pages/ChannelPage.tsx b/client/src/pages/ChannelPage.tsx index 0514c78..66e965e 100644 --- a/client/src/pages/ChannelPage.tsx +++ b/client/src/pages/ChannelPage.tsx @@ -1,14 +1,10 @@ -import { - ArrowRightIcon, - HeartIcon, - UserIcon, -} from "@heroicons/react/24/outline"; +import { ArrowRightIcon, HeartIcon, UserIcon } from '@heroicons/react/24/outline'; -import Button from "../components/Button"; -import ChatMessage from "../components/ChatMessage"; -import Input from "../components/Input"; -import { numFormatter } from "../lib/format"; -import streams from "../placeholder/GetStreams"; +import Button from '../components/Button'; +import ChatMessage from '../components/ChatMessage'; +import Input from '../components/Input'; +import { numFormatter } from '../lib/format'; +import streams from '../placeholder/GetStreams'; function ChannelPage() { const stream = streams.data[1]; diff --git a/client/src/pages/LoginPage.tsx b/client/src/pages/LoginPage.tsx index 511bbb8..f4e1fd2 100644 --- a/client/src/pages/LoginPage.tsx +++ b/client/src/pages/LoginPage.tsx @@ -1,6 +1,6 @@ -import { FC } from "react"; +import { FC } from 'react'; -import LoginModal from "../components/LoginModal"; +import LoginModal from '../components/LoginModal'; const LoginPage: FC = () => { return ( diff --git a/client/src/pages/SignupPage.tsx b/client/src/pages/SignupPage.tsx index eb0de4a..1bf259d 100644 --- a/client/src/pages/SignupPage.tsx +++ b/client/src/pages/SignupPage.tsx @@ -1,6 +1,6 @@ -import { FC } from "react"; +import { FC } from 'react'; -import LoginModal from "../components/LoginModal"; +import LoginModal from '../components/LoginModal'; const SignupPage: FC = () => { return ( diff --git a/client/src/placeholder/GetStreams.ts b/client/src/placeholder/GetStreams.ts index 97e3f24..c36ab97 100644 --- a/client/src/placeholder/GetStreams.ts +++ b/client/src/placeholder/GetStreams.ts @@ -1,45 +1,43 @@ -import { FollowedStreams } from "../types"; +import { FollowedStreams } from '../types'; const streams: FollowedStreams = { data: [ { - id: "41375541868", - user_id: "459331509", - user_login: "auronplay", - user_name: "auronplay", - game_id: "494131", - game_name: "Little Nightmares", - type: "live", - title: "hablamos y le damos a Little Nightmares 1", + id: '41375541868', + user_id: '459331509', + user_login: 'auronplay', + user_name: 'auronplay', + game_id: '494131', + game_name: 'Little Nightmares', + type: 'live', + title: 'hablamos y le damos a Little Nightmares 1', viewer_count: 78365, - started_at: "2021-03-10T15:04:21Z", - language: "es", - thumbnail_url: - "https://static-cdn.jtvnw.net/previews-ttv/live_user_auronplay-250x250.jpg", + started_at: '2021-03-10T15:04:21Z', + language: 'es', + thumbnail_url: 'https://static-cdn.jtvnw.net/previews-ttv/live_user_auronplay-250x250.jpg', tag_ids: [], is_mature: false, }, { - id: "41375541869", - user_id: "459331510", - user_login: "xqcow", - user_name: "xqcow", - game_id: "494131", - game_name: "Just Chatting", - type: "live", - title: "slam", + id: '41375541869', + user_id: '459331510', + user_login: 'xqcow', + user_name: 'xqcow', + game_id: '494131', + game_name: 'Just Chatting', + type: 'live', + title: 'slam', viewer_count: 56230, - started_at: "2022-09-29T14:04:21Z", - language: "en", - thumbnail_url: - "https://static-cdn.jtvnw.net/previews-ttv/live_user_xqcow-250x250.jpg", + started_at: '2022-09-29T14:04:21Z', + language: 'en', + thumbnail_url: 'https://static-cdn.jtvnw.net/previews-ttv/live_user_xqcow-250x250.jpg', tag_ids: [], is_mature: false, }, ], pagination: { cursor: - "eyJiIjp7IkN1cnNvciI6ImV5SnpJam8zT0RNMk5TNDBORFF4TlRjMU1UY3hOU3dpWkNJNlptRnNjMlVzSW5RaU9uUnlkV1Y5In0sImEiOnsiQ3Vyc29yIjoiZXlKeklqb3hOVGs0TkM0MU56RXhNekExTVRZNU1ESXNJbVFpT21aaGJITmxMQ0owSWpwMGNuVmxmUT09In19", + 'eyJiIjp7IkN1cnNvciI6ImV5SnpJam8zT0RNMk5TNDBORFF4TlRjMU1UY3hOU3dpWkNJNlptRnNjMlVzSW5RaU9uUnlkV1Y5In0sImEiOnsiQ3Vyc29yIjoiZXlKeklqb3hOVGs0TkM0MU56RXhNekExTVRZNU1ESXNJbVFpT21aaGJITmxMQ0owSWpwMGNuVmxmUT09In19', }, }; diff --git a/client/src/placeholder/GetUserFollows.ts b/client/src/placeholder/GetUserFollows.ts index 8d62db4..0c1a1e4 100644 --- a/client/src/placeholder/GetUserFollows.ts +++ b/client/src/placeholder/GetUserFollows.ts @@ -1,28 +1,28 @@ -import { UserFollows } from "../types"; +import { UserFollows } from '../types'; export const following: UserFollows = { total: 4, data: [ { - from_id: "171003792", - from_login: "niku", - from_name: "niku", - to_id: "23161357", - to_name: "LIRIK", - to_login: "lirik", - followed_at: "2017-08-22T22:55:24Z", + from_id: '171003792', + from_login: 'niku', + from_name: 'niku', + to_id: '23161357', + to_name: 'LIRIK', + to_login: 'lirik', + followed_at: '2017-08-22T22:55:24Z', }, { - from_id: "171003792", - from_login: "niku", - from_name: "niku", - to_id: "23161358", - to_name: "Cowser", - to_login: "cowser", - followed_at: "2017-08-22T22:55:24Z", + from_id: '171003792', + from_login: 'niku', + from_name: 'niku', + to_id: '23161358', + to_name: 'Cowser', + to_login: 'cowser', + followed_at: '2017-08-22T22:55:24Z', }, ], pagination: { - cursor: "eyJiIjpudWxsLCJhIjoiMTUwMzQ0MTc3NjQyNDQyMjAwMCJ9", + cursor: 'eyJiIjpudWxsLCJhIjoiMTUwMzQ0MTc3NjQyNDQyMjAwMCJ9', }, }; diff --git a/client/src/placeholder/SearchCategories.ts b/client/src/placeholder/SearchCategories.ts index 702ccc6..034c68a 100644 --- a/client/src/placeholder/SearchCategories.ts +++ b/client/src/placeholder/SearchCategories.ts @@ -1,12 +1,12 @@ export const categories = { data: [ { - id: "33214", - name: "Just Chatting", - box_art_url: "https://static-cdn.jtvnw.net/ttv-boxart/509658-144x192.jpg", + id: '33214', + name: 'Just Chatting', + box_art_url: 'https://static-cdn.jtvnw.net/ttv-boxart/509658-144x192.jpg', }, ], pagination: { - cursor: "eyJiIjpudWxsLCJhIjp7IkN", + cursor: 'eyJiIjpudWxsLCJhIjp7IkN', }, }; diff --git a/client/vite.config.ts b/client/vite.config.ts index b1b5f91..627a319 100644 --- a/client/vite.config.ts +++ b/client/vite.config.ts @@ -1,7 +1,7 @@ -import { defineConfig } from 'vite' -import react from '@vitejs/plugin-react' +import { defineConfig } from 'vite'; +import react from '@vitejs/plugin-react'; // https://vitejs.dev/config/ export default defineConfig({ - plugins: [react()] -}) + plugins: [react()], +});