mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 11:50:00 +00:00
Run eslint over files, see what gets fixed automatically and clean up
This commit is contained in:
parent
f4eae72c48
commit
43bcf4ab98
@ -4,10 +4,17 @@
|
|||||||
(function () {
|
(function () {
|
||||||
var config = {};
|
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() {
|
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) {
|
function getCommandLineParameter(key, defaultValue = undefined) {
|
||||||
var index = process.argv.indexOf(`--${key}`);
|
var index = process.argv.indexOf(`--${key}`);
|
||||||
var value = index > -1 ? process.argv[index + 1] : undefined;
|
var value = index > -1 ? process.argv[index + 1] : undefined;
|
||||||
@ -23,6 +30,9 @@
|
|||||||
config["tls"] = process.argv.indexOf("--use-tls") > 0;
|
config["tls"] = process.argv.indexOf("--use-tls") > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param url
|
||||||
|
*/
|
||||||
function getServerConfig(url) {
|
function getServerConfig(url) {
|
||||||
// Return new pending promise
|
// Return new pending promise
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@ -47,6 +57,10 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param message
|
||||||
|
* @param code
|
||||||
|
*/
|
||||||
function fail(message, code = 1) {
|
function fail(message, code = 1) {
|
||||||
if (message !== undefined && typeof message === "string") {
|
if (message !== undefined && typeof message === "string") {
|
||||||
console.log(message);
|
console.log(message);
|
||||||
|
@ -169,11 +169,11 @@ var App = function () {
|
|||||||
loadNextModule();
|
loadNextModule();
|
||||||
};
|
};
|
||||||
|
|
||||||
/* cmpVersions(a,b)
|
/**
|
||||||
* Compare two semantic version numbers and return the difference.
|
* Compare two semantic version numbers and return the difference.
|
||||||
*
|
*
|
||||||
* argument a string - Version number a.
|
* @param {string} a Version number a.
|
||||||
* argument a string - Version number b.
|
* @param {string} b Version number b.
|
||||||
*/
|
*/
|
||||||
function cmpVersions(a, b) {
|
function cmpVersions(a, b) {
|
||||||
var i, diff;
|
var i, diff;
|
||||||
|
@ -16,7 +16,7 @@ const config = require(rootPath + "/.eslintrc.json");
|
|||||||
const Log = require(rootPath + "/js/logger.js");
|
const Log = require(rootPath + "/js/logger.js");
|
||||||
const Utils = require(rootPath + "/js/utils.js");
|
const Utils = require(rootPath + "/js/utils.js");
|
||||||
|
|
||||||
/* getConfigFile()
|
/**
|
||||||
* Return string with path of configuration file
|
* Return string with path of configuration file
|
||||||
* Check if set by environment variable MM_CONFIG_FILE
|
* Check if set by environment variable MM_CONFIG_FILE
|
||||||
*/
|
*/
|
||||||
@ -29,6 +29,9 @@ function getConfigFile() {
|
|||||||
return configFileName;
|
return configFileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
function checkConfigFile() {
|
function checkConfigFile() {
|
||||||
const configFileName = getConfigFile();
|
const configFileName = getConfigFile();
|
||||||
|
|
||||||
|
11
js/class.js
11
js/class.js
@ -57,7 +57,9 @@
|
|||||||
: prop[name];
|
: prop[name];
|
||||||
}
|
}
|
||||||
|
|
||||||
// The dummy class constructor
|
/**
|
||||||
|
* The dummy class constructor
|
||||||
|
*/
|
||||||
function Class() {
|
function Class() {
|
||||||
// All construction is actually done in the init method
|
// All construction is actually done in the init method
|
||||||
if (!initializing && this.init) {
|
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) {
|
function cloneObject(obj) {
|
||||||
if (obj === null || typeof obj !== "object") {
|
if (obj === null || typeof obj !== "object") {
|
||||||
return obj;
|
return obj;
|
||||||
|
@ -15,6 +15,9 @@ const BrowserWindow = electron.BrowserWindow;
|
|||||||
// be closed automatically when the JavaScript object is garbage collected.
|
// be closed automatically when the JavaScript object is garbage collected.
|
||||||
let mainWindow;
|
let mainWindow;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
function createWindow() {
|
function createWindow() {
|
||||||
app.commandLine.appendSwitch("autoplay-policy", "no-user-gesture-required");
|
app.commandLine.appendSwitch("autoplay-policy", "no-user-gesture-required");
|
||||||
var electronOptionsDefaults = {
|
var electronOptionsDefaults = {
|
||||||
|
@ -451,11 +451,13 @@ Module.create = function (name) {
|
|||||||
return new ModuleClass();
|
return new ModuleClass();
|
||||||
};
|
};
|
||||||
|
|
||||||
/* cmpVersions(a,b)
|
/**
|
||||||
* Compare two semantic version numbers and return the difference.
|
* Compare two semantic version numbers and return the difference.
|
||||||
*
|
*
|
||||||
* argument a string - Version number a.
|
* @param {string} a Version number a.
|
||||||
* argument a string - Version number b.
|
* @param {string} b Version number b.
|
||||||
|
*
|
||||||
|
* @returns {number}
|
||||||
*/
|
*/
|
||||||
function cmpVersions(a, b) {
|
function cmpVersions(a, b) {
|
||||||
var i, diff;
|
var i, diff;
|
||||||
|
@ -7,11 +7,11 @@
|
|||||||
* MIT Licensed.
|
* MIT Licensed.
|
||||||
*/
|
*/
|
||||||
var Translator = (function () {
|
var Translator = (function () {
|
||||||
/* loadJSON(file, callback)
|
/**
|
||||||
* Load a JSON file via XHR.
|
* Load a JSON file via XHR.
|
||||||
*
|
*
|
||||||
* argument file string - Path of the file we want to load.
|
* @param {string} file Path of the file we want to load.
|
||||||
* argument callback function - Function called when done.
|
* @param {Function} callback Function called when done.
|
||||||
*/
|
*/
|
||||||
function loadJSON(file, callback) {
|
function loadJSON(file, callback) {
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
@ -41,10 +41,17 @@ var Translator = (function () {
|
|||||||
translate: function (module, key, variables) {
|
translate: function (module, key, variables) {
|
||||||
variables = variables || {}; //Empty object by default
|
variables = variables || {}; //Empty object by default
|
||||||
|
|
||||||
// Combines template and variables like:
|
/**
|
||||||
// template: "Please wait for {timeToWait} before continuing with {work}."
|
* Combines template and variables like:
|
||||||
// variables: {timeToWait: "2 hours", work: "painting"}
|
* template: "Please wait for {timeToWait} before continuing with {work}."
|
||||||
// to: "Please wait for 2 hours before continuing with painting."
|
* 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) {
|
function createStringFromTemplate(template, variables) {
|
||||||
if (Object.prototype.toString.call(template) !== "[object String]") {
|
if (Object.prototype.toString.call(template) !== "[object String]") {
|
||||||
return template;
|
return template;
|
||||||
|
@ -13,6 +13,9 @@
|
|||||||
(function (window) {
|
(function (window) {
|
||||||
/**
|
/**
|
||||||
* extend obj function
|
* extend obj function
|
||||||
|
*
|
||||||
|
* @param a
|
||||||
|
* @param b
|
||||||
*/
|
*/
|
||||||
function extend(a, b) {
|
function extend(a, b) {
|
||||||
for (let key in b) {
|
for (let key in b) {
|
||||||
@ -25,6 +28,8 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* NotificationFx function
|
* NotificationFx function
|
||||||
|
*
|
||||||
|
* @param options
|
||||||
*/
|
*/
|
||||||
function NotificationFx(options) {
|
function NotificationFx(options) {
|
||||||
this.options = extend({}, this.options);
|
this.options = extend({}, this.options);
|
||||||
|
@ -556,12 +556,11 @@ Module.register("calendar", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* symbolsForEvent(event)
|
|
||||||
* Retrieves the symbols for a specific 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) {
|
symbolsForEvent: function (event) {
|
||||||
let symbols = this.getCalendarPropertyAsArray(event.url, "symbol", this.config.defaultSymbol);
|
let symbols = this.getCalendarPropertyAsArray(event.url, "symbol", this.config.defaultSymbol);
|
||||||
|
@ -152,6 +152,10 @@ Module.register("clock", {
|
|||||||
timeWrapper.appendChild(periodWrapper);
|
timeWrapper.appendChild(periodWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param config
|
||||||
|
* @param time
|
||||||
|
*/
|
||||||
function formatTime(config, time) {
|
function formatTime(config, time) {
|
||||||
var formatString = hourSymbol + ":mm";
|
var formatString = hourSymbol + ":mm";
|
||||||
if (config.showPeriod && config.timeFormat !== 24) {
|
if (config.showPeriod && config.timeFormat !== 24) {
|
||||||
|
@ -119,6 +119,9 @@ WeatherProvider.providers = [];
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Static method to register a new weather provider.
|
* Static method to register a new weather provider.
|
||||||
|
*
|
||||||
|
* @param providerIdentifier
|
||||||
|
* @param providerDetails
|
||||||
*/
|
*/
|
||||||
WeatherProvider.register = function (providerIdentifier, providerDetails) {
|
WeatherProvider.register = function (providerIdentifier, providerDetails) {
|
||||||
WeatherProvider.providers[providerIdentifier.toLowerCase()] = WeatherProvider.extend(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.
|
* Static method to initialize a new weather provider.
|
||||||
|
*
|
||||||
|
* @param providerIdentifier
|
||||||
|
* @param delegate
|
||||||
*/
|
*/
|
||||||
WeatherProvider.initialize = function (providerIdentifier, delegate) {
|
WeatherProvider.initialize = function (providerIdentifier, delegate) {
|
||||||
providerIdentifier = providerIdentifier.toLowerCase();
|
providerIdentifier = providerIdentifier.toLowerCase();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user