Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Pre-Commit hook support #541

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .pre-commit-hook.yaml
Jarmos-san marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
- id: selene
name: selene (cargo)
description: An opinionated Lua code linter
entry: selene
language: rust
types:
- lua

- id: selene-system
name: selene (system)
description: An opinionated Lua code linter
entry: selene
language: system
types:
- lua

- id: selene-docker
name: selene (docker)
description: An opinionated Lua code linter
entry: selene
language: docker
types:
- lua
3 changes: 2 additions & 1 deletion docs/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- [Configuration](./usage/configuration.md)
- [Filtering](./usage/filtering.md)
- [Standard Library Format](./usage/std.md)
- [Git Hook](./usage/git-hook.md)
- [Roblox Guide](./roblox.md)
- [Contributing](./contributing.md)
- [Lints](./lints/index.md)
Expand Down Expand Up @@ -41,4 +42,4 @@
- [unscoped_variables](./lints/unscoped_variables.md)
- [unused_variable](./lints/unused_variable.md)
- [Archive](./archive/index.md)
- [TOML Standard Library Format](./archive/std_v1.md)
- [TOML Standard Library Format](./archive/std_v1.md)
25 changes: 25 additions & 0 deletions docs/src/usage/git-hook.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Git Hook Support

Selene has [githooks](https://git-scm.com/docs/githooks) support thanks to
[pre-commit](https://pre-commit.com) which means you will need to add a
configuration file - `.pre-commit-config.yaml` to your repository. Thereafter
you'll need to install the hooks and `selene` will be run against all recently
changed files before you commit the changes.

This section of the document details the ways you could setup `pre-commit` for
linting your Lua code before each commits.

In the `.pre-commit-config.yaml` file add the following configurations and then
run `pre-commit install --install-hooks` to setup the pre-commit hooks.

```yaml
repos:
- repo: https://github.com/Kampfkarren/selene
rev: '' # Add the latest version of Selene here
hooks:
- selene # this will use Cargo to compile the binary before usage
- selene-system # this will use the installed binary on the system
- selene-docker # this will build a Docker image before usage
```

To ensure `pre-commit` is the latest tagged version of `selene`, run the `pre-commit autoupdate` command.