chore: Add linters section to guide

This commit is contained in:
Robert Prehn 2021-07-21 10:27:57 -05:00
parent 080c32699f
commit 91c3c4f559
2 changed files with 32 additions and 0 deletions

View file

@ -0,0 +1,31 @@
# Linters
Legendary ships with a set of reasonable default linter configurations to help
enforce consistent code style in your application. This is particularly valuable
when working together as a team. However, even when working solo, linters will
find some errors in your code and help you to avoid needless changes in the future.
Included linters:
- *credo* for Elixir
- *prettier* for JavaScript
- *stylelint* for CSS
## Pre-commit hooks
If you would like to lint your code before every commit, you can use
[lefthook](https://github.com/evilmartians/lefthook) to do so. We include a
lefthook.yml that runs credo, prettier, and stylelint for you.
First, if you do not have it installed already, you will need to
[install lefthook](https://github.com/evilmartians/lefthook/blob/master/docs/other.md#installation).
On the Mac with Homebrew, this is as simple as `brew install lefthook`. Instructions
for other environments are available in the lefthook documentation linked above.
Then you can install the hooks via `lefthook install`. You can test them without
committing by running `lefthook run pre-commit`.
## Linters in CI
The included `.gitlab-ci.yml` runs credo, prettier, and stylelint in CI as an
additional consistency check.

View file

@ -61,6 +61,7 @@ defmodule Legendary.Core.MixProject do
"guides/features/feature-flags.md", "guides/features/feature-flags.md",
"guides/features/i18n.md", "guides/features/i18n.md",
"guides/features/tasks-and-scripts.md", "guides/features/tasks-and-scripts.md",
"guides/features/linters.md",
] ]
end end