Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add eslint in root of monorepo #431

Merged
merged 3 commits into from
Jul 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
**/node_modules/
**/dist/
**/lib/
**/*.js
24 changes: 24 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// This is a WIP, running eslint for the whole monorepo causes
// javascript to run out of memory, so it needs a bit of refinement
module.exports = {
// extends: [
// "eslint:recommended",
// "plugin:@typescript-eslint/recommended",
// "plugin:@typescript-eslint/recommended-requiring-type-checking",
// "plugin:react/recommended",
// ],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
tsconfigRootDir: __dirname,
// project: ["./tsconfig.json", "./packages/**/tsconfig.json"],
},
// plugins: ["@typescript-eslint", "react", "only-warn"],
root: true,
settings: {
react: {
version: "detect",
},
},
};
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@
"clean": "npx rimraf {.,backend,examples,packages}/**/{.parcel-cache,.turbo,build,dist,node_modules,yarn-error.log} packages/app-extension/dev"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.31.0",
"@typescript-eslint/parser": "^5.31.0",
"env-cmd": "^10.1.0",
"eslint": "^8.20.0",
"eslint-plugin-only-warn": "^1.0.3",
"eslint-plugin-react": "^7.30.1",
"husky": "^8.0.1",
"lint-staged": "^12.4.1",
"prettier": "^2.6.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ import { Typography } from "@mui/material";
import { PublicKey } from "@solana/web3.js";
import { useCustomTheme, styles } from "@coral-xyz/themes";
import { useNftMetadata } from "@coral-xyz/recoil";
import { PrimaryButton, SecondaryButton } from "../../common";
import { PrimaryButton, SecondaryButton, TextField } from "../../common";
import {
useDrawerContext,
WithDrawer,
WithMiniDrawer,
CloseButton,
} from "../../Layout/Drawer";
import { NavStackEphemeral, NavStackScreen } from "../../Layout/NavStack";
import { TextField } from "../../common";
import { SendConfirmationCard } from "../Balances/TokensWidget/Send";

const useStyles = styles((theme) => ({
Expand Down
2 changes: 1 addition & 1 deletion packages/background/src/keyring/store.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as bs58 from "bs58";
import { Commitment } from "@solana/web3.js";
import type { Commitment } from "@solana/web3.js";
import type { KeyringStoreState } from "@coral-xyz/recoil";
import { KeyringStoreStateEnum } from "@coral-xyz/recoil";
import type { EventEmitter, DerivationPath } from "@coral-xyz/common";
Expand Down
9 changes: 4 additions & 5 deletions packages/common/src/solana/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import BN from "bn.js";
import type { TransactionInstruction, Commitment } from "@solana/web3.js";
import {
import type {
TransactionInstruction,
Commitment,
Connection,
PublicKey,
SystemProgram,
Transaction,
} from "@solana/web3.js";
import { PublicKey, SystemProgram, Transaction } from "@solana/web3.js";
import { Token } from "@solana/spl-token";
import type { TokenInfo } from "@solana/spl-token-registry";
import * as anchor from "@project-serum/anchor";
Expand Down
8 changes: 4 additions & 4 deletions packages/ledger-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export async function solanaLedgerSignBytes(
derivationPath: Buffer,
msgBytes: Buffer // Transaction "message".
) {
var numPaths = Buffer.alloc(1);
const numPaths = Buffer.alloc(1);
// @ts-ignore
numPaths.writeUInt8(1);
const payload = Buffer.concat([numPaths, derivationPath, msgBytes]);
Expand All @@ -79,7 +79,7 @@ export async function getPublicKey(
account: number,
path: DerivationPath
) {
let dPath = solanaDerivationPath(account, path);
const dPath = solanaDerivationPath(account, path);
const pubkeyBytes = await solanaLedgerPubkey(transport, dPath);
return new PublicKey(bs58.encode(pubkeyBytes));
}
Expand Down Expand Up @@ -112,8 +112,8 @@ async function solanaSend(
p1: number,
payload: Buffer
) {
var p2 = 0;
var payload_offset = 0;
let p2 = 0;
let payload_offset = 0;

if (payload.length > MAX_PAYLOAD) {
while (payload.length - payload_offset > MAX_PAYLOAD) {
Expand Down
2 changes: 1 addition & 1 deletion packages/ledger-injection/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,6 @@ class LedgerInjection {
}
}

let LEDGER = new LedgerInjection();
const LEDGER = new LedgerInjection();

main();
6 changes: 3 additions & 3 deletions packages/react-xnft-renderer/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ export class Plugin {
this._nextRenderId = 0;
this._iframe = document.createElement("iframe");
this._iframe.setAttribute("fetchpriority", "low");
this._iframe!.src = this.iframeUrl;
this._iframe.src = this.iframeUrl;
this._iframe.sandbox.add("allow-same-origin");
this._iframe.sandbox.add("allow-scripts");
this._iframe!.onload = async () => {
this._iframe.onload = async () => {
this._rpcServer.setWindow(this._iframe!.contentWindow);
this._bridgeServer.setWindow(this._iframe!.contentWindow);
this._dom = new Dom();
Expand Down Expand Up @@ -519,7 +519,7 @@ export class Plugin {
if (this._pendingBridgeRequests!.length === 0) {
return false;
}
let nextReq = this._pendingBridgeRequests![0];
const nextReq = this._pendingBridgeRequests![0];
return nextReq.renderId === this._nextRenderId;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/react-xnft/src/reconciler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ const RECONCILER = ReactReconciler({
logger.debug("createTextInstance", text);
const instance = {
id: h.nextId(),
kind: "raw" as "raw", // ts wtf?
kind: "raw" as const,
text,
props: undefined,
style: undefined,
Expand Down Expand Up @@ -1242,7 +1242,7 @@ function getOnChangeHandler(viewId: number): (event: any) => void {
}

export class ReconcilerBridgeManager {
private static _renderId: number = 0;
private static _renderId = 0;

//
// Send a message from the plugin-ui to the host over the reconciler bridge.
Expand Down
2 changes: 1 addition & 1 deletion packages/react-xnft/src/sdk/Stack/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function NavStackInner({
(c: any) => c.props.name === activeRoute.name
);

let { title: titleDefault } = options({
const { title: titleDefault } = options({
route: activeRoute,
});
if (!title) {
Expand Down
4 changes: 2 additions & 2 deletions packages/recoil/src/atoms/token.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export const solanaNftCollections = selector({
// Bucket all the nfts by collection name.
//
const collections: Map<string, any> = new Map();
for (let [key, value] of metadata.entries()) {
for (const [key, value] of metadata.entries()) {
if (value.tokenMetaUriData.collection) {
const name = value.tokenMetaUriData.collection.name;
if (!collections.has(name)) {
Expand All @@ -212,7 +212,7 @@ export const solanaNftCollections = selector({
// Finally, sort each bucket for consistent UI presentation.
//
const sortedCollections: any = [];
for (let [name, items] of collections.entries()) {
for (const [name, items] of collections.entries()) {
items.sort((a, b) =>
a.publicKey > b.publicKey ? 1 : a.publicKey === b.publicKey ? 0 : -1
);
Expand Down
2 changes: 1 addition & 1 deletion packages/recoil/src/context/Swap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export function SwapProvider(props: any) {

const executeSwap = async () => {
if (!transactions) return null;
for (let transactionStep of [
for (const transactionStep of [
"setupTransaction",
"swapTransaction",
"cleanupTransaction",
Expand Down
1 change: 1 addition & 0 deletions packages/recoil/src/hooks/useLocalStorage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useState } from "react";

export function useLocalStorage(key: string, initialValue: any) {
// State to store our value

// Pass initial state function to useState so logic is only executed once
const [storedValue, setStoredValue] = useState(() => {
if (typeof window === "undefined") {
Expand Down
4 changes: 2 additions & 2 deletions packages/recoil/src/hooks/useNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function useNavigation(): NavigationContext {
const pathname = location.pathname;
const isRoot = TAB_SET.has(pathname.slice(1));
const params = new URLSearchParams(location.search);
let title = isRoot
const title = isRoot
? ""
: useDecodedSearchParams<ExtensionSearchParams>(params).title || "";

Expand Down Expand Up @@ -123,7 +123,7 @@ function makeParams(ob = {}) {
.join("&");
}

export module SearchParamsFor {
export namespace SearchParamsFor {
export interface Plugin {
props: { pluginUrl: string };
}
Expand Down
7 changes: 6 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9398,12 +9398,17 @@ eslint-plugin-mui-unused-classes@^1.0.3:
resolved "https://registry.yarnpkg.com/eslint-plugin-mui-unused-classes/-/eslint-plugin-mui-unused-classes-1.0.3.tgz#5601c17ac6094b36452117fe84792eeaaddc23a8"
integrity sha512-hsvoxxcL189LSyUyBvak+tK7XHKvoAiUBQpnCRyx6hLf4FTE+WWNtE9cRwcUwZvdh+E/wLHGp9JpNveQcQpUTw==

eslint-plugin-only-warn@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/eslint-plugin-only-warn/-/eslint-plugin-only-warn-1.0.3.tgz#a75f3a9ded7f03e9808e75ec27f22b644084506e"
integrity sha512-XQOX/TfLoLw6h8ky51d29uUjXRTQHqBGXPylDEmy5fe/w7LIOnp8MA24b1OSMEn9BQoKow1q3g1kLe5/9uBTvw==

eslint-plugin-react-hooks@^4.5.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.6.0.tgz#4c3e697ad95b77e93f8646aaa1630c1ba607edd3"
integrity sha512-oFc7Itz9Qxh2x4gNHStv3BqJq54ExXmfC+a1NjAta66IAN87Wu0R/QArgIS9qKzX3dXKPI9H5crl9QchNMY9+g==

eslint-plugin-react@^7.29.4:
eslint-plugin-react@^7.29.4, eslint-plugin-react@^7.30.1:
version "7.30.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.30.1.tgz#2be4ab23ce09b5949c6631413ba64b2810fd3e22"
integrity sha512-NbEvI9jtqO46yJA3wcRF9Mo0lF9T/jhdHqhCHXiXtD+Zcb98812wvokjWpU7Q4QH5edo6dmqrukxVvWWXHlsUg==
Expand Down