Skip to content

Commit

Permalink
include test folder in type checking in lint step
Browse files Browse the repository at this point in the history
  • Loading branch information
gsteenkamp89 committed Nov 4, 2024
1 parent 6f6ee52 commit 9efb854
Show file tree
Hide file tree
Showing 21 changed files with 57 additions and 49 deletions.
6 changes: 3 additions & 3 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
"scripts": {
"build:esm": "tsc --project tsconfig.build.json",
"build": "pnpm run build:esm",
"dev": "tsup src/index.ts --format esm --watch --dts",
"dev": "tsc --watch --project tsconfig.build.json",
"lint": "pnpm run type-check && eslint \"src/**/*.ts*\"",
"type-check": "tsc",
"type-check": "tsc --project tsconfig.json",
"format": "prettier --write .",
"check-format": "prettier --check .",
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
"check-exports": "attw --pack . --ignore-rules=cjs-resolves-to-esm",
"test": "vitest run --config ./vitest.config.mts",
"test": "vitest run --config ./vitest.config.ts",
"ci": "pnpm run build && pnpm run check-exports pnpm npm run lint && pnpm run test",
"typedoc": "typedoc --out docs src/index.ts"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/test/common/anvil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
FORK_URL_MAINNET,
pool,
PRIVATE_KEY,
} from "./constants";
} from "./constants.js";
import {
type Account,
type Client,
Expand All @@ -23,7 +23,7 @@ import {
walletActions,
} from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { type Compute } from "./utils";
import { type Compute } from "./utils.js";
import { createServer } from "prool";
import { anvil } from "prool/instances";

Expand Down
5 changes: 3 additions & 2 deletions packages/sdk/test/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ export const USDC_WHALE = getAddress(
);

function getEnv(key: string): string {
if (!process.env[key]) {
const value = process.env[key];
if (!value) {
throw new Error(`Missing environment variable "${key}"`);
}
return process.env[key];
return value;
}

function getMaybeEnv(key: string): string | undefined {
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/test/common/globalSetup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { chainClients } from "./anvil";
import { chainClients } from "./anvil.js";

export default async function () {
const servers = await Promise.all(
Expand Down
8 changes: 4 additions & 4 deletions packages/sdk/test/common/relayer.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { Hash, TransactionReceipt } from "viem";
import type { TransactionReceipt } from "viem";
import {
getDepositFromLogs,
type AcrossClient,
type ConfiguredPublicClient,
} from "../../src";
import type { ChainClient } from "./anvil";
import { spokePoolAbi } from "../../src/abis/SpokePool";
} from "../../src/index.js";
import type { ChainClient } from "./anvil.js";
import { spokePoolAbi } from "../../src/abis/SpokePool.js";

type RelayerParams = {
depositReceipt: TransactionReceipt;
Expand Down
6 changes: 3 additions & 3 deletions packages/sdk/test/common/sdk.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createAcrossClient } from "../../src/client";
import { createAcrossClient } from "../../src/client.js";
import {
arbitrum,
base,
Expand All @@ -11,8 +11,8 @@ import {
redstone,
zora,
} from "viem/chains";
import { TENDERLY_KEY } from "./constants";
import { MAINNET_API_URL } from "../../src/constants";
import { TENDERLY_KEY } from "./constants.js";
import { MAINNET_API_URL } from "../../src/constants/index.js";

export const MAINNET_SUPPORTED_CHAINS = [
arbitrum,
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/test/common/setup.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { afterAll } from "vitest";
import { chainClients } from "./anvil";
import { chainClients } from "./anvil.js";

afterAll(async () => {
await Promise.all(
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/test/common/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Address, Chain, PublicClient, TestClient } from "viem";
import { USDC_MAINNET, USDC_WHALE } from "./constants";
import type { ChainClient } from "./anvil";
import { USDC_MAINNET, USDC_WHALE } from "./constants.js";
import type { ChainClient } from "./anvil.js";

export function sleep(ms: number) {
return new Promise((resolve) => {
Expand Down
6 changes: 3 additions & 3 deletions packages/sdk/test/e2e/client.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { assertType, describe, expect, test } from "vitest";
import { testClient } from "../common/sdk";
import { testClient } from "../common/sdk.js";
import {
DefaultLogger,
type AcrossChain,
type ConfiguredPublicClient,
} from "../../src";
} from "../../src/index.js";
import type { Address } from "viem";
import { chains } from "../common/anvil";
import { chains } from "../common/anvil.js";

const chainIds = Object.values(chains).map((chain) => chain.id);

Expand Down
14 changes: 7 additions & 7 deletions packages/sdk/test/e2e/executeQuote.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,27 @@ import {
expect,
test,
} from "vitest";
import { testClient } from "../common/sdk";
import { testClient } from "../common/sdk.js";
import {
type FilledV3RelayEvent,
type Quote,
type Route,
} from "../../src/index";
} from "../../src/index.js";
import { parseEther, parseEventLogs, parseUnits, type Hash } from "viem";
import {
chainClientArbitrum,
chainClientMainnet,
publicClientArbitrum,
publicClientMainnet,
testWalletMainnet,
} from "../common/anvil";
} from "../common/anvil.js";
import {
BLOCK_NUMBER_ARBITRUM,
BLOCK_NUMBER_MAINNET,
} from "../common/constants";
import { fundUsdc } from "../common/utils";
import { waitForDepositAndFill } from "../common/relayer";
import { spokePoolAbi } from "../../src/abis/SpokePool";
} from "../common/constants.js";
import { fundUsdc } from "../common/utils.js";
import { waitForDepositAndFill } from "../common/relayer.js";
import { spokePoolAbi } from "../../src/abis/SpokePool.js";

const inputToken = {
address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
Expand Down
6 changes: 3 additions & 3 deletions packages/sdk/test/mocks/data/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from "./available-routes";
export * from "./chains";
export * from "./suggested-fees";
export * from "./available-routes.js";
export * from "./chains.js";
export * from "./suggested-fees.js";
6 changes: 3 additions & 3 deletions packages/sdk/test/mocks/handlers.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// src/mocks/handlers.js
import { http, HttpResponse } from "msw";
import { MAINNET_SUPPORTED_CHAINS, TEST_BASE_URL } from "../common/sdk";
import { MAINNET_SUPPORTED_CHAINS, TEST_BASE_URL } from "../common/sdk.js";
import {
usdcMainnetArbitrum as route,
mainnetChainInfo,
usdcMainnetArbitrumFees as fees,
} from "./data";
import { getCurrentTimeSeconds } from "../../src";
} from "./data/index.js";
import { getCurrentTimeSeconds } from "../../src/index.js";

export const handlers = [
// getAvailableRoutes
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/test/mocks/setup.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { setupServer } from "msw/node";
import { handlers } from "./handlers";
import { handlers } from "./handlers.js";
import { afterAll, afterEach, beforeAll } from "vitest";
import { MOCK_API } from "../common/constants";
import { MOCK_API } from "../common/constants.js";

const server = setupServer(...handlers);

Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/test/unit/actions/getAvailableRoutes.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, test } from "vitest";
import { testClient } from "../../common/sdk";
import { testClient } from "../../common/sdk.js";

// MAINNET => OPTIMISM
const testnetRoute = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { arbitrum, mainnet, optimism, polygon } from "viem/chains";
import { describe, expect, test } from "vitest";
import { configurePublicClients } from "../../../src";
import { configurePublicClients } from "../../../src/index.js";

const chains = [...[mainnet, optimism, polygon, arbitrum]];

Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/test/unit/utils/logger.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, test, vi } from "vitest";
import { testClient } from "../../common/sdk";
import { testClient } from "../../common/sdk.js";

test("Higher severity is logged", () => {
const consoleLogSpy = vi.spyOn(console, "log");
Expand Down
12 changes: 12 additions & 0 deletions packages/sdk/tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "@across-toolkit/typescript-config/base.json",
"compilerOptions": {
"noEmit": true,
"module": "NodeNext",
"target": "es2022",
"lib": ["es2022", "dom", "dom.iterable"],
"paths": {
"@/*": ["./src/*"]
}
}
}
2 changes: 1 addition & 1 deletion packages/sdk/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "./tsconfig.json",
"extends": "./tsconfig.base.json",
"include": ["src"],
"compilerOptions": {
"outDir": "dist",
Expand Down
12 changes: 3 additions & 9 deletions packages/sdk/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
// for local dev & linting. we can include test folder
{
"extends": "@across-toolkit/typescript-config/base.json",
"extends": "./tsconfig.base.json",
"include": ["."],
"exclude": ["dist"],
"compilerOptions": {
"noEmit": true,
"module": "NodeNext",
"target": "es2022",
"lib": ["es2022", "dom", "dom.iterable"],
"paths": {
"@/*": ["./src/*"]
}
"noEmit": true
}
}
File renamed without changes.
1 change: 1 addition & 0 deletions packages/typescript-config/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
"strict": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true,
"noUnusedLocals": true
}
}

0 comments on commit 9efb854

Please sign in to comment.