Skip to content

Commit

Permalink
[Lint] Remove inconsequential violations of no-unused-vars (#175)
Browse files Browse the repository at this point in the history
Leaving behind instances that are due to unresolved questions.

Fixes 58 ES lint errors. 38 to go till #162 is complete :-)

[1]: #162
  • Loading branch information
dchege711 authored Jun 15, 2024
1 parent a884d5a commit 23bf3fa
Show file tree
Hide file tree
Showing 14 changed files with 24 additions and 63 deletions.
2 changes: 1 addition & 1 deletion src/controllers/AuthenticationController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export function registerUser(req: Request, res: Response) {
});
}

export function loginUser(req: Request, res: Response, next: NextFunction) {
export function loginUser(req: Request, res: Response) {
LogInUtilities
.authenticateUser(req.body)
.then((user) => {
Expand Down
6 changes: 0 additions & 6 deletions src/controllers/ControllerUtilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ import { AuthenticateUser } from "../models/LogInUtilities";
import { ICard } from "../models/mongoose_models/CardSchema";
import * as allPaths from "../paths";

const generic_500_msg = {
success: false,
status: 500,
message: "Internal Server Error",
};

interface TemplateVariables {
APP_NAME: string;
BASE_URL: string;
Expand Down
3 changes: 0 additions & 3 deletions src/controllers/InAppController.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
"use strict";

import { Request, Response } from "express";
import { StatusCodes } from "http-status-codes";

import * as config from "../config";
import * as CardsDB from "../models/CardsMongoDB";
import * as loginUtilities from "../models/LogInUtilities";
import * as MetadataDB from "../models/MetadataMongoDB";
import { MiniICard } from "../models/mongoose_models/CardSchema";
Expand Down
2 changes: 0 additions & 2 deletions src/models/DailyTasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
* @module
*/

import * as mongoDB from "mongodb";

import { IStreak, Metadata } from "./mongoose_models/MetadataCardSchema";
import { closeMongooseConnection } from "./MongooseClient";

Expand Down
3 changes: 1 addition & 2 deletions src/models/EmailClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import { createTransport } from "nodemailer";

import Mail = require("nodemailer/lib/mailer");
import SMTPPool = require("nodemailer/lib/smtp-pool");

import {
APP_NAME,
Expand Down Expand Up @@ -41,7 +40,7 @@ const transporter = createTransport({
*/
export function sendEmail(mailOptions: Mail.Options): Promise<void> {
mailOptions.from = `${APP_NAME} <${EMAIL_ADDRESS}>`;
return transporter.sendMail(mailOptions).then((_) => {});
return transporter.sendMail(mailOptions).then(() => {});
}

/**
Expand Down
10 changes: 2 additions & 8 deletions src/models/LogInUtilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import * as stanfordCrypto from "sjcl";
import * as config from "../config";
import { APP_NAME } from "../config";
import { UserRecoverableError } from "../errors";
import { BaseResponse } from "../types";
import { createMany } from "./CardsMongoDB";
import * as Email from "./EmailClient";
import { Card } from "./mongoose_models/CardSchema";
Expand All @@ -29,7 +28,7 @@ const UPPER_CASE = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
* @description Clean up resources before exiting the script.
*/
export function close() {
return new Promise(function(resolve, reject) {
return new Promise(function(resolve) {
Email.close();
resolve(null);
});
Expand Down Expand Up @@ -205,7 +204,7 @@ export async function sendAccountValidationLink(
return `${payload.email} has already validated their account.`;
}

const { userIDInApp, validationURI } = await getIdInAppAndValidationURI();
const { validationURI } = await getIdInAppAndValidationURI();
user.account_validation_uri = validationURI;
await user.save();

Expand Down Expand Up @@ -513,11 +512,6 @@ export async function sendResetLink(
return `We've sent a reset link to ${userIdentifier.email} that is valid for 2 hours.`;
}

type PasswordResetLinkResponse = BaseResponse & {
message: string;
redirect_url?: string;
};

/**
* Resolves the promise if `resetPasswordURI` is valid and hasn't expired.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { css, html, LitElement } from "lit";
import { customElement, property, query } from "lit/decorators.js";
import { customElement, property } from "lit/decorators.js";
import { CardChangedEvent } from "./card-changed-event.js";

@customElement("cg-card-privacy-toggle")
Expand Down
4 changes: 2 additions & 2 deletions src/public/src/components/search-bar/search-bar.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { css, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators.js";
import { createRef, Ref, ref } from "lit/directives/ref.js";
import { customElement, state } from "lit/decorators.js";
import { createRef, Ref } from "lit/directives/ref.js";

import { SearchResultsChangedEvent } from "../../context/search-results-context.js";
import {
Expand Down
13 changes: 4 additions & 9 deletions src/public/src/pages/common/cards-viewing-page.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { provide } from "@lit/context";
import { css, html, LitElement } from "lit";
import { customElement, property, state } from "lit/decorators.js";
import { css, LitElement } from "lit";
import { state } from "lit/decorators.js";

import {
cardsCarouselContext,
Expand All @@ -10,17 +10,12 @@ import {
import {
kSearchResultsChangedEventName,
kSearchResultSelectedEventName,
SearchResultsChangedEvent,
searchResultsContext,
SearchResultSelectedEvent,
} from "../../context/search-results-context.js";
import { tagsAutoCompleteContext } from "../../context/tags-auto-complete-context.js";
import { AutoComplete } from "../../models/auto-complete.js";
import {
CardsCarousel,
CardsCarouselBSTKey,
} from "../../models/cards-carousel.js";
import { Card, CardFetchEndpoint, CardSearchResult, trpc } from "../../trpc.js";
import { CardsCarousel } from "../../models/cards-carousel.js";
import { Card, CardFetchEndpoint, CardSearchResult } from "../../trpc.js";

import "../../components/search-bar/search-bar.js";
import "../../components/search-results/search-results.js";
Expand Down
15 changes: 0 additions & 15 deletions src/routes/InAppRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,10 @@ import {
} from "../controllers/InAppController";
import {
ACCOUNT,
ADD_CARD,
BROWSE,
DELETE_ACCOUNT,
DELETE_CARD,
DOWNLOAD_USER_DATA,
DUPLICATE_CARD,
FLAG_CARD,
HOME,
READ_CARD,
READ_METADATA,
READ_PUBLIC_CARD,
READ_PUBLIC_METADATA,
READ_TAG_GROUPS,
RESTORE_CARD_FROM_TRASH,
SEARCH_CARDS,
TRASH_CARD,
UPDATE_CARD,
UPDATE_STREAK,
UPDATE_USER_SETTINGS,
WIKI,
} from "../paths";

Expand Down
9 changes: 4 additions & 5 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
*/

import * as trpcExpress from "@trpc/server/adapters/express";
import { NextFunction, Request, Response } from "express";
import { Request, Response } from "express";

import { IS_DEV } from "./config";
import { createContext } from "./context";
import { getDefaultTemplateVars } from "./controllers/ControllerUtilities";
import * as allPaths from "./paths";
import { inAppRouter } from "./routes/InAppRouter";
import { populateDummyAccountWithCards } from "./tests/DummyAccountUtils";
import { mergeRouters, publicProcedure, router } from "./trpc";
import { mergeRouters } from "./trpc";

const express = require("express");
const session = require("express-session");
Expand Down Expand Up @@ -107,7 +106,7 @@ if (config.IS_TS_NODE) {
app.use(express.static(newStaticsPath));
}

app.use(function(err: any, req: Request, res: Response, next: NextFunction) {
app.use(function(err: any, req: Request, res: Response) {
console.error(err.stack);
res.status(500).render(
"pages/5xx_error_page.ejs",
Expand All @@ -119,7 +118,7 @@ app.use(function(err: any, req: Request, res: Response, next: NextFunction) {
});

// Handling 404: https://expressjs.com/en/starter/faq.html
app.use(function(req: Request, res: Response, next: NextFunction) {
app.use(function(req: Request, res: Response) {
res.status(404).render(
"pages/4xx_error_page.ejs",
{
Expand Down
6 changes: 3 additions & 3 deletions src/tests/DummyAccountUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ export async function getDummyAccount(): Promise<

return LogInUtilities
.deleteAllAccounts([])
.then((_) => {
.then(() => {
return addPublicUser();
})
.then((_) => {
.then(() => {
return LogInUtilities.registerUserAndPassword(dummyAccountDetails);
})
.then((_) => {
.then(() => {
return LogInUtilities.authenticateUser({
username_or_email: dummyAccountDetails.username,
password: dummyAccountDetails.password,
Expand Down
8 changes: 4 additions & 4 deletions src/tests/mocha_tests/functionality_tests/TestLogIn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe("Test LoginUtilities\n", function() {
.then(function(signupResult) {
done(new Error(signupResult));
})
.catch(function(_: Error) {
.catch(function() {
done();
});
});
Expand All @@ -43,7 +43,7 @@ describe("Test LoginUtilities\n", function() {
.then(function(signupResult) {
done(new Error(signupResult));
})
.catch(function(_: Error) {
.catch(function() {
done();
});
});
Expand Down Expand Up @@ -71,7 +71,7 @@ describe("Test LoginUtilities\n", function() {
.then(function(signupResult) {
done(new Error(signupResult));
})
.catch(function(_: Error) {
.catch(function() {
done();
});
},
Expand All @@ -89,7 +89,7 @@ describe("Test LoginUtilities\n", function() {
.then(function(signupResult) {
done(new Error(signupResult));
})
.catch(function(_: Error) {
.catch(function() {
done();
});
},
Expand Down
4 changes: 2 additions & 2 deletions src/tests/mocha_tests/unit_tests/TestCardsMongoDB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe("Test CardsMongoDB\n", function() {
beforeEach(function(done) {
LogInUtilities
.deleteAllAccounts([config.PUBLIC_USER_USERNAME])
.then(function(_) {
.then(function() {
return getDummyAccount();
})
.then(function(accountInfo) {
Expand Down Expand Up @@ -83,7 +83,7 @@ describe("Test CardsMongoDB\n", function() {
.then(function(updatedCard) {
done(updatedCard);
})
.catch(function(_) {
.catch(function() {
done();
});
});
Expand Down

0 comments on commit 23bf3fa

Please sign in to comment.