legendary-doc-site/apps/core/guides/features/linters.md

32 lines
1.2 KiB
Markdown
Raw Normal View History

2021-07-21 15:27:57 +00:00
# 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.