Skip to content

Commit

Permalink
switch eslint prettier instead of biome (#8)
Browse files Browse the repository at this point in the history
* remove biome

* configure eslint and prettier instead of biome
  • Loading branch information
technophile-04 authored Apr 28, 2024
1 parent 6fc520a commit 1f8fbea
Show file tree
Hide file tree
Showing 9 changed files with 330 additions and 177 deletions.
48 changes: 0 additions & 48 deletions packages/burner-connector-test01/biome.json

This file was deleted.

40 changes: 40 additions & 0 deletions packages/burner-connector-test01/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// @ts-check

import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";

import { dirname } from "path";
import { fileURLToPath } from "url";

const __dirname = dirname(fileURLToPath(import.meta.url));

export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
{
languageOptions: {
parserOptions: {
project: true,
tsconfigRootDir: __dirname,
},
},
rules: {
"@typescript-eslint/ban-ts-comment": "error",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unnecessary-type-assertion": "off",
"@typescript-eslint/no-redundant-type-constituents": "off",
"@typescript-eslint/require-await": "off",
"@typescript-eslint/no-misused-promises": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-return": "off",
},
ignores: [".changeset", "dist/"],
},
{
files: ["**/*.js"],
...tseslint.configs.disableTypeChecked,
},
eslintPluginPrettierRecommended,
);
18 changes: 13 additions & 5 deletions packages/burner-connector-test01/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
"main": "./dist/esm/index.js",
"types": "./dist/types/index.d.ts",
"typings": "./dist/types/index.d.ts",
"files": ["dist/**", "!dist/**/*.tsbuildinfo"],
"files": [
"dist/**",
"!dist/**/*.tsbuildinfo"
],
"repository": {
"type": "git",
"url": "https://github.com/technophile-04/burner-connector.git"
Expand All @@ -18,16 +21,21 @@
"build:esm+types": "tsc --project tsconfig.json --outDir ./dist/esm --declaration --declarationMap --declarationDir ./dist/types",
"clean": "rm -rf dist tsconfig.tsbuildinfo",
"typecheck": "tsc --noEmit",
"lint": "biome check .",
"format": "biome format --write .",
"lint": "eslint . --ignore-pattern 'dist/' ",
"format": "prettier --write . '!(node_modules|dist)/**/*' '!CHANGELOG.md'",
"changeset:release": "pnpm run build && pnpm changeset publish"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@biomejs/biome": "1.7.1",
"typescript": "^5.4.5"
"@eslint/js": "^9.1.1",
"eslint": "^8",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"prettier": "3.2.5",
"typescript": "^5.4.5",
"typescript-eslint": "^7.7.1"
},
"dependencies": {
"@rainbow-me/rainbowkit": "2.0.2",
Expand Down
9 changes: 9 additions & 0 deletions packages/burner-connector-test01/prettier.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/** @type {import("prettier").Config} */
const config = {
tabWidth: 2,
printWidth: 120,
trailingComma: "all",
semi: true,
};

export default config;
29 changes: 6 additions & 23 deletions packages/burner-connector-test01/src/burnerConnector/burner.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import { createConnector, normalizeChainId } from "@wagmi/core";
import type {
EIP1193RequestFn,
Hex,
SendTransactionParameters,
Transport,
WalletRpcSchema,
} from "viem";
import type { EIP1193RequestFn, Hex, SendTransactionParameters, Transport, WalletRpcSchema } from "viem";
import {
http,
BaseError,
Expand All @@ -18,11 +12,7 @@ import {
} from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { getHttpRpcClient, hexToBigInt, numberToHex } from "viem/utils";
import {
burnerWalletId,
burnerWalletName,
loadBurnerPK,
} from "../utils/index.js";
import { burnerWalletId, burnerWalletName, loadBurnerPK } from "../utils/index.js";

export class ConnectorNotConnectedError extends BaseError {
override name = "ConnectorNotConnectedError";
Expand All @@ -38,9 +28,7 @@ export class ChainNotConfiguredError extends BaseError {
}
}

type Provider = ReturnType<
Transport<"custom", Record<any, any>, EIP1193RequestFn<WalletRpcSchema>>
>;
type Provider = ReturnType<Transport<"custom", Record<any, any>, EIP1193RequestFn<WalletRpcSchema>>>;

export const burner = () => {
let connected = true;
Expand All @@ -63,8 +51,7 @@ export const burner = () => {
return { accounts, chainId: currentChainId };
},
async getProvider({ chainId } = {}) {
const chain =
config.chains.find((x) => x.id === chainId) ?? config.chains[0];
const chain = config.chains.find((x) => x.id === chainId) ?? config.chains[0];

const url = chain.rpcUrls.default.http[0];
if (!url) throw new Error("No rpc url found for chain");
Expand All @@ -78,9 +65,7 @@ export const burner = () => {
const request: EIP1193RequestFn = async ({ method, params }) => {
if (method === "eth_sendTransaction") {
const actualParams = (params as SendTransactionParameters[])[0];
const value = actualParams?.value
? hexToBigInt(actualParams.value as unknown as Hex)
: undefined;
const value = actualParams?.value ? hexToBigInt(actualParams.value as unknown as Hex) : undefined;
const hash = await client.sendTransaction({
...(params as SendTransactionParameters[])[0],
value,
Expand Down Expand Up @@ -117,9 +102,7 @@ export const burner = () => {
if (!connected) throw new ConnectorNotConnectedError();
const provider = await this.getProvider();
const accounts = await provider.request({ method: "eth_accounts" });
const burnerAddress = accounts.map((x) =>
getAddress(x),
)[0] as `0x${string}`;
const burnerAddress = accounts.map((x) => getAddress(x))[0] as `0x${string}`;
return [burnerAddress];
},
async onDisconnect() {
Expand Down
4 changes: 1 addition & 3 deletions packages/burner-connector-test01/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ export const saveBurnerPK = (privateKey: Hex): void => {
export const loadBurnerPK = (): Hex => {
let currentSk: Hex = "0x";
if (typeof window !== "undefined" && window != null) {
currentSk = (window?.localStorage
?.getItem?.(burnerStorageKey)
?.replaceAll('"', "") ?? "0x") as Hex;
currentSk = (window?.localStorage?.getItem?.(burnerStorageKey)?.replaceAll('"', "") ?? "0x") as Hex;
}

if (!!currentSk && isValidPK(currentSk)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@ import { createConnector } from "@wagmi/core";
import type { EIP1193RequestFn, Transport, WalletRpcSchema } from "viem";
import { burner } from "../../burnerConnector/burner.js";

type Provider = ReturnType<
Transport<"custom", Record<any, any>, EIP1193RequestFn<WalletRpcSchema>>
>;
type Provider = ReturnType<Transport<"custom", Record<any, any>, EIP1193RequestFn<WalletRpcSchema>>>;

export const rainbowkitBurnerConnector = (
walletDetails: WalletDetailsParams,
) => {
export const rainbowkitBurnerConnector = (walletDetails: WalletDetailsParams) => {
return createConnector<Provider>((config) => ({
...burner()(config),
...walletDetails,
Expand Down
2 changes: 1 addition & 1 deletion packages/burner-connector-test01/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"include": ["src/**/*.ts"],
"include": ["src/**/*.ts", "prettier.config.js"],
"exclude": [],
"compilerOptions": {
// Incremental builds
Expand Down
Loading

0 comments on commit 1f8fbea

Please sign in to comment.