From c207ecef985bff94800649766021521515c8b170 Mon Sep 17 00:00:00 2001 From: Rafal Czajkowski Date: Wed, 15 Nov 2023 21:24:45 +0100 Subject: [PATCH 1/6] Update pre-commit hooks for `core` workspace Define pre-commit hooks for core package. Co-authored-by: Rafal Czajkowski --- .pre-commit-config.yaml | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c700c60d4..a08515b37 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,21 +1,25 @@ repos: - repo: local hooks: - - id: lint-sol + # Core + - id: core-lint-sol name: "lint core sol" - entry: /usr/bin/env bash -c "cd core/ && npm run lint:sol" - files: '\.sol$' + entry: /usr/bin/env bash -c "npm --prefix ./core/ run lint:sol" + files: ^core/ + types: [solidity] language: script description: "Checks solidity code according to the package's linter configuration" - - id: lint-js + - id: core-lint-js name: "lint core ts/js" - entry: /usr/bin/env bash -c "cd core/ && npm run lint:js" - files: '\.(ts|js)$' + entry: /usr/bin/env bash -c "npm --prefix ./core/ run lint:js" + files: ^core/ + types_or: [ts, javascript] language: script description: "Checks TS/JS code according to the package's linter configuration" - - id: lint-config + - id: core-lint-config name: "lint core json/yaml" - entry: /usr/bin/env bash -c "cd core/ && npm run lint:config" - files: '\.(json|yaml)$' + entry: /usr/bin/env bash -c "npm --prefix ./core/ run lint:config" + files: ^core/ + types_or: [json, yaml] language: script description: "Checks JSON/YAML code according to the package's linter configuration" From 2d26889063c0ccfd931ca391386e37a40348b726 Mon Sep 17 00:00:00 2001 From: Rafal Czajkowski Date: Wed, 15 Nov 2023 21:29:22 +0100 Subject: [PATCH 2/6] Add pre-commit hooks for website workspace Co-authored-by: Rafal Czajkowski --- .pre-commit-config.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a08515b37..7e0cf2b8f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -23,3 +23,18 @@ repos: types_or: [json, yaml] language: script description: "Checks JSON/YAML code according to the package's linter configuration" + # Website + - id: website-lint-js + name: "lint website ts/js" + entry: /usr/bin/env bash -c "npm --prefix ./website/ run lint:js" + files: ^website/ + types_or: [ts, tsx, javascript, jsx] + language: script + description: "Checks TS/JS code according to the package's linter configuration" + - id: website-lint-config + name: "lint website json/yaml" + entry: /usr/bin/env bash -c "npm --prefix ./website/ run lint:config" + files: ^website/ + types_or: [json, yaml] + language: script + description: "Checks JSON/YAML code according to the package's linter configuration" From e62d6bcd7db860bf49a350e0e5938d4d98d105ef Mon Sep 17 00:00:00 2001 From: Jakub Nowakowski Date: Thu, 23 Nov 2023 12:09:53 +0100 Subject: [PATCH 3/6] Add pre-commit hooks for dapp workspace --- .pre-commit-config.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7e0cf2b8f..e55db32ed 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -23,6 +23,21 @@ repos: types_or: [json, yaml] language: script description: "Checks JSON/YAML code according to the package's linter configuration" + # dApp + - id: dapp-lint-js + name: "lint dapp ts/js" + entry: /usr/bin/env bash -c "npm --prefix ./dapp/ run lint:js" + files: ^dapp/ + types_or: [ts, tsx, javascript, jsx] + language: script + description: "Checks TS/JS code according to the package's linter configuration" + - id: dapp-lint-config + name: "lint dapp json/yaml" + entry: /usr/bin/env bash -c "npm --prefix ./dapp/ run lint:config" + files: ^dapp/ + types_or: [json, yaml] + language: script + description: "Checks JSON/YAML code according to the package's linter configuration" # Website - id: website-lint-js name: "lint website ts/js" From d2a058fe6cfbab6f82d0d977d1b2d8bd9f494df1 Mon Sep 17 00:00:00 2001 From: Jakub Nowakowski Date: Thu, 23 Nov 2023 12:11:17 +0100 Subject: [PATCH 4/6] Auto-fix dapp files formatting --- dapp/manifest-ledger-live-app.json | 47 +++++++++++++----------------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/dapp/manifest-ledger-live-app.json b/dapp/manifest-ledger-live-app.json index a6ed3d306..a03b1bb09 100644 --- a/dapp/manifest-ledger-live-app.json +++ b/dapp/manifest-ledger-live-app.json @@ -1,30 +1,23 @@ { - "id": "acre", - "name": "ACRE", - "url": "http://localhost:5173/", - "homepageUrl": "http://localhost:5173/", - "icon": "http://localhost:5173/acre.svg", - "platform": "all", - "apiVersion": "2.0.0", - "manifestVersion": "1", - "branch": "stable", - "categories": [ - "buy" - ], - "currencies": [ - "bitcoin", - "bitcoin_testnet" - ], - "content": { - "shortDescription": { - "en": "Bitcoin Liquid Staking" - }, - "description": { - "en": "Bitcoin Liquid Staking" - } + "id": "acre", + "name": "ACRE", + "url": "http://localhost:5173/", + "homepageUrl": "http://localhost:5173/", + "icon": "http://localhost:5173/acre.svg", + "platform": "all", + "apiVersion": "2.0.0", + "manifestVersion": "1", + "branch": "stable", + "categories": ["buy"], + "currencies": ["bitcoin", "bitcoin_testnet"], + "content": { + "shortDescription": { + "en": "Bitcoin Liquid Staking" }, - "permissions": [], - "domains": [ - "http://*" - ] + "description": { + "en": "Bitcoin Liquid Staking" + } + }, + "permissions": [], + "domains": ["http://*"] } From 214a6b4db4d6ab3b495ecec6aa09b79a00f2e36b Mon Sep 17 00:00:00 2001 From: Jakub Nowakowski Date: Thu, 23 Nov 2023 12:13:36 +0100 Subject: [PATCH 5/6] Add auto-fix commit to git blame ignore revs --- .git-blame-ignore-revs | 2 ++ core/.git-blame-ignore-revs | 0 2 files changed, 2 insertions(+) create mode 100644 .git-blame-ignore-revs delete mode 100644 core/.git-blame-ignore-revs diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 000000000..b4f1cac41 --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,2 @@ +# Auto-fix linting +d2a058fe6cfbab6f82d0d977d1b2d8bd9f494df1 diff --git a/core/.git-blame-ignore-revs b/core/.git-blame-ignore-revs deleted file mode 100644 index e69de29bb..000000000 From a4a2b8511994206ed3cb8f8ea48da3c41eccff91 Mon Sep 17 00:00:00 2001 From: Jakub Nowakowski Date: Thu, 23 Nov 2023 12:20:59 +0100 Subject: [PATCH 6/6] Add info about testing pre-commit hooks config When configuring the hooks we may want to test them before pushing. --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 431a793c6..de2f62834 100644 --- a/README.md +++ b/README.md @@ -22,3 +22,15 @@ To setup the hooks follow the steps: ```sh pre-commit install ``` + +#### Testing + +To test the pre-commit hooks configuration you can invoke them with one of the +commands: +```sh +# Execute hooks for all files: +pre-commit run --all-files + +# Execute hooks for specific files (e.g. Acre.sol): +pre-commit run --files ./core/contracts/Acre.sol +```