Skip to content
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 1 commit into from
Jun 20, 2020
Merged

Git Hook: lint-staged #18

merged 1 commit into from
Jun 20, 2020

Conversation

svengreb
Copy link
Owner

Resolves #17

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
@svengreb svengreb force-pushed the feature/gh-17-git-hook-lint-staged branch from 017ddb2 to e32acc9 Compare June 20, 2020 07:05
@svengreb svengreb merged commit abae9c2 into base Jun 20, 2020
@svengreb svengreb deleted the feature/gh-17-git-hook-lint-staged branch June 20, 2020 07:06
@svengreb svengreb removed their assignment Jun 20, 2020
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant