Skip to content

Commit

Permalink
Fix yarn and eslint warnings (#1597)
Browse files Browse the repository at this point in the history
Closes https://linear.app/0xparc-pcd/issue/0XP-238
Closes https://linear.app/0xparc-pcd/issue/0XP-239

We have various warnings on `yarn install`, mostly relating to missing
or incorrect peer dependencies. Some of these were because of mismatches
between expected package versions and the installed versions, and were
solved by upgrading the dependant packages so that the dependencies
match their expected version ranges (mostly upgrading `eslint` to 8.x).

In addition, various `@opentelemetry` packages had mismatches in their
dependency versions, which has been solved by pinning to specific
compatible versions rather than allowing yarn to install newer but
potentially incompatible dependencies.

In other cases, it was necessary to install packages as
`devDependencies` so that the peer package would stop complaining about
a missing `peerDependency`. This is odd, as no functional issues seemed
to arise from this, but it seems like the correct thing to do is to
install the missing dependency.

As a result of upgrading `eslint`, the fact that `anon-message-client`
lacks an `eslintrc.js` or equivalent config file became a problem, as
`yarn lint` would hang while prompting the user to decide what to do
about this. So, I added a configuration file, which means that `yarn
lint` now actually runs for `anon-message-client`. This threw up some
simple linting issues (e.g. missing function return types) which I
fixed.

Finally, I took the opportunity to make the version number explicit on
the `@pcd/eslint-config-custom` and `@pcd/tsconfig` dependencies
throughout the codebase. Previously we were generally using `'*'` as the
version number, but this was flagged as an issue
[here](https://github.com/proofcarryingdata/zupass/pull/1564/files#r1524098374).

The result is that *most* of the warnings have gone away. The following
ones remain:

```
warning "workspace-aggregator-e02a239c-4952-405a-abbd-87259c138f94 > passport-client > [email protected]" has incorrect peer dependency "react@^16.8.0 || ^17.0.0".
warning "workspace-aggregator-e02a239c-4952-405a-abbd-87259c138f94 > passport-client > [email protected]" has incorrect peer dependency "react-dom@^16.8.0 || ^17.0.0".
```

The incorrect peer dependency for `react-qr-reader` comes from the fact
that `react-qr-reader` expects a maximum React version of `^17.0.0`, and
we are on `18.2.x`. There is an unmerged PR for this in the
`react-qr-reader` repo from November, which looks like it would resolve
the issue if merged:
JodusNodus/react-qr-reader#361
  • Loading branch information
robknight authored Mar 18, 2024
1 parent dd332e1 commit db6d1dc
Show file tree
Hide file tree
Showing 66 changed files with 1,325 additions and 572 deletions.
4 changes: 4 additions & 0 deletions apps/anon-message-client/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
extends: ["@pcd/eslint-config-custom"],
root: true,
};
4 changes: 2 additions & 2 deletions apps/anon-message-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
"typescript": "5.3.3"
},
"devDependencies": {
"eslint": "8.47.0",
"eslint-config-next": "13.4.13",
"@pcd/eslint-config-custom": "0.10.0",
"eslint": "8.57.0",
"nodemon": "^3.0.1",
"ts-node": "^10.9.2"
}
Expand Down
2 changes: 1 addition & 1 deletion apps/anon-message-client/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function RootLayout({
children
}: {
children: React.ReactNode;
}) {
}): JSX.Element {
return (
<html lang="en">
<body>{children}</body>
Expand Down
20 changes: 10 additions & 10 deletions apps/anon-message-client/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async function requestProof(
chatId: number,
topicId: number,
validEventIds: string[]
) {
): Promise<void> {
const watermark = getMessageWatermark(message).toString();
console.log("WATERMARK", watermark);
const revealedFields = {};
Expand Down Expand Up @@ -82,7 +82,7 @@ async function requestProof(
}
};

let passportOrigin = `${process.env.NEXT_PUBLIC_PASSPORT_CLIENT_URL}/`;
const passportOrigin = `${process.env.NEXT_PUBLIC_PASSPORT_CLIENT_URL}/`;
const returnUrl = `${
process.env.NEXT_PUBLIC_PASSPORT_SERVER_URL
}/telegram/message/?message=${encodeURIComponent(
Expand All @@ -101,7 +101,7 @@ async function requestProof(
window.location.href = proofUrl;
}

export default function () {
export default function (): JSX.Element {
const [message, setMessage] = useState("");
const [invalidMessage, setInvalidMessage] = useState<
InvalidMessage | undefined
Expand Down Expand Up @@ -142,7 +142,7 @@ export default function () {
} else if (invalidMessage) {
setInvalidMessage(undefined);
}
}, [message]);
}, [message, invalidMessage]);

const onClick = useCallback(async () => {
setLoadingProofUrl(true);
Expand All @@ -160,7 +160,7 @@ export default function () {
topicData.value.validEventIds
);
setLoadingProofUrl(false);
}, [message]);
}, [message, topicData]);

if (!topicData) {
return (
Expand All @@ -185,7 +185,7 @@ export default function () {
<textarea
placeholder="Type your anonymous message here"
value={message}
onChange={(e) => setMessage(e.target.value)}
onChange={(e): void => setMessage(e.target.value)}
className={`border-2 text-2xl rounded-lg text-black resize-none p-2 h-[25vh] select-text`}
autoFocus
/>
Expand Down Expand Up @@ -224,7 +224,7 @@ export default function () {
<div className="flex justify-between items-center mb-3">
{expanded ? (
<div
onClick={() => setExpanded(false)}
onClick={(): void => setExpanded(false)}
className="cursor-pointer"
>
<svg
Expand All @@ -244,7 +244,7 @@ export default function () {
</div>
) : (
<div
onClick={() => setExpanded(true)}
onClick={(): void => setExpanded(true)}
className="cursor-pointer"
>
<svg
Expand All @@ -269,7 +269,7 @@ export default function () {
</span>
<div
className="cursor-pointer"
onClick={() => setShowInfo(false)}
onClick={(): void => setShowInfo(false)}
>
<svg
width="15"
Expand Down Expand Up @@ -297,7 +297,7 @@ export default function () {
<div className="flex item-center gap-4 mx-auto mt-4 w-full">
<button
className="w-full flex justify-center items-center rounded-lg bg-white text-[#50acf9] px-6 py-2 cursor-pointer mx-auto font-medium shadow-sm"
onClick={() => setExpanded(true)}
onClick={(): void => setExpanded(true)}
>
Learn More
</button>
Expand Down
4 changes: 2 additions & 2 deletions apps/anon-message-client/src/app/profile/loading.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default function Loading() {
export default function Loading(): JSX.Element {
return (
<div className="flex flex-col items-center bg-white p-4">
<div className="flex items-center justify-center p-2 w-full">
Expand All @@ -16,7 +16,7 @@ export default function Loading() {
</span>
</div>
<div className="flex flex-col gap-2 mt-4 w-full">
{[...Array(5)].map((_message: any, i: number) => (
{[...Array(5)].map((_message: unknown, i: number) => (
<div
className="w-full flex flex-col border border-black border-opacity-10 rounded-lg p-4 animate-pulse"
key={i}
Expand Down
2 changes: 1 addition & 1 deletion apps/anon-message-client/src/app/profile/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ interface AnonymousProfileResponse {
totalKarma: number;
}

export default function Page() {
export default function Page(): JSX.Element {
const [response, setResponse] = useState<
AnonymousProfileResponse | undefined
>(undefined);
Expand Down
4 changes: 2 additions & 2 deletions apps/anon-message-client/src/components/CopyButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ interface CopyButtonProps {
const CopyButton: React.FC<CopyButtonProps> = ({ link }) => {
const [copied, setCopied] = useState<boolean>(false);

const copyLink = () => {
const copyLink = (): void => {
navigator.clipboard.writeText(link);
};

return (
<button
className="justify-center w-full flex items-center rounded-lg bg-white text-[#50acf9] px-6 py-2 cursor-pointer mx-auto font-medium shadow-sm"
onClick={() => {
onClick={(): void => {
copyLink();
setCopied(true);
}}
Expand Down
2 changes: 1 addition & 1 deletion apps/anon-message-client/src/components/post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function reactionsToReactionCount(reactions: string[]): Record<string, number> {
}

// from: https://github.com/dcposch/zucast/blob/master/src/components/PostBox.tsx
function formatTime(timeMs: number) {
function formatTime(timeMs: number): string {
const secsAgo = Math.floor((Date.now() - timeMs) / 1000);
if (secsAgo < 60) return "Now";
if (secsAgo < 60 * 60) return `${Math.floor(secsAgo / 60)}m`;
Expand Down
8 changes: 5 additions & 3 deletions apps/consumer-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"clean": "rm -rf node_modules public/js tsconfig.tsbuildinfo"
},
"dependencies": {
"@babel/core": "^7.24.0",
"@pcd/eddsa-frog-pcd": "0.2.0",
"@pcd/eddsa-pcd": "0.5.0",
"@pcd/eddsa-ticket-pcd": "0.5.0",
Expand All @@ -22,10 +23,10 @@
"@pcd/semaphore-group-pcd": "0.10.0",
"@pcd/semaphore-identity-pcd": "0.10.0",
"@pcd/semaphore-signature-pcd": "0.10.0",
"@pcd/util": "0.4.0",
"@pcd/webauthn-pcd": "0.10.0",
"@pcd/zk-eddsa-event-ticket-pcd": "0.4.0",
"@pcd/zk-eddsa-frog-pcd": "0.2.0",
"@pcd/util": "0.4.0",
"@personaelabs/spartan-ecdsa": "^2.1.4",
"@semaphore-protocol/identity": "^3.15.2",
"@simplewebauthn/browser": "^7.2.0",
Expand All @@ -34,6 +35,7 @@
"json-bigint": "^1.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-is": "^18.2.0",
"react-router-dom": "^6.9.0",
"styled-components": "^5.3.6",
"url-join": "^5.0.0",
Expand All @@ -42,15 +44,15 @@
"devDependencies": {
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
"@esbuild-plugins/node-modules-polyfill": "^0.2.2",
"@pcd/eslint-config-custom": "*",
"@pcd/eslint-config-custom": "0.10.0",
"@types/json-bigint": "^1.0.1",
"@types/react": "^18.2.6",
"@types/react-dom": "^18.0.7",
"@types/styled-components": "^5.1.26",
"@typescript-eslint/eslint-plugin": "^5.56.0",
"@typescript-eslint/parser": "^5.56.0",
"esbuild": "^0.17.10",
"eslint": "7.32.0",
"eslint": "8.57.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"ts-node": "^10.9.2",
Expand Down
6 changes: 3 additions & 3 deletions apps/consumer-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"dependencies": {
"@honeycombio/opentelemetry-node": "^0.3.2",
"@opentelemetry/api": "^1.3.0",
"@opentelemetry/api": "1.3.0",
"@opentelemetry/auto-instrumentations-node": "^0.36.0",
"@opentelemetry/sdk-node": "^0.34.0",
"@pcd/eddsa-ticket-pcd": "^0.5.0",
Expand All @@ -34,10 +34,10 @@
"@types/express": "^4.17.16",
"@types/mocha": "^10.0.1",
"@types/morgan": "^1.9.4",
"@types/node": "^17.0.12",
"@types/node": "^20.11.28",
"@types/react": "^18.0.22",
"dotenv": "^16.0.3",
"eslint": "7.32.0",
"eslint": "8.57.0",
"mocha": "^10.2.0",
"ts-mocha": "^10.0.0",
"ts-node-dev": "^2.0.0",
Expand Down
7 changes: 5 additions & 2 deletions apps/generic-issuance-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"dependencies": {
"@chakra-ui/icons": "^2.1.1",
"@chakra-ui/react": "^2.8.2",
"@chakra-ui/system": "^2.6.2",
"@emotion/react": "^11.11.3",
"@emotion/styled": "^11.11.0",
"@monaco-editor/react": "^4.6.0",
Expand All @@ -30,6 +31,8 @@
"javascript-time-ago": "^2.5.9",
"lodash": "^4.17.21",
"moment": "^2.30.1",
"monaco-editor": "^0.47.0",
"prop-types": "^15.8.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-icons": "^5.0.1",
Expand All @@ -44,7 +47,7 @@
"devDependencies": {
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
"@esbuild-plugins/node-modules-polyfill": "^0.2.2",
"@pcd/eslint-config-custom": "*",
"@pcd/eslint-config-custom": "0.10.0",
"@types/javascript-time-ago": "^2.0.8",
"@types/lodash": "^4.14.202",
"@types/react": "^18.2.6",
Expand All @@ -55,7 +58,7 @@
"@typescript-eslint/eslint-plugin": "^5.56.0",
"@typescript-eslint/parser": "^5.56.0",
"esbuild": "^0.17.10",
"eslint": "7.32.0",
"eslint": "8.57.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"ts-node": "^10.9.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function FancyEditor({
onChange={onValueChange}
loading={<Spinner />}
options={{
readonly: readonly,
readOnly: readonly,
minimap: {
enabled: false
}
Expand Down
4 changes: 2 additions & 2 deletions apps/kudosbot-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"devDependencies": {
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
"@esbuild-plugins/node-modules-polyfill": "^0.2.2",
"@pcd/eslint-config-custom": "*",
"@pcd/eslint-config-custom": "0.10.0",
"@types/express": "^4.17.21",
"@types/json-bigint": "^1.0.1",
"@types/react": "^18.2.6",
Expand All @@ -49,7 +49,7 @@
"@typescript-eslint/eslint-plugin": "^5.56.0",
"@typescript-eslint/parser": "^5.56.0",
"esbuild": "^0.17.10",
"eslint": "7.32.0",
"eslint": "8.57.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"ts-node": "^10.9.2",
Expand Down
7 changes: 5 additions & 2 deletions apps/passport-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"analyze-bundle": "yarn build && esbuild-visualizer --metadata ./public/js/bundle-size.json --filename public/bundle-stats.html && open public/bundle-stats.html"
},
"dependencies": {
"@babel/runtime": "^7.24.0",
"@pcd/eddsa-frog-pcd": "0.2.0",
"@pcd/eddsa-frog-pcd-ui": "0.1.0",
"@pcd/eddsa-pcd": "0.5.0",
Expand Down Expand Up @@ -54,6 +55,7 @@
"@semaphore-protocol/identity": "^3.15.2",
"boring-avatars": "^1.10.1",
"broadcast-channel": "^5.3.0",
"csstype": "^3.1.3",
"dotenv": "^16.0.3",
"email-validator": "^2.0.4",
"fast-json-stable-stringify": "^2.1.0",
Expand All @@ -62,6 +64,7 @@
"js-sha256": "^0.11.0",
"lodash": "^4.17.21",
"pretty-ms": "^8.0.0",
"prop-types": "^15.8.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hot-toast": "^2.4.1",
Expand All @@ -88,7 +91,7 @@
"devDependencies": {
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
"@esbuild-plugins/node-modules-polyfill": "^0.2.2",
"@pcd/eslint-config-custom": "*",
"@pcd/eslint-config-custom": "0.10.0",
"@types/chai": "^4.3.11",
"@types/email-validator": "^1.0.6",
"@types/express": "^4.17.17",
Expand All @@ -102,7 +105,7 @@
"@typescript-eslint/parser": "^5.56.0",
"esbuild": "^0.17.10",
"esbuild-visualizer": "^0.4.1",
"eslint": "7.32.0",
"eslint": "8.57.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"express": "^4.18.2",
Expand Down
11 changes: 6 additions & 5 deletions apps/passport-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
"clean": "rm -rf node_modules ./build"
},
"dependencies": {
"@apollo/client": "^3.9.2",
"@apollo/client": "^3.9.7",
"@honeycombio/opentelemetry-node": "^0.3.2",
"@opentelemetry/api": "^1.3.0",
"@opentelemetry/api": "1.3.0",
"@opentelemetry/auto-instrumentations-node": "^0.36.0",
"@opentelemetry/sdk-node": "^0.34.0",
"@pagerduty/pdjs": "^2.2.4",
"@pcd/eddsa-frog-pcd": "0.2.0",
"@pcd/message-pcd": "0.0.1",
"@pcd/eddsa-pcd": "0.5.0",
"@pcd/eddsa-ticket-pcd": "0.5.0",
"@pcd/email-pcd": "0.5.0",
"@pcd/message-pcd": "0.0.1",
"@pcd/passport-crypto": "0.10.0",
"@pcd/passport-interface": "0.10.0",
"@pcd/pcd-collection": "0.10.0",
Expand Down Expand Up @@ -55,6 +55,7 @@
"fast-json-stable-stringify": "^2.1.0",
"flat": "5",
"grammy": "^1.18.1",
"graphql": "^16.8.1",
"js-sha256": "^0.10.1",
"libhoney": "^4.0.1",
"lodash": "^4.17.21",
Expand Down Expand Up @@ -97,7 +98,7 @@
"@types/mocha": "^10.0.1",
"@types/mocha-steps": "^1.3.0",
"@types/morgan": "^1.9.4",
"@types/node": "^17.0.12",
"@types/node": "^20.11.28",
"@types/pg": "^8.6.6",
"@types/react": "^18.0.22",
"@types/request": "^2.48.8",
Expand All @@ -110,7 +111,7 @@
"csv-stringify": "^6.4.5",
"deep-equal-in-any-order": "^2.0.6",
"dotenv": "^16.0.3",
"eslint": "7.32.0",
"eslint": "8.57.0",
"mocha": "^10.2.0",
"mocha-steps": "^1.3.0",
"mockdate": "^3.0.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ export class GenericIssuanceService {
continue;
}

for (const capability of pipeline?.instance.capabilities) {
for (const capability of pipeline?.instance.capabilities ?? []) {
if (
isCheckinCapability(capability) &&
capability.canHandleCheckinForEvent(eventId)
Expand Down
Loading

0 comments on commit db6d1dc

Please sign in to comment.