Skip to content

Injected files strict checking#2380

Draft
jonathanKingston wants to merge 6 commits into
mainfrom
jkt/auto/injected-files-strict-checking-afb6
Draft

Injected files strict checking#2380
jonathanKingston wants to merge 6 commits into
mainfrom
jkt/auto/injected-files-strict-checking-afb6

Conversation

@jonathanKingston
Copy link
Copy Markdown
Contributor

@jonathanKingston jonathanKingston commented Feb 28, 2026

Asana Task/Github Issue:

Description

Created 13 Cursor rule files (.cursor/rules/strict-*.mdc) to define subagent tasks for migrating all 80 remaining injected/src/ files into strict TypeScript checking (CORE_FILES). Each rule file is a self-contained task, providing:

  • Specific file assignments for strictness fixes.
  • Full tsc --strict error output for the assigned files.
  • Detailed fix patterns for common TypeScript errors.
  • A step-by-step workflow for subagents, including branching and verification.
  • Constraints to ensure type-only changes without introducing any or @ts-ignore.

These files enable parallel subagent execution to systematically address strictness errors across the injected/src/ directory.

Testing Steps

  • Launch subagents using these rule files (e.g., cursor --rule .cursor/rules/strict-detectors.mdc).
  • Verify that each subagent creates a separate branch following the cursor/strict/<name> convention.
  • Confirm that the subagents correctly identify and fix strict errors as per their instructions, and that tsc-strict-core passes on their respective branches.

Checklist

Please tick all that apply:

  • I have tested this change locally
  • I have tested this change locally in all supported browsers
  • This change will be visible to users
  • I have added automated tests that cover this change
  • I have ensured the change is gated by config
  • This change was covered by a ship review
  • This change was covered by a tech design
  • Any dependent config has been merged

Open in Web Open in Cursor 


Note

Low Risk
Adds documentation-like Cursor rule files only; no runtime code or build configuration is changed beyond guiding future work, so behavior risk is low.

Overview
Introduces 13 new .cursor/rules/strict-*.mdc files that define subagent task plans for enabling strict TypeScript checking across remaining injected/src areas (broker protection, click-to-load, detectors, DuckPlayer, fingerprinting, message bridge, standalone features, and web compat/telemetry).

Each rule file enumerates the target files, captures current tsc --strict error output, and provides fix patterns/workflows (including adding the files to CORE_FILES in scripts/check-strict-core.js) to enable parallel, type-only strictness migrations. No hardcoded secrets were found in the added rules.

Reviewed by Cursor Bugbot for commit 5ef9a78. Bugbot is set up for automated code reviews on this repo. Configure here.

Each .cursor/rules/strict-*.mdc file defines a self-contained subagent task:
- File list to add to CORE_FILES in scripts/check-strict-core.js
- Exact tsc strict errors per file with line numbers
- Fix patterns for each error category
- Step-by-step workflow (branch, fix, verify, push)
- Constraints (no any, no ts-ignore, type-only changes)

Subagent groups (80 files total, ~641 errors):
1. zero-errors-batch: 16 files, 0 errors (just register)
2. detectors: 4 files, 17 errors
3. broker-protection-actions: 7 files, 39 errors
4. broker-protection-rest: 8 files, 22 errors
5. click-to-load: 2 files, 170 errors
6. duckplayer: 9 files, 41 errors
7. duckplayer-native: 7 files, 20 errors
8. fingerprinting: 5 files, 26 errors
9. message-bridge: 3 files, 62 errors
10. web-compat-and-telemetry: 2 files, 69 errors
11. standalone-features-a: 7 files, 108 errors
12. standalone-features-b: 5 files, 53 errors
13. standalone-features-c: 5 files, 13 errors

Co-authored-by: Jonathan Kingston <jonathanKingston@users.noreply.github.com>
@cursor
Copy link
Copy Markdown
Contributor

cursor Bot commented Feb 28, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 28, 2026

[Beta] Generated file diff

Time updated: Fri, 22 May 2026 10:15:56 GMT

daxtheduck
daxtheduck previously approved these changes Feb 28, 2026
@daxtheduck daxtheduck dismissed their stale review March 1, 2026 22:58

Dismissing stale approval — new commits pushed, awaiting Cursor re-review.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 1, 2026

Build Branch

Branch pr-releases/jkt/auto/injected-files-strict-checking-afb6
Commit 36890eb9b7
Updated May 22, 2026 at 10:15:14 AM UTC

Static preview entry points

QR codes (mobile preview)
Entry point QR code
Docs QR for docs preview
Static pages QR for static pages preview
Integration pages QR for integration pages preview

Integration commands

npm (Android / Extension):

npm i github:duckduckgo/content-scope-scripts#pr-releases/jkt/auto/injected-files-strict-checking-afb6

Swift Package Manager (Apple):

.package(url: "https://github.com/duckduckgo/content-scope-scripts.git", branch: "pr-releases/jkt/auto/injected-files-strict-checking-afb6")

git submodule (Windows):

git -C submodules/content-scope-scripts fetch origin pr-releases/jkt/auto/injected-files-strict-checking-afb6
git -C submodules/content-scope-scripts checkout origin/pr-releases/jkt/auto/injected-files-strict-checking-afb6
Pin to exact commit

npm (Android / Extension):

npm i github:duckduckgo/content-scope-scripts#36890eb9b7bb5fc7314fa2309dcfccf0e13d6620

Swift Package Manager (Apple):

.package(url: "https://github.com/duckduckgo/content-scope-scripts.git", revision: "36890eb9b7bb5fc7314fa2309dcfccf0e13d6620")

git submodule (Windows):

git -C submodules/content-scope-scripts fetch origin pr-releases/jkt/auto/injected-files-strict-checking-afb6
git -C submodules/content-scope-scripts checkout 36890eb9b7bb5fc7314fa2309dcfccf0e13d6620

daxtheduck
daxtheduck previously approved these changes Mar 1, 2026
@github-actions github-actions Bot added the patch Increment the patch version when merged label Mar 4, 2026
@daxtheduck daxtheduck dismissed their stale review March 4, 2026 14:16

Dismissing stale approval — new commits pushed, awaiting Cursor re-review.

daxtheduck
daxtheduck previously approved these changes Mar 4, 2026
@daxtheduck daxtheduck dismissed their stale review March 5, 2026 01:52

Dismissing stale approval — new commits pushed, awaiting Cursor re-review.

@github-actions github-actions Bot added the semver-patch Bug fix / internal — no release needed label Mar 5, 2026
daxtheduck
daxtheduck previously approved these changes Mar 5, 2026
@daxtheduck daxtheduck dismissed their stale review March 9, 2026 22:43

Dismissing stale approval — new commits pushed, awaiting Cursor re-review.

Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Web Compatibility Assessment

  1. .cursor/rules/strict-broker-protection-rest.mdc (## Fix Patterns, around line 88), severity: info.
    The change is process/documentation-only and does not modify injected runtime code paths (load/init/urlChanged, wrappers, shims, or platform entry points), so there is no direct API-surface/prototype-chain/site-compat regression in this PR itself.

  2. .cursor/rules/*.mdc (all new files), severity: info.
    No changes to injected/src/ execution logic, wrapper utilities, or feature enablement gates were introduced; compatibility risk is deferred to follow-up implementation PRs that apply these rules.

Security Assessment

  1. .cursor/rules/strict-broker-protection-rest.mdc (## Fix Patterns, around line 88), severity: warning.
    The guidance includes "Add // @ts-ignore only as last resort" for parse-address. In this codebase, suppressing checker errors in injected/security-sensitive code can mask type-contract violations around page-controlled data and should be avoided in migration guidance unless narrowly constrained and justified.

  2. .cursor/rules/*.mdc (all new files), severity: info.
    No modifications to captured-globals, message transports, message-bridge trust checks, origin validation, or network/data-exfiltration surfaces were made. Direct exploitability change in this PR is effectively nil.

Risk Level

Low Risk — this PR adds only Cursor rule/task-definition files and does not alter shipped injected JavaScript behavior, platform bridges, or security-critical runtime code.

Recommendations

  1. Remove or tighten the @ts-ignore suggestion in .cursor/rules/strict-broker-protection-rest.mdc; prefer local type declarations (.d.ts) or unknown + narrowing.
  2. Add a short shared rule snippet (referenced by all strict task files) forbidding @ts-ignore/any without exception to prevent drift across subagent outputs.
  3. For follow-up PRs generated from these rules, require targeted integration coverage for message-bridge, web-compat, and wrapper-facing files in addition to tsc-strict-core/unit/lint checks.

Open in Web View Automation 

daxtheduck
daxtheduck previously approved these changes Mar 9, 2026
@daxtheduck daxtheduck dismissed their stale review May 22, 2026 10:16

Dismissing stale approval — new commits pushed, awaiting Cursor re-review.

Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Web Compatibility Assessment

  1. .cursor/rules/*.mdc (all new files), severity: info.
    This PR adds Cursor task/rule files only. It does not change shipped injected runtime code, feature lifecycle ordering, wrappers/shims, platform entry points, DOM observers, or API overrides, so I do not see a direct web-compat regression in the current diff.

Security Assessment

  1. .cursor/rules/strict-message-bridge.mdc line 96, .cursor/rules/strict-web-compat-and-telemetry.mdc line 80, .cursor/rules/strict-broker-protection-rest.mdc line 86, severity: warning.
    The strict-fix guidance recommends bare String(error) / instanceof Error patterns. For injected code, especially message-bridge and web-compat, that can lead follow-up implementations to read mutable page-world globals instead of importing captured String / Error from injected/src/captured-globals.js. This PR does not introduce the runtime bug directly, but the rule would steer future strictness migrations toward a global-capture hygiene violation.

  2. .cursor/rules/strict-broker-protection-rest.mdc lines 88 and 106, severity: warning.
    The parse-address guidance allows // @ts-ignore as an exception. In injected/security-sensitive code, suppressing checker errors can hide contract mismatches around page-controlled data. Prefer a minimal local declaration or typed wrapper with unknown + narrowing, and keep the rule’s no-@ts-ignore constraint absolute.

Risk Level

Low Risk — current changes are process-only Cursor rules and do not alter shipped injected JavaScript, messaging transports, captured globals, or origin/security checks.

Recommendations

  1. Replace bare error coercion guidance with captured-global-safe patterns, e.g. import { String, Error } from captured-globals.js where coercion or instanceof is needed.
  2. Remove the @ts-ignore exception for parse-address; use a local .d.ts module declaration or a narrow typed adapter instead.
  3. For follow-up PRs generated from these rules, require targeted review/tests for message-bridge, web-compat, and wrapper-facing strictness fixes, not just tsc-strict-core.
Open in Web View Automation 

Sent by Cursor Automation: Web compat and sec

### message-bridge.js (5 errors)
- TS7006: Add `@param` annotations.
- TS2769: Same overload pattern as above.
- TS18046: `instanceof Error` check or `String(e)`.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For injected code, this guidance should avoid bare String(e) / instanceof Error: both read mutable page-world globals if copied into runtime code. Prefer explicitly importing captured String / Error from injected/src/captured-globals.js in follow-up strictness fixes, especially in message-bridge.

- **TS7006** (Parameter implicitly any): Add `@param {Type}` JSDoc.
- **TS18046** ('e' is unknown): Use `error instanceof Error ? error.message : String(error)` pattern.
- **TS2345** (Argument not assignable): Narrow types with guards or adjust the function signature upstream.
- **TS7016** (No declaration file for module): Add `// @ts-ignore` only as last resort, or create a minimal `.d.ts` declaration in the project. Better: use `/** @type {import('parse-address')} */` if types exist, or `/** @type {Record<string, Function>} */` for the default import.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’d remove the @ts-ignore escape hatch here. A minimal local module declaration or typed adapter keeps strict checking useful without creating a pattern that can suppress security-relevant type contract issues in injected code.

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

Labels

patch Increment the patch version when merged semver-patch Bug fix / internal — no release needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants