From 43bcf4ab985bcfa4c5eebaa6ec9f16a2804423b9 Mon Sep 17 00:00:00 2001 From: rejas Date: Mon, 27 Jul 2020 14:24:30 +0200 Subject: [PATCH] Run eslint over files, see what gets fixed automatically and clean up --- clientonly/index.js | 20 +++++++++++++++++--- js/app.js | 6 +++--- js/check_config.js | 5 ++++- js/class.js | 11 ++++++++--- js/electron.js | 3 +++ js/module.js | 10 ++++++---- js/translator.js | 21 ++++++++++++++------- modules/default/alert/notificationFx.js | 5 +++++ modules/default/calendar/calendar.js | 5 ++--- modules/default/clock/clock.js | 4 ++++ modules/default/weather/weatherprovider.js | 6 ++++++ 11 files changed, 72 insertions(+), 24 deletions(-) diff --git a/clientonly/index.js b/clientonly/index.js index 7d1c4fe3..e42aa186 100644 --- a/clientonly/index.js +++ b/clientonly/index.js @@ -4,10 +4,17 @@ (function () { var config = {}; - // Helper function to get server address/hostname from either the commandline or env + /** + * Helper function to get server address/hostname from either the commandline or env + */ function getServerAddress() { - // Helper function to get command line parameters - // Assumes that a cmdline parameter is defined with `--key [value]` + /** + * Helper function to get command line parameters + * Assumes that a cmdline parameter is defined with `--key [value]` + * + * @param key + * @param defaultValue + */ function getCommandLineParameter(key, defaultValue = undefined) { var index = process.argv.indexOf(`--${key}`); var value = index > -1 ? process.argv[index + 1] : undefined; @@ -23,6 +30,9 @@ config["tls"] = process.argv.indexOf("--use-tls") > 0; } + /** + * @param url + */ function getServerConfig(url) { // Return new pending promise return new Promise((resolve, reject) => { @@ -47,6 +57,10 @@ }); } + /** + * @param message + * @param code + */ function fail(message, code = 1) { if (message !== undefined && typeof message === "string") { console.log(message); diff --git a/js/app.js b/js/app.js index b1fcc9bb..49b3ee85 100644 --- a/js/app.js +++ b/js/app.js @@ -169,11 +169,11 @@ var App = function () { loadNextModule(); }; - /* cmpVersions(a,b) + /** * Compare two semantic version numbers and return the difference. * - * argument a string - Version number a. - * argument a string - Version number b. + * @param {string} a Version number a. + * @param {string} b Version number b. */ function cmpVersions(a, b) { var i, diff; diff --git a/js/check_config.js b/js/check_config.js index cfd56824..64dbbc6e 100644 --- a/js/check_config.js +++ b/js/check_config.js @@ -16,7 +16,7 @@ const config = require(rootPath + "/.eslintrc.json"); const Log = require(rootPath + "/js/logger.js"); const Utils = require(rootPath + "/js/utils.js"); -/* getConfigFile() +/** * Return string with path of configuration file * Check if set by environment variable MM_CONFIG_FILE */ @@ -29,6 +29,9 @@ function getConfigFile() { return configFileName; } +/** + * + */ function checkConfigFile() { const configFileName = getConfigFile(); diff --git a/js/class.js b/js/class.js index f52ac405..5dc6fbd0 100644 --- a/js/class.js +++ b/js/class.js @@ -57,7 +57,9 @@ : prop[name]; } - // The dummy class constructor + /** + * The dummy class constructor + */ function Class() { // All construction is actually done in the init method if (!initializing && this.init) { @@ -78,8 +80,11 @@ }; })(); -//Define the clone method for later use. -//Helper Method +/** + * Define the clone method for later use. Helper Method. + * + * @param obj + */ function cloneObject(obj) { if (obj === null || typeof obj !== "object") { return obj; diff --git a/js/electron.js b/js/electron.js index 0978cd0d..216dee48 100644 --- a/js/electron.js +++ b/js/electron.js @@ -15,6 +15,9 @@ const BrowserWindow = electron.BrowserWindow; // be closed automatically when the JavaScript object is garbage collected. let mainWindow; +/** + * + */ function createWindow() { app.commandLine.appendSwitch("autoplay-policy", "no-user-gesture-required"); var electronOptionsDefaults = { diff --git a/js/module.js b/js/module.js index 4aa26a80..17236b74 100644 --- a/js/module.js +++ b/js/module.js @@ -157,7 +157,7 @@ var Module = Class.extend({ /** nunjucksEnvironment() * Returns the nunjucks environment for the current module. * The environment is checked in the _nunjucksEnvironment instance variable. - + * @returns Nunjucks Environment */ nunjucksEnvironment: function () { @@ -451,11 +451,13 @@ Module.create = function (name) { return new ModuleClass(); }; -/* cmpVersions(a,b) +/** * Compare two semantic version numbers and return the difference. * - * argument a string - Version number a. - * argument a string - Version number b. + * @param {string} a Version number a. + * @param {string} b Version number b. + * + * @returns {number} */ function cmpVersions(a, b) { var i, diff; diff --git a/js/translator.js b/js/translator.js index ee4e1051..aa70a846 100644 --- a/js/translator.js +++ b/js/translator.js @@ -7,11 +7,11 @@ * MIT Licensed. */ var Translator = (function () { - /* loadJSON(file, callback) + /** * Load a JSON file via XHR. * - * argument file string - Path of the file we want to load. - * argument callback function - Function called when done. + * @param {string} file Path of the file we want to load. + * @param {Function} callback Function called when done. */ function loadJSON(file, callback) { var xhr = new XMLHttpRequest(); @@ -41,10 +41,17 @@ var Translator = (function () { translate: function (module, key, variables) { variables = variables || {}; //Empty object by default - // Combines template and variables like: - // template: "Please wait for {timeToWait} before continuing with {work}." - // variables: {timeToWait: "2 hours", work: "painting"} - // to: "Please wait for 2 hours before continuing with painting." + /** + * Combines template and variables like: + * template: "Please wait for {timeToWait} before continuing with {work}." + * variables: {timeToWait: "2 hours", work: "painting"} + * to: "Please wait for 2 hours before continuing with painting." + * + * @param template + * @param variables + * + * @returns {*} + */ function createStringFromTemplate(template, variables) { if (Object.prototype.toString.call(template) !== "[object String]") { return template; diff --git a/modules/default/alert/notificationFx.js b/modules/default/alert/notificationFx.js index 61ba59d7..44b2f01a 100644 --- a/modules/default/alert/notificationFx.js +++ b/modules/default/alert/notificationFx.js @@ -13,6 +13,9 @@ (function (window) { /** * extend obj function + * + * @param a + * @param b */ function extend(a, b) { for (let key in b) { @@ -25,6 +28,8 @@ /** * NotificationFx function + * + * @param options */ function NotificationFx(options) { this.options = extend({}, this.options); diff --git a/modules/default/calendar/calendar.js b/modules/default/calendar/calendar.js index 06026363..8e9d4ce3 100755 --- a/modules/default/calendar/calendar.js +++ b/modules/default/calendar/calendar.js @@ -556,12 +556,11 @@ Module.register("calendar", { }, /** - * symbolsForEvent(event) * Retrieves the symbols for a specific event. * - * argument event object - Event to look for. + * @param {object} event Event to look for. * - * return array - The Symbols + * @returns {*} array The Symbols */ symbolsForEvent: function (event) { let symbols = this.getCalendarPropertyAsArray(event.url, "symbol", this.config.defaultSymbol); diff --git a/modules/default/clock/clock.js b/modules/default/clock/clock.js index cfcd1e40..8911b7d4 100644 --- a/modules/default/clock/clock.js +++ b/modules/default/clock/clock.js @@ -152,6 +152,10 @@ Module.register("clock", { timeWrapper.appendChild(periodWrapper); } + /** + * @param config + * @param time + */ function formatTime(config, time) { var formatString = hourSymbol + ":mm"; if (config.showPeriod && config.timeFormat !== 24) { diff --git a/modules/default/weather/weatherprovider.js b/modules/default/weather/weatherprovider.js index cfcb3ef6..22897337 100644 --- a/modules/default/weather/weatherprovider.js +++ b/modules/default/weather/weatherprovider.js @@ -119,6 +119,9 @@ WeatherProvider.providers = []; /** * Static method to register a new weather provider. + * + * @param providerIdentifier + * @param providerDetails */ WeatherProvider.register = function (providerIdentifier, providerDetails) { WeatherProvider.providers[providerIdentifier.toLowerCase()] = WeatherProvider.extend(providerDetails); @@ -126,6 +129,9 @@ WeatherProvider.register = function (providerIdentifier, providerDetails) { /** * Static method to initialize a new weather provider. + * + * @param providerIdentifier + * @param delegate */ WeatherProvider.initialize = function (providerIdentifier, delegate) { providerIdentifier = providerIdentifier.toLowerCase();