Skip to content

Commit d6a8ce0

Browse files
committed
linting cleanup pass and config
1 parent 783f105 commit d6a8ce0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+492
-458
lines changed

packages/b2c-cli/.prettierrc.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
1-
"@oclif/prettier-config"
1+
{
2+
"singleQuote": true,
3+
"printWidth": 120,
4+
"endOfLine": "auto",
5+
"semi": true,
6+
"tabWidth": 2,
7+
"bracketSpacing": false,
8+
"trailingComma": "all"
9+
}

packages/b2c-cli/bin/dev.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env -S node --import tsx
22

3-
import {execute} from '@oclif/core'
3+
import {execute} from '@oclif/core';
44

5-
await execute({development: true, dir: import.meta.url})
5+
await execute({development: true, dir: import.meta.url});

packages/b2c-cli/bin/run.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env node
22

3-
import {execute} from '@oclif/core'
3+
import {execute} from '@oclif/core';
44

5-
await execute({dir: import.meta.url})
5+
await execute({dir: import.meta.url});

packages/b2c-cli/eslint.config.mjs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import {includeIgnoreFile} from '@eslint/compat'
2-
import oclif from 'eslint-config-oclif'
3-
import prettier from 'eslint-config-prettier'
4-
import path from 'node:path'
5-
import {fileURLToPath} from 'node:url'
1+
import {includeIgnoreFile} from '@eslint/compat';
2+
import oclif from 'eslint-config-oclif';
3+
import prettierPlugin from 'eslint-plugin-prettier/recommended';
4+
import path from 'node:path';
5+
import {fileURLToPath} from 'node:url';
66

7-
const gitignorePath = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '.gitignore')
7+
const gitignorePath = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '.gitignore');
88

99
export default [
1010
includeIgnoreFile(gitignorePath),
1111
...oclif,
12-
prettier,
12+
prettierPlugin,
1313
{
1414
rules: {
1515
// Disable perfectionist rules - we use prettier for formatting
@@ -36,4 +36,4 @@ export default [
3636
],
3737
},
3838
},
39-
]
39+
];

packages/b2c-cli/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@
2525
"eslint": "^9",
2626
"eslint-config-oclif": "^6",
2727
"eslint-config-prettier": "^10",
28+
"eslint-plugin-prettier": "^5.5.4",
2829
"mocha": "^10",
2930
"oclif": "^4",
31+
"prettier": "^3.6.2",
3032
"shx": "^0.3.3",
3133
"tsx": "^4.20.6",
3234
"typescript": "^5"
@@ -81,6 +83,8 @@
8183
"scripts": {
8284
"build": "shx rm -rf dist && tsc",
8385
"lint": "eslint",
86+
"format": "prettier --write src",
87+
"format:check": "prettier --check src",
8488
"postpack": "shx rm -f oclif.manifest.json",
8589
"posttest": "pnpm run lint",
8690
"prepack": "oclif manifest && oclif readme",
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
1-
import { Args } from '@oclif/core'
2-
import { uploadCartridges } from '@salesforce/b2c-tooling'
3-
import { InstanceCommand } from '@salesforce/b2c-tooling/cli'
4-
import { t } from '../../i18n/index.js'
1+
import {Args} from '@oclif/core';
2+
import {uploadCartridges} from '@salesforce/b2c-tooling';
3+
import {InstanceCommand} from '@salesforce/b2c-tooling/cli';
4+
import {t} from '../../i18n/index.js';
55

66
export default class Deploy extends InstanceCommand<typeof Deploy> {
77
static args = {
88
cartridgePath: Args.string({
99
description: 'Path to cartridges directory',
1010
default: './cartridges',
1111
}),
12-
}
12+
};
1313

14-
static description = t('commands.code.deploy.description', 'Deploy cartridges to a B2C Commerce instance')
14+
static description = t('commands.code.deploy.description', 'Deploy cartridges to a B2C Commerce instance');
1515

1616
static examples = [
1717
'<%= config.bin %> <%= command.id %>',
1818
'<%= config.bin %> <%= command.id %> ./my-cartridges',
1919
'<%= config.bin %> <%= command.id %> --server my-sandbox.demandware.net --code-version v1',
20-
]
20+
];
2121

2222
async run(): Promise<void> {
23-
this.requireServer()
24-
this.requireCodeVersion()
25-
this.requireWebDavCredentials()
23+
this.requireServer();
24+
this.requireCodeVersion();
25+
this.requireWebDavCredentials();
2626

27-
const instance = this.createWebDavInstance()
28-
const path = this.args.cartridgePath
29-
const hostname = this.resolvedConfig.hostname!
30-
const version = this.resolvedConfig.codeVersion!
27+
const instance = this.createWebDavInstance();
28+
const path = this.args.cartridgePath;
29+
const hostname = this.resolvedConfig.hostname!;
30+
const version = this.resolvedConfig.codeVersion!;
3131

32-
this.log(t('commands.code.deploy.deploying', 'Deploying cartridges from {{path}}...', { path }))
33-
this.log(t('commands.code.deploy.target', 'Target: {{hostname}}', { hostname }))
34-
this.log(t('commands.code.deploy.codeVersion', 'Code Version: {{version}}', { version }))
32+
this.log(t('commands.code.deploy.deploying', 'Deploying cartridges from {{path}}...', {path}));
33+
this.log(t('commands.code.deploy.target', 'Target: {{hostname}}', {hostname}));
34+
this.log(t('commands.code.deploy.codeVersion', 'Code Version: {{version}}', {version}));
3535

3636
try {
37-
await uploadCartridges(instance, path)
38-
this.log(t('commands.code.deploy.complete', 'Deployment complete'))
37+
await uploadCartridges(instance, path);
38+
this.log(t('commands.code.deploy.complete', 'Deployment complete'));
3939
} catch (error) {
4040
if (error instanceof Error) {
41-
this.error(t('commands.code.deploy.failed', 'Deployment failed: {{message}}', { message: error.message }))
41+
this.error(t('commands.code.deploy.failed', 'Deployment failed: {{message}}', {message: error.message}));
4242
}
43-
throw error
43+
throw error;
4444
}
4545
}
4646
}

packages/b2c-cli/src/commands/hello/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { Args, Command, Flags } from '@oclif/core';
1+
import {Args, Command, Flags} from '@oclif/core';
22

33
export default class Hello extends Command {
44
static args = {
5-
person: Args.string({ description: 'Person to say hello to', required: true }),
5+
person: Args.string({description: 'Person to say hello to', required: true}),
66
};
77

88
static description = 'Say hello';
@@ -14,11 +14,11 @@ hello friend from oclif!
1414
];
1515

1616
static flags = {
17-
from: Flags.string({ char: 'f', description: 'Who is saying hello', required: true }),
17+
from: Flags.string({char: 'f', description: 'Who is saying hello', required: true}),
1818
};
1919

2020
async run(): Promise<void> {
21-
const { args, flags } = await this.parse(Hello);
21+
const {args, flags} = await this.parse(Hello);
2222

2323
this.log(`hello ${args.person} from ${flags.from}!`);
2424
}
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import {Command} from '@oclif/core'
1+
import {Command} from '@oclif/core';
22

33
export default class World extends Command {
4-
static args = {}
5-
static description = 'Say hello world'
4+
static args = {};
5+
static description = 'Say hello world';
66
static examples = [
77
`<%= config.bin %> <%= command.id %>
88
hello world! (./src/commands/hello/world.ts)
99
`,
10-
]
11-
static flags = {}
10+
];
11+
static flags = {};
1212

1313
async run(): Promise<void> {
14-
this.log('hello world! (./src/commands/hello/world.ts)')
14+
this.log('hello world! (./src/commands/hello/world.ts)');
1515
}
1616
}
Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Args, Flags } from '@oclif/core'
2-
import { MrtCommand } from '@salesforce/b2c-tooling/cli'
3-
import { t } from '../../../i18n/index.js'
1+
import {Args, Flags} from '@oclif/core';
2+
import {MrtCommand} from '@salesforce/b2c-tooling/cli';
3+
import {t} from '../../../i18n/index.js';
44

55
/**
66
* Stub command demonstrating MrtCommand usage.
@@ -16,13 +16,16 @@ export default class MrtEnvVarSet extends MrtCommand<typeof MrtEnvVarSet> {
1616
description: 'Environment variable value',
1717
required: true,
1818
}),
19-
}
19+
};
2020

21-
static description = t('commands.mrt.envVar.set.description', 'Set an environment variable on a Managed Runtime project')
21+
static description = t(
22+
'commands.mrt.envVar.set.description',
23+
'Set an environment variable on a Managed Runtime project',
24+
);
2225

2326
static examples = [
2427
'<%= config.bin %> <%= command.id %> MY_VAR "my value" --project acme-storefront --environment production',
25-
]
28+
];
2629

2730
static flags = {
2831
project: Flags.string({
@@ -34,24 +37,30 @@ export default class MrtEnvVarSet extends MrtCommand<typeof MrtEnvVarSet> {
3437
description: 'Target environment',
3538
required: true,
3639
}),
37-
}
40+
};
3841

3942
async run(): Promise<void> {
40-
this.requireMrtCredentials()
43+
this.requireMrtCredentials();
4144

42-
const key = this.args.key
43-
const value = this.args.value
44-
const project = this.flags.project
45-
const environment = this.flags.environment
45+
const key = this.args.key;
46+
const value = this.args.value;
47+
const project = this.flags.project;
48+
const environment = this.flags.environment;
4649

47-
this.log(t('commands.mrt.envVar.set.setting', 'Setting {{key}} on {{project}}/{{environment}}...', { key, project, environment }))
50+
this.log(
51+
t('commands.mrt.envVar.set.setting', 'Setting {{key}} on {{project}}/{{environment}}...', {
52+
key,
53+
project,
54+
environment,
55+
}),
56+
);
4857

4958
// TODO: Implement actual MRT API call using this.createMrtClient()
5059

51-
this.log('')
52-
this.log(t('commands.mrt.envVar.set.stub', '(stub) Environment variable setting not yet implemented'))
53-
this.log(t('commands.mrt.envVar.set.wouldSet', 'Would set {{key}}={{value}}', { key, value }))
54-
this.log(t('commands.mrt.envVar.set.project', 'Project: {{project}}', { project }))
55-
this.log(t('commands.mrt.envVar.set.environment', 'Environment: {{environment}}', { environment }))
60+
this.log('');
61+
this.log(t('commands.mrt.envVar.set.stub', '(stub) Environment variable setting not yet implemented'));
62+
this.log(t('commands.mrt.envVar.set.wouldSet', 'Would set {{key}}={{value}}', {key, value}));
63+
this.log(t('commands.mrt.envVar.set.project', 'Project: {{project}}', {project}));
64+
this.log(t('commands.mrt.envVar.set.environment', 'Environment: {{environment}}', {environment}));
5665
}
5766
}
Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Args, Flags } from '@oclif/core'
2-
import { OAuthCommand } from '@salesforce/b2c-tooling/cli'
3-
import { t } from '../../i18n/index.js'
1+
import {Args, Flags} from '@oclif/core';
2+
import {OAuthCommand} from '@salesforce/b2c-tooling/cli';
3+
import {t} from '../../i18n/index.js';
44

55
/**
66
* Stub command demonstrating OAuthCommand usage.
@@ -12,14 +12,14 @@ export default class SandboxCreate extends OAuthCommand<typeof SandboxCreate> {
1212
description: 'Realm ID',
1313
required: true,
1414
}),
15-
}
15+
};
1616

17-
static description = t('commands.sandbox.create.description', 'Create a new on-demand sandbox')
17+
static description = t('commands.sandbox.create.description', 'Create a new on-demand sandbox');
1818

1919
static examples = [
2020
'<%= config.bin %> <%= command.id %> abcd --ttl 24',
2121
'<%= config.bin %> <%= command.id %> abcd --profile medium',
22-
]
22+
];
2323

2424
static flags = {
2525
ttl: Flags.integer({
@@ -30,24 +30,26 @@ export default class SandboxCreate extends OAuthCommand<typeof SandboxCreate> {
3030
description: 'Sandbox profile (small, medium, large)',
3131
default: 'medium',
3232
}),
33-
}
33+
};
3434

3535
async run(): Promise<void> {
36-
this.requireOAuthCredentials()
36+
this.requireOAuthCredentials();
3737

38-
const realm = this.args.realm
39-
const profile = this.flags.profile
40-
const ttl = this.flags.ttl
41-
const clientId = this.resolvedConfig.clientId
38+
const realm = this.args.realm;
39+
const profile = this.flags.profile;
40+
const ttl = this.flags.ttl;
41+
const clientId = this.resolvedConfig.clientId;
4242

43-
this.log(t('commands.sandbox.create.creating', 'Creating sandbox in realm {{realm}}...', { realm }))
44-
this.log(t('commands.sandbox.create.profile', 'Profile: {{profile}}', { profile }))
45-
this.log(t('commands.sandbox.create.ttl', 'TTL: {{ttl}} hours', { ttl }))
43+
this.log(t('commands.sandbox.create.creating', 'Creating sandbox in realm {{realm}}...', {realm}));
44+
this.log(t('commands.sandbox.create.profile', 'Profile: {{profile}}', {profile}));
45+
this.log(t('commands.sandbox.create.ttl', 'TTL: {{ttl}} hours', {ttl}));
4646

4747
// TODO: Implement actual ODS API call using this.getOAuthStrategy()
4848

49-
this.log('')
50-
this.log(t('commands.sandbox.create.stub', '(stub) Sandbox creation not yet implemented'))
51-
this.log(t('commands.sandbox.create.wouldCreate', 'Would create sandbox with OAuth client: {{clientId}}', { clientId }))
49+
this.log('');
50+
this.log(t('commands.sandbox.create.stub', '(stub) Sandbox creation not yet implemented'));
51+
this.log(
52+
t('commands.sandbox.create.wouldCreate', 'Would create sandbox with OAuth client: {{clientId}}', {clientId}),
53+
);
5254
}
5355
}

0 commit comments

Comments
 (0)