Skip to content

Commit

Permalink
removed ignore for jshint after v2.13 is released
Browse files Browse the repository at this point in the history
  • Loading branch information
UKnowWhoIm committed Jun 9, 2021
1 parent 85ab858 commit dc44ddc
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"node": true,
"esversion": 9,
"esversion": 11,
"camelcase": true,
"eqeqeq": true,
"evil": true,
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 1 addition & 7 deletions src/commands/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,41 +44,35 @@ 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,
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)
return sendReply(bot, interaction, "District not found");
district = districtData.code;
}
if (!age) {
// jshint ignore:start
if (!userInDb?.age)
return sendReply(
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))
Expand Down
9 changes: 2 additions & 7 deletions src/commands/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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){
Expand All @@ -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 >>>>>>>>
Expand All @@ -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,
Expand Down
4 changes: 1 addition & 3 deletions src/commands/notifyMe.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
Expand Down
4 changes: 2 additions & 2 deletions src/config.js
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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
export const IS_PROXY = (process.env.IS_PROXY ?? "false") !== "false";
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit dc44ddc

Please sign in to comment.