Skip to content

test: prefer assert.match for string matching#8540

Merged
BridgeAR merged 2 commits into
masterfrom
watson/eslint-rule-prefer-match
May 19, 2026
Merged

test: prefer assert.match for string matching#8540
BridgeAR merged 2 commits into
masterfrom
watson/eslint-rule-prefer-match

Conversation

@watson

@watson watson commented May 19, 2026

Copy link
Copy Markdown
Collaborator

What does this PR do?

Adds a new custom ESLint rule, eslint-prefer-assert-match, that runs on test files and flags assert.ok(...) calls whose first argument is a plain string-matching expression — String.prototype.startsWith, String.prototype.endsWith, String.prototype.match, or RegExp.prototype.test (with optional ! negation). The rule auto-fixes the cases it can do safely (regex literals, and string literals whose regex metacharacters can be escaped into a regex literal) and reports the rest without a fix. The auto-fix has also been applied across the existing test suite.

Motivation

assert.match(string, regexp) produces much more informative failure messages than assert.ok(string.startsWith('foo')) — the latter fails with just Expected value to be truthy: false, while assert.match includes both the actual string and the regex it was tested against. Until now we relied on convention; this rule mechanically enforces it on new test code and converts the existing call sites in one pass.

Additional Notes

  • .includes() is deliberately not handled. Across this codebase it is used about equally on strings (comment.includes("ddsh='...'")) and arrays (tags.includes('foo'), _traceBuffer.includes(...)), and without runtime type information we'd produce a lot of false positives. Easy to extend later if we want it.
  • Two call sites are intentionally left on assert.ok (with an inline // eslint-disable-next-line eslint-rules/eslint-prefer-assert-match comment that explains why): packages/datadog-webpack/test/plugin.spec.js and integration-tests/code-origin.spec.js. In both cases the search string is a runtime value (source, cwd) that can legitimately contain regex metacharacters, and safe escaping requires RegExp.escape, which is only available on Node.js 24+. The comments point at the rewrite we'll be able to do once our minimum supported Node version is 24.

Add a new ESLint rule `eslint-prefer-assert-match` that runs on
test files and flags `assert.ok(...)` calls whose first argument
is a plain string-matching expression: `startsWith`, `endsWith`,
`String.prototype.match`, or `RegExp.prototype.test` (optionally
prefixed with `!`). `assert.match()` / `assert.doesNotMatch()`
produces much more informative failure messages than
`assert.ok(false)`.

The rule auto-fixes safe cases (regex literals, and string
literals whose metacharacters can be escaped into a regex
literal) and reports the rest without a fix. `.includes()` is
intentionally not handled because it is ambiguous between
String and Array.

Apply the auto-fixes across the test suite. Two call sites in
`packages/datadog-webpack/test/plugin.spec.js` and
`integration-tests/code-origin.spec.js` are intentionally kept
on `assert.ok` (with an inline `eslint-disable` comment) because
their search string is a runtime value (`source`, `cwd`) and
safe escaping requires `RegExp.escape`, which is only available
on Node.js 24+. They can be converted once the minimum supported
Node.js version is 24.

watson commented May 19, 2026

Copy link
Copy Markdown
Collaborator Author

@watson watson self-assigned this May 19, 2026
@dd-octo-sts

dd-octo-sts Bot commented May 19, 2026

Copy link
Copy Markdown
Contributor

Overall package size

Self size: 5.88 MB
Deduped: 6.72 MB
No deduping: 6.72 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.0.1 | 82.56 kB | 817.39 kB | | dc-polyfill | 0.1.11 | 25.74 kB | 25.74 kB |

🤖 This report was automatically generated by heaviest-objects-in-the-universe

@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented May 19, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 86.44% (+0.00%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: f3feb11 | Docs | Datadog PR Page | Give us feedback!

@codecov

codecov Bot commented May 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.72%. Comparing base (7302ef8) to head (f3feb11).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #8540   +/-   ##
=======================================
  Coverage   89.72%   89.72%           
=======================================
  Files         844      844           
  Lines       45707    45707           
  Branches     8526     8526           
=======================================
+ Hits        41010    41012    +2     
+ Misses       4697     4695    -2     
Flag Coverage Δ
aiguard-integration-active 41.25% <ø> (ø)
aiguard-integration-latest 41.20% <ø> (ø)
aiguard-integration-maintenance 41.25% <ø> (ø)
aiguard-macos 34.99% <ø> (-0.09%) ⬇️
aiguard-ubuntu 35.09% <ø> (-0.09%) ⬇️
aiguard-windows 34.85% <ø> (-0.09%) ⬇️
apm-capabilities-tracing-macos 49.23% <ø> (+0.17%) ⬆️
apm-capabilities-tracing-ubuntu-active 49.07% <ø> (-0.18%) ⬇️
apm-capabilities-tracing-ubuntu-latest 49.04% <ø> (ø)
apm-capabilities-tracing-ubuntu-maintenance 49.25% <ø> (+0.17%) ⬆️
apm-capabilities-tracing-ubuntu-oldest 49.06% <ø> (-0.18%) ⬇️
apm-capabilities-tracing-windows 49.04% <ø> (ø)
apm-integrations-aerospike-18-gte.5.2.0 34.43% <ø> (-0.09%) ⬇️
apm-integrations-aerospike-20-gte.5.5.0 34.45% <ø> (-0.09%) ⬇️
apm-integrations-aerospike-22-gte.5.12.1 34.45% <ø> (-0.09%) ⬇️
apm-integrations-aerospike-22-gte.6.0.0 34.45% <ø> (-0.09%) ⬇️
apm-integrations-aerospike-eol- 34.36% <ø> (-0.09%) ⬇️
apm-integrations-child-process 35.50% <ø> (-0.09%) ⬇️
apm-integrations-confluentinc-kafka-javascript-18 41.31% <ø> (-0.09%) ⬇️
apm-integrations-confluentinc-kafka-javascript-20 41.33% <ø> (-0.09%) ⬇️
apm-integrations-confluentinc-kafka-javascript-22 41.33% <ø> (-0.09%) ⬇️
apm-integrations-confluentinc-kafka-javascript-24 41.26% <ø> (-0.09%) ⬇️
apm-integrations-couchbase-18 34.47% <ø> (?)
apm-integrations-couchbase-eol 34.50% <ø> (-0.09%) ⬇️
apm-integrations-dns 34.28% <ø> (-0.09%) ⬇️
apm-integrations-elasticsearch 35.24% <ø> (-0.08%) ⬇️
apm-integrations-http-latest 42.18% <ø> (-0.08%) ⬇️
apm-integrations-http-maintenance 42.24% <ø> (-0.08%) ⬇️
apm-integrations-http-oldest 42.24% <ø> (-0.08%) ⬇️
apm-integrations-http2 39.49% <ø> (-0.09%) ⬇️
apm-integrations-kafkajs-latest 41.07% <ø> (-0.04%) ⬇️
apm-integrations-kafkajs-oldest 41.18% <ø> (-0.09%) ⬇️
apm-integrations-net 35.17% <ø> (-0.09%) ⬇️
apm-integrations-next-11.1.4 29.13% <ø> (-0.08%) ⬇️
apm-integrations-next-12.3.7 30.81% <ø> (-0.11%) ⬇️
apm-integrations-next-13.0.0 30.83% <ø> (-0.06%) ⬇️
apm-integrations-next-13.2.0 30.80% <ø> (-0.08%) ⬇️
apm-integrations-next-13.5.11 30.93% <ø> (-0.08%) ⬇️
apm-integrations-next-14.0.0 30.89% <ø> (-0.06%) ⬇️
apm-integrations-next-14.2.35 30.87% <ø> (-0.08%) ⬇️
apm-integrations-next-14.2.6 30.87% <ø> (-0.08%) ⬇️
apm-integrations-next-14.2.7 30.87% <ø> (-0.08%) ⬇️
apm-integrations-next-15.0.0 30.87% <ø> (-0.08%) ⬇️
apm-integrations-next-15.4.0 30.93% <ø> (-0.08%) ⬇️
apm-integrations-oracledb 34.78% <ø> (-0.08%) ⬇️
apm-integrations-prisma-18-gte.6.16.0.and.lt.7.0.0 36.74% <ø> (-0.08%) ⬇️
apm-integrations-prisma-latest-all 35.56% <ø> (-0.08%) ⬇️
apm-integrations-restify 36.53% <ø> (-0.08%) ⬇️
apm-integrations-sharedb 34.00% <ø> (-0.09%) ⬇️
apm-integrations-tedious 34.58% <ø> (-0.08%) ⬇️
appsec-express 52.14% <ø> (-0.07%) ⬇️
appsec-fastify 48.87% <ø> (-0.07%) ⬇️
appsec-graphql 48.94% <ø> (-0.07%) ⬇️
appsec-integration-active 37.04% <ø> (ø)
appsec-integration-latest 37.01% <ø> (ø)
appsec-integration-maintenance 37.05% <ø> (ø)
appsec-integration-oldest 37.04% <ø> (ø)
appsec-kafka 41.60% <ø> (-0.08%) ⬇️
appsec-ldapjs 40.86% <ø> (-0.07%) ⬇️
appsec-lodash 40.93% <ø> (-0.07%) ⬇️
appsec-macos 58.14% <ø> (-0.07%) ⬇️
appsec-mongodb-core 45.41% <ø> (-0.07%) ⬇️
appsec-mongoose 46.31% <ø> (-0.06%) ⬇️
appsec-mysql 48.20% <ø> (-0.10%) ⬇️
appsec-next-latest-11.1.4 29.26% <ø> (-0.08%) ⬇️
appsec-next-latest-12.3.7 30.94% <ø> (-0.08%) ⬇️
appsec-next-latest-13.0.0 30.94% <ø> (-0.08%) ⬇️
appsec-next-latest-13.2.0 30.95% <ø> (-0.08%) ⬇️
appsec-next-latest-13.5.11 31.03% <ø> (-0.08%) ⬇️
appsec-next-latest-14.0.0 30.97% <ø> (-0.08%) ⬇️
appsec-next-latest-14.2.35 30.97% <ø> (-0.08%) ⬇️
appsec-next-latest-14.2.6 30.97% <ø> (-0.08%) ⬇️
appsec-next-latest-14.2.7 30.97% <ø> (-0.08%) ⬇️
appsec-next-latest-15.0.0 30.97% <ø> (-0.08%) ⬇️
appsec-next-latest-latest 30.98% <ø> (-0.08%) ⬇️
appsec-next-oldest-11.1.4 29.28% <ø> (-0.08%) ⬇️
appsec-next-oldest-12.3.7 30.95% <ø> (-0.08%) ⬇️
appsec-next-oldest-13.0.0 30.95% <ø> (-0.08%) ⬇️
appsec-next-oldest-13.2.0 31.22% <ø> (-0.09%) ⬇️
appsec-next-oldest-13.5.11 31.32% <ø> (-0.08%) ⬇️
appsec-next-oldest-14.0.0 31.26% <ø> (-0.08%) ⬇️
appsec-next-oldest-14.2.35 31.26% <ø> (-0.08%) ⬇️
appsec-next-oldest-14.2.6 31.26% <ø> (-0.08%) ⬇️
appsec-next-oldest-14.2.7 31.26% <ø> (-0.08%) ⬇️
appsec-next-oldest-15.0.0 31.26% <ø> (-0.08%) ⬇️
appsec-next-oldest-latest 30.03% <ø> (ø)
appsec-node-serialize 40.15% <ø> (-0.07%) ⬇️
appsec-passport 43.98% <ø> (-0.08%) ⬇️
appsec-postgres 47.87% <ø> (-0.07%) ⬇️
appsec-sourcing 39.55% <ø> (-0.07%) ⬇️
appsec-stripe 41.78% <ø> (-0.07%) ⬇️
appsec-template 40.41% <ø> (-0.07%) ⬇️
appsec-ubuntu 58.22% <ø> (-0.07%) ⬇️
appsec-windows 58.02% <ø> (-0.17%) ⬇️
debugger-ubuntu-active 43.30% <ø> (ø)
debugger-ubuntu-latest 43.25% <ø> (ø)
debugger-ubuntu-maintenance 43.31% <ø> (ø)
debugger-ubuntu-oldest 43.75% <ø> (ø)
instrumentations-instrumentation-bluebird 29.36% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-body-parser 37.11% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-child_process 34.90% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-cookie-parser 31.27% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-express 31.48% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-express-mongo-sanitize 31.39% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-express-session 36.81% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-fs 29.05% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-generic-pool 28.68% <ø> (ø)
instrumentations-instrumentation-http 36.31% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-knex 29.34% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-light-my-request 36.69% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-mongoose 30.64% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-multer 36.78% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-mysql2 34.90% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-passport 40.55% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-passport-http 40.22% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-passport-local 40.70% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-pg 34.45% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-promise 29.30% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-promise-js 29.31% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-q 29.34% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-url 29.26% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-when 29.32% <ø> (-0.09%) ⬇️
instrumentations-integration-esbuild-0.16.12-active 19.23% <ø> (ø)
instrumentations-integration-esbuild-0.16.12-latest 19.21% <ø> (ø)
instrumentations-integration-esbuild-0.16.12-maintenance 19.23% <ø> (ø)
instrumentations-integration-esbuild-0.16.12-oldest 19.22% <ø> (ø)
instrumentations-integration-esbuild-latest-active 19.23% <ø> (ø)
instrumentations-integration-esbuild-latest-latest 19.21% <ø> (ø)
instrumentations-integration-esbuild-latest-maintenance 19.23% <ø> (ø)
instrumentations-integration-esbuild-latest-oldest 19.22% <ø> (ø)
llmobs-ai 37.83% <ø> (-0.08%) ⬇️
llmobs-anthropic 37.92% <ø> (-0.08%) ⬇️
llmobs-bedrock 36.56% <ø> (-0.08%) ⬇️
llmobs-google-genai 36.97% <ø> (-0.08%) ⬇️
llmobs-langchain 38.24% <ø> (-0.07%) ⬇️
llmobs-openai-latest 40.49% <ø> (-0.08%) ⬇️
llmobs-openai-oldest 40.53% <ø> (-0.08%) ⬇️
llmobs-sdk-active 45.01% <ø> (-0.09%) ⬇️
llmobs-sdk-latest 44.95% <ø> (-0.09%) ⬇️
llmobs-sdk-maintenance 45.01% <ø> (-0.09%) ⬇️
llmobs-sdk-oldest 45.00% <ø> (-0.09%) ⬇️
llmobs-vertex-ai 37.10% <ø> (-0.08%) ⬇️
master-coverage 89.72% <ø> (?)
openfeature-macos 38.07% <ø> (ø)
openfeature-ubuntu 38.15% <ø> (ø)
openfeature-unit-active 49.27% <ø> (ø)
openfeature-unit-latest 49.11% <ø> (ø)
openfeature-unit-maintenance 49.27% <ø> (ø)
openfeature-unit-oldest 49.27% <ø> (ø)
openfeature-windows 37.94% <ø> (+0.05%) ⬆️
platform-core 36.45% <ø> (ø)
platform-esbuild 39.82% <ø> (ø)
platform-instrumentations-misc 31.44% <ø> (ø)
platform-integration-active 47.09% <ø> (-0.02%) ⬇️
platform-integration-latest 47.05% <ø> (ø)
platform-integration-maintenance 47.10% <ø> (ø)
platform-integration-oldest 47.27% <ø> (ø)
platform-shimmer 42.26% <ø> (ø)
platform-unit-guardrails 35.42% <ø> (ø)
platform-webpack 20.36% <ø> (ø)
plugins-azure-durable-functions 37.08% <ø> (ø)
plugins-azure-event-hubs 34.90% <ø> (ø)
plugins-azure-service-bus 35.40% <ø> (ø)
plugins-bullmq 40.16% <ø> (-0.09%) ⬇️
plugins-cassandra 34.83% <ø> (-0.08%) ⬇️
plugins-cookie 27.41% <ø> (ø)
plugins-cookie-parser 27.14% <ø> (ø)
plugins-crypto 27.27% <ø> (ø)
plugins-dd-trace-api 34.72% <ø> (-0.09%) ⬇️
plugins-express-mongo-sanitize 27.32% <ø> (ø)
plugins-express-session 27.09% <ø> (ø)
plugins-fastify 38.85% <ø> (-0.08%) ⬇️
plugins-fetch 35.18% <ø> (-0.08%) ⬇️
plugins-fs 35.15% <ø> (-0.09%) ⬇️
plugins-generic-pool 25.94% <ø> (ø)
plugins-google-cloud-pubsub 42.38% <ø> (-0.08%) ⬇️
plugins-grpc 37.64% <ø> (-0.08%) ⬇️
plugins-handlebars 27.38% <ø> (ø)
plugins-hapi 36.76% <ø> (-0.08%) ⬇️
plugins-hono 37.05% <ø> (-0.08%) ⬇️
plugins-ioredis 35.30% <ø> (-0.09%) ⬇️
plugins-knex 26.90% <ø> (ø)
plugins-langgraph 34.56% <ø> (-0.09%) ⬇️
plugins-ldapjs 24.07% <ø> (ø)
plugins-light-my-request 26.57% <ø> (ø)
plugins-limitd-client 29.60% <ø> (-0.15%) ⬇️
plugins-lodash 26.05% <ø> (ø)
plugins-mariadb 36.26% <ø> (-0.09%) ⬇️
plugins-memcached 34.88% <ø> (-0.09%) ⬇️
plugins-microgateway-core 35.88% <ø> (-0.09%) ⬇️
plugins-modelcontextprotocol-sdk 33.76% <ø> (-0.09%) ⬇️
plugins-moleculer 37.66% <ø> (-0.08%) ⬇️
plugins-mongodb 36.19% <ø> (-0.19%) ⬇️
plugins-mongodb-core 35.92% <ø> (-0.09%) ⬇️
plugins-mongoose 35.72% <ø> (-0.08%) ⬇️
plugins-multer 27.09% <ø> (ø)
plugins-mysql 35.75% <ø> (-0.09%) ⬇️
plugins-mysql2 35.91% <ø> (-0.09%) ⬇️
plugins-node-serialize 27.47% <ø> (ø)
plugins-opensearch 34.72% <ø> (-0.08%) ⬇️
plugins-passport-http 27.14% <ø> (ø)
plugins-pino 31.35% <ø> (-0.09%) ⬇️
plugins-postgres 35.58% <ø> (-0.09%) ⬇️
plugins-process 27.27% <ø> (ø)
plugins-pug 27.41% <ø> (ø)
plugins-redis 35.28% <ø> (-0.09%) ⬇️
plugins-router 39.25% <ø> (-0.08%) ⬇️
plugins-sequelize 25.64% <ø> (ø)
plugins-test-and-upstream-amqp10 35.08% <ø> (+0.04%) ⬆️
plugins-test-and-upstream-amqplib 40.17% <ø> (-0.22%) ⬇️
plugins-test-and-upstream-apollo 36.17% <ø> (-0.08%) ⬇️
plugins-test-and-upstream-avsc 35.28% <ø> (-0.09%) ⬇️
plugins-test-and-upstream-bunyan 30.73% <ø> (-0.28%) ⬇️
plugins-test-and-upstream-connect 37.45% <ø> (-0.09%) ⬇️
plugins-test-and-upstream-graphql 37.12% <ø> (-0.09%) ⬇️
plugins-test-and-upstream-koa 37.03% <ø> (-0.08%) ⬇️
plugins-test-and-upstream-protobufjs 35.49% <ø> (-0.09%) ⬇️
plugins-test-and-upstream-rhea 40.26% <ø> (-0.09%) ⬇️
plugins-undici 35.70% <ø> (-0.08%) ⬇️
plugins-url 27.27% <ø> (ø)
plugins-valkey 34.79% <ø> (-0.23%) ⬇️
plugins-vm 27.27% <ø> (ø)
plugins-winston 31.25% <ø> (-0.09%) ⬇️
plugins-ws 38.26% <ø> (-0.08%) ⬇️
profiling-macos 42.82% <ø> (-0.02%) ⬇️
profiling-ubuntu 43.18% <ø> (-0.07%) ⬇️
profiling-windows 40.07% <ø> (-0.07%) ⬇️
serverless-aws-sdk-latest-aws-sdk 34.49% <ø> (-0.08%) ⬇️
serverless-aws-sdk-latest-bedrockruntime 33.10% <ø> (-0.08%) ⬇️
serverless-aws-sdk-latest-client 21.74% <ø> (ø)
serverless-aws-sdk-latest-dynamodb 35.47% <ø> (-0.08%) ⬇️
serverless-aws-sdk-latest-eventbridge 28.62% <ø> (-0.08%) ⬇️
serverless-aws-sdk-latest-kinesis 38.62% <ø> (-0.08%) ⬇️
serverless-aws-sdk-latest-lambda 36.05% <ø> (-0.08%) ⬇️
serverless-aws-sdk-latest-s3 34.00% <ø> (-0.08%) ⬇️
serverless-aws-sdk-latest-serverless-peer-service 40.67% <ø> (-0.09%) ⬇️
serverless-aws-sdk-latest-sns 39.73% <ø> (-0.08%) ⬇️
serverless-aws-sdk-latest-sqs 39.22% <ø> (-0.08%) ⬇️
serverless-aws-sdk-latest-stepfunctions 34.67% <ø> (-0.08%) ⬇️
serverless-aws-sdk-latest-util 48.38% <ø> (ø)
serverless-aws-sdk-oldest-aws-sdk 34.58% <ø> (-0.07%) ⬇️
serverless-aws-sdk-oldest-bedrockruntime 33.37% <ø> (-0.08%) ⬇️
serverless-aws-sdk-oldest-client 22.22% <ø> (ø)
serverless-aws-sdk-oldest-dynamodb 35.60% <ø> (-0.08%) ⬇️
serverless-aws-sdk-oldest-eventbridge 28.66% <ø> (-0.08%) ⬇️
serverless-aws-sdk-oldest-kinesis 38.75% <ø> (-0.08%) ⬇️
serverless-aws-sdk-oldest-lambda 36.13% <ø> (-0.08%) ⬇️
serverless-aws-sdk-oldest-s3 34.07% <ø> (-0.08%) ⬇️
serverless-aws-sdk-oldest-serverless-peer-service 40.72% <ø> (-0.09%) ⬇️
serverless-aws-sdk-oldest-sns 39.81% <ø> (-0.08%) ⬇️
serverless-aws-sdk-oldest-sqs 39.12% <ø> (-0.08%) ⬇️
serverless-aws-sdk-oldest-stepfunctions 34.74% <ø> (-0.08%) ⬇️
serverless-aws-sdk-oldest-util 48.68% <ø> (ø)
serverless-azure-functions-eventhubs 38.57% <ø> (ø)
serverless-azure-functions-servicebus 38.63% <ø> (ø)
serverless-lambda 36.10% <ø> (-0.10%) ⬇️
test-optimization-cucumber-latest-7.0.0 50.32% <ø> (+0.01%) ⬆️
test-optimization-cucumber-latest-latest 53.20% <ø> (+0.12%) ⬆️
test-optimization-cucumber-oldest-7.0.0 50.36% <ø> (+0.12%) ⬆️
test-optimization-cypress-latest-12.0.0-commonJS 48.80% <ø> (+0.07%) ⬆️
test-optimization-cypress-latest-12.0.0-esm 48.83% <ø> (+0.07%) ⬆️
test-optimization-cypress-latest-14.5.4-commonJS 48.65% <ø> (+0.07%) ⬆️
test-optimization-cypress-latest-14.5.4-esm 48.79% <ø> (+0.18%) ⬆️
test-optimization-cypress-latest-latest-commonJS 49.14% <ø> (+0.07%) ⬆️
test-optimization-cypress-latest-latest-esm 49.17% <ø> (+0.07%) ⬆️
test-optimization-cypress-oldest-12.0.0-commonJS 48.84% <ø> (+0.16%) ⬆️
test-optimization-cypress-oldest-12.0.0-esm 48.87% <ø> (+0.07%) ⬆️
test-optimization-cypress-oldest-14.5.4-commonJS 48.68% <ø> (+0.07%) ⬆️
test-optimization-cypress-oldest-14.5.4-esm 48.72% <ø> (+0.07%) ⬆️
test-optimization-jest-latest-latest 54.83% <ø> (+0.08%) ⬆️
test-optimization-jest-latest-oldest 53.65% <ø> (+0.08%) ⬆️
test-optimization-jest-oldest-latest 54.83% <ø> (+0.08%) ⬆️
test-optimization-jest-oldest-oldest 53.59% <ø> (+0.08%) ⬆️
test-optimization-mocha-latest-latest 53.63% <ø> (+0.08%) ⬆️
test-optimization-mocha-latest-oldest 51.29% <ø> (+0.08%) ⬆️
test-optimization-mocha-oldest-latest 53.70% <ø> (+0.08%) ⬆️
test-optimization-mocha-oldest-oldest 51.23% <ø> (+0.06%) ⬆️
test-optimization-playwright-latest-latest-playwright-active-test-span 44.35% <ø> (+0.28%) ⬆️
test-optimization-playwright-latest-latest-playwright-atr 43.13% <ø> (+0.11%) ⬆️
test-optimization-playwright-latest-latest-playwright-efd 43.55% <ø> (+0.09%) ⬆️
test-optimization-playwright-latest-latest-playwright-final-status 43.61% <ø> (+0.11%) ⬆️
test-optimization-playwright-latest-latest-playwright-impacted-tests 43.06% <ø> (ø)
test-optimization-playwright-latest-latest-playwright-reporting 43.02% <ø> (+0.09%) ⬆️
test-optimization-playwright-latest-latest-playwright-test-management 44.79% <ø> (+0.10%) ⬆️
test-optimization-playwright-latest-oldest-playwright-active-test-span 44.42% <ø> (?)
test-optimization-playwright-latest-oldest-playwright-atr 43.34% <ø> (+0.11%) ⬆️
test-optimization-playwright-latest-oldest-playwright-efd 43.85% <ø> (+0.33%) ⬆️
test-optimization-playwright-latest-oldest-playwright-final-status 43.67% <ø> (+0.11%) ⬆️
test-optimization-playwright-latest-oldest-playwright-impacted-tests 43.11% <ø> (ø)
test-optimization-playwright-latest-oldest-playwright-reporting 43.09% <ø> (+0.09%) ⬆️
test-optimization-playwright-latest-oldest-playwright-test-management 44.86% <ø> (+0.10%) ⬆️
test-optimization-playwright-oldest-latest-playwright-active-test-span 44.37% <ø> (+0.25%) ⬆️
test-optimization-playwright-oldest-latest-playwright-atr 43.17% <ø> (+0.11%) ⬆️
test-optimization-playwright-oldest-latest-playwright-efd 43.57% <ø> (+0.09%) ⬆️
test-optimization-playwright-oldest-latest-playwright-final-status 43.62% <ø> (+0.11%) ⬆️
test-optimization-playwright-oldest-latest-playwright-impacted-tests 43.10% <ø> (ø)
test-optimization-playwright-oldest-latest-playwright-reporting 43.03% <ø> (+0.09%) ⬆️
test-optimization-playwright-oldest-latest-playwright-test-management 44.80% <ø> (+0.10%) ⬆️
test-optimization-playwright-oldest-oldest-playwright-active-test-span 44.46% <ø> (+0.28%) ⬆️
test-optimization-playwright-oldest-oldest-playwright-atr 43.38% <ø> (+0.11%) ⬆️
test-optimization-playwright-oldest-oldest-playwright-efd 43.62% <ø> (+0.09%) ⬆️
test-optimization-playwright-oldest-oldest-playwright-final-status 43.68% <ø> (+0.11%) ⬆️
test-optimization-playwright-oldest-oldest-playwright-impacted-tests 43.15% <ø> (ø)
test-optimization-playwright-oldest-oldest-playwright-reporting 43.10% <ø> (+0.09%) ⬆️
test-optimization-playwright-oldest-oldest-playwright-test-management 44.88% <ø> (+0.10%) ⬆️
test-optimization-selenium-latest 45.58% <ø> (+0.07%) ⬆️
test-optimization-selenium-oldest 45.15% <ø> (+0.08%) ⬆️
test-optimization-testopt-active 46.96% <ø> (+0.13%) ⬆️
test-optimization-testopt-latest 46.92% <ø> (+0.13%) ⬆️
test-optimization-testopt-maintenance 46.96% <ø> (+0.13%) ⬆️
test-optimization-testopt-oldest 47.84% <ø> (+0.14%) ⬆️
test-optimization-vitest-latest 51.22% <ø> (+0.10%) ⬆️
test-optimization-vitest-oldest 48.31% <ø> (+0.33%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@watson
watson marked this pull request as ready for review May 19, 2026 12:10
@watson
watson requested review from a team as code owners May 19, 2026 12:10
@watson
watson requested review from bojbrook and khanayan123 and removed request for a team May 19, 2026 12:10

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8415f93601

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread eslint-rules/eslint-prefer-assert-match.mjs
BridgeAR
BridgeAR previously approved these changes May 19, 2026
@pr-commenter

pr-commenter Bot commented May 19, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-05-19 12:30:51

Comparing candidate commit f3feb11 in PR branch watson/eslint-rule-prefer-match with baseline commit 7302ef8 in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 1501 metrics, 92 unstable metrics.

@BridgeAR
BridgeAR enabled auto-merge (squash) May 19, 2026 12:24
@BridgeAR
BridgeAR merged commit a01a6b8 into master May 19, 2026
921 checks passed
@BridgeAR
BridgeAR deleted the watson/eslint-rule-prefer-match branch May 19, 2026 12:34
dd-octo-sts Bot pushed a commit that referenced this pull request May 20, 2026
Add a new ESLint rule `eslint-prefer-assert-match` that runs on
test files and flags `assert.ok(...)` calls whose first argument
is a plain string-matching expression: `startsWith`, `endsWith`,
`String.prototype.match`, or `RegExp.prototype.test` (optionally
prefixed with `!`). `assert.match()` / `assert.doesNotMatch()`
produces much more informative failure messages than
`assert.ok(false)`.

The rule auto-fixes safe cases (regex literals, and string
literals whose metacharacters can be escaped into a regex
literal) and reports the rest without a fix. `.includes()` is
intentionally not handled because it is ambiguous between
String and Array.

Apply the auto-fixes across the test suite. Two call sites in
`packages/datadog-webpack/test/plugin.spec.js` and
`integration-tests/code-origin.spec.js` are intentionally kept
on `assert.ok` (with an inline `eslint-disable` comment) because
their search string is a runtime value (`source`, `cwd`) and
safe escaping requires `RegExp.escape`, which is only available
on Node.js 24+. They can be converted once the minimum supported
Node.js version is 24.
@dd-octo-sts dd-octo-sts Bot mentioned this pull request May 20, 2026
pabloerhard pushed a commit that referenced this pull request May 20, 2026
Add a new ESLint rule `eslint-prefer-assert-match` that runs on
test files and flags `assert.ok(...)` calls whose first argument
is a plain string-matching expression: `startsWith`, `endsWith`,
`String.prototype.match`, or `RegExp.prototype.test` (optionally
prefixed with `!`). `assert.match()` / `assert.doesNotMatch()`
produces much more informative failure messages than
`assert.ok(false)`.

The rule auto-fixes safe cases (regex literals, and string
literals whose metacharacters can be escaped into a regex
literal) and reports the rest without a fix. `.includes()` is
intentionally not handled because it is ambiguous between
String and Array.

Apply the auto-fixes across the test suite. Two call sites in
`packages/datadog-webpack/test/plugin.spec.js` and
`integration-tests/code-origin.spec.js` are intentionally kept
on `assert.ok` (with an inline `eslint-disable` comment) because
their search string is a runtime value (`source`, `cwd`) and
safe escaping requires `RegExp.escape`, which is only available
on Node.js 24+. They can be converted once the minimum supported
Node.js version is 24.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants