Skip to content

Feature request: output diff #111

Description

@maratori

The current json output for --mode lint is not human-readable. It would be great to be able to print a diff instead of json.

It can be a new --diff flag, or --format json/diff, or --mode diff.

For example, instead of

[
  {
    "path": "separator.in",
    "lines": {
      "start": 4,
      "end": 6
    },
    "message": "These lines are out of order.",
    "fixes": [
      {
        "replacements": [
          {
            "lines": {
              "start": 4,
              "end": 6
            },
            "new_content": "  \"Bar\",\n  \"Baz\",\n  \"Foo\"\n"
          }
        ]
      }
    ]
  },
  {
    "path": "separator.in",
    "lines": {
      "start": 12,
      "end": 16
    },
    "message": "These lines are out of order.",
    "fixes": [
      {
        "replacements": [
          {
            "lines": {
              "start": 12,
              "end": 16
            },
            "new_content": "// Sticky comment\n\"Bar\",\n\"Baz\",\n\"Foo\"\n// Trailing comments\n"
          }
        ]
      }
    ]
  }
]

I'd like to see

--- goldens/separator.in
+++ goldens/separator.in
@@ -1,17 +1,17 @@
 Comma separator:
 static class Foo {
   // keep-sorted-test start
-  "Foo",
+  "Bar",
-  "Bar",
+  "Baz",
-  "Baz"
+  "Foo"
   // keep-sorted-test end
 }
 
 Comma separator with comments:
-// keep-sorted-test start sticky_comments=yes
-"Foo",
+// keep-sorted-test start sticky_comments=yes
 // Sticky comment
 "Bar",
-"Baz"
+"Baz",
+"Foo"
 // Trailing comments
 // keep-sorted-test end

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions