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 9, 2024
1 parent e02c3c3 commit 1358070
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
22 changes: 16 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,51 @@
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)
[![Build](https://github.com/boidolr/pre-commit-ast-grep/actions/workflows/test.yaml/badge.svg)](https://github.com/boidolr/pre-commit-ast-grep/actions/workflows/test.yaml)
[![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

Add this to your `.pre-commit-config.yaml`:
```
- repo: https://github.com/boidolr/pre-commit-ast-grep
rev: v0.2.0 # Use the ref you want to point at
rev: v0.18.1 # Use the ref you want to point at
hooks:
- id: ast-grep
```

Note that only rules with a severity of "error" will lead to the commit hook failing.


### Automatically execute rewrites

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

When executing rewrites, the commit hook will fail for any severity.

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


### Provide explicit configuration

```
- repo: https://github.com/boidolr/pre-commit-ast-grep
rev: v0.2.0 # Use the ref you want to point at
rev: v0.18.1 # Use the ref you want to point at
hooks:
- id: ast-grep
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.
3 changes: 1 addition & 2 deletions renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
"extends": [
"github>boidolr/actions",
"github>boidolr/actions//presets/precommit"
],
"ignoreTests": true
]
}

0 comments on commit 1358070

Please sign in to comment.