Skip to content

piecioshka/boilerplate-husky-lint-staged-prettier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

boilerplate-husky-lint-staged-prettier

🍴 Setup code formatter as a pre-commit Git hooks task only for changes

Goals

  • 🐶 Use husky to set pre-commit hooks
  • 🧱 Use lint-staged to process only changes in files (not whole project)
  • 🧬 Use prettier to have the same syntax in the whole project

How to setup in my project? 🎉

  1. Create package.json:

    {
        "name": "boilerplate-husky-lint-staged-prettier"
    }
  2. Install deps:

    npm install -D prettier lint-staged husky
  3. Insert in package.json:

    ...
    "scripts": {
        ...
        "prepare": "husky install",
        "pre-commit": "lint-staged"
    },
    "lint-staged": {
        "*.md": "prettier --write"
    },
    "prettier": {
        "trailingComma": "all",
        "tabWidth": 2,
        "semi": true,
        "singleQuote": true,
        "arrowParens": "always",
        "proseWrap": "never"
    }
    ...

    Alternate option will be create files for each configuration:

  4. Husky

    Husky was evolved and introduce new way to setup Git hooks.

    npx husky-init && npm install
    npx husky add .husky/pre-commit "npm run pre-commit"
  5. Make a commit (using Git of course) and see how changed files look like 🎊

About

🍴 Setup code formatter as a pre-commit Git hooks task only for changes

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages