Skip to content

Commit ce8ee66

Browse files
andraz maierLukaAvbreht
authored andcommitted
Refactor: upgrade linter and correct linter errors
1 parent d47ef01 commit ce8ee66

File tree

6 files changed

+24
-30
lines changed

6 files changed

+24
-30
lines changed

eslint.config.mjs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import eslint from '@eslint/js';
44
import tseslint from 'typescript-eslint';
5-
import * as importPlugin from 'eslint-plugin-import';
65

76
export default tseslint.config(
87
eslint.configs.recommended,
@@ -16,15 +15,8 @@ export default tseslint.config(
1615
tsconfigRootDir: import.meta.dirname,
1716
},
1817
},
19-
// extends: [
20-
// flatConfigs.recommended, flatConfigs.typescript
21-
// ],
22-
plugins: {
23-
import: importPlugin
24-
},
25-
// },
26-
// {
27-
// add aditional rules here
18+
// import plugins for rules
19+
// plugins: { import: importPlugin },
2820
rules: {
2921
// Disables the rule that prefers the namespace keyword over the module keyword for declaring TypeScript namespaces.
3022
'@typescript-eslint/prefer-namespace-keyword': 'off',
@@ -46,8 +38,6 @@ export default tseslint.config(
4638
'guard-for-in': 'warn',
4739
// Errors when a case in a switch statement falls through to the next case without a break statement or other termination.
4840
'no-fallthrough': 'error',
49-
// Only allow relative path imports (e.g., import { foo } from './foo';).
50-
'import/no-absolute-path': 'error',
5141
},
5242
},
5343
// Override rules for specific files

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
],
1212
"scripts": {
1313
"build": "nest build",
14-
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
1514
"start": "nest start",
1615
"start:dev": "nest start --watch",
1716
"start:debug": "nest start --debug --watch",

src/external-libs/AttestationDefinitionStore.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,16 +164,16 @@ export class AttestationDefinitionStore {
164164
) {
165165
throw new Error(`Invalid request ABI`);
166166
}
167-
const requestBodyAbi: unknown = definition.requestAbi.components.find(
167+
const requestBodyAbi = definition.requestAbi.components.find(
168168
(item: ABIFragment) => item.name == 'requestBody',
169-
);
169+
) as ABIFragment;
170170
if (!requestBodyAbi) {
171171
throw new Error(
172172
`Invalid request ABI for attestation type id: '${request.attestationType}'. No 'requestBody'.`,
173173
);
174174
}
175175
const abiEncodeBody = this.coder.encode(
176-
[requestBodyAbi],
176+
[requestBodyAbi as unknown as ParamType],
177177
[request.requestBody],
178178
);
179179
return ethers.concat([abiEncodePrefix, abiEncodeBody]);
@@ -217,24 +217,23 @@ export class AttestationDefinitionStore {
217217
) {
218218
throw new Error(`Invalid request ABI`);
219219
}
220-
const requestBodyAbi: unknown = definition.requestAbi?.components.find(
220+
const requestBodyAbi = definition.requestAbi?.components.find(
221221
(item: ABIFragment) => item.name == 'requestBody',
222-
);
222+
) as ABIFragment;
223223
if (!requestBodyAbi) {
224224
throw new Error(
225225
`Invalid request ABI for attestation type id: '${prefix.attestationType}'. No 'requestBody'.`,
226226
);
227227
}
228-
229228
const parsed: unknown = this.coder.decode(
230-
[requestBodyAbi],
229+
[requestBodyAbi as unknown as ParamType],
231230
'0x' + bytes.slice(2 + 3 * 64),
232231
)[0];
233232
return serializeBigInts({
234233
attestationType: prefix.attestationType,
235234
sourceId: prefix.sourceId,
236235
messageIntegrityCode: prefix.messageIntegrityCode,
237-
requestBody: remapABIParsedToObjects(parsed, requestBodyAbi) as unknown,
236+
requestBody: remapABIParsedToObjects(parsed, requestBodyAbi),
238237
}) as AR;
239238
}
240239

src/external-libs/utils.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,21 +150,21 @@ export function decodeAttestationName(encoded: string) {
150150
* @returns
151151
*/
152152
export function remapABIParsedToObjects(
153-
decoded: any,
153+
decoded: unknown,
154154
abi: ABIFragment,
155155
ignoreArray = false,
156-
): any {
156+
): unknown {
157157
if (abi.type == 'tuple' || (abi.type == 'tuple[]' && ignoreArray)) {
158-
const result: any = {};
158+
const result = {};
159159
for (const [index, item] of abi.components.entries()) {
160160
const key = item.name;
161161
result[key] = remapABIParsedToObjects(decoded[index], item);
162162
}
163163
return result;
164164
}
165165
if (abi.type == 'tuple[]') {
166-
const result: any = [];
167-
for (const item of decoded) {
166+
const result = [];
167+
for (const item of decoded as unknown[]) {
168168
result.push(remapABIParsedToObjects(item, abi, true));
169169
}
170170
return result;
@@ -181,8 +181,8 @@ export function remapABIParsedToObjects(
181181
// we assume here we have `type[]` where `type` is one of simple types.
182182
const match = abi.type.match(/^(.+)\[\]$/);
183183
if (match && isSupportedBasicSolidityType(match[1])) {
184-
const result: any = [];
185-
for (const item of decoded) {
184+
const result = [];
185+
for (const item of decoded as unknown[]) {
186186
result.push(item);
187187
}
188188
return result;

src/services/common/verifier-base.service.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ interface IVerificationServiceWithIndexerConfig
4343
| typeof XrpIndexerQueryManager;
4444
}
4545

46-
export type ITypeSpecificVerificationServiceConfig = Omit<IVerificationServiceWithIndexerConfig, 'attestationName'>;
46+
export type ITypeSpecificVerificationServiceConfig = Omit<
47+
IVerificationServiceWithIndexerConfig,
48+
'attestationName'
49+
>;
4750

4851
export abstract class BaseVerifierService<
4952
Req extends AttestationTypeBase_Request,

src/utils/api-models/ApiResponse.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ export async function handleApiResponse<T>(
7676
return new ApiResponseWrapper<T>(resp);
7777
} catch (reason) {
7878
if (sanitize) {
79-
const message = reason instanceof Error ? reason.message : 'Error while processing request';
79+
const message =
80+
reason instanceof Error
81+
? reason.message
82+
: 'Error while processing request';
8083
return new ApiResponseWrapper<T>(
8184
undefined,
8285
ApiResStatusEnum.ERROR,

0 commit comments

Comments
 (0)