Skip to content

Commit

Permalink
Merge branch '437-establish-a-global-prettier-configuration-file-at-t…
Browse files Browse the repository at this point in the history
…he-root-level' into 'dev'

Resolve "Establish a global Prettier configuration file at the root level"

Closes #437

See merge request ergo/rosen-bridge/ui!362
  • Loading branch information
vorujack committed Nov 26, 2024
2 parents ef3678b + 6581a5f commit e9b7361
Show file tree
Hide file tree
Showing 204 changed files with 790 additions and 882 deletions.
2 changes: 2 additions & 0 deletions .changeset/lazy-apricots-sniff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
2 changes: 2 additions & 0 deletions .changeset/selfish-vans-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
2 changes: 1 addition & 1 deletion .github/workflows/docker-dev-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
os: [ ubuntu-latest ]
os: [ubuntu-latest]
apps:
- watcher
- guard
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
os: [ ubuntu-latest ]
os: [ubuntu-latest]

steps:
- name: Checkout the Code
Expand Down
23 changes: 23 additions & 0 deletions .lintstagedrc.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
import fs from 'fs';
import path from 'path';

export default {
'*': 'prettier --ignore-unknown --write',
'**/{networks,packages,wallets}/**/*.{js,jsx,ts,tsx}': 'eslint --fix',
'**/{networks,packages,wallets}/**/*.{ts,tsx}': (files) => {
const packages = new Set();

files.forEach((file) => {
let directory = path.dirname(file);

while (directory !== process.cwd()) {
if (fs.existsSync(path.join(directory, 'package.json'))) {
packages.add(
`npm run type-check --workspace ${path.relative(process.cwd(), directory)}`,
);
break;
}
directory = path.dirname(directory);
}
});

return Array.from(packages);
},
'*.{js,jsx,ts,tsx}': 'npm run test:related',
};
19 changes: 18 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
{
"singleQuote": true
"singleQuote": true,
"quoteProps": "consistent",
"importOrder": [
"^(@?react|@?next)",
"<THIRD_PARTY_MODULES>",
"^@/(.*)$",
"^[.](.*)"
],
"importOrderCaseInsensitive": true,
"importOrderParserPlugins": [
"typescript",
"jsx",
"classProperties",
"[\"decorators\", { \"decoratorsBeforeExport\": true }]"
],
"importOrderSeparation": true,
"importOrderSortSpecifiers": false,
"plugins": ["@trivago/prettier-plugin-sort-imports"]
}
14 changes: 6 additions & 8 deletions apps/guard/app/(dashboard)/@actions/SendForSigningForm.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React, { useState } from 'react';
import { SubmitHandler, useForm } from 'react-hook-form';
import useSWRMutation from 'swr/mutation';

import { Alert } from '@rosen-bridge/icons';
import { useApiKey } from '@rosen-bridge/shared-contexts';
import {
AlertCard,
AlertProps,
Expand All @@ -15,16 +16,13 @@ import {
Typography,
styled,
} from '@rosen-bridge/ui-kit';
import { mutatorWithHeaders } from '@rosen-ui/swr-helpers';

import { Alert } from '@rosen-bridge/icons';

import { useApiKey } from '@rosen-bridge/shared-contexts';

import { ApiSignRequestBody, ApiSignResponse } from '@/_types/api';
import { ApiKeyModal } from '@rosen-bridge/ui-kit';
import { NETWORK_LABELS, NETWORKS } from '@rosen-ui/constants';
import { mutatorWithHeaders } from '@rosen-ui/swr-helpers';
import { Network } from '@rosen-ui/types';
import useSWRMutation from 'swr/mutation';

import { ApiSignRequestBody, ApiSignResponse } from '@/_types/api';

const AlertIcon = styled(Alert)((theme) => ({
fill: theme.palette.primary.main,
Expand Down
20 changes: 10 additions & 10 deletions apps/guard/app/(dashboard)/@actions/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ const Root = styled(Box)(({ theme }) => ({
* render a container for tabs
*/
const TabsContainer = styled(Box)(({ theme }) => ({
position: 'relative',
height: 'calc(100% + 32px)',
margin: theme.spacing(-2, 0),
'position': 'relative',
'height': 'calc(100% + 32px)',
'margin': theme.spacing(-2, 0),
[theme.breakpoints.down('tablet')]: {
margin: theme.spacing(-3, -2),
},
'& .MuiTabs-root': {
paddingTop: theme.spacing(5),
paddingBottom: theme.spacing(5),
'paddingTop': theme.spacing(5),
'paddingBottom': theme.spacing(5),
[theme.breakpoints.down('tablet')]: {
padding: theme.spacing(1, 2, 0, 2),
backgroundColor: theme.palette.info.dark,
Expand Down Expand Up @@ -91,11 +91,11 @@ const TabsContainer = styled(Box)(({ theme }) => ({
},
},
'& .card': {
position: 'absolute',
width: '100%',
height: '100%',
display: 'flex',
flexDirection: 'column',
'position': 'absolute',
'width': '100%',
'height': '100%',
'display': 'flex',
'flexDirection': 'column',
[theme.breakpoints.down('tablet')]: {
display: 'none',
},
Expand Down
14 changes: 7 additions & 7 deletions apps/guard/app/(dashboard)/@infoWidgets/HealthWidget.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import useSWR from 'swr';

import { Alert, ShieldCheck } from '@rosen-bridge/icons';
import {
Expand All @@ -12,6 +11,7 @@ import {
import { healthStatusColorMap } from '@rosen-ui/constants';
import { fetcher } from '@rosen-ui/swr-helpers';
import { AugmentedPalette } from '@rosen-ui/types';
import useSWR from 'swr';

import { ApiInfoResponse } from '@/_types/api';

Expand All @@ -25,17 +25,17 @@ interface HealthWidgetBaseProps {
*/
const HealthWidgetBase = styled(Card)<HealthWidgetBaseProps>(
({ theme, ...props }) => ({
padding: theme.spacing(2),
backgroundColor: theme.palette[props.widgetColor].main,
color: theme.palette[props.widgetColor].contrastText,
backgroundImage:
'padding': theme.spacing(2),
'backgroundColor': theme.palette[props.widgetColor].main,
'color': theme.palette[props.widgetColor].contrastText,
'backgroundImage':
theme.palette.mode === 'light'
? `linear-gradient(180deg, ${
theme.palette[props.widgetColor].main
} 0%, ${theme.palette[props.widgetColor].dark} 100%)`
: 'none',
display: 'flex',
alignItems: 'center',
'display': 'flex',
'alignItems': 'center',
'& span': {
marginLeft: theme.spacing(2),
marginRight: theme.spacing(1),
Expand Down
16 changes: 8 additions & 8 deletions apps/guard/app/(dashboard)/@infoWidgets/WalletWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,24 @@ interface WidgetCardProps {
*/
const WalletWidgetBase = styled(Card)<WidgetCardProps>(
({ theme, ...props }) => ({
padding: theme.spacing(2),
backgroundColor: theme.palette[props.widgetColor].main,
backgroundImage:
'padding': theme.spacing(2),
'backgroundColor': theme.palette[props.widgetColor].main,
'backgroundImage':
theme.palette.mode === 'light'
? `linear-gradient(180deg, ${
theme.palette[props.widgetColor].main
} 0%, ${theme.palette[props.widgetColor].dark} 100%)`
: 'none',
color: theme.palette.success.contrastText,
flexGrow: 1,
'color': theme.palette.success.contrastText,
'flexGrow': 1,
'& .title': {
fontSize: theme.typography.h5.fontSize,
fontWeight: 'bold',
},
'& .value': {
fontSize: theme.typography.h2.fontSize,
fontWeight: 'bold',
textAlign: 'right',
'fontSize': theme.typography.h2.fontSize,
'fontWeight': 'bold',
'textAlign': 'right',
'& span': {
fontSize: '50%',
fontWeight: 'normal',
Expand Down
7 changes: 3 additions & 4 deletions apps/guard/app/(dashboard)/@infoWidgets/page.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
'use client';

import useSWR from 'swr';

import { Stack } from '@rosen-bridge/ui-kit';
import { fetcher } from '@rosen-ui/swr-helpers';
import useSWR from 'swr';

import { ApiInfoResponse } from '@/_types/api';

import { HealthWidget } from './HealthWidget';
import { WalletWidget } from './WalletWidget';

import { ApiInfoResponse } from '@/_types/api';

const InfoWidgets = () => {
const { data: info, isLoading } = useSWR<ApiInfoResponse>('/info', fetcher);

Expand Down
2 changes: 1 addition & 1 deletion apps/guard/app/(dashboard)/@revenue/RevenueChart.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import moment from 'moment';
import React, { useMemo } from 'react';
import Chart from 'react-apexcharts';

import { useTheme } from '@rosen-bridge/ui-kit';
import { ChartPeriod } from '@rosen-ui/types';
import { getDecimalString, roundToPrecision } from '@rosen-ui/utils';
import moment from 'moment';

import { ApiRevenueChartResponse } from '@/_types/api';

Expand Down
6 changes: 3 additions & 3 deletions apps/guard/app/(dashboard)/@revenue/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

import dynamic from 'next/dynamic';
import React, { useState } from 'react';
import useSWR from 'swr';

import { FullCard } from '@rosen-bridge/ui-kit';
import { fetcher } from '@rosen-ui/swr-helpers';
import { ChartPeriod } from '@rosen-ui/types';
import useSWR from 'swr';

import { ApiRevenueChartResponse } from '@/_types/api';

import { PeriodSelect } from './PeriodSelect';
import { RevenueChartSkeleton } from './RevenueChartSkeleton';

import { ApiRevenueChartResponse } from '@/_types/api';

/**
* This is required because revenue chart cannot be pre-rendered in next and
* throws an error
Expand Down
5 changes: 2 additions & 3 deletions apps/guard/app/(dashboard)/@tokens/page.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
'use client';

import useSWR from 'swr';

import { Grid, TokensCard } from '@rosen-bridge/ui-kit';
import { NETWORKS } from '@rosen-ui/constants';
import { fetcher } from '@rosen-ui/swr-helpers';
import useSWR from 'swr';

import { ApiAddressAssetsResponse } from '@/_types/api';
import { NETWORKS } from '@rosen-ui/constants';

const Tokens = () => {
const { data: ergoTokens, isLoading: isErogTokensLoading } =
Expand Down
10 changes: 4 additions & 6 deletions apps/guard/app/App.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
'use client';

import React from 'react';
import { NoSsr } from '@mui/material';

import { NoSsr } from '@mui/material';
import { ApiKeyContextProvider } from '@rosen-bridge/shared-contexts';
import {
styled,
SnackbarProvider,
Expand All @@ -12,14 +13,11 @@ import {
} from '@rosen-bridge/ui-kit';
import { SWRConfig } from '@rosen-ui/swr-mock';

import { SideBar } from './SideBar';
import { Toolbar } from './Toolbar';

import { theme } from '@/_theme/theme';

import { ApiKeyContextProvider } from '@rosen-bridge/shared-contexts';

import { mockedData } from './_mock/mockedData';
import { SideBar } from './SideBar';
import { Toolbar } from './Toolbar';

const Root = styled('div')(({ theme }) => ({
width: '100vw',
Expand Down
3 changes: 1 addition & 2 deletions apps/guard/app/SideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ import {
} from '@rosen-bridge/icons';
import { AppBar, AppLogo } from '@rosen-bridge/ui-kit';

import { useInfo } from './_hooks/useInfo';

import packageJson from '../package.json';
import { useInfo } from './_hooks/useInfo';

/**
* render sidebar log and navigation buttons
Expand Down
13 changes: 6 additions & 7 deletions apps/guard/app/Toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@ import {
ToolbarThemeTogglerAction,
Toolbar as UiKitToolbar,
} from '@rosen-bridge/ui-kit';

import { ApiKeyModal } from '@rosen-bridge/ui-kit';

const pageTitleMap: Record<string, string> = {
'(dashboard)': 'Dashboard',
assets: 'Assets',
events: 'Events',
health: 'Health',
history: 'History',
revenues: 'Revenues',
'assets': 'Assets',
'events': 'Events',
'health': 'Health',
'history': 'History',
'revenues': 'Revenues',
};

/**
Expand All @@ -25,7 +24,7 @@ export const Toolbar = () => {

return (
<UiKitToolbar
title={page ? pageTitleMap[page] ?? '' : ''}
title={page ? (pageTitleMap[page] ?? '') : ''}
toolbarActions={
<>
<ApiKeyModal />
Expand Down
1 change: 1 addition & 0 deletions apps/guard/app/_hooks/useAddresses.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useMemo } from 'react';

import { Network } from '@rosen-ui/types';

import { useInfo } from './useInfo';
Expand Down
5 changes: 2 additions & 3 deletions apps/guard/app/_mock/mockedData.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import moment from 'moment';

import { SWRConfigProps } from '@rosen-ui/swr-mock';
import { NETWORKS } from '@rosen-ui/constants';
import { SWRConfigProps } from '@rosen-ui/swr-mock';
import { ChartPeriod } from '@rosen-ui/types';
import moment from 'moment';

import {
ApiAddressAssetsResponse,
Expand Down
2 changes: 1 addition & 1 deletion apps/guard/app/_theme/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ const create = (baseTheme: Theme) =>
},
body: {
[baseTheme.breakpoints.down('tablet')]: {
verticalAlign: 'top',
'verticalAlign': 'top',
'&:not(.MuiTableCell-paddingNone)': {
padding: baseTheme.spacing(1),
},
Expand Down
6 changes: 2 additions & 4 deletions apps/guard/app/assets/TableRow.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import { useState, FC, useMemo } from 'react';

import { AngleDown, AngleUp } from '@rosen-bridge/icons';
import {
Button,
EnhancedTableCell,
Id,
TableRow,
WithExternalLink,
} from '@rosen-bridge/ui-kit';

import { NETWORKS } from '@rosen-ui/constants';
import { AngleDown, AngleUp } from '@rosen-bridge/icons';

import { getAddressUrl, getDecimalString, getTokenUrl } from '@rosen-ui/utils';

import { GuardTokenInfo } from '@/_types/api';
import { useAddresses } from '@/_hooks/useAddresses';
import { GuardTokenInfo } from '@/_types/api';

interface RowProps extends GuardTokenInfo {
isLoading?: boolean;
Expand Down
Loading

0 comments on commit e9b7361

Please sign in to comment.