huskygit-huskylint-staged

Husky/lint-staged pre-commit formatting issue


Running husky/lint-staged hook for pre-commit formatting (working fine). Having one strange bug where for some reason on one file it keeps formatting the file with a spacing of 1 tab instead of 2 spaces. (husky/lint-staged seems to rewrite/reformat the entire file with tab spacing but just this file)

No idea why it is doing this, anyone encountered a issue like this before? Any help on this greatly appreciated as I am pulling my hair out at this stage.

Kind regards, UI

"husky": {
   "hooks": {
        "pre-commit": "lint-staged"
    }
},
"lint-staged": {
    "src/**/*.{js,scss}": [
        "prettier --write",
        "git add"
    ]
},

Solution

  • Found solution to above issue. Updated Prettier to V2.0.5 and added .prettierrc file. Resolved all issues with Husky commits. (Removed git add command as automatic with lint-staged V10)

    "husky": {
       "hooks": {
            "pre-commit": "lint-staged"
        }
    },
    "lint-staged": {
        "src/**/*.{js,scss}": [
            "prettier --write"
        ]
    },