Skip to content

Commit 4397c6b

Browse files
authored
Merge pull request #306 from onflow/as/prettier-format
Run Prettier format and add format check to ci
2 parents 6971df5 + c35cb84 commit 4397c6b

File tree

98 files changed

+2513
-2261
lines changed

Some content is hidden

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

98 files changed

+2513
-2261
lines changed

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/src/api/apollo/generated

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ install:
2525
$(info Task: install)
2626
$(EXEC) sh -c 'npm install || exit 255'
2727

28+
.PHONY: format
29+
format:
30+
$(info Task: format:check)
31+
$(EXEC) sh -c 'npm run format:check:app || exit 255'
32+
2833
.PHONY: build
2934
build:
3035
$(info Task: build production)
@@ -36,4 +41,4 @@ test:
3641
$(EXEC) sh -c 'npm run test || exit 255'
3742

3843
.PHONY: ci
39-
ci: clean install build test
44+
ci: clean install format build test

src/api/apollo/generated/graphql.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1636,4 +1636,3 @@ export type GetResultsQueryResult = ApolloReactCommon.QueryResult<GetResultsQuer
16361636
}
16371637
};
16381638
export default result;
1639-

src/api/apollo/mutations.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import gql from 'graphql-tag'
1+
import gql from 'graphql-tag';
22

33
export const CREATE_PROJECT = gql`
44
mutation CreateProject(
@@ -38,8 +38,21 @@ export const CREATE_PROJECT = gql`
3838
`;
3939

4040
export const SAVE_PROJECT = gql`
41-
mutation UpdateProject($projectId: UUID!, $title: String!, $description: String!, $readme: String!) {
42-
updateProject(input: { id: $projectId, persist: true, title: $title, description: $description, readme: $readme }) {
41+
mutation UpdateProject(
42+
$projectId: UUID!
43+
$title: String!
44+
$description: String!
45+
$readme: String!
46+
) {
47+
updateProject(
48+
input: {
49+
id: $projectId
50+
persist: true
51+
title: $title
52+
description: $description
53+
readme: $readme
54+
}
55+
) {
4356
id
4457
persist
4558
title

src/components/AccountAvatars.tsx

Lines changed: 47 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import React from "react";
2-
import { useThemeUI, Flex, Box, Badge } from "theme-ui";
3-
import { motion } from "framer-motion";
4-
import { Account, Project } from "src/api/apollo/generated/graphql";
5-
import Avatar from "components/Avatar";
1+
import React from 'react';
2+
import { useThemeUI, Flex, Box, Badge } from 'theme-ui';
3+
import { motion } from 'framer-motion';
4+
import { Account, Project } from 'src/api/apollo/generated/graphql';
5+
import Avatar from 'components/Avatar';
66

77
export const AccountAvatar: React.FC<{
88
onClick: (e: any, i: number) => void;
@@ -13,14 +13,14 @@ export const AccountAvatar: React.FC<{
1313
<Box
1414
//@ts-ignore
1515
onClick={onClick}
16-
mx={"0.5rem"}
16+
mx={'0.5rem'}
1717
sx={{
18-
position: "relative",
19-
borderRadius: "50%",
20-
".avatar": {
21-
position: "relative",
22-
top: "-3px"
23-
}
18+
position: 'relative',
19+
borderRadius: '50%',
20+
'.avatar': {
21+
position: 'relative',
22+
top: '-3px',
23+
},
2424
}}
2525
>
2626
{children}
@@ -33,8 +33,8 @@ export const AvatarList: React.FC = ({ children }) => {
3333
return (
3434
<Flex
3535
sx={{
36-
flex: "1 1 auto",
37-
alignItems: "center"
36+
flex: '1 1 auto',
37+
alignItems: 'center',
3838
}}
3939
>
4040
{children}
@@ -52,9 +52,16 @@ const AccountAvatars: React.FC<{
5252
accounts: Account[];
5353
maxSelection?: number;
5454
}> = (props) => {
55-
const { multi, selectedAccounts, accounts, project, onChange, maxSelection = 4 } = props;
55+
const {
56+
multi,
57+
selectedAccounts,
58+
accounts,
59+
project,
60+
onChange,
61+
maxSelection = 4,
62+
} = props;
5663
if (!multi) {
57-
throw new Error("Must include multi prop.");
64+
throw new Error('Must include multi prop.');
5865
}
5966

6067
const { theme } = useThemeUI();
@@ -64,47 +71,49 @@ const AccountAvatars: React.FC<{
6471
<AvatarList>
6572
{accounts.map((account: Account, i: number) => {
6673
const isSelected =
67-
selectedAccounts.includes(i) || selectionLimitReached
74+
selectedAccounts.includes(i) || selectionLimitReached;
6875
return (
6976
<motion.div key={account.address}>
7077
<AccountAvatar
7178
key={account.id}
72-
onClick={ isSelected
73-
? noop
74-
: () => { onChange(i); }
79+
onClick={
80+
isSelected
81+
? noop
82+
: () => {
83+
onChange(i);
84+
}
7585
}
7686
active={isSelected}
7787
>
7888
<motion.div
7989
style={{
80-
cursor: "pointer",
81-
borderRadius: "50%",
82-
pointerEvents: isSelected
83-
? "none"
84-
: "auto"
90+
cursor: 'pointer',
91+
borderRadius: '50%',
92+
pointerEvents: isSelected ? 'none' : 'auto',
8593
}}
8694
whileHover={{ scale: 1.05 }}
8795
>
8896
<Avatar
8997
seed={project.seed}
9098
index={i}
9199
style={{
92-
width: "35px",
93-
height: "35px",
94-
display: "block",
95-
borderRadius: "0 0 20px 20px",
96-
filter: isSelected
97-
? "grayscale(1)"
98-
: "none"
99-
}} />
100+
width: '35px',
101+
height: '35px',
102+
display: 'block',
103+
borderRadius: '0 0 20px 20px',
104+
filter: isSelected ? 'grayscale(1)' : 'none',
105+
}}
106+
/>
100107
<Badge
101-
px={"5px"}
108+
px={'5px'}
102109
sx={{
103110
fontSize: 3,
104-
backgroundColor: isSelected? theme.colors.greyBorder : theme.colors.primary,
105-
position: "absolute",
106-
left: "-2px",
107-
bottom: "-1px"
111+
backgroundColor: isSelected
112+
? theme.colors.greyBorder
113+
: theme.colors.primary,
114+
position: 'absolute',
115+
left: '-2px',
116+
bottom: '-1px',
108117
}}
109118
>
110119
0x{account.address.slice(-2)}

src/components/AccountList.tsx

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
import React from "react";
2-
import {navigate, useLocation} from "@reach/router"
3-
import {Account} from "api/apollo/generated/graphql";
4-
import {EntityType} from "providers/Project";
5-
import {SidebarSection as Root} from "layout/SidebarSection";
6-
import {SidebarHeader as Header} from "layout/SidebarHeader";
7-
import {SidebarItems as Items} from "layout/SidebarItems";
8-
import {SidebarItem as Item} from "layout/SidebarItem";
9-
import {Stack} from "layout/Stack";
10-
import {useProject} from "providers/Project/projectHooks";
11-
import Avatar from "components/Avatar";
12-
import styled from "@emotion/styled";
13-
import {ExportButton} from "components/ExportButton";
14-
import {getParams, isUUUID, LOCAL_PROJECT_ID} from "../util/url";
15-
import {ResourcesExplorerButton} from "components/ResourcesExplorerButton";
1+
import React from 'react';
2+
import { navigate, useLocation } from '@reach/router';
3+
import { Account } from 'api/apollo/generated/graphql';
4+
import { EntityType } from 'providers/Project';
5+
import { SidebarSection as Root } from 'layout/SidebarSection';
6+
import { SidebarHeader as Header } from 'layout/SidebarHeader';
7+
import { SidebarItems as Items } from 'layout/SidebarItems';
8+
import { SidebarItem as Item } from 'layout/SidebarItem';
9+
import { Stack } from 'layout/Stack';
10+
import { useProject } from 'providers/Project/projectHooks';
11+
import Avatar from 'components/Avatar';
12+
import styled from '@emotion/styled';
13+
import { ExportButton } from 'components/ExportButton';
14+
import { getParams, isUUUID, LOCAL_PROJECT_ID } from '../util/url';
15+
import { ResourcesExplorerButton } from 'components/ResourcesExplorerButton';
1616

1717
function getDeployedContracts(account: Account): string {
1818
const contracts = account.deployedContracts.map(
19-
contract => contract.split(".").slice(-1)[0]
19+
(contract) => contract.split('.').slice(-1)[0],
2020
);
21-
return contracts.join(", ");
21+
return contracts.join(', ');
2222
}
2323

2424
export const AccountCard = styled.div`
@@ -30,45 +30,45 @@ export const AccountCard = styled.div`
3030
`;
3131

3232
const AccountList: React.FC = () => {
33-
const {
34-
project,
35-
active,
36-
selectedResourceAccount
37-
} = useProject();
38-
const accountSelected = active.type === EntityType.Account
33+
const { project, active, selectedResourceAccount } = useProject();
34+
const accountSelected = active.type === EntityType.Account;
3935

4036
const location = useLocation();
41-
const params = getParams(location.search)
42-
const projectPath = isUUUID(project.id) ? project.id : LOCAL_PROJECT_ID
37+
const params = getParams(location.search);
38+
const projectPath = isUUUID(project.id) ? project.id : LOCAL_PROJECT_ID;
4339

4440
return (
4541
<Root>
4642
<Header>Accounts</Header>
4743
<Items>
4844
{project.accounts.map((account: Account, i: number) => {
49-
const { id } = account
50-
const isActive = accountSelected && params.id === id
51-
const accountAddress = `0x${account.address.slice(-2)}`
52-
const contractName = getDeployedContracts(account)
45+
const { id } = account;
46+
const isActive = accountSelected && params.id === id;
47+
const accountAddress = `0x${account.address.slice(-2)}`;
48+
const contractName = getDeployedContracts(account);
5349
const title = contractName
5450
? `${contractName} is deployed to this account`
55-
: `This account don't have any contracts`
56-
const typeName = account.__typename
51+
: `This account don't have any contracts`;
52+
const typeName = account.__typename;
5753
return (
58-
<Item
59-
title={title}
60-
active={isActive}
61-
key={account.address}
62-
>
54+
<Item title={title} active={isActive} key={account.address}>
6355
<AccountCard
64-
onClick={() => navigate(`/${projectPath}?type=account&id=${id}&storage=${selectedResourceAccount || 'none'}`)}
56+
onClick={() =>
57+
navigate(
58+
`/${projectPath}?type=account&id=${id}&storage=${
59+
selectedResourceAccount || 'none'
60+
}`,
61+
)
62+
}
6563
>
6664
<Avatar seed={project.seed} index={i} />
6765
<Stack>
6866
<strong>{accountAddress}</strong>
6967
<small>{contractName || '--'}</small>
7068
</Stack>
71-
{isActive && <ExportButton id={account.id} typeName={typeName}/>}
69+
{isActive && (
70+
<ExportButton id={account.id} typeName={typeName} />
71+
)}
7272
</AccountCard>
7373
<ResourcesExplorerButton address={accountAddress} />
7474
</Item>

src/components/AccountPicker.tsx

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import React, { useEffect } from "react";
2-
import { Flex, useThemeUI } from "theme-ui";
3-
import { Account, Project } from "api/apollo/generated/graphql";
4-
import AccountAvatars from "components/AccountAvatars";
5-
import AccountSigners from "components/AccountSigners";
1+
import React, { useEffect } from 'react';
2+
import { Flex, useThemeUI } from 'theme-ui';
3+
import { Account, Project } from 'api/apollo/generated/graphql';
4+
import AccountAvatars from 'components/AccountAvatars';
5+
import AccountSigners from 'components/AccountSigners';
66

77
type AccountPickerProps = {
88
project: Project;
@@ -18,7 +18,7 @@ const AccountPicker: React.FC<AccountPickerProps> = ({
1818
selected,
1919
onChange,
2020
maxSelection = 4,
21-
children
21+
children,
2222
}) => {
2323
const { theme } = useThemeUI();
2424
const handleOnChange = (i: number) => {
@@ -33,25 +33,25 @@ const AccountPicker: React.FC<AccountPickerProps> = ({
3333
if (!selected.length) {
3434
onChange([0]);
3535
}
36-
if (selected.length > maxSelection){
37-
onChange(selected.slice(0,maxSelection))
36+
if (selected.length > maxSelection) {
37+
onChange(selected.slice(0, maxSelection));
3838
}
3939
}, [maxSelection]);
4040

4141
return (
4242
<Flex
4343
sx={{
44-
flexDirection: "column"
44+
flexDirection: 'column',
4545
}}
4646
>
4747
<Flex
4848
my={1}
4949
sx={{
50-
padding: "0.8rem 0.5rem",
51-
alignItems: "center",
50+
padding: '0.8rem 0.5rem',
51+
alignItems: 'center',
5252
border: `1px solid ${theme.colors.borderDark}`,
5353
backgroundColor: theme.colors.background,
54-
borderRadius: "50px",
54+
borderRadius: '50px',
5555
}}
5656
>
5757
<AccountAvatars
@@ -65,14 +65,14 @@ const AccountPicker: React.FC<AccountPickerProps> = ({
6565
</Flex>
6666
<Flex
6767
sx={{
68-
padding: "0.8rem 0.5rem",
69-
alignItems: "center",
68+
padding: '0.8rem 0.5rem',
69+
alignItems: 'center',
7070
border: `1px solid ${theme.colors.borderDark}`,
7171
backgroundColor: theme.colors.background,
72-
borderRadius: "8px"
72+
borderRadius: '8px',
7373
}}
7474
>
75-
<AccountSigners
75+
<AccountSigners
7676
multi={true}
7777
project={project}
7878
accounts={accounts}
@@ -81,9 +81,9 @@ const AccountPicker: React.FC<AccountPickerProps> = ({
8181
maxSelection={maxSelection}
8282
/>
8383
<Flex
84-
px={"0.5rem"}
84+
px={'0.5rem'}
8585
sx={{
86-
alignItems: "center"
86+
alignItems: 'center',
8787
}}
8888
>
8989
{children}

0 commit comments

Comments
 (0)