Skip to content

feat: read the format keyword as part of the type - #225

Merged
alexander-akait merged 1 commit into
mainfrom
claude/filter-errors-quadratic-sibling-dos-1tqe2l
Sep 8, 2026
Merged

feat: read the format keyword as part of the type#225
alexander-akait merged 1 commit into
mainfrom
claude/filter-errors-quadratic-sibling-dos-1tqe2l

Conversation

@alexander-akait

Copy link
Copy Markdown
Member

Salvages what is still useful from #59 and #68, both of which this supersedes.

What is left in those two

#59 (feat: format object properties with types, issue #42) — the feature it adds landed in #224, so nothing here comes from it. Worth recording why it is not just rebased: it names the property type from a bare schema.properties[x].type, which prints foo: string,number for a union and nothing at all for a property described by anyOf/$ref/const. #224 formats the type through formatInnerSchema and drops it when it is composite or when the shape stops fitting on a line. The two open questions in its thread stay open — breaking long objects over lines (also raised in #42 (comment)) and sorting properties alphabetically.

#68 (feat: humanize format, issue #66) — two separate things. The absolutePath-as-a-format half is breaking and vankop flagged it for discussion; #223 has since covered that reporting as a keyword, so it is dropped. The other half is not on main and is what this PR takes.

The change

A format was reported as a hint sitting next to the constraints of the string:

configuration.strictFormat should be a string (should match format "date", should be < "2016-02-06").

It names the string, so it now reads as part of the type:

configuration.strictFormat should be a date string (should be < "2016-02-06").

src/util/humanize.js turns the name into words, so date-time, snake_case, PascalCase and camelCase formats all read as words.

Two cases #68 did not cover, both of which the existing fixtures caught:

  • A format is any string, not only a name. The test schema has format: "[0-9]*", which humanizing renders as [0 9]* string. A format that is not a name is left as a hint.
  • A negated format has no type to be part of — should not match format "date" stays a hint.

The format name goes next to the word it names rather than in front of the whole type, so a format: "email" with minLength: 1 is a non-empty email string, not an email non-empty string.

Tests

test/humanize.test.js carries over vankop's word list from #68, plus the empty/one-character and date-time cases. test/hints.test.js gains the composition and negation cases; its existing [0-9]* case covers the not-a-name guard. Two snapshots move, both to the shorter message above.

npm test (503 tests, 338 snapshots), npm run lint and npm run build all pass.

Co-authored with @vankop, whose commit in #68 this is taken from.

🤖 Generated with Claude Code

https://claude.ai/code/session_013wqLmVHkAGBsWQgXknEQCK


Generated by Claude Code

A `format` was reported as a hint next to the constraints of the string:

    configuration.strictFormat should be a string (should match format "date", should be < "2016-02-06").

It names the string, so it now reads as part of the type:

    configuration.strictFormat should be a date string (should be < "2016-02-06").

The name is turned into words, so a `date-time`, a `snake_case` and a
`camelCase` format all read as words. A format is any string though, not only
a name - one that is not a name, such as the pattern `[0-9]*`, is still
reported as a hint, and so is a negated format, which no type can state.

Taken from #68, without the part of it moving `absolutePath` from a keyword
to a format, which is breaking and was left open for discussion there.

Co-Authored-By: Ivan Kopeykin <10380560+vankop@users.noreply.github.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013wqLmVHkAGBsWQgXknEQCK
@codecov

codecov Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.72%. Comparing base (4baf113) to head (e86c29f).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #225      +/-   ##
==========================================
+ Coverage   96.66%   96.72%   +0.06%     
==========================================
  Files           9       10       +1     
  Lines         989     1009      +20     
  Branches      408      414       +6     
==========================================
+ Hits          956      976      +20     
  Misses         31       31              
  Partials        2        2              
Flag Coverage Δ
integration 96.72% <100.00%> (+0.06%) ⬆️

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

☔ View full report in Codecov by Harness.
📢 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.

@alexander-akait
alexander-akait merged commit 0f99aa9 into main Sep 8, 2026
33 checks passed
@alexander-akait
alexander-akait deleted the claude/filter-errors-quadratic-sibling-dos-1tqe2l branch September 8, 2026 16:01
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