Skip to content

Commit

Permalink
fix: run prettier over the codebase (#4701)
Browse files Browse the repository at this point in the history
* fix: run prettier over the codebase

* fix: lint staged was running on all files and not on staged files
  • Loading branch information
compojoom authored Dec 23, 2024
1 parent 50ac6ed commit 50486ea
Show file tree
Hide file tree
Showing 10 changed files with 146 additions and 156 deletions.
12 changes: 7 additions & 5 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: Bug report
about: Create an issue to fix a bug
labels: ["bug"]
labels: ['bug']
---

<!--
Expand All @@ -11,12 +11,14 @@ BEFORE SUBMITTING: Please search to make sure this issue hasn't been reported al
## Bug description

## Environment
- Browser: Chrome
- Wallet: MetaMask
- Chain: Ethereum mainnet

- Browser: Chrome
- Wallet: MetaMask
- Chain: Ethereum mainnet

## Steps to reproduce
1. Go to

1. Go to

## Expected result

Expand Down
7 changes: 4 additions & 3 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Resolves #
## Screenshots

## Checklist
* [ ] I've tested the branch on mobile 📱
* [ ] I've documented how it affects the analytics (if at all) 📊
* [ ] I've written a unit/e2e test for it (if applicable) 🧑‍💻

- [ ] I've tested the branch on mobile 📱
- [ ] I've documented how it affects the analytics (if at all) 📊
- [ ] I've written a unit/e2e test for it (if applicable) 🧑‍💻
4 changes: 2 additions & 2 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"*.ts": ["yarn prettier:fix"],
"*.tsx": ["yarn prettier:fix"],
"**/*.{js,jsx,ts,tsx,mjs,cjs,md,yml,json}": ["prettier --write"],
"*.tsx": ["prettier --write"],
"apps/mobile/assets/fonts/safe-icons/selection.json": [
"node ./apps/mobile/scripts/generateIconTypes.js",
"git add ./apps/mobile/src/types/iconTypes.ts"
Expand Down
5 changes: 4 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
build
coverage
node_modules
**/node_modules/*
html
ios
android
/assets

.next
apps/mobile/assets
apps/web/src/markdown/privacy/privacy.md
apps/web/src/markdown/terms/terms.md
57 changes: 28 additions & 29 deletions apps/web/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,49 +9,49 @@ const config: StorybookConfig = {
'@chromatic-com/storybook',
'@storybook/addon-interactions',
'@storybook/addon-themes',
'@storybook/addon-designs'
'@storybook/addon-designs',
],
framework: {
name: '@storybook/nextjs',
options: {},
},
webpackFinal: async (config) => {
config.module = config.module || {};
config.module.rules = config.module.rules || [];
config.module = config.module || {}
config.module.rules = config.module.rules || []

// This modifies the existing image rule to exclude .svg files
// since you want to handle those files with @svgr/webpack
const imageRule = config.module.rules.find((rule) => rule?.['test']?.test('.svg'));
const imageRule = config.module.rules.find((rule) => rule?.['test']?.test('.svg'))
if (imageRule) {
imageRule['exclude'] = /\.svg$/;
imageRule['exclude'] = /\.svg$/
}

config.module.rules.push({
test: /\.svg$/i,
issuer: { and: [/\.(js|ts|md)x?$/] },
use: [
{
loader: '@svgr/webpack',
options: {
prettier: false,
svgo: false,
svgoConfig: {
plugins: [
{
name: 'preset-default',
params: {
overrides: { removeViewBox: false },
},
config.module.rules.push({
test: /\.svg$/i,
issuer: { and: [/\.(js|ts|md)x?$/] },
use: [
{
loader: '@svgr/webpack',
options: {
prettier: false,
svgo: false,
svgoConfig: {
plugins: [
{
name: 'preset-default',
params: {
overrides: { removeViewBox: false },
},
],
},
titleProp: true,
},
],
},
titleProp: true,
},
],
})
},
],
})

return config;
return config
},
docs: {
autodocs: 'tag',
Expand All @@ -71,8 +71,7 @@ const config: StorybookConfig = {
// Makes string and boolean types that can be undefined appear as inputs and switches
shouldRemoveUndefinedFromOptional: true,
// Filter out third-party props from node_modules except @mui packages
propFilter: (prop) =>
prop.parent ? !/node_modules\/(?!@mui)/.test(prop.parent.fileName) : true,
propFilter: (prop) => (prop.parent ? !/node_modules\/(?!@mui)/.test(prop.parent.fileName) : true),
},
},
}
Expand Down
58 changes: 29 additions & 29 deletions apps/web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
![GitHub package.json version (branch)](https://img.shields.io/github/package-json/v/safe-global/safe-wallet-web)
[![GitPOAP Badge](https://public-api.gitpoap.io/v1/repo/safe-global/safe-wallet-web/badge)](https://www.gitpoap.io/gh/safe-global/safe-wallet-web)

# Safe{Wallet} Web 💻
# Safe{Wallet} Web 💻

This project is now part of the **@safe-global/safe-wallet** monorepo! The monorepo setup allows centralized management
of multiple
Expand Down Expand Up @@ -43,34 +43,34 @@ Create a `.env` file with environment variables. You can use the `.env.example`

Here's the list of all the environment variables:

| Env variable | Description |
| ------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `NEXT_PUBLIC_BRAND_NAME` | The name of the app, defaults to "Wallet fork" |
| `NEXT_PUBLIC_BRAND_LOGO` | The URL of the app logo displayed in the header |

| `NEXT_PUBLIC_INFURA_TOKEN` | [Infura](https://docs.infura.io/infura/networks/ethereum/how-to/secure-a-project/project-id) RPC API token |
| `NEXT_PUBLIC_SAFE_APPS_INFURA_TOKEN` | Infura token for Safe Apps, falls back to `NEXT_PUBLIC_INFURA_TOKEN` |
| `NEXT_PUBLIC_IS_PRODUCTION` | Set to `true` to build a minified production app |
| `NEXT_PUBLIC_GATEWAY_URL_PRODUCTION` | The base URL for the [Safe Client Gateway](https://github.com/safe-global/safe-client-gateway) |
| `NEXT_PUBLIC_GATEWAY_URL_STAGING` | The base CGW URL on staging |
| `NEXT_PUBLIC_SAFE_VERSION` | The latest version of the Safe contract, defaults to 1.4.1 |
| `NEXT_PUBLIC_WC_PROJECT_ID` | [WalletConnect v2](https://docs.walletconnect.com/2.0/cloud/relay) project ID |
| `NEXT_PUBLIC_TENDERLY_ORG_NAME` | [Tenderly](https://tenderly.co) org name for Transaction Simulation |
| `NEXT_PUBLIC_TENDERLY_PROJECT_NAME` | Tenderly project name |
| `NEXT_PUBLIC_TENDERLY_SIMULATE_ENDPOINT_URL` | Tenderly simulation URL |
| `NEXT_PUBLIC_BEAMER_ID` | [Beamer](https://www.getbeamer.com) is a news feed for in-app announcements |
| `NEXT_PUBLIC_GOOGLE_TAG_MANAGER_ID` | [GTM](https://tagmanager.google.com) project id |
| `NEXT_PUBLIC_GOOGLE_TAG_MANAGER_DEVELOPMENT_AUTH` | Dev GTM key |
| `NEXT_PUBLIC_GOOGLE_TAG_MANAGER_LATEST_AUTH` | Preview GTM key |
| `NEXT_PUBLIC_GOOGLE_TAG_MANAGER_LIVE_AUTH` | Production GTM key |
| `NEXT_PUBLIC_SENTRY_DSN` | [Sentry](https://sentry.io) id for tracking runtime errors |
| `NEXT_PUBLIC_IS_OFFICIAL_HOST` | Whether it's the official distribution of the app, or a fork; has legal implications. Set to true only if you also update the legal pages like Imprint and Terms of use |
| `NEXT_PUBLIC_REDEFINE_API` | Redefine API base URL |
| `NEXT_PUBLIC_FIREBASE_OPTIONS_PRODUCTION` | Firebase Cloud Messaging (FCM) `initializeApp` options on production |
| `NEXT_PUBLIC_FIREBASE_VAPID_KEY_PRODUCTION` | FCM vapid key on production |
| `NEXT_PUBLIC_FIREBASE_OPTIONS_STAGING` | FCM `initializeApp` options on staging |
| `NEXT_PUBLIC_FIREBASE_VAPID_KEY_STAGING` | FCM vapid key on staging |
| `NEXT_PUBLIC_SPINDL_SDK_KEY` | [Spindl](http://spindl.xyz) SDK key |
| Env variable | Description |
| ------------------------ | ----------------------------------------------- |
| `NEXT_PUBLIC_BRAND_NAME` | The name of the app, defaults to "Wallet fork" |
| `NEXT_PUBLIC_BRAND_LOGO` | The URL of the app logo displayed in the header |

| `NEXT_PUBLIC_INFURA_TOKEN` | [Infura](https://docs.infura.io/infura/networks/ethereum/how-to/secure-a-project/project-id) RPC API token |
| `NEXT_PUBLIC_SAFE_APPS_INFURA_TOKEN` | Infura token for Safe Apps, falls back to `NEXT_PUBLIC_INFURA_TOKEN` |
| `NEXT_PUBLIC_IS_PRODUCTION` | Set to `true` to build a minified production app |
| `NEXT_PUBLIC_GATEWAY_URL_PRODUCTION` | The base URL for the [Safe Client Gateway](https://github.com/safe-global/safe-client-gateway) |
| `NEXT_PUBLIC_GATEWAY_URL_STAGING` | The base CGW URL on staging |
| `NEXT_PUBLIC_SAFE_VERSION` | The latest version of the Safe contract, defaults to 1.4.1 |
| `NEXT_PUBLIC_WC_PROJECT_ID` | [WalletConnect v2](https://docs.walletconnect.com/2.0/cloud/relay) project ID |
| `NEXT_PUBLIC_TENDERLY_ORG_NAME` | [Tenderly](https://tenderly.co) org name for Transaction Simulation |
| `NEXT_PUBLIC_TENDERLY_PROJECT_NAME` | Tenderly project name |
| `NEXT_PUBLIC_TENDERLY_SIMULATE_ENDPOINT_URL` | Tenderly simulation URL |
| `NEXT_PUBLIC_BEAMER_ID` | [Beamer](https://www.getbeamer.com) is a news feed for in-app announcements |
| `NEXT_PUBLIC_GOOGLE_TAG_MANAGER_ID` | [GTM](https://tagmanager.google.com) project id |
| `NEXT_PUBLIC_GOOGLE_TAG_MANAGER_DEVELOPMENT_AUTH` | Dev GTM key |
| `NEXT_PUBLIC_GOOGLE_TAG_MANAGER_LATEST_AUTH` | Preview GTM key |
| `NEXT_PUBLIC_GOOGLE_TAG_MANAGER_LIVE_AUTH` | Production GTM key |
| `NEXT_PUBLIC_SENTRY_DSN` | [Sentry](https://sentry.io) id for tracking runtime errors |
| `NEXT_PUBLIC_IS_OFFICIAL_HOST` | Whether it's the official distribution of the app, or a fork; has legal implications. Set to true only if you also update the legal pages like Imprint and Terms of use |
| `NEXT_PUBLIC_REDEFINE_API` | Redefine API base URL |
| `NEXT_PUBLIC_FIREBASE_OPTIONS_PRODUCTION` | Firebase Cloud Messaging (FCM) `initializeApp` options on production |
| `NEXT_PUBLIC_FIREBASE_VAPID_KEY_PRODUCTION` | FCM vapid key on production |
| `NEXT_PUBLIC_FIREBASE_OPTIONS_STAGING` | FCM `initializeApp` options on staging |
| `NEXT_PUBLIC_FIREBASE_VAPID_KEY_STAGING` | FCM vapid key on staging |
| `NEXT_PUBLIC_SPINDL_SDK_KEY` | [Spindl](http://spindl.xyz) SDK key |

If you don't provide some of the variables, the corresponding features will be disabled in the UI.

Expand Down
100 changes: 50 additions & 50 deletions apps/web/cypress/fixtures/test-working-batch.json
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
{
"version":"1.0",
"chainId":"11155111",
"createdAt":1702396600164,
"meta":{
"name":"Transactions Batch",
"description":"",
"txBuilderVersion":"1.16.4",
"createdFromSafeAddress":"0x4DD4cB2299E491E1B469245DB589ccB2B16d7bde",
"createdFromOwnerAddress":"",
"checksum":"0x5117b795c64424440e9fccaac343a93606b405852a4b28809c909f9c805839f5"
"version": "1.0",
"chainId": "11155111",
"createdAt": 1702396600164,
"meta": {
"name": "Transactions Batch",
"description": "",
"txBuilderVersion": "1.16.4",
"createdFromSafeAddress": "0x4DD4cB2299E491E1B469245DB589ccB2B16d7bde",
"createdFromOwnerAddress": "",
"checksum": "0x5117b795c64424440e9fccaac343a93606b405852a4b28809c909f9c805839f5"
},
"transactions":[
{
"to":"0x11AB70A4564C62F567B92868Cb5e69b50c5434aF",
"value":"0",
"data":null,
"contractMethod":{
"inputs":[
{
"internalType":"address",
"name":"newValue",
"type":"address"
}
],
"name":"testAddressValue",
"payable":false
},
"contractInputsValues":{
"newValue":"0x4DD4cB2299E491E1B469245DB589ccB2B16d7bde"
}
},
{
"to":"0x11AB70A4564C62F567B92868Cb5e69b50c5434aF",
"value":"0",
"data":null,
"contractMethod":{
"inputs":[
{
"internalType":"address",
"name":"newValue",
"type":"address"
}
],
"name":"testAddressValue",
"payable":false
},
"contractInputsValues":{
"newValue":"0xc6b82bA149CFA113f8f48d5E3b1F78e933e16DfD"
}
}
"transactions": [
{
"to": "0x11AB70A4564C62F567B92868Cb5e69b50c5434aF",
"value": "0",
"data": null,
"contractMethod": {
"inputs": [
{
"internalType": "address",
"name": "newValue",
"type": "address"
}
],
"name": "testAddressValue",
"payable": false
},
"contractInputsValues": {
"newValue": "0x4DD4cB2299E491E1B469245DB589ccB2B16d7bde"
}
},
{
"to": "0x11AB70A4564C62F567B92868Cb5e69b50c5434aF",
"value": "0",
"data": null,
"contractMethod": {
"inputs": [
{
"internalType": "address",
"name": "newValue",
"type": "address"
}
],
"name": "testAddressValue",
"payable": false
},
"contractInputsValues": {
"newValue": "0xc6b82bA149CFA113f8f48d5E3b1F78e933e16DfD"
}
}
]
}
}
10 changes: 5 additions & 5 deletions apps/web/docs/code-style.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
- Strive for pragmatism
- Don’t add bells and whistles (newlines, spaces for “beauty”, ordering imports etc.)
- Avoid unnecessary stylistic changes
- They increase the chance of git conflicts (esp. in imports)
- They make it harder to review the PR
- Ultimately, a waste of time
- They increase the chance of git conflicts (esp. in imports)
- They make it harder to review the PR
- Ultimately, a waste of time

## Functional code style

Expand All @@ -33,7 +33,7 @@ Infamously, the hardest problem in computer science.
- Config-like constants should be in UPPER_CASE, e.g. `INFURA_URL`
- Regular `const` variables should be in camelCase
- Avoid prepositions in variable names:
- ~`restoreFromLocalStorage`~ 🙅
- `restoreStoredValue` 👍
- ~`restoreFromLocalStorage`~ 🙅
- `restoreStoredValue` 👍
- Try to name boolean vars with `is`, e.g. `isLoading` vs `loading`
- If something needs to be exported just for unit tests, export it with a `_` prefix, e.g. `_getOnboardConfig`
18 changes: 10 additions & 8 deletions apps/web/docs/environments.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
# Environments
We have several environments where the app can be deployed:

We have several environments where the app can be deployed:

|Env|URL|Purpose|How it's deployed|Backend env|
|---|---|---|---|---|
|local|http://localhost:3000/app|local development|`yarn start`|staging|
|PRs |`https://<PR_NAME>--walletweb.review.5afe.dev/`|peer review & feature QA|for all PRs on push|staging|
|dev |https://safe-wallet-web.dev.5afe.dev/|preview of all WIP features|on push to the `dev` branch|staging|
|staging|https://safe-wallet-web.staging.5afe.dev/|preview of features before a release|on push to `main`|**production** (for testing)|
|production|https://app.safe.global/|live app|deployed by DevOps (see the [Release Procedure](release-procedure.md))|**production**|
| Env | URL | Purpose | How it's deployed | Backend env |
| ---------- | ----------------------------------------------- | ------------------------------------ | ---------------------------------------------------------------------- | ---------------------------- |
| local | http://localhost:3000/app | local development | `yarn start` | staging |
| PRs | `https://<PR_NAME>--walletweb.review.5afe.dev/` | peer review & feature QA | for all PRs on push | staging |
| dev | https://safe-wallet-web.dev.5afe.dev/ | preview of all WIP features | on push to the `dev` branch | staging |
| staging | https://safe-wallet-web.staging.5afe.dev/ | preview of features before a release | on push to `main` | **production** (for testing) |
| production | https://app.safe.global/ | live app | deployed by DevOps (see the [Release Procedure](release-procedure.md)) | **production** |

## Lifecycle of a feature

After a feature enters the development cycle (i.e. is in a sprint), it goes through the following steps:

### Development & QA

1. Developer starts working on the feature
2. Developer creates a Pull Request and assigns a reviewer
3. Reviewer leaves feedback until the PR is approved
4. QA engineer starts testing the branch on a deployed site (each PR has one, see the table above)
5. Once QA gives a green light, the branch is merged to the `dev` branch

### Release

1. All merged branches sit on `dev`, which is occasionally reviewed on the [dev site](https://safe-wallet-web.dev.5afe.dev/).
2. In case some regression is noticed, it's fixed on dev.
3. Once a sufficient amount of features are ready for a release (at least once in a sprint), a release branch is made (normally from the HEAD of `dev`) and a PR to `main` is created.
Expand Down
Loading

0 comments on commit 50486ea

Please sign in to comment.