Commit Graph

2 Commits

Author SHA1 Message Date
Ignacy Łątka acfe80ab6b chore: add ESLint with typescript-eslint (#349)
## What

Adds type-aware linting to the workspace. Until now the only static gate
on JS/TS was Prettier (formatting) and `tsc` — there was no linter, so
the whole class of bugs `tsc` doesn't catch (floating promises, misused
promises, throwing non-Errors, unsafe stringification, dead code) went
unguarded across ~450 TS files.

- **`eslint.config.mjs`** — flat config. `recommendedTypeChecked` runs
on the TS sources via an explicit `project` list (each package keeps
tests in a separate `tsconfig.test.json` that `projectService` can't
auto-discover, so it's listed explicitly). Type-checked rules are
disabled for the loosely-typed plain-JS build/dev scripts. The
`argent-private` submodule and build artifacts are ignored (mirrors
`.prettierignore`).
- **`lint` / `lint:fix`** npm scripts.
- **`.github/workflows/lint.yml`** — builds the workspace (type-aware
rules need the referenced projects' declarations) then runs `eslint .`.
Node 24 (ESLint 10 requires `^20.19 || ^22.13 || >=24`).

## Rule calibration

This is an adoption PR, so it's deliberately calibrated rather than
maximal:

- **Kept on (bug-catchers):** `no-floating-promises`,
`no-misused-promises` (with `checksVoidReturn: false` to drop the noisy
callback variant), `only-throw-error`, `no-base-to-string`,
`prefer-promise-reject-errors`, `no-unused-vars` (`_`-prefix escape
hatch), plus the ESLint recommended set.
- **Parked off as documented debt:** the high-volume style/`any`-family
rules — `no-unsafe-*`, `require-await`, `no-unnecessary-type-assertion`,
`restrict-template-expressions`, `unbound-method`, `no-explicit-any`,
etc. These flag broad classes of pre-existing code and are out of scope
here; each is commented as a ratchet target for follow-up passes.

All findings from the kept-on rules are fixed in this PR (dead
code/imports, error-cause chaining, **3 genuine floating promises**,
non-Error throws, unsafe stringification). Stale unused `eslint-disable`
directives left over in the tree were removed by `--fix`.

## Verification

Locally, all green: `eslint .` (0 errors), `tsc --build`,
`typecheck:tests`/`typecheck:scripts`, the full `vitest` suite (no
behavior change from the fixes), and `prettier --check`.

## Not included (intentionally)

Other static-analysis gates discussed (CodeQL, dependency-audit,
ShellCheck, actionlint) are out of scope for this PR.
2026-06-17 12:20:55 +02:00
filip131311 083947111b feat(chromium): network inspection via view-network-logs / view-network-request-details (#335)
## Summary

Adds network inspection for Chromium (CDP) devices by extending the
**existing** RN network tools rather than adding a new one — so there's
one network-viewing surface across platforms.

- **`view-network-logs`** and **`view-network-request-details`** now
also accept a `chromium-cdp-<port>` `device_id`. They dispatch on the
device id (the same pattern the ported `debugger-*` tools and
`gesture-tap` use): RN → the Metro-injected `fetch` interceptor;
Chromium → the browser's native CDP `Network` recording for the **active
tab**. Same flags, same output shape.
- Both widen their capability from RN-only to `DEBUGGER_TOOL_CAPABILITY`
(apple + android + chromium).

## How the Chromium side works

A lean **`NetworkManager`** (`chromium-server/network.ts`) keeps a
passive, always-on capped ring buffer fed by the page's CDP `Network`
events, re-attached on tab switch so it follows the active tab. No
in-app injection (the browser exposes `Network` natively).
`view-network-request-details` fetches the response body on demand via
`Network.getResponseBody`, and reuses the existing header-redaction.

**Read-only**, matching the `view-network-*` contract. Per review, the
earlier cut's standalone `chromium-network` tool and its Fetch-based
**routing / abort / mock / HAR** were **removed** — the read capability
on the existing tools is sufficient.

> Rebased onto `main` after #334 (tabs) merged — diff is network-only.

## Test plan

- [x] `NetworkManager`: recording (fields/duration/headers/failed,
oldest-first), `get()`, `reattach` (Network.enable), `dispose` (disable
+ detach).
- [x] Chromium branch of both view tools: capability now admits
chromium, `services()` routing, paginated render matching the RN format,
no-traffic message, header redaction, body via
`Network.getResponseBody`, not-found.
- [x] Updated the RN locked-tools registry test (these two are no longer
RN-locked; 15→13) + a positive assertion they now admit Chromium. RN
integration tests unchanged/passing.
- [x] Full suite **1136 pass**; `tsc --build` + `typecheck:tests` +
prettier clean; tool-description gate **9.25 ≥ 9.0**.
- [x] **Live (Chrome for Testing)**: `view-network-logs --device_id
chromium-cdp-9222` → `=== NETWORK LOGS (page 1/1, 1 total) === {id: …}
"GET example.com" 200 Document`; `view-network-request-details` → full
request/response headers + body via `getResponseBody`.
2026-06-15 15:31:51 +02:00