From dfab85da6522be5bd056e592a0c2754872c3971d Mon Sep 17 00:00:00 2001 From: Andres Date: Mon, 11 Jul 2022 12:23:43 +0200 Subject: [PATCH] add prettier and reformat all files --- .prettierrc.js | 7 + package.json | 109 +++++++------- public/index.html | 41 +++-- public/manifest.json | 46 +++--- src/index.css | 8 +- src/index.tsx | 8 +- src/reportWebVitals.ts | 26 ++-- src/s1-main/App.module.css | 5 +- src/s1-main/App.tsx | 2 +- src/s2-homeworks/hw01/FriendMessage.tsx | 26 +++- src/s2-homeworks/hw01/HW1.tsx | 10 +- src/s2-homeworks/hw01/Message.module.css | 7 +- src/s2-homeworks/hw01/Message.tsx | 2 - src/s2-homeworks/hw01/MessageSender.tsx | 33 ++-- src/s2-homeworks/hw02/Affair.tsx | 13 +- src/s2-homeworks/hw02/Affairs.module.css | 1 - src/s2-homeworks/hw02/Affairs.tsx | 59 ++++++-- src/s2-homeworks/hw02/AlternativeAffairs.tsx | 6 +- src/s2-homeworks/hw02/HW2.tsx | 38 ++--- .../hw02/tests/deleteAffair.test.tsx | 14 +- .../hw02/tests/filterAffairs.test.tsx | 14 +- src/s2-homeworks/hw03/Greeting.module.css | 92 ++++++------ src/s2-homeworks/hw03/Greeting.tsx | 33 +++- src/s2-homeworks/hw03/GreetingContainer.tsx | 9 +- src/s2-homeworks/hw03/HW3.tsx | 15 +- src/s2-homeworks/hw04/HW4.tsx | 6 +- src/s2-homeworks/hw04/Stand.module.css | 2 +- src/s2-homeworks/hw04/Stand.tsx | 31 ++-- .../c1-SuperInputText/SuperInputText.tsx | 59 +++++--- .../common/c2-SuperButton/SuperButton.tsx | 26 ++-- .../c3-SuperCheckbox/SuperCheckbox.module.css | 4 +- .../common/c3-SuperCheckbox/SuperCheckbox.tsx | 42 ++++-- src/s2-homeworks/hw05/HW5.tsx | 2 +- src/s2-homeworks/hw05/Pages.tsx | 14 +- src/s2-homeworks/hw05/header/Header.tsx | 18 +-- src/s2-homeworks/hw05/layout/Layout.tsx | 8 +- .../hw05/pages/Error404.module.css | 2 +- src/s2-homeworks/hw05/pages/Junior.tsx | 10 +- src/s2-homeworks/hw05/pages/JuniorPlus.tsx | 10 +- src/s2-homeworks/hw05/pages/PreJunior.tsx | 10 +- .../hw05/sidebar/Sidebar.module.css | 5 +- src/s2-homeworks/hw05/sidebar/Sidebar.tsx | 15 +- src/s2-homeworks/hw06/HW6.tsx | 26 ++-- .../SuperEditableSpan.module.css | 2 +- .../SuperEditableSpan.tsx | 81 +++++----- .../hw06/localStorage/localStorage.ts | 4 +- src/s2-homeworks/hw07/HW7.tsx | 14 +- .../c5-SuperSelect/SuperSelect.module.css | 46 +++--- .../common/c5-SuperSelect/SuperSelect.tsx | 55 ++++--- .../c6-SuperRadio/SuperRadio.module.css | 2 +- .../hw07/common/c6-SuperRadio/SuperRadio.tsx | 96 ++++++------ src/s2-homeworks/hw08/HW8.module.css | 2 +- src/s2-homeworks/hw08/HW8.tsx | 61 +++++--- src/s2-homeworks/hw08/User.tsx | 5 +- src/s2-homeworks/hw08/bll/homeWorkReducer.ts | 23 ++- .../hw08/bll/tests/homeWorkReducer.test.tsx | 31 ++-- src/s2-homeworks/hw09/Clock.tsx | 27 ++-- src/s2-homeworks/hw09/HW9.tsx | 8 +- src/s2-homeworks/hw10/HW10.tsx | 37 +++-- src/s2-homeworks/hw10/bll/loadingReducer.ts | 18 ++- src/s2-homeworks/hw10/bll/store.ts | 6 +- src/s2-homeworks/hw11/HW11.tsx | 114 +++++++------- .../c7-SuperRange/SuperRange.module.css | 2 +- .../hw11/common/c7-SuperRange/SuperRange.tsx | 32 ++-- .../c8-SuperDoubleRange/SuperDoubleRange.tsx | 43 ++++-- src/s2-homeworks/hw12/HW12.module.css | 2 +- src/s2-homeworks/hw12/HW12.tsx | 62 ++++---- src/s2-homeworks/hw12/bll/themeReducer.ts | 10 +- src/s2-homeworks/hw13/HW13.tsx | 142 +++++++++--------- src/setupTests.ts | 2 +- tsconfig.json | 42 +++--- yarn.lock | 5 + 72 files changed, 1065 insertions(+), 823 deletions(-) create mode 100644 .prettierrc.js diff --git a/.prettierrc.js b/.prettierrc.js new file mode 100644 index 0000000..d5f574d --- /dev/null +++ b/.prettierrc.js @@ -0,0 +1,7 @@ +module.exports = { + trailingComma: 'es5', + tabWidth: 4, + semi: false, + singleQuote: true, + endOfLine: 'auto', +} diff --git a/package.json b/package.json index 6db149e..4b9b8ae 100644 --- a/package.json +++ b/package.json @@ -1,56 +1,57 @@ { - "name": "home-works", - "homepage": "https://IgnatZakalinsky.github.io/home-works", - "version": "0.1.0", - "private": true, - "dependencies": { - "@emotion/react": "^11.9.3", - "@emotion/styled": "^11.9.3", - "@mui/material": "^5.8.4", - "@testing-library/jest-dom": "^5.14.1", - "@testing-library/react": "^13.0.0", - "@testing-library/user-event": "^13.2.1", - "@types/jest": "^27.0.1", - "@types/node": "^16.7.13", - "@types/react": "^18.0.0", - "@types/react-dom": "^18.0.0", - "@types/uuid": "^8.3.4", - "axios": "^0.27.2", - "gh-pages": "^4.0.0", - "react": "^18.1.0", - "react-dom": "^18.1.0", - "react-redux": "^8.0.2", - "react-router-dom": "^6.3.0", - "react-scripts": "5.0.1", - "redux": "^4.2.0", - "typescript": "^4.4.2", - "uuid": "^8.3.2", - "web-vitals": "^2.1.0" - }, - "scripts": { - "start": "react-scripts start", - "build": "react-scripts build", - "test": "react-scripts test", - "eject": "react-scripts eject", - "predeploy": "npm run build", - "deploy": "gh-pages -d build" - }, - "eslintConfig": { - "extends": [ - "react-app", - "react-app/jest" - ] - }, - "browserslist": { - "production": [ - ">0.2%", - "not dead", - "not op_mini all" - ], - "development": [ - "last 1 chrome version", - "last 1 firefox version", - "last 1 safari version" - ] - } + "name": "home-works", + "homepage": "https://IgnatZakalinsky.github.io/home-works", + "version": "0.1.0", + "private": true, + "dependencies": { + "@emotion/react": "^11.9.3", + "@emotion/styled": "^11.9.3", + "@mui/material": "^5.8.4", + "@testing-library/jest-dom": "^5.14.1", + "@testing-library/react": "^13.0.0", + "@testing-library/user-event": "^13.2.1", + "@types/jest": "^27.0.1", + "@types/node": "^16.7.13", + "@types/react": "^18.0.0", + "@types/react-dom": "^18.0.0", + "@types/uuid": "^8.3.4", + "axios": "^0.27.2", + "gh-pages": "^4.0.0", + "prettier": "^2.7.1", + "react": "^18.1.0", + "react-dom": "^18.1.0", + "react-redux": "^8.0.2", + "react-router-dom": "^6.3.0", + "react-scripts": "5.0.1", + "redux": "^4.2.0", + "typescript": "^4.4.2", + "uuid": "^8.3.2", + "web-vitals": "^2.1.0" + }, + "scripts": { + "start": "react-scripts start", + "build": "react-scripts build", + "test": "react-scripts test", + "eject": "react-scripts eject", + "predeploy": "npm run build", + "deploy": "gh-pages -d build" + }, + "eslintConfig": { + "extends": [ + "react-app", + "react-app/jest" + ] + }, + "browserslist": { + "production": [ + ">0.2%", + "not dead", + "not op_mini all" + ], + "development": [ + "last 1 chrome version", + "last 1 firefox version", + "last 1 safari version" + ] + } } diff --git a/public/index.html b/public/index.html index bc15ee7..3bedd49 100644 --- a/public/index.html +++ b/public/index.html @@ -1,21 +1,21 @@ - - - - - - - - - - - React App - - - -
- - + --> diff --git a/public/manifest.json b/public/manifest.json index 080d6c7..f01493f 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -1,25 +1,25 @@ { - "short_name": "React App", - "name": "Create React App Sample", - "icons": [ - { - "src": "favicon.ico", - "sizes": "64x64 32x32 24x24 16x16", - "type": "image/x-icon" - }, - { - "src": "logo192.png", - "type": "image/png", - "sizes": "192x192" - }, - { - "src": "logo512.png", - "type": "image/png", - "sizes": "512x512" - } - ], - "start_url": ".", - "display": "standalone", - "theme_color": "#000000", - "background_color": "#ffffff" + "short_name": "React App", + "name": "Create React App Sample", + "icons": [ + { + "src": "favicon.ico", + "sizes": "64x64 32x32 24x24 16x16", + "type": "image/x-icon" + }, + { + "src": "logo192.png", + "type": "image/png", + "sizes": "192x192" + }, + { + "src": "logo512.png", + "type": "image/png", + "sizes": "512x512" + } + ], + "start_url": ".", + "display": "standalone", + "theme_color": "#000000", + "background_color": "#ffffff" } diff --git a/src/index.css b/src/index.css index fe5e20d..14abadb 100644 --- a/src/index.css +++ b/src/index.css @@ -7,17 +7,16 @@ body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', - 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', - 'Helvetica Neue', sans-serif; + 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', + 'Helvetica Neue', sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; box-sizing: border-box; - } code { font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', - monospace; + monospace; } [data-theme='1'] { @@ -68,7 +67,6 @@ code { --success: #16a34a; --warning: #d97706; --error: #dc2626; - } html { diff --git a/src/index.tsx b/src/index.tsx index 610ca37..1f2ac6e 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -3,16 +3,14 @@ import ReactDOM from 'react-dom/client' import './index.css' import App from './s1-main/App' import reportWebVitals from './reportWebVitals' -import {Provider} from 'react-redux' +import { Provider } from 'react-redux' import store from './s2-homeworks/hw10/bll/store' -const root = ReactDOM.createRoot( - document.getElementById('root') as HTMLElement -) +const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement) root.render( - + ) diff --git a/src/reportWebVitals.ts b/src/reportWebVitals.ts index 49a2a16..3984df9 100644 --- a/src/reportWebVitals.ts +++ b/src/reportWebVitals.ts @@ -1,15 +1,17 @@ -import { ReportHandler } from 'web-vitals'; +import { ReportHandler } from 'web-vitals' const reportWebVitals = (onPerfEntry?: ReportHandler) => { - if (onPerfEntry && onPerfEntry instanceof Function) { - import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { - getCLS(onPerfEntry); - getFID(onPerfEntry); - getFCP(onPerfEntry); - getLCP(onPerfEntry); - getTTFB(onPerfEntry); - }); - } -}; + if (onPerfEntry && onPerfEntry instanceof Function) { + import('web-vitals').then( + ({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { + getCLS(onPerfEntry) + getFID(onPerfEntry) + getFCP(onPerfEntry) + getLCP(onPerfEntry) + getTTFB(onPerfEntry) + } + ) + } +} -export default reportWebVitals; +export default reportWebVitals diff --git a/src/s1-main/App.module.css b/src/s1-main/App.module.css index a672827..d64c0de 100644 --- a/src/s1-main/App.module.css +++ b/src/s1-main/App.module.css @@ -3,7 +3,6 @@ } .hw { - } .hwTitle { @@ -25,5 +24,5 @@ hr { border-top: 1px solid #d9d9d9; - margin: 0 -} \ No newline at end of file + margin: 0; +} diff --git a/src/s1-main/App.tsx b/src/s1-main/App.tsx index 5d2671c..83cfec7 100644 --- a/src/s1-main/App.tsx +++ b/src/s1-main/App.tsx @@ -25,7 +25,7 @@ const App = () => { {/**/} {/**/} - + ) } diff --git a/src/s2-homeworks/hw01/FriendMessage.tsx b/src/s2-homeworks/hw01/FriendMessage.tsx index c301cb1..9ae30b3 100644 --- a/src/s2-homeworks/hw01/FriendMessage.tsx +++ b/src/s2-homeworks/hw01/FriendMessage.tsx @@ -4,38 +4,48 @@ import s from './Message.module.css' // создать тип вместо any и отобразить приходящие данные const FriendMessage = (props: any) => { return ( -
+
{'avatar'}
-
+
{/*создаёт студент*/} {props.message.user.name} {/**/}
-
+
{/*создаёт студент*/} {props.message.message.text} {/**/}
-
-
+
{/*создаёт студент*/} {props.message.message.time} {/**/}
- ) } diff --git a/src/s2-homeworks/hw01/HW1.tsx b/src/s2-homeworks/hw01/HW1.tsx index 24b2f27..0e073e0 100644 --- a/src/s2-homeworks/hw01/HW1.tsx +++ b/src/s2-homeworks/hw01/HW1.tsx @@ -32,7 +32,6 @@ export const friendMessage0: MessageType = { }, } - const HW1 = () => { return (
@@ -40,21 +39,20 @@ const HW1 = () => { {/*можно убрать этот тег*/}
Homework #1
-
+
{/*проверка отображения (не менять)*/}
- + {/*не обязательно*/} - +
{/*для автоматической проверки дз (не менять)*/} - +
- {/*
*/} {/*можно убрать этот тег*/}
diff --git a/src/s2-homeworks/hw01/Message.module.css b/src/s2-homeworks/hw01/Message.module.css index b299352..7accfea 100644 --- a/src/s2-homeworks/hw01/Message.module.css +++ b/src/s2-homeworks/hw01/Message.module.css @@ -63,7 +63,8 @@ max-width: 70%; height: 100%; background-color: #06c; - box-shadow: 0 5px 20px rgba(29, 33, 38, 0.03), 0 1px 2px rgba(29, 33, 38, 0.1); + box-shadow: 0 5px 20px rgba(29, 33, 38, 0.03), + 0 1px 2px rgba(29, 33, 38, 0.1); display: flex; flex-direction: column; margin-right: 20px; @@ -119,7 +120,8 @@ .textarea { box-sizing: border-box; background: #f5f7fb; - box-shadow: 0 5px 20px rgba(29, 33, 38, 0.03), 0 1px 2px rgba(29, 33, 38, 0.1); + box-shadow: 0 5px 20px rgba(29, 33, 38, 0.03), + 0 1px 2px rgba(29, 33, 38, 0.1); border-radius: 20px; width: 100%; border: none; @@ -173,4 +175,3 @@ img { width: 48px; text-align: center; } - diff --git a/src/s2-homeworks/hw01/Message.tsx b/src/s2-homeworks/hw01/Message.tsx index aa46568..c9e019d 100644 --- a/src/s2-homeworks/hw01/Message.tsx +++ b/src/s2-homeworks/hw01/Message.tsx @@ -11,7 +11,6 @@ const Message = (props: MessagePropsType) => {
{'avatar'} { {/**/}
- ) } diff --git a/src/s2-homeworks/hw01/MessageSender.tsx b/src/s2-homeworks/hw01/MessageSender.tsx index 26df1ff..5d6c2b6 100644 --- a/src/s2-homeworks/hw01/MessageSender.tsx +++ b/src/s2-homeworks/hw01/MessageSender.tsx @@ -9,33 +9,44 @@ const MessageSender = (props: any) => { const [text, setText] = useState('') const addMessage = () => { - setMessages([...messages, { - id: messages.length ? messages.length + 1 : 1, - user: message0.user, - message: { - text, - time: new Date().toTimeString().slice(0, 5), + setMessages([ + ...messages, + { + id: messages.length ? messages.length + 1 : 1, + user: message0.user, + message: { + text, + time: new Date().toTimeString().slice(0, 5), + }, }, - }]) + ]) setTimeout(() => setText(''), 4) } return ( <> - {messages.map(m => )} + {messages.map((m) => ( + + ))}