add .gitattributes and fix prettier/js warnings (#3094)

see title, as discussed in
https://github.com/MichMich/MagicMirror/pull/3093
This commit is contained in:
Karsten Hassel
2023-04-22 09:29:51 +02:00
committed by GitHub
parent b80485b52f
commit a41aa48dd1
37 changed files with 58 additions and 162 deletions

View File

@@ -44,7 +44,6 @@ process.on("uncaughtException", function (err) {
/**
* The core app.
*
* @class
*/
function App() {
@@ -53,7 +52,6 @@ function App() {
/**
* Loads the config file. Combines it with the defaults and returns the config
*
* @async
* @returns {Promise<object>} the loaded config or the defaults if something goes wrong
*/
@@ -135,7 +133,6 @@ function App() {
/**
* Checks the config for deprecated options and throws a warning in the logs
* if it encounters one option from the deprecated.js list
*
* @param {object} userConfig The user config
*/
function checkDeprecatedOptions(userConfig) {
@@ -150,7 +147,6 @@ function App() {
/**
* Loads a specific module.
*
* @param {string} module The name of the module (including subpath).
*/
function loadModule(module) {
@@ -204,7 +200,6 @@ function App() {
/**
* Loads all modules.
*
* @param {Module[]} modules All modules to be loaded
* @returns {Promise} A promise that is resolved when all modules been loaded
*/
@@ -220,7 +215,6 @@ function App() {
/**
* Compare two semantic version numbers and return the difference.
*
* @param {string} a Version number a.
* @param {string} b Version number b.
* @returns {number} A positive number if a is larger than b, a negative
@@ -246,7 +240,6 @@ function App() {
* Start the core app.
*
* It loads the config, then it loads all modules.
*
* @async
* @returns {Promise<object>} the config used
*/
@@ -301,7 +294,6 @@ function App() {
* exists.
*
* Added to fix #1056
*
* @returns {Promise} A promise that is resolved when all node_helpers and
* the http server has been closed
*/

View File

@@ -18,7 +18,6 @@ const Utils = require(`${rootPath}/js/utils.js`);
/**
* Returns a string with path of configuration file.
* Check if set by environment variable MM_CONFIG_FILE
*
* @returns {string} path and filename of the config file
*/
function getConfigFile() {

View File

@@ -82,7 +82,6 @@
/**
* Define the clone method for later use. Helper Method.
*
* @param {object} obj Object to be cloned
* @returns {object} the cloned object
*/

View File

@@ -4,7 +4,6 @@
*
* Attention: After some discussion we always return the third party
* implementation until the node implementation is stable and more tested
*
* @see https://github.com/MichMich/MagicMirror/pull/2952
* @see https://github.com/MichMich/MagicMirror/issues/2649
* @param {string} url to be fetched

View File

@@ -52,7 +52,6 @@ const Loader = (function () {
/**
* Retrieve list of all modules.
*
* @returns {object[]} module data as configured in config
*/
const getAllModules = function () {
@@ -61,7 +60,6 @@ const Loader = (function () {
/**
* Generate array with module information including module paths.
*
* @returns {object[]} Module information.
*/
const getModuleData = function () {
@@ -103,7 +101,6 @@ const Loader = (function () {
/**
* Load modules via ajax request and create module objects.
*
* @param {object} module Information about the module we want to load.
* @returns {Promise<void>} resolved when module is loaded
*/
@@ -131,7 +128,6 @@ const Loader = (function () {
/**
* Bootstrap modules by setting the module data and loading the scripts & styles.
*
* @param {object} module Information about the module we want to load.
* @param {Module} mObj Modules instance.
*/
@@ -153,7 +149,6 @@ const Loader = (function () {
/**
* Load a script or stylesheet by adding it to the dom.
*
* @param {string} fileName Path of the file we want to load.
* @returns {Promise} resolved when the file is loaded
*/
@@ -229,7 +224,6 @@ const Loader = (function () {
/**
* Load a file (script or stylesheet).
* Prevent double loading and search for files in the vendor folder.
*
* @param {string} fileName Path of the file we want to load.
* @param {Module} module The module that calls the loadFile function.
* @returns {Promise} resolved when the file is loaded

View File

@@ -68,7 +68,6 @@ const MM = (function () {
/**
* Select the wrapper dom object for a specific position.
*
* @param {string} position The name of the position.
* @returns {HTMLElement | void} the wrapper element
*/
@@ -85,7 +84,6 @@ const MM = (function () {
/**
* Send a notification to all modules.
*
* @param {string} notification The identifier of the notification.
* @param {*} payload The payload of the notification.
* @param {Module} sender The module that sent the notification.
@@ -102,7 +100,6 @@ const MM = (function () {
/**
* Update the dom for a specific module.
*
* @param {Module} module The module that needs an update.
* @param {number} [speed] The (optional) number of microseconds for the animation.
* @returns {Promise} Resolved when the dom is fully updated.
@@ -129,7 +126,6 @@ const MM = (function () {
/**
* Update the dom with the specified content
*
* @param {Module} module The module that needs an update.
* @param {number} [speed] The (optional) number of microseconds for the animation.
* @param {string} newHeader The new header that is generated.
@@ -167,7 +163,6 @@ const MM = (function () {
/**
* Check if the content has changed.
*
* @param {Module} module The module to check.
* @param {string} newHeader The new header that is generated.
* @param {HTMLElement} newContent The new content that is generated.
@@ -198,7 +193,6 @@ const MM = (function () {
/**
* Update the content of a module on screen.
*
* @param {Module} module The module to check.
* @param {string} newHeader The new header that is generated.
* @param {HTMLElement} newContent The new content that is generated.
@@ -224,7 +218,6 @@ const MM = (function () {
/**
* Hide the module.
*
* @param {Module} module The module to hide.
* @param {number} speed The speed of the hide animation.
* @param {Function} callback Called when the animation is done.
@@ -269,7 +262,6 @@ const MM = (function () {
/**
* Show the module.
*
* @param {Module} module The module to show.
* @param {number} speed The speed of the show animation.
* @param {Function} callback Called when the animation is done.
@@ -376,13 +368,11 @@ const MM = (function () {
/**
* Adds special selectors on a collection of modules.
*
* @param {Module[]} modules Array of modules.
*/
const setSelectionMethodsForModules = function (modules) {
/**
* Filter modules with the specified classes.
*
* @param {string|string[]} className one or multiple classnames (array or space divided).
* @returns {Module[]} Filtered collection of modules.
*/
@@ -392,7 +382,6 @@ const MM = (function () {
/**
* Filter modules without the specified classes.
*
* @param {string|string[]} className one or multiple classnames (array or space divided).
* @returns {Module[]} Filtered collection of modules.
*/
@@ -402,7 +391,6 @@ const MM = (function () {
/**
* Filters a collection of modules based on classname(s).
*
* @param {string|string[]} className one or multiple classnames (array or space divided).
* @param {boolean} include if the filter should include or exclude the modules with the specific classes.
* @returns {Module[]} Filtered collection of modules.
@@ -431,7 +419,6 @@ const MM = (function () {
/**
* Removes a module instance from the collection.
*
* @param {object} module The module instance to remove from the collection.
* @returns {Module[]} Filtered collection of modules.
*/
@@ -446,7 +433,6 @@ const MM = (function () {
/**
* Walks thru a collection of modules and executes the callback with the module as an argument.
*
* @param {Function} callback The function to execute with the module as an argument.
*/
const enumerate = function (callback) {
@@ -487,7 +473,6 @@ const MM = (function () {
/**
* Gets called when all modules are started.
*
* @param {Module[]} moduleObjects All module instances.
*/
modulesStarted: function (moduleObjects) {
@@ -502,7 +487,6 @@ const MM = (function () {
/**
* Send a notification to all modules.
*
* @param {string} notification The identifier of the notification.
* @param {*} payload The payload of the notification.
* @param {Module} sender The module that sent the notification.
@@ -529,7 +513,6 @@ const MM = (function () {
/**
* Update the dom for a specific module.
*
* @param {Module} module The module that needs an update.
* @param {number} [speed] The number of microseconds for the animation.
*/
@@ -550,7 +533,6 @@ const MM = (function () {
/**
* Returns a collection of all modules currently active.
*
* @returns {Module[]} A collection of all modules currently active.
*/
getModules: function () {
@@ -560,7 +542,6 @@ const MM = (function () {
/**
* Hide the module.
*
* @param {Module} module The module to hide.
* @param {number} speed The speed of the hide animation.
* @param {Function} callback Called when the animation is done.
@@ -573,7 +554,6 @@ const MM = (function () {
/**
* Show the module.
*
* @param {Module} module The module to show.
* @param {number} speed The speed of the show animation.
* @param {Function} callback Called when the animation is done.

View File

@@ -46,7 +46,6 @@ const Module = Class.extend({
/**
* Returns a list of scripts the module requires to be loaded.
*
* @returns {string[]} An array with filenames.
*/
getScripts: function () {
@@ -55,7 +54,6 @@ const Module = Class.extend({
/**
* Returns a list of stylesheets the module requires to be loaded.
*
* @returns {string[]} An array with filenames.
*/
getStyles: function () {
@@ -66,7 +64,6 @@ const Module = Class.extend({
* Returns a map of translation files the module requires to be loaded.
*
* return Map<String, String> -
*
* @returns {*} A map with langKeys and filenames.
*/
getTranslations: function () {
@@ -77,7 +74,6 @@ const Module = Class.extend({
* Generates the dom which needs to be displayed. This method is called by the MagicMirror² core.
* This method can to be subclassed if the module wants to display info on the mirror.
* Alternatively, the getTemplate method could be subclassed.
*
* @returns {HTMLElement|Promise} The dom or a promise with the dom to display.
*/
getDom: function () {
@@ -111,7 +107,6 @@ const Module = Class.extend({
* Generates the header string which needs to be displayed if a user has a header configured for this module.
* This method is called by the MagicMirror² core, but only if the user has configured a default header for the module.
* This method needs to be subclassed if the module wants to display modified headers on the mirror.
*
* @returns {string} The header to display above the header.
*/
getHeader: function () {
@@ -123,7 +118,6 @@ const Module = Class.extend({
* This method needs to be subclassed if the module wants to use a template.
* It can either return a template sting, or a template filename.
* If the string ends with '.html' it's considered a file from within the module's folder.
*
* @returns {string} The template string of filename.
*/
getTemplate: function () {
@@ -133,7 +127,6 @@ const Module = Class.extend({
/**
* Returns the data to be used in the template.
* This method needs to be subclassed if the module wants to use a custom data.
*
* @returns {object} The data for the template
*/
getTemplateData: function () {
@@ -142,7 +135,6 @@ const Module = Class.extend({
/**
* Called by the MagicMirror² core when a notification arrives.
*
* @param {string} notification The identifier of the notification.
* @param {*} payload The payload of the notification.
* @param {Module} sender The module that sent the notification.
@@ -158,7 +150,6 @@ const Module = Class.extend({
/**
* Returns the nunjucks environment for the current module.
* The environment is checked in the _nunjucksEnvironment instance variable.
*
* @returns {object} The Nunjucks Environment
*/
nunjucksEnvironment: function () {
@@ -180,7 +171,6 @@ const Module = Class.extend({
/**
* Called when a socket notification arrives.
*
* @param {string} notification The identifier of the notification.
* @param {*} payload The payload of the notification.
*/
@@ -208,7 +198,6 @@ const Module = Class.extend({
/**
* Set the module data.
*
* @param {object} data The module data
*/
setData: function (data) {
@@ -222,7 +211,6 @@ const Module = Class.extend({
/**
* Set the module config and combine it with the module defaults.
*
* @param {object} config The combined module config.
* @param {boolean} deep Merge module config in deep.
*/
@@ -233,7 +221,6 @@ const Module = Class.extend({
/**
* Returns a socket object. If it doesn't exist, it's created.
* It also registers the notification callback.
*
* @returns {MMSocket} a socket object
*/
socket: function () {
@@ -250,7 +237,6 @@ const Module = Class.extend({
/**
* Retrieve the path to a module file.
*
* @param {string} file Filename
* @returns {string} the file path
*/
@@ -260,7 +246,6 @@ const Module = Class.extend({
/**
* Load all required stylesheets by requesting the MM object to load the files.
*
* @returns {Promise<void>}
*/
loadStyles: function () {
@@ -269,7 +254,6 @@ const Module = Class.extend({
/**
* Load all required scripts by requesting the MM object to load the files.
*
* @returns {Promise<void>}
*/
loadScripts: function () {
@@ -278,7 +262,6 @@ const Module = Class.extend({
/**
* Helper method to load all dependencies.
*
* @param {string} funcName Function name to call to get scripts or styles.
* @returns {Promise<void>}
*/
@@ -301,6 +284,7 @@ const Module = Class.extend({
/**
* Load all translations.
* @returns {Promise<void>}
*/
loadTranslations: async function () {
const translations = this.getTranslations() || {};
@@ -329,7 +313,6 @@ const Module = Class.extend({
/**
* Request the translation for a given key with optional variables and default value.
*
* @param {string} key The key of the string to translate
* @param {string|object} [defaultValueOrVariables] The default value or variables for translating.
* @param {string} [defaultValue] The default value with variables.
@@ -344,7 +327,6 @@ const Module = Class.extend({
/**
* Request an (animated) update of the module.
*
* @param {number} [speed] The speed of the animation.
*/
updateDom: function (speed) {
@@ -353,7 +335,6 @@ const Module = Class.extend({
/**
* Send a notification to all modules.
*
* @param {string} notification The identifier of the notification.
* @param {*} payload The payload of the notification.
*/
@@ -363,7 +344,6 @@ const Module = Class.extend({
/**
* Send a socket notification to the node helper.
*
* @param {string} notification The identifier of the notification.
* @param {*} payload The payload of the notification.
*/
@@ -373,7 +353,6 @@ const Module = Class.extend({
/**
* Hide this module.
*
* @param {number} speed The speed of the hide animation.
* @param {Function} callback Called when the animation is done.
* @param {object} [options] Optional settings for the hide method.
@@ -401,7 +380,6 @@ const Module = Class.extend({
/**
* Show this module.
*
* @param {number} speed The speed of the show animation.
* @param {Function} callback Called when the animation is done.
* @param {object} [options] Optional settings for the show method.
@@ -447,7 +425,6 @@ const Module = Class.extend({
* -------
*
* Todo: idea of Mich determinate what do you want to merge or not
*
* @param {object} result the initial object
* @returns {object} the merged config
*/
@@ -509,7 +486,6 @@ window.Module = Module;
/**
* Compare two semantic version numbers and return the difference.
*
* @param {string} a Version number a.
* @param {string} b Version number b.
* @returns {number} A positive number if a is larger than b, a negative

View File

@@ -32,7 +32,6 @@ const NodeHelper = Class.extend({
/**
* This method is called when a socket notification arrives.
*
* @param {string} notification The identifier of the notification.
* @param {*} payload The payload of the notification.
*/
@@ -42,7 +41,6 @@ const NodeHelper = Class.extend({
/**
* Set the module name.
*
* @param {string} name Module name.
*/
setName(name) {
@@ -51,7 +49,6 @@ const NodeHelper = Class.extend({
/**
* Set the module path.
*
* @param {string} path Module path.
*/
setPath(path) {
@@ -123,7 +120,6 @@ NodeHelper.checkFetchStatus = function (response) {
/**
* Look at the specified error and return an appropriate error type, that
* can be translated to a detailed error message
*
* @param {Error} error the error from fetching something
* @returns {string} the string of the detailed error message in the translations
*/

View File

@@ -19,7 +19,6 @@ const { cors, getConfig, getHtml, getVersion } = require("./server_functions");
/**
* Server
*
* @param {object} config The MM config
* @class
*/
@@ -31,7 +30,6 @@ function Server(config) {
/**
* Opens the server for incoming connections
*
* @returns {Promise} A promise that is resolved when the server listens to connections
*/
this.open = function () {
@@ -106,7 +104,6 @@ function Server(config) {
/**
* Closes the server and destroys all lingering connections to it.
*
* @returns {Promise} A promise that resolves when server has successfully shut down
*/
this.close = function () {

View File

@@ -5,7 +5,6 @@ const fetch = require("./fetch");
/**
* Gets the config.
*
* @param {Request} req - the request
* @param {Response} res - the result
*/
@@ -19,7 +18,6 @@ function getConfig(req, res) {
* Example input request url: /cors?sendheaders=header1:value1,header2:value2&expectedheaders=header1,header2&url=http://www.test.com/path?param1=value1
*
* Only the url-param of the input request url is required. It must be the last parameter.
*
* @param {Request} req - the request
* @param {Response} res - the result
*/
@@ -57,7 +55,6 @@ async function cors(req, res) {
/**
* Gets headers and values to attach to the web request.
*
* @param {string} url - The url containing the headers and values to send.
* @returns {object} An object specifying name and value of the headers.
*/
@@ -79,7 +76,6 @@ function getHeadersToSend(url) {
/**
* Gets the headers expected from the response.
*
* @param {string} url - The url containing the expected headers from the response.
* @returns {string[]} headers - The name of the expected headers.
*/
@@ -97,7 +93,6 @@ function geExpectedRecievedHeaders(url) {
/**
* Gets the HTML to display the magic mirror.
*
* @param {Request} req - the request
* @param {Response} res - the result
*/
@@ -116,7 +111,6 @@ function getHtml(req, res) {
/**
* Gets the MagicMirror version.
*
* @param {Request} req - the request
* @param {Response} res - the result
*/

View File

@@ -9,7 +9,6 @@
const Translator = (function () {
/**
* Load a JSON file via XHR.
*
* @param {string} file Path of the file we want to load.
* @returns {Promise<object>} the translations in the specified file
*/
@@ -43,7 +42,6 @@ const Translator = (function () {
/**
* Load a translation for a given key for a given module.
*
* @param {Module} module The module to load the translation for.
* @param {string} key The key of the text to translate.
* @param {object} variables The variables to use within the translation template (optional)
@@ -55,7 +53,6 @@ const Translator = (function () {
* 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 {string} template Text with placeholder
* @param {object} variables Variables for the placeholder
* @returns {string} the template filled with the variables
@@ -98,7 +95,6 @@ const Translator = (function () {
/**
* Load a translation file (json) and remember the data.
*
* @param {Module} module The module to load the translation file for.
* @param {string} file Path of the file we want to load.
* @param {boolean} isFallback Flag to indicate fallback translations.
@@ -117,7 +113,6 @@ const Translator = (function () {
/**
* Load the core translations.
*
* @param {string} lang The language identifier of the core language.
*/
loadCoreTranslations: async function (lang) {