Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
Use linting that doesn't depend on react
Browse files Browse the repository at this point in the history
  • Loading branch information
voltrevo committed Sep 18, 2023
1 parent 4f2a0ac commit 8166af7
Show file tree
Hide file tree
Showing 14 changed files with 106 additions and 477 deletions.
3 changes: 2 additions & 1 deletion account-integrations/safe/.eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
lib
lib
typechain-types
121 changes: 45 additions & 76 deletions account-integrations/safe/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,100 +1,69 @@
/* eslint-env node */

module.exports = {
root: true,
env: { node: true, es2020: true, mocha: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'airbnb',
],
parser: '@typescript-eslint/parser',
env: {
node: true,
es2021: true,
},
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: true,
ecmaVersion: "latest",
sourceType: "module",
tsconfigRootDir: __dirname,
},
plugins: ['prettier', '@typescript-eslint', 'import'],
settings: {
react: {
version: "detect",
plugins: ["prettier", "@typescript-eslint", "import"],
extends: "xo-typescript",
overrides: [
{
env: {
node: true,
},
files: [".eslintrc.{js,cjs}"],
parserOptions: {
sourceType: "script",
},
},
},
],
rules: {
'prettier/prettier': [
'error',
indent: "off",
"@typescript-eslint/indent": "off",
"prettier/prettier": [
"error",
{
bracketSpacing: true,
bracketSameLine: false,
printWidth: 80,
semi: true,
singleQuote: false,
tabWidth: 2,
trailingComma: 'all',
trailingComma: "all",
useTabs: false,
proseWrap: 'always',
proseWrap: "always",
},
],
'quotes': ['error', 'double'],
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
quotes: ["error", "double"],
"@typescript-eslint/quotes": "off",
"@typescript-eslint/naming-convention": [
"error",
{
varsIgnorePattern: '^_',
argsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
selector: "variable",
format: ["camelCase", "UPPER_CASE"],
leadingUnderscore: "allow",
trailingUnderscore: "allow",
},
],
'import/extensions': 'off',
'import/no-unresolved': 'off',
'import/no-extraneous-dependencies': 'off',
'import/no-absolute-path': 'off',
'no-useless-constructor': 'off',
'@typescript-eslint/no-useless-constructor': 'error',
'no-empty-function': 'off',
'object-curly-newline': 'off',
'no-return-await': 'off',
'max-classes-per-file': 'off',
'lines-between-class-members': [
'error',
'always',
{
exceptAfterSingleLine: true,
selector: "typeLike",
format: ["PascalCase"],
},
],
'no-use-before-define': 'off',
'no-redeclare': 'off',
'brace-style': 'off',
'no-restricted-syntax': 'off',
'operator-linebreak': 'off',

// Found false positive with these. Maybe the typescript used for linting is
// out of date.
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',

'no-shadow': 'off',
'@typescript-eslint/no-shadow': 'error',

camelcase: [
'error',
{
allow: ['^[a-zA-Z]+__factory$', '^eth_[a-zA-Z]+$'],
},
"@typescript-eslint/object-curly-spacing": ["error", "always"],
"@typescript-eslint/consistent-type-imports": "off",
"@typescript-eslint/padding-line-between-statements": "off",
"@typescript-eslint/prefer-regexp-exec": "off",
"@typescript-eslint/ban-types": [
"error",
{ types: { null: false, "[]": false } },
],

'implicit-arrow-linebreak': 'off',
'function-paren-newline': 'off',
'react/jsx-wrap-multilines': 'off',
'no-void': 'off',
'react/jsx-curly-newline': 'off',
'no-await-in-loop': 'off',
'no-continue': 'off',
'no-constant-condition': 'off',
'no-underscore-dangle': 'off',
'prefer-destructuring': 'off',
"@typescript-eslint/member-ordering": "off",
"@typescript-eslint/return-await": "off",
"no-constant-condition": "off",
},
};
2 changes: 1 addition & 1 deletion account-integrations/safe/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const config: HardhatUserConfig = {
timeout: 120000,
},
preprocess: {
eachLine: (hre) => ({
eachLine: (_hre) => ({
transform: (line: string) => {
if (line.match(/^\s*import /i)) {
for (const [from, to] of getRemappings()) {
Expand Down
13 changes: 6 additions & 7 deletions account-integrations/safe/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,16 @@
"@types/chai": "^4.2.0",
"@types/mocha": ">=9.1.0",
"@types/node": ">=16.0.0",
"@typescript-eslint/eslint-plugin": "^6.7.0",
"@typescript-eslint/parser": "^6.7.0",
"@typescript-eslint/eslint-plugin": ">=6.0.0",
"@typescript-eslint/parser": ">=6.0.0",
"chai": "^4.2.0",
"dotenv": "^16.3.1",
"eslint": "^8.49.0",
"eslint-config-airbnb": "^19.0.4",
"eslint": ">=8.0.0",
"eslint-config-prettier": "^9.0.0",
"eslint-config-xo": "^0.43.1",
"eslint-config-xo-typescript": "^1.0.1",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-react": "^7.33.2",
"ethers": "^6.4.0",
"ethers-v5": "npm:[email protected]",
"hardhat": "^2.17.1",
Expand All @@ -42,6 +41,6 @@
"solidity-coverage": "^0.8.0",
"ts-node": ">=8.0.0",
"typechain": "^8.1.0",
"typescript": ">=4.5.0"
"typescript": ">=4.7"
}
}
6 changes: 3 additions & 3 deletions account-integrations/safe/script/deploy_all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
Safe__factory,
} from "../typechain-types";

const deploy = async function () {
async function deploy() {
const contractFactories = [
SimulateTxAccessor__factory,
SafeProxyFactory__factory,
Expand All @@ -35,13 +35,13 @@ const deploy = async function () {
for (const contractFactory of contractFactories) {
const contract = await safeSingletonFactory.connectOrDeploy(
contractFactory,
[]
[],
);

const contractName = contractFactory.name.split("_")[0];
console.log(`deployed ${contractName} to ${await contract.getAddress()}`);
}
};
}

deploy().catch((error: Error) => {
console.error(error);
Expand Down
15 changes: 9 additions & 6 deletions account-integrations/safe/script/fundAccounts.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
/* global eth */

const devAccounts = [
"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
"0x70997970C51812dc3A010C7d01b50e0d17dc79C8",
"0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC",
"0x90F79bf6EB2c4f870365E785982E1f101E93b906",
"0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65",
"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
"0x70997970C51812dc3A010C7d01b50e0d17dc79C8",
"0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC",
"0x90F79bf6EB2c4f870365E785982E1f101E93b906",
"0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65",
];

for (const to of devAccounts) {
eth.sendTransaction({ from: eth.coinbase, to, value: 1e22 });
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
eth.sendTransaction({ from: eth.coinbase, to, value: 1e22 });
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ describe("SafeBlsPlugin", () => {
ENTRYPOINT_ADDRESS,
);
} catch (e) {
// eslint-disable-next-line no-console
console.log("EntryPoint handleOps error=", e);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
SafeProxyFactory__factory,
Safe__factory,
} from "../../../typechain-types";
import sleep from "../utils/sleep";

const ERC4337_TEST_ENV_VARIABLES_DEFINED =
typeof process.env.ERC4337_TEST_BUNDLER_URL !== "undefined" &&
Expand All @@ -25,18 +26,11 @@ const BUNDLER_URL = process.env.ERC4337_TEST_BUNDLER_URL;
const NODE_URL = process.env.ERC4337_TEST_NODE_URL;
const MNEMONIC = process.env.MNEMONIC;

const sleep = (ms: number) =>
new Promise((resolve) => {
setTimeout(resolve, ms);
});

describe("SafeECDSAPlugin", () => {
const setupTests = async () => {
const bundlerProvider = new ethersV5.providers.JsonRpcProvider(BUNDLER_URL);
const provider = new ethers.JsonRpcProvider(NODE_URL);
const userWallet = ethers.Wallet.fromPhrase(MNEMONIC as string).connect(
provider,
);
const userWallet = ethers.Wallet.fromPhrase(MNEMONIC!).connect(provider);

const entryPoints = (await bundlerProvider.send(
"eth_supportedEntryPoints",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
SafeProxyFactory__factory,
Safe__factory,
} from "../../../typechain-types";
import sleep from "../utils/sleep";

const ERC4337_TEST_ENV_VARIABLES_DEFINED =
typeof process.env.ERC4337_TEST_BUNDLER_URL !== "undefined" &&
Expand All @@ -24,18 +25,11 @@ const BUNDLER_URL = process.env.ERC4337_TEST_BUNDLER_URL;
const NODE_URL = process.env.ERC4337_TEST_NODE_URL;
const MNEMONIC = process.env.MNEMONIC;

const sleep = (ms: number) =>
new Promise((resolve) => {
setTimeout(resolve, ms);
});

describe("SafeWebAuthnPlugin", () => {
const setupTests = async () => {
const bundlerProvider = new ethersV5.providers.JsonRpcProvider(BUNDLER_URL);
const provider = new ethers.JsonRpcProvider(NODE_URL);
const userWallet = ethers.Wallet.fromPhrase(MNEMONIC as string).connect(
provider,
);
const userWallet = ethers.Wallet.fromPhrase(MNEMONIC!).connect(provider);

const entryPoints = (await bundlerProvider.send(
"eth_supportedEntryPoints",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ export default class SafeSingletonFactory {
};

provider: ethers.Provider;

// eslint-disable-next-line no-use-before-define
viewer: SafeSingletonFactoryViewer;

private constructor(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ethers } from "ethers";
import { SafeProxyFactory } from "../../../typechain-types";

// eslint-disable-next-line import/prefer-default-export
export const calculateProxyAddress = async (
factory: SafeProxyFactory,
singleton: string,
Expand Down
5 changes: 5 additions & 0 deletions account-integrations/safe/test/hardhat/utils/sleep.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default async function sleep(ms: number) {
await new Promise((resolve) => {
setTimeout(resolve, ms);
});
}
1 change: 1 addition & 0 deletions account-integrations/safe/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
"skipLibCheck": true,
"resolveJsonModule": true
},
"include": [".", ".eslintrc.cjs"],
"exclude": ["lib"]
}
Loading

0 comments on commit 8166af7

Please sign in to comment.