diff --git a/.eslintrc b/.eslintrc index 9c2b88f9b..615dc50a3 100644 --- a/.eslintrc +++ b/.eslintrc @@ -4,22 +4,27 @@ "plugin:@typescript-eslint/recommended", "plugin:@typescript-eslint/recommended-requiring-type-checking" ], - "plugins": ["@typescript-eslint", "prettier"], + "plugins": ["@typescript-eslint"], "env": { "browser": true, "es6": true, "node": true }, "rules": { - "prettier/prettier": "error", "@typescript-eslint/semi": ["error"], - "@typescript-eslint/explicit-function-return-type": "off", - "@typescript-eslint/explicit-module-boundary-types": "off", - "@typescript-eslint/restrict-template-expressions": "off", - "@typescript-eslint/restrict-plus-operands": "off", - "@typescript-eslint/no-unsafe-member-access": "off", + "@typescript-eslint/explicit-function-return-type": "warn", + "@typescript-eslint/explicit-module-boundary-types": "warn", + "@typescript-eslint/restrict-template-expressions": "warn", + "@typescript-eslint/restrict-plus-operands": "warn", + "@typescript-eslint/no-unsafe-member-access": "warn", "@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }], - "no-case-declarations": "off" + "@typescript-eslint/no-misused-promises": "warn", + "@typescript-eslint/no-unsafe-argument": "warn", + "@typescript-eslint/no-unsafe-call": "warn", + "@typescript-eslint/no-unsafe-assignment": "warn", + "@typescript-eslint/no-explicit-any": "warn", + "@typescript-eslint/no-loss-of-precision": "warn", + "no-case-declarations": "warn" }, "parser": "@typescript-eslint/parser", "parserOptions": { diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a5bff2971..0af70682d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,3 +18,4 @@ jobs: - run: cp config.json.example config.json - run: echo '{"version":"","buildLabel":"","matchmakingBuildId":""}' > static/data/buildConfig.json - run: npm run build + - run: npm run lint diff --git a/src/controllers/api/artifactsController.ts b/src/controllers/api/artifactsController.ts index 65041ecad..6b6f6248a 100644 --- a/src/controllers/api/artifactsController.ts +++ b/src/controllers/api/artifactsController.ts @@ -1,4 +1,3 @@ -import { parseString } from "@/src/helpers/general"; import { getJSONfromString } from "@/src/helpers/stringHelpers"; import { getAccountIdForRequest } from "@/src/services/loginService"; import { upgradeMod } from "@/src/services/inventoryService"; diff --git a/src/controllers/api/claimCompletedRecipeController.ts b/src/controllers/api/claimCompletedRecipeController.ts index 291516ef2..522361664 100644 --- a/src/controllers/api/claimCompletedRecipeController.ts +++ b/src/controllers/api/claimCompletedRecipeController.ts @@ -8,7 +8,6 @@ import { IOid } from "@/src/types/commonTypes"; import { getJSONfromString } from "@/src/helpers/stringHelpers"; import { getAccountIdForRequest } from "@/src/services/loginService"; import { getInventory } from "@/src/services/inventoryService"; -import { IInventoryDatabase } from "@/src/types/inventoryTypes/inventoryTypes"; export interface IClaimCompletedRecipeRequest { RecipeIds: IOid[]; diff --git a/src/controllers/api/getGuildDojoController.ts b/src/controllers/api/getGuildDojoController.ts index b38b23a93..cf60ed136 100644 --- a/src/controllers/api/getGuildDojoController.ts +++ b/src/controllers/api/getGuildDojoController.ts @@ -23,7 +23,7 @@ export const getGuildDojoController: RequestHandler = async (req, res) => { CompletionTime: new Date(Date.now()) } ]; - guild.save(); + await guild.save(); } const dojo: IDojoClient = { diff --git a/src/controllers/api/getShipController.ts b/src/controllers/api/getShipController.ts index 3459548ee..f0ba44688 100644 --- a/src/controllers/api/getShipController.ts +++ b/src/controllers/api/getShipController.ts @@ -4,7 +4,6 @@ import allShipFeatures from "@/static/fixed_responses/allShipFeatures.json"; import { getAccountIdForRequest } from "@/src/services/loginService"; import { getPersonalRooms } from "@/src/services/personalRoomsService"; import { getShip } from "@/src/services/shipService"; -import { PersonalRooms } from "@/src/models/personalRoomsModel"; import { Loadout } from "@/src/models/inventoryModels/loadoutModel"; import { logger } from "@/src/utils/logger"; import { toOid } from "@/src/helpers/inventoryHelpers"; diff --git a/src/controllers/api/inventoryController.ts b/src/controllers/api/inventoryController.ts index 368f4823c..a2fed5332 100644 --- a/src/controllers/api/inventoryController.ts +++ b/src/controllers/api/inventoryController.ts @@ -56,7 +56,7 @@ const inventoryController: RequestHandler = async (request: Request, response: R if (config.unlockAllSkins) { inventoryResponse.WeaponSkins = []; - for (let skin of allSkins) { + for (const skin of allSkins) { inventoryResponse.WeaponSkins.push({ ItemId: { $oid: "000000000000000000000000" diff --git a/src/controllers/api/loginController.ts b/src/controllers/api/loginController.ts index 4b0dc26b5..0b9477b1e 100644 --- a/src/controllers/api/loginController.ts +++ b/src/controllers/api/loginController.ts @@ -66,7 +66,7 @@ const loginController: RequestHandler = async (request, response) => { if (account.Nonce == 0 || loginRequest.ClientType != "webui") { account.Nonce = nonce; - account.save(); + await account.save(); } const { email, password, ...databaseAccount } = account.toJSON(); diff --git a/src/controllers/api/logoutController.ts b/src/controllers/api/logoutController.ts index 16181d7fd..735014d4f 100644 --- a/src/controllers/api/logoutController.ts +++ b/src/controllers/api/logoutController.ts @@ -1,14 +1,13 @@ import { RequestHandler } from "express"; import { getAccountIdForRequest } from "@/src/services/loginService"; import { Account } from "@/src/models/loginModel"; -import { IDatabaseAccountDocument } from "@/src/types/loginTypes"; const logoutController: RequestHandler = async (req, res) => { const accountId = await getAccountIdForRequest(req); const account = await Account.findOne({ _id: accountId }); if (account) { account.Nonce = 0; - account.save(); + await account.save(); } res.writeHead(200, { "Content-Type": "text/html", diff --git a/src/controllers/api/updateChallengeProgressController.ts b/src/controllers/api/updateChallengeProgressController.ts index 887224e3d..45490ce3e 100644 --- a/src/controllers/api/updateChallengeProgressController.ts +++ b/src/controllers/api/updateChallengeProgressController.ts @@ -13,7 +13,7 @@ const updateChallengeProgressController: RequestHandler = async (req, res) => { const accountId = await getAccountIdForRequest(req); const inventory = await getInventory(accountId); addChallenges(inventory, payload.ChallengeProgress); - inventory.save(); + await inventory.save(); res.status(200).end(); }; diff --git a/src/controllers/api/upgradesController.ts b/src/controllers/api/upgradesController.ts index f617b70a3..09592daf1 100644 --- a/src/controllers/api/upgradesController.ts +++ b/src/controllers/api/upgradesController.ts @@ -15,7 +15,7 @@ export const upgradesController: RequestHandler = async (req, res) => { operation.UpgradeRequirement == "/Lotus/Types/Items/MiscItems/ModSlotUnlocker" || operation.UpgradeRequirement == "/Lotus/Types/Items/MiscItems/CustomizationSlotUnlocker" ) { - updateCurrency(10, true, accountId); + await updateCurrency(10, true, accountId); } else { addMiscItems(inventory, [ { diff --git a/src/controllers/stats/viewController.ts b/src/controllers/stats/viewController.ts index 2e0145073..033724336 100644 --- a/src/controllers/stats/viewController.ts +++ b/src/controllers/stats/viewController.ts @@ -8,7 +8,7 @@ import allScans from "@/static/fixed_responses/allScans.json"; const viewController: RequestHandler = async (req, res) => { const accountId = await getAccountIdForRequest(req); - const inventory = await Inventory.findOne({ accountOwnerId: req.query.accountId }); + const inventory = await Inventory.findOne({ accountOwnerId: accountId }); if (!inventory) { res.status(400).json({ error: "inventory was undefined" }); return; diff --git a/src/helpers/customHelpers/addItemHelpers.ts b/src/helpers/customHelpers/addItemHelpers.ts index 4371856a2..2b1f464df 100644 --- a/src/helpers/customHelpers/addItemHelpers.ts +++ b/src/helpers/customHelpers/addItemHelpers.ts @@ -1,4 +1,4 @@ -import { isString, parseString } from "@/src/helpers/general"; +import { isString } from "@/src/helpers/general"; import { items } from "@/src/services/itemDataService"; export enum ItemType { diff --git a/src/index.ts b/src/index.ts index 9c2a3e9a6..e82fd2fe1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -20,9 +20,8 @@ const httpsPort = config.httpsPort || 443; // const server = http.createServer(app).listen(80); http.createServer(app).listen(httpPort, () => logger.info("HTTP server started on port " + httpPort)); -const server = https - .createServer(options, app) - .listen(httpsPort, () => logger.info("HTTPS server started on port " + httpsPort)); +const server = https.createServer(options, app); +server.listen(httpsPort, () => logger.info("HTTPS server started on port " + httpsPort)); // server.keepAliveTimeout = 60 * 1000 + 1000; // server.headersTimeout = 60 * 1000 + 2000; diff --git a/src/models/inventoryModels/inventoryModel.ts b/src/models/inventoryModels/inventoryModel.ts index 7efd2ee2f..c6c95ca1b 100644 --- a/src/models/inventoryModels/inventoryModel.ts +++ b/src/models/inventoryModels/inventoryModel.ts @@ -1016,6 +1016,7 @@ type InventoryDocumentProps = { PendingRecipes: Types.DocumentArray; }; +// eslint-disable-next-line @typescript-eslint/ban-types type InventoryModelType = Model; export const Inventory = model("Inventory", inventorySchema); diff --git a/src/models/inventoryModels/loadoutModel.ts b/src/models/inventoryModels/loadoutModel.ts index a9afc0d7e..7bd2aaa18 100644 --- a/src/models/inventoryModels/loadoutModel.ts +++ b/src/models/inventoryModels/loadoutModel.ts @@ -89,6 +89,7 @@ type loadoutDocumentProps = { DRIFTER: Types.DocumentArray; }; +// eslint-disable-next-line @typescript-eslint/ban-types type loadoutModelType = Model; export const Loadout = model("Loadout", loadoutSchema); diff --git a/src/pathman.ts b/src/pathman.ts index 1e1d5127c..0d41bc4b1 100644 --- a/src/pathman.ts +++ b/src/pathman.ts @@ -1,6 +1,7 @@ // Hooks node to support require from "@/" paths for `npm run build && npm run start`. // Based on https://github.com/dividab/tsconfig-paths +/* eslint-disable */ const Module = require("module"); const originalResolveFilename = Module._resolveFilename; Module._resolveFilename = function (request: string, _parent: any): string { diff --git a/src/types/personalRoomsTypes.ts b/src/types/personalRoomsTypes.ts index 68ddec83b..dda71362e 100644 --- a/src/types/personalRoomsTypes.ts +++ b/src/types/personalRoomsTypes.ts @@ -26,4 +26,5 @@ export type PersonalRoomsDocumentProps = { }; }; +// eslint-disable-next-line @typescript-eslint/ban-types export type PersonalRoomsModelType = Model; diff --git a/src/types/requestTypes.ts b/src/types/requestTypes.ts index c58217f00..6693c5983 100644 --- a/src/types/requestTypes.ts +++ b/src/types/requestTypes.ts @@ -80,5 +80,5 @@ export interface IUpgradeOperation { UpgradeRequirement: string; // uniqueName of item being consumed PolarizeSlot: number; PolarizeValue: FocusSchool; - PolarityRemap: {}[]; + PolarityRemap: object[]; }