-
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Git Hook: lint-staged #18
Merged
Merged
+597
−1
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 --list-different` - Runs Prettier [5] (GH-13) against `*.{js,json,md,yml}` 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 GH-17
017ddb2
to
e32acc9
Compare
svengreb
added a commit
that referenced
this pull request
Aug 22, 2020
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
svengreb
added a commit
that referenced
this pull request
Aug 22, 2020
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #17