Skip to content

Commit

Permalink
eslint 9.2 upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
rylorin committed May 11, 2024
1 parent 0a386de commit cba8e4e
Show file tree
Hide file tree
Showing 9 changed files with 254 additions and 191 deletions.
60 changes: 60 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { fixupPluginRules } from "@eslint/compat";
import eslint from "@eslint/js";
import prettier from "eslint-plugin-prettier/recommended";
import rxjs from "eslint-plugin-rxjs";
// import storybook from "eslint-plugin-storybook";
import tseslint from "typescript-eslint";

export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommended,
prettier,
// storybook.configs.recommended,
{
languageOptions: {
ecmaVersion: 2020,
sourceType: "module",
parserOptions: { project: ["./tsconfig.json", "./tsconfig.server.json"] },
},
plugins: { rxjs: fixupPluginRules(rxjs) },
rules: {
strict: "error",
"no-console": "off",
"no-unsafe-optional-chaining": "error",
"no-unused-vars": "off", // off required as we use the @typescript-eslint/no-unused-vars rule
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
varsIgnorePattern: "^_",
},
],
"@typescript-eslint/ban-types": "error",
"@typescript-eslint/explicit-function-return-type": "error",
"@typescript-eslint/explicit-module-boundary-types": "error",
"@typescript-eslint/no-empty-function": "error",
"@typescript-eslint/no-explicit-any": "off", // We allow explicit any
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-non-null-assertion": "off", // behavior mismatch between TSlint and TScompiler. I make a valid usage of non null assertions
"@typescript-eslint/no-inferrable-types": "error",
"@typescript-eslint/no-misused-promises": "error",
"@typescript-eslint/no-unnecessary-type-assertion": "off", // behavior mismatch between TSlint and TScompiler. giving too many useless errors and we allow unnecessary type assertions
"@typescript-eslint/no-unsafe-argument": "error",
"@typescript-eslint/no-unsafe-assignment": "off", // off for the moment because we have too many warnings
"@typescript-eslint/no-unsafe-call": "error",
"@typescript-eslint/no-unsafe-member-access": "off", // off for the moment because we have too many warnings
"@typescript-eslint/no-unsafe-return": "error",
"@typescript-eslint/require-await": "error",
"@typescript-eslint/restrict-plus-operands": "error",
"@typescript-eslint/restrict-template-expressions": "error",
"@typescript-eslint/unbound-method": "error",
"rxjs/no-async-subscribe": "warn",
"rxjs/no-ignored-observable": "warn",
"rxjs/no-ignored-subscription": "warn",
"rxjs/no-unbound-methods": "warn",
"rxjs/throw-error": "warn",
},
},
{ ignores: ["node_modules/*", "build/*", "dist/*", "**/*.spec.ts", "*.config.mjs"] },
);
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"doc": "typedoc --excludeInternal",
"doc:dev": "typedoc --out ./doc-dev",
"postinstall": "patch-package && yarn build:ib",
"lint": "eslint . --ext .ts,.tsx",
"lint": "eslint ./src",
"prepare": "husky install",
"prepublishOnly": "yarn build",
"qc": "yarn lint && tsc --noEmit && prettier --check . && stylelint \"**/*.css\"",
Expand Down Expand Up @@ -65,6 +65,7 @@
"devDependencies": {
"@babel/core": "^7.24.5",
"@chakra-ui/storybook-addon": "^5.1.0",
"@eslint/compat": "^1.0.1",
"@storybook/addon-actions": "^8.0.10",
"@storybook/addon-essentials": "^8.0.10",
"@storybook/addon-links": "^8.0.10",
Expand All @@ -81,12 +82,10 @@
"@types/react-dom": "^18.3.0",
"@types/react-router-dom": "^5.3.3",
"@types/validator": "^13.11.9",
"@typescript-eslint/eslint-plugin": "^7.4.0",
"@typescript-eslint/parser": "^7.4.0",
"@vitejs/plugin-react": "^4.2.1",
"babel-loader": "^9.1.3",
"concurrently": "^8.2.2",
"eslint": "^8.57.0",
"eslint": "^9.2.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-rxjs": "^5.0.3",
Expand All @@ -102,6 +101,7 @@
"stylelint-config-standard": "^36.0.0",
"ts-node-dev": "^2.0.0",
"typescript": "^5.4.5",
"typescript-eslint": "^7.8.0",
"vite": "^5.2.11",
"webpack": "^5.91.0"
},
Expand Down
2 changes: 1 addition & 1 deletion src/bots/cc.bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class SellCoveredCallsBot extends ITradingBot {
option["yield"] = (option.contract.bid! / option.strike / diffDays) * 360;
// option.stock.contract = await Contract.findByPk(option.stock.id);
}
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion,@typescript-eslint/no-non-null-assertion

options.sort((a: OptionEx, b: OptionEx) => b.yield! - a.yield!);
// for (const option of options) {
// console.log("yield of contract", option["yield"]);
Expand Down
3 changes: 1 addition & 2 deletions src/bots/csp.bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ export class SellCashSecuredPutBot extends ITradingBot {
// RULE 6: check overall margin space
const stock = await StockContract.findByPk(option.stock.id);
if (option.strike * option.multiplier * this.base_rates[option.contract.currency] < max_for_all_symbols) {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion,@typescript-eslint/no-non-null-assertion
if (option.impliedVolatility! > stock!.historicalVolatility!) {
// RULE 1: implied volatility > historical volatility
// const expiry: Date = new Date(option.lastTradeDate);
Expand All @@ -177,7 +176,7 @@ export class SellCashSecuredPutBot extends ITradingBot {
}
}
// order by yield
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion,@typescript-eslint/no-non-null-assertion

filtered_options.sort((a: OptionEx, b: OptionEx) => b.yield! - a.yield!);
if (filtered_options.length > 0) {
console.log("filtered_options:", filtered_options.length);
Expand Down
4 changes: 2 additions & 2 deletions src/bots/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ export class ITradingBot extends EventEmitter {
throw { name: "ITradingBotNotImplemented", message } as Error;
}
}
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion,@typescript-eslint/no-non-null-assertion

if (!transaction_) await transaction!.commit();
} catch (err: any) {
if (err.name == "IBApiNextError") {
Expand All @@ -976,7 +976,7 @@ export class ITradingBot extends EventEmitter {
if (err.name == "SequelizeTimeoutError") this.app.stop();
}
// rollback changes
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion,@typescript-eslint/no-non-null-assertion

if (!transaction_) await transaction!.rollback();
// and propagate exception
throw err;
Expand Down
6 changes: 2 additions & 4 deletions src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
* Logging facility
* @author Guerrilla Team
*/
/* eslint-disable no-console */
/* eslint-disable @typescript-eslint/no-explicit-any */
import stringify from "json-stringify-safe";
import { exit } from "process";
import winston, { Logger as WinstonLogger, createLogger, format, transports } from "winston";

import dotenv from "dotenv";
dotenv.config(); // eslint-disable-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-call
dotenv.config();

export const LogLevel = {
Fatal: 0,
Expand Down Expand Up @@ -132,7 +130,7 @@ class Logger {
else if (value === null) return "null";
else if (typeof value === "string") return value.replaceAll("\n", "\\n");
else if (typeof value === "number") return String(value);
else return stringify(value as any) as string; // eslint-disable-line @typescript-eslint/no-unsafe-call
else return stringify(value as any) as string;
// Object.entries(value).
}

Expand Down
2 changes: 1 addition & 1 deletion src/routers/statements.router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { updateTradeDetails } from "./trades.utils";

const MODULE = "StatementsRouter";

// eslint-disable-next-line @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unused-vars
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
const sequelize_logging = (...args: any[]): void => logger.trace(MODULE + ".squelize", ...args);

const router = express.Router({ mergeParams: true });
Expand Down
10 changes: 5 additions & 5 deletions tsconfig.server.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "dist",
"module": "commonjs",
"noEmit": false
},
// "compilerOptions": {
// "outDir": "./dist",
// "module": "ESNext",
// "noEmit": false
// },
"include": ["./src"],
"exclude": ["./src/app"]
}
Loading

0 comments on commit cba8e4e

Please sign in to comment.