Kaynağa Gözat

@uppy/companion: fix some linter warnings (#3752)

Antoine du Hamel 2 yıl önce
ebeveyn
işleme
29e8fffac1

+ 12 - 1
.eslintrc.js

@@ -307,8 +307,19 @@ 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
+        // but will require separate PRs to gradually get there
+        // and so the meantime: just warn
+        'class-methods-use-this': 'warn',
+        'consistent-return': 'warn',
+        'global-require': 'warn',
+        'import/order': 'warn',
+        'no-param-reassign': 'warn',
+        'no-redeclare': 'warn',
+        'no-shadow': 'warn',
+        'no-use-before-define': 'warn',
       },
     },
     {

+ 1 - 1
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

+ 10 - 10
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') {

+ 4 - 0
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) {

+ 3 - 0
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) {

+ 1 - 1
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,

+ 1 - 1
packages/@uppy/companion/src/server/redis.js

@@ -7,7 +7,7 @@ let redisClient
  * A Singleton module that provides a single redis client through out
  * the lifetime of the server
  *
- * @param {object=} opts node-redis client options
+ * @param {Record<string, unknown>} [opts] node-redis client options
  */
 function createClient (opts) {
   if (!redisClient) {