Skip to content

Commit

Permalink
feat: fixed eslint & improved package.json structure
Browse files Browse the repository at this point in the history
  • Loading branch information
k0beLeenders committed Feb 17, 2025
1 parent f403f8a commit eadb10c
Show file tree
Hide file tree
Showing 27 changed files with 291 additions and 605 deletions.
16 changes: 14 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
// .eslintrc.js
module.exports = {
root: true,
// This tells ESLint to load the config from the package `eslint-config-custom`
extends: ["@mrgnlabs/eslint-config-custom"],
extends: [
"next", // Next.js recommended rules
"turbo", // Turbo repo rules (if applicable)
"prettier" // Disable ESLint rules that might conflict with Prettier
],
rules: {
// Keep your previous customizations
"@next/next/no-html-link-for-pages": "off",
"react/jsx-key": "off",
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
},
settings: {
// This ensures that ESLint knows where your Next.js apps live
next: {
rootDir: ["apps/*/"],
},
Expand Down
1 change: 0 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
store-dir=~/.pnpm-store
shamefully-hoist=true
node-linker=hoisted
2 changes: 0 additions & 2 deletions apps/alpha-liquidator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@
"dependencies": {
"@jup-ag/core": "^4.0.0-beta.20",
"@mongodb-js/zstd": "^1.1.0",
"@mrgnlabs/eslint-config-custom": "workspace:*",
"@mrgnlabs/marginfi-client-v2": "workspace:*",
"@mrgnlabs/mrgn-common": "workspace:*",
"@mrgnlabs/tsconfig": "workspace:*",
"@saberhq/solana-contrib": "1.13.6",
"@saberhq/token-utils": "1.13.6",
"@sentry/node": "^7.40.0",
Expand Down
2 changes: 0 additions & 2 deletions apps/health-notifier/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
"@dialectlabs/blockchain-sdk-solana": "^1.2.0",
"@dialectlabs/monitor": "^3.4.2",
"@dialectlabs/sdk": "^1.9.1",
"@mrgnlabs/eslint-config-custom": "workspace:*",
"@mrgnlabs/marginfi-client-v2": "workspace:*",
"@mrgnlabs/mrgn-common": "workspace:*",
"@mrgnlabs/tsconfig": "workspace:*",
"@sentry/node": "^7.40.0",
"@solana/buffer-layout": "4.0.0",
"@solana/buffer-layout-utils": "~0.2.0",
Expand Down
3 changes: 0 additions & 3 deletions apps/marginfi-landing-page/.eslintrc.json

This file was deleted.

4 changes: 1 addition & 3 deletions apps/marginfi-landing-page/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,14 @@
"tailwind-merge": "^1.14.0",
"zod": "^3.23.8"
},
"devDependencies": {
"@mrgnlabs/eslint-config-custom": "workspace:*",
"devDependencies": {
"@mrgnlabs/tsconfig": "workspace:*",
"@types/lodash.debounce": "^4.0.7",
"@types/lodash.random": "^3.2.9",
"@types/lodash.shuffle": "^4.2.9",
"@types/node": "^20.12.2",
"@types/react": "^18.2.61",
"@types/react-dom": "^18.2.19",
"eslint": "8.30.0",
"postcss": "^8",
"tailwindcss": "^3.4.1",
"typescript": "^5"
Expand Down
3 changes: 0 additions & 3 deletions apps/marginfi-v2-docs/.eslintrc.json

This file was deleted.

7 changes: 1 addition & 6 deletions apps/marginfi-v2-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,9 @@
"zustand": "^4.3.2"
},
"devDependencies": {
"@mrgnlabs/eslint-config-custom": "workspace:*",
"@mrgnlabs/tsconfig": "workspace:*",
"@types/katex": "^0.16.7",
"@types/react-katex": "^3.0.4",
"eslint": "^8.56.0",
"eslint-config-next": "^14.0.4",
"prettier": "^3.1.1",
"prettier-plugin-tailwindcss": "^0.5.11",
"@mrgnlabs/tsconfig": "workspace:*",
"sharp": "0.33.1"
}
}
3 changes: 0 additions & 3 deletions apps/marginfi-v2-trading/.eslintrc.json

This file was deleted.

3 changes: 0 additions & 3 deletions apps/marginfi-v2-trading/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@
"zustand": "^4.4.1"
},
"devDependencies": {
"@mrgnlabs/eslint-config-custom": "workspace:*",
"@mrgnlabs/tsconfig": "workspace:*",
"@tailwindcss/typography": "^0.5.10",
"@types/bn.js": "^5.1.6",
Expand All @@ -115,10 +114,8 @@
"@types/react-dom": "^18.2.19",
"@types/uuid": "^9.0.2",
"autoprefixer": "^10.4.13",
"eslint": "8.30.0",
"next-transpile-modules": "^10.0.0",
"postcss": "^8.4.20",
"prettier": "^2.8.1",
"tailwindcss": "^3.2.4",
"typescript": "5"
}
Expand Down
3 changes: 0 additions & 3 deletions apps/marginfi-v2-ui/.eslintrc.json

This file was deleted.

20 changes: 18 additions & 2 deletions apps/marginfi-v2-ui/next.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const path = require("path");

const withPWA = require("next-pwa")({
dest: "public",
disable: process.env.NODE_ENV === "development",
Expand Down Expand Up @@ -28,10 +30,24 @@ let config = withBundleAnalyzer({
// },
// ];
// },
transpilePackages: ["@mrgnlabs/marginfi-client-v2", "@mrgnlabs/mrgn-common", "@mrgnlabs/lip-client"],
transpilePackages: [
"@mrgnlabs/marginfi-client-v2",
"@mrgnlabs/mrgn-common",
"@mrgnlabs/lip-client",
"@mrgnlabs/mrgn-utils",
"@mrgnlabs/mrgn-ui",
],
reactStrictMode: true,
experimental: {
externalDir: true,
},
webpack: (config) => {
config.resolve.alias["@solana/spl-token-0.4"] = require.resolve("@solana/spl-token");
config.resolve.alias = {
...config.resolve.alias,
"@solana/wallet-adapter-react": path.resolve(__dirname, "node_modules/@solana/wallet-adapter-react"),
react: path.resolve(__dirname, "node_modules/react"),
"react-dom": path.resolve(__dirname, "node_modules/react-dom"),
};
config.resolve.fallback = {
fs: false,
path: false,
Expand Down
3 changes: 0 additions & 3 deletions apps/marginfi-v2-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
"zustand": "^4.4.1"
},
"devDependencies": {
"@mrgnlabs/eslint-config-custom": "workspace:*",
"@mrgnlabs/tsconfig": "workspace:*",
"@tailwindcss/typography": "^0.5.10",
"@types/bn.js": "^5.1.6",
Expand All @@ -111,13 +110,11 @@
"@types/react-dom": "^18.2.19",
"@types/uuid": "^9.0.2",
"autoprefixer": "^10.4.13",
"eslint": "8.30.0",
"grpc-tools": "^1.12.3",
"next-transpile-modules": "^10.0.0",
"node-cache": "^5.1.2",
"node-fetch": "^2.6.7",
"postcss": "^8.4.20",
"prettier": "^2.8.1",
"tailwindcss": "^3.2.4",
"tailwind-merge": "^1.14.0",
"protoc-gen-ts": "^0.8.5",
Expand Down
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@
},
"devDependencies": {
"@jest/globals": "^29.7.0",
"@mrgnlabs/eslint-config-custom": "workspace:*",
"@types/jest": "^29.5.12",
"eslint": "^9.20.1",
"eslint-config-next": "^15.1.7",
"eslint-config-prettier": "^10.0.1",
"eslint-plugin-react": "7.37.4",
"eslint-plugin-react-hooks": "^5.2.0-canary-e670e72f-20250214",
"jest": "^29.7.0",
"prettier": "^2.8.1",
"prettier": "^3.5.1",
"rimraf": "^4.4.0",
"ts-jest": "^29.1.5",
"turbo": "1.13.4",
Expand All @@ -47,7 +51,8 @@
"node": ">=20.0.0"
},
"dependencies": {
"@changesets/cli": "^2.26.0"
"@changesets/cli": "^2.26.0",
"debug": "^4.4.0"
},
"packageManager": "pnpm@10.3.0",
"pnpm": {
Expand Down
4 changes: 1 addition & 3 deletions packages/lip-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"build": "tsc -p tsconfig.json"
},
"dependencies": {
"@mrgnlabs/tsconfig": "workspace:*",
"@coral-xyz/anchor": "^0.30.1",
"@mrgnlabs/marginfi-client-v2": "workspace:*",
"@mrgnlabs/mrgn-common": "workspace:*",
Expand All @@ -24,10 +25,7 @@
"superstruct": "^1.0.3"
},
"devDependencies": {
"@mrgnlabs/eslint-config-custom": "workspace:*",
"@mrgnlabs/tsconfig": "workspace:*",
"@types/node": "^18.15.0",
"eslint": "^7.32.0",
"ts-node": "^10.9.1",
"typescript": "^4.5.2"
},
Expand Down
4 changes: 1 addition & 3 deletions packages/marginfi-client-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,13 @@
"superstruct": "^1.0.4"
},
"devDependencies": {
"@jup-ag/api": "^6.0.38",
"@mrgnlabs/eslint-config-custom": "workspace:*",
"@mrgnlabs/tsconfig": "workspace:*",
"@jup-ag/api": "^6.0.38",
"@types/big.js": "^6.2.2",
"@types/bn.js": "^5.1.5",
"@types/debug": "^4.1.12",
"@types/inquirer": "^9.0.7",
"big.js": "^6.2.1",
"eslint": "^9.5.0",
"inquirer": "^9.2.23",
"ts-node": "^10.9.2",
"typedoc": "^0.26.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export function formatTransactions(

const flashloanIndex = getFlashloanIndex(transactionsArg);
transactionsArg.forEach((tx) => {
if (!isV0Tx(tx)) {
if (!isV0Tx(tx)) {
tx.recentBlockhash = blockhash;
tx.feePayer = feePayer;
}
Expand Down
2 changes: 0 additions & 2 deletions packages/marginfi-v2-ui-state/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@
"zustand": "^4.4.1"
},
"devDependencies": {
"@mrgnlabs/eslint-config-custom": "workspace:*",
"@mrgnlabs/tsconfig": "workspace:*",
"@types/uuid": "^9.0.2",
"eslint": "^7.32.0",
"ts-node": "^10.9.1",
"typescript": "^4.5.2"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ async function fetchGroupData(
tokenDatas: Map<string, MintData>;
feedIdMap: PythPushFeedIdMap;
}> {
const debug = require("debug")("mfi:client");
// Fetch & shape all accounts of Bank type (~ bank discovery)
let bankDatasKeyed: { address: PublicKey; data: BankRaw }[] = [];
if (bankAddresses && bankAddresses.length > 0) {
debug("Using preloaded bank addresses, skipping gpa call", bankAddresses.length, "banks");
let bankAccountsData = await program.account.bank.fetchMultiple(bankAddresses);
for (let i = 0; i < bankAccountsData.length; i++) {
if (bankAccountsData[i] !== null) {
Expand Down Expand Up @@ -154,8 +152,6 @@ async function fetchGroupData(
})
);

debug("Fetched %s banks and %s price feeds", banks.size, priceInfos.size);

return {
marginfiGroup,
banks,
Expand All @@ -165,4 +161,4 @@ async function fetchGroupData(
};
}

export { fetchGroupData };
export { fetchGroupData };
5 changes: 1 addition & 4 deletions packages/marginfi-v2-ui-state/src/store/mrgnlendStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ async function getCachedMarginfiAccountsForAuthority(
authority: PublicKey,
client: MarginfiClient
): Promise<MarginfiAccountWrapper[]> {
const debug = require("debug")("mfi:getCachedMarginfiAccountsForAuthority");
if (typeof window === "undefined") {
return client.getMarginfiAccountsForAuthority(authority);
}
Expand All @@ -132,7 +131,6 @@ async function getCachedMarginfiAccountsForAuthority(
cachedAccounts = JSON.parse(cachedAccountsStr);
}

debug("cachedAccounts", cachedAccounts);
if (cachedAccounts && cachedAccounts.length > 0) {
const accountAddresses: PublicKey[] = cachedAccounts.reduce((validAddresses: PublicKey[], address: string) => {
try {
Expand All @@ -147,7 +145,6 @@ async function getCachedMarginfiAccountsForAuthority(

// Update local storage with valid addresses only
window.localStorage.setItem(cacheKey, JSON.stringify(accountAddresses.map((addr) => addr.toString())));
debug("Loading ", accountAddresses.length, "accounts from cache");
return client.getMultipleMarginfiAccounts(accountAddresses);
} else {
const accounts = await client.getMarginfiAccountsForAuthority(authority);
Expand Down Expand Up @@ -229,7 +226,7 @@ const stateCreator: StateCreator<MrgnlendState, [], []> = (set, get) => ({

const stageTokens = args?.stageTokens ?? get().stageTokens;

const isReadOnly = args?.isOverride !== undefined ? args.isOverride : get().marginfiClient?.isReadOnly ?? false;
const isReadOnly = args?.isOverride !== undefined ? args.isOverride : (get().marginfiClient?.isReadOnly ?? false);
const bundleSimRpcEndpoint = args?.bundleSimRpcEndpoint ?? get().bundleSimRpcEndpoint ?? undefined;
const processTransactionStrategy =
args?.processTransactionStrategy ?? get().processTransactionStrategy ?? undefined;
Expand Down
2 changes: 0 additions & 2 deletions packages/mrgn-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@
"superstruct": "^1.0.4"
},
"devDependencies": {
"@mrgnlabs/eslint-config-custom": "workspace:*",
"@mrgnlabs/tsconfig": "workspace:*",
"@types/numeral": "^2.0.5",
"eslint": "^9.5.0",
"ts-node": "^10.9.2",
"typescript": "^5.5.2"
},
Expand Down
3 changes: 0 additions & 3 deletions packages/mrgn-ui/.eslintrc.json

This file was deleted.

22 changes: 10 additions & 12 deletions packages/mrgn-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@
"@solana/buffer-layout": "^4.0.1",
"@solana/buffer-layout-utils": "^0.2.0",
"@solana/spl-stake-pool": "^0.6.5",
"@solana/wallet-adapter-base": "^0.9.23",
"@solana/wallet-adapter-react": "^0.15.35",
"@solana/web3.js": "^1.93.2",
"@solana/spl-token": "^0.3.8",
"@tabler/icons-react": "^3.3.0",
Expand All @@ -61,12 +59,10 @@
"cmdk": "^0.2.0",
"decimal.js": "^10.4.3",
"embla-carousel-react": "^8.1.6",
"eslint": "8.30.0",
"lottie-react": "^2.4.0",
"lucide-react": "^0.475.0",
"minidenticons": "^4.2.0",
"numeral": "^2.0.6",
"react": "18.2.0",
"numeral": "^2.0.6",
"react-confetti": "^6.1.0",
"react-cookie": "^6.1.1",
"react-copy-to-clipboard": "^5.1.0",
Expand All @@ -81,25 +77,27 @@
"zustand": "^4.4.1"
},
"devDependencies": {
"@mrgnlabs/eslint-config-custom": "workspace:*",
"@mrgnlabs/tsconfig": "workspace:*",
"@types/numeral": "^2.0.5",
"@types/react": "^18.2.61",
"@types/react-copy-to-clipboard": "^5.0.5",
"@types/uuid": "^9.0.2",
"eslint": "^9.5.0",
"ts-node": "^10.9.2",
"typescript": "^5.5.2",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"@solana/wallet-adapter-base": "^0.9.23",
"@solana/wallet-adapter-react": "^0.15.35",
"react": "18.2.0",
"react-dom": "18.2.0",
"next": "14.2.21"
},
"publishConfig": {
"access": "public"
},
"peerDependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0",
"@solana/wallet-adapter-base": "^0.9.23",
"@solana/wallet-adapter-react": "^0.15.35"
"@solana/wallet-adapter-react": "^0.15.35",
"react": "18.2.0",
"react-dom": "18.2.0",
"next": "14.2.21"
}
}
Loading

0 comments on commit eadb10c

Please sign in to comment.