From 02623847cfec6b82e980977492a38513441fd106 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Wed, 18 May 2022 11:56:35 +0200 Subject: [PATCH 1/2] @uppy/companion: fix JSDoc format --- .eslintrc.js | 32 +++++++++++++++++++ .../companion/src/server/helpers/utils.js | 2 +- packages/@uppy/companion/src/server/logger.js | 20 ++++++------ .../src/server/provider/box/index.js | 4 +++ .../src/server/provider/onedrive/index.js | 3 ++ packages/@uppy/companion/src/server/redis.js | 2 +- 6 files changed, 51 insertions(+), 12 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 07ec0fe5c5..03654642de 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -297,6 +297,38 @@ module.exports = { rules: { 'no-restricted-syntax': 'warn', 'no-underscore-dangle': 'off', + + // transloadit rules we would like to enforce in the future + // but will require separate PRs to gradually get there + // and so the meantime: just warn + 'class-methods-use-this': 'warn', + 'consistent-return': 'warn', + 'default-case': 'warn', + 'global-require': 'warn', + 'import/no-unresolved': 'warn', + 'import/order': 'warn', + 'max-classes-per-file': ['warn', 2], + 'no-mixed-operators': 'warn', + 'no-param-reassign': 'warn', + 'no-redeclare': 'warn', + 'no-shadow': 'warn', + 'no-use-before-define': 'warn', + 'radix': 'warn', + 'react/button-has-type': 'error', + 'react/destructuring-assignment': 'warn', + 'react/forbid-prop-types': 'error', + 'react/jsx-props-no-spreading': 'warn', + 'react/no-access-state-in-setstate': 'error', + 'react/no-array-index-key': 'error', + 'react/no-deprecated': 'error', + 'react/no-this-in-sfc': 'error', + 'react/no-will-update-set-state': 'error', + 'react/prefer-stateless-function': 'error', + 'react/sort-comp': 'error', + 'react/style-prop-object': 'error', + 'react/no-unknown-property': ['error', { + ignore: svgPresentationAttributes, + }], }, }, { diff --git a/packages/@uppy/companion/src/server/helpers/utils.js b/packages/@uppy/companion/src/server/helpers/utils.js index 42dde25858..98545ba66a 100644 --- a/packages/@uppy/companion/src/server/helpers/utils.js +++ b/packages/@uppy/companion/src/server/helpers/utils.js @@ -43,7 +43,7 @@ module.exports.getURLBuilder = (options) => { * * @param {string} path the tail path of the url * @param {boolean} isExternal if the url is for the external world - * @param {boolean=} excludeHost if the server domain and protocol should be included + * @param {boolean} [excludeHost] if the server domain and protocol should be included */ const buildURL = (path, isExternal, excludeHost) => { let url = path diff --git a/packages/@uppy/companion/src/server/logger.js b/packages/@uppy/companion/src/server/logger.js index d7bb051537..3875190e18 100644 --- a/packages/@uppy/companion/src/server/logger.js +++ b/packages/@uppy/companion/src/server/logger.js @@ -39,8 +39,8 @@ function maskMessage (msg) { * @param {string | Error} arg the message or error to log * @param {string} tag a unique tag to easily search for this message * @param {string} level error | info | debug - * @param {string=} id a unique id to easily trace logs tied to a request - * @param {Function=} color function to display the log in appropriate color + * @param {string} [id] a unique id to easily trace logs tied to a request + * @param {Function} [color] function to display the log in appropriate color */ const log = (arg, tag = '', level, id = '', color = (message) => message) => { const time = new Date().toISOString() @@ -66,8 +66,8 @@ const log = (arg, tag = '', level, id = '', color = (message) => message) => { * INFO level log * * @param {string} msg the message to log - * @param {string=} tag a unique tag to easily search for this message - * @param {string=} traceId a unique id to easily trace logs tied to a request + * @param {string} [tag] a unique tag to easily search for this message + * @param {string} [traceId] a unique id to easily trace logs tied to a request */ exports.info = (msg, tag, traceId) => { log(msg, tag, 'info', traceId) @@ -77,8 +77,8 @@ exports.info = (msg, tag, traceId) => { * WARN level log * * @param {string} msg the message to log - * @param {string=} tag a unique tag to easily search for this message - * @param {string=} traceId a unique id to easily trace logs tied to a request + * @param {string} [tag] a unique tag to easily search for this message + * @param {string} [traceId] a unique id to easily trace logs tied to a request */ exports.warn = (msg, tag, traceId) => { // @ts-ignore @@ -89,8 +89,8 @@ exports.warn = (msg, tag, traceId) => { * ERROR level log * * @param {string | Error} msg the message to log - * @param {string=} tag a unique tag to easily search for this message - * @param {string=} traceId a unique id to easily trace logs tied to a request + * @param {string} [tag] a unique tag to easily search for this message + * @param {string} [traceId] a unique id to easily trace logs tied to a request */ exports.error = (msg, tag, traceId) => { // @ts-ignore @@ -101,8 +101,8 @@ exports.error = (msg, tag, traceId) => { * DEBUG level log * * @param {string} msg the message to log - * @param {string=} tag a unique tag to easily search for this message - * @param {string=} traceId a unique id to easily trace logs tied to a request + * @param {string} [tag] a unique tag to easily search for this message + * @param {string} [traceId] a unique id to easily trace logs tied to a request */ exports.debug = (msg, tag, traceId) => { if (process.env.NODE_ENV !== 'production') { diff --git a/packages/@uppy/companion/src/server/provider/box/index.js b/packages/@uppy/companion/src/server/provider/box/index.js index 9023f7551f..532ea1323e 100644 --- a/packages/@uppy/companion/src/server/provider/box/index.js +++ b/packages/@uppy/companion/src/server/provider/box/index.js @@ -41,6 +41,10 @@ class Box extends Provider { * Lists files and folders from Box API * * @param {object} options + * @param {string} options.directory + * @param {any} options.query + * @param {string} options.token + * @param {unknown} options.companion * @param {Function} done */ _list ({ directory, token, query, companion }, done) { diff --git a/packages/@uppy/companion/src/server/provider/onedrive/index.js b/packages/@uppy/companion/src/server/provider/onedrive/index.js index b7ee7a62ae..23ffeb7b0c 100644 --- a/packages/@uppy/companion/src/server/provider/onedrive/index.js +++ b/packages/@uppy/companion/src/server/provider/onedrive/index.js @@ -37,6 +37,9 @@ class OneDrive extends Provider { * it then waits till both requests are done before proceeding with the callback * * @param {object} options + * @param {string} options.directory + * @param {any} options.query + * @param {string} options.token * @param {Function} done */ _list ({ directory, query, token }, done) { diff --git a/packages/@uppy/companion/src/server/redis.js b/packages/@uppy/companion/src/server/redis.js index fd1bc3b7f8..a1d7576546 100644 --- a/packages/@uppy/companion/src/server/redis.js +++ b/packages/@uppy/companion/src/server/redis.js @@ -6,7 +6,7 @@ let redisClient * A Singleton module that provides only on redis client through out * the lifetime of the server * - * @param {object=} opts node-redis client options + * @param {Record} [opts] node-redis client options */ module.exports.client = (opts) => { if (!opts) { From 7d2099823becc71fc807ea40532ca7fb00368cb7 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Tue, 24 May 2022 01:04:26 +0200 Subject: [PATCH 2/2] consolidate lint rules --- .eslintrc.js | 21 ------------------- .../src/server/provider/unsplash/adapter.js | 2 +- 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 03654642de..7a1dfff98d 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -295,7 +295,6 @@ module.exports = { { files: ['./packages/@uppy/companion/**/*.js'], rules: { - 'no-restricted-syntax': 'warn', 'no-underscore-dangle': 'off', // transloadit rules we would like to enforce in the future @@ -303,32 +302,12 @@ module.exports = { // and so the meantime: just warn 'class-methods-use-this': 'warn', 'consistent-return': 'warn', - 'default-case': 'warn', 'global-require': 'warn', - 'import/no-unresolved': 'warn', 'import/order': 'warn', - 'max-classes-per-file': ['warn', 2], - 'no-mixed-operators': 'warn', 'no-param-reassign': 'warn', 'no-redeclare': 'warn', 'no-shadow': 'warn', 'no-use-before-define': 'warn', - 'radix': 'warn', - 'react/button-has-type': 'error', - 'react/destructuring-assignment': 'warn', - 'react/forbid-prop-types': 'error', - 'react/jsx-props-no-spreading': 'warn', - 'react/no-access-state-in-setstate': 'error', - 'react/no-array-index-key': 'error', - 'react/no-deprecated': 'error', - 'react/no-this-in-sfc': 'error', - 'react/no-will-update-set-state': 'error', - 'react/prefer-stateless-function': 'error', - 'react/sort-comp': 'error', - 'react/style-prop-object': 'error', - 'react/no-unknown-property': ['error', { - ignore: svgPresentationAttributes, - }], }, }, { diff --git a/packages/@uppy/companion/src/server/provider/unsplash/adapter.js b/packages/@uppy/companion/src/server/provider/unsplash/adapter.js index 9735b0c1c0..3fb9bcec91 100644 --- a/packages/@uppy/companion/src/server/provider/unsplash/adapter.js +++ b/packages/@uppy/companion/src/server/provider/unsplash/adapter.js @@ -40,7 +40,7 @@ exports.getItemThumbnailUrl = (item) => { } exports.getNextPageQuery = (currentQuery) => { - const newCursor = parseInt(currentQuery.cursor || 1) + 1 + const newCursor = Number.parseInt(currentQuery.cursor || 1, 10) + 1 const query = { ...currentQuery, cursor: newCursor,