Skip to content

Conversation

@leagris
Copy link

@leagris leagris commented Dec 29, 2025

Normalizes json files matching:

  • src/**/mcmod.info
  • src/**/*.json
  • src/**/*.mcmeta

Processes only changed files from origin/master.

Normalizations:

  • Indent with 2 spaces
  • Preserves collapsed objects/arrays on same line when it does not exceed 100 chars
  • Uses unix newline LF
  • Ends file with a newline character

Sample diffs:

--- a/src/main/resources/assets/gtnhintergalactic/textures/items/drones/MiningDroneUMV.png.mcmeta
+++ b/src/main/resources/assets/gtnhintergalactic/textures/items/drones/MiningDroneUMV.png.mcmeta
@@ -1 +1 @@
-{"animation": {"frametime": 3}}
+{ "animation": { "frametime": 3 } }
--- a/src/main/resources/assets/gregtech/textures/blocks/iconsets/BLOCK_SIXPHASEDCOPPER.png.mcmeta
+++ b/src/main/resources/assets/gregtech/textures/blocks/iconsets/BLOCK_SIXPHASEDCOPPER.png.mcmeta
@@ -1 +1 @@
-{ "animation": { "frametime": 1, "frames": [ 0, 1, 0, 1, 0, { "index": 2, "time": 75 } ] } }
\ No newline at end of file
+{ "animation": { "frametime": 1, "frames": [0, 1, 0, 1, 0, { "index": 2, "time": 75 }] } }
--- a/src/main/resources/assets/gtnhintergalactic/textures/blocks/spaceElevator/cable/CableLightBlinking24.pn>
+++ b/src/main/resources/assets/gtnhintergalactic/textures/blocks/spaceElevator/cable/CableLightBlinking24.pn>
@@ -1,5 +1,4 @@
-
-        {
-        "animation": {
-        "frames": [
-        {
+{
+  "animation": {
+    "frames": [
+      {
@@ -8,2 +7,2 @@
-        },
-        {
+      },
+      {
@@ -12,2 +11,2 @@
-        },
-        {
+      },
+      {
@@ -16,5 +15,4 @@
-        }
-        ]
-        }
-        }
-
\ No newline at end of file
+      }
+    ]
+  }
+}

Normalizes json files matching:
- `src/**/mcmod.info`
- `src/**/*.json`
- `src/**/*.mcmeta`

Processes only changed files from `origin/master`.

Normalizations:
- Indent with 2 spaces
- Preserves collapsed objects/arrays on same line when it
  does not exceed 100 chars
- Uses unix newline LF
- Ends file with a newline character

Sample diffs:

```diff
--- a/src/main/resources/assets/gtnhintergalactic/textures/items/drones/MiningDroneUMV.png.mcmeta
+++ b/src/main/resources/assets/gtnhintergalactic/textures/items/drones/MiningDroneUMV.png.mcmeta
@@ -1 +1 @@
-{"animation": {"frametime": 3}}
+{ "animation": { "frametime": 3 } }
```

```diff
--- a/src/main/resources/assets/gregtech/textures/blocks/iconsets/BLOCK_SIXPHASEDCOPPER.png.mcmeta
+++ b/src/main/resources/assets/gregtech/textures/blocks/iconsets/BLOCK_SIXPHASEDCOPPER.png.mcmeta
@@ -1 +1 @@
-{ "animation": { "frametime": 1, "frames": [ 0, 1, 0, 1, 0, { "index": 2, "time": 75 } ] } }
\ No newline at end of file
+{ "animation": { "frametime": 1, "frames": [0, 1, 0, 1, 0, { "index": 2, "time": 75 }] } }
```

```diff
--- a/src/main/resources/assets/gtnhintergalactic/textures/blocks/spaceElevator/cable/CableLightBlinking24.pn>
+++ b/src/main/resources/assets/gtnhintergalactic/textures/blocks/spaceElevator/cable/CableLightBlinking24.pn>
@@ -1,5 +1,4 @@
-
-        {
-        "animation": {
-        "frames": [
-        {
+{
+  "animation": {
+    "frames": [
+      {
@@ -8,2 +7,2 @@
-        },
-        {
+      },
+      {
@@ -12,2 +11,2 @@
-        },
-        {
+      },
+      {
@@ -16,5 +15,4 @@
-        }
-        ]
-        }
-        }
-
\ No newline at end of file
+      }
+    ]
+  }
+}
```
@leagris leagris requested a review from a team December 29, 2025 16:55
@leagris
Copy link
Author

leagris commented Dec 29, 2025

Note for reviewers:

To test this config:

  • Checkout this PR feat(spotless): prettier json #308 on the ExampleMod1.7.10 project (with GitHub CLI):

    gh pr checkout 308
  • Modify or add some JSON files

    # Forces a genuine change to the file so it will be handled by spotless
    printf \\n >> src/main/resources/mcmod.info 
    
    # Create a pack.mcmeta file that will be formatted by spotless
    cat > src/main/pack.mcmeta <<'JSON'
    {"pack": {
    "pack_format": 1, "description": "ExampleMod Resource Pack"}
    }
    JSON
    # add it to index without tracking
    git add -N src/main/pack.mcmeta
  • Run Spotless for the json category:

    ./gradlew spotlessJsonApply -Pgtnh.settings.blowdryerTag=LOCAL

    Setting the property blowdryerTag=LOCAL tells Blowdryer to use the local gtnhShared directory for the spotless configuration files.

  • Then inspect the changes with:

    git diff
  • Optionally restore the repository with:

    git reset src && git restore src && git clean -f src

@leagris leagris merged commit d6d9298 into master Dec 30, 2025
1 check passed
@leagris leagris deleted the spotless-json branch December 30, 2025 18:09
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.

3 participants