Skip to content

Commit 2a54ecd

Browse files
authored
Fix frontend codestyle (#67)
Signed-off-by: vityaman <vityaman.dev@yandex.ru>
1 parent ff0d522 commit 2a54ecd

File tree

92 files changed

+2099
-1732
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+2099
-1732
lines changed

.github/workflows/gradle.yml

+4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@ on:
55
branches:
66
- main
77
- lab-[1234]
8+
paths-ignore:
9+
- frontend
810
pull_request:
911
branches:
1012
- main
1113
- lab-[1234]
14+
paths-ignore:
15+
- frontend
1216

1317
jobs:
1418
build:

.github/workflows/nodejs.yml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: NodeJS
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- lab-[1234]
8+
paths-ignore:
9+
- backend
10+
pull_request:
11+
branches:
12+
- main
13+
- lab-[1234]
14+
paths-ignore:
15+
- backend
16+
17+
jobs:
18+
build:
19+
defaults:
20+
run:
21+
working-directory: ./frontend
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- uses: actions/setup-node@v3
27+
with:
28+
node-version: latest
29+
30+
- name: Create Fake Certificates
31+
run: |
32+
mkdir -p .cert
33+
touch .cert/privkey.pem
34+
touch .cert/cert.pem
35+
touch .cert/chain.pem
36+
37+
- name: Install Dependencies
38+
run: npm install
39+
40+
- name: Build
41+
run: npm run build
42+
43+
- name: Lint
44+
run: npm run lint
45+
46+
- name: Check Formatting
47+
run: npm run format

frontend/.eslintrc.cjs

+11-16
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,31 @@
11
module.exports = {
22
env: {
33
browser: true,
4-
es2021: true
4+
es2021: true,
55
},
66
extends: [
77
'eslint:recommended',
88
'plugin:@typescript-eslint/recommended',
9-
'plugin:react/recommended'
9+
'plugin:react/recommended',
1010
],
1111
overrides: [
1212
{
1313
env: {
14-
node: true
14+
node: true,
1515
},
16-
files: [
17-
'.eslintrc.{js,cjs}'
18-
],
16+
files: ['.eslintrc.{js,cjs}'],
1917
parserOptions: {
20-
'sourceType': 'script'
21-
}
22-
}
18+
sourceType: 'script',
19+
},
20+
},
2321
],
2422
parser: '@typescript-eslint/parser',
2523
parserOptions: {
2624
ecmaVersion: 'latest',
27-
sourceType: 'module'
25+
sourceType: 'module',
2826
},
29-
plugins: [
30-
'@typescript-eslint',
31-
'react'
32-
],
27+
plugins: ['@typescript-eslint', 'react'],
3328
rules: {
3429
'react/react-in-jsx-scope': 0,
35-
}
36-
};
30+
},
31+
}

frontend/.prettierrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all",
4+
"semi": false
5+
}

frontend/index.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<!doctype html>
22
<html lang="en">
33
<head>
4-
<meta charset="utf-8"/>
5-
<meta name="viewport" content="width=device-width, initial-scale=1"/>
6-
<meta name="theme-color" content="#000000"/>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1" />
6+
<meta name="theme-color" content="#000000" />
77
<title>ITMO Dating</title>
88
</head>
99
<body>

frontend/package.json

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
"build": "tsc --noEmit && vite build",
4343
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
4444
"lint:fix": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0 --fix",
45+
"format": "npx prettier --check .",
46+
"format:fix": "npx prettier --write --check . ",
4547
"preview": "vite preview",
4648
"predeploy": "npm run build"
4749
},

frontend/src/app/index.tsx

+24-27
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,30 @@
1-
import {useEffect} from "react";
2-
import {router} from "./routes/api";
3-
import {RouterProvider} from "atomic-router-react";
1+
import { useEffect } from 'react'
2+
import { router } from './routes/api'
3+
import { RouterProvider } from 'atomic-router-react'
44

5-
import {$errorStore} from "@/shared/api";
6-
import {message} from "antd";
7-
import {Routes} from "@/app/routes/ui";
8-
9-
import {init, mockTgEnv} from './telegram-sdk';
10-
import {retrieveLaunchParams} from '@telegram-apps/sdk';
5+
import { $errorStore } from '@/shared/api'
6+
import { message } from 'antd'
7+
import { Routes } from '@/app/routes/ui'
118

9+
import { init, mockTgEnv } from './telegram-sdk'
10+
import { retrieveLaunchParams } from '@telegram-apps/sdk'
1211

1312
export const App = () => {
14-
mockTgEnv()
15-
.then(() => {
16-
init(retrieveLaunchParams().startParam === 'debug' || import.meta.env.DEV);
17-
})
13+
mockTgEnv().then(() => {
14+
init(retrieveLaunchParams().startParam === 'debug' || import.meta.env.DEV)
15+
})
1816

19-
const [messageApi, contextHolder] = message.useMessage();
20-
useEffect(() => {
21-
$errorStore.watch(state => {
22-
if (state)
23-
messageApi.error(state?.message)
24-
})
25-
}, [])
17+
const [messageApi, contextHolder] = message.useMessage()
18+
useEffect(() => {
19+
$errorStore.watch((state) => {
20+
if (state) messageApi.error(state?.message)
21+
})
22+
}, [])
2623

27-
return (
28-
<RouterProvider router={router}>
29-
{contextHolder}
30-
<Routes/>
31-
</RouterProvider>
32-
);
33-
};
24+
return (
25+
<RouterProvider router={router}>
26+
{contextHolder}
27+
<Routes />
28+
</RouterProvider>
29+
)
30+
}

frontend/src/app/routes/api/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export {routes, routesMap, router} from "./routing.ts"
1+
export { routes, routesMap, router } from './routing.ts'
+14-14
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
import { createHistoryRouter, createRoute } from "atomic-router";
2-
import { createBrowserHistory } from "history";
1+
import { createHistoryRouter, createRoute } from 'atomic-router'
2+
import { createBrowserHistory } from 'history'
33

4-
const basePath = "/itmo-dating-mini-app"
4+
const basePath = '/itmo-dating-mini-app'
55
export const routes = {
6-
home: createRoute(),
7-
registration: createRoute(),
8-
main: createRoute()
9-
};
6+
home: createRoute(),
7+
registration: createRoute(),
8+
main: createRoute(),
9+
}
1010

1111
export const routesMap = [
12-
{ path: "", route: routes.home },
13-
{ path: "/registration", route: routes.registration},
14-
{ path: "/main", route: routes.main},
15-
];
12+
{ path: '', route: routes.home },
13+
{ path: '/registration', route: routes.registration },
14+
{ path: '/main', route: routes.main },
15+
]
1616

17-
const history = createBrowserHistory();
17+
const history = createBrowserHistory()
1818

19-
export const router = createHistoryRouter({ base: basePath, routes: routesMap });
19+
export const router = createHistoryRouter({ base: basePath, routes: routesMap })
2020

21-
router.setHistory(history);
21+
router.setHistory(history)

frontend/src/app/routes/ui/index.tsx

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import {Route} from "atomic-router-react";
2-
import {routes} from "../api";
3-
import {Registration, Home, Main} from "@/pages";
1+
import { Route } from 'atomic-router-react'
2+
import { routes } from '../api'
3+
import { Registration, Home, Main } from '@/pages'
44

55
export const Routes = () => (
6-
<>
7-
<Route route={routes.home} view={Home}/>
8-
<Route route={routes.registration} view={Registration}/>
9-
<Route route={routes.main} view={Main}/>
10-
</>
11-
);
6+
<>
7+
<Route route={routes.home} view={Home} />
8+
<Route route={routes.registration} view={Registration} />
9+
<Route route={routes.main} view={Main} />
10+
</>
11+
)
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export {init} from "./init.ts"
1+
export { init } from './init.ts'
22

3-
export {mockTgEnv} from "./mockEnv.ts"
3+
export { mockTgEnv } from './mockEnv.ts'
+40-41
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,52 @@
11
import {
2-
backButton,
3-
viewport,
4-
themeParams,
5-
miniApp,
6-
initData,
7-
$debug,
8-
init as initSDK,
9-
} from '@telegram-apps/sdk';
10-
import {mountMainButton} from "@/entities/main-button";
11-
import {mountBackButton} from "@/entities/back-button";
2+
backButton,
3+
viewport,
4+
themeParams,
5+
miniApp,
6+
initData,
7+
$debug,
8+
init as initSDK,
9+
} from '@telegram-apps/sdk'
10+
import { mountMainButton } from '@/entities/main-button'
11+
import { mountBackButton } from '@/entities/back-button'
1212

1313
/**
1414
* Initializes the application and configures its dependencies.
1515
*/
1616
export function init(debug: boolean): void {
17-
// Set @telegram-apps/sdk-react debug mode.
18-
$debug.set(debug);
17+
// Set @telegram-apps/sdk-react debug mode.
18+
$debug.set(debug)
1919

20-
// Initialize special event handlers for Telegram Desktop, Android, iOS, etc.
21-
// Also, configure the package.
22-
initSDK();
20+
// Initialize special event handlers for Telegram Desktop, Android, iOS, etc.
21+
// Also, configure the package.
22+
initSDK()
2323

24-
// Add Eruda if needed.
25-
debug && import('eruda')
26-
.then((lib) => lib.default.init())
27-
.catch(console.error);
24+
// Add Eruda if needed.
25+
debug &&
26+
import('eruda').then((lib) => lib.default.init()).catch(console.error)
2827

29-
// Check if all required components are supported.
30-
if (!backButton.isSupported() || !miniApp.isSupported()) {
31-
throw new Error('ERR_NOT_SUPPORTED');
32-
}
28+
// Check if all required components are supported.
29+
if (!backButton.isSupported() || !miniApp.isSupported()) {
30+
throw new Error('ERR_NOT_SUPPORTED')
31+
}
3332

34-
// Mount all components used in the project.
35-
mountMainButton()
36-
mountBackButton()
33+
// Mount all components used in the project.
34+
mountMainButton()
35+
mountBackButton()
3736

38-
miniApp.mount();
39-
themeParams.mount();
40-
initData.restore();
41-
void viewport
42-
.mount()
43-
.catch(e => {
44-
console.error('Something went wrong mounting the viewport', e);
45-
})
46-
.then(() => {
47-
viewport.bindCssVars();
48-
});
37+
miniApp.mount()
38+
themeParams.mount()
39+
initData.restore()
40+
void viewport
41+
.mount()
42+
.catch((e) => {
43+
console.error('Something went wrong mounting the viewport', e)
44+
})
45+
.then(() => {
46+
viewport.bindCssVars()
47+
})
4948

50-
// Define components-related CSS variables.
51-
miniApp.bindCssVars();
52-
themeParams.bindCssVars();
53-
}
49+
// Define components-related CSS variables.
50+
miniApp.bindCssVars()
51+
themeParams.bindCssVars()
52+
}

0 commit comments

Comments
 (0)