Skip to content

Commit 6d16603

Browse files
chore(github CI): add eslint (#184)
* chore(github CI): add eslint * update eslintrc * fix error Co-authored-by: zhengqi zhang <[email protected]>
1 parent 65a0b30 commit 6d16603

File tree

8 files changed

+15
-13
lines changed

8 files changed

+15
-13
lines changed

.eslintrc.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,7 @@ module.exports = {
1515
'@typescript-eslint/explicit-function-return-type': 'off',
1616
'@typescript-eslint/no-explicit-any': 'off',
1717
'@typescript-eslint/explicit-module-boundary-types': 'off',
18+
'@typescript-eslint/no-inferrable-types': 'off',
19+
'prefer-const': 'off',
1820
},
1921
};

.github/workflows/lint.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,5 @@ jobs:
4242
- name: Prettify js/ts code
4343
run: npx prettier --check "**/*.{js,ts}"
4444

45-
# - run: |
46-
# npx eslint .
45+
- run: |
46+
npx eslint .

test/global_state.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class GlobalState {
4747
orderLevels: number,
4848
accountLevels: number,
4949
nTx: number,
50-
options: object = { enable_self_trade: false, verbose: false },
50+
options: any = { enable_self_trade: false, verbose: false },
5151
) {
5252
this.balanceLevels = balanceLevels;
5353
this.orderLevels = orderLevels;
@@ -64,8 +64,8 @@ class GlobalState {
6464
this.orderIdToPos = new Map();
6565
this.orderPosToId = new Map();
6666
this.accounts = new Map(); // map[account_id]acount_state
67-
this.bufferedTxs = new Array();
68-
this.bufferedBlocks = new Array();
67+
this.bufferedTxs = [];
68+
this.bufferedBlocks = [];
6969
this.nextOrderPositions = new Map();
7070
this.options = options;
7171
this.nTx = nTx;

test/massive.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function initTestCase(nTxsn, balanceLevels, orderLevels, accountLevels) {
6363

6464
/// start txs
6565

66-
for (var i = 0; i < nTxs; i++) {
66+
for (let i = 0; i < nTxs; i++) {
6767
let spotTradeTx = {
6868
order1AccountID: accountID1,
6969
order2AccountID: accountID2,

test/testcases/block.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ function initBlockTestCase() {
168168
};
169169
state.SpotTrade(spotTradeTx);
170170

171-
for (var i = state.bufferedTxs.length; i < nTxs; i++) {
171+
for (let i = state.bufferedTxs.length; i < nTxs; i++) {
172172
state.Nop();
173173
}
174174

@@ -182,7 +182,7 @@ function initEmptyBlockTestCase(): L2Block {
182182
let state = new GlobalState(balanceLevels, orderLevels, accountLevels, nTxs);
183183
// we need to have at least 1 account
184184
state.createNewAccount();
185-
for (var i = 0; i < nTxs; i++) {
185+
for (let i = 0; i < nTxs; i++) {
186186
state.Nop();
187187
}
188188
let block = state.forgeAllL2Blocks()[0];

test/testcases/encode_txdata.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ function mockBigDepositToTx(): Array<bigint> {
111111
const tokenLevels = 6;
112112
const accountLevels = 2;
113113

114-
function genOutput(payload: Array<bigint>): Object {
114+
function genOutput(payload: Array<bigint>): any {
115115
const hasher = new DA_Hasher(accountLevels, tokenLevels);
116116
hasher.encodeRawPayload(payload);
117117
return {

test/testcases/interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ interface TestComponent {
33
main: string;
44
}
55
interface SimpleTest {
6-
getTestData(): Array<{ name: string; input: object; output?: object }>;
6+
getTestData(): Array<{ name: string; input: any; output?: any }>;
77
getComponent(): TestComponent;
88
}
99

tools/inspect_l2_block.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
var fs = require('fs');
1+
const fs = require('fs');
22
import { TxLength, TxDetailIdx } from '../test/codec/tx_data';
33
import { TxType } from '../test/common/tx';
44
function main() {
5-
var obj = JSON.parse(fs.readFileSync(process.argv[2], 'utf8'));
5+
let obj = JSON.parse(fs.readFileSync(process.argv[2], 'utf8'));
66
for (let i = 0; i < obj.txsType.length; i++) {
77
console.log('Tx', i);
88
console.log('type:', TxType[obj.txsType[i]]);
9-
for (var enumStr of Object.values(TxDetailIdx)) {
9+
for (let enumStr of Object.values(TxDetailIdx)) {
1010
if (typeof enumStr == 'string') {
1111
const enumIdx = TxDetailIdx[enumStr];
1212
const value = obj.encodedTxs[i][enumIdx];

0 commit comments

Comments
 (0)