Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

strategy:
matrix:
node-version: [22.10.0]
node-version: [22.16.0]

steps:
- uses: actions/checkout@v3
Expand Down
3 changes: 2 additions & 1 deletion controllers/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,8 @@ const updateTaskStatus = async (req, res, next) => {
const isCurrProgress100 = parseInt(task.taskData.percentCompleted || 0) === 100;
const isCurrProgress0 = parseInt(task.taskData.percentCompleted || 0) === 0;
const isNewProgress100 = !!req.body.percentCompleted && parseInt(req.body.percentCompleted) === 100;
const isNewProgress0 = !!req.body.percentCompleted !== undefined && parseInt(req.body.percentCompleted) === 0;
const percentCompleted = req.body.percentCompleted;
const isNewProgress0 = percentCompleted !== undefined && parseInt(percentCompleted) === 0;

if (
!isCurrProgress100 &&
Expand Down
44 changes: 44 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import js from "@eslint/js";
import globals from "globals";
import mochaPlugin from "eslint-plugin-mocha";
import securityPlugin from "eslint-plugin-security";
import prettierPlugin from "eslint-plugin-prettier";

export default [
{
ignores: ["dist/*", "**/.eslintrc.js", "public/*"],
},
js.configs.recommended,
{
languageOptions: {
ecmaVersion: "latest",
sourceType: "module",
globals: {
...globals.node,
...globals.mocha,
config: "readonly",
logger: "readonly",
},
},
plugins: {
mocha: mochaPlugin,
security: securityPlugin,
prettier: prettierPlugin,
},
rules: {
// Custom eslint rules
"no-trailing-spaces": "error",
"consistent-return": "error",
"no-console": "error",

// Mocha rules
"mocha/no-exclusive-tests": "error",

// Prettier for formatting
"prettier/prettier": "error",

"no-unused-vars": "off",
},
ignores: ["public/*", "dist/*"],
},
];
2 changes: 1 addition & 1 deletion models/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ const createEventCode = async (eventCodeData) => {
const data = docSnapshot.data();

const previouslyPresentEventCodes = eventSnapshotData?.event_codes?.by_role?.mavens && [
...eventSnapshotData?.event_codes?.by_role?.mavens,
...eventSnapshotData.event_codes.by_role.mavens,
];

if (!data) throw new Error();
Expand Down
1 change: 0 additions & 1 deletion models/items.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ const getItemBasedOnFilter = async (query) => {
try {
let call = itemTagsModel;
Object.keys(query).forEach((key) => {
// eslint-disable-next-line security/detect-object-injection
call = call.where(key, "==", query[key]);
});
const items = [];
Expand Down
2 changes: 0 additions & 2 deletions models/logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ const fetchLogs = async (query, param) => {
try {
let call = logsModel.where("type", "==", param);
Object.keys(query).forEach((key) => {
// eslint-disable-next-line security/detect-object-injection
if (key !== "limit" && key !== "lastDocId") {
// eslint-disable-next-line security/detect-object-injection
call = call.where(key, "==", query[key]);
}
});
Expand Down
1 change: 0 additions & 1 deletion models/userStatus.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-console */
const { Forbidden, NotFound } = require("http-errors");
const admin = require("firebase-admin");
const firestore = require("../utils/firestore");
Expand Down
64 changes: 33 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
"tdd:watch": "sh scripts/tests/tdd.sh"
},
"dependencies": {
"@aws-sdk/client-identitystore": "^3.665.0",
"@types/nodemailer": "^6.4.15",
"axios": "1.7.4",
"cloudinary": "2.0.3",
"@aws-sdk/client-identitystore": "3.817.0",
"@types/nodemailer": "6.4.17",
"axios": "1.9.0",
"cloudinary": "2.6.1",
"config": "3.3.7",
"cookie-parser": "1.4.6",
"cookie-parser": "1.4.7",
"cors": "2.8.5",
"datauri": "4.1.0",
"debug": "4.3.5",
Expand All @@ -36,55 +36,57 @@
"morgan": "1.10.0",
"multer": "1.4.5-lts.1",
"newrelic": "11.19.0",
"nodemailer": "^6.9.15",
"nodemailer-mock": "^2.0.6",
"nodemailer": "6.7.3",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this downgrade?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did it by mistake.
It's fixed.

Thanks

"nodemailer-mock": "2.0.8",
"passport": "0.7.0",
"passport-github2": "0.1.12",
"passport-google-oauth20": "^2.0.0",
"rate-limiter-flexible": "5.0.3",
"winston": "3.13.0"
"rate-limiter-flexible": "7.1.1",
"winston": "3.17.0"
},
"devDependencies": {
"@eslint/compat": "^1.2.9",
"@eslint/eslintrc": "^3.3.1",
"@eslint/js": "^9.27.0",
"@types/chai": "4.3.16",
"@types/config": "3.3.4",
"@types/config": "3.3.5",
"@types/express": "4.17.21",
"@types/jest": "29.5.12",
"@types/mocha": "10.0.6",
"@types/node": "20.11.24",
"@types/jest": "29.5.14",
"@types/mocha": "10.0.10",
"@types/node": "22.15.21",
"@types/sinon": "17.0.3",
"@typescript-eslint/parser": "^7.1.1",
"@typescript-eslint/parser": "8.32.1",
"chai": "4.4.1",
"chai-http": "4.4.0",
"cross-env": "7.0.3",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-standard": "^16.0.3",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-mocha": "^10.0.0",
"eslint": "^9.27.0",
"eslint-config-prettier": "10.1.5",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-mocha": "^11.1.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-security": "^1.7.1",
"firebase-tools": "13.4.0",
"mocha": "10.3.0",
"eslint-plugin-prettier": "^5.4.0",
"eslint-plugin-security": "^3.0.1",
"firebase-tools": "14.4.0",
"globals": "^16.2.0",
"mocha": "11.5.0",
"nock": "13.2.9",
"nodemon": "3.1.3",
"nyc": "15.1.0",
"nodemon": "3.1.10",
"nyc": "17.1.0",
"pre-commit": "1.2.2",
"prettier": "^2.5.1",
"sinon": "18.0.0",
"sinon": "20.0.0",
"ts-node": "10.9.2",
"ts-node-dev": "2.0.0",
"typescript": "5.3.3"
"typescript": "5.8.3"
},
"engines": {
"node": "22.10.0"
"node": "22.16.0"
},
"pre-commit": [
"lint"
],
"volta": {
"node": "22.10.0",
"yarn": "1.22.21"
"node": "22.16.0",
"yarn": "1.22.22"
}
}
4 changes: 2 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ function onError(error) {
case "EACCES":
logger.error(bind + " requires elevated privileges");
process.exit(1);
// eslint-disable-next-line no-unreachable

break;

case "EADDRINUSE":
logger.error(bind + " is already in use");
process.exit(1);
// eslint-disable-next-line no-unreachable

break;

default:
Expand Down
2 changes: 1 addition & 1 deletion services/discordService.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const setInDiscordFalseScript = async () => {
const updateUsersPromises = [];
users.forEach((user) => {
const id = user.id;
// eslint-disable-next-line security/detect-object-injection

delete user[id];
const userData = {
...user,
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/discordResponse/discord-response.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ const getOnboarding31DPlusMembers = [
nick: "john",
pending: false,
premium_since: null,
// eslint-disable-next-line no-loss-of-precision

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can we also remove these empty lines

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

roles: ["9876543210", "11334336"],
user: {
id: "9653710123456",
Expand Down
1 change: 0 additions & 1 deletion test/integration/contributions.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-unused-expressions */
const chai = require("chai");
const sinon = require("sinon");
const { expect } = chai;
Expand Down
18 changes: 4 additions & 14 deletions test/integration/discordactions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ describe("Discord actions", function () {

describe("DELETE /discord-actions/groups/:groupId", function () {
let groupId;
// eslint-disable-next-line mocha/no-setup-in-describe

const roleData = groupData[0];

beforeEach(async function () {
Expand Down Expand Up @@ -952,7 +952,6 @@ describe("Discord actions", function () {
});
});

// eslint-disable-next-line mocha/no-skipped-tests
describe.skip("GET /discord-actions/invite", function () {
it("should return the invite for the user if no userId is provided in the params and the invite exists", async function () {
await addInviteToInviteModel({ userId: superUserId, inviteLink: "discord.gg/apQYT7HB" });
Expand Down Expand Up @@ -995,7 +994,6 @@ describe("Discord actions", function () {
});

// <------ Will revisit this later https://github.com/Real-Dev-Squad/website-backend/issues/2078 --->
// eslint-disable-next-line mocha/no-skipped-tests
describe.skip("POST /discord-actions/invite", function () {
afterEach(function () {
sinon.restore();
Expand All @@ -1011,7 +1009,6 @@ describe("Discord actions", function () {
expect(res.body.message).to.be.equal("User should be super user to generate link for other users");
});

// eslint-disable-next-line mocha/no-skipped-tests
it.skip("should return 403 if the user has discord id in their user object, which means user is already in discord", async function () {
const res = await chai
.request(app)
Expand All @@ -1022,7 +1019,6 @@ describe("Discord actions", function () {
expect(res.body.message).to.be.equal("Only users who have never joined discord can generate invite link");
});

// eslint-disable-next-line mocha/no-skipped-tests
it.skip("should return 403 if user has role archieved", async function () {
archievedUserId = await addUser(archievedUser);
archievedUserToken = authService.generateAuthToken({ userId: archievedUserId });
Expand All @@ -1035,7 +1031,6 @@ describe("Discord actions", function () {
expect(res.body.message).to.be.equal("Archived users cannot generate invite");
});

// eslint-disable-next-line mocha/no-skipped-tests
it.skip("should return 403 if the user doesn't have role designer, product_manager, or mavens", async function () {
developerUserWithoutApprovedProfileStatusId = await addUser(developerUserWithoutApprovedProfileStatus);
developerUserWithoutApprovedProfileStatusToken = authService.generateAuthToken({
Expand All @@ -1050,7 +1045,6 @@ describe("Discord actions", function () {
expect(res.body.message).to.be.equal("Only selected roles can generate discord link directly");
});

// eslint-disable-next-line mocha/no-skipped-tests
it.skip("should generate discord link if user is a product mananger", async function () {
fetchStub.returns(
Promise.resolve({
Expand All @@ -1071,7 +1065,6 @@ describe("Discord actions", function () {
expect(res.body.inviteLink).to.be.equal("discord.gg/xyz");
});

// eslint-disable-next-line mocha/no-skipped-tests
it.skip("should generate discord link if user is a designer", async function () {
fetchStub.returns(
Promise.resolve({
Expand All @@ -1092,7 +1085,6 @@ describe("Discord actions", function () {
expect(res.body.inviteLink).to.be.equal("discord.gg/zlmfasd");
});

// eslint-disable-next-line mocha/no-skipped-tests
it.skip("should generate discord link if user is a maven", async function () {
fetchStub.returns(
Promise.resolve({
Expand Down Expand Up @@ -1153,7 +1145,6 @@ describe("Discord actions", function () {
);
});

// eslint-disable-next-line mocha/no-skipped-tests
it.skip("should generate discord link if user has an approved application", async function () {
sinon.stub(ApplicationModel, "getUserApplications").resolves([{ status: "accepted" }]);
fetchStub.returns(
Expand Down Expand Up @@ -1318,7 +1309,7 @@ describe("Discord actions", function () {
expect(res.body.message).to.equal("Roles fetched successfully!");
expect(res.body.groups).to.be.an("array");
expect(res.body.links).to.have.keys(["next", "prev"]);
// eslint-disable-next-line no-unused-expressions

expect(res.body.links.next).to.be.null;
expect(res.body.links.prev).to.equal(`/discord-actions/groups?page=${page - 1}&size=${size}&dev=true`);
return done();
Expand Down Expand Up @@ -1350,10 +1341,10 @@ describe("Discord actions", function () {
expect(res).to.have.status(200);
expect(res.body).to.be.an("object");
expect(res.body.message).to.equal("Roles fetched successfully!");
// eslint-disable-next-line no-unused-expressions

expect(res.body.groups).to.be.an("array").that.is.empty;
expect(res.body.links).to.have.keys(["next", "prev"]);
// eslint-disable-next-line no-unused-expressions

expect(res.body.links.next).to.be.null;
expect(res.body.links.prev).to.equal(`/discord-actions/groups?page=${page - 1}&size=${size}&dev=true`);
return done();
Expand All @@ -1367,7 +1358,6 @@ describe("Discord actions", function () {
.request(app)
.get("/discord-actions/groups?dev=true")
.set("cookie", `${cookieName}=${userAuthToken}`)
// eslint-disable-next-line node/handle-callback-err
.end((err, res) => {
expect(res).to.have.status(500);
expect(res.body).to.be.an("object");
Expand Down
4 changes: 2 additions & 2 deletions test/integration/members.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ describe("Members", function () {
}

expect(res).to.have.status(204);
/* eslint-disable no-unused-expressions */

expect(res.body).to.be.a("object").to.be.empty;

return done();
Expand Down Expand Up @@ -325,7 +325,7 @@ describe("Members", function () {
}

expect(res).to.have.status(204);
/* eslint-disable no-unused-expressions */

expect(res.body).to.be.a("object").to.be.empty;

return done();
Expand Down
1 change: 0 additions & 1 deletion test/integration/notify.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ describe("Notify Test", function () {
});

describe("POST call to notify", function () {
// eslint-disable-next-line mocha/no-skipped-tests
it.skip("should send message to specified users", async function () {
// skipping the test because it connects with firebase cloud messaging service which we are unable to mock.

Expand Down
4 changes: 2 additions & 2 deletions test/integration/progressesTasks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -674,10 +674,10 @@ describe("Test Progress Updates API for Tasks", function () {
expect(res).to.have.status(200);
expect(res.body).to.be.an("object");
expect(res.body.message).to.equal("Progress document retrieved successfully.");
// eslint-disable-next-line no-unused-expressions

expect(res.body.data).to.be.an("array").that.is.empty;
expect(res.body.links).to.have.keys(["next", "prev"]);
// eslint-disable-next-line no-unused-expressions

expect(res.body.links.next).to.be.null;
expect(res.body.links.prev).to.equal(`/progresses?type=task&page=${page - 1}&size=${size}&dev=true`);
return done();
Expand Down
4 changes: 2 additions & 2 deletions test/integration/progressesUsers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,10 +511,10 @@ describe("Test Progress Updates API for Users", function () {
expect(res).to.have.status(200);
expect(res.body).to.be.an("object");
expect(res.body.message).to.equal("Progress document retrieved successfully.");
// eslint-disable-next-line no-unused-expressions

expect(res.body.data).to.be.an("array").that.is.empty;
expect(res.body.links).to.have.keys(["next", "prev"]);
// eslint-disable-next-line no-unused-expressions

expect(res.body.links.next).to.be.null;
expect(res.body.links.prev).to.equal(`/progresses?type=user&page=${page - 1}&size=${size}&dev=true`);
return done();
Expand Down
Loading
Loading