Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3fbb460

Browse files
committedOct 10, 2024
fix: many type fixes, eslint bump and config migration
1 parent 5c69b6b commit 3fbb460

File tree

15 files changed

+816
-458
lines changed

15 files changed

+816
-458
lines changed
 

‎eslint-config/package.json

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,22 @@
55
"main": ".eslintrc.js",
66
"license": "MIT",
77
"dependencies": {
8-
"@typescript-eslint/eslint-plugin": "^5.62.0",
9-
"@typescript-eslint/parser": "^5.62.0",
10-
"@typescript-eslint/utils": "^5.62.0",
11-
"eslint-config-prettier": "^8.10.0",
12-
"eslint-config-standard": "^16.0.3",
13-
"eslint-plugin-import": "^2.29.1",
8+
"@typescript-eslint/eslint-plugin": "^8.8.1",
9+
"@typescript-eslint/parser": "^8.8.1",
10+
"@typescript-eslint/utils": "^8.8.1",
11+
"eslint-config-prettier": "^9.1.0",
12+
"eslint-config-standard": "^17.1.0",
13+
"eslint-plugin-import": "^2.31.0",
1414
"eslint-plugin-node": "^11.1.0",
15-
"eslint-plugin-prettier": "^4.2.1",
16-
"eslint-plugin-promise": "^5.2.0",
17-
"eslint-plugin-security": "^1.7.1",
15+
"eslint-plugin-prettier": "^5.2.1",
16+
"eslint-plugin-promise": "^6.0.0",
17+
"eslint-plugin-security": "^3.0.1",
1818
"eslint-utils": "^3.0.0"
1919
},
2020
"devDependencies": {
21+
"@eslint/eslintrc": "^3.1.0",
22+
"@eslint/js": "^9.12.0",
23+
"globals": "^15.11.0",
2124
"typescript": "^5.3.3"
2225
},
2326
"peerDependencies": {

‎kleros-sdk/src/dataMappings/actions/callAction.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export const callAction = async (mapping: AbiCallMapping, alchemyApiKey: string)
1313
const data = await publicClient.readContract({
1414
address,
1515
abi: [parsedAbi],
16+
functionName: "TODO: FIX ME",
1617
args,
1718
});
1819

‎kleros-sdk/src/dataMappings/actions/eventAction.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { parseAbiItem } from "viem";
2+
import { type AbiEvent } from "abitype";
23
import { AbiEventMapping } from "src/dataMappings/utils/actionTypes";
34
import { createResultObject } from "src/dataMappings/utils/createResultObject";
45
import { configureSDK, getPublicClient } from "src/sdk";
@@ -8,17 +9,17 @@ export const eventAction = async (mapping: AbiEventMapping, alchemyApiKey: strin
89
const publicClient = getPublicClient();
910

1011
const { abi: source, address, eventFilter, seek, populate } = mapping;
11-
const parsedAbi = typeof source === "string" ? parseAbiItem(source) : source;
12+
const parsedAbi = parseAbiItem(source) as AbiEvent;
1213

1314
const filter = await publicClient.createEventFilter({
1415
address,
1516
event: parsedAbi,
1617
args: eventFilter.args,
17-
fromBlock: eventFilter.fromBlock,
18-
toBlock: eventFilter.toBlock,
18+
fromBlock: eventFilter.fromBlock ? BigInt(eventFilter.fromBlock.toString()) : undefined,
19+
toBlock: eventFilter.toBlock ? BigInt(eventFilter.toBlock.toString()) : undefined,
1920
});
2021

21-
const contractEvent = await publicClient.getFilterLogs({ filter: filter as any });
22+
const contractEvent = await publicClient.getFilterLogs({ filter });
2223
const eventData = contractEvent[0].args;
2324

2425
return createResultObject(eventData, seek, populate);

‎kleros-sdk/src/dataMappings/executeActions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const executeAction = async (
2424
mapping: ActionMapping,
2525
context: Record<string, unknown> = {}
2626
): Promise<ActionResult> => {
27-
mapping = replacePlaceholdersWithValues(mapping, context);
27+
mapping = replacePlaceholdersWithValues(mapping, context) as ActionMapping;
2828

2929
switch (mapping.type) {
3030
case "graphql":

‎kleros-sdk/src/dataMappings/utils/actionTypes.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { type Address } from "viem";
2+
13
export type JsonMapping = {
24
type: string;
35
value: object;
@@ -17,7 +19,7 @@ export interface SubgraphMapping {
1719
export type AbiCallMapping = {
1820
type: string;
1921
abi: string;
20-
address: string;
22+
address: Address;
2123
args: any[];
2224
seek: string[];
2325
populate: string[];
@@ -26,7 +28,7 @@ export type AbiCallMapping = {
2628
export type AbiEventMapping = {
2729
type: string;
2830
abi: string;
29-
address: string;
31+
address: Address;
3032
eventFilter: {
3133
fromBlock: BigInt | string;
3234
toBlock: BigInt | string;

‎kleros-sdk/src/dataMappings/utils/disputeDetailsSchema.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { z } from "zod";
22
import { isAddress } from "viem";
33
import { normalize } from "viem/ens";
44

5-
const isHexAddress = (str: string): boolean => /^0x[a-fA-F0-9]{40}$/.test(str);
6-
const isHexId = (str: string): boolean => /^0x[a-fA-F0-9]{1,64}$/.test(str);
7-
const isMultiaddr = (str: string): boolean =>
5+
export const isHexAddress = (str: string): boolean => /^0x[a-fA-F0-9]{40}$/.test(str);
6+
export const isHexId = (str: string): boolean => /^0x[a-fA-F0-9]{1,64}$/.test(str);
7+
export const isMultiaddr = (str: string): boolean =>
88
/^\/(?:ip4|ip6|dns4|dns6|dnsaddr|tcp|udp|utp|tls|ws|wss|p2p-circuit|p2p-webrtc-star|p2p-webrtc-direct|p2p-websocket-star|onion|ipfs)(\/[^\s\/]+)+$|^ipfs:\/\/[a-zA-Z0-9]+\/[a-zA-Z0-9]+(\.[a-zA-Z0-9]+)?$/.test(
99
str
1010
);
Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
import mustache from "mustache";
2+
import { ActionMapping } from "./actionTypes";
23

3-
export const replacePlaceholdersWithValues = (mapping: any, context: Record<string, unknown>) => {
4-
const replace = (obj) => {
4+
export function replacePlaceholdersWithValues(
5+
mapping: ActionMapping,
6+
context: Record<string, unknown>
7+
): ActionMapping | ActionMapping[] {
8+
function replace(obj: ActionMapping): ActionMapping | ActionMapping[] {
59
if (typeof obj === "string") {
6-
return mustache.render(obj, context);
10+
return mustache.render(obj, context) as unknown as ActionMapping;
711
} else if (Array.isArray(obj)) {
8-
return obj.map(replace);
12+
return obj.map(replace) as unknown as ActionMapping[];
913
} else if (typeof obj === "object" && obj !== null) {
10-
return Object.fromEntries(Object.entries(obj).map(([key, value]) => [key, replace(value)]));
14+
return Object.fromEntries(
15+
Object.entries(obj).map(([key, value]) => [key, replace(value)])
16+
) as unknown as ActionMapping[];
1117
} else {
1218
return obj;
1319
}
14-
};
20+
}
1521

1622
return replace(mapping);
17-
};
23+
}

‎kleros-sdk/src/sdk.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { createPublicClient, webSocket } from "viem";
1+
import { createPublicClient, webSocket, type PublicClient } from "viem";
22
import { arbitrumSepolia } from "viem/chains";
33

4-
let publicClient;
4+
let publicClient: PublicClient | undefined;
55

66
export const configureSDK = (config: { apiKey?: string }) => {
77
if (config.apiKey) {
@@ -14,7 +14,7 @@ export const configureSDK = (config: { apiKey?: string }) => {
1414
}
1515
};
1616

17-
export const getPublicClient = () => {
17+
export const getPublicClient = (): PublicClient => {
1818
if (!publicClient) {
1919
throw new Error("SDK not configured. Please call `configureSDK` before using.");
2020
}

‎prettier-config/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"main": "index.js",
55
"license": "MIT",
66
"dependencies": {
7-
"eslint": "^8.56.0",
7+
"eslint": "^8.57.1",
88
"prettier": "^2.8.8",
99
"prettier-plugin-solidity": "^1.3.1"
1010
},

‎web-devtools/.eslintignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

‎web-devtools/.eslintrc.json

Lines changed: 0 additions & 166 deletions
This file was deleted.

‎web-devtools/eslint.config.mjs

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
import { fixupConfigRules, fixupPluginRules } from "@eslint/compat";
2+
import react from "eslint-plugin-react";
3+
import reactHooks from "eslint-plugin-react-hooks";
4+
import security from "eslint-plugin-security";
5+
import _import from "eslint-plugin-import";
6+
import globals from "globals";
7+
import tsParser from "@typescript-eslint/parser";
8+
import path from "node:path";
9+
import { fileURLToPath } from "node:url";
10+
import js from "@eslint/js";
11+
import { FlatCompat } from "@eslint/eslintrc";
12+
13+
const __filename = fileURLToPath(import.meta.url);
14+
const __dirname = path.dirname(__filename);
15+
const compat = new FlatCompat({
16+
baseDirectory: __dirname,
17+
recommendedConfig: js.configs.recommended,
18+
allConfig: js.configs.all
19+
});
20+
21+
export default [{
22+
ignores: ["src/assets", "src/hooks/contracts/generated.ts", "src/graphql/**/*.ts"],
23+
}, ...fixupConfigRules(compat.extends(
24+
"next/core-web-vitals",
25+
"eslint:recommended",
26+
"plugin:react/recommended",
27+
"plugin:react-hooks/recommended",
28+
"plugin:import/recommended",
29+
"plugin:import/react",
30+
"plugin:security/recommended",
31+
"plugin:@typescript-eslint/recommended",
32+
"plugin:prettier/recommended",
33+
"prettier",
34+
)), {
35+
plugins: {
36+
react: fixupPluginRules(react),
37+
"react-hooks": fixupPluginRules(reactHooks),
38+
security: fixupPluginRules(security),
39+
import: fixupPluginRules(_import),
40+
},
41+
42+
languageOptions: {
43+
globals: {
44+
...globals.browser,
45+
...globals.node,
46+
Atomics: "readonly",
47+
SharedArrayBuffer: "readonly",
48+
},
49+
50+
parser: tsParser,
51+
ecmaVersion: 2020,
52+
sourceType: "module",
53+
54+
parserOptions: {
55+
ecmaFeatures: {
56+
jsx: true,
57+
},
58+
},
59+
},
60+
61+
settings: {
62+
react: {
63+
version: "^16.12.0",
64+
},
65+
66+
"import/resolver": {
67+
typescript: {
68+
alwaysTryTypes: true,
69+
project: "./tsconfig.json",
70+
},
71+
72+
node: {
73+
extensions: [".js", ".jsx", ".ts", ".tsx"],
74+
},
75+
},
76+
},
77+
78+
rules: {
79+
"max-len": ["warn", {
80+
code: 120,
81+
}],
82+
83+
"react/prop-types": 0,
84+
"no-unused-vars": "off",
85+
86+
"@typescript-eslint/no-unused-vars": ["error", {
87+
varsIgnorePattern: "(^_+[0-9]*$)|([iI]gnored$)|(^ignored)",
88+
argsIgnorePattern: "(^_+[0-9]*$)|([iI]gnored$)|(^ignored)",
89+
}],
90+
91+
"no-console": ["error", {
92+
allow: ["warn", "error", "info", "debug"],
93+
}],
94+
95+
"@typescript-eslint/no-non-null-assertion": "off",
96+
"@typescript-eslint/no-explicit-any": "off",
97+
"security/detect-object-injection": "off",
98+
"security/detect-non-literal-fs-filename": "off",
99+
100+
"import/extensions": ["error", "ignorePackages", {
101+
js: "never",
102+
jsx: "never",
103+
ts: "never",
104+
tsx: "never",
105+
}],
106+
107+
"import/no-unresolved": "off",
108+
109+
"import/order": ["warn", {
110+
groups: ["builtin", "external", "internal", "parent", "sibling", "index"],
111+
112+
pathGroups: [{
113+
pattern: "{react,styled-components}",
114+
group: "external",
115+
position: "before",
116+
}, {
117+
pattern: "@kleros/**",
118+
group: "external",
119+
position: "after",
120+
}, {
121+
pattern: "{svgs/**,assets/**}",
122+
group: "internal",
123+
position: "after",
124+
}, {
125+
pattern: "{hooks/**,utils/**,consts/**,types/**,context/**,connectors/**,}",
126+
group: "internal",
127+
position: "after",
128+
}, {
129+
pattern: "{queries/**,}",
130+
group: "internal",
131+
position: "after",
132+
}, {
133+
pattern: "{src/**,}",
134+
group: "internal",
135+
position: "after",
136+
}, {
137+
pattern: "{styles/**,}",
138+
group: "internal",
139+
position: "after",
140+
}, {
141+
pattern: "{layout/**,pages/**,components/**,}",
142+
group: "internal",
143+
position: "after",
144+
}],
145+
146+
pathGroupsExcludedImportTypes: ["builtin"],
147+
"newlines-between": "always",
148+
149+
alphabetize: {
150+
order: "asc",
151+
caseInsensitive: true,
152+
},
153+
}],
154+
},
155+
}];

‎web-devtools/package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@
3030
"@types/node": "^20",
3131
"@types/react": "18.2.0",
3232
"@types/react-dom": "^18.2.18",
33-
"@typescript-eslint/eslint-plugin": "^5.62.0",
34-
"@typescript-eslint/parser": "^5.62.0",
35-
"@typescript-eslint/utils": "^5.62.0",
33+
"@typescript-eslint/eslint-plugin": "^8.8.1",
34+
"@typescript-eslint/parser": "^8.8.1",
35+
"@typescript-eslint/utils": "^8.8.1",
3636
"@wagmi/cli": "^2.0.3",
37-
"eslint": "^8.56.0",
38-
"eslint-config-next": "^14.2.5",
39-
"eslint-config-prettier": "^8.10.0",
40-
"eslint-import-resolver-typescript": "^3.6.1",
41-
"eslint-plugin-react": "^7.33.2",
42-
"eslint-plugin-react-hooks": "^4.6.0",
37+
"eslint": "^8.57.1",
38+
"eslint-config-next": "^14.2.15",
39+
"eslint-config-prettier": "^9.1.0",
40+
"eslint-import-resolver-typescript": "^3.6.3",
41+
"eslint-plugin-react": "^7.37.1",
42+
"eslint-plugin-react-hooks": "^4.6.2",
4343
"ts-node": "^10.9.2",
4444
"typescript": "^5.5.3"
4545
},

‎web/package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@
5858
"@types/react": "18.2.0",
5959
"@types/react-dom": "^18.2.18",
6060
"@types/styled-components": "^5.1.34",
61-
"@typescript-eslint/eslint-plugin": "^5.62.0",
62-
"@typescript-eslint/parser": "^5.62.0",
63-
"@typescript-eslint/utils": "^5.62.0",
61+
"@typescript-eslint/eslint-plugin": "^8.8.1",
62+
"@typescript-eslint/parser": "^8.8.1",
63+
"@typescript-eslint/utils": "^8.8.1",
6464
"@wagmi/cli": "^2.0.3",
65-
"eslint": "^8.56.0",
66-
"eslint-config-prettier": "^8.10.0",
67-
"eslint-import-resolver-typescript": "^3.6.1",
68-
"eslint-plugin-react": "^7.33.2",
69-
"eslint-plugin-react-hooks": "^4.6.0",
65+
"eslint": "^8.57.1",
66+
"eslint-config-prettier": "^9.1.0",
67+
"eslint-import-resolver-typescript": "^3.6.3",
68+
"eslint-plugin-react": "^7.37.1",
69+
"eslint-plugin-react-hooks": "^4.6.2",
7070
"lru-cache": "^7.18.3",
7171
"supabase": "^1.133.3",
7272
"typescript": "^5.3.3",

‎yarn.lock

Lines changed: 601 additions & 242 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.