Skip to content

Commit

Permalink
Configure ESLint and Solhint
Browse files Browse the repository at this point in the history
  • Loading branch information
forshtat committed Dec 23, 2024
1 parent 1ed2352 commit 6680f8c
Show file tree
Hide file tree
Showing 9 changed files with 967 additions and 34 deletions.
79 changes: 79 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
module.exports = {
env: {
browser: true,
es6: true,
jest: true,
mocha: true,
node: true
},
globals: {
artifacts: false,
assert: false,
contract: false,
web3: false
},
extends:
[
'standard-with-typescript'
],
// This is needed to add configuration to rules with type information
parser: '@typescript-eslint/parser',
parserOptions: {
project: ['./tsconfig.json']
},
ignorePatterns: [
'.eslintrc.js',
'**/types/truffle-contracts',
'coverage',
'dist/'
],
rules: {
'no-console': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/return-await': 'off',
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
'@typescript-eslint/require-array-sort-compare': ['error',
{
ignoreStringArrays: true
}
]
},
overrides: [
{
files: '*',
rules: {
'@typescript-eslint/naming-convention': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/restrict-template-expressions': 'off'
}
},
{
files: [
'**/test/**/*.ts'
],
rules: {
'no-unused-expressions': 'off',
// chai assertions trigger this rule
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/no-non-null-assertion': 'off'
}
},
{
// otherwise it will raise an error in every JavaScript file
files: ['*.ts'],
rules: {
'@typescript-eslint/prefer-ts-expect-error': 'off',
// allow using '${val}' with numbers, bool and null types
'@typescript-eslint/restrict-template-expressions': [
'error',
{
allowNumber: true,
allowBoolean: true,
allowNullish: true,
allowNullable: true
}
]
}
}
]
}
12 changes: 12 additions & 0 deletions .solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "solhint:recommended",
"rules": {
"compiler-version": ["error",">=0.7.5"],
"func-visibility": ["off",{"ignoreConstructors":true}],
"custom-errors": ["off"],
"explicit-types": ["warn", "explicit"],
"no-global-import": ["off"],
"immutable-vars-naming": ["off"],
"mark-callable-contracts": ["off"]
}
}
1 change: 1 addition & 0 deletions .solhintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
contracts/bls/lib/
3 changes: 3 additions & 0 deletions contracts/Import.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.23;

import "@account-abstraction/contracts/core/EntryPoint.sol";
import "@account-abstraction/contracts/core/EntryPointSimulations.sol";

Expand Down
1 change: 1 addition & 0 deletions contracts/SimpleAccountFactory.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* solhint-disable one-contract-per-file */
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.23;

Expand Down
13 changes: 12 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"test": "hardhat test",
"lint": "yarn run lint:sol && yarn run lint:js",
"lint:js": "eslint -f unix .",
"lint:sol": "solhint -f unix \"contracts/**/*.sol\" --max-warnings 0"
"lint:sol": "solhint -f unix \"contracts/**/*.sol\" --max-warnings 0",
"lint-fix": "eslint -f unix . --fix"
},
"dependencies": {
"@account-abstraction/contracts": "^0.7.0",
Expand All @@ -30,12 +31,22 @@
"@types/chai": "^4.2.0",
"@types/mocha": ">=9.1.0",
"@types/node": ">=18.0.0",
"@typescript-eslint/eslint-plugin": "^5.30.5",
"@typescript-eslint/parser": "^5.30.5",
"chai": "^4.2.0",
"eslint": "^8.19.0",
"eslint-config-standard": "^17.0.0",
"eslint-config-standard-with-typescript": "^21.0.1",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-standard": "^5.0.0",
"ethereum-waffle": "^3.4.0",
"ethereumjs-util": "^7.1.0",
"ethers": "^5.7.2",
"hardhat": "^2.22.17",
"hardhat-gas-reporter": "^1.0.8",
"solhint": "^3.3.7",
"solidity-coverage": "^0.8.0",
"ts-node": ">=8.0.0",
"typechain": "^8.1.0",
Expand Down
8 changes: 4 additions & 4 deletions test/TokenPaymaster.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,10 @@ describe('TokenPaymaster', function () {
await ethers.provider.send('hardhat_setNextBlockBaseFeePerGas', [utils.hexlify(op.maxFeePerGas)])
const tx = await entryPoint
.handleOps([opPacked], beneficiaryAddress, {
gasLimit: 3e7,
maxFeePerGas: op.maxFeePerGas,
maxPriorityFeePerGas: op.maxFeePerGas
}
gasLimit: 3e7,
maxFeePerGas: op.maxFeePerGas,
maxPriorityFeePerGas: op.maxFeePerGas
}
)
.then(async tx => await tx.wait())

Expand Down
6 changes: 3 additions & 3 deletions test/testutils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ethers } from 'hardhat'
import { toHex } from 'hardhat/internal/util/bigint'
// import { toHex } from 'hardhat/internal/util/bigint'
import {
arrayify,
hexConcat,
Expand All @@ -16,10 +16,10 @@ import {
SimpleAccount,
SimpleAccountFactory__factory,
SimpleAccount__factory,
SimpleAccountFactory, EntryPoint__factory,
SimpleAccountFactory, EntryPoint__factory
} from '../typechain'
import { BytesLike, Hexable } from '@ethersproject/bytes'
import { JsonRpcProvider } from '@ethersproject/providers'
// import { JsonRpcProvider } from '@ethersproject/providers'
import { expect } from 'chai'
import { Create2Factory } from '../src/Create2Factory'
import { debugTransaction } from './debugTx'
Expand Down
Loading

0 comments on commit 6680f8c

Please sign in to comment.