# ERB Lint [](https://github.com/Shopify/erb_lint/actions)
`erb_lint` is a tool to help lint your ERB or HTML files using the included linters or by writing your own.
## Requirements
* Ruby 2.3.0+
- This is due to use of the safe navigation operator (`&.`)
- This is also due to the use of the tilde-heredoc `<<~` syntax in some tests.
## Installation
```bash
gem install erb_lint
```
...or add the following to your `Gemfile` and run `bundle install`:
```ruby
gem 'erb_lint', require: false
```
## Configuration
Create a `.erb_lint.yml` file in your project, with the following structure:
```yaml
---
EnableDefaultLinters: true
linters:
ErbSafety:
enabled: true
better_html_config: .better-html.yml
Rubocop:
enabled: true
rubocop_config:
inherit_from:
- .rubocop.yml
```
> [!TIP]
> Creating an `.erb_lint.yml` config file is _not_ mandatory; **the tool works out of the box with default settings**.
>
> Please note that the two config files referenced in the examples above and below _must_ exist, or you will get an error. (Of course, you can omit the two config file references (i.e. the `better_html_config` key, and the `rubocop_config` section.)
See below for linter-specific configuration options.
## Usage
This gem provides a command-line interface which can be run like so:
1. Run `erb_lint [options]` if the gem is installed standalone.
2. Run `bundle exec erb_lint [options]` if the gem is installed as a Gemfile dependency for your app.
For example, `erb_lint --lint-all --enable-all-linters` will run all available
linters on all ERB files in the current directory or its descendants (`**/*.html{+*,}.erb`).
If you want to change the glob & exclude that is used, you can configure it by adding it to your config file as follows:
```yaml
---
glob: "**/*.{html,text,js}{+*,}.erb"
exclude:
- '**/vendor/**/*'
- '**/node_modules/**/*'
linters:
ErbSafety:
enabled: true
better_html_config: .better-html.yml
Rubocop:
enabled: true
rubocop_config:
inherit_from:
- .rubocop.yml
```
Make sure to add `**/` to exclude patterns; it matches the target files' absolute paths.
## Enable or disable default linters
`EnableDefaultLinters`: enables or disables default linters. [Default linters](#linters) are enabled by default.
## Disable rule at offense-level
You can disable a rule by placing a disable comment in the following format:
Comment on offending lines
```.erb