Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/boidolr/ast-grep-pre-commit
ast-grep integration for pre-commit hooks
https://github.com/boidolr/ast-grep-pre-commit
ast-grep codemod git-hooks pre-commit refactoring
Last synced: 3 months ago
JSON representation
ast-grep integration for pre-commit hooks
- Host: GitHub
- URL: https://github.com/boidolr/ast-grep-pre-commit
- Owner: boidolr
- License: mit
- Created: 2024-02-01T17:39:03.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-08-19T07:24:10.000Z (3 months ago)
- Last Synced: 2024-08-19T08:45:11.429Z (3 months ago)
- Topics: ast-grep, codemod, git-hooks, pre-commit, refactoring
- Homepage:
- Size: 43 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
ast-grep-pre-commit
[![tag](https://img.shields.io/github/v/tag/boidolr/ast-grep-pre-commit?sort=semver)](https://github.com/boidolr/ast-grep-pre-commit/tags)
[![Build](https://github.com/boidolr/ast-grep-pre-commit/actions/workflows/test.yaml/badge.svg)](https://github.com/boidolr/ast-grep-pre-commit/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 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 ast-grep-pre-commit with pre-commit
Add this to your `.pre-commit-config.yaml`:
```
- repo: https://github.com/boidolr/ast-grep-pre-commit
rev: 0.26.2 # 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/ast-grep-pre-commit
rev: 0.26.2
hooks:
- id: ast-grep
args: ["--update-all"]
```### Provide explicit configuration
```
- repo: https://github.com/boidolr/ast-grep-pre-commit
rev: 0.26.2
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.