Skip to content

Commit

Permalink
docs: update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mrexox committed Jul 17, 2024
1 parent 5fe51bb commit f8f3997
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -1259,7 +1259,9 @@ pre-commit:

### `exclude`

You can provide a regular expression to exclude some files from being passed to [`run`](#run) command.
You can provide a list of filenames or a regular expression to exclude some files from being passed to [`run`](#run) command.

If you pass a list of filenames, they must contain the full path of the file from the project root.

The regular expression is matched against full paths to files in the repo,
relative to the repo root, using `/` as the directory separator on all platforms.
Expand All @@ -1280,6 +1282,23 @@ pre-commit:
run: bundle exec rubocop --force-exclusion {staged_files}
```

The same example using a list of filenames.

```yml
# lefthook.yml
pre-commit:
commands:
lint:
glob: "*.rb"
exclude:
- config/routes.rb
- config/application.rb
- spec/rails_helper.rb
run: bundle exec rubocop --force-exclusion {staged_files}
```


**Notes**

Be careful with the config file format's string quoting and escaping rules when writing regexps in it. For YAML, single quotes are often the simplest choice.
Expand Down

0 comments on commit f8f3997

Please sign in to comment.