Skip to content

Commit

Permalink
Configure pre-commit hooks for packages (#42)
Browse files Browse the repository at this point in the history
In this PR we configure pre-commit hooks for dapp and website packages.
  • Loading branch information
r-czajkowski authored Nov 23, 2023
2 parents 4cf4d8c + a4a2b85 commit 3929638
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 36 deletions.
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto-fix linting
d2a058fe6cfbab6f82d0d977d1b2d8bd9f494df1
52 changes: 43 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,55 @@
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"
# 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"
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"
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Empty file removed core/.git-blame-ignore-revs
Empty file.
47 changes: 20 additions & 27 deletions dapp/manifest-ledger-live-app.json
Original file line number Diff line number Diff line change
@@ -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://*"]
}

0 comments on commit 3929638

Please sign in to comment.