Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add prettier-config package #72

Merged
merged 14 commits into from
Oct 17, 2024
Merged
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
node_modules/
.next/
**/generated/*.ts
theme.ts
theme.ts
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
title: ""
labels: ""
assignees: ""
---

**Describe the bug** A clear and concise description of what the bug is.
Expand Down
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/custom.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: Custom issue template
about: Describe this issue template's purpose here.
title: ''
labels: ''
assignees: ''
title: ""
labels: ""
assignees: ""
---
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''
title: ""
labels: ""
assignees: ""
---

**Is your feature request related to a problem? Please describe.** A clear and concise description
Expand Down
13 changes: 2 additions & 11 deletions .lintstagedrc.cjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
// https://nextjs.org/docs/pages/building-your-application/configuring/eslint#lint-staged

const path = require('path')

const buildEslintCommand = filenames =>
`next lint --fix --max-warnings 0 --file ${filenames
.map(f => path.relative(process.cwd(), f))
.join(' --file ')}`

module.exports = {
'*.{js,jsx,ts,tsx}': [buildEslintCommand, 'bash -c "pnpm run typecheck"'],
'*.{js,jsx,ts,tsx}': ['eslint --fix', 'bash -c "pnpm run typecheck"'],
'*.{md,json,yaml,ts,tsx}': 'prettier --write',
'*.css': 'stylelint --fix',
}
};
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.next/
pnpm-lock.yaml

13 changes: 13 additions & 0 deletions apps/beets-frontend-v3/.lintstagedrc.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// https://nextjs.org/docs/pages/building-your-application/configuring/eslint#lint-staged
import baseConfig from '../../.lintstagedrc.cjs'
import path from 'path'

const buildEslintCommand = filenames =>
`next lint --fix --max-warnings 0 --file ${filenames
.map(f => path.relative(process.cwd(), f))
.join(' --file ')}`

export default {
...baseConfig,
'*.{js,jsx,ts,tsx}': [buildEslintCommand, 'bash -c "pnpm run typecheck"'],
}
7 changes: 0 additions & 7 deletions apps/beets-frontend-v3/.prettierrc.cjs

This file was deleted.

1 change: 1 addition & 0 deletions apps/beets-frontend-v3/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"@repo/prettier-config"
5 changes: 1 addition & 4 deletions apps/beets-frontend-v3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"@chakra-ui/cli": "^2.4.1",
"@chakra-ui/styled-system": "^2.9.2",
"@repo/eslint-config": "workspace:*",
"@repo/prettier-config": "workspace:*",
"@repo/typescript-config": "workspace:*",
"@sentry/types": "^7.89.0",
"@types/js-cookie": "^3.0.6",
Expand All @@ -50,12 +51,8 @@
"concurrently": "^8.2.2",
"cross-fetch": "^4.0.0",
"eslint": "8.43.0",
"eslint-config-next": "14.0.1",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-prettier": "^4.2.1",
"happy-dom": "^12.10.3",
"lokijs": "^1.5.12",
"prettier": "^2.8.8",
"sentry-testkit": "^5.0.9",
"typescript": "5.4.5"
},
Expand Down
13 changes: 13 additions & 0 deletions apps/frontend-v3/.lintstagedrc.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// https://nextjs.org/docs/pages/building-your-application/configuring/eslint#lint-staged
import baseConfig from '../../.lintstagedrc.cjs'
import path from 'path'

const buildEslintCommand = filenames =>
`next lint --fix --max-warnings 0 --file ${filenames
.map(f => path.relative(process.cwd(), f))
.join(' --file ')}`

export default {
...baseConfig,
'*.{js,jsx,ts,tsx}': [buildEslintCommand, 'bash -c "pnpm run typecheck"'],
}
1 change: 1 addition & 0 deletions apps/frontend-v3/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"@repo/prettier-config"
5 changes: 1 addition & 4 deletions apps/frontend-v3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"@chakra-ui/cli": "^2.4.1",
"@chakra-ui/styled-system": "^2.9.2",
"@repo/eslint-config": "workspace:*",
"@repo/prettier-config": "workspace:*",
"@repo/typescript-config": "workspace:*",
"@sentry/types": "^7.89.0",
"@types/js-cookie": "^3.0.6",
Expand All @@ -50,12 +51,8 @@
"concurrently": "^8.2.2",
"cross-fetch": "^4.0.0",
"eslint": "8.43.0",
"eslint-config-next": "14.0.1",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-prettier": "^4.2.1",
"happy-dom": "^12.10.3",
"lokijs": "^1.5.12",
"prettier": "^2.8.8",
"sentry-testkit": "^5.0.9",
"typescript": "5.4.5"
},
Expand Down
6 changes: 6 additions & 0 deletions packages/eslint-config/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
root: true,
extends: ["@repo/eslint-config/library.js"],
parser: "@typescript-eslint/parser",
};
4 changes: 4 additions & 0 deletions packages/eslint-config/.lintstagedrc.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default {
'*.js': ['eslint --fix'],
'*.{json,js,md}': ['prettier --write'],
};
2 changes: 1 addition & 1 deletion packages/eslint-config/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const project = resolve(process.cwd(), "tsconfig.json");

/** @type {import("eslint").Linter.Config} */
module.exports = {
extends: ["eslint:recommended", "prettier", "turbo"],
extends: ["eslint:recommended", "turbo", "prettier"],
plugins: ["only-warn"],
globals: {
React: true,
Expand Down
46 changes: 23 additions & 23 deletions packages/eslint-config/next.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ const { resolve } = require("node:path");

const project = resolve(process.cwd(), "tsconfig.json");

/** @type {import("eslint").Linter.Config} */
/** @type {import('eslint').Linter.Config} */
module.exports = {
extends: [
"eslint:recommended",
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
"plugin:@typescript-eslint/recommended",
require.resolve("@vercel/style-guide/eslint/next"),
require.resolve("@vercel/style-guide/eslint/react"),
"turbo",
"prettier",
],
globals: {
React: true,
Expand All @@ -20,7 +20,7 @@ module.exports = {
node: true,
browser: true,
},
plugins: ['@typescript-eslint', 'prettier', "only-warn"],
plugins: ["@typescript-eslint", "only-warn"],
settings: {
"import/resolver": {
typescript: {
Expand All @@ -35,36 +35,36 @@ module.exports = {
],
overrides: [{ files: ["*.js?(x)", "*.ts?(x)"] }],
rules: {
'prettier/prettier': 'warn',
curly: ['error', 'multi-line'],
'no-console': ['off'],
'max-len': ['warn', { code: 120, ignoreComments: true, ignoreUrls: true }],
'@typescript-eslint/no-explicit-any': ['off'],
'no-html-link-for-pages': ['off'],
'no-restricted-imports': [
'error',
curly: ["error", "multi-line"],
"no-console": ["off"],
"max-len": ["warn", { code: 120, ignoreComments: true, ignoreUrls: true }],
"@typescript-eslint/no-explicit-any": ["off"],
"no-html-link-for-pages": ["off"],
"no-restricted-imports": [
"error",
{
patterns: [
{
group: ['wagmi'],
importNames: ['useAccount'],
message: 'Use useUserAccount instead to avoid hydration issues',
group: ["wagmi"],
importNames: ["useAccount"],
message: "Use useUserAccount instead to avoid hydration issues",
},
{
group: ['wagmi/dist'],
message: 'Invalid import: remove dist from import path',
group: ["wagmi/dist"],
message: "Invalid import: remove dist from import path",
},
{
group: ['@apollo/client'],
importNames: ['useQuery'],
group: ["@apollo/client"],
importNames: ["useQuery"],
message:
// eslint-disable-next-line max-len
'Import useQuery from @apollo/experimental-nextjs-app-support/ssr to avoid u.inFlightLinkObservables errors',
"Import useQuery from @apollo/experimental-nextjs-app-support/ssr to avoid u.inFlightLinkObservables errors",
},
{
group: ['act'],
importNames: ['react-dom/test-utils'],
message: "Invalid import: import from '@testing-library/react' instead",
group: ["act"],
importNames: ["react-dom/test-utils"],
message:
"Invalid import: import from '@testing-library/react' instead",
},
],
},
Expand Down
8 changes: 4 additions & 4 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
"react-internal.js"
],
"devDependencies": {
"@vercel/style-guide": "^5.2.0",
"eslint-config-turbo": "^2.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-only-warn": "^1.1.0",
"@typescript-eslint/parser": "^7.1.0",
"@typescript-eslint/eslint-plugin": "^7.1.0",
"@vercel/style-guide": "^5.2.0",
"eslint-plugin-only-warn": "^1.1.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-turbo": "^2.0.0",
"typescript": "^5.3.3"
}
}
6 changes: 0 additions & 6 deletions packages/lib/.lintstagedrc.mjs

This file was deleted.

1 change: 1 addition & 0 deletions packages/lib/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"@repo/prettier-config"
8 changes: 4 additions & 4 deletions packages/lib/modules/marketing/useEcosystemPoolActivity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ const getDefaultPoolActivityChartOptions = (
metaData.type === GqlPoolEventType.Add
? 'Add'
: metaData.type === GqlPoolEventType.Remove
? 'Remove'
: 'Swap'
? 'Remove'
: 'Swap'

const arrow = `<svg xmlns="http://www.w3.org/2000/svg" width="9" height="9" fill="none"><path stroke="#718096" stroke-linecap="round" stroke-linejoin="round" d="M2 1h6v6M1 8l7-7"/></svg>`

Expand All @@ -228,8 +228,8 @@ const getDefaultPoolActivityChartOptions = (
<div style="color: ${
toolTipTheme.text
}; display:flex;justify-content:start;align-items:center;gap:6px; margin-bottom:${
index === tokens.length - 1 ? `4px` : `-20px`
}">
index === tokens.length - 1 ? `4px` : `-20px`
}">
<img src="${
token.token?.logoURI
}" style="width: 16px; height: 16px; border-radius: 50%; margin-right;letter-spacing:-0.1px" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ const getDefaultPoolActivityChartOptions = (
<div style="font-size: 14px; font-weight: 700; color: ${
toolTipTheme.text
}; display:flex;justify-content:start;gap:4px;letter-spacing:-0.25px;${
toolTipTheme.heading
};">
toolTipTheme.heading
};">
<span>${data.seriesName}</span>
<span>${currencyFormatter(metaData.usdValue)}</span>
</div>
Expand All @@ -158,8 +158,8 @@ const getDefaultPoolActivityChartOptions = (
<div style="color: ${
toolTipTheme.text
}; display:flex;justify-content:start;align-items:center;gap:6px; margin-bottom:${
index === tokens.length - 1 ? `4px` : `-20px`
}">
index === tokens.length - 1 ? `4px` : `-20px`
}">
<img src="${
token.token?.logoURI
}" style="width: 16px; height: 16px; border-radius: 50%; margin-right;letter-spacing:-0.1px" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,8 @@ export function usePoolCharts() {
activePeriod.value in dataRangeToDaysMap
? dataRangeToDaysMap[activePeriod.value]
: daysSinceMinDataDate > MIN_DISPLAY_PERIOD_DAYS
? daysSinceMinDataDate
: MIN_DISPLAY_PERIOD_DAYS
? daysSinceMinDataDate
: MIN_DISPLAY_PERIOD_DAYS

if (iterateTo === undefined) {
throw new Error("DataRangeToDaysMap doesn't have a value for the selected period")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { balAddress, daiAddress, usdcAddress, usdtAddress, wETHAddress } from '@repo/lib/debug-helpers'
import {
balAddress,
daiAddress,
usdcAddress,
usdtAddress,
wETHAddress,
} from '@repo/lib/debug-helpers'
import { GqlPoolElement } from '@repo/lib/shared/services/api/generated/graphql'
import { aBalWethPoolElementMock } from '@repo/lib/test/msw/builders/gqlPoolElement.builders'
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export function _useAddLiquidity(urlTxHash?: Hash) {
({
tokenAddress: token.address,
humanAmount: '',
} as HumanTokenAmountWithAddress)
}) as HumanTokenAmountWithAddress
)
setHumanAmountsIn(amountsIn)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ export function QuoteBptOut({ label, isLoading = false }: { label?: string; isLo
const _label = label
? label
: proportionalRequired
? 'You will get'
: 'You will get (if no slippage)'
? 'You will get'
: 'You will get (if no slippage)'

return <BptRow label={_label} bptAmount={bptOutUnits} pool={pool} isLoading={isLoading} />
}
17 changes: 10 additions & 7 deletions packages/lib/modules/pool/queries/useUserStakedBalance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,16 @@ function poolContracts(poolByStaking: Record<Address, Pool>, userAddress: Addres
}

function createPoolByStakingRecord(pools: Pool[]): Record<Address, Pool> {
return pools.reduce((acc, pool) => {
const stakingAddresses = getStakingAddresses(pool)
stakingAddresses.forEach(stakingAddress => {
acc[stakingAddress] = pool
})
return acc
}, {} as Record<Address, Pool>)
return pools.reduce(
(acc, pool) => {
const stakingAddresses = getStakingAddresses(pool)
stakingAddresses.forEach(stakingAddress => {
acc[stakingAddress] = pool
})
return acc
},
{} as Record<Address, Pool>
)
}

function getStakingAddresses(pool: Pool): Address[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function useUserUnstakedBalance(pools: Pool[] = []) {
functionName: 'balanceOf',
args: [userAddress as Address],
chainId: getChainId(pool.chain),
} as const)
}) as const
),
})

Expand Down
Loading
Loading