From c0fcb01bb4389f43a8ad70f4335306d804e96095 Mon Sep 17 00:00:00 2001 From: Jakub Nowakowski Date: Thu, 26 Oct 2023 09:03:56 +0200 Subject: [PATCH 1/2] Add pre-commit hooks configuration The pre-commit hooks are used to run code formatting checks before the code is submitted to the repository with `git commit` command. To setup the hooks follow the steps: 1. Install `pre-commit` tool: ```sh brew install pre-commit ``` 2. Install the hooks for the repository: ```sh pre-commit install ``` --- .pre-commit-config.yaml | 21 +++++++++++++++++++++ README.md | 19 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..395353ffb --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,21 @@ +repos: + - repo: local + hooks: + - id: lint-sol + name: "lint core sol" + entry: /usr/bin/env bash -c "cd core/ && npm run lint:sol" + files: '\.sol$' + language: script + description: "Checks solidity code according to the package's linter configuration" + - id: lint-eslint + name: "lint core ts/js" + entry: /usr/bin/env bash -c "cd core/ && npm run lint:eslint" + files: '\.(ts|js)$' + language: script + description: "Checks TS/JS code according to the package's linter configuration" + - id: lint-config + name: "lint core json/yaml" + entry: /usr/bin/env bash -c "cd core/ && npm run lint:config" + files: '\.(json|yaml)$' + language: script + description: "Checks JSON/YAML code according to the package's linter configuration" diff --git a/README.md b/README.md index 14fe49a09..f4912793e 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,21 @@ # litmus Bitcoin Liquid Staking + +# Development + +## Pre-commit Hooks + +Developers are encouraged to use [pre-commit](https://pre-commit.com/) hooks to +automatically discover code issues, before they submit the code. + +To setup the hooks follow the steps: + +1. Install `pre-commit` tool: + ```sh + brew install pre-commit + ``` + +2. Install the hooks for the repository: + ```sh + pre-commit install + ``` From bb1e92fbf8b9dafbbca6dd14535d1570cca5401e Mon Sep 17 00:00:00 2001 From: Jakub Nowakowski Date: Wed, 1 Nov 2023 12:09:48 +0100 Subject: [PATCH 2/2] Update name of the script for JS linting The script was renamed to `lint:js`. --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 395353ffb..c700c60d4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,9 +7,9 @@ repos: files: '\.sol$' language: script description: "Checks solidity code according to the package's linter configuration" - - id: lint-eslint + - id: lint-js name: "lint core ts/js" - entry: /usr/bin/env bash -c "cd core/ && npm run lint:eslint" + entry: /usr/bin/env bash -c "cd core/ && npm run lint:js" files: '\.(ts|js)$' language: script description: "Checks TS/JS code according to the package's linter configuration"