Skip to content

Commit

Permalink
Update ts, eslint, prettier (#963)
Browse files Browse the repository at this point in the history
  • Loading branch information
rin-st authored Oct 26, 2024
1 parent dd4a434 commit c7772e3
Show file tree
Hide file tree
Showing 15 changed files with 453 additions and 452 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"hardhat:lint": "yarn workspace @se-2/hardhat lint",
"hardhat:lint-staged": "yarn workspace @se-2/hardhat lint-staged",
"hardhat:format": "yarn workspace @se-2/hardhat format",
"hardhat:check-types": "yarn workspace @se-2/hardhat check-types",
"hardhat:test": "yarn workspace @se-2/hardhat test",
"test": "yarn hardhat:test",
"format": "yarn next:format && yarn hardhat:format",
Expand Down
4 changes: 2 additions & 2 deletions packages/hardhat/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"parser": "@typescript-eslint/parser",
"extends": ["plugin:prettier/recommended", "plugin:@typescript-eslint/recommended"],
"rules": {
"@typescript-eslint/no-unused-vars": ["error"],
"@typescript-eslint/no-explicit-any": ["off"],
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/no-explicit-any": "off",
"prettier/prettier": [
"warn",
{
Expand Down
3 changes: 3 additions & 0 deletions packages/hardhat/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@ cache-zk
# deployments
deployments/localhost

# typescript
*.tsbuildinfo

# other
temp
2 changes: 1 addition & 1 deletion packages/hardhat/deploy/99_generateTsAbis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const generateTsAbis: DeployFunction = async function () {
}
fs.writeFileSync(
`${TARGET_DIR}deployedContracts.ts`,
prettier.format(
await prettier.format(
`${generatedContractComment} import { GenericContractsDeclaration } from "~~/utils/scaffold-eth/contract"; \n\n
const deployedContracts = {${fileContent}} as const; \n\n export default deployedContracts satisfies GenericContractsDeclaration`,
{
Expand Down
19 changes: 10 additions & 9 deletions packages/hardhat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"scripts": {
"account": "hardhat run scripts/listAccount.ts",
"chain": "hardhat node --network hardhat --no-deploy",
"check-types": "tsc --noEmit --incremental",
"compile": "hardhat compile",
"deploy": "hardhat deploy",
"fork": "MAINNET_FORKING_ENABLED=true hardhat node --network hardhat --no-deploy",
Expand All @@ -25,26 +26,26 @@
"@nomicfoundation/hardhat-verify": "^2.0.10",
"@typechain/ethers-v5": "^11.1.2",
"@typechain/hardhat": "^9.1.0",
"@types/eslint": "^8",
"@types/eslint": "^8.56.12",
"@types/mocha": "^10.0.8",
"@types/prettier": "^2",
"@types/prettier": "^3.0.0",
"@types/qrcode": "^1.5.5",
"@typescript-eslint/eslint-plugin": "latest",
"@typescript-eslint/parser": "latest",
"@typescript-eslint/eslint-plugin": "^8.8.1",
"@typescript-eslint/parser": "^8.8.1",
"chai": "^4.5.0",
"eslint": "^8.26.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint": "^8.57.1",
"eslint-config-prettier": "^8.10.0",
"eslint-plugin-prettier": "^5.2.1",
"ethers": "^6.13.2",
"hardhat": "^2.22.10",
"hardhat-deploy": "^0.12.4",
"hardhat-deploy-ethers": "^0.4.2",
"hardhat-gas-reporter": "^2.2.1",
"prettier": "^2.8.4",
"prettier": "^3.3.3",
"solidity-coverage": "^0.8.13",
"ts-node": "^10.9.1",
"typechain": "^8.3.2",
"typescript": "^5.1.6"
"typescript": "<5.6.0"
},
"dependencies": {
"@openzeppelin/contracts": "^5.0.2",
Expand Down
1 change: 1 addition & 0 deletions packages/hardhat/scripts/listAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ async function main() {
console.log("--", networkName, "-- 📡");
console.log(" balance:", +ethers.formatEther(balance));
console.log(" nonce:", +(await provider.getTransactionCount(address)));
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (e) {
console.log("Can't connect to network", networkName);
}
Expand Down
8 changes: 3 additions & 5 deletions packages/nextjs/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
{
"parser": "@typescript-eslint/parser",
"extends": ["next/core-web-vitals", "plugin:prettier/recommended", "plugin:@typescript-eslint/recommended"],
"extends": ["next/core-web-vitals", "plugin:@typescript-eslint/recommended", "plugin:prettier/recommended"],
"rules": {
"@typescript-eslint/no-unused-vars": ["error"],
"@typescript-eslint/no-explicit-any": ["off"],
"@typescript-eslint/ban-ts-comment": ["off"],
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/ban-ts-comment": "off",
"prettier/prettier": [
"warn",
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
module.exports = {
"arrowParens": "avoid",
"printWidth": 120,
"tabWidth": 2,
"trailingComma": "all",
"importOrder": ["^react$", "^next/(.*)$", "<THIRD_PARTY_MODULES>", "^@heroicons/(.*)$", "^~~/(.*)$"],
"importOrderSortSpecifiers": true
"importOrderSortSpecifiers": true,
"plugins": [require.resolve("@trivago/prettier-plugin-sort-imports")],
}
21 changes: 12 additions & 9 deletions packages/nextjs/app/debug/_components/contract/TupleArray.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,18 @@ export const TupleArray = ({ abiTupleParameter, setParentForm, parentStateObject

useEffect(() => {
// Extract and group fields based on index prefix
const groupedFields = Object.keys(form).reduce((acc, key) => {
const [indexPrefix, ...restArray] = key.split("_");
const componentName = restArray.join("_");
if (!acc[indexPrefix]) {
acc[indexPrefix] = {};
}
acc[indexPrefix][componentName] = form[key];
return acc;
}, {} as Record<string, Record<string, any>>);
const groupedFields = Object.keys(form).reduce(
(acc, key) => {
const [indexPrefix, ...restArray] = key.split("_");
const componentName = restArray.join("_");
if (!acc[indexPrefix]) {
acc[indexPrefix] = {};
}
acc[indexPrefix][componentName] = form[key];
return acc;
},
{} as Record<string, Record<string, any>>,
);

let argsArray: Array<Record<string, any>> = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const isJsonString = (str: string) => {
try {
JSON.parse(str);
return true;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (e) {
return false;
}
Expand All @@ -23,6 +24,7 @@ const isBigInt = (str: string) => {
try {
BigInt(str);
return true;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (e) {
return false;
}
Expand Down
1 change: 1 addition & 0 deletions packages/nextjs/components/scaffold-eth/Input/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export const isValidInteger = (dataType: IntegerVariant, value: string) => {
let valueAsBigInt;
try {
valueAsBigInt = BigInt(value);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (e) {}
if (typeof valueAsBigInt !== "bigint") {
if (!value || typeof value !== "string") {
Expand Down
15 changes: 7 additions & 8 deletions packages/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,20 @@
"zustand": "^5.0.0"
},
"devDependencies": {
"@trivago/prettier-plugin-sort-imports": "^4.1.1",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/node": "^18.19.50",
"@types/react": "^18.3.5",
"@typescript-eslint/eslint-plugin": "^5.39.0",
"abitype": "1.0.6",
"autoprefixer": "^10.4.20",
"eslint": "^8.15.0",
"eslint-config-next": "^14.0.4",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint": "^8.57.1",
"eslint-config-next": "^14.2.15",
"eslint-config-prettier": "^8.10.0",
"eslint-plugin-prettier": "^5.2.1",
"postcss": "^8.4.45",
"prettier": "^2.8.4",
"prettier": "^3.3.3",
"tailwindcss": "^3.4.11",
"type-fest": "^4.26.1",
"typescript": "5.5.3",
"typescript": "<5.6.0",
"vercel": "^37.4.2"
}
}
1 change: 1 addition & 0 deletions packages/nextjs/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ["./app/**/*.{js,ts,jsx,tsx}", "./components/**/*.{js,ts,jsx,tsx}", "./utils/**/*.{js,ts,jsx,tsx}"],
// eslint-disable-next-line @typescript-eslint/no-require-imports
plugins: [require("daisyui")],
darkTheme: "dark",
darkMode: ["selector", "[data-theme='dark']"],
Expand Down
27 changes: 14 additions & 13 deletions packages/nextjs/utils/scaffold-eth/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,17 @@ type OptionalTuple<T> = T extends readonly [infer H, ...infer R] ? readonly [H |
type UseScaffoldArgsParam<
TContractName extends ContractName,
TFunctionName extends ExtractAbiFunctionNames<ContractAbi<TContractName>>,
> = TFunctionName extends FunctionNamesWithInputs<TContractName>
? {
args: OptionalTuple<UnionToIntersection<AbiFunctionArguments<ContractAbi<TContractName>, TFunctionName>>>;
value?: ExtractAbiFunction<ContractAbi<TContractName>, TFunctionName>["stateMutability"] extends "payable"
? bigint | undefined
: undefined;
}
: {
args?: never;
};
> =
TFunctionName extends FunctionNamesWithInputs<TContractName>
? {
args: OptionalTuple<UnionToIntersection<AbiFunctionArguments<ContractAbi<TContractName>, TFunctionName>>>;
value?: ExtractAbiFunction<ContractAbi<TContractName>, TFunctionName>["stateMutability"] extends "payable"
? bigint | undefined
: undefined;
}
: {
args?: never;
};

export type UseScaffoldReadConfig<
TContractName extends ContractName,
Expand Down Expand Up @@ -305,9 +306,9 @@ export type UseScaffoldEventHistoryData<
IndexedOnly: false;
}
>;
block: TBlockData extends true ? Block<bigint, true> : null;
receipt: TReceiptData extends true ? GetTransactionReturnType : null;
transaction: TTransactionData extends true ? GetTransactionReceiptReturnType : null;
blockData: TBlockData extends true ? Block<bigint, true> : null;
receiptData: TReceiptData extends true ? GetTransactionReturnType : null;
transactionData: TTransactionData extends true ? GetTransactionReceiptReturnType : null;
}[]
>
| undefined;
Expand Down
Loading

0 comments on commit c7772e3

Please sign in to comment.