-
Notifications
You must be signed in to change notification settings - Fork 0
Align validation schema with upstream @jk-com/adblock-compiler #218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Remove support for 'content' field and 'inline' type (not in upstream ISource) - Make 'source' field required (per upstream schema) - Update valid types to only 'adblock' or 'hosts' (per upstream SourceType enum) - Create user-rules.txt file to replace inline content - Update compiler-config.json to use file-based source - Update tests to reflect schema changes Co-authored-by: jaypatrick <1800595+jaypatrick@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes validation errors during filter list compilation by aligning the local validation schema with the upstream @jk-com/adblock-compiler package. The local code was incorrectly accepting non-standard fields (content array and type: 'inline') that don't exist in the upstream schema.
Changes:
- Removed validation support for the
contentfield in source objects (not in upstream schema) - Restricted
typefield to only accept 'adblock' or 'hosts' (removed 'inline' option) - Made
sourcefield required (no longer optional with content alternative) - Migrated inline content from config to a new file-based source (
data/input/user-rules.txt) - Updated test assertions to reflect the schema changes
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/rules-compiler-typescript/src/validation.ts | Simplified source validation to match upstream schema - removed content field support and inline type, made source required |
| src/rules-compiler-typescript/src/validation.test.ts | Updated test assertion to remove reference to removed content field |
| src/rules-compiler-typescript/compiler-config.json | Replaced inline content with file-based source reference |
| data/input/user-rules.txt | New file containing the user rules previously defined inline |
| "||example-ads.com^", | ||
| "||tracking.example.net^" | ||
| ] | ||
| "source": "data/input/user-rules.txt", |
Copilot
AI
Jan 19, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The file path referenced in the configuration will not resolve correctly. The compiler runs from the src/rules-compiler-typescript/ directory (as shown in CI workflows), so data/input/user-rules.txt will resolve to src/rules-compiler-typescript/data/input/user-rules.txt, but the actual file was created at data/input/user-rules.txt (repository root).
The path should be ../../data/input/user-rules.txt to correctly reference the file at the repository root from the compiler's working directory.
After updating
@jk-com/adblock-compilerin #217, local validation accepted fields not in the upstreamISourceinterface:content: string[]andtype: "inline".Changes
validation.ts: Enforce upstream schema
sourcefield (URL or file path)contentfield validationtypeto'adblock' | 'hosts'(remove'inline')compiler-config.json: Migrate example to file-based source
data/input/user-rules.txtwith inline contentvalidation.test.ts: Update test assertions
Migration
Configs using invalid schema need conversion:
{ "sources": [{ - "type": "inline", - "content": ["||example.com^", "||tracker.net^"] + "source": "data/input/my-rules.txt", + "type": "adblock" }] }Valid file/URL sources continue working unchanged.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
dl.deno.land/usr/bin/curl curl --fail --location --progress-bar --output /home/REDACTED/.deno/bin/deno.zip REDACTED(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.