Skip to content

Commit 047d3a3

Browse files
committed
add linting
1 parent b39a99e commit 047d3a3

File tree

14 files changed

+356
-331
lines changed

14 files changed

+356
-331
lines changed

.eslintrc.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module.exports = {
2+
env: {
3+
browser: true,
4+
es2021: true,
5+
node: true,
6+
},
7+
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:prettier/recommended"],
8+
overrides: [],
9+
parser: "@typescript-eslint/parser",
10+
parserOptions: {
11+
ecmaVersion: "latest",
12+
sourceType: "module",
13+
},
14+
plugins: ["@typescript-eslint", "no-only-tests"],
15+
rules: {},
16+
};

package.json

Lines changed: 84 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,86 @@
11
{
2-
"name": "@safe-global/safe-contracts",
3-
"version": "1.3.0",
4-
"description": "Ethereum multisig contract",
5-
"homepage": "https://github.com/safe-global/safe-contracts/",
6-
"license": "GPL-3.0",
7-
"main": "dist/index.js",
8-
"typings": "dist/index.d.ts",
9-
"files": [
10-
"contracts",
11-
"dist",
12-
"src",
13-
"test",
14-
"build"
15-
],
16-
"scripts": {
17-
"build": "hardhat compile",
18-
"build:ts": "yarn rimraf dist && tsc",
19-
"test": "hardhat test",
20-
"coverage": "hardhat coverage",
21-
"benchmark": "yarn test benchmark/*.ts",
22-
"deploy-custom": "rm -rf deployments/custom && yarn deploy-all custom",
23-
"deploy-all": "hardhat deploy-contracts --network",
24-
"deploy": "hardhat deploy --network",
25-
"lint": "yarn lint:sol && yarn lint:ts",
26-
"lint:sol": "solhint 'contracts/**/*.sol'",
27-
"lint:ts": "eslint --max-warnings 0 .",
28-
"fmt:sol": "prettier 'contracts/**/*.sol' -w",
29-
"fmt:ts": "prettier 'src/**/*.ts' 'test/**/*.ts' -w",
30-
"prepack": "yarn build",
31-
"prepare": "husky install",
32-
"prepublish": "yarn rimraf build && yarn build && yarn build:ts"
33-
},
34-
"repository": {
35-
"type": "git",
36-
"url": "git+https://github.com/safe-global/safe-contracts.git"
37-
},
38-
"keywords": [
39-
"Ethereum",
40-
"Wallet",
41-
"Safe"
42-
],
43-
"author": "richard@safe.global",
44-
"bugs": {
45-
"url": "https://github.com/safe-global/safe-contracts/issues"
46-
},
47-
"devDependencies": {
48-
"@gnosis.pm/mock-contract": "^4.0.0",
49-
"@gnosis.pm/safe-singleton-factory": "^1.0.3",
50-
"@nomiclabs/hardhat-ethers": "2.0.2",
51-
"@nomiclabs/hardhat-etherscan": "^2.1.0",
52-
"@nomiclabs/hardhat-waffle": "2.0.1",
53-
"@openzeppelin/contracts": "^3.4.0",
54-
"@types/chai": "^4.2.14",
55-
"@types/mocha": "^8.2.0",
56-
"@types/node": "^14.14.21",
57-
"@types/yargs": "^15.0.10",
58-
"@typescript-eslint/eslint-plugin": "^4.7.0",
59-
"@typescript-eslint/parser": "^4.7.0",
60-
"argv": "^0.0.2",
61-
"chai": "^4.2.0",
62-
"debug": "^4.2.0",
63-
"dotenv": "^8.0.0",
64-
"eslint": "^7.13.0",
65-
"eslint-config-prettier": "^6.15.0",
66-
"eslint-plugin-import": "^2.22.1",
67-
"eslint-plugin-no-only-tests": "^2.4.0",
68-
"eslint-plugin-prettier": "^3.1.4",
69-
"ethereum-waffle": "^3.3.0",
70-
"ethers": "5.4.0",
71-
"hardhat": "^2.2.1",
72-
"hardhat-deploy": "0.9.2",
73-
"husky": "^5.1.3",
74-
"prettier": "^2.8.3",
75-
"prettier-plugin-solidity": "1.1.1",
76-
"solc": "0.7.6",
77-
"solhint": "3.3.8",
78-
"solhint-plugin-prettier": "0.0.5",
79-
"solidity-coverage": "^0.7.17",
80-
"ts-node": "^9.1.1",
81-
"typescript": "^4.2.4",
82-
"yargs": "^16.1.1"
83-
},
84-
"peerDependencies": {
85-
"ethers": "5.4.0"
86-
}
2+
"name": "@safe-global/safe-contracts",
3+
"version": "1.3.0",
4+
"description": "Ethereum multisig contract",
5+
"homepage": "https://github.com/safe-global/safe-contracts/",
6+
"license": "GPL-3.0",
7+
"main": "dist/index.js",
8+
"typings": "dist/index.d.ts",
9+
"files": [
10+
"contracts",
11+
"dist",
12+
"src",
13+
"test",
14+
"build"
15+
],
16+
"scripts": {
17+
"build": "hardhat compile",
18+
"build:ts": "yarn rimraf dist && tsc",
19+
"test": "hardhat test",
20+
"coverage": "hardhat coverage",
21+
"benchmark": "yarn test benchmark/*.ts",
22+
"deploy-custom": "rm -rf deployments/custom && yarn deploy-all custom",
23+
"deploy-all": "hardhat deploy-contracts --network",
24+
"deploy": "hardhat deploy --network",
25+
"lint": "yarn lint:sol && yarn lint:ts",
26+
"lint:sol": "solhint 'contracts/**/*.sol'",
27+
"lint:ts": "eslint 'src/**/*.ts' 'test/**/*.ts' --max-warnings 0 --fix",
28+
"fmt:sol": "prettier 'contracts/**/*.sol' -w",
29+
"fmt:ts": "prettier 'src/**/*.ts' 'test/**/*.ts' -w",
30+
"prepack": "yarn build",
31+
"prepare": "husky install",
32+
"prepublish": "yarn rimraf build && yarn build && yarn build:ts"
33+
},
34+
"repository": {
35+
"type": "git",
36+
"url": "git+https://github.com/safe-global/safe-contracts.git"
37+
},
38+
"keywords": [
39+
"Ethereum",
40+
"Wallet",
41+
"Safe"
42+
],
43+
"author": "richard@safe.global",
44+
"bugs": {
45+
"url": "https://github.com/safe-global/safe-contracts/issues"
46+
},
47+
"devDependencies": {
48+
"@gnosis.pm/mock-contract": "^4.0.0",
49+
"@gnosis.pm/safe-singleton-factory": "^1.0.3",
50+
"@nomiclabs/hardhat-ethers": "2.0.2",
51+
"@nomiclabs/hardhat-etherscan": "^2.1.0",
52+
"@nomiclabs/hardhat-waffle": "2.0.1",
53+
"@openzeppelin/contracts": "^3.4.0",
54+
"@types/chai": "^4.2.14",
55+
"@types/mocha": "^8.2.0",
56+
"@types/node": "^14.14.21",
57+
"@types/yargs": "^15.0.10",
58+
"@typescript-eslint/eslint-plugin": "^5.49.0",
59+
"@typescript-eslint/parser": "^5.49.0",
60+
"argv": "^0.0.2",
61+
"chai": "^4.2.0",
62+
"debug": "^4.2.0",
63+
"dotenv": "^8.0.0",
64+
"eslint": "^8.32.0",
65+
"eslint-config-prettier": "^8.6.0",
66+
"eslint-plugin-no-only-tests": "^3.1.0",
67+
"eslint-plugin-prettier": "^4.2.1",
68+
"ethereum-waffle": "^3.3.0",
69+
"ethers": "5.4.0",
70+
"hardhat": "^2.2.1",
71+
"hardhat-deploy": "0.9.2",
72+
"husky": "^5.1.3",
73+
"prettier": "^2.8.3",
74+
"prettier-plugin-solidity": "1.1.1",
75+
"solc": "0.7.6",
76+
"solhint": "3.3.8",
77+
"solhint-plugin-prettier": "0.0.5",
78+
"solidity-coverage": "^0.7.17",
79+
"ts-node": "^9.1.1",
80+
"typescript": "^4.2.4",
81+
"yargs": "^16.1.1"
82+
},
83+
"peerDependencies": {
84+
"ethers": "5.4.0"
85+
}
8786
}

src/tasks/local_verify.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ task("local-verify", "Verifies that the local deployment files correspond to the
88
const deployedContracts = await hre.deployments.all();
99
for (const contract of Object.keys(deployedContracts)) {
1010
const deployment = await hre.deployments.get(contract);
11-
const meta = JSON.parse(deployment.metadata!!);
11+
const meta = JSON.parse(deployment.metadata!);
1212
const solcjs = await loadSolc(meta.compiler.version);
1313
delete meta.compiler;
1414
delete meta.output;

src/utils/execution.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export const safeSignTypedData = async (
100100
chainId?: BigNumberish,
101101
): Promise<SafeSignature> => {
102102
if (!chainId && !signer.provider) throw Error("Provider required to retrieve chainId");
103-
const cid = chainId || (await signer.provider!!.getNetwork()).chainId;
103+
const cid = chainId || (await signer.provider!.getNetwork()).chainId;
104104
const signerAddress = await signer.getAddress();
105105
return {
106106
signer: signerAddress,
@@ -123,7 +123,7 @@ export const safeSignMessage = async (
123123
safeTx: SafeTransaction,
124124
chainId?: BigNumberish,
125125
): Promise<SafeSignature> => {
126-
const cid = chainId || (await signer.provider!!.getNetwork()).chainId;
126+
const cid = chainId || (await signer.provider!.getNetwork()).chainId;
127127
return signHash(signer, calculateSafeTransactionHash(safe, safeTx, cid));
128128
};
129129

test/accessors/SimulateTxAccessor.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { expect } from "chai";
22
import hre, { deployments, waffle } from "hardhat";
33
import "@nomiclabs/hardhat-ethers";
44
import { deployContract, getSimulateTxAccessor, getSafeWithOwners, getCompatFallbackHandler } from "../utils/setup";
5-
import { buildContractCall, executeTx, executeTxWithSigners } from "../../src/utils/execution";
5+
import { buildContractCall, executeTxWithSigners } from "../../src/utils/execution";
66
import { parseEther } from "ethers/lib/utils";
77

88
describe("SimulateTxAccessor", async () => {
@@ -43,7 +43,7 @@ describe("SimulateTxAccessor", async () => {
4343
const killLib = await deployContract(user1, killLibSource);
4444
const tx = buildContractCall(killLib, "killme", [], 0);
4545

46-
let code = await hre.ethers.provider.getCode(accessor.address);
46+
const code = await hre.ethers.provider.getCode(accessor.address);
4747
await expect(accessor.simulate(tx.to, tx.value, tx.data, tx.operation)).to.be.revertedWith(
4848
"SimulateTxAccessor should only be called via delegatecall",
4949
);
@@ -78,7 +78,7 @@ describe("SimulateTxAccessor", async () => {
7878
});
7979

8080
it("simulate selfdestruct", async () => {
81-
const { safe, accessor, interactor, simulator } = await setupTests();
81+
const { safe, accessor, simulator } = await setupTests();
8282
const expectedCode = await hre.ethers.provider.getCode(safe.address);
8383
await user1.sendTransaction({ to: safe.address, value: parseEther("1") });
8484
const killLib = await deployContract(user1, killLibSource);

test/core/Safe.Execution.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ describe("Safe", async () => {
185185
return tx;
186186
}),
187187
).to.emit(safe, "ExecutionSuccess");
188-
const receipt = await hre.ethers.provider.getTransactionReceipt(executedTx!!.hash);
188+
const receipt = await hre.ethers.provider.getTransactionReceipt(executedTx!.hash);
189189
const logIndex = receipt.logs.length - 1;
190190
const successEvent = safe.interface.decodeEventLog(
191191
"ExecutionSuccess",
@@ -222,7 +222,7 @@ describe("Safe", async () => {
222222
return tx;
223223
}),
224224
).to.emit(safe, "ExecutionFailure");
225-
const receipt = await hre.ethers.provider.getTransactionReceipt(executedTx!!.hash);
225+
const receipt = await hre.ethers.provider.getTransactionReceipt(executedTx!.hash);
226226
const logIndex = receipt.logs.length - 1;
227227
const successEvent = safe.interface.decodeEventLog(
228228
"ExecutionFailure",

test/core/Safe.Incoming.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe("Safe", async () => {
99

1010
const setupTests = deployments.createFixture(async ({ deployments }) => {
1111
await deployments.fixture();
12-
let source = `
12+
const source = `
1313
contract Test {
1414
function transferEth(address payable safe) public payable returns (bool success) {
1515
safe.transfer(msg.value);

test/factory/ProxyFactory.spec.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ describe("ProxyFactory", async () => {
178178

179179
it("check callback is invoked", async () => {
180180
const { factory, mock, singleton } = await setupTests();
181-
let callback = await hre.ethers.getContractAt("IProxyCreationCallback", mock.address);
181+
const callback = await hre.ethers.getContractAt("IProxyCreationCallback", mock.address);
182182
const initCode = singleton.interface.encodeFunctionData("init", []);
183183

184184
const proxyAddress = await calculateProxyAddressWithCallback(factory, singleton.address, initCode, saltNonce, mock.address);
@@ -188,7 +188,12 @@ describe("ProxyFactory", async () => {
188188

189189
expect(await mock.callStatic.invocationCount()).to.be.deep.equal(BigNumber.from(1));
190190

191-
let callbackData = callback.interface.encodeFunctionData("proxyCreated", [proxyAddress, factory.address, initCode, saltNonce]);
191+
const callbackData = callback.interface.encodeFunctionData("proxyCreated", [
192+
proxyAddress,
193+
factory.address,
194+
initCode,
195+
saltNonce,
196+
]);
192197
expect(await mock.callStatic.invocationCountForMethod(callbackData)).to.be.deep.equal(BigNumber.from(1));
193198
});
194199

test/handlers/CompatibilityFallbackHandler.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ describe("CompatibilityFallbackHandler", async () => {
181181
});
182182

183183
describe("simulate", async () => {
184+
// eslint-disable-next-line @typescript-eslint/no-empty-function
184185
it.skip("can be called for any Safe", async () => {});
185186

186187
it("should revert changes", async () => {

test/integration/Safe.ReservedAddresses.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe("Safe", async () => {
2121

2222
expect(await safe.isOwner(AddressOne)).to.be.false;
2323

24-
let sig =
24+
const sig =
2525
"0x" +
2626
"0000000000000000000000000000000000000000000000000000000000000001" +
2727
"0000000000000000000000000000000000000000000000000000000000000000" +

0 commit comments

Comments
 (0)