Added JSDoc to ESLint (#3529)

* Added JSDoc to eslint rules

Signed-off-by: Matthew Nickson <mnickson@sidingsmedia.com>

* Fixed JSDoc eslint errors

Signed-off-by: Matthew Nickson <mnickson@sidingsmedia.com>

* Update the check-linters workflow to Node.js 20

---------

Signed-off-by: Matthew Nickson <mnickson@sidingsmedia.com>
Co-authored-by: Louis Lam <louislam@users.noreply.github.com>
This commit is contained in:
Matthew Nickson
2023-08-11 09:46:41 +02:00
committed by GitHub
parent da4f4e3d76
commit 8a92054c2b
153 changed files with 1505 additions and 574 deletions

View File

@@ -51,7 +51,10 @@ export default {
};
},
methods: {
/** Submit form data to add new status page */
/**
* Submit form data to add new status page
* @returns {Promise<void>}
*/
async submit() {
this.processing = true;

View File

@@ -359,47 +359,71 @@ export default {
},
methods: {
getResBaseURL,
/** Request a test notification be sent for this monitor */
/**
* Request a test notification be sent for this monitor
* @returns {void}
*/
testNotification() {
this.$root.getSocket().emit("testNotification", this.monitor.id);
toast.success("Test notification is requested.");
},
/** Show dialog to confirm pause */
/**
* Show dialog to confirm pause
* @returns {void}
*/
pauseDialog() {
this.$refs.confirmPause.show();
},
/** Resume this monitor */
/**
* Resume this monitor
* @returns {void}
*/
resumeMonitor() {
this.$root.getSocket().emit("resumeMonitor", this.monitor.id, (res) => {
this.$root.toastRes(res);
});
},
/** Request that this monitor is paused */
/**
* Request that this monitor is paused
* @returns {void}
*/
pauseMonitor() {
this.$root.getSocket().emit("pauseMonitor", this.monitor.id, (res) => {
this.$root.toastRes(res);
});
},
/** Show dialog to confirm deletion */
/**
* Show dialog to confirm deletion
* @returns {void}
*/
deleteDialog() {
this.$refs.confirmDelete.show();
},
/** Show dialog to confirm clearing events */
/**
* Show dialog to confirm clearing events
* @returns {void}
*/
clearEventsDialog() {
this.$refs.confirmClearEvents.show();
},
/** Show dialog to confirm clearing heartbeats */
/**
* Show dialog to confirm clearing heartbeats
* @returns {void}
*/
clearHeartbeatsDialog() {
this.$refs.confirmClearHeartbeats.show();
},
/** Request that this monitor is deleted */
/**
* Request that this monitor is deleted
* @returns {void}
*/
deleteMonitor() {
this.$root.deleteMonitor(this.monitor.id, (res) => {
if (res.ok) {
@@ -411,7 +435,10 @@ export default {
});
},
/** Request that this monitors events are cleared */
/**
* Request that this monitors events are cleared
* @returns {void}
*/
clearEvents() {
this.$root.clearEvents(this.monitor.id, (res) => {
if (! res.ok) {
@@ -420,7 +447,10 @@ export default {
});
},
/** Request that this monitors heartbeats are cleared */
/**
* Request that this monitors heartbeats are cleared
* @returns {void}
*/
clearHeartbeats() {
this.$root.clearHeartbeats(this.monitor.id, (res) => {
if (! res.ok) {
@@ -431,8 +461,8 @@ export default {
/**
* Return the correct title for the ping stat
* @param {boolean} [average=false] Is the statistic an average?
* @returns {string} Title formated dependant on monitor type
* @param {boolean} average Is the statistic an average?
* @returns {string} Title formatted dependant on monitor type
*/
pingTitle(average = false) {
let translationPrefix = "";
@@ -456,7 +486,11 @@ export default {
return getMonitorRelativeURL(id);
},
/** Filter and hide password in URL for display */
/**
* Filter and hide password in URL for display
* @param {string} urlString URL to censor
* @returns {string} Censored URL
*/
filterPassword(urlString) {
try {
let parsedUrl = new URL(urlString);

View File

@@ -417,7 +417,10 @@ export default {
});
},
methods: {
/** Initialise page */
/**
* Initialise page
* @returns {void}
*/
init() {
this.affectedMonitors = [];
this.selectedStatusPages = [];
@@ -479,7 +482,10 @@ export default {
}
},
/** Create new maintenance */
/**
* Create new maintenance
* @returns {Promise<void>}
*/
async submit() {
this.processing = true;
@@ -526,8 +532,9 @@ export default {
/**
* Add monitor to maintenance
* @param {number} maintenanceID
* @param {socketCB} callback
* @param {number} maintenanceID ID of maintenance to modify
* @param {socketCB} callback Callback for socket response
* @returns {Promise<void>}
*/
async addMonitorMaintenance(maintenanceID, callback) {
await this.$root.addMonitorMaintenance(maintenanceID, this.affectedMonitors, async (res) => {
@@ -543,8 +550,9 @@ export default {
/**
* Add status page to maintenance
* @param {number} maintenanceID
* @param {socketCB} callback
* @param {number} maintenanceID ID of maintenance to modify
* @param {socketCB} callback Callback for socket response
* @returns {void}
*/
async addMaintenanceStatusPage(maintenanceID, callback) {
await this.$root.addMaintenanceStatusPage(maintenanceID, (this.showOnAllPages) ? this.selectedStatusPagesOptions : this.selectedStatusPages, async (res) => {

View File

@@ -1069,8 +1069,7 @@ message HealthCheckResponse {
/**
* Generates the parent monitor options list based on the sorted group monitor list and draft group name.
*
* @return {Array} The parent monitor options list.
* @returns {Array} The parent monitor options list.
*/
parentMonitorOptionsList() {
let list = [];
@@ -1234,7 +1233,10 @@ message HealthCheckResponse {
this.kafkaSaslMechanismOptions = kafkaSaslMechanismOptions;
},
methods: {
/** Initialize the edit monitor form */
/**
* Initialize the edit monitor form
* @returns {void}
*/
init() {
if (this.isAdd) {
@@ -1447,6 +1449,7 @@ message HealthCheckResponse {
* Added a Notification Event
* Enable it if the notification is added in EditMonitor.vue
* @param {number} id ID of notification to add
* @returns {void}
*/
addedNotification(id) {
this.monitor.notificationIDList[id] = true;
@@ -1456,21 +1459,26 @@ message HealthCheckResponse {
* Added a Proxy Event
* Enable it if the proxy is added in EditMonitor.vue
* @param {number} id ID of proxy to add
* @returns {void}
*/
addedProxy(id) {
this.monitor.proxyId = id;
},
// Added a Docker Host Event
// Enable it if the Docker Host is added in EditMonitor.vue
/**
* Added a Docker Host Event
* Enable it if the Docker Host is added in EditMonitor.vue
* @param {number} id ID of docker host
* @returns {void}
*/
addedDockerHost(id) {
this.monitor.docker_host = id;
},
/**
* Adds a draft group.
*
* @param {string} draftGroupName - The name of the draft group.
* @param {string} draftGroupName The name of the draft group.
* @returns {void}
*/
addedDraftGroup(draftGroupName) {
this.draftGroupName = draftGroupName;

View File

@@ -65,7 +65,10 @@ export default {
this.init();
},
methods: {
/** Initialise page */
/**
* Initialise page
* @returns {void}
*/
init() {
this.$root.getSocket().emit("getMonitorMaintenance", this.$route.params.id, (res) => {
if (res.ok) {
@@ -84,12 +87,18 @@ export default {
});
},
/** Confirm deletion */
/**
* Confirm deletion
* @returns {void}
*/
deleteDialog() {
this.$refs.confirmDelete.show();
},
/** Delete maintenance after showing confirmation */
/**
* Delete maintenance after showing confirmation
* @returns {void}
*/
deleteMaintenance() {
this.$root.deleteMaintenance(this.maintenance.id, (res) => {
if (res.ok) {

View File

@@ -135,7 +135,7 @@ export default {
/**
* Get maintenance URL
* @param {number} id
* @param {number} id ID of maintenance to read
* @returns {string} Relative URL
*/
maintenanceURL(id) {
@@ -144,14 +144,19 @@ export default {
/**
* Show delete confirmation
* @param {number} maintenanceID
* @param {number} maintenanceID ID of maintenance to show delete
* confirmation for.
* @returns {void}
*/
deleteDialog(maintenanceID) {
this.selectedMaintenanceID = maintenanceID;
this.$refs.confirmDelete.show();
},
/** Delete maintenance after showing confirmation dialog */
/**
* Delete maintenance after showing confirmation dialog
* @returns {void}
*/
deleteMaintenance() {
this.$root.deleteMaintenance(this.selectedMaintenanceID, (res) => {
if (res.ok) {
@@ -165,6 +170,9 @@ export default {
/**
* Show dialog to confirm pause
* @param {number} maintenanceID ID of maintenance to confirm
* pause.
* @returns {void}
*/
pauseDialog(maintenanceID) {
this.selectedMaintenanceID = maintenanceID;
@@ -173,6 +181,7 @@ export default {
/**
* Pause maintenance
* @returns {void}
*/
pauseMaintenance() {
this.$root.getSocket().emit("pauseMaintenance", this.selectedMaintenanceID, (res) => {
@@ -182,6 +191,8 @@ export default {
/**
* Resume maintenance
* @param {number} id ID of maintenance to resume
* @returns {void}
*/
resumeMaintenance(id) {
this.$root.getSocket().emit("resumeMaintenance", id, (res) => {

View File

@@ -45,7 +45,10 @@ export default {
},
methods: {
/** Go back 1 in browser history */
/**
* Go back 1 in browser history
* @returns {void}
*/
goBack() {
history.back();
}

View File

@@ -139,6 +139,7 @@ export default {
/**
* Load the general settings page
* For desktop only, on mobile do nothing
* @returns {void}
*/
loadGeneralPage() {
if (!this.currentPage && !this.$root.isMobile) {
@@ -146,7 +147,10 @@ export default {
}
},
/** Load settings from server */
/**
* Load settings from server
* @returns {void}
*/
loadSettings() {
this.$root.getSocket().emit("getSettings", (res) => {
this.settings = res.data;
@@ -186,13 +190,15 @@ export default {
/**
* Callback for saving settings
* @callback saveSettingsCB
* @param {Object} res Result of operation
* @param {object} res Result of operation
* @returns {void}
*/
/**
* Save Settings
* @param {saveSettingsCB} [callback]
* @param {string} [currentPassword] Only need for disableAuth to true
* @param {saveSettingsCB} callback Callback for socket response
* @param {string} currentPassword Only need for disableAuth to true
* @returns {void}
*/
saveSettings(callback, currentPassword) {
let valid = this.validateSettings();
@@ -212,7 +218,7 @@ export default {
/**
* Ensure settings are valid
* @returns {Object} Contains success state and error msg
* @returns {object} Contains success state and error msg
*/
validateSettings() {
if (this.settings.keepDataPeriodDays < 0) {

View File

@@ -452,6 +452,7 @@ export default {
/**
* If the monitor is added to public list, which will not be in this list.
* @returns {object[]} List of monitors
*/
sortedMonitorList() {
let result = [];
@@ -596,7 +597,8 @@ export default {
/**
* If connected to the socket and logged in, request private data of this statusPage
* @param connected
* @param {boolean} loggedIn Is the client logged in?
* @returns {void}
*/
"$root.loggedIn"(loggedIn) {
if (loggedIn) {
@@ -619,6 +621,8 @@ export default {
/**
* Selected a monitor and add to the list.
* @param {object} monitor Monitor to add
* @returns {void}
*/
selectedMonitor(monitor) {
if (monitor) {
@@ -723,7 +727,7 @@ export default {
/**
* Get status page data
* It should be preloaded in window.preloadData
* @returns {Promise<any>}
* @returns {Promise<any>} Status page data
*/
getData: function () {
if (window.preloadData) {
@@ -738,13 +742,16 @@ export default {
/**
* Provide syntax highlighting for CSS
* @param {string} code Text to highlight
* @returns {string}
* @returns {string} Highlighted HTML
*/
highlighter(code) {
return highlight(code, languages.css);
},
/** Update the heartbeat list and update favicon if neccessary */
/**
* Update the heartbeat list and update favicon if necessary
* @returns {void}
*/
updateHeartbeatList() {
// If editMode, it will use the data from websocket.
if (! this.editMode) {
@@ -792,7 +799,10 @@ export default {
}, 1000);
},
/** Enable editing mode */
/**
* Enable editing mode
* @returns {void}
*/
edit() {
if (this.hasToken) {
this.$root.initSocketIO(true);
@@ -804,7 +814,10 @@ export default {
}
},
/** Save the status page */
/**
* Save the status page
* @returns {void}
*/
save() {
let startTime = new Date();
this.config.slug = this.config.slug.trim().toLowerCase();
@@ -832,12 +845,18 @@ export default {
});
},
/** Show dialog confirming deletion */
/**
* Show dialog confirming deletion
* @returns {void}
*/
deleteDialog() {
this.$refs.confirmDelete.show();
},
/** Request deletion of this status page */
/**
* Request deletion of this status page
* @returns {void}
*/
deleteStatusPage() {
this.$root.getSocket().emit("deleteStatusPage", this.slug, (res) => {
if (res.ok) {
@@ -850,15 +869,18 @@ export default {
},
/**
* Returns label for a specifed monitor
* @param {Object} monitor Object representing monitor
* @returns {string}
* Returns label for a specified monitor
* @param {object} monitor Object representing monitor
* @returns {string} Monitor label
*/
monitorSelectorLabel(monitor) {
return `${monitor.name}`;
},
/** Add a group to the status page */
/**
* Add a group to the status page
* @returns {void}
*/
addGroup() {
let groupName = this.$t("Untitled Group");
@@ -872,12 +894,18 @@ export default {
});
},
/** Add a domain to the status page */
/**
* Add a domain to the status page
* @returns {void}
*/
addDomainField() {
this.config.domainNameList.push("");
},
/** Discard changes to status page */
/**
* Discard changes to status page
* @returns {void}
*/
discard() {
location.href = "/status/" + this.slug;
},
@@ -885,19 +913,26 @@ export default {
/**
* Set URL of new image after successful crop operation
* @param {string} imgDataUrl URL of image in data:// format
* @returns {void}
*/
cropSuccess(imgDataUrl) {
this.imgDataUrl = imgDataUrl;
},
/** Show image crop dialog if in edit mode */
/**
* Show image crop dialog if in edit mode
* @returns {void}
*/
showImageCropUploadMethod() {
if (this.editMode) {
this.showImageCropUpload = true;
}
},
/** Create an incident for this status page */
/**
* Create an incident for this status page
* @returns {void}
*/
createIncident() {
this.enableEditIncidentMode = true;
@@ -912,7 +947,10 @@ export default {
};
},
/** Post the incident to the status page */
/**
* Post the incident to the status page
* @returns {void}
*/
postIncident() {
if (this.incident.title === "" || this.incident.content === "") {
toast.error(this.$t("Please input title and content"));
@@ -932,13 +970,19 @@ export default {
},
/** Click Edit Button */
/**
* Click Edit Button
* @returns {void}
*/
editIncident() {
this.enableEditIncidentMode = true;
this.previousIncident = Object.assign({}, this.incident);
},
/** Cancel creation or editing of incident */
/**
* Cancel creation or editing of incident
* @returns {void}
*/
cancelIncident() {
this.enableEditIncidentMode = false;
@@ -948,7 +992,10 @@ export default {
}
},
/** Unpin the incident */
/**
* Unpin the incident
* @returns {void}
*/
unpinIncident() {
this.$root.getSocket().emit("unpinIncident", this.slug, () => {
this.incident = null;
@@ -957,7 +1004,8 @@ export default {
/**
* Get the relative time difference of a date from now
* @returns {string}
* @param {any} date Date to get time difference
* @returns {string} Time difference
*/
dateFromNow(date) {
return dayjs.utc(date).fromNow();
@@ -966,6 +1014,7 @@ export default {
/**
* Remove a domain from the status page
* @param {number} index Index of domain to remove
* @returns {void}
*/
removeDomain(index) {
this.config.domainNameList.splice(index, 1);
@@ -973,7 +1022,7 @@ export default {
/**
* Generate sanitized HTML from maintenance description
* @param {string} description
* @param {string} description Text to sanitize
* @returns {string} Sanitized HTML
*/
maintenanceHTML(description) {