Skip to content

Commit 8234dba

Browse files
committed
[SDK] Feature: Adds tsdoc parsing and other eslint rules (#5622)
<!-- start pr-codex --> ## PR-Codex overview This PR focuses on improving TypeScript typings, updating ESLint configurations, and refining package dependencies across various files in the `thirdweb` package. ### Detailed summary - Changed parameter name from `uri` to `_uri` in `onDisplayUri` callback. - Updated `WalletCreationOptions` type definition. - Modified listener type to use `_event`. - Added ESLint rules for better coding practices. - Removed outdated TSDoc tags and added `@example` tag. - Updated package dependencies in `pnpm-lock.yaml`. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent 43fbcac commit 8234dba

File tree

7 files changed

+281
-156
lines changed

7 files changed

+281
-156
lines changed

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@
7070
"ws@>=8.0.0 <8.17.1": "8.17.1",
7171
"ws@>=7.0.0 <7.5.10": "7.5.10",
7272
"ws@>=6.0.0 <6.2.3": "6.2.3",
73-
"eslint": "8.57.0",
74-
"@typescript-eslint/typescript-estree": "^7.14.1",
7573
"axios@<1.7.4": "^1.7.4",
7674
"send@<0.19.0": "^0.19.0",
7775
"elliptic@<6.5.7": "^6.5.7",

packages/thirdweb/.eslintrc.cjs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
module.exports = {
2+
rules: {
3+
"no-restricted-syntax": [
4+
"warn",
5+
{
6+
selector: "CallExpression[callee.name='useEffect']",
7+
message:
8+
'Are you *sure* you need to use "useEffect" here? If you loading any async function prefer using "useQuery".',
9+
},
10+
{
11+
selector: "CallExpression[callee.name='createContext']",
12+
message:
13+
'Are you *sure* you need to use a "Context"? In almost all cases you should prefer passing props directly.',
14+
},
15+
{
16+
selector: "CallExpression[callee.name='defineChain']",
17+
message: "Use getCachedChain instead for all internal usage",
18+
},
19+
],
20+
"no-unused-vars": [
21+
"warn",
22+
{
23+
argsIgnorePattern: "^_",
24+
varsIgnorePattern: "^_",
25+
caughtErrorsIgnorePattern: "^_",
26+
destructuredArrayIgnorePattern: "^_",
27+
ignoreRestSiblings: true,
28+
args: "none", // Ignore variables used in type definitions
29+
},
30+
],
31+
"tsdoc/syntax": "warn",
32+
},
33+
parser: "@typescript-eslint/parser",
34+
plugins: ["@typescript-eslint", "eslint-plugin-tsdoc"],
35+
parserOptions: {
36+
ecmaVersion: 2019,
37+
ecmaFeatures: {
38+
impliedStrict: true,
39+
jsx: true,
40+
},
41+
warnOnUnsupportedTypeScriptVersion: false,
42+
},
43+
overrides: [
44+
// THIS NEEDS TO GO LAST!
45+
{
46+
files: ["*.ts", "*.js", "*.tsx", "*.jsx"],
47+
extends: ["biome"],
48+
},
49+
],
50+
env: {
51+
browser: true,
52+
node: true,
53+
},
54+
};

packages/thirdweb/src/wallets/wallet-connect/receiver/receiver.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const URI_MOCK =
2727

2828
const DEFAULT_METADATA = getDefaultAppMetadata();
2929

30-
const listeners: Record<string, (event?: unknown) => Promise<void>> = {};
30+
const listeners: Record<string, (_event?: unknown) => Promise<void>> = {};
3131

3232
const signClientMock = {
3333
on: vi.fn((event, listener) => {

packages/thirdweb/src/wallets/wallet-connect/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ export type WCConnectOptions = {
160160
* })
161161
* ```
162162
*/
163-
onDisplayUri?: (uri: string) => void;
163+
onDisplayUri?: (_uri: string) => void;
164164
}
165165
>;
166166
};

packages/thirdweb/src/wallets/wallet-types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export type WalletAutoConnectionOption<T extends WalletId> =
134134
* @example
135135
* ```ts
136136
* type X = WalletCreationOptions<'io.metamask'>
137-
* ````
137+
* ```
138138
*/
139139
export type WalletCreationOptions<T extends WalletId> = T extends "smart"
140140
? SmartWalletOptions

packages/thirdweb/tsdoc.json

Lines changed: 120 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -1,118 +1,122 @@
11
{
2-
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
3-
"tagDefinitions": [
4-
{
5-
"tagName": "@contract",
6-
"syntaxKind": "block"
7-
},
8-
{
9-
"tagName": "@wallet",
10-
"syntaxKind": "block"
11-
},
12-
{
13-
"tagName": "@extension",
14-
"syntaxKind": "block"
15-
},
16-
{
17-
"tagName": "@rpc",
18-
"syntaxKind": "block"
19-
},
20-
{
21-
"tagName": "@transaction",
22-
"syntaxKind": "block"
23-
},
24-
{
25-
"tagName": "@connectWallet",
26-
"syntaxKind": "block"
27-
},
28-
{
29-
"tagName": "@theme",
30-
"syntaxKind": "block"
31-
},
32-
{
33-
"tagName": "@locale",
34-
"syntaxKind": "block"
35-
},
36-
{
37-
"tagName": "@component",
38-
"syntaxKind": "block"
39-
},
40-
{
41-
"tagName": "@walletConfig",
42-
"syntaxKind": "block"
43-
},
44-
{
45-
"tagName": "@walletConnection",
46-
"syntaxKind": "block"
47-
},
48-
{
49-
"tagName": "@walletUtils",
50-
"syntaxKind": "block"
51-
},
52-
{
53-
"tagName": "@buyCrypto",
54-
"syntaxKind": "block"
55-
},
56-
{
57-
"tagName": "@storage",
58-
"syntaxKind": "block"
59-
},
60-
{
61-
"tagName": "@auth",
62-
"syntaxKind": "block"
63-
},
64-
{
65-
"tagName": "@utils",
66-
"syntaxKind": "block"
67-
},
68-
{
69-
"tagName": "@chain",
70-
"syntaxKind": "block"
71-
},
72-
{
73-
"tagName": "@modules",
74-
"syntaxKind": "block"
75-
},
76-
{
77-
"tagName": "@social",
78-
"syntaxKind": "block"
79-
},
80-
{
81-
"tagName": "@client",
82-
"syntaxKind": "block"
83-
},
84-
{
85-
"tagName": "@nft",
86-
"syntaxKind": "block"
87-
},
88-
{
89-
"tagName": "@account",
90-
"syntaxKind": "block"
91-
}
92-
],
93-
"supportForTags": {
94-
"@contract": true,
95-
"@wallet": true,
96-
"@extension": true,
97-
"@rpc": true,
98-
"@transaction": true,
99-
"@connectWallet": true,
100-
"@theme": true,
101-
"@locale": true,
102-
"@component": true,
103-
"@walletConfig": true,
104-
"@walletConnection": true,
105-
"@walletUtils": true,
106-
"@buyCrypto": true,
107-
"@storage": true,
108-
"@auth": true,
109-
"@utils": true,
110-
"@chain": true,
111-
"@modules": true,
112-
"@social": true,
113-
"@client": true,
114-
"@nft": true,
115-
"@account": true,
116-
"@beta": true
117-
}
2+
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
3+
"tagDefinitions": [
4+
{
5+
"tagName": "@example",
6+
"syntaxKind": "block"
7+
},
8+
{
9+
"tagName": "@contract",
10+
"syntaxKind": "block"
11+
},
12+
{
13+
"tagName": "@wallet",
14+
"syntaxKind": "block"
15+
},
16+
{
17+
"tagName": "@extension",
18+
"syntaxKind": "block"
19+
},
20+
{
21+
"tagName": "@rpc",
22+
"syntaxKind": "block"
23+
},
24+
{
25+
"tagName": "@transaction",
26+
"syntaxKind": "block"
27+
},
28+
{
29+
"tagName": "@connectWallet",
30+
"syntaxKind": "block"
31+
},
32+
{
33+
"tagName": "@theme",
34+
"syntaxKind": "block"
35+
},
36+
{
37+
"tagName": "@locale",
38+
"syntaxKind": "block"
39+
},
40+
{
41+
"tagName": "@component",
42+
"syntaxKind": "block"
43+
},
44+
{
45+
"tagName": "@walletConfig",
46+
"syntaxKind": "block"
47+
},
48+
{
49+
"tagName": "@walletConnection",
50+
"syntaxKind": "block"
51+
},
52+
{
53+
"tagName": "@walletUtils",
54+
"syntaxKind": "block"
55+
},
56+
{
57+
"tagName": "@buyCrypto",
58+
"syntaxKind": "block"
59+
},
60+
{
61+
"tagName": "@storage",
62+
"syntaxKind": "block"
63+
},
64+
{
65+
"tagName": "@auth",
66+
"syntaxKind": "block"
67+
},
68+
{
69+
"tagName": "@utils",
70+
"syntaxKind": "block"
71+
},
72+
{
73+
"tagName": "@chain",
74+
"syntaxKind": "block"
75+
},
76+
{
77+
"tagName": "@modules",
78+
"syntaxKind": "block"
79+
},
80+
{
81+
"tagName": "@social",
82+
"syntaxKind": "block"
83+
},
84+
{
85+
"tagName": "@client",
86+
"syntaxKind": "block"
87+
},
88+
{
89+
"tagName": "@nft",
90+
"syntaxKind": "block"
91+
},
92+
{
93+
"tagName": "@account",
94+
"syntaxKind": "block"
95+
}
96+
],
97+
"supportForTags": {
98+
"@contract": true,
99+
"@wallet": true,
100+
"@extension": true,
101+
"@rpc": true,
102+
"@transaction": true,
103+
"@connectWallet": true,
104+
"@theme": true,
105+
"@locale": true,
106+
"@component": true,
107+
"@walletConfig": true,
108+
"@walletConnection": true,
109+
"@walletUtils": true,
110+
"@buyCrypto": true,
111+
"@storage": true,
112+
"@auth": true,
113+
"@utils": true,
114+
"@chain": true,
115+
"@modules": true,
116+
"@social": true,
117+
"@client": true,
118+
"@nft": true,
119+
"@account": true,
120+
"@beta": true
121+
}
118122
}

0 commit comments

Comments
 (0)