Skip to content

Commit

Permalink
fix(CI/CD): fix solhint (#190)
Browse files Browse the repository at this point in the history
* fix(solhint): rm redundant pre-commit linting hook

* fix(solhint): update linting script & pkg version

* chore(contracts): apply linting fixes
  • Loading branch information
sebsadface authored Oct 15, 2024
1 parent ca8cc46 commit 1e2a6a1
Show file tree
Hide file tree
Showing 13 changed files with 187 additions and 286 deletions.
35 changes: 14 additions & 21 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ repos:
- repo: https://github.com/Yelp/detect-secrets
rev: v1.5.0
hooks:
- id: detect-secrets
args: ['--baseline', '.secrets.baseline']
- id: detect-secrets
args: ["--baseline", ".secrets.baseline"]
exclude: "(pnpm-lock.yaml|testdata|static|config.json|genesis.json)"

# Then run code formatters
Expand All @@ -27,16 +27,16 @@ repos:
- id: go-mod-tidy # Run go mod tidy when go.mod changes
files: go.mod
- id: go-fmt
args: [ -w, -s ] # simplify code and write result to (source) file instead of stdout
args: [-w, -s] # simplify code and write result to (source) file instead of stdout

- repo: local
hooks:
- id: run-solidity-lint
name: run-solidity-lint
language: script
entry: .pre-commit/run_solidity_lint.sh
types: [ file, solidity ]
require_serial: true
- id: run-solidity-lint
name: run-solidity-lint
language: script
entry: .pre-commit/run_solidity_lint.sh
types: [file, solidity]
require_serial: true

# Then run code validators (on the formatted code)

Expand All @@ -54,40 +54,33 @@ repos:
name: run-buf
language: script
entry: .pre-commit/run_buf.sh
types: [ file, proto ]
types: [file, proto]
pass_filenames: false

- id: run-go-tests
name: run-go-tests
language: script
require_serial: true # Don't run this in parallel
entry: .pre-commit/run_go_tests.sh
types: [ file, go ]
types: [file, go]

- id: run-forge-tests
name: run-forge-tests
language: script
entry: .pre-commit/run_forge_tests.sh
types: [ file, solidity ]
types: [file, solidity]
require_serial: true

- id: run-regexp
name: run-regexp
language: script
entry: .pre-commit/run_regexp.sh
types: [ file, go ]
types: [file, go]
exclude: "(_test.go|contracts/bindings/.*|scripts/)"

- id: run-goversion
name: run-goversion
language: script
entry: .pre-commit/run_goversion.sh
pass_filenames: false
types: [ file, go ]

- id: run-solhint
name: run-solhint
language: script
entry: .pre-commit/run_solhint.sh
types: [ file, solidity ]
require_serial: true
types: [file, go]
13 changes: 0 additions & 13 deletions .pre-commit/run_solhint.sh

This file was deleted.

14 changes: 6 additions & 8 deletions .pre-commit/run_solidity_lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
# Runs `pnpm lint-check` for every unique foundry project derived from the list
# of files provided as arguments by pre-commit.

# TODO: Unify and fix solhint versions in repo
# source scripts/install_foundry.sh
source scripts/install_foundry.sh

# import foundryroots
# source .pre-commit/foundry_utils.sh
source .pre-commit/foundry_utils.sh

# for dir in $(foundryroots $@); do
# echo "Running 'lint-check' in ./$dir"
# (cd $dir && pnpm lint-check)
# done
for dir in $(foundryroots $@); do
echo "Running 'lint-fix and lint-full' in ./$dir"
(cd $dir && pnpm lint-fix && pnpm lint-full)
done
12 changes: 0 additions & 12 deletions .solhint.json

This file was deleted.

1 change: 0 additions & 1 deletion .solhintignore

This file was deleted.

3 changes: 1 addition & 2 deletions contracts/.solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"private-vars-leading-underscore": "off",
"func-name-mixedcase": "off",
"var-name-mixedcase": "off",
"modifier-name-mixedcase": "off",
"custom-errors": "off"
"modifier-name-mixedcase": "off"
}
}
11 changes: 5 additions & 6 deletions contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
],
"scripts": {
"test": "pnpm test:gen && forge test",
"lint-full": "prettier --log-level warn --ignore-path .gitignore '{contracts,test}/**/*.sol' --check && solhint '{contracts,test}/**/*.sol'",
"lint-fix": "prettier --log-level warn --ignore-path .gitignore '{contracts,test}/**/*.sol' --write",
"lint-check": "solhint '{contracts,script,test}/**/*.sol'"
"lint-full": "prettier --log-level warn --ignore-path .gitignore '{src,test,script}/**/*.sol' --check && solhint '{src,test,script}/**/*.sol'",
"lint-fix": "prettier --log-level warn --ignore-path .gitignore '{src,test,script}/**/*.sol' --write",
"lint-check": "solhint '{src,test,script}/**/*.sol'"
},
"devDependencies": {
"@openzeppelin/merkle-tree": "^1.0.5",
Expand All @@ -23,9 +23,8 @@
"ethereum-cryptography": "^2.1.3",
"forge-std": "https://github.com/foundry-rs/forge-std",
"prettier": "^3.3.3",
"prettier-plugin-solidity": "^1.3.1",
"solhint": "^5.0.1",
"solhint-community": "^4.0.0",
"prettier-plugin-solidity": "^1.4.1",
"solhint": "^5.0.3",
"solhint-plugin-prettier": "^0.1.0",
"ts-node": "^10.9.2",
"typescript": "^5.3.3",
Expand Down
Loading

0 comments on commit 1e2a6a1

Please sign in to comment.