From 80763702f2ce4016a3ad56aeca88431c4fa5d79a Mon Sep 17 00:00:00 2001 From: kchason Date: Tue, 29 Mar 2022 14:25:47 -0400 Subject: [PATCH 1/3] Add pre-commit rules and job for JSON --- .github/workflows/ci.yml | 4 ++++ .pre-commit-config.yaml | 11 +++++++++++ 2 files changed, 15 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 392335bd..3feb7fec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,6 +32,10 @@ jobs: uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} + - name: Pre-commit Checks + run: | + pip -q install pre-commit + pre-commit run --all-files - name: Start from clean state run: make clean - name: Run tests diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..761c732f --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,11 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.3.0 + hooks: + - id: check-json + - id: pretty-format-json + args: + - --autofix + - --indent=4 + - --no-ensure-ascii + - --no-sort-keys From a918c521f37810afd1a7be2b626f7e2ea742b008 Mon Sep 17 00:00:00 2001 From: kchason Date: Tue, 29 Mar 2022 14:28:12 -0400 Subject: [PATCH 2/3] Update docs --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index bca30db0..efe0a471 100644 --- a/README.md +++ b/README.md @@ -25,3 +25,15 @@ Mapping notes & respective JSON-LD output: - [Raw Data](examples/illustrations/raw_data/raw_data.json) - [Reconstructed File](examples/illustrations/reconstructed_file/reconstructed_file.json) (*[info](examples/illustrations/reconstructed_file/)*) - [SMS and Contacts](examples/illustrations/sms_and_contacts/sms_and_contacts.json) + + +This project uses [the `pre-commit` tool](https://pre-commit.com/) for linting the JSON files and ensuring consistent formatting. The easiest way to install it is with `pip`: +```bash +pip install pre-commit +pre-commit --version +``` + +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: +```bash +pre-commit install +``` \ No newline at end of file From af08f7b9fb0dafa24d363c23fadbed4d8ad7902a Mon Sep 17 00:00:00 2001 From: kchason Date: Tue, 29 Mar 2022 14:49:27 -0400 Subject: [PATCH 3/3] Update docs and bump version --- .pre-commit-config.yaml | 2 +- README.md | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 761c732f..339017a6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v2.3.0 + rev: v4.1.0 hooks: - id: check-json - id: pretty-format-json diff --git a/README.md b/README.md index efe0a471..28337eb2 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Mapping notes & respective JSON-LD output: - [SMS and Contacts](examples/illustrations/sms_and_contacts/sms_and_contacts.json) -This project uses [the `pre-commit` tool](https://pre-commit.com/) for linting the JSON files and ensuring consistent formatting. The easiest way to install it is with `pip`: +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`: ```bash pip install pre-commit pre-commit --version @@ -36,4 +36,6 @@ pre-commit --version 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: ```bash pre-commit install -``` \ No newline at end of file +``` + +To uninstall `pre-commit`, run either `pre-commit uninstall` or `rm .git/hooks/pre-commit`. \ No newline at end of file