diff --git a/dev_config/eslint.config.mjs b/dev_config/eslint.config.mjs index ee766d2..8a47250 100644 --- a/dev_config/eslint.config.mjs +++ b/dev_config/eslint.config.mjs @@ -16,16 +16,17 @@ export default defineConfig([{ }, rules: { "no-tabs": ["error", { allowIndentationTabs: true }], - indent: ["error", "tab"], + "indent": ["error", "tab"], "linebreak-style": ["error", "unix"], - quotes: ["error", "double"], - semi: ["error", "always"], + "quotes": ["error", "double"], + "semi": ["error", "always"], "brace-style": ["error", "stroustrup", { allowSingleLine: false }], "no-unused-vars": ["warn", { "argsIgnorePattern": "^_", "varsIgnorePattern": "^_", "caughtErrorsIgnorePattern": "^_" }], - "prefer-const": ["error"] + "prefer-const": ["error"], + "eqeqeq": ["error"] } }]); diff --git a/src/backends/pve.js b/src/backends/pve.js index 9fce1bb..19feb3a 100644 --- a/src/backends/pve.js +++ b/src/backends/pve.js @@ -203,7 +203,7 @@ export default class PVE extends PVE_BACKEND { async getDisk (node, instance, disk) { const config = await this.getInstance(node, instance); - if (config != null && config.volumes[disk] != null) { + if (config !== null && config.volumes[disk] !== null) { return config.volumes[disk]; } else { @@ -213,7 +213,7 @@ export default class PVE extends PVE_BACKEND { async getNet (node, instance, netid) { const config = await this.getInstance(node, instance); - if (config != null && config.nets[netid] != null) { + if (config !== null && config.nets[netid] !== null) { return config.nets[netid]; } else { @@ -223,7 +223,7 @@ export default class PVE extends PVE_BACKEND { async getDevice (node, instance, deviceid) { const config = await this.getInstance(node, instance); - if (config != null && config.devices[deviceid] != null) { + if (config !== null && config.devices[deviceid] !== null) { return config.devices[deviceid]; } else { @@ -238,11 +238,11 @@ export default class PVE extends PVE_BACKEND { return null; } const data = res.data; - if (data.length != 1) { + if (data.length !== 1) { return null; } const poolPVE = data[0]; - if (poolPVE.poolid != pool) { + if (poolPVE.poolid !== pool) { return null; } diff --git a/src/routes/access/groups.js b/src/routes/access/groups.js index b134a8d..4c65c51 100644 --- a/src/routes/access/groups.js +++ b/src/routes/access/groups.js @@ -21,7 +21,7 @@ router.get("/:groupname", async (req, res) => { // attempt to parse group from groupname const groupObj = global.utils.getGroupObjFromGroupname(params.groupname); - if (groupObj == null) { + if (groupObj === null) { res.status(400).send({ auth: true, error:`Groupname ${params.groupname} does not match format gid-realm or gid.` }); } diff --git a/src/routes/access/users.js b/src/routes/access/users.js index 73414f5..8b98a50 100644 --- a/src/routes/access/users.js +++ b/src/routes/access/users.js @@ -21,7 +21,7 @@ router.get("/:username", async (req, res) => { // attempt to parse user from username const userObj = global.utils.getUserObjFromUsername(params.username); - if (userObj == null) { + if (userObj === null) { res.status(400).send({ auth:true, error:`username ${params.username} does not match format uid@realm.` }); } diff --git a/src/routes/cluster/disk.js b/src/routes/cluster/disk.js index 6ed9cc4..8ec8edc 100644 --- a/src/routes/cluster/disk.js +++ b/src/routes/cluster/disk.js @@ -141,7 +141,7 @@ router.post("/:disk/resize", async (req, res) => { // attempt to parse user from username const userObj = global.utils.getUserObjFromUsername(req.cookies.username); - if (userObj == null) { + if (userObj === null) { res.status(400).send({ auth:true, error:`username ${req.cookies.username} does not match format uid@realm.` }); } @@ -212,7 +212,7 @@ router.post("/:disk/move", async (req, res) => { // attempt to parse user from username const userObj = global.utils.getUserObjFromUsername(req.cookies.username); - if (userObj == null) { + if (userObj === null) { res.status(400).send({ auth:true, error:`username ${req.cookies.username} does not match format uid@realm.` }); } @@ -339,7 +339,7 @@ router.post("/:disk/create", async (req, res) => { // attempt to parse user from username const userObj = global.utils.getUserObjFromUsername(req.cookies.username); - if (userObj == null) { + if (userObj === null) { res.status(400).send({ auth:true, error:`username ${req.cookies.username} does not match format uid@realm.` }); return; } diff --git a/src/utils.js b/src/utils.js index f45d49c..893df02 100644 --- a/src/utils.js +++ b/src/utils.js @@ -254,7 +254,7 @@ export async function approveResources (req, user, node, pool, request) { // if the resource type is list, check if the requested resource exists in the list if (configResources[key].type === "list") { const index = resourceData.findIndex((availElement) => request[key].includes(availElement.match)); - // if no matching resource when index == -1, then remaining is -1 otherwise use the remaining value + // if no matching resource when index === -1, then remaining is -1 otherwise use the remaining value const avail = index === -1 ? false : resourceData[index].avail > 0; if (avail !== configResources[key].whitelist) { reason[key] = { approved: false, reason: `${key} ${configResources[key].whitelist ? "not in whitelist" : "in blacklist"}` };