diff --git a/apps/core/guides/features/linters.md b/apps/core/guides/features/linters.md new file mode 100644 index 00000000..a9334e53 --- /dev/null +++ b/apps/core/guides/features/linters.md @@ -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. diff --git a/apps/core/mix.exs b/apps/core/mix.exs index e6b001b3..cae5b648 100644 --- a/apps/core/mix.exs +++ b/apps/core/mix.exs @@ -61,6 +61,7 @@ defmodule Legendary.Core.MixProject do "guides/features/feature-flags.md", "guides/features/i18n.md", "guides/features/tasks-and-scripts.md", + "guides/features/linters.md", ] end