Injected files strict checking#2380
Conversation
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 Agent can help with this pull request. Just |
[Beta] Generated file diffTime updated: Fri, 22 May 2026 10:15:56 GMT |
Dismissing stale approval — new commits pushed, awaiting Cursor re-review.
Build Branch
Static preview entry points
QR codes (mobile preview)
Integration commandsnpm (Android / Extension): 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-afb6Pin to exact commitnpm (Android / Extension): 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 |
Dismissing stale approval — new commits pushed, awaiting Cursor re-review.
Dismissing stale approval — new commits pushed, awaiting Cursor re-review.
Dismissing stale approval — new commits pushed, awaiting Cursor re-review.
There was a problem hiding this comment.
Stale comment
Web Compatibility Assessment
.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.
.cursor/rules/*.mdc(all new files), severity:info.
No changes toinjected/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
.cursor/rules/strict-broker-protection-rest.mdc(## Fix Patterns, around line 88), severity:warning.
The guidance includes"Add // @ts-ignore only as last resort"forparse-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.
.cursor/rules/*.mdc(all new files), severity:info.
No modifications tocaptured-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
- Remove or tighten the
@ts-ignoresuggestion in.cursor/rules/strict-broker-protection-rest.mdc; prefer local type declarations (.d.ts) orunknown+ narrowing.- Add a short shared rule snippet (referenced by all strict task files) forbidding
@ts-ignore/anywithout exception to prevent drift across subagent outputs.- For follow-up PRs generated from these rules, require targeted integration coverage for
message-bridge,web-compat, and wrapper-facing files in addition totsc-strict-core/unit/lint checks.
Dismissing stale approval — new commits pushed, awaiting Cursor re-review.
There was a problem hiding this comment.
Web Compatibility Assessment
.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
-
.cursor/rules/strict-message-bridge.mdcline 96,.cursor/rules/strict-web-compat-and-telemetry.mdcline 80,.cursor/rules/strict-broker-protection-rest.mdcline 86, severity:warning.
The strict-fix guidance recommends bareString(error)/instanceof Errorpatterns. For injected code, especiallymessage-bridgeandweb-compat, that can lead follow-up implementations to read mutable page-world globals instead of importing capturedString/Errorfrominjected/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. -
.cursor/rules/strict-broker-protection-rest.mdclines 88 and 106, severity:warning.
Theparse-addressguidance allows// @ts-ignoreas 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 withunknown+ narrowing, and keep the rule’s no-@ts-ignoreconstraint 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
- Replace bare error coercion guidance with captured-global-safe patterns, e.g. import
{ String, Error }fromcaptured-globals.jswhere coercion orinstanceofis needed. - Remove the
@ts-ignoreexception forparse-address; use a local.d.tsmodule declaration or a narrow typed adapter instead. - For follow-up PRs generated from these rules, require targeted review/tests for
message-bridge,web-compat, and wrapper-facing strictness fixes, not justtsc-strict-core.
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)`. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.


Asana Task/Github Issue:
Description
Created 13 Cursor rule files (
.cursor/rules/strict-*.mdc) to define subagent tasks for migrating all 80 remaininginjected/src/files into strict TypeScript checking (CORE_FILES). Each rule file is a self-contained task, providing:tsc --stricterror output for the assigned files.anyor@ts-ignore.These files enable parallel subagent execution to systematically address strictness errors across the
injected/src/directory.Testing Steps
cursor --rule .cursor/rules/strict-detectors.mdc).cursor/strict/<name>convention.tsc-strict-corepasses on their respective branches.Checklist
Please tick all that apply:
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-*.mdcfiles that define subagent task plans for enabling strict TypeScript checking across remaininginjected/srcareas (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 --stricterror output, and provides fix patterns/workflows (including adding the files toCORE_FILESinscripts/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.