chore: config linting, formatting and git hooks

This commit is contained in:
gitpusha 2020-10-07 19:45:46 +02:00 committed by Twin Fish
parent 7295ad39fe
commit fc92050590
11 changed files with 1643 additions and 2109 deletions

View File

@ -21,6 +21,12 @@ jobs: # a collection of steps
- run: # Compile - run: # Compile
name: Compile name: Compile
command: npx buidler compile command: npx buidler compile
- run: # Formatting
name: Prettier Check
command: yarn prettier --check .
- run: # Linting
name: ESLint
command: yarn eslint .
- run: # Tests - run: # Tests
name: Tests using buidler-ganache mainnet fork name: Tests using buidler-ganache mainnet fork
command: npx buidler test command: npx buidler test

13
.eslintrc.json Normal file
View File

@ -0,0 +1,13 @@
{
"env": {
"commonjs": true,
"es2021": true,
"node": true,
"mocha": true
},
"extends": ["eslint:recommended", "prettier"],
"parserOptions": {
"ecmaVersion": 12
},
"rules": {}
}

3
.gitignore vendored
View File

@ -8,6 +8,9 @@ node_modules
artifacts/ artifacts/
cache/ cache/
# ESLint
.eslintcache
# macOS # macOS
.DS_Store .DS_Store
*.icloud *.icloud

9
.prettierignore Normal file
View File

@ -0,0 +1,9 @@
# Ignore artifacts:
#artifacts
cache
assets
coverage
# Solidity
contracts
#pre-compiles

1
.prettierrc.json Normal file
View File

@ -0,0 +1 @@
{}

20
.vscode/settings.json vendored
View File

@ -1,19 +1,5 @@
{ {
// HTML "editor.defaultFormatter": "esbenp.prettier-vscode",
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
// Javascript
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
// JSON
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
// Solidity // Solidity
"solidity.formatter": "none", "solidity.formatter": "none",
"solidity.linter": "solhint", "solidity.linter": "solhint",
@ -21,9 +7,5 @@
"solidity.packageDefaultDependenciesDirectory": "node_modules", "solidity.packageDefaultDependenciesDirectory": "node_modules",
"solidity.solhintRules": { "solidity.solhintRules": {
"quotes": ["error", "double"] "quotes": ["error", "double"]
},
// Typscript
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
} }
} }

View File

@ -1,3 +1,6 @@
// Buidler
const { task, usePlugin, types } = require("@nomiclabs/buidler/config");
// Libraries // Libraries
const assert = require("assert"); const assert = require("assert");
const { utils } = require("ethers"); const { utils } = require("ethers");
@ -114,13 +117,13 @@ task(
) )
.addOptionalParam("gelatocoreaddress") .addOptionalParam("gelatocoreaddress")
.addFlag("log", "Logs return values to stdout") .addFlag("log", "Logs return values to stdout")
.setAction(async (taskArgs) => { .setAction(async (taskArgs, bre) => {
try { try {
const gelatoCore = await ethers.getContractAt( const gelatoCore = await bre.ethers.getContractAt(
GelatoCoreLib.GelatoCore.abi, GelatoCoreLib.GelatoCore.abi,
taskArgs.gelatocoreaddress taskArgs.gelatocoreaddress
? taskArgs.gelatocoreaddress ? taskArgs.gelatocoreaddress
: network.config.GelatoCore : bre.network.config.GelatoCore
); );
const oracleAbi = ["function latestAnswer() view returns (int256)"]; const oracleAbi = ["function latestAnswer() view returns (int256)"];
@ -128,7 +131,7 @@ task(
const gelatoGasPriceOracleAddress = await gelatoCore.gelatoGasPriceOracle(); const gelatoGasPriceOracleAddress = await gelatoCore.gelatoGasPriceOracle();
// Get gelatoGasPriceOracleAddress // Get gelatoGasPriceOracleAddress
const gelatoGasPriceOracle = await ethers.getContractAt( const gelatoGasPriceOracle = await bre.ethers.getContractAt(
oracleAbi, oracleAbi,
gelatoGasPriceOracleAddress gelatoGasPriceOracleAddress
); );

View File

@ -5,18 +5,39 @@
"repository": "https://github.com/gelatodigital/gelato-instadapp", "repository": "https://github.com/gelatodigital/gelato-instadapp",
"author": "gitpusha", "author": "gitpusha",
"private": false, "private": false,
"scripts": {}, "scripts": {
"rebase": "HUSKY_SKIP_HOOKS=1 git rebase",
"compile": "npx buidler compile",
"format": "prettier --write .",
"lint": "eslint --cache .",
"lint:fix": "eslint --cache --fix .",
"test": "npx buidler test"
},
"devDependencies": { "devDependencies": {
"@gelatonetwork/core": "0.5.3", "@gelatonetwork/core": "0.5.3",
"@nomiclabs/buidler": "1.4.7", "@nomiclabs/buidler": "1.4.7",
"@nomiclabs/buidler-ethers": "2.0.0", "@nomiclabs/buidler-ethers": "2.0.2",
"@nomiclabs/buidler-ganache": "^1.3.3", "@nomiclabs/buidler-ganache": "1.3.3",
"@nomiclabs/buidler-waffle": "2.1.0", "@nomiclabs/buidler-waffle": "2.1.0",
"chai": "^4.2.0", "chai": "4.2.0",
"dotenv": "8.2.0", "dotenv": "8.2.0",
"ethereum-waffle": "3.1.0", "eslint": "7.10.0",
"ethers": "5.0.14", "eslint-config-prettier": "6.12.0",
"prettier": "2.0.5" "ethereum-waffle": "3.1.1",
"ethers": "5.0.17",
"husky": ">=4",
"lint-staged": ">=10",
"prettier": "2.1.2"
}, },
"dependencies": {} "dependencies": {},
"husky": {
"hooks": {
"pre-commit": "yarn compile; lint-staged;",
"pre-push": "git fetch origin && HUSKY_SKIP_HOOKS=1 git rebase origin/master && yarn compile && lint-staged; yarn test"
}
},
"lint-staged": {
"*.js": "eslint --cache --fix",
"*.{js,css,md}": "prettier --write"
}
} }

View File

@ -4,7 +4,7 @@ const { expect } = require("chai");
const bre = require("@nomiclabs/buidler"); const bre = require("@nomiclabs/buidler");
const { ethers } = bre; const { ethers } = bre;
const GelatoCoreLib = require("@gelatonetwork/core"); const GelatoCoreLib = require("@gelatonetwork/core");
const { sleep } = GelatoCoreLib; //const { sleep } = GelatoCoreLib;
// Constants // Constants
const ETH = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"; const ETH = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";

View File

@ -4,7 +4,7 @@ const { expect } = require("chai");
const bre = require("@nomiclabs/buidler"); const bre = require("@nomiclabs/buidler");
const { ethers } = bre; const { ethers } = bre;
const GelatoCoreLib = require("@gelatonetwork/core"); const GelatoCoreLib = require("@gelatonetwork/core");
const { sleep } = GelatoCoreLib; //const { sleep } = GelatoCoreLib;
// Constants // Constants
const DAI_100 = ethers.utils.parseUnits("100", 18); const DAI_100 = ethers.utils.parseUnits("100", 18);

3646
yarn.lock

File diff suppressed because it is too large Load Diff