Skip to content

Commit 86f956e

Browse files
authored
chore: finish setting up linter (#21)
1 parent 8869324 commit 86f956e

File tree

6 files changed

+24
-23
lines changed

6 files changed

+24
-23
lines changed

eslint.config.js

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1 @@
1-
// eslint-disable-next-line @typescript-eslint/no-require-imports
2-
const base = require('@ton/toolchain');
3-
// eslint-disable-next-line @typescript-eslint/no-require-imports
4-
const tsEslint = require('@ton/toolchain').tsEslint;
5-
6-
module.exports = [
7-
...base,
8-
{
9-
plugins: {
10-
'@typescript-eslint': tsEslint,
11-
},
12-
rules: {
13-
'no-console': 'off',
14-
'@typescript-eslint/no-explicit-any': 'off',
15-
'@typescript-eslint/no-require-imports': 'warn',
16-
'@typescript-eslint/no-namespace': 'warn',
17-
'no-undef': 'warn',
18-
'no-empty': 'warn',
19-
},
20-
},
21-
];
1+
module.exports = require('@ton/toolchain');

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
},
4444
"prettier": "@ton/toolchain/prettier",
4545
"scripts": {
46-
"lint": "eslint .",
47-
"lint:fix": "eslint . --fix",
46+
"lint": "eslint . --max-warnings 0",
47+
"lint:fix": "eslint . --max-warnings 0 --fix",
4848
"test": "jest",
4949
"build": "rm -rf dist && tsc"
5050
},

src/test/chai.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import { compareAddressForTest, compareCellForTest, compareSliceForTest } from '
44
import { CompareResult } from './interface';
55
import { compareTransactionForTest, FlatTransactionComparable } from './transaction';
66

7+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
78
function wrapComparer<T>(comparer: (subject: any, cmp: T) => CompareResult) {
9+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
810
return function (this: any, cmp: T) {
911
const result = comparer(this._obj, cmp);
1012
this.assert(result.pass, result.posMessage(), result.negMessage());

src/test/comparisons.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@ import { Address, Cell, Slice } from '@ton/core';
22

33
import { CompareResult } from './interface';
44

5+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
56
export function compareCellForTest(subject: any, cmp: Cell): CompareResult {
67
return {
78
pass: cmp.equals(subject),
9+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
810
posMessage: ((subject: any, cmp: Cell) => `Expected\n${subject}\nto equal\n${cmp}`).bind(
911
undefined,
1012
subject,
1113
cmp,
1214
),
15+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1316
negMessage: ((subject: any, cmp: Cell) => `Expected\n${subject}\nNOT to equal\n${cmp}\nbut it does`).bind(
1417
undefined,
1518
subject,
@@ -18,14 +21,17 @@ export function compareCellForTest(subject: any, cmp: Cell): CompareResult {
1821
};
1922
}
2023

24+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2125
export function compareAddressForTest(subject: any, cmp: Address): CompareResult {
2226
return {
2327
pass: cmp.equals(subject),
28+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2429
posMessage: ((subject: any, cmp: Address) => `Expected ${subject} to equal ${cmp}`).bind(
2530
undefined,
2631
subject,
2732
cmp,
2833
),
34+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2935
negMessage: ((subject: any, cmp: Address) => `Expected ${subject} NOT to equal ${cmp}, but it does`).bind(
3036
undefined,
3137
subject,
@@ -34,14 +40,17 @@ export function compareAddressForTest(subject: any, cmp: Address): CompareResult
3440
};
3541
}
3642

43+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
3744
export function compareSliceForTest(subject: any, cmp: Slice): CompareResult {
3845
return {
3946
pass: cmp.asCell().equals(subject.asCell()),
47+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
4048
posMessage: ((subject: any, cmp: Slice) => `Expected\n${subject}\nto equal\n${cmp}`).bind(
4149
undefined,
4250
subject,
4351
cmp,
4452
),
53+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
4554
negMessage: ((subject: any, cmp: Slice) => `Expected\n${subject}\nNOT to equal\n${cmp}\nbut it does`).bind(
4655
undefined,
4756
subject,

src/test/jest.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { FlatTransactionComparable, compareTransactionForTest } from './transact
55
import { CompareResult } from './interface';
66
import { compareAddressForTest, compareCellForTest, compareSliceForTest } from './comparisons';
77

8+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
89
function wrapComparer<T>(comparer: (subject: any, cmp: T) => CompareResult): MatcherFunction<[cmp: T]> {
910
return function (actual, cmp) {
1011
const result = comparer(actual, cmp);

src/test/transaction.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ export function flattenTransaction(tx: Transaction): FlatTransaction {
116116
};
117117
}
118118

119+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
119120
function compareValue(a: any, b: any) {
120121
if (a instanceof Address) {
121122
if (!(b instanceof Address)) return false;
@@ -143,7 +144,9 @@ export function compareTransaction(tx: FlatTransaction, cmp: FlatTransactionComp
143144
for (const key in cmp) {
144145
if (!(key in tx)) throw new Error(`Unknown flat transaction object key ${key}`);
145146

147+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
146148
const cmpv = (cmp as any)[key];
149+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
147150
const txv = (tx as any)[key];
148151
if (typeof cmpv === 'function') {
149152
if (!cmpv(txv)) return false;
@@ -155,16 +158,19 @@ export function compareTransaction(tx: FlatTransaction, cmp: FlatTransactionComp
155158
return true;
156159
}
157160

161+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
158162
export function compareTransactionForTest(subject: any, cmp: FlatTransactionComparable): CompareResult {
159163
if (Array.isArray(subject)) {
160164
return {
161165
pass: subject.some((tx) => compareTransaction(flattenTransaction(tx), cmp)),
166+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
162167
posMessage: ((subj: any[], cmp: FlatTransactionComparable) =>
163168
`Expected ${inspect(subj.map((tx) => prettifyTransaction(tx)))} to contain a transaction that matches pattern ${inspect(cmp)}`).bind(
164169
undefined,
165170
subject,
166171
cmp,
167172
),
173+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
168174
negMessage: ((subj: any[], cmp: FlatTransactionComparable) =>
169175
`Expected ${inspect(subj.map((tx) => prettifyTransaction(tx)))} NOT to contain a transaction that matches pattern ${inspect(cmp)}, but it does`).bind(
170176
undefined,
@@ -176,12 +182,14 @@ export function compareTransactionForTest(subject: any, cmp: FlatTransactionComp
176182
try {
177183
return {
178184
pass: compareTransaction(flattenTransaction(subject), cmp),
185+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
179186
posMessage: ((subj: any, cmp: FlatTransactionComparable) =>
180187
`Expected ${inspect(prettifyTransaction(subj))} to match pattern ${inspect(cmp)}`).bind(
181188
undefined,
182189
subject,
183190
cmp,
184191
),
192+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
185193
negMessage: ((subj: any, cmp: FlatTransactionComparable) =>
186194
`Expected ${inspect(prettifyTransaction(subj))} NOT to match pattern ${inspect(cmp)}, but it does`).bind(
187195
undefined,
@@ -191,6 +199,7 @@ export function compareTransactionForTest(subject: any, cmp: FlatTransactionComp
191199
};
192200
} catch (e) {
193201
if (subject.transactions !== undefined) {
202+
// eslint-disable-next-line no-console
194203
console.warn(
195204
'It seems that a SendMessageResult is being used for this comparison. Please make sure to pass `result.transactions` instead of just `result` into the matcher.',
196205
);

0 commit comments

Comments
 (0)