Skip to content

Commit

Permalink
Unify and update TypeScript, ESLint and yarn version + fix detected e…
Browse files Browse the repository at this point in the history
…slint issues (#81)
  • Loading branch information
Muhammad-Altabba authored Dec 20, 2024
1 parent 7709f9e commit 806dfb1
Show file tree
Hide file tree
Showing 27 changed files with 14,846 additions and 10,097 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
with:
node-version: ${{ matrix.node }}
cache: yarn
- run: corepack enable
- run: yarn install
- run: yarn workspace circle-demo-webapp lint
- run: yarn workspace circle-demo-webapp build
1 change: 1 addition & 0 deletions .github/workflows/publish-storybook-gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
with:
node-version: 20
cache: yarn
- run: corepack enable
- run: yarn install
- run: yarn workspace circle-demo-webapp build-storybook
- name: Setup Pages
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ node_modules
.idea
.vscode
tmp
.history
.yarn/install-state.gz
941 changes: 941 additions & 0 deletions .yarn/releases/yarn-4.5.3.cjs

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.5.3.cjs
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
"dev": "yarn workspace circle-demo-webapp dev",
"start": "yarn workspace circle-demo-webapp start"
},
"packageManager": "yarn@1.22.22"
"packageManager": "yarn@4.5.3"
}
11 changes: 6 additions & 5 deletions packages/circle-demo-webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"build-storybook": "storybook build"
},
"dependencies": {
"@chainsafe/eslint-config": "^2.2.4",
"@circle-fin/developer-controlled-wallets": "^6.0.0",
"@radix-ui/react-avatar": "^1.1.1",
"@radix-ui/react-dialog": "^1.1.2",
Expand Down Expand Up @@ -46,24 +47,24 @@
"@types/node": "^22.9.0",
"@types/react": "^18.2.20",
"@types/react-dom": "^18.2.7",
"@typescript-eslint/eslint-plugin": "^6.7.4",
"@typescript-eslint/parser": "^6.7.4",
"@typescript-eslint/eslint-plugin": "^8.18.1",
"@typescript-eslint/parser": "^8.18.1",
"@vitejs/plugin-react": "^4.3.3",
"autoprefixer": "^10.4.19",
"eslint": "^8.38.0",
"eslint": "^9.17.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-hooks": "^5.1.0",
"eslint-plugin-storybook": "^0.11.1",
"postcss": "^8.4.38",
"prettier": "^3.4.1",
"storybook": "^8.4.7",
"storybook-dark-mode": "^4.0.2",
"tailwindcss": "^3.4.4",
"typescript": "^5.1.6",
"typescript": "^5.7.2",
"typescript-eslint": "^8.11.0",
"vite": "^5.1.0",
"vite-tsconfig-paths": "^4.2.1"
Expand Down
69 changes: 69 additions & 0 deletions packages/web3-circle-sdk/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import globals from 'globals';
import importPlugin from 'eslint-plugin-import';
import js from '@eslint/js';
import prettier from 'eslint-plugin-prettier';
import react from 'eslint-plugin-react';
import reactHooks from 'eslint-plugin-react-hooks';
import reactRefresh from 'eslint-plugin-react-refresh';
import tseslint from 'typescript-eslint';

export default tseslint.config(
{ ignores: ['lib'] },
{
extends: [
js.configs.recommended,
...tseslint.configs.recommendedTypeChecked, // or tseslint.configs.strictTypeChecked
...tseslint.configs.stylisticTypeChecked,
],
files: ['**/*.{ts,tsx}'],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
parserOptions: {
project: ['./tsconfig.json'],
tsconfigRootDir: import.meta.dirname,
},
},
plugins: {
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
react,
prettier,
import: importPlugin,
},
rules: {
...reactHooks.configs.recommended.rules,
...react.configs.recommended.rules,
...react.configs['jsx-runtime'].rules,
'import/order': [
'error',
{
groups: ['builtin', 'external', 'internal', ['parent', 'sibling', 'index']],
pathGroups: [
{
pattern: '~/**',
group: 'internal',
},
],
pathGroupsExcludedImportTypes: ['builtin', 'external'],
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
'newlines-between': 'always',
},
],
'prettier/prettier': 'error',
'arrow-body-style': 'off',
'prefer-arrow-callback': 'off',
},
settings: {
react: {
version: 'detect',
},
'import/resolver': {
typescript: {},
},
},
},
);
11 changes: 6 additions & 5 deletions packages/web3-circle-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,19 @@
"url": "[email protected]:ChainSafe/web3-circle-libs.git"
},
"devDependencies": {
"@chainsafe/eslint-config": "^2.0.0",
"@chainsafe/eslint-config": "^2.2.4",
"@types/jest": "^29.5.2",
"@types/node": "^20.2.6",
"@types/node-forge": "^1.3.11",
"eslint": "8",
"@typescript-eslint/eslint-plugin": "^8.18.1",
"@typescript-eslint/parser": "^8.18.1",
"eslint": "^9.17.0",
"jest": "^29.5.0",
"jest-extended": "^4.0.0",
"ts-jest": "^29.1.0",
"ts-node": "^10.9.1",
"typedoc": "^0.26.11",
"typescript": "^5.1.3",
"web3": "^4.2.2"
"typedoc": "^0.27.5",
"typescript": "^5.7.2"
},
"dependencies": {
"cross-fetch": "^4.0.0",
Expand Down
15 changes: 8 additions & 7 deletions packages/web3-circle-sdk/src/BaseApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { v4 } from 'uuid';
import { BASE_URL } from './constants';
import { objectToUrlParams } from './utils';

type ResponseData<ReturnType> = {
interface ResponseData<ReturnType> {
code: number;
message?: string;
data: ReturnType;
Expand All @@ -14,12 +14,13 @@ type ResponseData<ReturnType> = {
invalidValue: string;
error: string;
}[];
};
type RequestData = { headers: HeadersInit; body: BodyInit };

interface BaseParams {
[key: string]: unknown; // Allows any other properties
}
interface RequestData {
headers: HeadersInit;
body: BodyInit;
}

type BaseParams = Record<string, unknown>;

/**
* Methods for sending requests to the Circle REST API
Expand Down Expand Up @@ -50,7 +51,7 @@ export class BaseApi {
};
}

protected addIdempotencyKeyToParams<Param extends { [key: string]: unknown }>(
protected addIdempotencyKeyToParams<Param extends Record<string, unknown>>(
params: Param,
): Param & { idempotencyKey: string } {
return {
Expand Down
8 changes: 3 additions & 5 deletions packages/web3-circle-sdk/src/DeveloperApi.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BaseApi } from './BaseApi';
import { SecretApi } from './SecretApi';
import { BASE_URL } from './constants';
import { SecretApi } from './SecretApi';

export class DeveloperApi extends BaseApi {
protected secret?: string;
Expand All @@ -23,7 +23,7 @@ export class DeveloperApi extends BaseApi {
}
return SecretApi.getEntitySecretCiphertext(this.secret, this.publicKey);
}
protected async addCipherTextToParams<Param extends { [key: string]: unknown }>(
protected async addCipherTextToParams<Param extends Record<string, unknown>>(
params: Param,
): Promise<Param & { entitySecretCiphertext: string }> {
return {
Expand All @@ -33,9 +33,7 @@ export class DeveloperApi extends BaseApi {
: await this.generateCipherText(),
};
}
protected addCipherTextAndIdempotencyKeyToParams<
Param extends { [key: string]: unknown },
>(
protected addCipherTextAndIdempotencyKeyToParams<Param extends Record<string, unknown>>(
params: Param,
): Promise<Param & { entitySecretCiphertext: string; idempotencyKey: string }> {
return this.addCipherTextToParams<Param & { idempotencyKey: string }>(
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-circle-sdk/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { BASE_URL } from './constants';
import { FaucetApi } from './FaucetApi';
import { MonitoredTokensApi } from './MonitoredTokensApi';
import { SecretApi } from './SecretApi';
Expand All @@ -9,7 +10,6 @@ import { TokenLookupApi } from './TokenLookupApi';
import { TransactionApi } from './TransactionApi';
import { WalletApi } from './WalletApi';
import { WalletSetApi } from './WalletSetApi';
import { BASE_URL } from './constants';

// types and constants
export * from './constants';
Expand Down
Loading

0 comments on commit 806dfb1

Please sign in to comment.