Skip to content

Commit

Permalink
[SDK] Feature: Adds tsdoc parsing and other eslint rules (#5622)
Browse files Browse the repository at this point in the history
<!-- 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 -->
  • Loading branch information
gregfromstl committed Dec 7, 2024
1 parent 43fbcac commit 8234dba
Show file tree
Hide file tree
Showing 7 changed files with 281 additions and 156 deletions.
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@
"ws@>=8.0.0 <8.17.1": "8.17.1",
"ws@>=7.0.0 <7.5.10": "7.5.10",
"ws@>=6.0.0 <6.2.3": "6.2.3",
"eslint": "8.57.0",
"@typescript-eslint/typescript-estree": "^7.14.1",
"axios@<1.7.4": "^1.7.4",
"send@<0.19.0": "^0.19.0",
"elliptic@<6.5.7": "^6.5.7",
Expand Down
54 changes: 54 additions & 0 deletions packages/thirdweb/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
module.exports = {
rules: {
"no-restricted-syntax": [
"warn",
{
selector: "CallExpression[callee.name='useEffect']",
message:
'Are you *sure* you need to use "useEffect" here? If you loading any async function prefer using "useQuery".',
},
{
selector: "CallExpression[callee.name='createContext']",
message:
'Are you *sure* you need to use a "Context"? In almost all cases you should prefer passing props directly.',
},
{
selector: "CallExpression[callee.name='defineChain']",
message: "Use getCachedChain instead for all internal usage",
},
],
"no-unused-vars": [
"warn",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
destructuredArrayIgnorePattern: "^_",
ignoreRestSiblings: true,
args: "none", // Ignore variables used in type definitions
},
],
"tsdoc/syntax": "warn",
},
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint", "eslint-plugin-tsdoc"],
parserOptions: {
ecmaVersion: 2019,
ecmaFeatures: {
impliedStrict: true,
jsx: true,
},
warnOnUnsupportedTypeScriptVersion: false,
},
overrides: [
// THIS NEEDS TO GO LAST!
{
files: ["*.ts", "*.js", "*.tsx", "*.jsx"],
extends: ["biome"],
},
],
env: {
browser: true,
node: true,
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const URI_MOCK =

const DEFAULT_METADATA = getDefaultAppMetadata();

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

const signClientMock = {
on: vi.fn((event, listener) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/thirdweb/src/wallets/wallet-connect/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export type WCConnectOptions = {
* })
* ```
*/
onDisplayUri?: (uri: string) => void;
onDisplayUri?: (_uri: string) => void;
}
>;
};
Expand Down
2 changes: 1 addition & 1 deletion packages/thirdweb/src/wallets/wallet-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export type WalletAutoConnectionOption<T extends WalletId> =
* @example
* ```ts
* type X = WalletCreationOptions<'io.metamask'>
* ````
* ```
*/
export type WalletCreationOptions<T extends WalletId> = T extends "smart"
? SmartWalletOptions
Expand Down
236 changes: 120 additions & 116 deletions packages/thirdweb/tsdoc.json
Original file line number Diff line number Diff line change
@@ -1,118 +1,122 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
"tagDefinitions": [
{
"tagName": "@contract",
"syntaxKind": "block"
},
{
"tagName": "@wallet",
"syntaxKind": "block"
},
{
"tagName": "@extension",
"syntaxKind": "block"
},
{
"tagName": "@rpc",
"syntaxKind": "block"
},
{
"tagName": "@transaction",
"syntaxKind": "block"
},
{
"tagName": "@connectWallet",
"syntaxKind": "block"
},
{
"tagName": "@theme",
"syntaxKind": "block"
},
{
"tagName": "@locale",
"syntaxKind": "block"
},
{
"tagName": "@component",
"syntaxKind": "block"
},
{
"tagName": "@walletConfig",
"syntaxKind": "block"
},
{
"tagName": "@walletConnection",
"syntaxKind": "block"
},
{
"tagName": "@walletUtils",
"syntaxKind": "block"
},
{
"tagName": "@buyCrypto",
"syntaxKind": "block"
},
{
"tagName": "@storage",
"syntaxKind": "block"
},
{
"tagName": "@auth",
"syntaxKind": "block"
},
{
"tagName": "@utils",
"syntaxKind": "block"
},
{
"tagName": "@chain",
"syntaxKind": "block"
},
{
"tagName": "@modules",
"syntaxKind": "block"
},
{
"tagName": "@social",
"syntaxKind": "block"
},
{
"tagName": "@client",
"syntaxKind": "block"
},
{
"tagName": "@nft",
"syntaxKind": "block"
},
{
"tagName": "@account",
"syntaxKind": "block"
}
],
"supportForTags": {
"@contract": true,
"@wallet": true,
"@extension": true,
"@rpc": true,
"@transaction": true,
"@connectWallet": true,
"@theme": true,
"@locale": true,
"@component": true,
"@walletConfig": true,
"@walletConnection": true,
"@walletUtils": true,
"@buyCrypto": true,
"@storage": true,
"@auth": true,
"@utils": true,
"@chain": true,
"@modules": true,
"@social": true,
"@client": true,
"@nft": true,
"@account": true,
"@beta": true
}
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
"tagDefinitions": [
{
"tagName": "@example",
"syntaxKind": "block"
},
{
"tagName": "@contract",
"syntaxKind": "block"
},
{
"tagName": "@wallet",
"syntaxKind": "block"
},
{
"tagName": "@extension",
"syntaxKind": "block"
},
{
"tagName": "@rpc",
"syntaxKind": "block"
},
{
"tagName": "@transaction",
"syntaxKind": "block"
},
{
"tagName": "@connectWallet",
"syntaxKind": "block"
},
{
"tagName": "@theme",
"syntaxKind": "block"
},
{
"tagName": "@locale",
"syntaxKind": "block"
},
{
"tagName": "@component",
"syntaxKind": "block"
},
{
"tagName": "@walletConfig",
"syntaxKind": "block"
},
{
"tagName": "@walletConnection",
"syntaxKind": "block"
},
{
"tagName": "@walletUtils",
"syntaxKind": "block"
},
{
"tagName": "@buyCrypto",
"syntaxKind": "block"
},
{
"tagName": "@storage",
"syntaxKind": "block"
},
{
"tagName": "@auth",
"syntaxKind": "block"
},
{
"tagName": "@utils",
"syntaxKind": "block"
},
{
"tagName": "@chain",
"syntaxKind": "block"
},
{
"tagName": "@modules",
"syntaxKind": "block"
},
{
"tagName": "@social",
"syntaxKind": "block"
},
{
"tagName": "@client",
"syntaxKind": "block"
},
{
"tagName": "@nft",
"syntaxKind": "block"
},
{
"tagName": "@account",
"syntaxKind": "block"
}
],
"supportForTags": {
"@contract": true,
"@wallet": true,
"@extension": true,
"@rpc": true,
"@transaction": true,
"@connectWallet": true,
"@theme": true,
"@locale": true,
"@component": true,
"@walletConfig": true,
"@walletConnection": true,
"@walletUtils": true,
"@buyCrypto": true,
"@storage": true,
"@auth": true,
"@utils": true,
"@chain": true,
"@modules": true,
"@social": true,
"@client": true,
"@nft": true,
"@account": true,
"@beta": true
}
}
Loading

0 comments on commit 8234dba

Please sign in to comment.