bgwebagency / who-wants-to-be-a-javascriptaire

JavaScript multiple choice questions with answers and video explanation to help you with Frontend/Web coding interviews
https://youtu.be/Uysa8_Aa5Sg
MIT License
27 stars 13 forks source link

Run prettier check on pre commit husky hook #35

Closed kirandash closed 1 year ago

kirandash commented 1 year ago

The goal of this task is to make sure all the js files are formatted properly.

Install husky and prettier. And activate pre-commit hook.

Please use the following prettier settings:

{
    "arrowParens": "avoid",
    "bracketSameLine": false,
    "bracketSpacing": true,
    "embeddedLanguageFormatting": "auto",
    "endOfLine": "lf",
    "htmlWhitespaceSensitivity": "css",
    "insertPragma": false,
    "jsxSingleQuote": false,
    "printWidth": 80,
    "proseWrap": "always",
    "quoteProps": "as-needed",
    "requirePragma": false,
    "semi": false,
    "singleAttributePerLine": false,
    "singleQuote": true,
    "tabWidth": 2,
    "trailingComma": "all",
    "useTabs": true
}

Create a "prettier" script to run on all .js files ex: "prettier": "prettier \"**/*.+(js)\"",

Create a "check-format" script ex: "check-format": "npm run prettier -- --list-different",

Add "check-format" script to pre-commit file ex: npm run check-format

Add a "format" script to help us format all files at once ex: "format": "npm run prettier -- --write"

If you need any clarification or help on how to implement this, please leave your comment here or on our discord server

MehmetTerc commented 1 year ago

I can do it

kirandash commented 1 year ago

@MehmetTerc Thanks a lot for your contribution 🎉