@@ -11,6 +11,7 @@ import type { FmtMode, FmtRunResult, ResolvedFmtConfig } from './types.ts';
1111interface ParsedFmtCLIArgs {
1212 mode : FmtMode ;
1313 patterns : string [ ] ;
14+ ignorePaths : string [ ] ;
1415 maxWorkers ?: number ;
1516 help : boolean ;
1617 /** Path the stdin content is formatted as; it need not exist on disk. */
@@ -28,6 +29,7 @@ ${color.cyan('Options')}:
2829 --write Write formatted files in place (default)
2930 --check Check whether files are formatted
3031 --list-different Print paths of unformatted files
32+ --ignore-path <path> Path to an additional ignore file (repeatable)
3133 --parallel-workers <count> Number of parallel workers
3234 --stdin-filepath <path> Format stdin as if it were saved at <path>
3335 -h, --help Display this help message` ;
@@ -57,6 +59,7 @@ const parseFmtCLIArgs = (args: string[]): ParsedFmtCLIArgs => {
5759 check : { type : 'boolean' } ,
5860 'list-different' : { type : 'boolean' } ,
5961 listDifferent : { type : 'boolean' } ,
62+ 'ignore-path' : { type : 'string' , multiple : true } ,
6063 'parallel-workers' : { type : 'string' } ,
6164 parallelWorkers : { type : 'string' } ,
6265 'stdin-filepath' : { type : 'string' } ,
@@ -92,6 +95,7 @@ const parseFmtCLIArgs = (args: string[]): ParsedFmtCLIArgs => {
9295 return {
9396 mode,
9497 patterns : positionals ,
98+ ignorePaths : values [ 'ignore-path' ] ?? [ ] ,
9599 maxWorkers,
96100 help : values . help ?? false ,
97101 stdinFilepath,
@@ -210,7 +214,7 @@ const runFmtCLI = async (args: string[]): Promise<void> => {
210214 // Argument errors are reported like every other failure so that a single
211215 // exit code identifies "rs fmt refused to run".
212216 try {
213- const { help, maxWorkers, mode, patterns, stdinFilepath } = parseFmtCLIArgs ( args ) ;
217+ const { help, ignorePaths , maxWorkers, mode, patterns, stdinFilepath } = parseFmtCLIArgs ( args ) ;
214218 if ( help ) {
215219 logger . log ( fmtHelpMessage ) ;
216220 return ;
@@ -221,12 +225,22 @@ const runFmtCLI = async (args: string[]): Promise<void> => {
221225 /* rspackChunkName: 'fmtStdin' */
222226 './stdin.ts'
223227 ) ;
224- await runFmtStdin ( { filepath : stdinFilepath , cwd, loadConfig : ( ) => loadFmtConfig ( cwd ) } ) ;
228+ await runFmtStdin ( {
229+ filepath : stdinFilepath ,
230+ cwd,
231+ ignorePaths,
232+ loadConfig : ( ) => loadFmtConfig ( cwd ) ,
233+ } ) ;
225234 return ;
226235 }
227236
228237 const config = await loadFmtConfig ( cwd ) ;
229- const files = await discoverFmtFiles ( { cwd, patterns, config } ) ;
238+ const files = await discoverFmtFiles ( {
239+ cwd,
240+ patterns,
241+ config,
242+ ignorePaths,
243+ } ) ;
230244
231245 if ( files . length === 0 ) {
232246 if ( mode !== 'list-different' ) {
0 commit comments