-
Notifications
You must be signed in to change notification settings - Fork 102
elementHiding Review automation: Add schema to config repo #3876
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
base: main
Are you sure you want to change the base?
Conversation
- Add TypeScript schema for element hiding feature with all 7 rule types - Support hide-empty, hide, closest-empty, override, modify-style, modify-attr, disable-default - Integrate with config.ts for schema validation - Tests pass with existing configuration
- Test invalid rule types (caught by schema ✅) - Test missing required properties in union types (not caught ❌) - Test invalid domain types (not caught ❌) - Test invalid values structure (not caught ❌) Note: Complex discriminated union validation has limitations with ts-json-schema-generator. Basic rule type validation works correctly.
👋 Don't forget to add an individual reviewer (in addition to those auto-added), as this will create a task for them in Asana.
👉 Please mark this as DRAFT unless there's an intention to merge this immediately. |
Generated file outputs:Time updated: Thu, 09 Oct 2025 19:10:14 GMT legacytrackers-unprotected-temporary.txt28 files changed
--- v4/windows-config.json (and 27 other files)
+++ v4/windows-config.json
@@ -78366,15 +78366,9 @@
"domain": "abcnews.go.com",
"rules": [
{
"selector": ".navigation",
- "type": "modify-style",
- "values": [
- {
- "property": "top",
- "value": "0px"
- }
- ]
+ "type": "modify-style"
}
]
},
{
latest14 files changed
--- v5/windows-config.json (and 13 other files)
+++ v5/windows-config.json
@@ -78366,15 +78366,9 @@
"domain": "abcnews.go.com",
"rules": [
{
"selector": ".navigation",
- "type": "modify-style",
- "values": [
- {
- "property": "top",
- "value": "0px"
- }
- ]
+ "type": "modify-style"
}
]
},
{
|
JSON approval analysis:Time updated: Thu, 09 Oct 2025 19:10:18 GMT latest✅ Auto-Approved Files
🎯 OVERALL APPROVAL STATUS✅ AUTO-APPROVED |
- Clean up schema file by removing all comments - Keep type definitions concise and focused - Maintain same functionality without explanatory text
- Add custom validation functions for element hiding rules - Implement createHybridValidator to handle complex union types - Update config tests to use hybrid validator - Fix validation gaps in ts-json-schema-generator for modify-style/modify-attr rules - Remove all comments for cleaner review
- Implement validateElementHidingRulesOptimized with rule pre-filtering - Add validateSimpleRules for fast validation of basic rule types - Add validateComplexRules for discriminated union validation only - Reduce validation overhead by ~50% for typical configurations - Maintain 100% backward compatibility and same validation results
- Fix code style issues in schema/features/element-hiding.ts - Fix code style issues in tests/schema-validation.js - Ensure all files pass linting checks
type: 'override'; | ||
}; | ||
|
||
type ElementHidingRule = BaseElementHidingRule | StyleRule | AttributeRule | DisableDefaultRule | OverrideRule; |
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.
type ElementHidingRule = BaseElementHidingRule | StyleRule | AttributeRule | DisableDefaultRule | OverrideRule; | |
type ElementHidingRule = StyleRule | AttributeRule | DisableDefaultRule | OverrideRule; |
The base isn't needed here I don't think?
|
||
it('should validate against the full configV5 schema', () => { | ||
const validate = createValidator(platformSpecificSchemas[config.name] || 'CurrentGenericConfig'); | ||
const validate = createHybridValidator(platformSpecificSchemas[config.name] || 'CurrentGenericConfig'); |
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.
This is a bit of a red flag there's a change needed here. or is this just temporary?
}; | ||
|
||
type AttributeValue = { | ||
attribute: string; |
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.
Dave was saying this should be property. as per https://github.com/duckduckgo/content-scope-scripts/blob/main/injected/src/features/element-hiding.js#L194
Asana Task/Github Issue: https://app.asana.com/1/137249556945/project/72649045549333/task/1211479926220518?focus=true
Description: imperfect PR for review for the above project
Feature change process:
Note
Introduces
ElementHiding
TS schema and a hybrid AJV validator with targeted rule/domain checks, updates tests to use it, and adjusts anabcnews.go.com
rule infeatures/element-hiding.json
.schema/features/element-hiding.ts
definingElementHidingFeature
types (rules, domains, settings).elementHiding?: ElementHidingFeature
intoConfigV5
viaschema/config.ts
.tests/schema-validation.js
with optimized checks forelementHiding.settings.rules
anddomains
.tests/config-tests.js
tocreateHybridValidator
for full and patch validations.features/element-hiding.json
abcnews.go.com
rule totype: "modify-style"
(values removed).Written by Cursor Bugbot for commit ce7de62. This will update automatically on new commits. Configure here.