Repository navigation
chore(lint): Move mechanical Bugbot rules to lint and the test runner - #26854
Conversation
Ban Node built-in imports in core, browser and browser-utils, and ban eval and new Function in src. Drop two stale Bugbot rules. Refs #26852 Co-Authored-By: Francesco Gringl-Novy <2411343+mydea@users.noreply.github.com>
Flag innerHTML/outerHTML assignment, insertAdjacentHTML() and document.write()/writeln() in src, and drop the Bugbot rule it replaces. Refs #26852 Co-Authored-By: Francesco Gringl-Novy <2411343+mydea@users.noreply.github.com>
size-limit report 📦Compared: fdc01a9 (PR test merge using develop at 06fdfe2) Against: 06fdfe2 (develop) · base run #67906 ✅ Baseline matches: this diff contains only this PR's changes.
|
…no healthcheck up --wait returns as soon as such a service starts, so the test would race its startup. Drop the Bugbot rule the runner now enforces. Refs #26852 Co-Authored-By: Francesco Gringl-Novy <2411343+mydea@users.noreply.github.com>
Optional E2E testsSome optional checks were not successful. They do not block the merge. 2 not successful, 81 successful. See the run.
Successful checks
|
Ban process.version(s) and ctx/context.skip in suite tests, so they use supports() from utils instead. Refs #26852 Co-Authored-By: Francesco Gringl-Novy <2411343+mydea@users.noreply.github.com>
| const upOutcome = (result: ReturnType<typeof spawnSync>): string => | ||
| timedOut(result) ? `timed out after ${UP_TIMEOUT_MS}ms` : `exit ${result.status}`; | ||
|
|
||
| assertServicesHaveHealthchecks(cwd, composeArgs('config', '--format', 'json')); |
There was a problem hiding this comment.
is this slow? can we make it faster?
There was a problem hiding this comment.
Not really. docker compose config only resolves the compose file and doesn't talk to the daemon. It took 200–310 ms per suite locally (about 250 ms median, 5.3 s across all 21). It runs once per describeWithDockerCompose group in beforeAll, not once per test, and the existing down + pull + up --wait in that same hook takes seconds to minutes.
The only faster in-process option is parsing the YAML ourselves, and this package has no YAML parser, so that means adding a dependency. Another option is a one-off CI script that checks every compose file up front instead of the runner, but then a local run of a new suite wouldn't catch a missing healthcheck. I'd keep it as is, unless you'd rather go the CI script route.
## What The check from #26854, that every docker-compose service has a healthcheck, now runs as one static test (`suites/docker-compose.test.ts`). The test parses the compose files with `yaml` instead of running `docker compose config` before every Docker suite. `yaml` is a new devDependency of node-integration-tests. It was already in the lockfile as a transitive dependency. ## Why The per-suite `docker compose config` spawn could hit its 10s timeout on a slow runner. When it did, it failed the suite with an empty error ([job](https://github.com/getsentry/sentry-javascript/actions/runs/45631694816/job/139267746094)). Linting a YAML file doesn't need Docker. A static test also runs once instead of once per suite, and it names the file that's wrong. Part of #26852 <!-- junior-request-attribution:start --> via @mydea. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3Ad72f31cba93f4e84e882d2b860cda943 --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3Ad72f31cba93f4e84e882d2b860cda943) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3Ad72f31cba93f4e84e882d2b860cda943/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: Francesco Gringl-Novy <2411343+mydea@users.noreply.github.com>
What
node:*,fs,path, ...) insrcofcore,browser,browser-utilsand the other browser- or edge-only packages (angular,ember,feedback,gatsby,integration-shims,react,replay-*,solid,svelte,vercel-edge,vue,wasm).no-eval,no-new-funcand a newsdk/no-unsafe-html-writesrule are errors in every package'ssrc. The new rule flags assigninginnerHTML/outerHTML,insertAdjacentHTML()anddocument.write()/writeln().docker-compose.ymlservice has no healthcheck, or has it turned off (disable: trueortest: ['NONE']).process.version(s)or callctx.skip/context.skip. They gate withsupports()instead..cursor/BUGBOT.mddrops the rules these now enforce (eval/Function()/innerHTML, Compose healthchecks), plus the stalegenerateInstrumentationOnceandgetFirstEnvelope*rules.Why
These checks are mechanical, so lint and the runner enforce them reliably and Bugbot doesn't spend review time on them. Current code already follows them.
builtinModules, because a gitignore-stylegroupalso matches relative imports like./constants. Type imports are banned too: a Node type in a shipped.d.tsbreaks consumers without@types/node. Meta-frameworks andeffectmix client and server code insrc, so they aren't covered.innerHTMLneeds a custom rule becauseno-restricted-propertiesalso flags reads, such as incontextlines.ts.no-implied-evalis not added: the type-awaretypescript/no-implied-evalalready runs.no-restricted-syntax, so the suite rule usesno-restricted-properties. It can't seeprocess.env.RUNTIME, a destructuredskip, orskipIf/runIfconditions, so that Bugbot rule stays. The Node-imports Bugbot rule stays too, because it also coverscloudflare,deno,bunandrequire().Left for follow-ups:
typescript/no-non-null-assertioninsrc. There are many more existing assertions than expected, mostly indexed access undernoUncheckedIndexedAccess, so it needs its own cleanup PR.sdk/*rules, the test harness checks and the CI scripts.Part of #26852
via @mydea.
--
View Session [Sentry]