Skip to content

Commit e556fdf

Browse files
committed
Add help output for the lint command
1 parent 3165f64 commit e556fdf

3 files changed

Lines changed: 55 additions & 1 deletion

File tree

‎packages/rstack/src/cli/commands.ts‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,31 @@ const renderLibMfDevHelp = (): string =>
321321
],
322322
});
323323

324+
const renderLintHelp = (): string =>
325+
renderHelp({
326+
usage: 'rs lint [options] [files...]',
327+
description: 'Lint code',
328+
sections: [
329+
{
330+
title: 'Options',
331+
items: [
332+
['--fix', 'Automatically fix problems'],
333+
['--type-check', 'Enable TypeScript type checking'],
334+
['--type-check-only', 'Run only TypeScript type checking'],
335+
['--format <format>', 'Set output format (default | jsonline | github | gitlab)'],
336+
['--quiet', 'Report errors only'],
337+
['--timing [all|N]', 'Print a per-rule timing table (all rules or top N)'],
338+
['--max-warnings <count>', 'Set the maximum number of warnings'],
339+
['--rule <rule>', 'Override a rule (repeatable)'],
340+
['--no-color', 'Disable colored output'],
341+
['--force-color', 'Force colored output'],
342+
['-c, --config <path>', 'Specify Rstack config file path'],
343+
['-h, --help', 'Display this help message'],
344+
],
345+
},
346+
],
347+
});
348+
324349
async function runRsbuildCLI(args: string[]): Promise<void> {
325350
if (hasHelpFlag(args)) {
326351
switch (args[0]) {
@@ -439,6 +464,11 @@ async function runRspressCLI(args: string[]): Promise<void> {
439464
}
440465

441466
async function runRslintCLI(args: string[]): Promise<void> {
467+
if (hasHelpFlag(args)) {
468+
console.log(renderLintHelp());
469+
return;
470+
}
471+
442472
const argv = [
443473
process.execPath,
444474
'rslint',

‎packages/rstack/tests/cli/__snapshots__/help.test.ts.snap‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,30 @@ Options:
103103
"
104104
`;
105105
106+
exports[`displays lint help 1`] = `
107+
"Rstack v<version>
108+
109+
Usage:
110+
$ rs lint [options] [files...]
111+
112+
Lint code
113+
114+
Options:
115+
--fix Automatically fix problems
116+
--type-check Enable TypeScript type checking
117+
--type-check-only Run only TypeScript type checking
118+
--format <format> Set output format (default | jsonline | github | gitlab)
119+
--quiet Report errors only
120+
--timing [all|N] Print a per-rule timing table (all rules or top N)
121+
--max-warnings <count> Set the maximum number of warnings
122+
--rule <rule> Override a rule (repeatable)
123+
--no-color Disable colored output
124+
--force-color Force colored output
125+
-c, --config <path> Specify Rstack config file path
126+
-h, --help Display this help message
127+
"
128+
`;
129+
106130
exports[`displays preview help 1`] = `
107131
"Rstack v<version>
108132

‎packages/rstack/tests/cli/help.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ test('displays top-level help', ({ execCli, expect }) => {
1212
expect(normalizeHelpOutput(execCli('--help'))).toMatchSnapshot();
1313
});
1414

15-
for (const command of ['dev', 'build', 'preview']) {
15+
for (const command of ['dev', 'build', 'preview', 'lint']) {
1616
test(`displays ${command} help`, ({ execCli, expect }) => {
1717
const output = execCli(`${command} --help`);
1818

0 commit comments

Comments
 (0)