feat(xml-diff): add XML diff tool - #1840
Open
bruno-b-martins wants to merge 4 commits into
Open
Conversation
Compare two pasted XML documents and highlight the differences, mirroring the JSON diff tool's UI and diff engine. XML is parsed with a native DOMParser-based normalizer (attributes as @name, text-only leaves as plain strings) instead of xml-js, and a reconciliation step coerces mismatched single/repeated element shapes into arrays before diffing so a repeated element compares cleanly instead of producing a garbled type-mismatch diff. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Fixes a SonarQube quality gate failure (32.3% duplication on new code, required <= 3%) caused by xml-diff.models.ts, xml-diff.types.ts and diff-viewer.models.tsx being near-verbatim copies of json-diff's own files. The diff algorithm and viewer are format-agnostic, so xml-diff now imports diff() and DiffRootViewer directly from json-diff instead of maintaining a parallel copy, mirroring the existing precedent of xml-to-json importing isValidXML from xml-formatter. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



#1839
Summary
DOMParser-based normalizer instead ofxml-js: attributes become@namekeys, text-only leaves collapse to plain strings, and repeated elements become arrays — avoidingxml-js's ambiguous "single element vs. array" compact format.xml-diff.reconcile.ts) that coerces mismatched single/repeated element shapes into arrays before diffing, so an element going from one occurrence to several diffs cleanly (e.g. "item added: B") instead of producing a garbled type-mismatch diff..gitignoreentry for.pnpm-store.Test plan
pnpm run typecheckpassespnpm lintpasses with no new errors/warningspnpm run test:unitpasses (all 36 test files, including new parser/reconciliation/model unit tests)pnpm run buildsucceedsGenerated with Claude 🤖