Browse Source

chore(backend): fixed eslint issues

Signed-off-by: Jonathan <theflametrooper@gmail.com>
Jonathan 3 years ago
parent
commit
f73ebca08f
3 changed files with 28 additions and 5 deletions
  1. 22 0
      backend/classes/Timer.class.js
  2. 2 2
      backend/core.js
  3. 4 3
      backend/index.js

+ 22 - 0
backend/classes/Timer.class.js

@@ -1,4 +1,5 @@
 export default class Timer {
+	// eslint-disable-next-line require-jsdoc
 	constructor(callback, delay, paused) {
 		this.callback = callback;
 		this.timerId = undefined;
@@ -13,6 +14,10 @@ export default class Timer {
 		}
 	}
 
+	/**
+	 * Pauses the timer
+	 *
+	 */
 	pause() {
 		clearTimeout(this.timerId);
 		this.remaining -= Date.now() - this.start;
@@ -20,12 +25,20 @@ export default class Timer {
 		this.paused = true;
 	}
 
+	/**
+	 * Ensures the timer's resume function is called if it is paused
+	 *
+	 */
 	ifNotPaused() {
 		if (!this.paused) {
 			this.resume();
 		}
 	}
 
+	/**
+	 * Resumes the timer
+	 *
+	 */
 	resume() {
 		this.start = Date.now();
 		clearTimeout(this.timerId);
@@ -34,10 +47,19 @@ export default class Timer {
 		this.paused = false;
 	}
 
+	/**
+	 * Resets the time when paused
+	 *
+	 */
 	resetTimeWhenPaused() {
 		this.timeWhenPaused = 0;
 	}
 
+	/**
+	 * Gets the amount of time the timer has been paused
+	 *
+	 * @returns {Date} - the amount of time the timer has been paused
+	 */
 	getTimePaused() {
 		if (!this.paused) {
 			return this.timeWhenPaused;

+ 2 - 2
backend/core.js

@@ -247,11 +247,11 @@ class Job {
 	/**
 	 * Logs to the module of the job
 	 *
-	 * @param  {any} args
+	 * @param  {any} args - Anything to be added to the log e.g. log type, log message
 	 */
 	log(...args) {
 		args.splice(1, 0, this.name); // Adds the name of the job as the first argument (after INFO/SUCCESS/ERROR).
-		this.module.log.apply(this.module, args);
+		this.module.log(...args);
 	}
 }
 

+ 4 - 3
backend/index.js

@@ -4,7 +4,7 @@ import util from "util";
 import config from "config";
 
 // eslint-disable-next-line no-extend-native
-Array.prototype.remove = function (item) {
+Array.prototype.remove = item => {
 	this.splice(this.indexOf(item), 1);
 };
 
@@ -383,7 +383,7 @@ moduleManager.initialize();
 /**
  * Prints a job
  *
- * @param {Job} job - the job
+ * @param {object} job - the job
  * @param {number} layer - the layer
  */
 function printJob(job, layer) {
@@ -397,7 +397,7 @@ function printJob(job, layer) {
 /**
  * Prints a task
  *
- * @param {Task} task - the task
+ * @param {object} task - the task
  * @param {number} layer - the layer
  */
 function printTask(task, layer) {
@@ -492,6 +492,7 @@ process.stdin.on("data", data => {
 	if (command.startsWith("eval")) {
 		const evalCommand = command.replace("eval ", "");
 		console.log(`Running eval command: ${evalCommand}`);
+		// eslint-disable-next-line no-eval
 		const response = eval(evalCommand);
 		console.log(`Eval response: `, response);
 	}