Skip to content

Treat equivalent JSX whitespace expressions as unchanged #1026

Description

@karlhorky

Somewhat related to #72

First of all, thanks for Difftastic! These foundational tools which reduce unnecessary work are invaluable, especially now with the high number of PRs created by AI agents.

The "before" and "after" JSX below both produce equivalent whitespace:

-{label} {required && <Asterisk />}
+{label}{' '}
+{required && <Asterisk />}

However, Difftastic currently shows them as changed:

$ cat > /tmp/difft-before.tsx <<'EOF'
{formField.label} {formField.required && <Asterisk />}
EOF

$ cat > /tmp/difft-after.tsx <<'EOF'
{formField.label}{' '}
{formField.required && <Asterisk />}
EOF

$ difft \
  --display inline \
  --color never \
  /tmp/difft-before.tsx \
  /tmp/difft-after.tsx
/tmp/difft-after.tsx --- TypeScript TSX
1    {formField.label} {formField.required && <Asterisk />}
   1 {formField.label}{' '}

It would be nice if the whitespace text node and the {' '} expression were treated as equivalent, so only meaningful JSX changes are shown.

Difftastic: 0.69.0

Keywords for search: React

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions