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
4 changes: 2 additions & 2 deletions packages/rstack/src/fmt/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ ${color.cyan('Options')}:
--check Check whether files are formatted
--list-different Print paths of unformatted files
--ignore-path <path> Path to an additional ignore file (repeatable)
--ignore-unknown Ignore unknown files
-u, --ignore-unknown Ignore unknown files
--no-error-on-unmatched-pattern Do not error when no files match
--parallel-workers <count> Number of parallel workers
--stdin-filepath <path> Format stdin as if it were saved at <path>
Expand All @@ -59,7 +59,7 @@ const parseFmtCLIArgs = (args: string[]): ParsedFmtCLIArgs => {
check: { type: 'boolean' },
'list-different': { type: 'boolean' },
'ignore-path': { type: 'string', multiple: true },
'ignore-unknown': { type: 'boolean' },
'ignore-unknown': { type: 'boolean', short: 'u' },
'no-error-on-unmatched-pattern': { type: 'boolean' },
'parallel-workers': { type: 'string' },
'stdin-filepath': { type: 'string' },
Expand Down
12 changes: 11 additions & 1 deletion packages/rstack/tests/cli/fmt/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ test('ignores unsupported files with --ignore-unknown', () => {
writeProjectFile('notes.unknown', 'plain text');

for (const modeArgs of [[], ['--check'], ['--list-different']]) {
const result = runFmt([...modeArgs, '--ignoreUnknown', 'notes.unknown']);
const result = runFmt([...modeArgs, '--ignore-unknown', 'notes.unknown']);

expect(result.status).toBe(0);
expect(result.stdout).toBe(
Expand All @@ -652,6 +652,16 @@ test('ignores unsupported files with --ignore-unknown', () => {
}
});

test('supports -u as an alias for --ignore-unknown', () => {
writeProjectFile('notes.unknown', 'plain text');

const result = runFmt(['-u', 'notes.unknown']);

expect(result.status).toBe(0);
expect(result.stdout).toBe('');
expect(result.stderr).toBe('');
});

test('does not treat unmatched patterns as unknown files', () => {
const result = runFmt(['--ignore-unknown', 'missing/**/*.unknown']);

Expand Down
2 changes: 1 addition & 1 deletion packages/rstack/tests/fmt/__snapshots__/cli.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Options:
--check Check whether files are formatted
--list-different Print paths of unformatted files
--ignore-path <path> Path to an additional ignore file (repeatable)
--ignore-unknown Ignore unknown files
-u, --ignore-unknown Ignore unknown files
--no-error-on-unmatched-pattern Do not error when no files match
--parallel-workers <count> Number of parallel workers
--stdin-filepath <path> Format stdin as if it were saved at <path>
Expand Down
2 changes: 1 addition & 1 deletion packages/rstack/tests/fmt/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ test('parses --no-error-on-unmatched-pattern', () => {
expect(parseFmtCLIArgs(['--no-error-on-unmatched-pattern']).noErrorOnUnmatchedPattern).toBe(true);
});

test.each(['--ignore-unknown', '--ignoreUnknown'])('parses %s', (option) => {
test.each(['-u', '--ignore-unknown', '--ignoreUnknown'])('parses %s', (option) => {
expect(parseFmtCLIArgs([option]).ignoreUnknown).toBe(true);
});

Expand Down
8 changes: 7 additions & 1 deletion website/docs/en/guide/cli/fmt.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,13 @@ Each file acts as a separate ignore source. See [Ignore order](../formatting#ign
Ignore matched files when no parser can be inferred. This allows the command to exit successfully even when every matched file has an unknown type:

```bash
rs fmt --ignore-unknown '**/*'
rs fmt --ignore-unknown
```

The short option `-u` is an alias for `--ignore-unknown`.

```bash
rs fmt -u
```

This option does not suppress errors for unmatched paths or globs. Combine it with [`--no-error-on-unmatched-pattern`](#--no-error-on-unmatched-pattern) when an integration needs to tolerate both cases.
Expand Down
8 changes: 7 additions & 1 deletion website/docs/zh/guide/cli/fmt.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,13 @@ rs fmt --ignore-path .prettierignore --ignore-path config/format.ignore
忽略无法推断 parser 的匹配文件。即使所有匹配文件的类型均未知,该选项也可以让命令成功退出:

```bash
rs fmt --ignore-unknown '**/*'
rs fmt --ignore-unknown
```

短选项 `-u` 是 `--ignore-unknown` 的别名。

```bash
rs fmt -u
```

此选项不会忽略未匹配路径或 glob 的错误。如果集成需要同时容忍这两种情况,可以将它与 [`--no-error-on-unmatched-pattern`](#--no-error-on-unmatched-pattern) 一起使用。
Expand Down