feat(cli): add --max-file-size to skip large Markdown files (#81)#83
Merged
Conversation
Add a --max-file-size <size> flag that drops Markdown files larger than the limit (warning to stderr) before linting/fixing. Filtering reuses runTasksWithLimit with STAT_CONCURRENCY_LIMIT so it does not reintroduce the N-fd stat burst fixed in #80. --threads auto recomputes concurrency on the remaining files; behavior is unchanged when the flag is omitted.
Replace formatMiB (always MiB) with formatBytes, which picks B / KiB / MiB / GiB dynamically so sub-MiB thresholds no longer render as a misleading "0 MiB".
Replace the permissive [bkmg]+ unit class (which accepted then rejected kk/mbb) with an explicit b|k|kb|m|mb|g|gb alternation, matching the issue's format definition. Drop the now-dead multiplier guard and add a test pinning malformed-unit rejection.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--max-file-size <size>CLI flag. Markdown files larger than the limit are skipped with awarning: skipped large Markdown file ...message written to stderr, and never reach lint/fix.b/kb/k/mb/m/gb/g(case-insensitive). Decimals (1.5mb), whitespace (1 mb),0, negatives, and invalid strings are rejected withexit 1+ stderr, matching the--threadsvalidation style.loadMdFiles()and beforeresolveAdaptiveConcurrency(), so--threads autorecomputes concurrency on the remaining files (the two are intentionally independent, per the issue).--fixalso skips oversized files. Filtered-to-empty reuses the existing🎉 No markdown files to lint 🎉path.Why this design
filterFilesByMaxSizereusesrunTasksWithLimitwith the existingSTAT_CONCURRENCY_LIMIT(128), so the per-filestat()pass is bounded exactly likegetMaxFileSize. We deliberately did not add another unboundedPromise.all(stat).parse-size.tsparses/validates sizes;configure.ts#getMaxFileSizeOptiondoes CLI validation +exit 1;filter-by-max-size.tsdoes the bounded scan + warning. The existinggetMaxFileSize(real-max-size) is untouched.Scope / non-goals
.lintmdrcpersistence, no--ignore-large-filesflag, no default threshold (omit = unlimited).lintMarkdown()public API unchanged.Test plan
parse-size.spec.ts: unit tests for500kb/1mb/5mb/1gb(+ case), and rejection of1.5mb/1 mb/0/-1/abc.max-file-size.spec.ts:STAT_CONCURRENCY_LIMIT; stat failure propagates.--fixskips; all filtered → 🎉 message;--threads auto+ filter on remaining files.npm test(88 passed) andnpm run lintgreen.Closes #81
🤖 Generated with opencode