diff --git a/src/box-command.js b/src/box-command.js index 13729b50..7e43481a 100644 --- a/src/box-command.js +++ b/src/box-command.js @@ -300,7 +300,9 @@ class BoxCommand extends Command { // Set up the command for bulk run DEBUG.init('Preparing for bulk input'); this.isBulk = true; + // eslint-disable-next-line unicorn/prefer-structured-clone originalArgs = _.cloneDeep(this.constructor.args); + // eslint-disable-next-line unicorn/prefer-structured-clone originalFlags = _.cloneDeep(this.constructor.flags); this.disableRequiredArgsAndFlags(); } @@ -615,7 +617,7 @@ class BoxCommand extends Command { let parsedData; try { let jsonFile = JSON.parse(fileContents); - parsedData = jsonFile.hasOwnProperty('entries') + parsedData = Object.hasOwn(jsonFile, 'entries') ? jsonFile.entries : jsonFile; } catch (error) { @@ -651,10 +653,7 @@ class BoxCommand extends Command { // Arrays can be one of two things: an array of values for a single key, // or an array of grouped flags/args as objects // First, check if everything in the array is either all object or all non-object - let types = value.reduce( - (acc, t) => acc.concat(typeof t), - [] - ); + let types = value.map((t) => typeof t); if ( types.some((t) => t !== 'object') && types.includes('object') @@ -1196,11 +1195,10 @@ class BoxCommand extends Command { if (Array.isArray(content)) { // Format each object individually and then flatten in case this an array of arrays, // which happens when a command that outputs a collection gets run in bulk - formattedOutputData = ( - await Promise.all( - content.map((o) => this._formatOutputObject(o)) - ) - ).flat(); + const formattedOutputResults = await Promise.all( + content.map((o) => this._formatOutputObject(o)) + ); + formattedOutputData = formattedOutputResults.flat(); DEBUG.output( 'Formatted %d output entries for display', content.length @@ -1649,9 +1647,10 @@ class BoxCommand extends Command { if (!fields) { return output; } - fields = REQUIRED_FIELDS.concat( - fields.split(',').filter((f) => !REQUIRED_FIELDS.includes(f)) - ); + fields = [ + ...REQUIRED_FIELDS, + ...fields.split(',').filter((f) => !REQUIRED_FIELDS.includes(f)), + ]; DEBUG.output('Filtering output with fields: %O', fields); if (Array.isArray(output)) { output = output.map((o) => @@ -1723,7 +1722,7 @@ class BoxCommand extends Command { ) { let subKeys = this.getNestedKeys(object[key]); subKeys = subKeys.map((x) => `${key}.${x}`); - keys = keys.concat(subKeys); + keys = [...keys, ...subKeys]; } else { keys.push(key); } @@ -1757,10 +1756,10 @@ class BoxCommand extends Command { ); // Successively apply the offsets to the current time - newDate = argPairs.reduce( - (d, args) => offsetDate(d, ...args), - new Date() - ); + newDate = new Date(); + for (const args of argPairs) { + newDate = offsetDate(newDate, ...args); + } } else if (time === 'now') { newDate = new Date(); } else { diff --git a/src/commands/collaborations/update.js b/src/commands/collaborations/update.js index ef26f734..dcc5a2a5 100644 --- a/src/commands/collaborations/update.js +++ b/src/commands/collaborations/update.js @@ -15,7 +15,7 @@ class CollaborationsUpdateCommand extends BoxCommand { if (flags.status) { parameters.body.status = flags.status; } - if (flags.hasOwnProperty('can-view-path')) { + if (Object.hasOwn(flags, 'can-view-path')) { parameters.body.can_view_path = flags['can-view-path']; } if (flags.role) { diff --git a/src/commands/configure/environments/add.js b/src/commands/configure/environments/add.js index 5e18de58..26eb5938 100644 --- a/src/commands/configure/environments/add.js +++ b/src/commands/configure/environments/add.js @@ -45,7 +45,7 @@ class EnvironmentsAddCommand extends BoxCommand { cacheTokens: true, }; - if (environmentsObject.environments.hasOwnProperty(environmentName)) { + if (Object.hasOwn(environmentsObject.environments, environmentName)) { throw new BoxCLIError( 'There already is an environment with this name' ); diff --git a/src/commands/configure/environments/delete.js b/src/commands/configure/environments/delete.js index 0e213fb8..254c21b2 100644 --- a/src/commands/configure/environments/delete.js +++ b/src/commands/configure/environments/delete.js @@ -27,7 +27,7 @@ class EnvironmentsDeleteCommand extends BoxCommand { name = answers.environment; } - if (environmentsObject.environments.hasOwnProperty(name)) { + if (Object.hasOwn(environmentsObject.environments, name)) { delete environmentsObject.environments[name]; if (environmentsObject.default === name) { environmentsObject.default = ''; diff --git a/src/commands/configure/environments/set-current.js b/src/commands/configure/environments/set-current.js index 551fd2e4..47ff9ffa 100644 --- a/src/commands/configure/environments/set-current.js +++ b/src/commands/configure/environments/set-current.js @@ -22,7 +22,7 @@ class EnvironmentsSetCurrentCommand extends BoxCommand { name = answers.environment; } - if (environmentsObject.environments.hasOwnProperty(name)) { + if (Object.hasOwn(environmentsObject.environments, name)) { environmentsObject.default = name; await this.updateEnvironments(environmentsObject); this.info(`The ${name} environment has been set as the default`); diff --git a/src/commands/configure/environments/update.js b/src/commands/configure/environments/update.js index 06a19619..42c39b22 100644 --- a/src/commands/configure/environments/update.js +++ b/src/commands/configure/environments/update.js @@ -62,7 +62,7 @@ class EnvironmentsUpdateCommand extends BoxCommand { environment.useDefaultAsUser = true; } - if (flags.hasOwnProperty('cache-tokens')) { + if (Object.hasOwn(flags, 'cache-tokens')) { environment.cacheTokens = flags['cache-tokens']; } diff --git a/src/commands/configure/settings.js b/src/commands/configure/settings.js index cf9ffaee..3df95908 100644 --- a/src/commands/configure/settings.js +++ b/src/commands/configure/settings.js @@ -68,10 +68,10 @@ class ConfigureSettingsCommand extends BoxCommand { } settings.boxReportsFolderPath = reportsPath; } - if (flags.hasOwnProperty('output-json')) { + if (Object.hasOwn(flags, 'output-json')) { settings.outputJson = flags['output-json']; } - if (flags.hasOwnProperty('enable-proxy')) { + if (Object.hasOwn(flags, 'enable-proxy')) { settings.enableProxy = flags['enable-proxy']; } if (flags['proxy-url']) { @@ -83,7 +83,7 @@ class ConfigureSettingsCommand extends BoxCommand { if (flags['proxy-password']) { settings.proxy.password = flags['proxy-password']; } - if (flags.hasOwnProperty(['enable-analytics-client'])) { + if (Object.hasOwn(flags, 'enable-analytics-client')) { settings.enableAnalyticsClient = flags['enable-analytics-client']; } if (flags['analytics-client-name']) { diff --git a/src/commands/files/lock.js b/src/commands/files/lock.js index d4b00be9..8ac0b7b1 100644 --- a/src/commands/files/lock.js +++ b/src/commands/files/lock.js @@ -11,7 +11,7 @@ class FilesLockCommand extends BoxCommand { if (flags.expires) { options.expires_at = flags.expires; } - if (flags.hasOwnProperty('prevent-download')) { + if (Object.hasOwn(flags, 'prevent-download')) { options.is_download_prevented = flags['prevent-download']; } diff --git a/src/commands/files/rename.js b/src/commands/files/rename.js index d641f5b1..75fde85c 100644 --- a/src/commands/files/rename.js +++ b/src/commands/files/rename.js @@ -11,7 +11,7 @@ class FilesRenameCommand extends BoxCommand { name: args.name, }; - if (flags.hasOwnProperty('description')) { + if (Object.hasOwn(flags, 'description')) { options.description = flags.description; } diff --git a/src/commands/files/update.js b/src/commands/files/update.js index 45fdbca3..b5fef7c7 100644 --- a/src/commands/files/update.js +++ b/src/commands/files/update.js @@ -12,7 +12,7 @@ class FileUpdateCommand extends BoxCommand { if (flags.name) { updates.name = flags.name; } - if (flags.hasOwnProperty('description')) { + if (Object.hasOwn(flags, 'description')) { updates.description = flags.description; } if (flags.tags) { diff --git a/src/commands/folders/delete.js b/src/commands/folders/delete.js index 7e08a135..0ccd0780 100644 --- a/src/commands/folders/delete.js +++ b/src/commands/folders/delete.js @@ -8,7 +8,7 @@ class FoldersDeleteCommand extends BoxCommand { const { flags, args } = await this.parse(FoldersDeleteCommand); let options = {}; - if (flags.hasOwnProperty('recursive')) { + if (Object.hasOwn(flags, 'recursive')) { options.recursive = flags.recursive; } diff --git a/src/commands/folders/download.js b/src/commands/folders/download.js index 07d269a9..aed33d5a 100644 --- a/src/commands/folders/download.js +++ b/src/commands/folders/download.js @@ -46,7 +46,7 @@ class FoldersDownloadCommand extends BoxCommand { this.outputPath = null; this.maxDepth = - flags.hasOwnProperty('depth') && flags.depth >= 0 + Object.hasOwn(flags, 'depth') && flags.depth >= 0 ? flags.depth : Number.POSITIVE_INFINITY; this.overwrite = flags.overwrite; diff --git a/src/commands/folders/update.js b/src/commands/folders/update.js index 71de171f..9f3958a3 100644 --- a/src/commands/folders/update.js +++ b/src/commands/folders/update.js @@ -12,14 +12,14 @@ class FoldersUpdateCommand extends BoxCommand { if (flags.name) { updates.name = flags.name; } - if (flags.hasOwnProperty('can-non-owners-invite')) { + if (Object.hasOwn(flags, 'can-non-owners-invite')) { updates.can_non_owners_invite = flags['can-non-owners-invite']; } - if (flags.hasOwnProperty('can-non-owners-view-collaborators')) { + if (Object.hasOwn(flags, 'can-non-owners-view-collaborators')) { updates.can_non_owners_view_collaborators = flags['can-non-owners-view-collaborators']; } - if (flags.hasOwnProperty('description')) { + if (Object.hasOwn(flags, 'description')) { updates.description = flags.description; } if (flags['upload-email-access']) { @@ -27,17 +27,17 @@ class FoldersUpdateCommand extends BoxCommand { access: flags['upload-email-access'], }; } - if (flags.hasOwnProperty('restrict-collaboration')) { + if (Object.hasOwn(flags, 'restrict-collaboration')) { updates.can_non_owners_invite = !flags['restrict-collaboration']; } - if (flags.hasOwnProperty('restrict-to-enterprise')) { + if (Object.hasOwn(flags, 'restrict-to-enterprise')) { updates.is_collaboration_restricted_to_enterprise = flags['restrict-to-enterprise']; } if (flags.tags) { updates.tags = flags.tags.split(','); } - if (flags.hasOwnProperty('sync')) { + if (Object.hasOwn(flags, 'sync')) { updates.sync_state = flags.sync ? 'synced' : 'not_synced'; } diff --git a/src/commands/groups/memberships/add.js b/src/commands/groups/memberships/add.js index f1fa2ebc..52b02026 100644 --- a/src/commands/groups/memberships/add.js +++ b/src/commands/groups/memberships/add.js @@ -8,19 +8,19 @@ class GroupsAddMembershipCommand extends BoxCommand { const { flags, args } = await this.parse(GroupsAddMembershipCommand); let options = { configurable_permissions: {} }; - if (flags.hasOwnProperty('can-run-reports')) { + if (Object.hasOwn(flags, 'can-run-reports')) { options.configurable_permissions.can_run_reports = flags['can-run-reports']; } - if (flags.hasOwnProperty('can-instant-login')) { + if (Object.hasOwn(flags, 'can-instant-login')) { options.configurable_permissions.can_instant_login = flags['can-instant-login']; } - if (flags.hasOwnProperty('can-create-accounts')) { + if (Object.hasOwn(flags, 'can-create-accounts')) { options.configurable_permissions.can_create_accounts = flags['can-create-accounts']; } - if (flags.hasOwnProperty('can-edit-accounts')) { + if (Object.hasOwn(flags, 'can-edit-accounts')) { options.configurable_permissions.can_edit_accounts = flags['can-edit-accounts']; } diff --git a/src/commands/groups/memberships/update.js b/src/commands/groups/memberships/update.js index 74ef4f4c..e6bb9e68 100644 --- a/src/commands/groups/memberships/update.js +++ b/src/commands/groups/memberships/update.js @@ -8,19 +8,19 @@ class GroupsUpdateMembershipCommand extends BoxCommand { const { flags, args } = await this.parse(GroupsUpdateMembershipCommand); let options = { configurable_permissions: {} }; - if (flags.hasOwnProperty('can-run-reports')) { + if (Object.hasOwn(flags, 'can-run-reports')) { options.configurable_permissions.can_run_reports = flags['can-run-reports']; } - if (flags.hasOwnProperty('can-instant-login')) { + if (Object.hasOwn(flags, 'can-instant-login')) { options.configurable_permissions.can_instant_login = flags['can-instant-login']; } - if (flags.hasOwnProperty('can-create-accounts')) { + if (Object.hasOwn(flags, 'can-create-accounts')) { options.configurable_permissions.can_create_accounts = flags['can-create-accounts']; } - if (flags.hasOwnProperty('can-edit-accounts')) { + if (Object.hasOwn(flags, 'can-edit-accounts')) { options.configurable_permissions.can_edit_accounts = flags['can-edit-accounts']; } diff --git a/src/commands/integration-mappings/slack/create.js b/src/commands/integration-mappings/slack/create.js index 2a431f57..9666f386 100644 --- a/src/commands/integration-mappings/slack/create.js +++ b/src/commands/integration-mappings/slack/create.js @@ -28,7 +28,7 @@ class IntegrationMappingsSlackCreateCommand extends BoxCommand { 'Either the --slack-workspace-id or --slack-org-id flag must be passed' ); } - if (flags.hasOwnProperty('disable-access-management')) { + if (Object.hasOwn(flags, 'disable-access-management')) { body.options = { is_access_management_disabled: flags['disable-access-management'], diff --git a/src/commands/integration-mappings/slack/index.js b/src/commands/integration-mappings/slack/index.js index fbe96012..e5d95af8 100644 --- a/src/commands/integration-mappings/slack/index.js +++ b/src/commands/integration-mappings/slack/index.js @@ -15,7 +15,7 @@ class IntegrationMappingsSlackListCommand extends BoxCommand { if (flags['box-item-id']) { options.box_item_id = flags['box-item-id']; } - if (flags.hasOwnProperty('manually-created')) { + if (Object.hasOwn(flags, 'manually-created')) { options.is_manually_created = flags['manually-created']; } diff --git a/src/commands/integration-mappings/slack/update.js b/src/commands/integration-mappings/slack/update.js index 48c02dd0..905bc3c1 100644 --- a/src/commands/integration-mappings/slack/update.js +++ b/src/commands/integration-mappings/slack/update.js @@ -17,7 +17,7 @@ class IntegrationMappingsSlackUpdateCommand extends BoxCommand { type: 'folder', }; } - if (flags.hasOwnProperty('disable-access-management')) { + if (Object.hasOwn(flags, 'disable-access-management')) { body.options = { is_access_management_disabled: flags['disable-access-management'], diff --git a/src/commands/legal-hold-policies/create.js b/src/commands/legal-hold-policies/create.js index 2ac9ca42..1564f010 100644 --- a/src/commands/legal-hold-policies/create.js +++ b/src/commands/legal-hold-policies/create.js @@ -20,7 +20,7 @@ class LegalHoldPoliciesCreateCommand extends BoxCommand { if (flags['filter-ended-at']) { options.filter_ended_at = flags['filter-ended-at']; } - if (flags.hasOwnProperty('ongoing')) { + if (Object.hasOwn(flags, 'ongoing')) { options.is_ongoing = true; } diff --git a/src/commands/login.js b/src/commands/login.js index 39778da1..799e328c 100644 --- a/src/commands/login.js +++ b/src/commands/login.js @@ -29,7 +29,7 @@ class OAuthLoginCommand extends BoxCommand { if (this.flags.reauthorize) { if ( - !environmentsObject.environments.hasOwnProperty(this.flags.name) + !Object.hasOwn(environmentsObject.environments, this.flags.name) ) { this.error(`The ${this.flags.name} environment does not exist`); } diff --git a/src/commands/metadata-query.js b/src/commands/metadata-query.js index c7a9f28f..ddcb88d8 100644 --- a/src/commands/metadata-query.js +++ b/src/commands/metadata-query.js @@ -29,19 +29,13 @@ class MetadataQueryCommand extends BoxCommand { if (queryParameter) { combinedQueryParameters = { ...combinedQueryParameters, - ...queryParameter.reduce( - (accumulator, current) => ({ ...accumulator, ...current }), - {} - ), + ...Object.assign({}, ...queryParameter), }; } if (queryParameterArray) { combinedQueryParameters = { ...combinedQueryParameters, - ...queryParameterArray.reduce( - (accumulator, current) => ({ ...accumulator, ...current }), - {} - ), + ...Object.assign({}, ...queryParameterArray), }; } diff --git a/src/commands/metadata-templates/create.js b/src/commands/metadata-templates/create.js index d59d887c..1c9135ae 100644 --- a/src/commands/metadata-templates/create.js +++ b/src/commands/metadata-templates/create.js @@ -122,9 +122,9 @@ function _parseFlags(preparsedArgv) { } // Add the last field if necessary and return - template.fields = template.fields - .concat(currentField) - .filter((op) => op !== null); + template.fields = [...template.fields, currentField].filter( + (op) => op !== null + ); return template; } diff --git a/src/commands/metadata-templates/update.js b/src/commands/metadata-templates/update.js index f1de6336..9e2c6933 100644 --- a/src/commands/metadata-templates/update.js +++ b/src/commands/metadata-templates/update.js @@ -322,7 +322,7 @@ function _parseOperations(preparsedArgv) { } // Add the last field if necessary and return - return ops.concat(currentOp).filter((op) => op !== null); + return [...ops, currentOp].filter((op) => op !== null); } class MetadataTemplatesUpdateCommand extends BoxCommand { diff --git a/src/commands/request.js b/src/commands/request.js index 74a4634c..d7201526 100644 --- a/src/commands/request.js +++ b/src/commands/request.js @@ -17,7 +17,7 @@ class ManualRequestCommand extends BoxCommand { parameters.qs = querystring.parse(flags.query); } - if (flags.hasOwnProperty('body') && flags.body !== '') { + if (Object.hasOwn(flags, 'body') && flags.body !== '') { try { parameters.body = JSON.parse(flags.body); parameters.json = true; diff --git a/src/commands/retention-policies/assign.js b/src/commands/retention-policies/assign.js index 0c0ab878..678464f6 100644 --- a/src/commands/retention-policies/assign.js +++ b/src/commands/retention-policies/assign.js @@ -15,10 +15,10 @@ class RetentionPoliciesAssignCommand extends BoxCommand { let assignID = flags['assign-to-id']; let options = {}; - if (flags.hasOwnProperty('filter-field')) { + if (Object.hasOwn(flags, 'filter-field')) { options.filter_fields = flags['filter-field']; } - if (flags.hasOwnProperty('start-date-field')) { + if (Object.hasOwn(flags, 'start-date-field')) { options.start_date_field = flags['start-date-field']; } diff --git a/src/commands/retention-policies/create.js b/src/commands/retention-policies/create.js index 77b595c0..274d09d5 100644 --- a/src/commands/retention-policies/create.js +++ b/src/commands/retention-policies/create.js @@ -14,10 +14,10 @@ class RetentionPoliciesCreateCommand extends BoxCommand { let dispositionAction = flags['disposition-action']; let options = {}; - if (flags.hasOwnProperty('notify-owners')) { + if (Object.hasOwn(flags, 'notify-owners')) { options.are_owners_notified = flags['notify-owners']; } - if (flags.hasOwnProperty('allow-extension')) { + if (Object.hasOwn(flags, 'allow-extension')) { options.can_owner_extend_retention = flags['allow-extension']; } if (flags['retention-length']) { @@ -33,10 +33,10 @@ class RetentionPoliciesCreateCommand extends BoxCommand { options.retention_type = this.client.retentionPolicies.retentionTypes.NON_MODIFIABLE; } - if (flags.hasOwnProperty('description')) { + if (Object.hasOwn(flags, 'description')) { options.description = flags.description; } - if (flags.hasOwnProperty('custom-notification-recipient')) { + if (Object.hasOwn(flags, 'custom-notification-recipient')) { options.custom_notification_recipients = flags['custom-notification-recipient']; } diff --git a/src/commands/retention-policies/update.js b/src/commands/retention-policies/update.js index 734a3826..15db1ec6 100644 --- a/src/commands/retention-policies/update.js +++ b/src/commands/retention-policies/update.js @@ -33,10 +33,10 @@ class RetentionPoliciesUpdateCommand extends BoxCommand { updates.status = 'retired'; } - if (flags.hasOwnProperty('notify-owners')) { + if (Object.hasOwn(flags, 'notify-owners')) { updates.are_owners_notified = flags['notify-owners']; } - if (flags.hasOwnProperty('allow-extension')) { + if (Object.hasOwn(flags, 'allow-extension')) { updates.can_owner_extend_retention = flags['allow-extension']; } diff --git a/src/commands/search.js b/src/commands/search.js index 2365064e..ea06d1dd 100644 --- a/src/commands/search.js +++ b/src/commands/search.js @@ -180,8 +180,8 @@ class SearchCommand extends BoxCommand { options.trash_content = flags['trash-content']; } if ( - flags.hasOwnProperty('size-from') || - flags.hasOwnProperty('size-to') + Object.hasOwn(flags, 'size-from') || + Object.hasOwn(flags, 'size-to') ) { options.size_range = `${_.get(flags, 'size-from', '')},${_.get(flags, 'size-to', '')}`; } @@ -198,7 +198,7 @@ class SearchCommand extends BoxCommand { options.direction = flags.direction; } - if (flags.hasOwnProperty('include-recent-shared-links')) { + if (Object.hasOwn(flags, 'include-recent-shared-links')) { options.include_recent_shared_links = flags['include-recent-shared-links']; } diff --git a/src/commands/users/create.js b/src/commands/users/create.js index 44b205a4..49414e6f 100644 --- a/src/commands/users/create.js +++ b/src/commands/users/create.js @@ -10,25 +10,25 @@ class UsersCreateCommand extends BoxCommand { let options = {}; let user; - if (flags.hasOwnProperty('sync-enable')) { + if (Object.hasOwn(flags, 'sync-enable')) { options.is_sync_enabled = flags['sync-enable']; } if (flags['password-reset']) { options.is_password_reset_required = true; } - if (flags.hasOwnProperty('exempt-from-device-limits')) { + if (Object.hasOwn(flags, 'exempt-from-device-limits')) { options.is_exempt_from_device_limits = flags['exempt-from-device-limits']; } - if (flags.hasOwnProperty('exempt-from-2fa')) { + if (Object.hasOwn(flags, 'exempt-from-2fa')) { options.is_exempt_from_login_verification = flags['exempt-from-2fa']; } - if (flags.hasOwnProperty('restrict-external-collab')) { + if (Object.hasOwn(flags, 'restrict-external-collab')) { options.is_external_collab_restricted = flags['restrict-external-collab']; } - if (flags.hasOwnProperty('can-see-managed-users')) { + if (Object.hasOwn(flags, 'can-see-managed-users')) { options.can_see_managed_users = flags['can-see-managed-users']; } if (flags.role) { diff --git a/src/commands/users/delete.js b/src/commands/users/delete.js index d365b1e6..f8912647 100644 --- a/src/commands/users/delete.js +++ b/src/commands/users/delete.js @@ -8,10 +8,10 @@ class UsersDeleteCommand extends BoxCommand { const { flags, args } = await this.parse(UsersDeleteCommand); let options = {}; - if (flags.hasOwnProperty('notify')) { + if (Object.hasOwn(flags, 'notify')) { options.notify = flags.notify; } - if (flags.hasOwnProperty('force')) { + if (Object.hasOwn(flags, 'force')) { options.force = flags.force; } diff --git a/src/commands/users/email-aliases/add.js b/src/commands/users/email-aliases/add.js index 0d2f0591..1d7288ad 100644 --- a/src/commands/users/email-aliases/add.js +++ b/src/commands/users/email-aliases/add.js @@ -9,7 +9,7 @@ class UsersAddEmailAliasCommand extends BoxCommand { let options = {}; - if (flags.hasOwnProperty('confirm')) { + if (Object.hasOwn(flags, 'confirm')) { options.is_confirmed = flags.confirm; } diff --git a/src/commands/users/transfer-content.js b/src/commands/users/transfer-content.js index 8ae5cb48..574bfd4a 100644 --- a/src/commands/users/transfer-content.js +++ b/src/commands/users/transfer-content.js @@ -15,7 +15,7 @@ class UsersMoveRootContentCommand extends BoxCommand { qs: {}, }; - if (flags.hasOwnProperty('notify')) { + if (Object.hasOwn(flags, 'notify')) { parameters.qs.notify = flags.notify; } diff --git a/src/commands/users/update.js b/src/commands/users/update.js index bfec6124..bac87011 100644 --- a/src/commands/users/update.js +++ b/src/commands/users/update.js @@ -8,28 +8,28 @@ class UsersUpdateCommand extends BoxCommand { const { flags, args } = await this.parse(UsersUpdateCommand); let updates = {}; - if (flags.hasOwnProperty('sync-enable')) { + if (Object.hasOwn(flags, 'sync-enable')) { updates.is_sync_enabled = flags['sync-enable']; } if (flags['password-reset']) { updates.is_password_reset_required = true; } - if (flags.hasOwnProperty('exempt-from-device-limits')) { + if (Object.hasOwn(flags, 'exempt-from-device-limits')) { updates.is_exempt_from_device_limits = flags['exempt-from-device-limits']; } - if (flags.hasOwnProperty('exempt-from-2fa')) { + if (Object.hasOwn(flags, 'exempt-from-2fa')) { updates.is_exempt_from_login_verification = flags['exempt-from-2fa']; } - if (flags.hasOwnProperty('restrict-external-collab')) { + if (Object.hasOwn(flags, 'restrict-external-collab')) { updates.is_external_collab_restricted = flags['restrict-external-collab']; } - if (flags.hasOwnProperty('can-see-managed-users')) { + if (Object.hasOwn(flags, 'can-see-managed-users')) { updates.can_see_managed_users = flags['can-see-managed-users']; } - if (flags.hasOwnProperty('notification-email')) { + if (Object.hasOwn(flags, 'notification-email')) { updates.notification_email = flags['notification-email'] === '' ? null diff --git a/src/modules/collaboration.js b/src/modules/collaboration.js index d3d6b1e7..ec136a0b 100644 --- a/src/modules/collaboration.js +++ b/src/modules/collaboration.js @@ -34,10 +34,10 @@ class CollaborationModule { if (flags.fields) { parameters.qs.fields = flags.fields; } - if (flags.hasOwnProperty('notify')) { + if (Object.hasOwn(flags, 'notify')) { parameters.qs.notify = flags.notify; } - if (flags.hasOwnProperty('can-view-path')) { + if (Object.hasOwn(flags, 'can-view-path')) { parameters.body.can_view_path = flags['can-view-path']; } if (flags.role) { diff --git a/src/modules/shared-links.js b/src/modules/shared-links.js index 79c89f52..c1b9945a 100644 --- a/src/modules/shared-links.js +++ b/src/modules/shared-links.js @@ -36,7 +36,7 @@ class SharedLinksModule { if (flags['unshared-at']) { updates.shared_link.unshared_at = flags['unshared-at']; } - if (flags.hasOwnProperty('can-download')) { + if (Object.hasOwn(flags, 'can-download')) { updates.shared_link.permissions.can_download = flags['can-download']; } @@ -45,7 +45,7 @@ class SharedLinksModule { } if (arguments_.itemType === 'file') { - if (flags.hasOwnProperty('can-edit')) { + if (Object.hasOwn(flags, 'can-edit')) { updates.shared_link.permissions.can_edit = flags['can-edit']; } return this.client.files.update(arguments_.itemID, updates); diff --git a/src/util.js b/src/util.js index 42b39496..1fd1bd23 100644 --- a/src/util.js +++ b/src/util.js @@ -358,7 +358,7 @@ module.exports = { */ parseMetadata(value) { let op = parseMetadataString(value); - if (!op.hasOwnProperty('path') || !op.hasOwnProperty('value')) { + if (!Object.hasOwn(op, 'path') || !Object.hasOwn(op, 'value')) { throw new BoxCLIError('Metadata must be in the form key=value'); } diff --git a/test/commands/folders.test.js b/test/commands/folders.test.js index fa4efbe1..2e288626 100644 --- a/test/commands/folders.test.js +++ b/test/commands/folders.test.js @@ -1898,7 +1898,8 @@ describe('Folders', function () { 'should download folder to zip file when --zip flag is passed', async (context) => { // Find zip file in directory - let filename = (await fs.readdir(downloadPath)).find( + const files = await fs.readdir(downloadPath); + let filename = files.find( (f) => f.startsWith(`folders-download-${folderID}`) && f.endsWith('.zip') diff --git a/test/commands/tokens.test.js b/test/commands/tokens.test.js index 77850c73..50c2dbce 100644 --- a/test/commands/tokens.test.js +++ b/test/commands/tokens.test.js @@ -1,5 +1,7 @@ 'use strict'; +/* eslint-disable mocha/no-skipped-tests */ + const { test } = require('@oclif/test'); const assert = require('chai').assert; const jwt = require('jsonwebtoken'); diff --git a/test/helpers/test-helper.js b/test/helpers/test-helper.js index 801d997b..22a2fef5 100644 --- a/test/helpers/test-helper.js +++ b/test/helpers/test-helper.js @@ -31,7 +31,7 @@ function getFixture(fixture) { ? content.replaceAll(/(?