From 78344b4e3501ccf98378421aa3128ea051a05559 Mon Sep 17 00:00:00 2001 From: Dan Gowans Date: Mon, 31 Oct 2022 12:03:28 -0400 Subject: [PATCH] linting --- .eslintrc.json | 1 + app.js | 8 ++++---- app.ts | 9 ++++----- bin/www.js | 16 ++++++++++------ bin/www.ts | 21 ++++++++++++--------- cypress.config.ts | 2 -- routes/login.ts | 2 +- types/globalTypes.ts | 3 +++ 8 files changed, 35 insertions(+), 27 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index dafb0707..4d4782c2 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -21,6 +21,7 @@ ], "rules": { "node/no-missing-import": "off", + "node/no-unpublished-import": "off", "unicorn/consistent-function-scoping": "warn", "unicorn/empty-brace-spaces": "off", "unicorn/filename-case": [ diff --git a/app.js b/app.js index 1e6f0422..1ef276fc 100644 --- a/app.js +++ b/app.js @@ -130,10 +130,10 @@ app.all(urlPrefix + "/keepAlive", (_request, response) => { app.use(urlPrefix + "/login", routerLogin); app.get(urlPrefix + "/logout", (request, response) => { if (request.session.user && request.cookies[sessionCookieName]) { - request.session.destroy(null); - request.session = undefined; - response.clearCookie(sessionCookieName); - response.redirect(urlPrefix + "/"); + request.session.destroy(() => { + response.clearCookie(sessionCookieName); + response.redirect(urlPrefix + "/"); + }); } else { response.redirect(urlPrefix + "/login"); diff --git a/app.ts b/app.ts index 5588a06e..22ad0b00 100644 --- a/app.ts +++ b/app.ts @@ -233,11 +233,10 @@ app.use(urlPrefix + "/login", routerLogin); app.get(urlPrefix + "/logout", (request, response) => { if (request.session.user && request.cookies[sessionCookieName]) { - // eslint-disable-next-line unicorn/no-null - request.session.destroy(null); - request.session = undefined; - response.clearCookie(sessionCookieName); - response.redirect(urlPrefix + "/"); + request.session.destroy(() => { + response.clearCookie(sessionCookieName); + response.redirect(urlPrefix + "/"); + }); } else { response.redirect(urlPrefix + "/login"); } diff --git a/bin/www.js b/bin/www.js index 42a20a73..8e5b31a4 100644 --- a/bin/www.js +++ b/bin/www.js @@ -10,20 +10,25 @@ const onError = (error) => { throw error; } switch (error.code) { - case "EACCES": + case "EACCES": { debugWWW("Requires elevated privileges"); process.exit(1); - case "EADDRINUSE": + } + case "EADDRINUSE": { debugWWW("Port is already in use."); process.exit(1); - default: + } + default: { throw error; + } } }; const onListening = (server) => { const addr = server.address(); - const bind = typeof addr === "string" ? "pipe " + addr : "port " + addr.port.toString(); - debugWWW("Listening on " + bind); + if (addr) { + const bind = typeof addr === "string" ? "pipe " + addr : "port " + addr.port.toString(); + debugWWW("Listening on " + bind); + } }; const httpPort = configFunctions.getProperty("application.httpPort"); if (httpPort) { @@ -39,6 +44,5 @@ exitHook(() => { if (httpServer) { debugWWW("Closing HTTP"); httpServer.close(); - httpServer = undefined; } }); diff --git a/bin/www.ts b/bin/www.ts index c3682c03..8d818e04 100644 --- a/bin/www.ts +++ b/bin/www.ts @@ -26,29 +26,33 @@ const onError = (error: ServerError) => { // handle specific listen errors with friendly messages switch (error.code) { // eslint-disable-next-line no-fallthrough - case "EACCES": + case "EACCES": { debugWWW("Requires elevated privileges"); process.exit(1); - // break; + // break; + } // eslint-disable-next-line no-fallthrough - case "EADDRINUSE": + case "EADDRINUSE": { debugWWW("Port is already in use."); process.exit(1); - // break; + // break; + } // eslint-disable-next-line no-fallthrough - default: + default: { throw error; + } } }; const onListening = (server: http.Server) => { const addr = server.address(); - const bind = typeof addr === "string" ? "pipe " + addr : "port " + addr.port.toString(); - - debugWWW("Listening on " + bind); + if (addr) { + const bind = typeof addr === "string" ? "pipe " + addr : "port " + addr.port.toString(); + debugWWW("Listening on " + bind); + } }; /** @@ -74,6 +78,5 @@ exitHook(() => { if (httpServer) { debugWWW("Closing HTTP"); httpServer.close(); - httpServer = undefined; } }); diff --git a/cypress.config.ts b/cypress.config.ts index 4d91cb24..ae084c4d 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -1,5 +1,3 @@ -/* eslint-disable node/no-unpublished-import */ - import { defineConfig } from "cypress"; export default defineConfig({ diff --git a/routes/login.ts b/routes/login.ts index 3039f8e8..9b278f3b 100644 --- a/routes/login.ts +++ b/routes/login.ts @@ -65,7 +65,7 @@ router isAuthenticated = await authenticationFunctions.authenticate(userName, passwordPlain); } - let userObject: recordTypes.User; + let userObject: recordTypes.User | undefined; if (isAuthenticated) { const userNameLowerCase = userName.toLowerCase(); diff --git a/types/globalTypes.ts b/types/globalTypes.ts index 3b6ae70a..bd7ae840 100644 --- a/types/globalTypes.ts +++ b/types/globalTypes.ts @@ -4,9 +4,12 @@ export interface LOS { mapKey: string, contextualClass: "success" | "danger" ) => void; + initializeDatePickers: (containerElement: HTMLElement) => void; initializeTimePickers: (containerElement: HTMLElement) => void; + initializeUnlockFieldButtons: (containerElement: HTMLElement) => void; + populateAliases: (containerElement: HTMLElement) => void; getRandomColor: (seedString: string) => string; }