Skip to content

Empty objects get split by newline with --pretty-print, then fails without #19

@swantzter

Description

@swantzter

Reproduction: https://github.com/swantzter/jsonlint-repro

Hi, we're having an issue where there's inconsistent behaviours between --pretty-print and "just" linting when it comes to empty objects.

When pretty-print serialises an object it outputs {\n} whereas the lint want it to become just {}

Given the above reproduction and test.json:

{
  "obj1": {},
  "obj2": {
  }
}

running npm run lint:fix (jsonlint --in-place --pretty-print) changes the file and outputs the following

{
  "obj1": {
  },
  "obj2": {
  }
}

Running npm run lint (jsonlint) after that makes it complain:

test.json: 1 hunk differs
===================================================================
--- test.json.orig
+++ test.json
@@ -1,6 +1,4 @@
 {
-  "obj1": {
-  },
-  "obj2": {
-  }
+  "obj1": {},
+  "obj2": {}
 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions