Skip to content

chore: adopt oxfmt for code formatting - #476

Merged
sjvans merged 2 commits into
developfrom
chore/oxfmt
Aug 10, 2026
Merged

chore: adopt oxfmt for code formatting#476
sjvans merged 2 commits into
developfrom
chore/oxfmt

Conversation

@sjvans

@sjvans sjvans commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Supersedes the #438 oxfmt spike — adopts oxfmt (0.63.0, pinned) properly.

Config (.oxfmtrc.jsonc)

Based on the #438 spike, verified against the lib/*.js house style: singleQuote, semi: false, printWidth: 120, tabWidth: 2, trailingComma: none, arrowParens: avoid. ignorePatterns excludes *.md, node_modules, package-lock.json, CHANGELOG.md, and jest.config.js (see coordination).

Scripts

  • formatnpx oxfmt (write is oxfmt's default)
  • format:checknpx oxfmt --check

No git hook / husky / lint-staged — CI format:check + scripts only (the intrusive hook from the #438 spike is intentionally not carried over).

Commits (reviewable split)

  1. chore: add oxfmt formatter tooling — config + scripts + devDep + lockfile + CI step
  2. chore: apply oxfmt formatting — repo-wide reformat (11 files, line-wrapping only; verified non-semantic via git diff -w)

eslint coexistence

@sap/cds/eslint.config.mjs is recommended + no-unused-vars/no-console only (no stylistic rules) → no conflict. npm run lint stays green.

CI

One line added to the lint job in ci.yml: npm run format:check.

Verified

npm run format:check ✅ (56 files) · npm run lint (--max-warnings=0) ✅ · npm run test → 53 pass / 14 skip, exit 0 · lockfile resolved from public npm (0 internal-registry URLs).

Coordination

Parallel PR #474 (jest→vitest) deletes jest.config.js — this PR excludes it from formatting (0-line diff confirmed) so no collision. package.json change here is additive (scripts + devDep); lockfile will conflict with #474 — whichever merges second rebases.

@sjvans sjvans mentioned this pull request Aug 10, 2026
@hyperspace-pr-bot

Copy link
Copy Markdown
Contributor

Summary

The following content is AI-generated and provides a summary of the pull request:


Adopt oxfmt for Code Formatting

Chore

🔧 Introduces oxfmt (0.63.0, pinned) as the project's code formatter, replacing ad-hoc formatting. A repository-wide reformat is applied — all changes are whitespace/line-wrapping only and verified non-semantic.

Changes

  • .oxfmtrc.jsonc: New formatter configuration file. Sets house style: singleQuote, semi: false, printWidth: 120, tabWidth: 2, trailingComma: none, arrowParens: avoid. Excludes *.md, node_modules, package-lock.json, CHANGELOG.md, and jest.config.js.
  • package.json: Added format (npx oxfmt) and format:check (npx oxfmt --check) scripts; added oxfmt: "0.63.0" as a pinned devDependency.
  • .github/workflows/ci.yml: Added npm run format:check step to the lint CI job.
  • package-lock.json: Updated with oxfmt and its platform-specific native bindings.
  • lib/exporter/ConsoleMetricExporter.js, lib/logging/index.js, lib/metrics/index.js, lib/tracing/index.js, lib/tracing/cloud_sdk.js: Long lines reformatted by oxfmt (line-wrapping only, no logic changes).
  • test/bookshop/srv/admin-service.js, test/console-span-exporter.test.js, test/tracing-attributes.test.js, test/tracing-outboxed-batch.test.js, test/tracing-remote-native.test.js: Test files reformatted (line-wrapping only, no logic changes).

Note: No git hooks (husky/lint-staged) are introduced — formatting is enforced via CI only. jest.config.js is excluded from formatting to avoid collision with the parallel PR #474 (jest→vitest migration), which deletes that file.


  • 🔄 Regenerate and Update Summary
  • ✏️ Insert as PR Description (deletes this comment)
  • 🗑️ Delete comment
PR Bot Information

Version: 1.29.18

@hyperspace-pr-bot hyperspace-pr-bot Bot left a comment

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.

The CI lint job has no setup-node step, but oxfmt requires Node ^20.19.0 || >=22.12.0 (as declared in the lockfile). Without an explicit setup, the runner uses whatever Node version ships with ubuntu-latest, which may not satisfy that constraint and would cause format:check to fail with an engine incompatibility error. Consider adding an actions/setup-node step to the lint job pinning a compatible version (e.g. 22.x), matching the pattern already used in the test job. The $schema reference to ./node_modules/oxfmt/configuration_schema.json is the only other noteworthy point — it won't resolve in editors before npm install — but since the $schema is purely advisory for IDE validation and doesn't affect CI, it's a minor inconvenience rather than a defect.

PR Bot Information

Version: 1.29.18

  • File Content Strategy: Full file content
  • Correlation ID: a5e7ba40-94b3-11f1-9980-719ea635abfd
  • LLM: anthropic--claude-4.6-sonnet
  • Event Trigger: pull_request.opened

Comment thread .oxfmtrc.jsonc
@@ -0,0 +1,21 @@
{
"$schema": "./node_modules/oxfmt/configuration_schema.json",

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.

Best Practices: The $schema path points to ./node_modules/oxfmt/configuration_schema.json, which only resolves after npm install. If the schema file is absent (e.g. fresh clone before install, or in editors that resolve schemas at open time before install), the schema reference silently fails to validate. A remote URL (e.g. from a CDN or the package's GitHub raw URL) would work universally. If the local path is intentional for offline use, this is acceptable but worth noting.


Please provide feedback on the review comment by checking the appropriate box:

  • 🌟 Awesome comment, a human might have missed that.
  • ✅ Helpful comment
  • 🤷 Neutral
  • ❌ This comment is not helpful

sjvans added 2 commits August 10, 2026 16:19
Add oxfmt (0.63.0) as the code formatter:
- .oxfmtrc.jsonc matching house style (single quotes, no semi, width 120,
  2-space, no trailing comma, arrowParens: avoid)
- format / format:check npm scripts (oxfmt --write / --check)
- oxfmt devDependency + lockfile
- format:check step in CI lint job

No git hook is added; scripts + CI check only. jest.config.js, CHANGELOG.md,
node_modules and package-lock.json are excluded via ignorePatterns.
Repo-wide reformat by oxfmt 0.63.0. Whitespace/line-reflow only; no logic
changes (verified via git diff -w).
@sjvans
sjvans merged commit 205e449 into develop Aug 10, 2026
8 checks passed
@sjvans
sjvans deleted the chore/oxfmt branch August 10, 2026 18:12
sjvans added a commit that referenced this pull request Aug 11, 2026
… ConsoleMetricExporter (#479)

## What

Consolidates all outbox/metrics test-quality work into one PR (formerly
split as #479 + the stacked #480).

- **In-memory metric reader** —
`test/bookshop/lib/MyInMemoryMetricReader.js`, the metrics counterpart
to `MyInMemorySpanExporter` (#465). Mirrors production **DELTA**
temporality: SUM counters are accumulated across flushes into per-series
running totals; GAUGE datapoints keep the latest absolute value. Wired
via the `metrics-outbox`, `metrics-outbox-disabled`, and `metrics`
profiles in `.cdsrc.json`.
- **Outbox suites off console spying** — the three
`metrics-outbox*.test.js` suites drop the `console.dir` spy and fixed
`wait()` sleeps in favor of the reader + an `expectEventually()`
force-flush polling helper (fails fast if the meter provider isn't
wired). Folds in #445's polling approach.
- **ConsoleMetricExporter unit test** — new
`test/console-metric-exporter.test.js`, a pure unit test of the
exporter's formatting (db.pool table, queue table, other
single-vs-array, tenant variants, host-metrics aggregation,
shutdown→FAILED), mirroring `console-span-exporter.test.js`.
- **`metrics.test.js`** converted from scraping `cds.test.log()` output
to asserting on the in-memory reader's datapoints.

Metrics testing now mirrors the tracing side exactly: a to-console unit
test **plus** in-memory-exporter–based integration tests.

## Why

Follow-up to #465 (span test infra): eliminate console/log spying in the
metrics suite and give `ConsoleMetricExporter` direct unit coverage.

## Review addressed

- Bot review triaged: explicit `COUNTER_METRIC_NAMES` dispatch for
`isCounter`; real wall-clock debounce in the multitenant test; isolation
NOTE on the module-level singletons.
- Dropped the unused debug-log silencer in the multitenant suite (never
asserted). Kept the single-tenant `debugLog` mock — it backs a real
`unknown service` assertion.

Test-only change (no `lib/` change), so no CHANGELOG entry — consistent
with #465/#474/#476.

closes #478

Supersedes #445 and #480 (both folded in here) — I'll close them once
this merges.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant