Skip to content

Commit

Permalink
(improvement) Prettier code formatting (#69)
Browse files Browse the repository at this point in the history
* set up prettier code formatting

* formatted code

* lint/prettier fix
  • Loading branch information
Blaumaus authored Dec 25, 2023
1 parent cea2158 commit 63c829e
Show file tree
Hide file tree
Showing 97 changed files with 1,824 additions and 1,371 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ jobs:

- name: Lint validation
run: npm run lint

- name: Code formatting validation
run: npm run format
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
build
dist
13 changes: 13 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
printWidth: 120, // max 120 chars in line, code is easy to read
useTabs: false, // use spaces instead of tabs
tabWidth: 2, // "visual width" of of the "tab"
trailingComma: 'all', // add trailing commas in objects, arrays, etc.
semi: false, // Only add semicolons at the beginning of lines that may introduce ASI failures
singleQuote: true, // '' for stings instead of ""
bracketSpacing: true, // import { some } ... instead of import {some} ...
arrowParens: 'always', // braces even for single param in arrow functions (a) => { }
jsxSingleQuote: true, // '' for react props
bracketSameLine: false, // pretty JSX
endOfLine: 'lf', // 'lf' for linux, 'crlf' for windows, we need to use 'lf' for git
}
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@
"test": "react-scripts test",
"eject": "react-scripts eject",
"analyse": "source-map-explorer 'build/static/js/*.js'",
"lint": "eslint src"
"lint": "eslint src",
"format": "prettier --check --ignore-unknown ./src",
"format:fix": "prettier --write --ignore-unknown ./src"
},
"browserslist": {
"production": [
Expand All @@ -65,8 +67,7 @@
"extends": [
"react-app",
"react-app/jest",
"eslint:recommended",
"plugin:react/recommended"
"eslint:recommended"
],
"plugins": [
"lodash",
Expand Down Expand Up @@ -147,6 +148,7 @@
"eslint-plugin-lodash": "^7.4.0",
"eslint-plugin-react": "^7.32.1",
"eslint-plugin-react-hooks": "^4.6.0",
"prettier": "^3.1.1",
"source-map-explorer": "^2.5.3",
"tailwindcss": "^3.2.4"
}
Expand Down
132 changes: 131 additions & 1 deletion public/index.css
Original file line number Diff line number Diff line change
@@ -1 +1,131 @@
body{height:100%;margin:0;padding:0;width:100%;-webkit-font-smoothing:antialiased}.loader.available{opacity:0}.loader{background-color:#f9fafb;width:100%;height:100%;position:fixed;opacity:1;pointer-events:none;-webkit-transition:opacity cubic-bezier(.4,0,.2,1) 436ms;-moz-transition:opacity cubic-bezier(.4,0,.2,1) 436ms;transition:opacity cubic-bezier(.4,0,.2,1) 436ms;z-index:9999}.logo-frame{display:-webkit-flex;display:-moz-flex;display:flex;-webkit-flex-direction:column;-moz-flex-direction:column;flex-direction:column;-webkit-justify-content:center;-moz-justify-content:center;justify-content:center;-webkit-animation:fadein 436ms;-moz-animation:fadein 436ms;animation:fadein 436ms;height:98%}.logo-frame-img{font-size:30px;padding-left:10px;padding-right:10px;-webkit-align-self:center;-moz-align-self:center;align-self:center}.loader-head{background-color:#c6dafc;height:4px;overflow:hidden;position:relative}.loader .first,.loader .second{background-color:#4f46e5;bottom:0;left:0;right:0;top:0;position:absolute;-webkit-transform-origin:left center;-moz-transform-origin:left center;transform-origin:left center;-webkit-transform:scaleX(0);-moz-transform:scaleX(0);transform:scaleX(0)}.loader .first{-webkit-animation:first 2s linear infinite;-moz-animation:first 2s linear infinite;animation:first 2s linear infinite}.loader .second{-webkit-animation:second 2s linear infinite;-moz-animation:second 2s linear infinite;animation:second 2s linear infinite}@-webkit-keyframes fadein{from{opacity:0}to{opacity:1}}@-moz-keyframes fadein{from{opacity:0}to{opacity:1}}@keyframes fadein{from{opacity:0}to{opacity:1}}@keyframes first{0%{transform:translate(0) scaleX(0)}25%{transform:translate(0) scaleX(.5)}50%{transform:translate(25%) scaleX(.75)}75%{transform:translate(100%) scaleX(0)}100%{transform:translate(100%) scaleX(0)}}@keyframes second{0%{transform:translate(0) scaleX(0)}60%{transform:translate(0) scaleX(0)}80%{transform:translate(0) scaleX(.6)}100%{transform:translate(100%) scaleX(.1)}}
body {
height: 100%;
margin: 0;
padding: 0;
width: 100%;
-webkit-font-smoothing: antialiased;
}
.loader.available {
opacity: 0;
}
.loader {
background-color: #f9fafb;
width: 100%;
height: 100%;
position: fixed;
opacity: 1;
pointer-events: none;
-webkit-transition: opacity cubic-bezier(0.4, 0, 0.2, 1) 436ms;
-moz-transition: opacity cubic-bezier(0.4, 0, 0.2, 1) 436ms;
transition: opacity cubic-bezier(0.4, 0, 0.2, 1) 436ms;
z-index: 9999;
}
.logo-frame {
display: -webkit-flex;
display: -moz-flex;
display: flex;
-webkit-flex-direction: column;
-moz-flex-direction: column;
flex-direction: column;
-webkit-justify-content: center;
-moz-justify-content: center;
justify-content: center;
-webkit-animation: fadein 436ms;
-moz-animation: fadein 436ms;
animation: fadein 436ms;
height: 98%;
}
.logo-frame-img {
font-size: 30px;
padding-left: 10px;
padding-right: 10px;
-webkit-align-self: center;
-moz-align-self: center;
align-self: center;
}
.loader-head {
background-color: #c6dafc;
height: 4px;
overflow: hidden;
position: relative;
}
.loader .first,
.loader .second {
background-color: #4f46e5;
bottom: 0;
left: 0;
right: 0;
top: 0;
position: absolute;
-webkit-transform-origin: left center;
-moz-transform-origin: left center;
transform-origin: left center;
-webkit-transform: scaleX(0);
-moz-transform: scaleX(0);
transform: scaleX(0);
}
.loader .first {
-webkit-animation: first 2s linear infinite;
-moz-animation: first 2s linear infinite;
animation: first 2s linear infinite;
}
.loader .second {
-webkit-animation: second 2s linear infinite;
-moz-animation: second 2s linear infinite;
animation: second 2s linear infinite;
}
@-webkit-keyframes fadein {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@-moz-keyframes fadein {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes fadein {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes first {
0% {
transform: translate(0) scaleX(0);
}
25% {
transform: translate(0) scaleX(0.5);
}
50% {
transform: translate(25%) scaleX(0.75);
}
75% {
transform: translate(100%) scaleX(0);
}
100% {
transform: translate(100%) scaleX(0);
}
}
@keyframes second {
0% {
transform: translate(0) scaleX(0);
}
60% {
transform: translate(0) scaleX(0);
}
80% {
transform: translate(0) scaleX(0.6);
}
100% {
transform: translate(100%) scaleX(0.1);
}
}
78 changes: 38 additions & 40 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,47 +1,45 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">

<head>
<meta charset="utf-8" />
<title>Swetrix Marketplace</title>
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#818cf8" />
<!-- <meta name="description" content="Ultimate open-source analytics to satisfy all your needs" /> -->
<!-- <meta name="twitter:title" content="Swetrix | Ultimate open-source analytics to satisfy all your needs" /> -->
<!-- <meta name="twitter:description"
<head>
<meta charset="utf-8" />
<title>Swetrix Marketplace</title>
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#818cf8" />
<!-- <meta name="description" content="Ultimate open-source analytics to satisfy all your needs" /> -->
<!-- <meta name="twitter:title" content="Swetrix | Ultimate open-source analytics to satisfy all your needs" /> -->
<!-- <meta name="twitter:description"
content="Swetrix is a cookie-less privacy-first web analytics service which provides a huge variety of services" /> -->
<meta name="twitter:card" content="summary_large_image" />
<meta property="og:title" content="Swetrix Marketplace" />
<!-- <meta property="og:description" content="Ultimate open-source analytics to satisfy all your needs" /> -->
<meta property="og:image" content="https://swetrix.com/assets/og_image.png" />
<meta property="og:site_name" content="Swetrix Marketplace" />
<meta property="og:url" content="https://swetrix.com">
<meta property="og:type" content="website">
<meta name="google" content="notranslate" />
<meta name="apple-mobile-web-app-title" content="Swetrix Marketplace">
<meta name="application-name" content="Swetrix Marketplace">
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<meta name="twitter:card" content="summary_large_image" />
<meta property="og:title" content="Swetrix Marketplace" />
<!-- <meta property="og:description" content="Ultimate open-source analytics to satisfy all your needs" /> -->
<meta property="og:image" content="https://swetrix.com/assets/og_image.png" />
<meta property="og:site_name" content="Swetrix Marketplace" />
<meta property="og:url" content="https://swetrix.com" />
<meta property="og:type" content="website" />
<meta name="google" content="notranslate" />
<meta name="apple-mobile-web-app-title" content="Swetrix Marketplace" />
<meta name="application-name" content="Swetrix Marketplace" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />

<link rel="preconnect" href="https://fonts.bunny.net">
<link href="https://fonts.bunny.net/css?family=inter:300,400,500,600,700,800" rel="stylesheet" />
<link rel="preconnect" href="https://fonts.bunny.net" />
<link href="https://fonts.bunny.net/css?family=inter:300,400,500,600,700,800" rel="stylesheet" />

<link href="/index.css" rel="stylesheet" />
</head>
<link href="/index.css" rel="stylesheet" />
</head>

<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div class="loader" id="loader">
<div class="loader-head">
<div class="first"></div>
<div class="second"></div>
</div>
<div class="logo-frame">
<img class="logo-frame-img" src="/assets/logo_blue.png" alt="" />
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div class="loader" id="loader">
<div class="loader-head">
<div class="first"></div>
<div class="second"></div>
</div>
<div class="logo-frame">
<img class="logo-frame-img" src="/assets/logo_blue.png" alt="" />
</div>
</div>
</div>
<div id="root"></div>
</body>

<div id="root"></div>
</body>
</html>
4 changes: 2 additions & 2 deletions public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"accountSettings": "Account settings",
"submit": "Submit"
},
"header": {
"header": {
"switchTheme": "Switch theme",
"dark": "Dark",
"light": "Light",
Expand Down Expand Up @@ -201,7 +201,7 @@
"changelog": "Changelog",
"cookie": "Cookie Policy",
"captcha": "CAPTCHA",
"press":"Media & Press",
"press": "Media & Press",
"open": "Open startup"
}
}
2 changes: 1 addition & 1 deletion public/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"sizes": "512x512"
}
],
"screenshots" : [
"screenshots": [
{
"src": "assets/swe1.png",
"sizes": "1866x764",
Expand Down
51 changes: 13 additions & 38 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import React, {
useEffect, lazy, Suspense, useState,
} from 'react'
import React, { useEffect, lazy, Suspense, useState } from 'react'
import { Switch, Route, useLocation } from 'react-router-dom'
import routes from 'routes'
import { useDispatch, useSelector } from 'react-redux'
Expand Down Expand Up @@ -30,9 +28,7 @@ const ExtensionPage = lazy(() => import('pages/Extension/View/ExtensionPage'))
const UserSettings = lazy(() => import('pages/UserSettings'))
const Checklist = lazy(() => import('pages/Checklist'))
const InstalledExtensionSettings = lazy(() => import('./pages/Extension/Settings/InstalledSettings'))
const minimalFooterPages = [
'/projects', '/dashboard', '/settings', '/contact',
]
const minimalFooterPages = ['/projects', '/dashboard', '/settings', '/contact']

const Fallback = () => {
const [showLoader, setShowLoader] = useState(false)
Expand All @@ -51,23 +47,17 @@ const Fallback = () => {
}
}, [])

return (
<div className='bg-gray-50 dark:bg-slate-900 min-h-page'>
{showLoader && (
<Loader />
)}
</div>
)
return <div className='bg-gray-50 dark:bg-slate-900 min-h-page'>{showLoader && <Loader />}</div>
}

const App = () => {
const dispatch = useDispatch()
const alert = useAlert()
const location = useLocation()
const { loading, authenticated } = useSelector(state => state.auth)
const { theme } = useSelector(state => state.ui.theme)
const { error } = useSelector(state => state.errors)
const { message, type } = useSelector(state => state.alerts)
const { loading, authenticated } = useSelector((state) => state.auth)
const { theme } = useSelector((state) => state.ui.theme)
const { error } = useSelector((state) => state.errors)
const { message, type } = useSelector((state) => state.alerts)
const accessToken = getAccessToken()
const refreshToken = getRefreshToken()

Expand All @@ -82,9 +72,10 @@ const App = () => {
}
}, [])

// prettier-ignore
useEffect(() => {
(async () => {
if ((accessToken && refreshToken) && !authenticated) {
if (accessToken && refreshToken && !authenticated) {
try {
const me = await authMe()
dispatch(authActions.loginSuccess(me))
Expand Down Expand Up @@ -133,26 +124,10 @@ const App = () => {
<Route path={routes.dashboard} component={Dashboard} exact />
<Route path={routes.search} component={Search} exact />
<Route path={routes.checklist} component={Checklist} exact />
<Route
path={routes.new_extension}
component={ProjectSettings}
exact
/>
<Route
path={routes.extension_settings}
component={ProjectSettings}
exact
/>
<Route
path={routes.view_extensions}
component={ExtensionPage}
exact
/>
<Route
path={routes.installed_extension_settings}
component={InstalledExtensionSettings}
exact
/>
<Route path={routes.new_extension} component={ProjectSettings} exact />
<Route path={routes.extension_settings} component={ProjectSettings} exact />
<Route path={routes.view_extensions} component={ExtensionPage} exact />
<Route path={routes.installed_extension_settings} component={InstalledExtensionSettings} exact />
<Route path='*' component={NotFound} />
</Switch>
</Suspense>
Expand Down
Loading

0 comments on commit 63c829e

Please sign in to comment.