Skip to content

Commit

Permalink
chore: Prettier and Lint applied for clean slate
Browse files Browse the repository at this point in the history
  • Loading branch information
brunomenezes committed Sep 27, 2023
1 parent 6a41d88 commit e4a3013
Show file tree
Hide file tree
Showing 17 changed files with 73 additions and 84 deletions.
7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.next
dist
node_modules
.storybook
graphql
contracts.ts
**/rollups-wagmi/src/index.tsx
2 changes: 1 addition & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"tabWidth": 4,
"tabWidth": 4,
"overrides": [
{
"files": "*.md",
Expand Down
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll": true,
"source.organizeImports": true
}
}
12 changes: 6 additions & 6 deletions apps/web/src/app/applications/[address]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
"use client";
import { FC, useEffect, useState } from "react";
import { useScrollIntoView } from "@mantine/hooks";
import { pathOr } from "ramda";
import { TbInbox } from "react-icons/tb";
import {
Anchor,
Breadcrumbs,
Expand All @@ -14,14 +10,18 @@ import {
Text,
Title,
} from "@mantine/core";
import { useScrollIntoView } from "@mantine/hooks";
import Link from "next/link";
import { InputOrderByInput, useInputsQuery } from "../../../graphql";
import { pathOr } from "ramda";
import { FC, useEffect, useState } from "react";
import { TbInbox } from "react-icons/tb";
import Address from "../../../components/address";
import InputRow from "../../../components/inputRow";
import { InputOrderByInput, useInputsQuery } from "../../../graphql";
import {
limitBounds,
usePaginationParams,
} from "../../../hooks/usePaginationParams";
import InputRow from "../../../components/inputRow";

export type ApplicationPageProps = {
params: { address: string };
Expand Down
3 changes: 1 addition & 2 deletions apps/web/src/components/inputRow.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"use client";
import { erc20PortalAddress, etherPortalAddress } from "@cartesi/rollups-wagmi";
import {
ActionIcon,
Badge,
Collapse,
Group,
JsonInput,
Stack,
Table,
Tabs,
Text,
Expand All @@ -22,7 +22,6 @@ import {
TbX,
} from "react-icons/tb";
import { Hex, formatUnits, getAddress, hexToString } from "viem";
import { erc20PortalAddress, etherPortalAddress } from "@cartesi/rollups-wagmi";
import { InputItemFragment } from "../graphql";
import Address from "./address";

Expand Down
3 changes: 3 additions & 0 deletions apps/workshop/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
module.exports = {
root: true,
extends: ["cartesi"],
rules: {
"@next/next/no-img-element": 'off'
}
};
12 changes: 6 additions & 6 deletions apps/workshop/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ This template provides a minimal setup to get React working in Vite with HMR and

Currently, two official plugins are available:

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh

## Expanding the ESLint configuration

If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:

- Configure the top-level `parserOptions` property like this:
- Configure the top-level `parserOptions` property like this:

```js
parserOptions: {
Expand All @@ -22,6 +22,6 @@ If you are developing a production application, we recommend updating the config
},
```

- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list
- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list
2 changes: 1 addition & 1 deletion apps/workshop/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState } from "react";
import "./App.css";
import reactLogo from "./assets/react.svg";
import viteLogo from "/vite.svg";
import "./App.css";

function App() {
const [count, setCount] = useState(0);
Expand Down
28 changes: 16 additions & 12 deletions apps/workshop/src/stories/InputDetails.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from "@cartesi/rollups-explorer-ui";
import { Button, Group, Stack, Title } from "@mantine/core";
import type { Meta, StoryObj } from "@storybook/react";
import { useEffect, useState } from "react";
import { useCallback, useEffect, useState } from "react";

const meta: Meta<typeof InputDetails> = {
component: InputDetails,
Expand All @@ -30,17 +30,21 @@ const useEmulatedData = (dataList: string[], delay = 0) => {
const [index, setIndex] = useState(0);
const data = loading ? "" : dataList[index];

const updateHooks = (action: () => void) => {
if (delay > 0) {
setLoading(true);
setTimeout(() => {
const updateHooks = useCallback(
(action: () => void) => {
if (delay > 0) {
setLoading(true);
setTimeout(() => {
action();
setLoading(false);
}, delay);
} else {
action();
setLoading(false);
}, delay);
} else {
action();
}
};
}
},
[setLoading, delay],
);

const nextPage = () => {
updateHooks(() => setIndex((n) => n + 1));
};
Expand All @@ -53,7 +57,7 @@ const useEmulatedData = (dataList: string[], delay = 0) => {
if (delay > 0) {
updateHooks(() => setIndex(0));
}
}, []);
}, [delay, updateHooks]);

return {
total: dataList.length,
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"dev": "turbo run dev --no-cache --continue",
"lint": "turbo run lint",
"clean": "turbo run clean && rm -rf node_modules",
"format:check": "prettier \"**/*.{ts,tsx}\" --check",
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"test" : "turbo run test",
"test:ci" : "turbo run test:ci",
Expand All @@ -21,7 +22,7 @@
"devDependencies": {
"@changesets/cli": "^2.26.2",
"eslint-config-cartesi": "*",
"prettier": "^3.0.3",
"prettier": "3.0.3",
"turbo": "^1.10.13"
},
"engines": {
Expand Down
3 changes: 1 addition & 2 deletions packages/rollups-wagmi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
"build": "tsup",
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
"codegen": "wagmi generate",
"dev": "tsup --watch",
"lint": "eslint \"src/**/*.ts*\""
"dev": "tsup --watch"
},
"dependencies": {
"wagmi": "^1"
Expand Down
9 changes: 6 additions & 3 deletions packages/ui/src/InputDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ const InputDetailsContent: FC = () => {
return !childComp ? (
<Fragment key={tab.label} />
) : (
<Tabs.Panel key={`panel-${tab.label}`} value={tab.label} data-testid={`panel-${tab.label.toLowerCase()}`} >
<Tabs.Panel
key={`panel-${tab.label}`}
value={tab.label}
data-testid={`panel-${tab.label.toLowerCase()}`}
>
{childComp}
</Tabs.Panel>
);
Expand Down Expand Up @@ -166,6 +170,5 @@ export {
InputDetails,
NoticeContent,
ReportContent,
VoucherContent
VoucherContent,
};

3 changes: 1 addition & 2 deletions packages/ui/test/InputDetails/mocks.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@

export const reportText = "0x6f696969";
export const jsonWithdraw0 =
"0x7b0a20202020226d6574686f64223a202265726332307769746864726177616c222c0a202020202261726773223a207b0a2020202020202020226572633230223a2022307830353963373530374239373364313531323736386330366633326138313342433933443833454232222c0a202020202020202022616d6f756e74223a203130300a202020207d0a7d";
export const jsonWithdraw1 =
"0x7b0a20202020226d6574686f64223a202265726332307769746864726177616c222c0a202020202261726773223a207b0a2020202020202020226572633230223a2022307835396236373065396641394430413432373735314166323031443637363731396139373038353762222c0a202020202020202022616d6f756e74223a203130300a202020207d0a7d";
export const jsonWithdraw2 =
"0x7b0a20202020226d6574686f64223a202265726332307769746864726177616c222c0a202020202261726773223a207b0a2020202020202020226572633230223a2022307835396236373065396641394430413432373735314166323031443637363731396139373038353762222c0a202020202020202022616d6f756e74223a2031303030303030303030303030303030303030300a202020207d0a7d";
export const queryContentAsHex = `0x494e5345525420494e544f20636572746966696572202056414c554553202827307866434432423566316346353562353643306632323464614439394331346234454530393237346433272c3130202c273078664344324235663163463535623536433066323234646144393943313462344545303932373464332729`;
export const queryContentAsHex = `0x494e5345525420494e544f20636572746966696572202056414c554553202827307866434432423566316346353562353643306632323464614439394331346234454530393237346433272c3130202c273078664344324235663163463535623536433066323234646144393943313462344545303932373464332729`;
4 changes: 2 additions & 2 deletions packages/ui/test/Summary.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ describe("Rollups Summary", () => {

expect(screen.getByText("Applications")).toBeInTheDocument();
expect(
screen.getByTestId("summary-card-applications-icon")
screen.getByTestId("summary-card-applications-icon"),
).toBeInTheDocument();
expect(screen.getByText("10")).toBeInTheDocument();
expect(screen.getByText("Inputs")).toBeInTheDocument();
expect(
screen.getByTestId("summary-card-inputs-icon")
screen.getByTestId("summary-card-inputs-icon"),
).toBeInTheDocument();
expect(screen.getByText("2")).toBeInTheDocument();
});
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/test/SummaryCard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ describe("Rollups SummaryCard", () => {

it("should display icon when defined", () => {
const { container } = render(
<SummaryCardE title="Applications" value={10} icon={TbUser} />
<SummaryCardE title="Applications" value={10} icon={TbUser} />,
);
expect(
screen.getByTestId("summary-card-applications-icon")
screen.getByTestId("summary-card-applications-icon"),
).toBeInTheDocument();
});
});
1 change: 0 additions & 1 deletion packages/ui/vitest-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ Object.defineProperty(window, "matchMedia", {
})),
});


global.ResizeObserver = vi.fn().mockImplementation(() => ({
observe: vi.fn(),
unobserve: vi.fn(),
Expand Down
52 changes: 9 additions & 43 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1088,14 +1088,7 @@
resolved "https://registry.yarnpkg.com/@babel/regjsgen/-/regjsgen-0.8.0.tgz#f0ba69b075e1f05fb2825b7fad991e7adbb18310"
integrity sha512-x/rqGMdzj+fWZvCOYForTghzbtqPDZ5gPwaoNGHdgDfF2QA/XZbCBp4Moo5scrkAMPhB7z26XM/AaHuIJdgauA==

"@babel/runtime@^7.0.0", "@babel/runtime@^7.12.5", "@babel/runtime@^7.13.10", "@babel/runtime@^7.17.2", "@babel/runtime@^7.17.8", "@babel/runtime@^7.20.1", "@babel/runtime@^7.20.13", "@babel/runtime@^7.20.7", "@babel/runtime@^7.22.6", "@babel/runtime@^7.5.5", "@babel/runtime@^7.8.4", "@babel/runtime@^7.8.7":
version "7.23.1"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.23.1.tgz#72741dc4d413338a91dcb044a86f3c0bc402646d"
integrity sha512-hC2v6p8ZSI/W0HUzh3V8C5g+NwSKzKPtJwSpTjwl0o297GP9+ZLQSkdvHz46CM3LqyoXxq+5G9komY+eSqSO0g==
dependencies:
regenerator-runtime "^0.14.0"

"@babel/runtime@^7.9.2":
"@babel/runtime@^7.0.0", "@babel/runtime@^7.12.5", "@babel/runtime@^7.13.10", "@babel/runtime@^7.17.2", "@babel/runtime@^7.17.8", "@babel/runtime@^7.20.1", "@babel/runtime@^7.20.13", "@babel/runtime@^7.20.7", "@babel/runtime@^7.22.6", "@babel/runtime@^7.5.5", "@babel/runtime@^7.8.4", "@babel/runtime@^7.8.7", "@babel/runtime@^7.9.2":
version "7.23.1"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.23.1.tgz#72741dc4d413338a91dcb044a86f3c0bc402646d"
integrity sha512-hC2v6p8ZSI/W0HUzh3V8C5g+NwSKzKPtJwSpTjwl0o297GP9+ZLQSkdvHz46CM3LqyoXxq+5G9komY+eSqSO0g==
Expand Down Expand Up @@ -3471,22 +3464,7 @@
"@storybook/preview-api" "7.4.5"
"@storybook/theming" "7.4.5"

"@storybook/[email protected]":
version "7.4.5"
resolved "https://registry.yarnpkg.com/@storybook/addon-viewport/-/addon-viewport-7.4.5.tgz#5bb8549c63031ce8378e8524d1ae2c50ec656d6a"
integrity sha512-SBLnUMIztVrqJ0fRCsVg9KZ29APLIxqAvTsYHF3twy5KB2naeCFuX3K9LxSH7vbROI6zHEfnPduz/Ykyvu9yUg==
dependencies:
"@storybook/client-logger" "7.4.5"
"@storybook/components" "7.4.5"
"@storybook/core-events" "7.4.5"
"@storybook/global" "^5.0.0"
"@storybook/manager-api" "7.4.5"
"@storybook/preview-api" "7.4.5"
"@storybook/theming" "7.4.5"
memoizerific "^1.11.3"
prop-types "^15.7.2"

"@storybook/addon-viewport@^7.4.0":
"@storybook/[email protected]", "@storybook/addon-viewport@^7.4.0":
version "7.4.5"
resolved "https://registry.yarnpkg.com/@storybook/addon-viewport/-/addon-viewport-7.4.5.tgz#5bb8549c63031ce8378e8524d1ae2c50ec656d6a"
integrity sha512-SBLnUMIztVrqJ0fRCsVg9KZ29APLIxqAvTsYHF3twy5KB2naeCFuX3K9LxSH7vbROI6zHEfnPduz/Ykyvu9yUg==
Expand Down Expand Up @@ -4015,16 +3993,6 @@
"@types/express" "^4.7.0"
file-system-cache "2.3.0"

"@storybook/[email protected]":
version "7.4.5"
resolved "https://registry.yarnpkg.com/@storybook/types/-/types-7.4.5.tgz#800685e3d5ba481070e420fe842abfdd0db6e8da"
integrity sha512-DTWFNjfRTpncjufDoUs0QnNkgHG2qThGKWL1D6sO18cYI02zWPyHWD8/cbqlvtT7XIGe3s1iUEfCTdU5GcwWBA==
dependencies:
"@storybook/channels" "7.4.5"
"@types/babel__core" "^7.0.0"
"@types/express" "^4.7.0"
file-system-cache "2.3.0"

"@sunodo/wagmi-plugin-hardhat-deploy@^0.2":
version "0.2.0"
resolved "https://registry.yarnpkg.com/@sunodo/wagmi-plugin-hardhat-deploy/-/wagmi-plugin-hardhat-deploy-0.2.0.tgz#e6d1cb6a1296d10f3ece978d7d59841bc31ca367"
Expand Down Expand Up @@ -4438,7 +4406,7 @@
resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.5.tgz#38bd1733ae299620771bd414837ade2e57757498"
integrity sha512-xrO9OoVPqFuYyR/loIHjnbvvyRZREYKLjxV4+dY6v3FQR3stQ9ZxIGkaclF7YhI9hfjpuTbu14hZEy94qKLtOA==

"@types/react-dom@^18", "@types/react-dom@^18.2.7":
"@types/react-dom@^18", "@types/react-dom@^18.0.0", "@types/react-dom@^18.2.7":
version "18.2.8"
resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-18.2.8.tgz#338f1b0a646c9f10e0a97208c1d26b9f473dffd6"
integrity sha512-bAIvO5lN/U8sPGvs1Xm61rlRHHaq5rp5N3kp9C+NJ/Q41P8iqjkXSu0+/qu8POsjH9pNWb0OYabFez7taP7omw==
Expand Down Expand Up @@ -10919,16 +10887,16 @@ prelude-ls@^1.2.1:
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396"
integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==

[email protected]:
version "3.0.3"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.0.3.tgz#432a51f7ba422d1469096c0fdc28e235db8f9643"
integrity sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==

prettier@^2.7.1, prettier@^2.8.0, prettier@^2.8.1:
version "2.8.8"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da"
integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==

prettier@^3.0.3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.0.3.tgz#432a51f7ba422d1469096c0fdc28e235db8f9643"
integrity sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==

pretty-format@^27.0.2:
version "27.5.1"
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-27.5.1.tgz#2181879fdea51a7a5851fb39d920faa63f01d88e"
Expand Down Expand Up @@ -13633,12 +13601,11 @@ ws@^7.4.5, ws@^7.5.1:
resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.9.tgz#54fa7db29f4c7cec68b1ddd3a89de099942bb591"
integrity sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==

<<<<<<< HEAD
ws@^8.12.0, ws@^8.13.0, ws@^8.2.3, ws@^8.5.0:
version "8.14.2"
resolved "https://registry.yarnpkg.com/ws/-/ws-8.14.2.tgz#6c249a806eb2db7a20d26d51e7709eab7b2e6c7f"
integrity sha512-wEBG1ftX4jcglPxgFCMJmZ2PLtSbJ2Peg6TmpJFTbe9GZYOQCDPdMYu/Tm0/bGZkw8paZnJY45J4K2PZrLYq8g==
=======

xml-name-validator@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-4.0.0.tgz#79a006e2e63149a8600f15430f0a4725d1524835"
Expand All @@ -13648,7 +13615,6 @@ xmlchars@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/xmlchars/-/xmlchars-2.2.0.tgz#060fe1bcb7f9c76fe2a17db86a9bc3ab894210cb"
integrity sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==
>>>>>>> 461dc8e (Add Vitest + support libraries, including configs to the UI package.)

xtend@^4.0.1, xtend@~4.0.1:
version "4.0.2"
Expand Down

0 comments on commit e4a3013

Please sign in to comment.