Skip to content

Commit

Permalink
Replace linters (#368)
Browse files Browse the repository at this point in the history
* replaced fmt for type pkg

* Replaced Prettier

* fix lockfile

* schema formatted

* small fixes

* new rpc endpoints

* lint on util and types

* fix solidity contracts

* starting CLI pkg linting

* cli lint progress

* finished delinting internal fns

* delinted globalContext

* delinted cli

* fixed procs

* pkg updates

* fix create block
  • Loading branch information
timbrinded authored Jan 31, 2024
1 parent 3609a81 commit 0fc4e5e
Show file tree
Hide file tree
Showing 68 changed files with 2,344 additions and 2,549 deletions.
8 changes: 8 additions & 0 deletions .changeset/gentle-pianos-own.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@moonwall/types": patch
"@moonwall/util": patch
"@moonwall/cli": patch
"@moonwall/tests": patch
---

Linter and Pkg Updates
29 changes: 0 additions & 29 deletions .eslintrc.cjs

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ jobs:
- uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Run standard ${{matrix.suite}}}
- name: Run standard ${{matrix.suite}}
run: |
cd test
bun moonwall test ${{matrix.suite}}
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

1. Do all the changes you want on a user-branch
2. Run as many tests until you're happy
3. Run `prettier`
3. Run `fmt:fix`
4. Commit changes and push to GitHub
5. Raise PR with additional details if required

Expand Down
31 changes: 31 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"$schema": "https://biomejs.dev/schemas/1.5.3/schema.json",
"files": {
"include": ["*.js", "*.ts", "*.json", "*.yml", "*.md"],
"ignore": ["./dist/*", "./node_modules/*"]
},
"organizeImports": {
"enabled": false
},
"formatter": {
"enabled": true
},
"javascript": {
"formatter": {
"trailingComma": "es5",
"semicolons": "always",
"indentStyle": "space",
"lineWidth": 100
}
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"suspicious": {
"noExplicitAny": "off",
"noAsyncPromiseExecutor": "off"
}
}
}
}
14 changes: 3 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
"scripts": {
"build": "pnpm -r --filter='./packages/**' run build",
"generate-types": "pnpm -r --filter='./packages/**' run generate-types",
"prettier": "pnpm exec prettier --write --ignore-path .gitignore '**/*.(yml|js|ts|json)'",
"fmt": "pnpm -r --filter='./packages/**' run fmt",
"fmt:fix": "pnpm -r --filter='./packages/**' run fmt:fix",
"fmt": "biome format ./biome.json; pnpm -r --filter='./packages/**' run fmt",
"fmt:fix": "biome format ./biome.json --write; pnpm -r --filter='./packages/**' run fmt:fix",
"lint": "pnpm -r --filter='./packages/**' run lint",
"lint:fix": "pnpm -r --filter='./packages/**' run lint:fix",
"changeset": "changeset",
Expand All @@ -24,15 +23,8 @@
"typecheck": "pnpm -r --filter='./packages/**' run typecheck"
},
"devDependencies": {
"@biomejs/biome": "1.5.3",
"@changesets/cli": "2.27.1",
"@pnpm/eslint-config": "1.1.0",
"@typescript-eslint/eslint-plugin": "6.19.0",
"@typescript-eslint/parser": "6.19.0",
"eslint": "8.56.0",
"eslint-config-prettier": "9.1.0",
"eslint-config-xo": "0.43.1",
"eslint-config-xo-typescript": "1.0.1",
"prettier": "3.2.4",
"typescript": "5.3.3"
}
}
4 changes: 4 additions & 0 deletions packages/cli/biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://biomejs.dev/schemas/1.5.3/schema.json",
"extends": ["../../biome.json"]
}
32 changes: 16 additions & 16 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,17 @@
"scripts": {
"clean": "rm -rf dist && rm -rf node_modules",
"build": "pnpm exec rm -rf dist && tsup src --format cjs,esm && pnpm generate-types",
"lint": "eslint ./src/**/*.ts",
"lint:fix": "eslint './src/**/*.ts' --fix",
"fmt": "pnpm prettier --check --ignore-path ../../.prettierignore '**/*.(yml|js|ts|json)'",
"fmt:fix": "pnpm prettier --write --ignore-path ../../.prettierignore '**/*.(yml|js|ts|json)'",
"lint": "pnpm biome lint ./src",
"lint:fix": "pnpm biome lint ./src --apply",
"fmt": "biome format .",
"fmt:fix": "biome format . --write",
"generate-types": "tsup src --format cjs,esm --dts ",
"watch": "tsup src --format cjs,esm --dts --watch",
"typecheck": "pnpm exec tsc --noEmit",
"prepublish": "pnpm run build && pnpm run generate-types"
},
"dependencies": {
"@acala-network/chopsticks": "0.9.7",
"@acala-network/chopsticks": "0.9.8",
"@moonbeam-network/api-augment": "0.2700.0",
"@moonwall/types": "workspace:*",
"@moonwall/util": "workspace:*",
Expand All @@ -73,7 +73,7 @@
"@polkadot/types-codec": "10.11.2",
"@polkadot/util": "12.6.2",
"@polkadot/util-crypto": "12.6.2",
"@vitest/ui": "1.2.1",
"@vitest/ui": "1.2.2",
"@zombienet/orchestrator": "0.0.68",
"@zombienet/utils": "0.0.24",
"bottleneck": "2.19.5",
Expand All @@ -82,37 +82,37 @@
"cli-progress": "3.12.0",
"colors": "1.4.0",
"debug": "4.3.4",
"dotenv": "16.3.2",
"dotenv": "16.4.1",
"ethers": "6.10.0",
"get-port": "^7.0.0",
"inquirer": "9.2.12",
"inquirer": "9.2.13",
"inquirer-press-to-continue": "1.2.0",
"jsonc-parser": "3.2.0",
"jsonc-parser": "3.2.1",
"minimatch": "9.0.3",
"node-fetch": "3.3.2",
"semver": "7.5.4",
"viem": "2.4.1",
"vitest": "1.2.1",
"viem": "2.7.1",
"vitest": "1.2.2",
"web3": "4.4.0",
"web3-providers-ws": "^4.0.7",
"ws": "8.16.0",
"yaml": "2.3.4",
"yargs": "17.7.2"
},
"peerDependencies": {
"@acala-network/chopsticks": "0.9.7",
"@acala-network/chopsticks": "0.9.8",
"@polkadot/api": "10.11.2",
"@vitest/ui": "1.2.1",
"vitest": "1.2.1"
"@vitest/ui": "1.2.2",
"vitest": "1.2.2"
},
"devDependencies": {
"@biomejs/biome": "1.5.3",
"@types/clear": "^0.1.4",
"@types/cli-progress": "3.11.5",
"@types/debug": "4.1.12",
"@types/node": "20.11.5",
"@types/node": "20.11.13",
"@types/ws": "^8.5.10",
"@types/yargs": "17.0.32",
"prettier": "3.2.4",
"tsup": "8.0.1",
"tsx": "4.7.0",
"typescript": "5.3.3"
Expand Down
14 changes: 9 additions & 5 deletions packages/cli/src/cmds/entrypoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ yargs(hideBin(process.argv))
.middleware((argv) => {
process.env.MOON_CONFIG_PATH = argv.configFile;
})
.command(`init`, "Run tests for a given Environment", async () => {
.command("init", "Run tests for a given Environment", async () => {
await generateConfig();
})
.command(
`download <bin> [ver] [path]`,
"download <bin> [ver] [path]",
"Download x86 artifact from GitHub",
(yargs) => {
return yargs
Expand Down Expand Up @@ -74,7 +74,7 @@ yargs(hideBin(process.argv))
}
)
.command(
`test <envName> [GrepTest]`,
"test <envName> [GrepTest]",
"Run tests for a given Environment",
(yargs) => {
return yargs
Expand All @@ -91,7 +91,11 @@ yargs(hideBin(process.argv))
async (args) => {
if (args.envName) {
process.env.MOON_RUN_SCRIPTS = "true";
if (!(await testCmd(args.envName.toString(), { testNamePattern: args.GrepTest }))) {
if (
!(await testCmd(args.envName.toString(), {
testNamePattern: args.GrepTest,
}))
) {
process.exitCode = 1;
}
} else {
Expand All @@ -102,7 +106,7 @@ yargs(hideBin(process.argv))
}
)
.command(
`run <envName> [GrepTest]`,
"run <envName> [GrepTest]",
"Start new network found in global config",
(yargs) => {
return yargs
Expand Down
19 changes: 9 additions & 10 deletions packages/cli/src/cmds/interactiveCmds/chopsticksIntCmds.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { promises as fsPromises } from "fs";
import inquirer from "inquirer";
import { parse } from "yaml";
import { importJsonConfig } from "../../lib/configReader";
import { getEnvironmentFromConfig } from "../../lib/configReader";
import { MoonwallContext } from "../../lib/globalContext";
import type { ApiPromise } from "@polkadot/api";
import { jumpBlocksChopsticks, jumpRoundsChopsticks, jumpToRoundChopsticks } from "@moonwall/util";

export async function resolveChopsticksInteractiveCmdChoice() {
const globalConfig = importJsonConfig();
const config = globalConfig.environments.find(({ name }) => name == process.env.MOON_TEST_ENV)!;
const config = getEnvironmentFromConfig();

if (config.foundation.type !== "chopsticks") {
throw new Error("Only chopsticks is supported, this is a bug please raise an issue.");
Expand All @@ -26,7 +25,7 @@ export async function resolveChopsticksInteractiveCmdChoice() {
name: "name",
type: "list",
choices: nodes,
message: `Which network would you like to interact with? `,
message: "Which network would you like to interact with? ",
});

return result.name;
Expand All @@ -35,7 +34,7 @@ export async function resolveChopsticksInteractiveCmdChoice() {
const nodeSelected = isMultiChain ? await promptNode() : config.foundation.launchSpec[0].name;

const ctx = await (await MoonwallContext.getContext()).connectEnvironment();
const provider = ctx.providers.find((a) => a.type == "polkadotJs" && a.name == nodeSelected);
const provider = ctx.providers.find((a) => a.type === "polkadotJs" && a.name === nodeSelected);

if (!provider) {
throw new Error(
Expand All @@ -47,7 +46,7 @@ export async function resolveChopsticksInteractiveCmdChoice() {

const ports = await Promise.all(
config.foundation.launchSpec
.filter(({ name }) => name == nodeSelected)
.filter(({ name }) => name === nodeSelected)
.map(async ({ configPath }) => {
const yaml = parse((await fsPromises.readFile(configPath)).toString());
return (yaml.port as string) || "8000";
Expand Down Expand Up @@ -84,7 +83,7 @@ export async function resolveChopsticksInteractiveCmdChoice() {
name: "cmd",
type: "list",
choices,
message: `What command would you like to run? `,
message: "What command would you like to run? ",
default: "createBlock",
});

Expand All @@ -97,7 +96,7 @@ export async function resolveChopsticksInteractiveCmdChoice() {
const result = await new inquirer.prompt({
name: "n",
type: "number",
message: `How many blocks? `,
message: "How many blocks? ",
});

await jumpBlocksChopsticks(port, result.n);
Expand All @@ -109,7 +108,7 @@ export async function resolveChopsticksInteractiveCmdChoice() {
const result = await new inquirer.prompt({
name: "round",
type: "number",
message: `Which round to jump to (in future)? `,
message: "Which round to jump to (in future)? ",
});
console.log("💤 This may take a while....");
await jumpToRoundChopsticks(api, port, result.round);
Expand All @@ -120,7 +119,7 @@ export async function resolveChopsticksInteractiveCmdChoice() {
const result = await new inquirer.prompt({
name: "n",
type: "number",
message: `How many rounds? `,
message: "How many rounds? ",
});
console.log("💤 This may take a while....");
await jumpRoundsChopsticks(api, port, result.n);
Expand Down
16 changes: 11 additions & 5 deletions packages/cli/src/cmds/interactiveCmds/devIntCmds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ import { jumpRoundsDev, jumpToRoundDev } from "@moonwall/util";

export async function resolveDevInteractiveCmdChoice() {
const ctx = await (await MoonwallContext.getContext()).connectEnvironment();
const api = ctx.providers.find((a) => a.type == "polkadotJs")!.api as ApiPromise;

const prov = ctx.providers.find((a) => a.type === "polkadotJs");

if (!prov) {
throw new Error("Provider not found. This is a bug, please raise an issue.");
}
const api = prov.api as ApiPromise;
const choices = [
{ name: "🆗 Create Block", value: "createblock" },
{ name: "🆕 Create Unfinalized Block", value: "createUnfinalizedBlock" },
Expand Down Expand Up @@ -36,7 +42,7 @@ export async function resolveDevInteractiveCmdChoice() {
name: "cmd",
type: "list",
choices,
message: `What command would you like to run? `,
message: "What command would you like to run? ",
default: "createBlock",
});

Expand All @@ -53,7 +59,7 @@ export async function resolveDevInteractiveCmdChoice() {
const result = await new inquirer.prompt({
name: "n",
type: "number",
message: `How many blocks? `,
message: "How many blocks? ",
});

const executeSequentially = async (remaining: number) => {
Expand All @@ -72,7 +78,7 @@ export async function resolveDevInteractiveCmdChoice() {
const result = await new inquirer.prompt({
name: "round",
type: "number",
message: `Which round to jump to (in future)? `,
message: "Which round to jump to (in future)? ",
});

await jumpToRoundDev(api, result.round);
Expand All @@ -83,7 +89,7 @@ export async function resolveDevInteractiveCmdChoice() {
const result = await new inquirer.prompt({
name: "n",
type: "number",
message: `How many rounds? `,
message: "How many rounds? ",
});

await jumpRoundsDev(api, result.n);
Expand Down
Loading

0 comments on commit 0fc4e5e

Please sign in to comment.