camacho/format-package

Formatting multiple package.json files in a mono repo fails

Closed this issue · 4 comments

Formatting multiple package.json files in a mono repo seems to fail for me and I'm not sure what the problem is. I'm using the setup below using husky and lint-staged in a precommit hook.

{
  "scripts": {
    "precommit": "lint-staged"
  },
  "lint-staged": {
    "**/package.json": [
      "format-package -w",
      "git add"
    ],
    "*.js": [
      "eslint --fix",
      "git add"
    ]
  }
}

This works fine for multiple Javascript files. Whenever there is an linter error, ESLint kicks in and fixes the problem or halts the commit.
However it doesn't work when there are multiple package.json files staged for commit. It will format one and ignore the rest.

@matijs could you share an example repo setup that i could test on to try and fix this issue?

@matijs as a follow up - i now have a working example and hope to have a fix pushed this week

this issue should be fixed in v4.3

@camacho So sorry for not getting back to you sooner and well done reproducing and getting it fixed. 👍

I hope to check out 4.3 shortly.