diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2019-09-25 18:19:42 +0200 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2019-10-01 17:16:09 +0200 |
commit | b9bc2417e7a8dc81feb0abe20359bedaf864f790 (patch) | |
tree | 61b47fbf37c1d168da8625224debde9e6a985348 /core/src/Util | |
parent | 7fb651235128dcbca8a6683b5cdafdf835f46300 (diff) | |
download | nextcloud-server-b9bc2417e7a8dc81feb0abe20359bedaf864f790.tar.gz nextcloud-server-b9bc2417e7a8dc81feb0abe20359bedaf864f790.zip |
Comply to eslint
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'core/src/Util')
-rw-r--r-- | core/src/Util/escapeHTML.js | 6 | ||||
-rw-r--r-- | core/src/Util/format-date.js | 6 | ||||
-rw-r--r-- | core/src/Util/get-url-parameter.js | 9 | ||||
-rw-r--r-- | core/src/Util/human-file-size.js | 28 | ||||
-rw-r--r-- | core/src/Util/relative-modified-date.js | 10 |
5 files changed, 31 insertions, 28 deletions
diff --git a/core/src/Util/escapeHTML.js b/core/src/Util/escapeHTML.js index f6cf868a6d0..b6596d44d21 100644 --- a/core/src/Util/escapeHTML.js +++ b/core/src/Util/escapeHTML.js @@ -22,9 +22,9 @@ /** * Sanitizes a HTML string by replacing all potential dangerous characters with HTML entities * @param {string} s String to sanitize - * @return {string} Sanitized string + * @returns {string} Sanitized string */ -export default function escapeHTML (s) { +export default function escapeHTML(s) { return s.toString() .split('&') .join('&') @@ -32,5 +32,5 @@ export default function escapeHTML (s) { .join('<').split('>') .join('>').split('"') .join('"').split('\'') - .join('''); + .join(''') } diff --git a/core/src/Util/format-date.js b/core/src/Util/format-date.js index 04a2d274de5..9551804d4ab 100644 --- a/core/src/Util/format-date.js +++ b/core/src/Util/format-date.js @@ -25,10 +25,10 @@ import OC from '../OC/index' /** * Format an UNIX timestamp to a human understandable format * @param {number} timestamp UNIX timestamp - * @return {string} Human readable format + * @returns {string} Human readable format * @deprecated 16.0.0 use OC.Util.formatDate instead */ -export default function formatDate (timestamp) { +export default function formatDate(timestamp) { console.warn('formatDate is deprecated, use OC.Util.formatDate instead') - return OC.Util.formatDate(timestamp); + return OC.Util.formatDate(timestamp) } diff --git a/core/src/Util/get-url-parameter.js b/core/src/Util/get-url-parameter.js index 6051e923e9d..6f809994f10 100644 --- a/core/src/Util/get-url-parameter.js +++ b/core/src/Util/get-url-parameter.js @@ -1,4 +1,4 @@ -/* +/** * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> * * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at> @@ -23,10 +23,11 @@ * Get the value of a URL parameter * @link http://stackoverflow.com/questions/1403888/get-url-parameter-with-jquery * @param {string} name URL parameter - * @return {string} + * @returns {string} */ -export default function getURLParameter (name) { +export default function getURLParameter(name) { return decodeURIComponent( + // eslint-disable-next-line no-sparse-arrays (new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search) || [, ''])[1].replace(/\+/g, '%20') - ) || ''; + ) || '' } diff --git a/core/src/Util/human-file-size.js b/core/src/Util/human-file-size.js index e671a86d053..586ef0e9267 100644 --- a/core/src/Util/human-file-size.js +++ b/core/src/Util/human-file-size.js @@ -23,29 +23,29 @@ * Returns a human readable file size * @param {number} size Size in bytes * @param {boolean} skipSmallSizes return '< 1 kB' for small files - * @return {string} + * @returns {string} */ -export default function humanFileSize (size, skipSmallSizes) { - var humanList = ['B', 'KB', 'MB', 'GB', 'TB']; +export default function humanFileSize(size, skipSmallSizes) { + var humanList = ['B', 'KB', 'MB', 'GB', 'TB'] // Calculate Log with base 1024: size = 1024 ** order - var order = size > 0 ? Math.floor(Math.log(size) / Math.log(1024)) : 0; + var order = size > 0 ? Math.floor(Math.log(size) / Math.log(1024)) : 0 // Stay in range of the byte sizes that are defined - order = Math.min(humanList.length - 1, order); - var readableFormat = humanList[order]; - var relativeSize = (size / Math.pow(1024, order)).toFixed(1); + order = Math.min(humanList.length - 1, order) + var readableFormat = humanList[order] + var relativeSize = (size / Math.pow(1024, order)).toFixed(1) if (skipSmallSizes === true && order === 0) { - if (relativeSize !== "0.0") { - return '< 1 KB'; + if (relativeSize !== '0.0') { + return '< 1 KB' } else { - return '0 KB'; + return '0 KB' } } if (order < 2) { - relativeSize = parseFloat(relativeSize).toFixed(0); + relativeSize = parseFloat(relativeSize).toFixed(0) } else if (relativeSize.substr(relativeSize.length - 2, 2) === '.0') { - relativeSize = relativeSize.substr(0, relativeSize.length - 2); + relativeSize = relativeSize.substr(0, relativeSize.length - 2) } else { - relativeSize = parseFloat(relativeSize).toLocaleString(OC.getCanonicalLocale()); + relativeSize = parseFloat(relativeSize).toLocaleString(OC.getCanonicalLocale()) } - return relativeSize + ' ' + readableFormat; + return relativeSize + ' ' + readableFormat } diff --git a/core/src/Util/relative-modified-date.js b/core/src/Util/relative-modified-date.js index 3837d2c372e..4e41f939250 100644 --- a/core/src/Util/relative-modified-date.js +++ b/core/src/Util/relative-modified-date.js @@ -1,4 +1,4 @@ -/* +/** * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> * * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at> @@ -24,14 +24,16 @@ import OC from '../OC/index' /** * Takes an absolute timestamp and return a string with a human-friendly relative date + * * @param {number} timestamp A Unix timestamp * @deprecated use OC.Util.relativeModifiedDate instead but beware the argument value + * @returns {string} */ -export default function relative_modified_date (timestamp) { - console.warn('relative_modified_date is deprecated, use OC.Util.relativeModifiedDate instead') +export default function relativeModifiedDate(timestamp) { + console.warn('relativeModifiedDate is deprecated, use OC.Util.relativeModifiedDate instead') /* Were multiplying by 1000 to bring the timestamp back to its original value per https://github.com/owncloud/core/pull/10647#discussion_r16790315 */ - return OC.Util.relativeModifiedDate(timestamp * 1000); + return OC.Util.relativeModifiedDate(timestamp * 1000) } |