Skip to content

Commit

Permalink
Update @thesis-co/eslint-config to the latest 0.8.0-pre version (#98)
Browse files Browse the repository at this point in the history
Update `@thesis-co/eslint-config` to the latest version. The commit hash
refers to the merge commit of
thesis/eslint-config#12. This version enables
`@typescript-eslint/recommended-type-checked` rules.

The configuration enforces multiple typing check rules that I found very
useful in the core module's typescript tests, where we were missing
`await` in a couple of places.

Example:
```ts
        it("should emit StakeReferral event", () => {
          expect(tx)
            .to.emit(acre, "StakeReferral")
            .withArgs(referral, amountToStake)
        })
```
Without the `await` the test returned a false-positive result and hadn't
checked if expect resolves correctly.

⚠️ Typing checks in the Core module require `typechain/` directory to be
generated before eslint verification is run. It is recommended that on
local environments `pnpm run build` is run before `pnpm run format`. In
this PR we update the CI process accordingly.

This PR updates the configuration of the Core, SDK, and Website modules.
This PR doesn't update the configuration of the dApp module, we should
handle that in #99.
  • Loading branch information
r-czajkowski authored Jan 4, 2024
2 parents a040b05 + 983d578 commit 803140d
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 36 deletions.
33 changes: 20 additions & 13 deletions .github/workflows/core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ defaults:
working-directory: ./core

jobs:
core-format:
core-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -30,10 +30,20 @@ jobs:
- name: Install Dependencies
run: pnpm install --prefer-offline --frozen-lockfile

- name: Format
run: pnpm run format
- name: Build
run: pnpm run build

core-build:
- name: Upload Build Artifacts
uses: actions/upload-artifact@v3
with:
name: core-build
path: |
core/build/
core/typechain/
if-no-files-found: error

core-format:
needs: [core-build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -50,17 +60,14 @@ jobs:
- name: Install Dependencies
run: pnpm install --prefer-offline --frozen-lockfile

- name: Build
run: pnpm run build

- name: Upload Build Artifacts
uses: actions/upload-artifact@v3
- name: Download Build Artifacts
uses: actions/download-artifact@v3
with:
name: core-build
path: |
core/build/
core/typechain/
if-no-files-found: error
path: core/

- name: Format
run: pnpm run format

core-slither:
needs: [core-build]
Expand Down
16 changes: 15 additions & 1 deletion core/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,19 @@
]
}
]
}
},
"overrides": [
{
"files": ["deploy/*.ts"],
"rules": {
"@typescript-eslint/unbound-method": "off"
}
},
{
"files": ["*.test.ts"],
"rules": {
"@typescript-eslint/no-unused-expressions": "off"
}
}
]
}
2 changes: 1 addition & 1 deletion core/deploy/00_resolve_testing_erc4626.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ func.tags = ["TestERC4626"]
func.dependencies = ["TBTC"]

func.skip = async (hre: HardhatRuntimeEnvironment): Promise<boolean> =>
hre.network.name === "mainnet"
Promise.resolve(hre.network.name === "mainnet")
2 changes: 1 addition & 1 deletion core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@nomicfoundation/hardhat-verify": "^2.0.1",
"@nomiclabs/hardhat-etherscan": "^3.1.7",
"@openzeppelin/hardhat-upgrades": "^2.4.1",
"@thesis-co/eslint-config": "^0.6.1",
"@thesis-co/eslint-config": "github:thesis/eslint-config#7b9bc8c",
"@typechain/ethers-v6": "^0.5.1",
"@typechain/hardhat": "^9.1.0",
"@types/chai": "^4.3.11",
Expand Down
21 changes: 11 additions & 10 deletions core/test/Acre.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
ZeroAddress,
encodeBytes32String,
} from "ethers"
import { ethers } from "hardhat"

import type { HardhatEthersSigner } from "@nomicfoundation/hardhat-ethers/signers"
import type { SnapshotRestorer } from "@nomicfoundation/hardhat-toolbox/network-helpers"
Expand All @@ -26,8 +27,8 @@ async function fixture() {
const [staker1, staker2, thirdParty] = await getUnnamedSigner()

const amountToMint = to1e18(100000)
tbtc.mint(staker1, amountToMint)
tbtc.mint(staker2, amountToMint)
await tbtc.mint(staker1, amountToMint)
await tbtc.mint(staker2, amountToMint)

return { acre, tbtc, staker1, staker2, dispatcher, governance, thirdParty }
}
Expand Down Expand Up @@ -85,8 +86,8 @@ describe("Acre", () => {
.stake(amountToStake, receiver.address, referral)
})

it("should emit Deposit event", () => {
expect(tx).to.emit(acre, "Deposit").withArgs(
it("should emit Deposit event", async () => {
await expect(tx).to.emit(acre, "Deposit").withArgs(
// Caller.
tbtcHolder.address,
// Receiver.
Expand All @@ -98,8 +99,8 @@ describe("Acre", () => {
)
})

it("should emit StakeReferral event", () => {
expect(tx)
it("should emit StakeReferral event", async () => {
await expect(tx)
.to.emit(acre, "StakeReferral")
.withArgs(referral, amountToStake)
})
Expand Down Expand Up @@ -558,8 +559,8 @@ describe("Acre", () => {
tx = await acre.connect(staker1).mint(sharesToMint, staker1.address)
})

it("should emit Deposit event", () => {
expect(tx).to.emit(acre, "Deposit").withArgs(
it("should emit Deposit event", async () => {
await expect(tx).to.emit(acre, "Deposit").withArgs(
// Caller.
staker1.address,
// Receiver.
Expand Down Expand Up @@ -1032,8 +1033,8 @@ describe("Acre", () => {
tx = await acre.deposit(amountToDeposit, staker1.address)
})

it("should emit Deposit event", () => {
expect(tx).to.emit(acre, "Deposit").withArgs(
it("should emit Deposit event", async () => {
await expect(tx).to.emit(acre, "Deposit").withArgs(
// Caller.
staker1.address,
// Receiver.
Expand Down
3 changes: 1 addition & 2 deletions core/test/helpers/contract.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ethers } from "ethers"
import { deployments } from "hardhat"
import { deployments, ethers } from "hardhat"

import type { BaseContract } from "ethers"
import { getUnnamedSigner } from "./signer"
Expand Down
44 changes: 38 additions & 6 deletions pnpm-lock.yaml

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

2 changes: 1 addition & 1 deletion sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"test": "mocha --exit --recursive 'test/**/*.test.ts'"
},
"devDependencies": {
"@thesis-co/eslint-config": "^0.6.1",
"@thesis-co/eslint-config": "github:thesis/eslint-config#7b9bc8c",
"@types/chai": "^4.3.11",
"@types/mocha": "^10.0.6",
"@types/node": "^20.9.4",
Expand Down
2 changes: 1 addition & 1 deletion website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"react-helmet": "^6.1.0"
},
"devDependencies": {
"@thesis-co/eslint-config": "^0.6.1",
"@thesis-co/eslint-config": "github:thesis/eslint-config#7b9bc8c",
"@types/node": "^20.9.4",
"@types/react": "^18.2.38",
"@types/react-dom": "^18.2.17",
Expand Down

0 comments on commit 803140d

Please sign in to comment.