Skip to content

Commit

Permalink
docs: extend README
Browse files Browse the repository at this point in the history
  • Loading branch information
boidolr committed Feb 6, 2024
1 parent 382d30d commit c3bf02f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
pre-commit-ast-grep
[![tag](https://img.shields.io/github/v/tag/boidolr/pre-commit-ast-grep?sort=semver)](https://github.com/boidolr/pre-commit-ast-grep/tags)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
[![pre-commit](https://img.shields.io/badge/pre--commit-hook-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
================


Minimal git hooks to run [`ast-grep`](https://github.com/ast-grep/ast-grep) based on the [pre-commit](https://github.com/pre-commit/pre-commit) framework.
Minimal git hook to run [ast-grep](https://github.com/ast-grep/ast-grep) based on the [pre-commit](https://github.com/pre-commit/pre-commit) framework.

## Using pre-commit-ast-grep with pre-commit

Expand All @@ -16,16 +16,22 @@ Add this to your `.pre-commit-config.yaml`:
- id: ast-grep
```

Note that only rules with a severity of "error" will trigger the commit hook.


### Automatically execute rewrites

```
- repo: https://github.com/boidolr/pre-commit-ast-grep
rev: v0.2.0 # Use the ref you want to point at
hooks:
- id: ast-grep
args: ["--update-all"]
args: ["--update-all"]
```

Mixing rules with fixes and without fixes with the "--update-all" option is currently not supported.


### Provide explicit configuration

```
Expand All @@ -36,6 +42,7 @@ Add this to your `.pre-commit-config.yaml`:
args: ["--config", "/some/path/sgconfig.yaml"]
```


## How to write rules

See https://ast-grep.github.io/ for details on `ast-grep` and how to write linters and rewriters.

0 comments on commit c3bf02f

Please sign in to comment.