From b1ff9747365e869ee7a42654c120cf26c642ad03 Mon Sep 17 00:00:00 2001 From: boyuanx Date: Wed, 1 Jan 2025 10:48:33 -0800 Subject: [PATCH] Use `forge fmt` as formatter --- .prettierignore | 3 ++- .vscode/settings.json | 3 +++ package.json | 4 ++-- src/Counter.sol | 6 +++--- src/CounterUpgradeable.sol | 8 ++++---- test/Counter.t.sol | 4 ++-- 6 files changed, 16 insertions(+), 12 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.prettierignore b/.prettierignore index f01bdcb..30a85b5 100644 --- a/.prettierignore +++ b/.prettierignore @@ -20,4 +20,5 @@ bun.lockb lcov.info package-lock.json pnpm-lock.yaml -yarn.lock \ No newline at end of file +yarn.lock +*.sol \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..5b3ca6c --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "solidity.formatter": "forge" +} diff --git a/package.json b/package.json index ad9f8df..f53f2ee 100644 --- a/package.json +++ b/package.json @@ -11,8 +11,8 @@ "build": "forge build && hardhat compile", "build:hh": "hardhat compile", "lint:sol": "forge fmt --check && solhint {script,src,test}/**/*.sol", - "prettier:check": "prettier --check **/*.{json,md,yml} --ignore-path=.prettierignore", - "prettier:write": "prettier --write **/*.{json,md,yml} --ignore-path=.prettierignore", + "prettier:check": "prettier --check **/*.{json,md,yml,ts} --ignore-path=.prettierignore", + "prettier:write": "prettier --write **/*.{json,md,yml,ts} --ignore-path=.prettierignore", "test": "forge test", "test:coverage": "forge coverage" }, diff --git a/src/Counter.sol b/src/Counter.sol index 1d8b97b..d7ad218 100644 --- a/src/Counter.sol +++ b/src/Counter.sol @@ -1,14 +1,14 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.13; -import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; +import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; contract Counter is Ownable { uint256 public number; - constructor() Ownable(_msgSender()) {} + constructor() Ownable(_msgSender()) { } - function setNumber(uint256 newNumber) public onlyOwner() { + function setNumber(uint256 newNumber) public onlyOwner { number = newNumber; } diff --git a/src/CounterUpgradeable.sol b/src/CounterUpgradeable.sol index 7226d08..184601c 100644 --- a/src/CounterUpgradeable.sol +++ b/src/CounterUpgradeable.sol @@ -2,8 +2,8 @@ // solhint-disable no-empty-blocks pragma solidity ^0.8.13; -import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; -import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; +import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; +import { UUPSUpgradeable } from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; contract CounterUpgradeable is OwnableUpgradeable, UUPSUpgradeable { uint256 public number; @@ -12,7 +12,7 @@ contract CounterUpgradeable is OwnableUpgradeable, UUPSUpgradeable { __Ownable_init(_msgSender()); } - function setNumber(uint256 newNumber) public onlyOwner() { + function setNumber(uint256 newNumber) public onlyOwner { number = newNumber; } @@ -20,5 +20,5 @@ contract CounterUpgradeable is OwnableUpgradeable, UUPSUpgradeable { number++; } - function _authorizeUpgrade(address newImplementation) internal override onlyOwner() {} + function _authorizeUpgrade(address newImplementation) internal override onlyOwner { } } diff --git a/test/Counter.t.sol b/test/Counter.t.sol index 4831910..1b446c3 100644 --- a/test/Counter.t.sol +++ b/test/Counter.t.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.13; -import {Test} from "forge-std/Test.sol"; -import {Counter} from "../src/Counter.sol"; +import { Test } from "forge-std/Test.sol"; +import { Counter } from "../src/Counter.sol"; contract CounterTest is Test { Counter public counter;