Skip to content
This repository was archived by the owner on Oct 11, 2024. It is now read-only.

Commit a06ed2b

Browse files
authored
Prettier (#362)
* Prettier entire codebase
1 parent 22893d3 commit a06ed2b

File tree

204 files changed

+1590
-1715
lines changed

Some content is hidden

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

204 files changed

+1590
-1715
lines changed

.prettierrc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"tabWidth": 4,
33
"printWidth": 120,
4-
"trailingComma": "all",
54
"singleQuote": true,
6-
"arrowParens": "avoid"
5+
"trailingComma": "all"
76
}

package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,21 @@
1111
"build:prod": "node --max_old_space_size=16384 ./node_modules/webpack/bin/webpack.js --mode production",
1212
"build:dev": "node --max-old-space-size=16384 ./node_modules/webpack/bin/webpack.js --mode development",
1313
"clean": "shx rm -rf public/bundle* mdx/tools",
14+
"typecheck": "tsc --pretty --noEmit",
1415
"test": "jest",
1516
"test:watch": "jest --watch",
1617
"eslint": "eslint 'ts/**/*.{ts,tsx}'",
1718
"lint": "tslint --format stylish --project . 'ts/**/*.ts' 'ts/**/*.tsx'",
1819
"fix": "yarn lint --fix",
19-
"pre_push": "yarn tsc --noEmit && yarn lint && yarn test",
20+
"pre_push": "yarn typecheck && yarn lint:prettier && yarn lint && yarn test",
2021
"update:tools": "aws s3 sync --delete s3://docs-markdown/ mdx/tools/ --profile $(npm config get awscli_profile)",
2122
"dev": "npm run update:tools && node --max-old-space-size=16384 ./node_modules/webpack-dev-server/bin/webpack-dev-server.js --mode development --content-base public --https",
2223
"deploy_dogfood": "npm run update:tools && yarn index_docs --environment dogfood && npm run build:prod && aws s3 sync ./public/. s3://dogfood.0xproject.com --profile $(npm config get awscli_profile) --region us-east-1 --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers && ./cdn-cache-clear.sh dogfood",
2324
"deploy_staging": "npm run update:tools && yarn index_docs --environment staging && npm run build:prod && aws s3 sync ./public/. s3://staging-0xproject --profile $(npm config get awscli_profile) --region us-east-1 --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers",
2425
"deploy_live": "npm run update:tools && yarn index_docs --environment production && DEPLOY_ROLLBAR_SOURCEMAPS=true npm run build:prod && aws s3 sync ./public/. s3://0x.org --profile $(npm config get awscli_profile) --region us-east-1 --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --exclude *.map.js && ./cdn-cache-clear.sh live",
25-
"index_docs": "TS_NODE_PROJECT=./tsconfig-indexing.json node --stack-size=16000 -r ts-node/register scripts/algolia_index.ts"
26+
"index_docs": "TS_NODE_PROJECT=./tsconfig-indexing.json node --stack-size=16000 -r ts-node/register scripts/algolia_index.ts",
27+
"prettier": "prettier --write \"ts/**/*.{ts,tsx,js,json,css,yml,md}\"",
28+
"lint:prettier": "prettier --check \"ts/**/*.{ts,tsx,js,json,css,yml,md}\""
2629
},
2730
"author": "Fabio Berger",
2831
"license": "Apache-2.0",
@@ -112,7 +115,7 @@
112115
"xml-js": "^1.6.4"
113116
},
114117
"devDependencies": {
115-
"@0x/tslint-config": "^3.0.1",
118+
"@0x/tslint-config": "^4.1.3",
116119
"@0x/typescript-typings": "^5.0.1",
117120
"@babel/core": "^7.5.5",
118121
"@babel/plugin-proposal-object-rest-spread": "^7.5.5",
@@ -166,6 +169,7 @@
166169
"json-stringify-pretty-compact": "^2.0.0",
167170
"less-loader": "^4.1.0",
168171
"node-sass": "^4.12.0",
172+
"prettier": "^2.2.1",
169173
"raw-loader": "^0.5.1",
170174
"react-svg-loader": "^2.1.0",
171175
"remark": "^10.0.1",

scripts/algolia_admin_client.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import { ALGOLIA_APP_ID } from '../ts/utils/algolia_constants';
44

55
const ALGOLIA_ADMIN_API_KEY = process.env.ALGOLIA_ADMIN_API_KEY;
66
if (ALGOLIA_ADMIN_API_KEY === undefined) {
7-
throw new Error('Env. var. ALGOLIA_ADMIN_API_KEY is undefined. An admin client cannot be instantiated without an admin API key.');
7+
throw new Error(
8+
'Env. var. ALGOLIA_ADMIN_API_KEY is undefined. An admin client cannot be instantiated without an admin API key.',
9+
);
810
}
911
const ALGOLIA_ADMIN_OPTIONS = {
1012
timeouts: {

scripts/algolia_helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const sharedSettings = {
4040
};
4141

4242
const settings: ObjectMap<IAlgoliaSettings> = {
43-
'api': sharedSettings,
43+
api: sharedSettings,
4444
'core-concepts': sharedSettings,
4545
guides: {
4646
...sharedSettings,

ts/blockchain.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,12 @@ export class Blockchain {
122122
};
123123
const ledgerSubprovider = new LedgerSubprovider(ledgerWalletConfigs);
124124
provider.addProvider(ledgerSubprovider);
125-
const rpcSubproviders = _.map(configs.PUBLIC_NODE_URLS_BY_NETWORK_ID[networkIdIfExists], publicNodeUrl => {
126-
return new RPCSubprovider(publicNodeUrl);
127-
});
125+
const rpcSubproviders = _.map(
126+
configs.PUBLIC_NODE_URLS_BY_NETWORK_ID[networkIdIfExists],
127+
(publicNodeUrl) => {
128+
return new RPCSubprovider(publicNodeUrl);
129+
},
130+
);
128131
provider.addProvider(new RedundantSubprovider(rpcSubproviders));
129132
providerUtils.startProviderEngine(provider);
130133
return [provider, ledgerSubprovider];
@@ -139,7 +142,7 @@ export class Blockchain {
139142
? new MetamaskSubprovider(injectedProviderIfExists)
140143
: new SignerSubprovider(injectedProviderIfExists);
141144
provider.addProvider(signerSubprovider);
142-
const rpcSubproviders = _.map(publicNodeUrlsIfExistsForNetworkId, publicNodeUrl => {
145+
const rpcSubproviders = _.map(publicNodeUrlsIfExistsForNetworkId, (publicNodeUrl) => {
143146
return new RPCSubprovider(publicNodeUrl);
144147
});
145148
provider.addProvider(new RedundantSubprovider(rpcSubproviders));
@@ -154,7 +157,7 @@ export class Blockchain {
154157
// injected into their browser.
155158
const provider = new Web3ProviderEngine();
156159
const networkId = constants.NETWORK_ID_MAINNET;
157-
const rpcSubproviders = _.map(configs.PUBLIC_NODE_URLS_BY_NETWORK_ID[networkId], publicNodeUrl => {
160+
const rpcSubproviders = _.map(configs.PUBLIC_NODE_URLS_BY_NETWORK_ID[networkId], (publicNodeUrl) => {
158161
return new RPCSubprovider(publicNodeUrl);
159162
});
160163
provider.addProvider(new RedundantSubprovider(rpcSubproviders));
@@ -510,7 +513,7 @@ export class Blockchain {
510513
? {}
511514
: trackedTokenStorage.getTrackedTokensByAddress(this._userAddressIfExists, this.networkId);
512515
const tokenRegistryTokens = _.values(tokenRegistryTokensByAddress);
513-
const tokenRegistryTokenSymbols = _.map(tokenRegistryTokens, t => t.symbol);
516+
const tokenRegistryTokenSymbols = _.map(tokenRegistryTokens, (t) => t.symbol);
514517
const defaultTrackedTokensInRegistry = _.intersection(
515518
tokenRegistryTokenSymbols,
516519
configs.DEFAULT_TRACKED_TOKEN_SYMBOLS,
@@ -528,8 +531,8 @@ export class Blockchain {
528531
return;
529532
}
530533
if (_.isEmpty(trackedTokensByAddress)) {
531-
_.each(configs.DEFAULT_TRACKED_TOKEN_SYMBOLS, symbol => {
532-
const token = _.find(tokenRegistryTokens, t => t.symbol === symbol);
534+
_.each(configs.DEFAULT_TRACKED_TOKEN_SYMBOLS, (symbol) => {
535+
const token = _.find(tokenRegistryTokens, (t) => t.symbol === symbol);
533536
token.trackedTimestamp = currentTimestamp;
534537
trackedTokensByAddress[token.address] = token;
535538
});

ts/components/animatedChatIcon.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,5 +91,5 @@ const Rays = styled.g`
9191
`;
9292

9393
const Dot = styled.circle<{ delay: number }>`
94-
animation: ${fadeInOut} 4s ${props => `${props.delay}s`} infinite;
94+
animation: ${fadeInOut} 4s ${(props) => `${props.delay}s`} infinite;
9595
`;

ts/components/animations/animation_loader.tsx

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,27 @@ interface IAnimationLoaderProps {
99
export const AnimationLoader: React.FC<IAnimationLoaderProps> = ({ name, shouldLoop }) => {
1010
const container = React.useRef(null);
1111

12-
const loadAnimationAsync = useCallback(async (_name: string) => {
13-
try {
14-
const animationData = await import(/* webpackChunkName: "animation/[request]" */ `../../../public/animations/${_name}.json`);
12+
const loadAnimationAsync = useCallback(
13+
async (_name: string) => {
14+
try {
15+
const animationData = await import(
16+
/* webpackChunkName: "animation/[request]" */ `../../../public/animations/${_name}.json`
17+
);
1518

16-
lottie.loadAnimation({
17-
container: container.current, // the dom element that will contain the animation
18-
renderer: 'svg',
19-
loop: shouldLoop ?? true,
20-
autoplay: true,
21-
animationData,
22-
});
23-
} catch (error) {
24-
// tslint:disable-next-line:no-console
25-
console.error('Error loading animation');
26-
}
27-
}, [shouldLoop]);
19+
lottie.loadAnimation({
20+
container: container.current, // the dom element that will contain the animation
21+
renderer: 'svg',
22+
loop: shouldLoop ?? true,
23+
autoplay: true,
24+
animationData,
25+
});
26+
} catch (error) {
27+
// tslint:disable-next-line:no-console
28+
console.error('Error loading animation');
29+
}
30+
},
31+
[shouldLoop],
32+
);
2833

2934
React.useEffect(() => {
3035
void loadAnimationAsync(name);

ts/components/annoucement_banner.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ const CustomSection = styled(Section)<CustomSectionProps>`
136136
max-width: 100%;
137137
width: inherit;
138138
transition: 300ms transform ease-in-out;
139-
transform: translateY(-${props => (props.dismissed ? '100%' : '0')});
139+
transform: translateY(-${(props) => (props.dismissed ? '100%' : '0')});
140140
font-family: Formular, sans-serif;
141141
@media (max-width: 900px) {
142142
align-items: center;
@@ -196,14 +196,14 @@ const ButtonWrap = styled.div`
196196
// to pass props down into the styled icon?
197197
const Border = styled.div<BorderProps>`
198198
position: absolute;
199-
background-image: ${props =>
199+
background-image: ${(props) =>
200200
props.isBottom ? 'url(/images/banner/bottomofcta.png);' : 'url(/images/banner/topofcta.png);'};
201-
background-position: ${props => (props.isBottom ? 'left top' : 'left bottom')};
201+
background-position: ${(props) => (props.isBottom ? 'left top' : 'left bottom')};
202202
left: 0;
203203
width: calc(100% + 214px);
204204
height: 40px;
205-
top: ${props => !props.isBottom && 0};
206-
bottom: ${props => props.isBottom && 0};
205+
top: ${(props) => !props.isBottom && 0};
206+
bottom: ${(props) => props.isBottom && 0};
207207
transform: translate(-112px);
208208
z-index: 0;
209209
pointer-events: none;

ts/components/background_marquee.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ const MarqueeWrap = styled.div<MarqueeWrapProps>`
2121
width: 130%;
2222
margin-left: -15%;
2323
margin-right: -15%;
24-
height: ${props => props.height || '100%'};
24+
height: ${(props) => props.height || '100%'};
2525
overflow: hidden;
2626
position: relative;
2727
2828
&:after {
2929
content: '';
3030
position: absolute;
3131
width: 100%;
32-
height: ${props => props.height || '100%'};
32+
height: ${(props) => props.height || '100%'};
3333
left: 0;
3434
top: 0;
3535
background: linear-gradient(180.18deg, #000000 11.09%, rgba(0, 0, 0, 0.8) 62.74%, rgba(0, 0, 0, 0) 103.8%);
@@ -56,20 +56,20 @@ const MarqueeWrap = styled.div<MarqueeWrapProps>`
5656
display: flex;
5757
flex-direction: column;
5858
will-change: transform;
59-
transform: translate3d(0, -${props => props.imgHeightInPx}px, 0);
59+
transform: translate3d(0, -${(props) => props.imgHeightInPx}px, 0);
6060
}
6161
6262
@media (min-width: 768px) {
6363
> div {
64-
height: ${props => props.imgHeightInPx * props.imgRepeatCt}px;
65-
animation: ${props => scrollFactory(props.imgHeightInPx, props.imgRepeatCt)} 140s linear infinite;
64+
height: ${(props) => props.imgHeightInPx * props.imgRepeatCt}px;
65+
animation: ${(props) => scrollFactory(props.imgHeightInPx, props.imgRepeatCt)} 140s linear infinite;
6666
}
6767
}
6868
6969
@media (max-width: 768px) {
7070
> div {
71-
height: ${props => props.imgHeightInPx * props.imgRepeatCt}px;
72-
animation: ${props => scrollMobileFactory(props.imgHeightInPx, props.imgRepeatCt)} 140s linear infinite;
71+
height: ${(props) => props.imgHeightInPx * props.imgRepeatCt}px;
72+
animation: ${(props) => scrollMobileFactory(props.imgHeightInPx, props.imgRepeatCt)} 140s linear infinite;
7373
}
7474
}
7575
`;
@@ -131,7 +131,7 @@ export class BackgroundMarquee extends React.Component<BackgroundMarqueeProps> {
131131
<Card key={`card-${index}`}>
132132
<MarqueeImg
133133
onLoad={index === 0 ? this._onImageUpdate : null}
134-
ref={ref => (index === 0 ? (this._imageRef = ref) : null)}
134+
ref={(ref) => (index === 0 ? (this._imageRef = ref) : null)}
135135
src={this.props.imgSrcUrl}
136136
alt=""
137137
/>

ts/components/banner.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,14 @@ const ButtonWrap = styled.div`
146146
// to pass props down into the styled icon?
147147
const Border = styled.div<BorderProps>`
148148
position: absolute;
149-
background-image: ${props =>
149+
background-image: ${(props) =>
150150
props.isBottom ? 'url(/images/banner/bottomofcta.png);' : 'url(/images/banner/topofcta.png);'};
151-
background-position: ${props => (props.isBottom ? 'left top' : 'left bottom')};
151+
background-position: ${(props) => (props.isBottom ? 'left top' : 'left bottom')};
152152
left: 0;
153153
width: calc(100% + 214px);
154154
height: 40px;
155-
top: ${props => !props.isBottom && 0};
156-
bottom: ${props => props.isBottom && 0};
155+
top: ${(props) => !props.isBottom && 0};
156+
bottom: ${(props) => props.isBottom && 0};
157157
transform: translate(-112px);
158158
159159
@media (max-width: 768px) {

0 commit comments

Comments
 (0)