From aacf1b7c2f4e041d7e1f080e4a6808e4f444a8ca Mon Sep 17 00:00:00 2001 From: Jamie Harding Date: Tue, 1 Oct 2024 09:13:54 +0200 Subject: [PATCH 01/15] package --- package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ab9c82bc..9cbdbd52 100644 --- a/package.json +++ b/package.json @@ -64,8 +64,10 @@ "dev": "node ./scripts/dev-script.js", "start": "next start", "build": "next build", - "lint": "eslint .", + "lint-check": "eslint .", "lint:fix": "eslint . --fix", - "format": "prettier --write ./**/*.{js,jsx,ts,tsx,css,md,json} --config ./.prettierrc.json" + "format-check": "prettier --list-different .", + "format": "prettier --write . --config ./.prettierrc.json", + "lint-format-check": "npm run lint-check && npm run format-check" } } From ab1f432c5200b14597483283229f81ebdaa9d8e3 Mon Sep 17 00:00:00 2001 From: Jamie Harding Date: Tue, 1 Oct 2024 10:14:32 +0200 Subject: [PATCH 02/15] prefer const --- app/_queries/strategyAnalytics.tsx | 2 +- app/_services/getTokenInfo.tsx | 2 +- eslint.config.js | 40 ++++++++++++++++++++---------- 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/app/_queries/strategyAnalytics.tsx b/app/_queries/strategyAnalytics.tsx index 83c1d13c..22d4ce12 100644 --- a/app/_queries/strategyAnalytics.tsx +++ b/app/_queries/strategyAnalytics.tsx @@ -78,7 +78,7 @@ export const transactionAnalytics = (transactionId: string) => ` export const getTransactionAnalyticsData = async (transactionId: string) => { const networks = getNetworkSubgraphs(); // Find which subgraph has the transaction data by checking each subgraph - for (let [network, subgraphUrl] of Object.entries(networks)) { + for (const [network, subgraphUrl] of Object.entries(networks)) { try { const response = await fetch(subgraphUrl, { method: "POST", diff --git a/app/_services/getTokenInfo.tsx b/app/_services/getTokenInfo.tsx index deb54bd2..618bc436 100644 --- a/app/_services/getTokenInfo.tsx +++ b/app/_services/getTokenInfo.tsx @@ -11,7 +11,7 @@ export interface TokenInfo { } export const getTokenInfos = async (yaml: YamlData): Promise => { - let tokenInfos = []; + const tokenInfos = []; for (const [tokenName, token] of Object.entries(yaml.tokens)) { if (!isHex(token.address)) diff --git a/eslint.config.js b/eslint.config.js index 2c7e686e..528a7bcf 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,7 +1,7 @@ import globals from 'globals'; import pluginJs from '@eslint/js'; import tseslint from 'typescript-eslint'; -import pluginReact from 'eslint-plugin-react'; +import reactPlugin from 'eslint-plugin-react'; export default [ { @@ -14,19 +14,10 @@ export default [ '!.env.example', 'pnpm-lock.yaml', 'package-lock.json', - 'yarn.lock' + 'yarn.lock', + '.next' ] }, - { - rules: { - 'no-console': process.env.NODE_ENV === 'production' || process.env.CI ? 'error' : 'off', - 'no-trailing-spaces': 'error', - eqeqeq: 'off', - 'no-unused-vars': 'error', - 'prefer-const': ['error', { ignoreReadBeforeAssign: true }], - 'react/react-in-jsx-scope': 'off' - } - }, { files: ['**/*.{js,mjs,cjs,ts,jsx,tsx}'] }, { @@ -43,7 +34,30 @@ export default [ } } }, + pluginJs.configs.recommended, ...tseslint.configs.recommended, - pluginReact.configs.flat.recommended + reactPlugin.configs.flat.recommended, + reactPlugin.configs.flat['jsx-runtime'], + { + rules: { + 'no-console': process.env.NODE_ENV === 'production' || process.env.CI ? ["error", { allow: ["warn", "error"] }] : 'off', + 'no-trailing-spaces': 'error', + eqeqeq: 'off', + 'prefer-const': ['error', { ignoreReadBeforeAssign: true }], + 'react/react-in-jsx-scope': 'off', + 'react/jsx-filename-extension': ['error', { extensions: ['.js', '.jsx', '.ts', '.tsx'] }], + 'react/prop-types': 'off', + 'react/no-unknown-property': ['error', { ignore: ['tw'] }], + // Disabled for PRs to be merged + 'react/jsx-key': 'off', + '@typescript-eslint/no-unused-vars': 'off', + '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/no-empty-object-type': 'off', + 'no-case-declarations': 'off', + 'react/no-unescaped-entities': 'off', + 'no-unsafe-optional-chaining': 'off', + // 'prefer-const': 'off', + } + } ]; From c2e244805f52d70e8b956832591caff1bc250022 Mon Sep 17 00:00:00 2001 From: Jamie Harding Date: Tue, 1 Oct 2024 10:16:28 +0200 Subject: [PATCH 03/15] no chaining --- app/_services/buttonsData.ts | 10 +++++++--- eslint.config.js | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/_services/buttonsData.ts b/app/_services/buttonsData.ts index 3c83bfbf..a84aa782 100644 --- a/app/_services/buttonsData.ts +++ b/app/_services/buttonsData.ts @@ -76,20 +76,23 @@ export const getDepositPresetsButtons = ( deposit: Deposit, token: TokenInfo ): any[] => { + if (!deposit) { + return []; + } return [ { buttonTarget: "buttonValue", buttonValue: "back", buttonText: "←", }, - ...(deposit?.presets - ? deposit.presets?.map((preset: number) => ({ + ...(deposit.presets + ? deposit.presets.map((preset: number) => ({ buttonTarget: "buttonValue", buttonValue: `${preset}`, buttonText: `${preset} ${token.symbol}`, })) : []), - ...(deposit?.min !== undefined + ...(deposit.min !== undefined ? [ { buttonTarget: "textInputLabel", @@ -101,6 +104,7 @@ export const getDepositPresetsButtons = ( ]; }; + export const generateButtonsData = ( yamlData: YamlData, currentState: FrameState diff --git a/eslint.config.js b/eslint.config.js index 528a7bcf..15570cee 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -56,7 +56,7 @@ export default [ '@typescript-eslint/no-empty-object-type': 'off', 'no-case-declarations': 'off', 'react/no-unescaped-entities': 'off', - 'no-unsafe-optional-chaining': 'off', + // 'no-unsafe-optional-chaining': 'off', // 'prefer-const': 'off', } } From ccbf4c6906abbf247688dd269c3ecc3d330ddbf2 Mon Sep 17 00:00:00 2001 From: Jamie Harding Date: Tue, 1 Oct 2024 10:19:02 +0200 Subject: [PATCH 04/15] escape apostrophes --- app/_components/SubmissionModal.tsx | 6 +++--- eslint.config.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/_components/SubmissionModal.tsx b/app/_components/SubmissionModal.tsx index 88f2a4f1..01026e38 100644 --- a/app/_components/SubmissionModal.tsx +++ b/app/_components/SubmissionModal.tsx @@ -138,8 +138,8 @@ export const SubmissionModal = ({ setError( <>

- You don't have enough {deposit.tokenInfo.symbol} to cover this - deposit. + You don't have enough {deposit.tokenInfo.symbol} to cover this deposit. +

Your balance:{" "} @@ -474,7 +474,7 @@ export const SubmissionModal = ({ Your strategy is live!

- It will continue to trade until removed. If you're interested in + It will continue to trade until removed. If you're interested in creating your own strategies from scratch, try{" "} Raindex.
diff --git a/eslint.config.js b/eslint.config.js index 15570cee..6c6fec4d 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -55,7 +55,7 @@ export default [ '@typescript-eslint/no-explicit-any': 'off', '@typescript-eslint/no-empty-object-type': 'off', 'no-case-declarations': 'off', - 'react/no-unescaped-entities': 'off', + // 'react/no-unescaped-entities': 'off', // 'no-unsafe-optional-chaining': 'off', // 'prefer-const': 'off', } From 6e376a8b03882d88a63a6ca20ed69e84f3218853 Mon Sep 17 00:00:00 2001 From: Jamie Harding Date: Tue, 1 Oct 2024 10:42:27 +0200 Subject: [PATCH 05/15] format --- eslint.config.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index 6c6fec4d..15c112b6 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -41,7 +41,10 @@ export default [ reactPlugin.configs.flat['jsx-runtime'], { rules: { - 'no-console': process.env.NODE_ENV === 'production' || process.env.CI ? ["error", { allow: ["warn", "error"] }] : 'off', + 'no-console': + process.env.NODE_ENV === 'production' || process.env.CI + ? ['error', { allow: ['warn', 'error'] }] + : 'off', 'no-trailing-spaces': 'error', eqeqeq: 'off', 'prefer-const': ['error', { ignoreReadBeforeAssign: true }], @@ -54,7 +57,7 @@ export default [ '@typescript-eslint/no-unused-vars': 'off', '@typescript-eslint/no-explicit-any': 'off', '@typescript-eslint/no-empty-object-type': 'off', - 'no-case-declarations': 'off', + 'no-case-declarations': 'off' // 'react/no-unescaped-entities': 'off', // 'no-unsafe-optional-chaining': 'off', // 'prefer-const': 'off', From 61571e7b4228f722cbff6f2b16fe2bc621b7d89f Mon Sep 17 00:00:00 2001 From: Jamie Harding Date: Tue, 1 Oct 2024 10:44:37 +0200 Subject: [PATCH 06/15] no chain --- app/_services/buttonsData.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/app/_services/buttonsData.ts b/app/_services/buttonsData.ts index 1d6e91ba..db874014 100644 --- a/app/_services/buttonsData.ts +++ b/app/_services/buttonsData.ts @@ -66,21 +66,28 @@ export const getFieldPresetsButtons = (field: Field): any[] => { ]; }; -export const getDepositPresetsButtons = (deposit: Deposit, token: TokenInfo): any[] => { +export const getDepositPresetsButtons = ( + deposit: Deposit | undefined | null, + token: TokenInfo +): any[] => { + if (!deposit) { + return []; + } + return [ { buttonTarget: 'buttonValue', buttonValue: 'back', buttonText: '←' }, - ...(deposit?.presets - ? deposit.presets?.map((preset: number) => ({ + ...(deposit.presets + ? deposit.presets.map((preset: number) => ({ buttonTarget: 'buttonValue', buttonValue: `${preset}`, buttonText: `${preset} ${token.symbol}` })) : []), - ...(deposit?.min !== undefined + ...(deposit.min !== undefined ? [ { buttonTarget: 'textInputLabel', From 71dafb69c04f73ee2b74c0e412991569c92e455e Mon Sep 17 00:00:00 2001 From: Jamie Harding Date: Tue, 1 Oct 2024 10:46:23 +0200 Subject: [PATCH 07/15] const --- app/_queries/strategyAnalytics.tsx | 2 +- app/_services/getTokenInfo.tsx | 2 +- eslint.config.js | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/_queries/strategyAnalytics.tsx b/app/_queries/strategyAnalytics.tsx index 6640c129..1439235c 100644 --- a/app/_queries/strategyAnalytics.tsx +++ b/app/_queries/strategyAnalytics.tsx @@ -78,7 +78,7 @@ export const transactionAnalytics = (transactionId: string) => ` export const getTransactionAnalyticsData = async (transactionId: string) => { const networks = getNetworkSubgraphs(); // Find which subgraph has the transaction data by checking each subgraph - for (let [network, subgraphUrl] of Object.entries(networks)) { + for (const [network, subgraphUrl] of Object.entries(networks)) { try { const response = await fetch(subgraphUrl, { method: 'POST', diff --git a/app/_services/getTokenInfo.tsx b/app/_services/getTokenInfo.tsx index 907ee64e..59db9923 100644 --- a/app/_services/getTokenInfo.tsx +++ b/app/_services/getTokenInfo.tsx @@ -11,7 +11,7 @@ export interface TokenInfo { } export const getTokenInfos = async (yaml: YamlData): Promise => { - let tokenInfos = []; + const tokenInfos = []; for (const [tokenName, token] of Object.entries(yaml.tokens)) { if (!isHex(token.address)) diff --git a/eslint.config.js b/eslint.config.js index 15c112b6..89ba7361 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -57,10 +57,9 @@ export default [ '@typescript-eslint/no-unused-vars': 'off', '@typescript-eslint/no-explicit-any': 'off', '@typescript-eslint/no-empty-object-type': 'off', - 'no-case-declarations': 'off' - // 'react/no-unescaped-entities': 'off', + 'no-case-declarations': 'off', + 'react/no-unescaped-entities': 'off', // 'no-unsafe-optional-chaining': 'off', - // 'prefer-const': 'off', } } ]; From 88f8692ab81c7f24e22859723667122427dffb08 Mon Sep 17 00:00:00 2001 From: Jamie Harding Date: Tue, 1 Oct 2024 10:58:35 +0200 Subject: [PATCH 08/15] apos --- eslint.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eslint.config.js b/eslint.config.js index 89ba7361..3781f232 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -58,7 +58,7 @@ export default [ '@typescript-eslint/no-explicit-any': 'off', '@typescript-eslint/no-empty-object-type': 'off', 'no-case-declarations': 'off', - 'react/no-unescaped-entities': 'off', + 'react/no-unescaped-entities': 'off' // 'no-unsafe-optional-chaining': 'off', } } From 8125bd6ef2b1b598ab753ef3774f2151c0cd5bbd Mon Sep 17 00:00:00 2001 From: Jamie Harding Date: Tue, 1 Oct 2024 10:59:32 +0200 Subject: [PATCH 09/15] unsafe chain --- app/_components/SubmissionModal.tsx | 4 ++-- eslint.config.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/_components/SubmissionModal.tsx b/app/_components/SubmissionModal.tsx index f7db4e6d..8a1124e3 100644 --- a/app/_components/SubmissionModal.tsx +++ b/app/_components/SubmissionModal.tsx @@ -129,7 +129,7 @@ export const SubmissionModal = ({ setError( <>

- You don't have enough {deposit.tokenInfo.symbol} to cover this deposit. + You don't have enough {deposit.tokenInfo.symbol} to cover this deposit.

Your balance: {formatUnits(BigInt(balance), deposit.tokenInfo.decimals)} @@ -426,7 +426,7 @@ export const SubmissionModal = ({

Your strategy is live!
- It will continue to trade until removed. If you're interested in creating your own + It will continue to trade until removed. If you're interested in creating your own strategies from scratch, try Raindex.