Skip to content

Commit 1bdc749

Browse files
authored
Reformat code with Prettier (#2180)
1 parent 6fc933e commit 1bdc749

File tree

132 files changed

+3056
-2160
lines changed

Some content is hidden

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

132 files changed

+3056
-2160
lines changed

eslint.config.js

+14-14
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,17 @@ const tseslintConfigs = tseslint.config(
1414
languageOptions: {
1515
parserOptions: { project: './tsconfig.js.json' },
1616
},
17-
extends: [
18-
...tseslint.configs.recommended,
19-
],
17+
extends: [...tseslint.configs.recommended],
2018
rules: {
2119
'@typescript-eslint/no-var-requires': 'off', // (tseslint does not autodetect commonjs context )
2220
},
23-
}, {
21+
},
22+
{
2423
files: tsconfigTsFiles,
2524
languageOptions: {
2625
parserOptions: { project: './tsconfig.ts.json' },
2726
},
28-
extends: [
29-
...tseslint.configs.recommended,
30-
],
27+
extends: [...tseslint.configs.recommended],
3128
},
3229
);
3330

@@ -59,17 +56,20 @@ module.exports = [
5956
files: ['**/*.test.{js,mjs,cjs}'],
6057
rules: {
6158
'no-unused-vars': 'off', // lots in tests, minimise churn for now
62-
}
59+
},
6360
},
6461
{
6562
files: [...tsconfigTsFiles, ...tsconfigJsFiles],
6663
rules: {
67-
'@typescript-eslint/ban-ts-comment': ['error', {
68-
'ts-expect-error': 'allow-with-description',
69-
'ts-ignore': 'allow-with-description',
70-
'ts-nocheck': true,
71-
'ts-check': true,
72-
}],
64+
'@typescript-eslint/ban-ts-comment': [
65+
'error',
66+
{
67+
'ts-expect-error': 'allow-with-description',
68+
'ts-ignore': 'allow-with-description',
69+
'ts-nocheck': true,
70+
'ts-check': true,
71+
},
72+
],
7373
},
7474
},
7575
];

esm.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ export const {
1212
Command,
1313
Argument,
1414
Option,
15-
Help
15+
Help,
1616
} = commander;

examples/action-this.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ program
99
.command('serve')
1010
.argument('<script>')
1111
.option('-p, --port <number>', 'port number', 80)
12-
.action(function() {
12+
.action(function () {
1313
console.error('Run script %s on port %s', this.args[0], this.opts().port);
1414
});
1515

examples/arguments-extra.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,19 @@ const commander = require('commander');
66
const program = new commander.Command();
77

88
program
9-
.addArgument(new commander.Argument('<drink-size>', 'drink cup size').choices(['small', 'medium', 'large']))
10-
.addArgument(new commander.Argument('[timeout]', 'timeout in seconds').default(60, 'one minute'))
9+
.addArgument(
10+
new commander.Argument('<drink-size>', 'drink cup size').choices([
11+
'small',
12+
'medium',
13+
'large',
14+
]),
15+
)
16+
.addArgument(
17+
new commander.Argument('[timeout]', 'timeout in seconds').default(
18+
60,
19+
'one minute',
20+
),
21+
)
1122
.action((drinkSize, timeout) => {
1223
console.log(`Drink size: ${drinkSize}`);
1324
console.log(`Timeout (s): ${timeout}`);

examples/configure-help.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,17 @@ const program = new commander.Command();
88

99
program.configureHelp({
1010
sortSubcommands: true,
11-
subcommandTerm: (cmd) => cmd.name() // Just show the name, instead of short usage.
11+
subcommandTerm: (cmd) => cmd.name(), // Just show the name, instead of short usage.
1212
});
1313

14-
program.command('zebra <herd-size>', 'African equines with distinctive black-and-white striped coats');
15-
program.command('aardvark [colour]', 'medium-sized, burrowing, nocturnal mammal');
14+
program.command(
15+
'zebra <herd-size>',
16+
'African equines with distinctive black-and-white striped coats',
17+
);
18+
program.command(
19+
'aardvark [colour]',
20+
'medium-sized, burrowing, nocturnal mammal',
21+
);
1622
program
1723
.command('beaver', 'large, semiaquatic rodent')
1824
.option('--pond')

examples/configure-output.js

+8-12
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,15 @@ function errorColor(str) {
66
return `\x1b[31m${str}\x1b[0m`;
77
}
88

9-
program
10-
.configureOutput({
11-
// Visibly override write routines as example!
12-
writeOut: (str) => process.stdout.write(`[OUT] ${str}`),
13-
writeErr: (str) => process.stdout.write(`[ERR] ${str}`),
14-
// Output errors in red.
15-
outputError: (str, write) => write(errorColor(str))
16-
});
9+
program.configureOutput({
10+
// Visibly override write routines as example!
11+
writeOut: (str) => process.stdout.write(`[OUT] ${str}`),
12+
writeErr: (str) => process.stdout.write(`[ERR] ${str}`),
13+
// Output errors in red.
14+
outputError: (str, write) => write(errorColor(str)),
15+
});
1716

18-
program
19-
.version('1.2.3')
20-
.option('-c, --compress')
21-
.command('sub-command');
17+
program.version('1.2.3').option('-c, --compress').command('sub-command');
2218

2319
program.parse();
2420

examples/custom-command-class.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,9 @@ program
3232
inpectCommand(command);
3333
});
3434

35-
program
36-
.command('build <target>')
37-
.action((buildTarget, options, command) => {
38-
inpectCommand(command);
39-
});
35+
program.command('build <target>').action((buildTarget, options, command) => {
36+
inpectCommand(command);
37+
});
4038

4139
program.parse();
4240

examples/custom-help

+6-4
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
const { Command } = require('commander');
77
const program = new Command();
88

9-
program
10-
.option('-f, --foo', 'enable some foo');
9+
program.option('-f, --foo', 'enable some foo');
1110

12-
program.addHelpText('after', `
11+
program.addHelpText(
12+
'after',
13+
`
1314
1415
Example call:
15-
$ custom-help --help`);
16+
$ custom-help --help`,
17+
);
1618

1719
program.parse(process.argv);
1820

examples/custom-help-text.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@ program
1919
program
2020
.command('extra')
2121
.addHelpText('before', 'Note: the extra command does not do anything')
22-
.addHelpText('after', `
22+
.addHelpText(
23+
'after',
24+
`
2325
Examples:
2426
awesome extra --help
25-
awesome help extra`);
27+
awesome help extra`,
28+
);
2629

2730
program.parse();
2831

examples/deploy

+12-4
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,19 @@ program
2525
.option('-e, --exec_mode <mode>', 'Which exec mode to use', 'fast')
2626
.action((script, options) => {
2727
console.log('read config from %s', program.opts().config);
28-
console.log('exec "%s" using %s mode and config %s', script, options.exec_mode, program.opts().config);
29-
}).addHelpText('after', `
28+
console.log(
29+
'exec "%s" using %s mode and config %s',
30+
script,
31+
options.exec_mode,
32+
program.opts().config,
33+
);
34+
})
35+
.addHelpText(
36+
'after',
37+
`
3038
Examples:
3139
$ deploy exec sequential
32-
$ deploy exec async`
40+
$ deploy exec async`,
3341
);
34-
42+
3543
program.parse(process.argv);

examples/global-options-added.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@ class MyRootCommand extends Command {
2323

2424
const program = new MyRootCommand();
2525

26-
program.command('print')
26+
program
27+
.command('print')
2728
.option('--a4', 'Use A4 sized paper')
2829
.action((options) => {
2930
console.log('print options: %O', options);
3031
});
3132

32-
program.command('serve')
33+
program
34+
.command('serve')
3335
.option('-p, --port <number>', 'port number for server')
3436
.action((options) => {
3537
console.log('serve options: %O', options);

examples/global-options-nested.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,15 @@
99
const { Command } = require('commander');
1010
const program = new Command();
1111

12-
program
13-
.configureHelp({ showGlobalOptions: true })
14-
.option('-g, --global');
12+
program.configureHelp({ showGlobalOptions: true }).option('-g, --global');
1513

1614
program
1715
.command('sub')
1816
.option('-l, --local')
1917
.action((options, cmd) => {
2018
console.log({
2119
opts: cmd.opts(),
22-
optsWithGlobals: cmd.optsWithGlobals()
20+
optsWithGlobals: cmd.optsWithGlobals(),
2321
});
2422
});
2523

examples/help-subcommands-usage.js

+10-5
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,24 @@ const commander = require('commander');
66
// See also ./configure-help.js which shows configuring the subcommand list to have no usage at all
77
// and just the subcommand name.
88

9-
const program = new commander.Command()
10-
.configureHelp({ subcommandTerm: (cmd) => cmd.name() + ' ' + cmd.usage() });
9+
const program = new commander.Command().configureHelp({
10+
subcommandTerm: (cmd) => cmd.name() + ' ' + cmd.usage(),
11+
});
1112

12-
program.command('make <FILENAME>')
13+
program
14+
.command('make <FILENAME>')
1315
.usage('-root ROOTDIR [-abc] <FILENAME>')
1416
.requiredOption('--root <ROOTDIR>')
1517
.option('-a')
1618
.option('-b')
1719
.option('-c')
1820
.summary('example command with custom usage')
19-
.description('this full description is displayed in the full help and not in the list of subcommands');
21+
.description(
22+
'this full description is displayed in the full help and not in the list of subcommands',
23+
);
2024

21-
program.command('serve <SERVICE>')
25+
program
26+
.command('serve <SERVICE>')
2227
.option('--port <PORTNUMBER>')
2328
.description('example command with default simple usage');
2429

examples/hook.js

+12-5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ program
2424
.hook('preAction', (thisCommand, actionCommand) => {
2525
if (thisCommand.opts().trace) {
2626
console.log('>>>>');
27-
console.log(`About to call action handler for subcommand: ${actionCommand.name()}`);
27+
console.log(
28+
`About to call action handler for subcommand: ${actionCommand.name()}`,
29+
);
2830
console.log('arguments: %O', actionCommand.args);
2931
console.log('options: %o', actionCommand.opts());
3032
console.log('<<<<');
@@ -43,13 +45,18 @@ program
4345
}
4446
});
4547

46-
program.command('start')
48+
program
49+
.command('start')
4750
.argument('[script]', 'script name', 'server.js')
4851
.option('-d, --delay <seconds>', 'how long to delay before starting')
49-
.addOption(new Option('-p, --port <number>', 'port number').default(8080).env('PORT'))
50-
.action(async(script, options) => {
52+
.addOption(
53+
new Option('-p, --port <number>', 'port number').default(8080).env('PORT'),
54+
)
55+
.action(async (script, options) => {
5156
if (options.delay) {
52-
await new Promise(resolve => setTimeout(resolve, parseInt(options.delay) * 1000));
57+
await new Promise((resolve) =>
58+
setTimeout(resolve, parseInt(options.delay) * 1000),
59+
);
5360
}
5461
console.log(`Starting ${script} on port ${options.port}`);
5562
});

examples/nestedCommands.js

+12-20
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,23 @@ const program = new commander.Command();
99

1010
// Add nested commands using `.command()`.
1111
const brew = program.command('brew');
12-
brew
13-
.command('tea')
14-
.action(() => {
15-
console.log('brew tea');
16-
});
17-
brew
18-
.command('coffee')
19-
.action(() => {
20-
console.log('brew coffee');
21-
});
12+
brew.command('tea').action(() => {
13+
console.log('brew tea');
14+
});
15+
brew.command('coffee').action(() => {
16+
console.log('brew coffee');
17+
});
2218

2319
// Add nested commands using `.addCommand().
2420
// The command could be created separately in another module.
2521
function makeHeatCommand() {
2622
const heat = new commander.Command('heat');
27-
heat
28-
.command('jug')
29-
.action(() => {
30-
console.log('heat jug');
31-
});
32-
heat
33-
.command('pot')
34-
.action(() => {
35-
console.log('heat pot');
36-
});
23+
heat.command('jug').action(() => {
24+
console.log('heat jug');
25+
});
26+
heat.command('pot').action(() => {
27+
console.log('heat pot');
28+
});
3729
return heat;
3830
}
3931
program.addCommand(makeHeatCommand());

examples/options-boolean-or-value.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
const commander = require('commander');
88
const program = new commander.Command();
99

10-
program
11-
.option('-c, --cheese [type]', 'Add cheese with optional type');
10+
program.option('-c, --cheese [type]', 'Add cheese with optional type');
1211

1312
program.parse(process.argv);
1413

0 commit comments

Comments
 (0)