Skip to content

Commit 5df8505

Browse files
committed
Fix lint errors and test assertion
- Reorder class members per perfectionist rules - Fix union type ordering (null before string[]) - Remove unnecessary length check in Array.some() - Fix test assertion to use lowercase 'apiFamily'
1 parent 500f262 commit 5df8505

3 files changed

Lines changed: 26 additions & 26 deletions

File tree

packages/b2c-cli/src/commands/scapi/schemas/get.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,21 @@ interface GetOutput {
3232
* Use --expand-all to get the full, unmodified schema.
3333
*/
3434
export default class ScapiSchemasGet extends ScapiSchemasCommand<typeof ScapiSchemasGet> {
35+
static args = {
36+
apiFamily: Args.string({
37+
description: t('args.apiFamily.description', 'API family (e.g., shopper, admin)'),
38+
required: true,
39+
}),
40+
apiName: Args.string({
41+
description: t('args.apiName.description', 'API name (e.g., products, orders)'),
42+
required: true,
43+
}),
44+
apiVersion: Args.string({
45+
description: t('args.apiVersion.description', 'API version (e.g., v1)'),
46+
required: true,
47+
}),
48+
};
49+
3550
static description = t(
3651
'commands.scapi.schemas.get.description',
3752
'Get a specific SCAPI schema with optional selective expansion',
@@ -56,21 +71,6 @@ export default class ScapiSchemasGet extends ScapiSchemasCommand<typeof ScapiSch
5671
'<%= config.bin %> <%= command.id %> shopper products v1 --tenant-id f_ecom_zzxy_prd --json',
5772
];
5873

59-
static args = {
60-
apiFamily: Args.string({
61-
description: t('args.apiFamily.description', 'API family (e.g., shopper, admin)'),
62-
required: true,
63-
}),
64-
apiName: Args.string({
65-
description: t('args.apiName.description', 'API name (e.g., products, orders)'),
66-
required: true,
67-
}),
68-
apiVersion: Args.string({
69-
description: t('args.apiVersion.description', 'API version (e.g., v1)'),
70-
required: true,
71-
}),
72-
};
73-
7474
static flags = {
7575
...ScapiSchemasCommand.baseFlags,
7676

@@ -127,7 +127,7 @@ export default class ScapiSchemasGet extends ScapiSchemasCommand<typeof ScapiSch
127127
}),
128128
};
129129

130-
async run(): Promise<GetOutput | string[] | null> {
130+
async run(): Promise<GetOutput | null | string[]> {
131131
this.requireOAuthCredentials();
132132

133133
const {apiFamily, apiName, apiVersion} = this.args;
@@ -364,7 +364,7 @@ export default class ScapiSchemasGet extends ScapiSchemasCommand<typeof ScapiSch
364364
for (const line of valueLines) {
365365
lines.push(`${indentStr} ${line}`);
366366
}
367-
} else if (Array.isArray(value) && value.length > 0 && value.some((item) => typeof item === 'object')) {
367+
} else if (Array.isArray(value) && value.some((item) => typeof item === 'object')) {
368368
// Array with objects - put on next line
369369
lines.push(`${indentStr}${key}:`);
370370
const valueLines = serializedValue.split('\n');

packages/b2c-cli/src/utils/scapi/schemas.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ export abstract class ScapiSchemasCommand<T extends typeof Command> extends OAut
2929
}),
3030
};
3131

32+
/**
33+
* Get the organization ID from the tenant-id flag.
34+
*/
35+
protected getOrganizationId(): string {
36+
const tenantId = (this.flags as Record<string, string>)['tenant-id'];
37+
return toOrganizationId(tenantId);
38+
}
39+
3240
/**
3341
* Get the SCAPI Schemas client, ensuring short code is configured.
3442
*/
@@ -48,12 +56,4 @@ export abstract class ScapiSchemasCommand<T extends typeof Command> extends OAut
4856
const oauthStrategy = this.getOAuthStrategy();
4957
return createScapiSchemasClient({shortCode, tenantId}, oauthStrategy);
5058
}
51-
52-
/**
53-
* Get the organization ID from the tenant-id flag.
54-
*/
55-
protected getOrganizationId(): string {
56-
const tenantId = (this.flags as Record<string, string>)['tenant-id'];
57-
return toOrganizationId(tenantId);
58-
}
5959
}

packages/b2c-cli/test/commands/scapi/schemas/get.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe('scapi schemas get', () => {
2121
it('requires apiFamily argument', async () => {
2222
const {error} = await runCommand('scapi schemas get --tenant-id f_ecom_zzxy_prd');
2323
expect(error).to.not.be.undefined;
24-
expect(error?.message).to.include('APIFAMILY');
24+
expect(error?.message).to.include('apiFamily');
2525
});
2626

2727
it('shows expand flags in help', async () => {

0 commit comments

Comments
 (0)