diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml new file mode 100644 index 00000000..b35581ab --- /dev/null +++ b/.pre-commit-hooks.yaml @@ -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 \ No newline at end of file diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md index 7d0d0618..5a3acc57 100644 --- a/docs/src/SUMMARY.md +++ b/docs/src/SUMMARY.md @@ -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) @@ -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) \ No newline at end of file diff --git a/docs/src/usage/git-hook.md b/docs/src/usage/git-hook.md new file mode 100644 index 00000000..775456a1 --- /dev/null +++ b/docs/src/usage/git-hook.md @@ -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. \ No newline at end of file