Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions packages/rstack/src/cli/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,31 @@ const renderLibMfDevHelp = (): string =>
],
});

const renderLintHelp = (): string =>
renderHelp({
usage: 'rs lint [options] [files...]',
description: 'Lint code',
sections: [
{
title: 'Options',
items: [
['--fix', 'Automatically fix problems'],
['--type-check', 'Enable TypeScript type checking'],
['--type-check-only', 'Run only TypeScript type checking'],
['--format <format>', 'Set output format (default | jsonline | github | gitlab)'],
['--quiet', 'Report errors only'],
['--timing [all|N]', 'Print a per-rule timing table (all rules or top N)'],
['--max-warnings <count>', 'Set the maximum number of warnings'],
['--rule <rule>', 'Override a rule (repeatable)'],
['--no-color', 'Disable colored output'],
['--force-color', 'Force colored output'],
['-c, --config <path>', 'Specify Rstack config file path'],
['-h, --help', 'Display this help message'],
],
},
],
});

async function runRsbuildCLI(args: string[]): Promise<void> {
if (hasHelpFlag(args)) {
switch (args[0]) {
Expand Down Expand Up @@ -439,6 +464,11 @@ async function runRspressCLI(args: string[]): Promise<void> {
}

async function runRslintCLI(args: string[]): Promise<void> {
if (hasHelpFlag(args)) {
console.log(renderLintHelp());
return;
}

const argv = [
process.execPath,
'rslint',
Expand Down
24 changes: 24 additions & 0 deletions packages/rstack/tests/cli/__snapshots__/help.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,30 @@ Options:
"
`;

exports[`displays lint help 1`] = `
"Rstack v<version>

Usage:
$ rs lint [options] [files...]

Lint code

Options:
--fix Automatically fix problems
--type-check Enable TypeScript type checking
--type-check-only Run only TypeScript type checking
--format <format> Set output format (default | jsonline | github | gitlab)
--quiet Report errors only
--timing [all|N] Print a per-rule timing table (all rules or top N)
--max-warnings <count> Set the maximum number of warnings
--rule <rule> Override a rule (repeatable)
--no-color Disable colored output
--force-color Force colored output
-c, --config <path> Specify Rstack config file path
-h, --help Display this help message
"
`;

exports[`displays preview help 1`] = `
"Rstack v<version>

Expand Down
2 changes: 1 addition & 1 deletion packages/rstack/tests/cli/help.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test('displays top-level help', ({ execCli, expect }) => {
expect(normalizeHelpOutput(execCli('--help'))).toMatchSnapshot();
});

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

Expand Down
1 change: 1 addition & 0 deletions scripts/dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ extglob
fnames
huskyrc
indentable
jsonline
llms
napi
noformat
Expand Down