Skip to content

Commit

Permalink
chore(ci): add some love to imports
Browse files Browse the repository at this point in the history
  • Loading branch information
tamtamchik committed Feb 8, 2024
1 parent 624bdbc commit 537e340
Show file tree
Hide file tree
Showing 30 changed files with 148 additions and 78 deletions.
18 changes: 16 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,26 @@
"parser": "@typescript-eslint/parser",
"extends": ["plugin:@typescript-eslint/recommended", "prettier"],
"parserOptions": { "ecmaVersion": 2022, "sourceType": "module" },
"plugins": ["no-only-tests"],
"plugins": ["no-only-tests", "simple-import-sort"],
"rules": {
"@typescript-eslint/no-explicit-any": ["warn"],
"@typescript-eslint/no-unused-vars": ["warn"],
// prevents committing `describe.only` and `it.only` tests
"no-only-tests/no-only-tests": "warn"
"no-only-tests/no-only-tests": "warn",
"simple-import-sort/imports": ["error",{
"groups": [
["^node:"],
["^\\u0000"],
["^[^@]\\w"],
["^@\\w"],
["^typechain-types"],
["^lib"],
["^test"],
["^../"],
["^./"],
["^"]
]
}]
},
"overrides": [
{
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ jobs:
run: pnpm hardhat compile

- name: Run TypeScript types check
run: pnpm type:check
run: pnpm type:check
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ coverage.json
/cache
/artifacts

.env
.env
8 changes: 5 additions & 3 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import path from "node:path";

import "@nomicfoundation/hardhat-chai-matchers";
import "@nomicfoundation/hardhat-toolbox";
import "@typechain/hardhat";

import "solidity-coverage";
import "tsconfig-paths/register";
import { globSync } from "glob";
import { TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS } from "hardhat/builtin-tasks/task-names";
import { HardhatUserConfig, subtask } from "hardhat/config";
import path from "path";
import "solidity-coverage";
import "tsconfig-paths/register";

const config: HardhatUserConfig = {
defaultNetwork: "hardhat",
Expand Down
1 change: 1 addition & 0 deletions lib/address.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Wallet } from "ethers";

import { streccak } from "./keccak";

export function randomAddress() {
Expand Down
7 changes: 5 additions & 2 deletions lib/aragon.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { BaseContract } from "ethers";

import { HardhatEthersSigner } from "@nomicfoundation/hardhat-ethers/signers";

import {
ACL__factory,
DAOFactory__factory,
Expand All @@ -8,10 +11,10 @@ import {
Kernel__factory,
Lido__factory,
} from "typechain-types";

import { dummyLocator } from "./dummy";
import { findEvents } from "./event";
import { streccak } from "./keccak";
import { BaseContract } from "ethers";
import { dummyLocator } from "./dummy";
import { ether } from "./units";

export async function createAragonDao(rootAccount: HardhatEthersSigner) {
Expand Down
5 changes: 4 additions & 1 deletion lib/dummy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { HardhatEthersSigner } from "@nomicfoundation/hardhat-ethers/signers";
import { ethers } from "hardhat";

import { HardhatEthersSigner } from "@nomicfoundation/hardhat-ethers/signers";

import { LidoLocator, LidoLocator__factory } from "typechain-types";

import { certainAddress } from ".";

export async function dummyLocator(config?: Partial<LidoLocator.ConfigStruct>, deployer?: HardhatEthersSigner) {
Expand Down
3 changes: 2 additions & 1 deletion lib/ec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ECDSASignature, bufferToHex, ecrecover, ecsign, pubToAddress, toChecksumAddress } from "ethereumjs-util";
import { bufferToHex, ECDSASignature, ecrecover, ecsign, pubToAddress, toChecksumAddress } from "ethereumjs-util";

import { de0x } from "./string";

export function sign(message: string, privateKey: string) {
Expand Down
6 changes: 4 additions & 2 deletions lib/eip712.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { toBuffer } from "ethereumjs-util";
import { AbiCoder, HDNodeWallet, keccak256, solidityPackedKeccak256 } from "ethers";
import { network } from "hardhat";
import { PermitSigner } from "typechain-types/*";

import { PermitSigner } from "typechain-types";

Check failure on line 5 in lib/eip712.ts

View workflow job for this annotation

GitHub Actions / TypeScript types check

Module '"typechain-types"' has no exported member 'PermitSigner'.

import { sign } from "./ec";
import { streccak } from "./keccak";
import { de0x } from "./string";
import { toBuffer } from "ethereumjs-util";

interface DeriveDomainSeparatorArgs {
type: string;
Expand Down
4 changes: 3 additions & 1 deletion lib/proxy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { BaseContract, BytesLike } from "ethers";

import { HardhatEthersSigner } from "@nomicfoundation/hardhat-ethers/signers";
import { OssifiableProxy, OssifiableProxy__factory } from "../typechain-types";

import { OssifiableProxy, OssifiableProxy__factory } from "typechain-types";

interface ProxifyArgs<T> {
impl: T;
Expand Down
3 changes: 2 additions & 1 deletion lib/snapshot.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { HardhatEthersProvider } from "@nomicfoundation/hardhat-ethers/internal/hardhat-ethers-provider";
import { ethers } from "hardhat";

import { HardhatEthersProvider } from "@nomicfoundation/hardhat-ethers/internal/hardhat-ethers-provider";

export class Snapshot {
private static provider: HardhatEthersProvider = ethers.provider;

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"eslint": "^8.48.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-no-only-tests": "^3.1.0",
"eslint-plugin-simple-import-sort": "10.0.0",
"ethereumjs-util": "^7.1.5",
"ethers": "^6.4.0",
"glob": "^10.3.10",
Expand Down
11 changes: 11 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions test/0.4.24/lido.finalizeUpgrade_v2.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { HardhatEthersSigner } from "@nomicfoundation/hardhat-ethers/signers";
import { time } from "@nomicfoundation/hardhat-network-helpers";
import { expect } from "chai";
import { MaxUint256, ZeroAddress } from "ethers";
import { ethers } from "hardhat";
import { INITIAL_STETH_HOLDER, certainAddress, dummyLocator, proxify } from "lib/address";

import { HardhatEthersSigner } from "@nomicfoundation/hardhat-ethers/signers";
import { time } from "@nomicfoundation/hardhat-network-helpers";

import {
LidoInitializedForFinalizeUpgradeV2,
LidoInitializedForFinalizeUpgradeV2__factory,
LidoLocator,
} from "typechain-types";

import { certainAddress, dummyLocator, INITIAL_STETH_HOLDER, proxify } from "lib/address";

describe("Lido:finalizeUpgrade_v2", () => {
let deployer: HardhatEthersSigner;

Expand Down
11 changes: 7 additions & 4 deletions test/0.4.24/lido.initialize.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { HardhatEthersSigner } from "@nomicfoundation/hardhat-ethers/signers";
import { time } from "@nomicfoundation/hardhat-network-helpers";
import { expect } from "chai";
import { MaxUint256, ZeroAddress } from "ethers";
import { ethers } from "hardhat";
import { INITIAL_STETH_HOLDER, certainAddress, dummyLocator, proxify } from "lib/address";
import { Lido, LidoLocator, Lido__factory } from "typechain-types";

import { HardhatEthersSigner } from "@nomicfoundation/hardhat-ethers/signers";
import { time } from "@nomicfoundation/hardhat-network-helpers";

import { Lido, Lido__factory, LidoLocator } from "typechain-types";

import { certainAddress, dummyLocator, INITIAL_STETH_HOLDER, proxify } from "lib/address";

describe("Lido:initialize", () => {
let deployer: HardhatEthersSigner;
Expand Down
7 changes: 5 additions & 2 deletions test/0.4.24/lido.staking-control.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { HardhatEthersSigner } from "@nomicfoundation/hardhat-ethers/signers";
import { expect } from "chai";
import { ethers } from "hardhat";
import { deployLidoDao } from "lib";

import { HardhatEthersSigner } from "@nomicfoundation/hardhat-ethers/signers";

import { ACL, Lido } from "typechain-types";

import { deployLidoDao } from "lib";

describe("Lido:staking-control", () => {
let deployer: HardhatEthersSigner;
let user: HardhatEthersSigner;
Expand Down
7 changes: 5 additions & 2 deletions test/0.4.24/steth.erc20.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { testERC20Compliance } from "../common/erc20.test";
import { ethers } from "hardhat";
import { ether } from "lib/units";

import { StethMinimalMockWithTotalPooledEther__factory } from "typechain-types";

import { ether } from "lib/units";

import { testERC20Compliance } from "../common/erc20.test";

testERC20Compliance({
tokenName: "stETH",
deploy,
Expand Down
8 changes: 5 additions & 3 deletions test/0.4.24/steth.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { HardhatEthersSigner } from "@nomicfoundation/hardhat-ethers/signers";
import { expect } from "chai";
import { ZeroAddress } from "ethers";
import { ethers } from "hardhat";
import { ONE_ETHER, batch, ether } from "lib";
import { describe } from "mocha";

import { HardhatEthersSigner } from "@nomicfoundation/hardhat-ethers/signers";

import { StethMinimalMockWithTotalPooledEther, StethMinimalMockWithTotalPooledEther__factory } from "typechain-types";

import { batch, ether, ONE_ETHER } from "lib";

describe("StETH:non-ERC-20 behavior", () => {
let holder: HardhatEthersSigner;
let recipient: HardhatEthersSigner;
Expand Down
14 changes: 8 additions & 6 deletions test/0.4.24/stethPermit.hook.test.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import { HardhatEthersSigner } from "@nomicfoundation/hardhat-ethers/signers";
import { time } from "@nomicfoundation/hardhat-network-helpers";
import { expect } from "chai";
import { ECDSASignature } from "ethereumjs-util";
import { HDNodeWallet, Wallet, ZeroAddress } from "ethers";
import { ethers } from "hardhat";
import { certainAddress, days, ether, randomAddress, signStethPermit, signStethPermitEIP1271 } from "lib";
import { describe } from "mocha";

import { HardhatEthersSigner } from "@nomicfoundation/hardhat-ethers/signers";
import { time } from "@nomicfoundation/hardhat-network-helpers";

import {
EIP712StETH,
EIP712StETH__factory,
OwnerWithEip712PermitSignature__factory,
StethPermitMockWithEip712Initialization__factory,
OwnerWithEip712PermitSignature,
OwnerWithEip712PermitSignature__factory,
StethPermitMockWithEip712Initialization,
StethPermitMockWithEip712Initialization__factory,
} from "typechain-types";

import { certainAddress, days, ether, randomAddress, signStethPermit, signStethPermitEIP1271 } from "lib";

describe("Permit", () => {
let deployer: HardhatEthersSigner;

Expand Down
7 changes: 4 additions & 3 deletions test/0.4.24/versioned.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { describe } from "mocha";
import { OssifiableProxy } from "typechain-types";
import { expect } from "chai";
import { ethers } from "hardhat";

import { HardhatEthersSigner } from "@nomicfoundation/hardhat-ethers/signers";
import { expect } from "chai";

import { OssifiableProxy } from "typechain-types";
import { VersionedMock } from "typechain-types/contracts/0.4.24/test_helpers";
import { VersionedMock__factory } from "typechain-types/factories/contracts/0.4.24/test_helpers";

Expand Down
7 changes: 5 additions & 2 deletions test/0.6.12/wsteth.erc20.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { ethers } from "hardhat";
import { ether } from "lib/units";

import { WstETH__factory } from "typechain-types";
import { testERC20Compliance } from "../common/erc20.test";
import { StethMinimalMockWithTotalPooledEther__factory } from "typechain-types";

import { ether } from "lib/units";

import { testERC20Compliance } from "../common/erc20.test";

testERC20Compliance({
tokenName: "wstETH",
deploy: async () => {
Expand Down
5 changes: 3 additions & 2 deletions test/0.8.9/eip712.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { expect } from "chai";
import { ZeroAddress } from "ethers";
import { ethers } from "hardhat";
import { certainAddress, deriveDomainSeparator, deriveTypeDataHash, streccak } from "lib";
import { describe } from "mocha";

import { EIP712StETH, EIP712StETH__factory } from "typechain-types";

import { certainAddress, deriveDomainSeparator, deriveTypeDataHash, streccak } from "lib";

interface Domain {
type: string;
name: string;
Expand Down
5 changes: 3 additions & 2 deletions test/0.8.9/lidoLocator.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { expect } from "chai";
import { ZeroAddress } from "ethers";
import { ethers } from "hardhat";
import { describe } from "mocha";
import { ArrayToUnion, randomAddress } from "lib";

import { LidoLocator } from "typechain-types";

import { ArrayToUnion, randomAddress } from "lib";

const services = [
"accountingOracle",
"depositSecurityModule",
Expand Down
7 changes: 5 additions & 2 deletions test/0.8.9/stakingRouter/stakingRouter.versioned.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { randomBytes } from "crypto";
import { ethers } from "hardhat";

import { StakingRouter__factory } from "typechain-types";

import { randomAddress } from "lib";

import testVersionedCompliance from "../../common/versioned.test";
import { randomBytes } from "crypto";
import { StakingRouter__factory } from "typechain-types";

testVersionedCompliance({
name: "StakingRouter",
Expand Down
8 changes: 5 additions & 3 deletions test/0.8.9/versioned.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { HardhatEthersSigner } from "@nomicfoundation/hardhat-ethers/signers";
import { expect } from "chai";
import { ethers } from "hardhat";
import { describe } from "mocha";
import { MAX_UINT256, proxify, streccak } from "lib";

import { HardhatEthersSigner } from "@nomicfoundation/hardhat-ethers/signers";

import { VersionedConsumerMock } from "typechain-types";

import { MAX_UINT256, proxify, streccak } from "lib";

describe("Versioned.sol", () => {
let admin: HardhatEthersSigner;
let user: HardhatEthersSigner;
Expand Down
4 changes: 3 additions & 1 deletion test/0.8.9/withdrawalQueue.erc721.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { ethers } from "hardhat";
import { testERC721Compliance } from "../common/erc721.test";

import { ether } from "lib";

import { testERC721Compliance } from "../common/erc721.test";

testERC721Compliance({
tokenName: "WithdrawalQueue NFT",
deploy: async () => {
Expand Down
Loading

0 comments on commit 537e340

Please sign in to comment.