diff --git a/.jshintrc b/.jshintrc index 25c3241..4edf416 100644 --- a/.jshintrc +++ b/.jshintrc @@ -1,6 +1,6 @@ { "node": true, - "esversion": 9, + "esversion": 11, "camelcase": true, "eqeqeq": true, "evil": true, diff --git a/README.md b/README.md index c5d3ec4..31996fa 100644 --- a/README.md +++ b/README.md @@ -66,8 +66,6 @@ For detailed understanding of the working of the project refer the [flowchart](i ### Contributing -You may notice sever `jshint ignore` comments in the code. It's because JSHint has not yet released support for optional chaining(`.?`). The feature is in the works for [v2.13](https://github.com/jshint/jshint/pull/3486). This is a temporary fix until they release `v2.13` - #### Requirements - Node.js - 14.17.0 diff --git a/src/commands/check.js b/src/commands/check.js index 99092b1..5d8b8f4 100644 --- a/src/commands/check.js +++ b/src/commands/check.js @@ -44,17 +44,14 @@ async function checkAvailability(bot, interaction) { const options = interaction.data.options; let date = options.filter((option) => option.name === "date")[0].value; - /* jshint ignore:start */ let district = options.filter((option) => option.name === "district")[0] ?.value; let age = options.filter((option) => option.name === "age")[0]?.value; - /* jshint ignore:end */ - + const dateRegex = /^\d{2}-\d{2}-\d{4}$/; const userInDb = await readUserData(getUserID(interaction)); if (!district) { - // jshint ignore:start if (!userInDb?.district) return sendReply( bot, @@ -62,7 +59,6 @@ async function checkAvailability(bot, interaction) { "Set your district using /set command or enter them while using /check" ); district = userInDb.district; - // jshint ignore:end } else { let districtData = await parseDistrict(district); if (!districtData.code) @@ -70,7 +66,6 @@ async function checkAvailability(bot, interaction) { district = districtData.code; } if (!age) { - // jshint ignore:start if (!userInDb?.age) return sendReply( bot, @@ -78,7 +73,6 @@ async function checkAvailability(bot, interaction) { "Set your age using /set command or enter it while using /check" ); age = userInDb.age; - // jshint ignore:end } else age = getAge(age); if (!dateRegex.test(date)) diff --git a/src/commands/common.js b/src/commands/common.js index 5783e73..bdd30d8 100644 --- a/src/commands/common.js +++ b/src/commands/common.js @@ -2,7 +2,7 @@ import { findBestMatch } from "string-similarity"; import { getDistricts } from "../dbCrud.js"; export class Command{ - static instances = []; // jshint ignore:line + static instances = []; // jshint ignore:line constructor(cmdName, cmdData, cmdCallBack){ this.name = cmdName; @@ -57,14 +57,12 @@ export async function parseDistrict(district){ const matches = findBestMatch(district.toLowerCase(), districtNames).ratings .filter((match) => match.rating >= minDiceCoeff); - /* jshint ignore:start */ return { "name": matches[0]?.target, "code": districtsInDb.filter((district) => district.districtName.toLowerCase() === matches[0]?.target )[0]?.districtID }; - /* jshint ignore:end */ } function getSessionText(sessions){ @@ -83,7 +81,6 @@ export async function processResults(bot, interaction, results, userID){ if(!userID) sendReply(bot, interaction, "Slots available"); - // jshint ignore:start for(const center of results) await sendDM(bot, userID ?? getUserID(interaction), ` <<<<<<<< New Center Available >>>>>>>> @@ -95,9 +92,7 @@ Fee Type: ${center.feeType} ${getSessionText(center.sessions)}`); return sendDM(bot, userID ?? getUserID(interaction), `Register Now: https://www.cowin.gov.in/home ***I'm a bot, so don't reply***.... -`); - // jshint ignore:end - +`); } if(!userID) return sendReply(bot, interaction, diff --git a/src/commands/notifyMe.js b/src/commands/notifyMe.js index 83fab60..d86bfbb 100644 --- a/src/commands/notifyMe.js +++ b/src/commands/notifyMe.js @@ -13,14 +13,12 @@ async function addUserToListners(bot, interaction){ const userInDB = await readUserData(user.id); - // jshint ignore:start if(!userInDB?.district) return sendReply(bot, interaction, "Set your district using /set command to recieve hourly notifications"); if(!userInDB?.age) return sendReply(bot, interaction, - "Set your age using /set command to recieve hourly notifications") - // jshint ignore:end + "Set your age using /set command to recieve hourly notifications"); updateUserData(user.id, {"notify": true}); sendReply(bot, interaction, `You have subscribed to hourly notifications`); diff --git a/src/config.js b/src/config.js index d5483c0..52ae15a 100644 --- a/src/config.js +++ b/src/config.js @@ -1,7 +1,7 @@ import { config } from "dotenv"; config(); -export const DEBUG = (process.env.DEBUG ?? "true") !== "false"; // jshint ignore:line +export const DEBUG = (process.env.DEBUG ?? "true") !== "false"; export const mongoURL = process.env.MONGODB_SRV; @@ -11,4 +11,4 @@ export const GUILD_ID = process.env.GUILD_ID; export const API_BASE = process.env.API_BASE; -export const IS_PROXY = (process.env.IS_PROXY ?? "false") !== "false"; // jshint ignore:line \ No newline at end of file +export const IS_PROXY = (process.env.IS_PROXY ?? "false") !== "false"; \ No newline at end of file diff --git a/src/index.js b/src/index.js index a6263aa..82196c7 100644 --- a/src/index.js +++ b/src/index.js @@ -7,7 +7,7 @@ import cron from "node-cron"; import { DEBUG, mongoURL } from "./config.js"; const app = express(); -const port = process.env.PORT ?? "3000"; // jshint ignore:line +const port = process.env.PORT ?? "3000"; async function start() { try {