Add .packmindignore support for CLI lint command#195
Merged
Conversation
- Create PackmindIgnoreReader service that walks up directories to collect ignore patterns - Add ignorePatterns to LintFilesFromConfig and LintFilesAgainstRule command types - Merge .packmindignore patterns with hardcoded excludes in both lint use cases - Read .packmindignore in lintHandler and pass patterns to use cases - Consolidate tryGetGitRepositoryRoot calls in lintHandler Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Greptile SummaryThis PR adds Key changes:
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant CLI as lintHandler
participant Git as PackmindCliHexa
participant IR as PackmindIgnoreReader
participant LF as ListFiles
participant UC as LintUseCase
CLI->>Git: tryGetGitRepositoryRoot(absolutePath)
Git-->>CLI: gitRoot (string | null)
CLI->>IR: readIgnorePatterns(absolutePath, gitRoot)
Note over IR: Walk dirs from absolutePath → gitRoot<br/>(or only absolutePath if gitRoot is null)
IR-->>CLI: ignorePatterns[]
CLI->>UC: execute({ path, ignorePatterns, ... })
Note over UC: excludes = [...DEFAULT_EXCLUDES, ...ignorePatterns]
UC->>LF: listFilesInDirectory(path, [], excludes)
LF-->>UC: files[]
UC-->>CLI: violations[]
Last reviewed commit: d6fb758 |
- Bound directory walk to startDirectory when no git root to avoid collecting unrelated ancestor patterns - Extract DEFAULT_EXCLUDES shared constant from duplicated hardcoded arrays - Fix misleading double-slash in lintHandler test assertion Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Author
|
@greptile update your review |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…Reader - Check for ENOENT specifically in parseIgnoreFile, re-throw other errors - Wrap readIgnorePatterns call in lintHandler with try/catch to log warning - Add tests for unreadable .packmindignore and lintHandler error fallback Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The `.min.` and `.map.` patterns never matched any files because matchesGlobPattern treated them as exact directory segment matches. Changed to `*.min.*` and `*.map` glob patterns which correctly go through the regex conversion branch. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…stRuleUseCase Verify that ignorePatterns passed to execute() are merged with DEFAULT_EXCLUDES when calling listFilesInDirectory. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Escape `.`, `[`, `(`, `{` and other special chars before glob-to-regex
conversion, preventing `*.min.*` from false-matching `admin.js` and
preventing SyntaxError crashes on user patterns containing `[` or `(`
- Add regression tests: admin.js not excluded, app.min.js excluded,
bracket pattern does not crash
- Fix docs: correct default exclusion patterns from `.min.*`/`.map.*`
to `*.min.*`/`*.map` in linter.mdx
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
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.



Explanation
Add support for
.packmindignorefiles in the CLI lint command. This allows users to exclude additional files/folders from analysis without modifying CLI source code, similar to.gitignore.The
.packmindignorefile supports:ListFiles.matchesGlobPattern())#lines) and empty lines are ignored.packmindignorefilesnode_modules,dist,.min.,.map.,.git)Type of Change
Affected Components
packmind-cliTesting
Test Details:
PackmindIgnoreReader.spec.ts: 7 tests covering parsing, comment stripping, whitespace trimming, multi-level merging, and edge caseslintHandler.spec.ts: 4 new tests verifying ignore patterns are read and passed to bothlintFilesFromConfigandlintFilesAgainstRuleTODO List
Reviewer Notes
lintHandlerwas refactored to consolidate 3 separatetryGetGitRepositoryRootcalls into 1, which is a minor improvement alongside the feature.packmindignorepatterns apply to all lint modes: full scan,--changed-files,--changed-lines, and--rule🤖 Generated with Claude Code