refactor: substitute "forge fmt" for "prettier-plugin-solidity"

build: remove "prettier-plugin-solidity" and "solhint-plugin-prettier" deps
chore: add "fmt" configuration in Foundry config
chore: delete solidity override from Prettier rules
chore: delete solidity rules from Solhint config
chore: modify scripts to run Prettier on all files except "*.sol"
test: document "setUp" function
This commit is contained in:
Paul Razvan Berg 2023-01-03 21:18:14 +02:00
parent 0ebca896c8
commit 6d027d098b
No known key found for this signature in database
GPG Key ID: BCC366159BD63828
7 changed files with 15 additions and 91 deletions

View File

@ -5,9 +5,3 @@ singleQuote: false
tabWidth: 2
trailingComma: "all"
useTabs: false
overrides:
- files: "*.sol"
options:
compiler: "0.8.17"
tabWidth: 4

View File

@ -1,18 +1,11 @@
{
"extends": "solhint:recommended",
"plugins": ["prettier"],
"rules": {
"code-complexity": ["error", 8],
"compiler-version": ["error", ">=0.8.4"],
"func-visibility": ["error", { "ignoreConstructors": true }],
"max-line-length": ["error", 120],
"not-rely-on-time": "off",
"prettier/prettier": [
"error",
{
"endOfLine": "auto"
}
],
"reason-string": ["warn", { "maxLength": 64 }]
}
}

View File

@ -1,5 +1,13 @@
# Full reference https://github.com/foundry-rs/foundry/tree/master/config
[fmt]
bracket_spacing = true
int_types = "long"
line_length = 120
number_underscore = "thousands"
quote_style = "double"
tab_width = 4
[profile.default]
auto_detect_solc = false
bytecode_hash = "none"
@ -16,3 +24,4 @@ test = "test"
[profile.ci]
fuzz = { runs = 10_000 }
verbosity = 4

View File

@ -14,10 +14,8 @@
"husky": "^8.0.2",
"lint-staged": "^13.0.3",
"prettier": "^2.7.1",
"prettier-plugin-solidity": "^1.0.0",
"rimraf": "^3.0.2",
"solhint": "^3.3.7",
"solhint-plugin-prettier": "^0.0.5"
"solhint": "^3.3.7"
},
"keywords": [
"blockchain",
@ -36,9 +34,9 @@
"scripts": {
"clean": "rimraf cache out",
"lint": "yarn lint:sol && yarn prettier:check",
"lint:sol": "solhint \"{src,test}/**/*.sol\"",
"lint:sol": "forge fmt --check && solhint \"{src,test}/**/*.sol\"",
"postinstall": "husky install",
"prettier:check": "prettier --check \"**/*.{json,md,sol,yml}\"",
"prettier:write": "prettier --write \"**/*.{json,md,sol,yml}\""
"prettier:check": "prettier --check \"**/*.{json,md,yml}\"",
"prettier:write": "prettier --write \"**/*.{json,md,yml}\""
}
}

View File

@ -2,5 +2,5 @@
pragma solidity >=0.8.4;
contract Foo {
// solhint-disable-previous-line no-empty-blocks
// solhint-disable-previous-line no-empty-blocks
}

View File

@ -8,6 +8,7 @@ import { StdCheats } from "forge-std/StdCheats.sol";
/// @dev See the "Writing Tests" section in the Foundry Book if this is your first time with Forge.
/// https://book.getfoundry.sh/forge/writing-tests
contract FooTest is PRBTest, StdCheats {
/// @dev An optional function invoked before each test case is run
function setUp() public {
// solhint-disable-previous-line no-empty-blocks
}

View File

@ -310,10 +310,8 @@ __metadata:
husky: ^8.0.2
lint-staged: ^13.0.3
prettier: ^2.7.1
prettier-plugin-solidity: ^1.0.0
rimraf: ^3.0.2
solhint: ^3.3.7
solhint-plugin-prettier: ^0.0.5
languageName: unknown
linkType: soft
@ -1245,13 +1243,6 @@ __metadata:
languageName: node
linkType: hard
"emoji-regex@npm:^10.2.1":
version: 10.2.1
resolution: "emoji-regex@npm:10.2.1"
checksum: 1aa2d16881c56531fdfc03d0b36f5c2b6221cc4097499a5665b88b711dc3fb4d5b8804f0ca6f00c56e5dcf89bac75f0487eee85da1da77df3a33accc6ecbe426
languageName: node
linkType: hard
"emoji-regex@npm:^7.0.1":
version: 7.0.3
resolution: "emoji-regex@npm:7.0.3"
@ -1296,13 +1287,6 @@ __metadata:
languageName: node
linkType: hard
"escape-string-regexp@npm:^4.0.0":
version: 4.0.0
resolution: "escape-string-regexp@npm:4.0.0"
checksum: 98b48897d93060f2322108bf29db0feba7dd774be96cd069458d1453347b25ce8682ecc39859d4bca2203cc0ab19c237bcc71755eff49a0f8d90beadeeba5cc5
languageName: node
linkType: hard
"eslint-scope@npm:^4.0.3":
version: 4.0.3
resolution: "eslint-scope@npm:4.0.3"
@ -2823,31 +2807,6 @@ __metadata:
languageName: node
linkType: hard
"prettier-linter-helpers@npm:^1.0.0":
version: 1.0.0
resolution: "prettier-linter-helpers@npm:1.0.0"
dependencies:
fast-diff: ^1.1.2
checksum: 00ce8011cf6430158d27f9c92cfea0a7699405633f7f1d4a45f07e21bf78e99895911cbcdc3853db3a824201a7c745bd49bfea8abd5fb9883e765a90f74f8392
languageName: node
linkType: hard
"prettier-plugin-solidity@npm:^1.0.0":
version: 1.0.0
resolution: "prettier-plugin-solidity@npm:1.0.0"
dependencies:
"@solidity-parser/parser": ^0.14.5
emoji-regex: ^10.2.1
escape-string-regexp: ^4.0.0
semver: ^7.3.8
solidity-comments-extractor: ^0.0.7
string-width: ^4.2.3
peerDependencies:
prettier: ^2.3.0
checksum: 2ca347d66f12dcb397ce3fcf441563c0413f17c8835bea6422625fb190458a6edbdb7c5775ccc8347f049f55f15443361b8fd3ea546a426b4f521c59a16aaf84
languageName: node
linkType: hard
"prettier@npm:^1.14.3":
version: 1.19.1
resolution: "prettier@npm:1.19.1"
@ -3142,17 +3101,6 @@ __metadata:
languageName: node
linkType: hard
"semver@npm:^7.3.8":
version: 7.3.8
resolution: "semver@npm:7.3.8"
dependencies:
lru-cache: ^6.0.0
bin:
semver: bin/semver.js
checksum: ba9c7cbbf2b7884696523450a61fee1a09930d888b7a8d7579025ad93d459b2d1949ee5bbfeb188b2be5f4ac163544c5e98491ad6152df34154feebc2cc337c1
languageName: node
linkType: hard
"shebang-command@npm:^1.2.0":
version: 1.2.0
resolution: "shebang-command@npm:1.2.0"
@ -3235,18 +3183,6 @@ __metadata:
languageName: node
linkType: hard
"solhint-plugin-prettier@npm:^0.0.5":
version: 0.0.5
resolution: "solhint-plugin-prettier@npm:0.0.5"
dependencies:
prettier-linter-helpers: ^1.0.0
peerDependencies:
prettier: ^1.15.0 || ^2.0.0
prettier-plugin-solidity: ^1.0.0-alpha.14
checksum: ca721e327daf49a4d9ef0ee5c9622482a8c5563d600eedfd3856c69ce67e416dd77da5166a033e2e641c9cdd7a0f2cbc7913b0eb1712081b3c7e8c633eef82a5
languageName: node
linkType: hard
"solhint@npm:^3.3.7":
version: 3.3.7
resolution: "solhint@npm:3.3.7"
@ -3275,13 +3211,6 @@ __metadata:
languageName: node
linkType: hard
"solidity-comments-extractor@npm:^0.0.7":
version: 0.0.7
resolution: "solidity-comments-extractor@npm:0.0.7"
checksum: a5cedf2310709969bc1783a6c336171478536f2f0ea96ad88437e0ef1e8844c0b37dd75591b0a824ec9c30640ea7e31b5f03128e871e6235bef3426617ce96c4
languageName: node
linkType: hard
"source-map-support@npm:^0.5.16":
version: 0.5.21
resolution: "source-map-support@npm:0.5.21"