Skip to content

Commit

Permalink
Fix linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewwalsh0 committed Jan 11, 2024
1 parent 1299475 commit 3bccb48
Show file tree
Hide file tree
Showing 60 changed files with 5,182 additions and 3,393 deletions.
87 changes: 71 additions & 16 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,91 @@
module.exports = {
root: true,

extends: ["@metamask/eslint-config"],
extends: ['@metamask/eslint-config'],

overrides: [
{
files: ["*.ts"],
extends: ["@metamask/eslint-config-typescript"],
files: ['*.ts'],
extends: ['@metamask/eslint-config-typescript'],
parserOptions: {
project: ['./tsconfig.json', './tsconfig.packages.json'],
},
rules: {
camelcase: 'off',
'consistent-return': 'off',
'default-case': 'off',
'guard-for-in': 'off',
'id-denylist': 'off',
'id-length': 'off',
'import/no-mutable-exports': 'off',
'import/no-nodejs-modules': 'off',
'import/no-unassigned-import': 'off',
'import/order': 'off',
'jsdoc/check-indentation': 'off',
'jsdoc/check-param-names': 'off',
'jsdoc/match-description': 'off',
'jsdoc/require-description': 'off',
'jsdoc/require-param-description': 'off',
'jsdoc/require-returns': 'off',
'no-constant-condition': 'off',
'no-eq-null': 'off',
'no-lonely-if': 'off',
'no-multi-assign': 'off',
'no-negated-condition': 'off',
'no-param-reassign': 'off',
'no-plusplus': 'off',
'no-restricted-globals': 'off',
'no-restricted-syntax': 'off',
'no-void': 'off',
'prefer-const': 'off',
'prefer-rest-params': 'off',
'pretter/prettier': 'off',
radix: 'off',
'require-unicode-regexp': 'off',
'@typescript-eslint/await-thenable': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/consistent-type-imports': 'off',
'@typescript-eslint/naming-convention': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-parameter-properties': 'off',
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/no-shadow': 'off',
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/prefer-enum-initializers': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/switch-exhaustiveness-check': 'off',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/unified-signatures': 'off',
},
},

{
files: ["*.js"],
files: ['*.js'],
parserOptions: {
sourceType: "script",
sourceType: 'script',
},
extends: ["@metamask/eslint-config-nodejs"],
extends: ['@metamask/eslint-config-nodejs'],
},

{
files: ["*.test.ts", "*.test.js"],
extends: [
"@metamask/eslint-config-jest",
"@metamask/eslint-config-nodejs",
],
files: ['*.test.ts', '*.test.js'],
extends: ['@metamask/eslint-config-nodejs'],
},
],

ignorePatterns: [
"!.eslintrc.js",
"!.prettierrc.js",
"dist/",
"docs/",
".yarn/",
'!.eslintrc.js',
'!.prettierrc.js',
'dist/',
'docs/',
'.yarn/',
'tsconfig.json',
],

rules: {},
};
11 changes: 5 additions & 6 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// All of these are defaults except singleQuote, but we specify them
// for explicitness
module.exports = {
quoteProps: 'as-needed',
singleQuote: true,
tabWidth: 2,
trailingComma: 'all',
};

quoteProps: 'as-needed',
singleQuote: true,
tabWidth: 2,
trailingComma: 'all',
};
37 changes: 22 additions & 15 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
import "@nomiclabs/hardhat-ethers";
import "@nomicfoundation/hardhat-toolbox";
import "hardhat-deploy";
import '@nomiclabs/hardhat-ethers';
import '@nomicfoundation/hardhat-toolbox';
import 'hardhat-deploy';

import fs from "fs";

import { HardhatUserConfig } from "hardhat/config";
import { NetworkUserConfig } from "hardhat/src/types/config";
import fs from 'fs';
import type { HardhatUserConfig } from 'hardhat/config';
import type { NetworkUserConfig } from 'hardhat/src/types/config';

const mnemonicFileName = process.env.MNEMONIC_FILE;
let mnemonic = "test ".repeat(11) + "junk";
let mnemonic = `${'test '.repeat(11)}junk`;
if (mnemonicFileName != null && fs.existsSync(mnemonicFileName)) {
mnemonic = fs.readFileSync(mnemonicFileName, "ascii").trim();
mnemonic = fs.readFileSync(mnemonicFileName, 'ascii').trim();
}

const infuraUrl = (name: string): string =>
`https://${name}.infura.io/v3/${process.env.INFURA_ID}`;

/**
*
* @param url
*/
function getNetwork(url: string): NetworkUserConfig {
return {
url,
Expand All @@ -25,27 +28,31 @@ function getNetwork(url: string): NetworkUserConfig {
};
}

/**
*
* @param name
*/
function getInfuraNetwork(name: string): NetworkUserConfig {
return getNetwork(infuraUrl(name));
}

const config: HardhatUserConfig = {
paths: {
sources: "src/contracts",
sources: 'src/contracts',
},
typechain: {
outDir: "src/contract-types",
target: "ethers-v5",
outDir: 'src/contract-types',
target: 'ethers-v5',
},
networks: {
localhost: {
url: "http://localhost:8545/",
url: 'http://localhost:8545/',
saveDeployments: false,
},
goerli: getInfuraNetwork("goerli"),
goerli: getInfuraNetwork('goerli'),
},
solidity: {
version: "0.8.15",
version: '0.8.15',
settings: {
optimizer: { enabled: true },
},
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
"url": "https://github.com/MetaMask/test-bundler.git"
},
"license": "MIT",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist"
],
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"scripts": {
"build": "tsc",
"build:clean": "rm -rf dist tsconfig.tsbuildinfo && yarn build",
Expand Down Expand Up @@ -71,12 +71,12 @@
"@types/express": "^4.17.13",
"@types/mocha": "^9.1.0",
"@types/node": "^16.4.12",
"@typescript-eslint/eslint-plugin": "^5.33.0",
"@typescript-eslint/parser": "^5.33.0",
"@typescript-eslint/eslint-plugin": "^5.43.0",
"@typescript-eslint/parser": "^5.43.0",
"body-parser": "^1.20.0",
"chai": "^4.2.0",
"depcheck": "^1.4.3",
"eslint": "^8.21.0",
"eslint": "^8.44.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^27.2.2",
Expand Down
52 changes: 26 additions & 26 deletions src/bundler/BundlerConfig.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
// TODO: consider adopting config-loading approach from hardhat to allow code in config file
import ow from 'ow'
import ow from 'ow';

const MIN_UNSTAKE_DELAY = 86400
const MIN_STAKE_VALUE = 1e18.toString()
export interface BundlerConfig {
beneficiary: string
entryPoint: string
gasFactor: string
minBalance: string
mnemonic: string
network: string
port: string
unsafe: boolean
debugRpc?: boolean
conditionalRpc: boolean
const MIN_UNSTAKE_DELAY = 86400;
const MIN_STAKE_VALUE = (1e18).toString();
export type BundlerConfig = {
beneficiary: string;
entryPoint: string;
gasFactor: string;
minBalance: string;
mnemonic: string;
network: string;
port: string;
unsafe: boolean;
debugRpc?: boolean;
conditionalRpc: boolean;

whitelist?: string[]
blacklist?: string[]
maxBundleGas: number
minStake: string
minUnstakeDelay: number
autoBundleInterval: number
autoBundleMempoolSize: number
}
whitelist?: string[];
blacklist?: string[];
maxBundleGas: number;
minStake: string;
minUnstakeDelay: number;
autoBundleInterval: number;
autoBundleMempoolSize: number;
};

// TODO: implement merging config (args -> config.js -> default) and runtime shape validation
export const BundlerConfigShape = {
Expand All @@ -43,8 +43,8 @@ export const BundlerConfigShape = {
minStake: ow.string,
minUnstakeDelay: ow.number,
autoBundleInterval: ow.number,
autoBundleMempoolSize: ow.number
}
autoBundleMempoolSize: ow.number,
};

// TODO: consider if we want any default fields at all
// TODO: implement merging config (args -> config.js -> default) and runtime shape validation
Expand All @@ -54,5 +54,5 @@ export const bundlerConfigDefault: Partial<BundlerConfig> = {
unsafe: false,
conditionalRpc: false,
minStake: MIN_STAKE_VALUE,
minUnstakeDelay: MIN_UNSTAKE_DELAY
}
minUnstakeDelay: MIN_UNSTAKE_DELAY,
};
Loading

0 comments on commit 3bccb48

Please sign in to comment.