Skip to content

Fix #87 Add --ignore-domains-file to load ignore domain patterns from a file - #198

Open
prakhar2000 wants to merge 1 commit into
morganstanley:mainfrom
prakhar2000:feat/ignore-domains-file
Open

prakhar2000 wants to merge 1 commit into
morganstanley:mainfrom
prakhar2000:feat/ignore-domains-file

Conversation

@prakhar2000

Copy link
Copy Markdown

Fixes #87

  1. Adds --ignore-domains-file <file> so domain ignore patterns can be loaded from a file instead of listing them all on the CLI.
  2. Reuses the existing --scan-file / --exclude-file loader: one pattern per line, # comments and blank lines skipped.
  3. File patterns are merged with --ignore-domains and passed through as ignoreDomains. No changes to urlFilter.ts were needed.

@prakhar2000
prakhar2000 requested a review from a team as a code owner September 15, 2026 23:22
@codecov

codecov Bot commented Sep 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 51.12%. Comparing base (ca0cb7a) to head (16d20f8).

Files with missing lines Patch % Lines
src/cli.ts 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #198      +/-   ##
==========================================
+ Coverage   49.89%   51.12%   +1.22%     
==========================================
  Files           9        9              
  Lines         487      491       +4     
  Branches      107      112       +5     
==========================================
+ Hits          243      251       +8     
+ Misses        244      240       -4     
Flag Coverage Δ
unittests 51.12% <0.00%> (+1.22%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bingenito

Copy link
Copy Markdown
Member

Thanks for the contribution, Prakhar! I went through the PR and the feature itself is correctly implemented — I verified the parsing, the merge, and the filtering, and the new tests pass. A few things worth addressing before this lands:

  1. The new CLI wiring isn't actually covered by the tests. tests/cli.test.ts exercises DetectorOptions.loadPatternsFromFile (a class method the CLI never calls), so the merge block in src/cli.ts that feeds ignoreDomains is untested. Concretely: if you revert ignoreDomains: options.ignoreDomains as string[] to drop the merge, the tests still pass — CI stays green while --ignore-domains-file silently filters nothing.

  2. README says comments with # are supported, but loadPatternsFromFile only strips whole-line comments. A trailing inline comment (api.corp.com # legacy) becomes a literal pattern that matches nothing, so the domain is silently not ignored. Either strip inline comments or soften the docs.

  3. loadPatternsFromFile is duplicated in src/cli.ts and DetectorOptions — the PR adds a third call site to the local copy, so a parsing fix in one implementation (the one the tests cover) never reaches the CLI. Consolidating to one implementation would remove the drift risk.

  4. The src/options.ts docstring now claims this method serves --ignore-domains-file, but the CLI uses its local copy — the docs misrepresent which code path runs.

  5. Small one: the README example names the file allowlist.txt, which is the opposite concept of the blocklist flag — ignored-domains.txt or similar would avoid inverted expectations.

Happy to help if you'd like to iterate on this — items 2, 4, and 5 are quick wins, and 1/3 would make the wiring genuinely tested.

Mirrors --scan-file / --exclude-file so large allowlists can be versioned
instead of passed on the CLI. Patterns from the file are appended to
--ignore-domains (and, like other CLI flags, override the config file's
ignoreDomains). Unlike the scan/exclude pattern files, the file is also
honoured in --stdin-language mode.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@prakhar2000
prakhar2000 force-pushed the feat/ignore-domains-file branch from 16d20f8 to e22efef Compare November 10, 2026 10:20
@prakhar2000

Copy link
Copy Markdown
Author

Thanks for the thorough review, @bingenito ! :

  1. CLI wiring is now tested. New end-to-end tests in tests/cli.test.ts run --ignore-domains-file through program.parseAsync. They cover the flag on its own, combined with --ignore-domains, and in --stdin-language mode. I checked that they catch the regression you described: with the ignoreDomains merge in src/cli.ts removed, those three tests fail.
  2. Trailing comments are stripped. A # with whitespace before it now starts a comment, so api.corp.com # legacy becomes api.corp.com. A # with no space before it stays in the pattern, so globs like src/#gen/** still work. CRLF files are handled too.
  3. One loader. There's now a single exported loadPatternsFromFile in src/options.ts. The CLI imports it, and DetectorOptions.loadPatternsFromFile delegates to it. The copy in cli.ts is removed.
  4. Docstring now describes the actual behaviour, since the CLI uses the shared loader.
  5. Renamed the README example to ignored-domains.txt.

How the file combines with other options: its patterns are added to --ignore-domains, and together they override the config file's ignoreDomains, the same way --scan-file / --exclude-file work. Unlike those two, it also applies in stdin mode, since it controls which URLs get reported rather than which files get read.

One side effect: trailing-comment handling now also applies to --scan-file / --exclude-file, because they share the loader.

Build, lint and the full test suite (180 tests) pass locally, and all new and changed lines are covered. Could you approve the CI workflows for the new commit? Happy to make further changes if needed.

@bingenito

Copy link
Copy Markdown
Member

Thanks for the thorough review

Checking again, we'll worry about the DCO once everything is good. If you want to get a jump start looking at the contributing guide. Our DCO isn't as straightforward as signed commits, you'll need to include a file with first contribution and then refer to that on every commit message moving forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add allowlist file support (--ignore-domains-file)

2 participants