Skip to content

Commit 9cf94c3

Browse files
authored
Merge pull request #5096 from NomicFoundation/no-async-describe
Add eslint rule to forbid describes with async functions
2 parents f0e6389 + 8e1b005 commit 9cf94c3

File tree

27 files changed

+109
-96
lines changed

27 files changed

+109
-96
lines changed

config/eslint/eslintrc.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = {
1212
plugins: [
1313
"@nomicfoundation/hardhat-internal-rules",
1414
"import",
15-
"no-only-tests",
15+
"mocha",
1616
"@typescript-eslint",
1717
"@nomicfoundation/slow-imports",
1818
],
@@ -206,7 +206,6 @@ module.exports = {
206206
"no-extra-bind": "error",
207207
"no-new-func": "error",
208208
"no-new-wrappers": "error",
209-
"no-only-tests/no-only-tests": "error",
210209
"no-return-await": "off",
211210
"@typescript-eslint/return-await": "error",
212211
"no-sequences": "error",
@@ -238,5 +237,7 @@ module.exports = {
238237
patterns: ["hardhat/src", "@nomiclabs/*/src"],
239238
},
240239
],
240+
"mocha/no-exclusive-tests": "error",
241+
"mocha/no-async-describe": "error",
241242
},
242243
};

packages/hardhat-chai-matchers/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"eslint": "^8.44.0",
5656
"eslint-config-prettier": "8.3.0",
5757
"eslint-plugin-import": "2.27.5",
58-
"eslint-plugin-no-only-tests": "3.0.0",
58+
"eslint-plugin-mocha": "10.4.1",
5959
"eslint-plugin-prettier": "3.4.0",
6060
"ethers": "^6.1.0",
6161
"get-port": "^5.1.1",

packages/hardhat-chai-matchers/test/bigNumber.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ describe("BigNumber matchers", function () {
860860
});
861861
});
862862

863-
describe("deep equal", async function () {
863+
describe("deep equal", function () {
864864
checkAll(1, 1, (a, b) => {
865865
it(`should work with ${typestr(a)} and ${typestr(b)}`, function () {
866866
// successful assertions

packages/hardhat-chai-matchers/test/events.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ describe(".to.emit (contract events)", () => {
405405
);
406406
});
407407

408-
describe("nested predicate", async function () {
408+
describe("nested predicate", function () {
409409
it("Should succeed when predicate passes", async function () {
410410
await expect(contract.emitUintArray(1, 2))
411411
.to.emit(contract, "WithUintArray")
@@ -630,7 +630,7 @@ describe(".to.emit (contract events)", () => {
630630
"WithStringArg"
631631
);
632632
});
633-
describe("When detecting two events from one call (chaining)", async function () {
633+
describe("When detecting two events from one call (chaining)", function () {
634634
it("Should succeed when both expected events are indeed emitted", async function () {
635635
await expect(contract.emitUintAndString(1, "a string"))
636636
.to.emit(contract, "WithUintArg")
@@ -663,7 +663,7 @@ describe(".to.emit (contract events)", () => {
663663
);
664664
});
665665
});
666-
describe("When specifying .withArgs()", async function () {
666+
describe("When specifying .withArgs()", function () {
667667
it("Should pass when expecting the correct args from the first event", async function () {
668668
await expect(contract.emitUintAndString(1, "a string"))
669669
.to.emit(contract, "WithUintArg")

packages/hardhat-chai-matchers/test/reverted/revertedWithCustomError.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ describe("INTEGRATION: Reverted with custom error", function () {
223223
});
224224

225225
describe("with args", function () {
226-
describe("one argument", async function () {
226+
describe("one argument", function () {
227227
it("Should match correct argument", async function () {
228228
await expect(matchers.revertWithCustomErrorWithUint(1))
229229
.to.be.revertedWithCustomError(matchers, "CustomErrorWithUint")
@@ -348,7 +348,7 @@ describe("INTEGRATION: Reverted with custom error", function () {
348348
});
349349
});
350350

351-
describe("array of different lengths", async function () {
351+
describe("array of different lengths", function () {
352352
it("Should fail if the expected array is bigger", async function () {
353353
await expect(
354354
expect(matchers.revertWithCustomErrorWithPair(1, 2))

packages/hardhat-core/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
"eslint": "^8.44.0",
9393
"eslint-config-prettier": "8.3.0",
9494
"eslint-plugin-import": "2.27.5",
95-
"eslint-plugin-no-only-tests": "3.0.0",
95+
"eslint-plugin-mocha": "10.4.1",
9696
"eslint-plugin-prettier": "3.4.0",
9797
"ethers": "^6.1.0",
9898
"ethers-v5": "npm:ethers@5",

packages/hardhat-core/test/internal/hardhat-network/stack-traces/test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ function defineTest(
153153
) {
154154
it.skip(desc, func);
155155
} else if (testDefinition.only !== undefined && testDefinition.only) {
156-
// eslint-disable-next-line no-only-tests/no-only-tests
156+
// eslint-disable-next-line mocha/no-exclusive-tests
157157
it.only(desc, func);
158158
} else {
159159
it(desc, func);
@@ -773,7 +773,7 @@ describe("Stack traces", function () {
773773
process.exit(1);
774774
}
775775

776-
// eslint-disable-next-line no-only-tests/no-only-tests
776+
// eslint-disable-next-line mocha/no-exclusive-tests
777777
describe.only(`Use compiler at ${customSolcPath} with version ${customSolcVersion}`, function () {
778778
const compilerOptions = {
779779
solidityVersion: customSolcVersion,
@@ -867,7 +867,7 @@ function defineTestForSolidityMajorVersion(
867867
testsPath: string
868868
) {
869869
for (const compilerOptions of solcVersionsCompilerOptions) {
870-
// eslint-disable-next-line no-only-tests/no-only-tests
870+
// eslint-disable-next-line mocha/no-exclusive-tests
871871
const describeFn = compilerOptions.only === true ? describe.only : describe;
872872

873873
describeFn(`Use compiler ${compilerOptions.compilerPath}`, function () {

packages/hardhat-ethers/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"eslint": "^8.44.0",
6262
"eslint-config-prettier": "8.3.0",
6363
"eslint-plugin-import": "2.27.5",
64-
"eslint-plugin-no-only-tests": "3.0.0",
64+
"eslint-plugin-mocha": "10.4.1",
6565
"eslint-plugin-prettier": "3.4.0",
6666
"ethers": "^6.1.0",
6767
"hardhat": "workspace:^2.0.0",

packages/hardhat-foundry/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"eslint": "^8.44.0",
4949
"eslint-config-prettier": "8.3.0",
5050
"eslint-plugin-import": "2.27.5",
51+
"eslint-plugin-mocha": "10.4.1",
5152
"eslint-plugin-prettier": "3.4.0",
5253
"hardhat": "workspace:^2.17.2",
5354
"mocha": "^10.0.0",

packages/hardhat-ledger/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"eslint": "^8.44.0",
6464
"eslint-config-prettier": "8.3.0",
6565
"eslint-plugin-import": "2.27.5",
66-
"eslint-plugin-no-only-tests": "3.0.0",
66+
"eslint-plugin-mocha": "10.4.1",
6767
"eslint-plugin-prettier": "3.4.0",
6868
"hardhat": "workspace:^2.16.0",
6969
"mocha": "^10.0.0",

packages/hardhat-network-helpers/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"eslint": "^8.44.0",
5656
"eslint-config-prettier": "8.3.0",
5757
"eslint-plugin-import": "2.27.5",
58-
"eslint-plugin-no-only-tests": "3.0.0",
58+
"eslint-plugin-mocha": "10.4.1",
5959
"eslint-plugin-prettier": "3.4.0",
6060
"ethers-v5": "npm:ethers@5",
6161
"hardhat": "workspace:^2.9.5",

packages/hardhat-shorthand/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"eslint": "^8.44.0",
5050
"eslint-config-prettier": "8.3.0",
5151
"eslint-plugin-import": "2.27.5",
52-
"eslint-plugin-no-only-tests": "3.0.0",
52+
"eslint-plugin-mocha": "10.4.1",
5353
"eslint-plugin-prettier": "3.4.0",
5454
"hardhat": "workspace:^2.0.0",
5555
"mocha": "^10.0.0",

packages/hardhat-solhint/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"eslint": "^8.44.0",
5353
"eslint-config-prettier": "8.3.0",
5454
"eslint-plugin-import": "2.27.5",
55-
"eslint-plugin-no-only-tests": "3.0.0",
55+
"eslint-plugin-mocha": "10.4.1",
5656
"eslint-plugin-prettier": "3.4.0",
5757
"fs-extra": "^7.0.1",
5858
"hardhat": "workspace:^2.0.0",

packages/hardhat-solpp/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"eslint": "^8.44.0",
5353
"eslint-config-prettier": "8.3.0",
5454
"eslint-plugin-import": "2.27.5",
55-
"eslint-plugin-no-only-tests": "3.0.0",
55+
"eslint-plugin-mocha": "10.4.1",
5656
"eslint-plugin-prettier": "3.4.0",
5757
"hardhat": "workspace:^2.0.0",
5858
"mocha": "^10.0.0",

packages/hardhat-solpp/test/tests.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ export async function expectErrorAsync(
1919
}
2020
}
2121

22-
describe("Solpp plugin", async function () {
23-
describe("js-config-project", async function () {
22+
describe("Solpp plugin", function () {
23+
describe("js-config-project", function () {
2424
useEnvironment("js-config-project");
2525

2626
it("should evaluate symbols as javascript functions", async function () {
@@ -36,7 +36,7 @@ describe("Solpp plugin", async function () {
3636
});
3737
});
3838

39-
describe("json-config-project", async function () {
39+
describe("json-config-project", function () {
4040
useEnvironment("json-config-project");
4141

4242
it("should load definitions from json", async function () {
@@ -54,7 +54,7 @@ describe("Solpp plugin", async function () {
5454
});
5555
});
5656

57-
describe("hardhat-project", async function () {
57+
describe("hardhat-project", function () {
5858
useEnvironment("hardhat-project");
5959

6060
it("should create processed contracts in the cache directory", async function () {
@@ -102,7 +102,7 @@ describe("Solpp plugin", async function () {
102102
});
103103

104104
// This test skipped because solpp won't fail if a contract has an non-defined symbol.
105-
describe.skip("fail-project", async function () {
105+
describe.skip("fail-project", function () {
106106
useEnvironment("fail-project");
107107

108108
it("should fail when symbol does not exist", async function () {

packages/hardhat-toolbox-viem/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"eslint": "^8.44.0",
6060
"eslint-config-prettier": "8.3.0",
6161
"eslint-plugin-import": "2.27.5",
62-
"eslint-plugin-no-only-tests": "3.0.0",
62+
"eslint-plugin-mocha": "10.4.1",
6363
"eslint-plugin-prettier": "3.4.0",
6464
"hardhat": "workspace:^2.11.0",
6565
"hardhat-gas-reporter": "^1.0.8",

packages/hardhat-toolbox/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"eslint": "^8.44.0",
5959
"eslint-config-prettier": "8.3.0",
6060
"eslint-plugin-import": "2.27.5",
61-
"eslint-plugin-no-only-tests": "3.0.0",
61+
"eslint-plugin-mocha": "10.4.1",
6262
"eslint-plugin-prettier": "3.4.0",
6363
"ethers": "^6.4.0",
6464
"hardhat": "workspace:^2.11.0",

packages/hardhat-truffle4/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"eslint": "^8.44.0",
5656
"eslint-config-prettier": "8.3.0",
5757
"eslint-plugin-import": "2.27.5",
58-
"eslint-plugin-no-only-tests": "3.0.0",
58+
"eslint-plugin-mocha": "10.4.1",
5959
"eslint-plugin-prettier": "3.4.0",
6060
"hardhat": "workspace:^2.6.4",
6161
"mocha": "^10.0.0",

packages/hardhat-truffle5/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"eslint": "^8.44.0",
5656
"eslint-config-prettier": "8.3.0",
5757
"eslint-plugin-import": "2.27.5",
58-
"eslint-plugin-no-only-tests": "3.0.0",
58+
"eslint-plugin-mocha": "10.4.1",
5959
"eslint-plugin-prettier": "3.4.0",
6060
"hardhat": "workspace:^2.6.4",
6161
"mocha": "^10.0.0",

packages/hardhat-verify/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
"eslint": "^8.44.0",
7171
"eslint-config-prettier": "8.3.0",
7272
"eslint-plugin-import": "2.27.5",
73-
"eslint-plugin-no-only-tests": "3.0.0",
73+
"eslint-plugin-mocha": "10.4.1",
7474
"eslint-plugin-prettier": "3.4.0",
7575
"ethers": "^5.0.0",
7676
"hardhat": "workspace:^2.0.4",

packages/hardhat-viem/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"eslint": "^8.44.0",
5656
"eslint-config-prettier": "8.3.0",
5757
"eslint-plugin-import": "2.27.5",
58-
"eslint-plugin-no-only-tests": "3.0.0",
58+
"eslint-plugin-mocha": "10.4.1",
5959
"eslint-plugin-prettier": "3.4.0",
6060
"hardhat": "workspace:^2.17.0",
6161
"jest-diff": "^29.7.0",

packages/hardhat-vyper/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"eslint": "^8.44.0",
5959
"eslint-config-prettier": "8.3.0",
6060
"eslint-plugin-import": "2.27.5",
61-
"eslint-plugin-no-only-tests": "3.0.0",
61+
"eslint-plugin-mocha": "10.4.1",
6262
"eslint-plugin-prettier": "3.4.0",
6363
"hardhat": "workspace:^2.8.3",
6464
"mocha": "^10.0.0",

packages/hardhat-vyper/test/tests.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ describe("Vyper plugin", function () {
242242
});
243243
});
244244

245-
describe("Mixed language", async function () {
245+
describe("Mixed language", function () {
246246
useFixtureProject("mixed-language");
247247
useEnvironment();
248248

packages/hardhat-web3-legacy/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"eslint": "^8.44.0",
4747
"eslint-config-prettier": "8.3.0",
4848
"eslint-plugin-import": "2.27.5",
49-
"eslint-plugin-no-only-tests": "3.0.0",
49+
"eslint-plugin-mocha": "10.4.1",
5050
"eslint-plugin-prettier": "3.4.0",
5151
"hardhat": "workspace:^2.0.0",
5252
"mocha": "^10.0.0",

packages/hardhat-web3-v4/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"eslint": "^8.44.0",
4848
"eslint-config-prettier": "8.3.0",
4949
"eslint-plugin-import": "2.27.5",
50-
"eslint-plugin-no-only-tests": "3.0.0",
50+
"eslint-plugin-mocha": "10.4.1",
5151
"eslint-plugin-prettier": "3.4.0",
5252
"hardhat": "workspace:^2.0.0",
5353
"mocha": "^10.0.0",

packages/hardhat-web3/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"eslint": "^8.44.0",
4747
"eslint-config-prettier": "8.3.0",
4848
"eslint-plugin-import": "2.27.5",
49-
"eslint-plugin-no-only-tests": "3.0.0",
49+
"eslint-plugin-mocha": "10.4.1",
5050
"eslint-plugin-prettier": "3.4.0",
5151
"hardhat": "workspace:^2.0.0",
5252
"mocha": "^10.0.0",

0 commit comments

Comments
 (0)