Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Git Hooks [1] are a fantastic way to customize the development workflow of a project to simplify and automate specific tasks that are required when working on the code base. For example, this includes tasks like formatting, "linting" and running tests before pushing a commit to ensure it conforms to the code style and works as expected. Most Git Hooks are not that complex and fullfil a simple purpose while other solutions like Danger [2] can help to manage larger projects and projects that need to scale. This "base" repository template initially uses a Git Hook that automatically runs configured linters on all files that have been staged and that match the configured pattern (file extension, filename etc.). Like documented in GH-15, NodeJS [3] is already a development dependency anyway so the lint-staged [4] NPM package is used for this goal. I've used this package in almost any project and it's again the most stable, production-proven and advanced tool that is currently out there with no comparable alternatives in other languages. >>> Configuration The configuration file `lint-staged.config.js` is placed in the project root and includes the command that should be run for matching file extensions (globs). Initialliy it includes the following three entries with the same order as listed here: 1. `prettier --check` - Runs Prettier [5] (GH-13) to ensure all files are formatted correctly. The `--list-different` prints files that are not conform with the Prettier configuration. 2. `remark --no-stdout` - Runs remark-lint [6] (GH-15) against `*.md` to ensure all Markdown files are compliant to the style guide. The `--no-stdout` flag suppresses the output of the parsed file content. [1]: https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks [2]: https://danger.systems [3]: https://nodejs.org [4]: https://github.com/okonet/lint-staged [5]: https://prettier.io [6]: https://github.com/remarkjs/remark-lint Closes GH-17
- Loading branch information