Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@uppy/companion: fix some linter warnings #3752

Merged
merged 2 commits into from
May 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does this have to do with jsdoc?
shouldn't this be done in the parent .eslintrc instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What parent .eslintrc? That's the root one. My plan is to harden lint rules for the whole repo (#3755), but we need to keep Companion's out of it because there's still too many errors and warnings in its source. I can make it part of another PR, or rename this PR, as you prefer.

// 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',
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/companion/src/server/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
mifi marked this conversation as resolved.
Show resolved Hide resolved
* @param {boolean} [excludeHost] if the server domain and protocol should be included
*/
const buildURL = (path, isExternal, excludeHost) => {
let url = path
Expand Down
20 changes: 10 additions & 10 deletions packages/@uppy/companion/src/server/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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') {
Expand Down
4 changes: 4 additions & 0 deletions packages/@uppy/companion/src/server/provider/box/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/companion/src/server/redis.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, unknown>} [opts] node-redis client options
*/
module.exports.client = (opts) => {
if (!opts) {
Expand Down