From 3e4a1a041e83b48cf0248a259da1495507ca7f08 Mon Sep 17 00:00:00 2001 From: mcieric Date: Thu, 9 Oct 2025 14:49:09 +0200 Subject: [PATCH] ci: add Solhint config and Solidity lint workflow --- .github/workflows/solhint.yml | 37 +++++++++++++++++++++++++++++++++++ .solhint.json | 17 ++++------------ 2 files changed, 41 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/solhint.yml diff --git a/.github/workflows/solhint.yml b/.github/workflows/solhint.yml new file mode 100644 index 00000000..d4eedf10 --- /dev/null +++ b/.github/workflows/solhint.yml @@ -0,0 +1,37 @@ +name: Solidity Lint (solhint) + +on: + pull_request: + branches: [ ${{ github.event.repository.default_branch || 'main' }} ] + push: + branches: [ ${{ github.event.repository.default_branch || 'main' }} ] + +jobs: + solhint: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 20 + + # Try local devDependency first; fallback to global install + - name: Install solhint + run: | + if [ -f package.json ]; then + npm ci || npm i + npx --yes solhint --version || npm i -D solhint + else + npm i -g solhint + fi + + - name: Run solhint + run: | + if ls contracts/**/*.sol >/dev/null 2>&1; then + npx solhint 'contracts/**/*.sol' || solhint 'contracts/**/*.sol' + else + echo "No Solidity files under contracts/, skipping." + fi diff --git a/.solhint.json b/.solhint.json index 323420dc..7a612548 100644 --- a/.solhint.json +++ b/.solhint.json @@ -1,18 +1,9 @@ { "extends": "solhint:recommended", "rules": { - "func-visibility": [ - "warn", - { - "ignoreConstructors": true - } - ], - "var-name-mixedcase": "off", - "custom-errors": "off", - "no-global-import": "off", - "reason-string": "off", - "no-inline-assembly": "off", - "immutable-vars-naming": "off", - "one-contract-per-file": "off" + "max-line-length": ["warn", 120], + "func-visibility": ["error", {"ignoreConstructors": true}], + "no-empty-blocks": "warn", + "compiler-version": ["error", "^0.8.0"] } }