Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

chore: synchronise linting rules of repositories #49

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"root": true
}
"extends": ["@matterlabs/eslint-config-typescript"],
"rules": {
"no-multiple-empty-lines": ["error", { "max": 1 }],
"@typescript-eslint/no-namespace": "off",
"import/no-named-as-default-member": "off",
"import/namespace": "off",
"import/no-unresolved": "off",
"import/order": "off"
}
}
16 changes: 16 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

CYAN='\033[0;36m'
NC='\033[0m' # No Color
RED='\033[0;31m'

# Check that the code is formatted in the given directory provided in the first argument
function check_prettier {
if ! yarn prettier:check; then
echo "${RED}Commit error! Cannot commit unformatted code!${NC}"
echo "Prettier errors found. Please format the code via ${CYAN}yarn prettier:fix${NC}!"
exit 1
fi
}

check_prettier
16 changes: 16 additions & 0 deletions .githooks/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

CYAN='\033[0;36m'
NC='\033[0m' # No Color
RED='\033[0;31m'

# Checking that the code is linted and formatted in the given directory provided in the first argument
function check_lint {
if ! yarn lint:check; then
echo "${RED}Push error! Cannot push unlinted code!${NC}"
echo "Lint errors found. Please lint the code via ${CYAN}yarn lint:fix${NC} and/or fix the errors manually!"
exit 1
fi
}

check_lint
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
name: Scripts-Related Bug Report
about: Use this template for reporting script related bugs. For contract bugs, see our security policy.
title: ''
title: ""
labels: bug
assignees: ''
assignees: ""
---

### 🐛 Script Bug Report
Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
name: Feature request
about: Use this template for requesting features
title: ''
title: ""
labels: feat
assignees: ''
assignees: ""
---

### 🌟 Feature Request
Expand Down
1 change: 0 additions & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@
- [ ] PR title corresponds to the body of PR (we generate changelog entries from PRs).
- [ ] Tests for the changes have been added / updated.
- [ ] Documentation comments have been added / updated.
- [ ] Code has been formatted via `yarn prettier:write` and `yarn lint:fix`.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
run: yarn

- name: Run lint
run: yarn lint
run: yarn lint:check

check_hashes:
needs: [build]
Expand Down Expand Up @@ -89,7 +89,7 @@ jobs:
bootloader/build

- name: Check hashes
run: yarn calculate-hashes --check-only
run: yarn calculate-hashes:check

test:
needs: [build, lint]
Expand Down
63 changes: 0 additions & 63 deletions .prettierrc

This file was deleted.

16 changes: 16 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
...require("@matterlabs/prettier-config"),
plugins: ["prettier-plugin-solidity"],
overrides: [
{
files: "*.sol",
options: {
bracketSpacing: false,
printWidth: 120,
singleQuote: false,
tabWidth: 4,
useTabs: false,
},
},
],
};
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ This repository is used as a submodule of the [zksync-2-dev](https://github.com/

Compile the solidity and yul contracts: `yarn build`

Check the system contracts hashes: `yarn calculate-hashes --check-only`
Check the system contracts hashes: `yarn calculate-hashes:check`

Update the system contracts hashes: `yarn calculate-hashes`
Update the system contracts hashes: `yarn calculate-hashes:fix`

## Update Process

Expand Down
84 changes: 42 additions & 42 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
import '@matterlabs/hardhat-zksync-chai-matchers';
import '@matterlabs/hardhat-zksync-solc';
import '@nomiclabs/hardhat-ethers';
import '@nomiclabs/hardhat-solpp';
import '@typechain/hardhat';
import "@matterlabs/hardhat-zksync-chai-matchers";
import "@matterlabs/hardhat-zksync-solc";
import "@nomiclabs/hardhat-ethers";
import "@nomiclabs/hardhat-solpp";
import "@typechain/hardhat";

// eslint-disable-next-line @typescript-eslint/no-var-requires
const systemConfig = require('./SystemConfig.json');
const systemConfig = require("./SystemConfig.json");

export default {
zksolc: {
version: '1.3.14',
compilerSource: 'binary',
settings: {
isSystem: true
}
zksolc: {
version: "1.3.14",
compilerSource: "binary",
settings: {
isSystem: true,
},
zkSyncDeploy: {
zkSyncNetwork: 'http://localhost:3050',
ethNetwork: 'http://localhost:8545'
},
zkSyncDeploy: {
zkSyncNetwork: "http://localhost:3050",
ethNetwork: "http://localhost:8545",
},
solidity: {
version: "0.8.17",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
viaIR: true,
},
solidity: {
version: '0.8.17',
settings: {
optimizer: {
enabled: true,
runs: 200
},
viaIR: true
}
},
solpp: {
defs: (() => {
return {
ECRECOVER_COST_GAS: systemConfig.ECRECOVER_COST_GAS,
KECCAK_ROUND_COST_GAS: systemConfig.KECCAK_ROUND_COST_GAS,
SHA256_ROUND_COST_GAS: systemConfig.SHA256_ROUND_COST_GAS,
};
})(),
},
networks: {
hardhat: {
zksync: true,
},
solpp: {
defs: (() => {
return {
ECRECOVER_COST_GAS: systemConfig.ECRECOVER_COST_GAS,
KECCAK_ROUND_COST_GAS: systemConfig.KECCAK_ROUND_COST_GAS,
SHA256_ROUND_COST_GAS: systemConfig.SHA256_ROUND_COST_GAS
};
})()
zkSyncTestNode: {
url: "http://127.0.0.1:8011",
ethNetwork: "",
zksync: true,
},
networks: {
hardhat: {
zksync: true
},
zkSyncTestNode: {
url: 'http://127.0.0.1:8011',
ethNetwork: '',
zksync: true
}
}
},
};
18 changes: 12 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
"zksync-web3": "^0.14.3"
},
"devDependencies": {
"@matterlabs/eslint-config-typescript": "^1.1.2",
"@matterlabs/hardhat-zksync-chai-matchers": "^0.1.4",
"@matterlabs/hardhat-zksync-solc": "^0.4.2",
"@matterlabs/prettier-config": "^1.0.3",
"@nomicfoundation/hardhat-chai-matchers": "^1.0.3",
"@nomiclabs/hardhat-ethers": "^2.0.6",
"@typechain/ethers-v5": "^10.0.0",
Expand All @@ -26,8 +28,11 @@
"@typescript-eslint/eslint-plugin": "^6.7.4",
"@typescript-eslint/parser": "^6.7.4",
"chai": "^4.3.6",
"lodash": "^4.17.21",
"eslint": "^8.51.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-prettier": "^5.0.1",
"lodash": "^4.17.21",
"markdownlint-cli": "^0.33.0",
"mocha": "^10.0.0",
"prettier": "^3.0.3",
Expand All @@ -52,20 +57,21 @@
"build": "yarn build:sol && yarn build:yul",
"build:sol": "hardhat compile",
"build:yul": "yarn preprocess:yul && yarn compile-yul",
"calculate-hashes": "ts-node scripts/calculate-hashes.ts",
"calculate-hashes:check": "ts-node scripts/calculate-hashes.ts --check-only",
"calculate-hashes:fix": "ts-node scripts/calculate-hashes.ts",
"clean": "yarn clean:sol && yarn clean:yul",
"clean:sol": "hardhat clean",
"clean:yul": "rm -rf ./bootloader/build ./bootloader/tests/artifacts ./contracts/artifacts ./contracts/precompiles/artifacts",
"compile-yul": "ts-node scripts/compile-yul.ts",
"deploy-preimages": "ts-node scripts/deploy-preimages.ts",
"lint": "yarn lint:md && yarn lint:sol && yarn lint:ts && yarn prettier:check",
"lint:fix": "yarn lint:md --fix && yarn lint:sol --fix && yarn lint:ts --fix && yarn prettier:write",
"lint:md": "markdownlint **/*.md",
"lint:check": "yarn lint:md && yarn lint:sol && yarn lint:ts && yarn prettier:check",
"lint:fix": "yarn lint:md --fix && yarn lint:sol --fix && yarn lint:ts --fix && yarn prettier:fix",
"lint:md": "markdownlint \"**/*.md\"",
"lint:sol": "solhint \"contracts/**/*.sol\"",
"lint:ts": "eslint .",
"preprocess:yul": "rm -rf ./bootloader/build && yarn ts-node scripts/process.ts",
"prettier:check": "prettier --check \"**/*.{js,json,md,sol,ts,yaml}\"",
"prettier:write": "prettier --write \"**/*.{js,json,md,sol,ts,yaml}\"",
"prettier:fix": "prettier --write \"**/*.{js,json,md,sol,ts,yaml}\"",
"test": "hardhat test --network zkSyncTestNode",
"test:bootloader": "cd bootloader/test_infra && cargo run"
}
Expand Down
Loading
Loading