Merge branch 'upgrade-credo' into 'master'
chore: Add linters section to guide See merge request mythic-insight/legendary!93
This commit is contained in:
		
						commit
						1fe986c67e
					
				
					 2 changed files with 32 additions and 0 deletions
				
			
		
							
								
								
									
										31
									
								
								apps/core/guides/features/linters.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								apps/core/guides/features/linters.md
									
									
									
									
									
										Normal 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.
 | 
			
		||||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue