Skip to content

Commit a8c5632

Browse files
authored
chore: Fix ESLint warnings (#617)
1 parent 0265e2a commit a8c5632

File tree

39 files changed

+92
-96
lines changed

39 files changed

+92
-96
lines changed

src/box-command.js

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,9 @@ class BoxCommand extends Command {
300300
// Set up the command for bulk run
301301
DEBUG.init('Preparing for bulk input');
302302
this.isBulk = true;
303+
// eslint-disable-next-line unicorn/prefer-structured-clone
303304
originalArgs = _.cloneDeep(this.constructor.args);
305+
// eslint-disable-next-line unicorn/prefer-structured-clone
304306
originalFlags = _.cloneDeep(this.constructor.flags);
305307
this.disableRequiredArgsAndFlags();
306308
}
@@ -615,7 +617,7 @@ class BoxCommand extends Command {
615617
let parsedData;
616618
try {
617619
let jsonFile = JSON.parse(fileContents);
618-
parsedData = jsonFile.hasOwnProperty('entries')
620+
parsedData = Object.hasOwn(jsonFile, 'entries')
619621
? jsonFile.entries
620622
: jsonFile;
621623
} catch (error) {
@@ -651,10 +653,7 @@ class BoxCommand extends Command {
651653
// Arrays can be one of two things: an array of values for a single key,
652654
// or an array of grouped flags/args as objects
653655
// First, check if everything in the array is either all object or all non-object
654-
let types = value.reduce(
655-
(acc, t) => acc.concat(typeof t),
656-
[]
657-
);
656+
let types = value.map((t) => typeof t);
658657
if (
659658
types.some((t) => t !== 'object') &&
660659
types.includes('object')
@@ -1196,11 +1195,10 @@ class BoxCommand extends Command {
11961195
if (Array.isArray(content)) {
11971196
// Format each object individually and then flatten in case this an array of arrays,
11981197
// which happens when a command that outputs a collection gets run in bulk
1199-
formattedOutputData = (
1200-
await Promise.all(
1201-
content.map((o) => this._formatOutputObject(o))
1202-
)
1203-
).flat();
1198+
const formattedOutputResults = await Promise.all(
1199+
content.map((o) => this._formatOutputObject(o))
1200+
);
1201+
formattedOutputData = formattedOutputResults.flat();
12041202
DEBUG.output(
12051203
'Formatted %d output entries for display',
12061204
content.length
@@ -1649,9 +1647,10 @@ class BoxCommand extends Command {
16491647
if (!fields) {
16501648
return output;
16511649
}
1652-
fields = REQUIRED_FIELDS.concat(
1653-
fields.split(',').filter((f) => !REQUIRED_FIELDS.includes(f))
1654-
);
1650+
fields = [
1651+
...REQUIRED_FIELDS,
1652+
...fields.split(',').filter((f) => !REQUIRED_FIELDS.includes(f)),
1653+
];
16551654
DEBUG.output('Filtering output with fields: %O', fields);
16561655
if (Array.isArray(output)) {
16571656
output = output.map((o) =>
@@ -1723,7 +1722,7 @@ class BoxCommand extends Command {
17231722
) {
17241723
let subKeys = this.getNestedKeys(object[key]);
17251724
subKeys = subKeys.map((x) => `${key}.${x}`);
1726-
keys = keys.concat(subKeys);
1725+
keys = [...keys, ...subKeys];
17271726
} else {
17281727
keys.push(key);
17291728
}
@@ -1757,10 +1756,10 @@ class BoxCommand extends Command {
17571756
);
17581757

17591758
// Successively apply the offsets to the current time
1760-
newDate = argPairs.reduce(
1761-
(d, args) => offsetDate(d, ...args),
1762-
new Date()
1763-
);
1759+
newDate = new Date();
1760+
for (const args of argPairs) {
1761+
newDate = offsetDate(newDate, ...args);
1762+
}
17641763
} else if (time === 'now') {
17651764
newDate = new Date();
17661765
} else {

src/commands/collaborations/update.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class CollaborationsUpdateCommand extends BoxCommand {
1515
if (flags.status) {
1616
parameters.body.status = flags.status;
1717
}
18-
if (flags.hasOwnProperty('can-view-path')) {
18+
if (Object.hasOwn(flags, 'can-view-path')) {
1919
parameters.body.can_view_path = flags['can-view-path'];
2020
}
2121
if (flags.role) {

src/commands/configure/environments/add.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class EnvironmentsAddCommand extends BoxCommand {
4545
cacheTokens: true,
4646
};
4747

48-
if (environmentsObject.environments.hasOwnProperty(environmentName)) {
48+
if (Object.hasOwn(environmentsObject.environments, environmentName)) {
4949
throw new BoxCLIError(
5050
'There already is an environment with this name'
5151
);

src/commands/configure/environments/delete.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class EnvironmentsDeleteCommand extends BoxCommand {
2727
name = answers.environment;
2828
}
2929

30-
if (environmentsObject.environments.hasOwnProperty(name)) {
30+
if (Object.hasOwn(environmentsObject.environments, name)) {
3131
delete environmentsObject.environments[name];
3232
if (environmentsObject.default === name) {
3333
environmentsObject.default = '';

src/commands/configure/environments/set-current.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class EnvironmentsSetCurrentCommand extends BoxCommand {
2222
name = answers.environment;
2323
}
2424

25-
if (environmentsObject.environments.hasOwnProperty(name)) {
25+
if (Object.hasOwn(environmentsObject.environments, name)) {
2626
environmentsObject.default = name;
2727
await this.updateEnvironments(environmentsObject);
2828
this.info(`The ${name} environment has been set as the default`);

src/commands/configure/environments/update.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class EnvironmentsUpdateCommand extends BoxCommand {
6262
environment.useDefaultAsUser = true;
6363
}
6464

65-
if (flags.hasOwnProperty('cache-tokens')) {
65+
if (Object.hasOwn(flags, 'cache-tokens')) {
6666
environment.cacheTokens = flags['cache-tokens'];
6767
}
6868

src/commands/configure/settings.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ class ConfigureSettingsCommand extends BoxCommand {
6868
}
6969
settings.boxReportsFolderPath = reportsPath;
7070
}
71-
if (flags.hasOwnProperty('output-json')) {
71+
if (Object.hasOwn(flags, 'output-json')) {
7272
settings.outputJson = flags['output-json'];
7373
}
74-
if (flags.hasOwnProperty('enable-proxy')) {
74+
if (Object.hasOwn(flags, 'enable-proxy')) {
7575
settings.enableProxy = flags['enable-proxy'];
7676
}
7777
if (flags['proxy-url']) {
@@ -83,7 +83,7 @@ class ConfigureSettingsCommand extends BoxCommand {
8383
if (flags['proxy-password']) {
8484
settings.proxy.password = flags['proxy-password'];
8585
}
86-
if (flags.hasOwnProperty(['enable-analytics-client'])) {
86+
if (Object.hasOwn(flags, 'enable-analytics-client')) {
8787
settings.enableAnalyticsClient = flags['enable-analytics-client'];
8888
}
8989
if (flags['analytics-client-name']) {

src/commands/files/lock.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class FilesLockCommand extends BoxCommand {
1111
if (flags.expires) {
1212
options.expires_at = flags.expires;
1313
}
14-
if (flags.hasOwnProperty('prevent-download')) {
14+
if (Object.hasOwn(flags, 'prevent-download')) {
1515
options.is_download_prevented = flags['prevent-download'];
1616
}
1717

src/commands/files/rename.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class FilesRenameCommand extends BoxCommand {
1111
name: args.name,
1212
};
1313

14-
if (flags.hasOwnProperty('description')) {
14+
if (Object.hasOwn(flags, 'description')) {
1515
options.description = flags.description;
1616
}
1717

src/commands/files/update.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class FileUpdateCommand extends BoxCommand {
1212
if (flags.name) {
1313
updates.name = flags.name;
1414
}
15-
if (flags.hasOwnProperty('description')) {
15+
if (Object.hasOwn(flags, 'description')) {
1616
updates.description = flags.description;
1717
}
1818
if (flags.tags) {

0 commit comments

Comments
 (0)