Skip to content

Commit 1c2e57b

Browse files
Merge pull request #59 from casework/pre-commit-json
JSON Pre-Commit
2 parents 3a2063e + af08f7b commit 1c2e57b

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ jobs:
3232
uses: actions/setup-python@v2
3333
with:
3434
python-version: ${{ matrix.python-version }}
35+
- name: Pre-commit Checks
36+
run: |
37+
pip -q install pre-commit
38+
pre-commit run --all-files
3539
- name: Start from clean state
3640
run: make clean
3741
- name: Run tests

.pre-commit-config.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.1.0
4+
hooks:
5+
- id: check-json
6+
- id: pretty-format-json
7+
args:
8+
- --autofix
9+
- --indent=4
10+
- --no-ensure-ascii
11+
- --no-sort-keys

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,17 @@ Mapping notes & respective JSON-LD output:
2525
- [Raw Data](examples/illustrations/raw_data/raw_data.json)
2626
- [Reconstructed File](examples/illustrations/reconstructed_file/reconstructed_file.json) (*[info](examples/illustrations/reconstructed_file/)*)
2727
- [SMS and Contacts](examples/illustrations/sms_and_contacts/sms_and_contacts.json)
28+
29+
30+
This project uses [the `pre-commit` tool](https://pre-commit.com/) for linting the JSON files and ensuring consistent formatting. It can be installed with `pip`:
31+
```bash
32+
pip install pre-commit
33+
pre-commit --version
34+
```
35+
36+
The `pre-commit` tool hooks into Git's commit machinery to run a set of linters and static analyzers over each change. To install `pre-commit` into Git's hooks, run:
37+
```bash
38+
pre-commit install
39+
```
40+
41+
To uninstall `pre-commit`, run either `pre-commit uninstall` or `rm .git/hooks/pre-commit`.

0 commit comments

Comments
 (0)