Skip to content

chore(eslint): enable rules globally and fix violations#7548

Merged
BridgeAR merged 2 commits into
masterfrom
watson/more-eslint
Feb 17, 2026
Merged

chore(eslint): enable rules globally and fix violations#7548
BridgeAR merged 2 commits into
masterfrom
watson/more-eslint

Conversation

@watson

@watson watson commented Feb 17, 2026

Copy link
Copy Markdown
Collaborator

What does this PR do?

Enables several ESLint rules in the global config so they apply to all files (not only src dirs), and fixes existing violations across the repo. The shared GLOBAL_RESTRICTED_REQUIRES list is extracted and reused so restricted-require config stays in one place.

Rules now applied globally:

  • eslint-rules/eslint-safe-typeof-object
  • no-implicit-coercion
  • no-useless-assignment
  • no-void
  • operator-assignment
  • prefer-exponentiation-operator
  • prefer-object-has-own
  • n/no-restricted-require (using GLOBAL_RESTRICTED_REQUIRES)

Those rules are removed from the dd-trace/src/all block to avoid duplication (except n/no-restricted-require which adds semver as a restricted require to src only).

Fix tests and app code for the new global rules:

  • Safe typeof checks
  • Remove useless assignments
  • Use ** and template literals
  • Use filter.includes() instead of ~indexOf
  • Fix typo in vertexai test (} if} else if)

Motivation

Unify lint rules across the codebase so test and non-src files follow the same style and safety rules.

The following rules now apply to all files (enabled in global config):

- `eslint-rules/eslint-safe-typeof-object`
- `no-implicit-coercion`
- `no-useless-assignment`
- `no-void`
- `operator-assignment`
- `prefer-exponentiation-operator`
- `prefer-object-has-own`
- `n/no-restricted-require` (using shared `GLOBAL_RESTRICTED_REQUIRES`)

Removed these from the `dd-trace/src/all` block to avoid duplication.

Fix tests and app code for the new global rules:

- Safe typeof checks
- Remove useless assignments
- Use `**` and template literals
- Use `filter.includes()` instead of `~indexOf`)
- Fix typo in vertexai test (`} if` → `} else if`).

watson commented Feb 17, 2026

Copy link
Copy Markdown
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@watson watson self-assigned this Feb 17, 2026
@github-actions

github-actions Bot commented Feb 17, 2026

Copy link
Copy Markdown
Contributor

Overall package size

Self size: 4.62 MB
Deduped: 5.46 MB
No deduping: 5.46 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 2.0.6 | 81.92 kB | 813.08 kB | | dc-polyfill | 0.1.10 | 26.73 kB | 26.73 kB |

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

@codecov

codecov Bot commented Feb 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.15%. Comparing base (46a9c8a) to head (5022f3f).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master    #7548       +/-   ##
===========================================
+ Coverage   59.58%   80.15%   +20.57%     
===========================================
  Files         425      730      +305     
  Lines       18259    31217    +12958     
===========================================
+ Hits        10880    25023    +14143     
+ Misses       7379     6194     -1185     
Flag Coverage Δ
aiguard-macos 39.00% <ø> (-0.11%) ⬇️
aiguard-ubuntu 39.12% <ø> (-0.11%) ⬇️
aiguard-windows 38.86% <ø> (-0.11%) ⬇️
apm-capabilities-tracing-macos 48.74% <ø> (?)
apm-capabilities-tracing-ubuntu 48.77% <ø> (?)
apm-capabilities-tracing-windows 48.47% <ø> (?)
apm-integrations-child-process 38.57% <ø> (-0.11%) ⬇️
apm-integrations-couchbase-18 37.33% <ø> (?)
apm-integrations-couchbase-eol 37.96% <ø> (?)
apm-integrations-oracledb 38.00% <ø> (?)
appsec-express 55.38% <ø> (?)
appsec-fastify 51.99% <ø> (?)
appsec-graphql 52.34% <ø> (?)
appsec-kafka 44.63% <ø> (?)
appsec-ldapjs 44.33% <ø> (-0.09%) ⬇️
appsec-lodash 44.01% <ø> (-0.08%) ⬇️
appsec-macos 58.43% <ø> (?)
appsec-mongodb-core 49.25% <ø> (?)
appsec-mongoose 49.94% <ø> (?)
appsec-mysql 51.33% <ø> (?)
appsec-node-serialize 43.52% <ø> (-0.09%) ⬇️
appsec-passport 48.09% <ø> (-0.09%) ⬇️
appsec-postgres 51.06% <ø> (?)
appsec-sourcing 42.87% <ø> (-0.09%) ⬇️
appsec-template 43.69% <ø> (-0.09%) ⬇️
appsec-ubuntu 58.51% <ø> (?)
appsec-windows 58.30% <ø> (?)
instrumentations-instrumentation-bluebird 32.27% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-body-parser 40.80% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-child_process 37.88% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-cookie-parser 34.49% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-express 34.83% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-express-mongo-sanitize 34.63% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-express-session 40.41% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-fs 31.87% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-generic-pool 30.19% <ø> (ø)
instrumentations-instrumentation-http 39.59% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-knex 32.27% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-mongoose 33.63% <ø> (?)
instrumentations-instrumentation-multer 40.54% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-mysql2 38.37% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-passport 44.40% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-passport-http 44.05% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-passport-local 44.61% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-pg 37.79% <ø> (?)
instrumentations-instrumentation-promise 32.20% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-promise-js 32.20% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-q 32.25% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-url 32.17% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-when 32.22% <ø> (-0.11%) ⬇️
llmobs-ai 41.41% <ø> (?)
llmobs-anthropic 40.60% <ø> (?)
llmobs-bedrock 39.49% <ø> (?)
llmobs-google-genai 40.10% <ø> (?)
llmobs-langchain 39.64% <ø> (?)
llmobs-openai 44.45% <ø> (?)
llmobs-vertex-ai 40.31% <ø> (-0.10%) ⬇️
platform-core 29.71% <ø> (ø)
platform-esbuild 32.89% <ø> (ø)
platform-instrumentations-misc 40.53% <ø> (ø)
platform-shimmer 36.14% <ø> (ø)
platform-unit-guardrails 31.27% <ø> (ø)
plugins-azure-event-hubs 24.02% <ø> (?)
plugins-azure-service-bus 23.42% <ø> (?)
plugins-bullmq 43.71% <ø> (?)
plugins-cassandra 38.04% <ø> (-0.10%) ⬇️
plugins-cookie 25.08% <ø> (ø)
plugins-cookie-parser 24.87% <ø> (ø)
plugins-crypto 24.72% <ø> (ø)
plugins-dd-trace-api 38.42% <ø> (-0.11%) ⬇️
plugins-express-mongo-sanitize 25.04% <ø> (ø)
plugins-express-session 24.83% <ø> (ø)
plugins-fastify 42.52% <ø> (?)
plugins-fetch 38.58% <ø> (-0.10%) ⬇️
plugins-fs 38.68% <ø> (?)
plugins-generic-pool 24.06% <ø> (ø)
plugins-google-cloud-pubsub 45.73% <ø> (?)
plugins-grpc 41.25% <ø> (?)
plugins-handlebars 25.08% <ø> (ø)
plugins-hapi 40.43% <ø> (?)
plugins-hono 40.70% <ø> (-0.10%) ⬇️
plugins-ioredis 38.48% <ø> (?)
plugins-knex 24.80% <ø> (ø)
plugins-ldapjs 22.61% <ø> (ø)
plugins-light-my-request 24.48% <ø> (ø)
plugins-limitd-client 32.57% <ø> (?)
plugins-lodash 24.13% <ø> (ø)
plugins-mariadb 39.63% <ø> (?)
plugins-memcached 38.21% <ø> (?)
plugins-microgateway-core 39.45% <ø> (-0.10%) ⬇️
plugins-moleculer 40.81% <ø> (?)
plugins-mongodb 39.46% <ø> (?)
plugins-mongodb-core 39.08% <ø> (?)
plugins-mongoose 39.13% <ø> (?)
plugins-multer 24.83% <ø> (ø)
plugins-mysql 39.23% <ø> (-0.11%) ⬇️
plugins-mysql2 39.33% <ø> (?)
plugins-node-serialize 25.12% <ø> (ø)
plugins-opensearch 37.87% <ø> (?)
plugins-passport-http 24.91% <ø> (ø)
plugins-postgres 35.73% <ø> (?)
plugins-process 24.72% <ø> (ø)
plugins-pug 25.08% <ø> (ø)
plugins-redis 38.96% <ø> (?)
plugins-router 43.30% <ø> (-0.10%) ⬇️
plugins-sequelize 23.66% <ø> (?)
plugins-test-and-upstream-amqp10 38.40% <ø> (?)
plugins-test-and-upstream-amqplib 43.89% <ø> (?)
plugins-test-and-upstream-apollo 39.28% <ø> (?)
plugins-test-and-upstream-avsc 38.82% <ø> (-0.11%) ⬇️
plugins-test-and-upstream-bunyan 33.88% <ø> (?)
plugins-test-and-upstream-connect 41.11% <ø> (?)
plugins-test-and-upstream-graphql 40.23% <ø> (?)
plugins-test-and-upstream-koa 40.68% <ø> (?)
plugins-test-and-upstream-protobufjs 39.05% <ø> (-0.11%) ⬇️
plugins-test-and-upstream-rhea 44.14% <ø> (?)
plugins-undici 39.37% <ø> (-0.10%) ⬇️
plugins-url 24.72% <ø> (ø)
plugins-valkey 38.13% <ø> (?)
plugins-vm 24.72% <ø> (ø)
plugins-winston 34.26% <ø> (-0.10%) ⬇️
plugins-ws 42.22% <ø> (-0.10%) ⬇️
profiling-macos 39.97% <ø> (?)
profiling-ubuntu 40.48% <ø> (?)
profiling-windows 41.34% <ø> (?)
serverless-azure-functions-client 23.75% <ø> (?)
serverless-azure-functions-eventhubs 23.75% <ø> (?)
serverless-azure-functions-servicebus 23.75% <ø> (?)

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.

@pr-commenter

pr-commenter Bot commented Feb 17, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-02-17 10:49:39

Comparing candidate commit 5022f3f in PR branch watson/more-eslint with baseline commit 46a9c8a in branch master.

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

@watson
watson marked this pull request as ready for review February 17, 2026 10:26
@watson
watson requested review from a team as code owners February 17, 2026 10:26
@watson
watson requested review from BridgeAR and removed request for a team February 17, 2026 10:26
Comment thread packages/datadog-plugin-google-cloud-pubsub/test/index.spec.js
vulnerabilitiesTrace.vulnerabilities.forEach(v => {
let count = vulnerabilitiesCount.get(v.type) || 0
vulnerabilitiesCount.set(v.type, ++count)
const count = (vulnerabilitiesCount.get(v.type) || 0) + 1

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.

Suggested change
const count = (vulnerabilitiesCount.get(v.type) || 0) + 1
const count = vulnerabilitiesCount.get(v.type) + 1 || 1

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

That's not identical. If vulnerabilitiesCount.get(v.type) is undefined we need the fallback to 0.

@simon-id simon-id Feb 17, 2026

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.

Before suggesting I of course double checked it:

> (undefined || 0) + 1
1
> undefined + 1 || 1
1

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

That's only because NaN is falsy. I don't think relying on that is such a good idea. Our TS checker would definitely not allow it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It is also more difficult to process in my opinion. We have to know that the OR is of higher precedence and that this works due to being coerced to NaN which is falsy.
The brackets are straight forward to understand.

BridgeAR
BridgeAR previously approved these changes Feb 17, 2026

@BridgeAR BridgeAR left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, just left two suggestions

Comment thread packages/dd-trace/test/appsec/iast/taint-tracking/plugin.spec.js Outdated
Comment thread packages/datadog-plugin-next/test/app/api/appDir/error/route.js Outdated
for (let i = 0; i < 5; i++) {
nowValue += 20
const event = { startTime: 0, duration: filter.nextSamplingInstant - 0 }
const event = { startTime: 0, duration: filter.nextSamplingInstant }

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.

would - 0 be a way to coalesce the value to a number ? sounds improbable that someone actually wrote - 0 without a reason no ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I had the same thought and looked over the code to see if nextSamplingInstant would ever not be a number. As far as I can see, nextSamplingInstant is ALWAYS a number.

@watson watson Feb 17, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

... and the tests pass, so 👍

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is in a test case, so if there is an issue with the test data, it would surface here. Neither before, nor after would it detect actual faulty user input that could theoretically cause issues.

Since the test passes, the simplification seems good.

@BridgeAR
BridgeAR merged commit 323fd0d into master Feb 17, 2026
839 of 840 checks passed
@BridgeAR
BridgeAR deleted the watson/more-eslint branch February 17, 2026 15:11
dd-octo-sts Bot pushed a commit that referenced this pull request Feb 17, 2026
* chore(eslint): enable rules globally and fix violations

The following rules now apply to all files (enabled in global config):

- `eslint-rules/eslint-safe-typeof-object`
- `no-implicit-coercion`
- `no-useless-assignment`
- `no-void`
- `operator-assignment`
- `prefer-exponentiation-operator`
- `prefer-object-has-own`
- `n/no-restricted-require` (using shared `GLOBAL_RESTRICTED_REQUIRES`)

Removed these from the `dd-trace/src/all` block to avoid duplication.

Fix tests and app code for the new global rules:

- Safe typeof checks
- Remove useless assignments
- Use `**` and template literals
- Use `filter.includes()` instead of `~indexOf`)
- Fix typo in vertexai test (`} if` → `} else if`).
@dd-octo-sts dd-octo-sts Bot mentioned this pull request Feb 17, 2026
juan-fernandez pushed a commit that referenced this pull request Feb 18, 2026
* chore(eslint): enable rules globally and fix violations

The following rules now apply to all files (enabled in global config):

- `eslint-rules/eslint-safe-typeof-object`
- `no-implicit-coercion`
- `no-useless-assignment`
- `no-void`
- `operator-assignment`
- `prefer-exponentiation-operator`
- `prefer-object-has-own`
- `n/no-restricted-require` (using shared `GLOBAL_RESTRICTED_REQUIRES`)

Removed these from the `dd-trace/src/all` block to avoid duplication.

Fix tests and app code for the new global rules:

- Safe typeof checks
- Remove useless assignments
- Use `**` and template literals
- Use `filter.includes()` instead of `~indexOf`)
- Fix typo in vertexai test (`} if` → `} else if`).
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.

3 participants