Skip to content

Commit

Permalink
Eslint upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielSchiavini committed Sep 4, 2024
1 parent 845fe5a commit 319bcf8
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 73 deletions.
40 changes: 0 additions & 40 deletions .eslintrc.json

This file was deleted.

86 changes: 86 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import globals from "globals";
import parser from "vue-eslint-parser";
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import tsParser from "@typescript-eslint/parser";
import path from "node:path";
import {fileURLToPath} from "node:url";
import js from "@eslint/js";
import {FlatCompat} from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});

export default [...compat.extends("eslint:recommended"), {
languageOptions: {
globals: {
...globals.browser,
},

parser: parser,
ecmaVersion: 5,
sourceType: "module",

parserOptions: {
parser: "babel-eslint",
allowImportExportEverywhere: false,
},
},

rules: {
"func-names": 0,
"no-nested-ternary": 0,
"max-len": 0,
"arrow-parens": ["error", "always"],
"no-underscore-dangle": 0,

"comma-dangle": ["error", {
arrays: "always-multiline",
objects: "always-multiline",
imports: "always-multiline",
exports: "always-multiline",
functions: "never",
}],

"no-use-before-define": ["error", "nofunc"],

"no-empty": ["error", {
allowEmptyCatch: true,
}],

"no-mixed-operators": ["error", {
allowSamePrecedence: true,
}],

indent: ["error", 4, {
flatTernaryExpressions: true,
SwitchCase: 1,
}],
},
}, ...compat.extends(
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
).map(config => ({
...config,
files: ["**/*.ts"],
})), {
files: ["**/*.ts"],

plugins: {
"@typescript-eslint": typescriptEslint,
},

languageOptions: {
parser: tsParser,
},

rules: {
"@typescript-eslint/ban-ts-comment": "warn",
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/no-explicit-any": "warn",
},
}];
49 changes: 21 additions & 28 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
"scripts": {
"build": "rm -rf lib && tsc -p tsconfig.build.json",
"test": "tsc && mocha dist/test",
"lint": "eslint src --ext .ts"
"lint": "eslint src"
},
"type": "module",
"devDependencies": {
"@babel/eslint-parser": "^7.25.1",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.9.1",
"@types/chai": "^4.3.18",
"@types/memoizee": "^0.4.11",
"@types/mocha": "^10.0.7",
Expand All @@ -29,6 +31,7 @@
"@typescript-eslint/parser": "^8.2.0",
"chai": "^5.1.1",
"eslint": "^9.9.1",
"globals": "^15.9.0",
"hardhat": "^2.22.10",
"mocha": "^10.7.3",
"typescript": "^5.5.4",
Expand Down
6 changes: 3 additions & 3 deletions src/external-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export const _getFactoryAPYs = memoize(
const [{data: data0}, {data: data1}] = await Promise.all([
fetch(urlStable),
fetch(urlCrypto),
].map(r => r.then(r => r.json() as any)));
].map((r) => r.then((r) => r.json() as any)));

const stableVolume = data0.totalVolumeUsd || data0.totalVolume || 0;
const cryptoVolume = data1.totalVolumeUsd || data1.totalVolume || 0;
Expand All @@ -104,12 +104,12 @@ export const _getFactoryAPYs = memoize(
address: item.poolAddress,
volumeUSD: item.totalVolumeUsd ?? 0,
day: item.apy ?? 0,
week: item.apy * 7 ?? 0, //Because api does not return week apy
week: (item.apy ?? 0) * 7, //Because api does not return week apy
}))

return {
poolsData: poolsData ?? [],
totalVolume: stableVolume + cryptoVolume ?? 0,
totalVolume: stableVolume + cryptoVolume,
cryptoVolume: cryptoVolume ?? 0,
cryptoShare: 100*cryptoVolume/(stableVolume + cryptoVolume) || 0,
};
Expand Down
2 changes: 1 addition & 1 deletion src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ const _getBestRoute = memoize(
const [gasAmounts, outputCoinUsdRate, {data: gasData}, ethUsdRate] = await Promise.all([
_estimateGasForDifferentRoutes(routes.map((r) => r.route), inputCoinAddress, outputCoinAddress, _amount),
_getUsdRate(outputCoinAddress),
fetch("https://api.curve.fi/api/getGas").then(r => r.json() as any),
fetch("https://api.curve.fi/api/getGas").then((r) => r.json() as any),
_getUsdRate(ETH_ADDRESS),
]);
const gasPrice = gasData.gas.standard;
Expand Down

0 comments on commit 319bcf8

Please sign in to comment.