Skip to content

Commit

Permalink
simplify tsconfig, build & lint
Browse files Browse the repository at this point in the history
  • Loading branch information
gsteenkamp89 committed Nov 1, 2024
1 parent f65a707 commit 843ca23
Show file tree
Hide file tree
Showing 14 changed files with 494 additions and 330 deletions.
7 changes: 6 additions & 1 deletion packages/eslint-config/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ const project = resolve(process.cwd(), "tsconfig.json");

/** @type {import("eslint").Linter.Config} */
module.exports = {
extends: ["eslint:recommended", "prettier", "turbo"],
extends: [
"eslint:recommended",
"prettier",
"turbo",
"plugin:@typescript-eslint/recommended",
],
plugins: ["only-warn"],
env: {
node: true,
Expand Down
6 changes: 4 additions & 2 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
"react-internal.js"
],
"devDependencies": {
"typescript": "^5.3.3"
},
"dependencies": {
"@next/eslint-plugin-next": "^14.1.4",
"@typescript-eslint/eslint-plugin": "^7.1.0",
"@typescript-eslint/parser": "^7.1.0",
"@vercel/style-guide": "^5.2.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-turbo": "^2.0.0",
"eslint-plugin-only-warn": "^1.1.0",
"typescript": "^5.3.3"
"eslint-plugin-only-warn": "^1.1.0"
}
}
11 changes: 0 additions & 11 deletions packages/sdk/.eslintrc.js

This file was deleted.

11 changes: 11 additions & 0 deletions packages/sdk/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"root": true,
"extends": ["@across-toolkit/eslint-config/library.js"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": true
},
"env": {
"es2020": true
}
}
15 changes: 7 additions & 8 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "@across-protocol/app-sdk",
"version": "0.0.3",
"main": "./dist/index.mjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.mts",
"main": "./dist/index.js",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"type": "module",
"description": "The official SDK for integrating Across bridge into your dapp.",
"keywords": [
"bridge",
Expand All @@ -29,13 +30,14 @@
"node": ">=18.0.0"
},
"scripts": {
"build-tsc": "tsc",
"build": "tsup src/index.ts --format esm --dts",
"dev": "tsup src/index.ts --format esm --watch --dts",
"lint": "pnpm run type-check && eslint \"src/**/*.ts*\"",
"type-check": "tsc",
"format": "prettier --write .",
"check-format": "prettier --check .",
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
"type-check": "tsc",
"check-exports": "attw --pack . --ignore-rules=cjs-resolves-to-esm",
"test": "vitest run --config ./vitest.config.mts",
"ci": "pnpm run build && pnpm run check-exports pnpm npm run lint && pnpm run test",
Expand All @@ -51,7 +53,7 @@
"msw": "^2.4.9",
"prettier": "^3.2.5",
"prool": "^0.0.16",
"tsup": "^8.0.2",
"tsup": "^8.3.5",
"typedoc": "^0.26.7",
"typedoc-plugin-markdown": "^4.2.8",
"typescript": "^5.3.3",
Expand All @@ -63,8 +65,5 @@
},
"peerDependencies": {
"viem": "^2.20.1"
},
"dependencies": {
"@across-protocol/constants": "^3.1.15"
}
}
2 changes: 1 addition & 1 deletion packages/sdk/src/actions/signUpdateDeposit.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Address, Hex, WalletClient } from "viem";
import { getUpdateDepositTypedData } from "../utils";
// eslint-disable-next-line no-unused-vars
// eslint-disable-next-line
import { simulateUpdateDepositTx } from "./simulateUpdateDepositTx";

export type SignUpdateDepositTypedDataParams = {
Expand Down
15 changes: 9 additions & 6 deletions packages/sdk/src/utils/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,19 @@ export function isOk(res: Response) {

function makeFetcher(
name: string,
apiErrorHandler?: (response: Response, data: any, url: string) => void,
apiErrorHandler?: (
response: Response,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
data: any,
url: string,
) => void,
) {
return async <ResBody, ReqParams = {}>(
return async <ResBody>(
apiUrl: string,
params: ReqParams,
params: Record<string, ParamBaseValue | Array<ParamBaseValue>>,
logger?: LoggerT,
): Promise<ResBody> => {
const searchParams = buildSearchParams(
params as Record<string, ParamBaseValue | Array<ParamBaseValue>>,
);
const searchParams = buildSearchParams(params);
const url = `${apiUrl}?${searchParams}`;

logger?.debug(`Fetching ${name}...`, url);
Expand Down
10 changes: 5 additions & 5 deletions packages/sdk/src/utils/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class DefaultLogger implements LoggerT {
/**
* Description - creates an indentation group for each call to `logger.[logLevel]()`
*/
log(logLevel: LogLevel, ...data: any[]) {
log(logLevel: LogLevel, ...data: unknown[]) {
const { label, prefix } = this.createLogLevelLabel(logLevel);
console.log(`${label}\n`);

Expand All @@ -39,26 +39,26 @@ export class DefaultLogger implements LoggerT {
});
}

debug(...data: any[]) {
debug(...data: unknown[]) {
// TODO it might be useful to show the file/function logging this data
if (LogLevels["DEBUG"] <= LogLevels[this.logLevel]) {
this.log("DEBUG", ...data);
}
}

info(...data: any[]) {
info(...data: unknown[]) {
if (LogLevels["INFO"] <= LogLevels[this.logLevel]) {
this.log("INFO", ...data);
}
}

warn(...data: any[]) {
warn(...data: unknown[]) {
if (LogLevels["WARN"] <= LogLevels[this.logLevel]) {
this.log("WARN", ...data);
}
}

error(...data: any[]) {
error(...data: unknown[]) {
if (LogLevels["ERROR"] <= LogLevels[this.logLevel]) {
this.log("ERROR", ...data);
}
Expand Down
3 changes: 0 additions & 3 deletions packages/sdk/test/package.json

This file was deleted.

27 changes: 0 additions & 27 deletions packages/sdk/test/tsconfig.json

This file was deleted.

15 changes: 12 additions & 3 deletions packages/sdk/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
{
"extends": "@across-toolkit/typescript-config/base.json",
"include": [".", "test/mocks/data/available-routes/.ts"],
"exclude": ["dist", "build", "node_modules", "test"],
"include": ["src/index.ts"],
"exclude": ["dist"],
"compilerOptions": {
"noEmit": true
"sourceMap": true,
"declarationMap": true,
"declaration": true,
"noEmit": true,
"moduleResolution": "Bundler",
"target": "es2022",
"lib": ["es2022", "dom", "dom.iterable"],
"paths": {
"@/*": ["./src/*"]
}
}
}
5 changes: 4 additions & 1 deletion packages/sdk/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ import { defineConfig } from "tsup";

export default defineConfig({
entryPoints: ["src/index.ts"],
format: ["esm"],
format: "esm",
dts: true,
outDir: "dist",
clean: true,
target: "esnext",
sourcemap: true,
treeshake: true,
});
23 changes: 7 additions & 16 deletions packages/typescript-config/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,15 @@
"$schema": "https://json.schemastore.org/tsconfig",
"display": "Default",
"compilerOptions": {
"composite": false,
"declaration": true,
"declarationMap": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"allowImportingTsExtensions": true,
"inlineSources": false,
"isolatedModules": true,
"module": "NodeNext",
"sourceMap": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"preserveWatchOutput": true,
"skipLibCheck": true,
"allowJs": true,
"resolveJsonModule": true,
"moduleDetection": "force",
"isolatedModules": true,
"verbatimModuleSyntax": false,
"strict": true,
"strictNullChecks": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true
},
"exclude": ["node_modules"]
"noImplicitOverride": true,
}
}
Loading

0 comments on commit 843ca23

Please sign in to comment.