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

update husky's lintstagedrc and linting rule #804

Merged
merged 6 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
8 changes: 7 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
{
"extends": ["eslint:recommended", "next/core-web-vitals", "prettier"]
"extends": ["eslint:recommended", "next/core-web-vitals", "prettier"],
"rules": {
"no-unused-vars": [
"error",
{ "vars": "all", "args": "after-used", "argsIgnorePattern": "^_" }
]
}
}
1 change: 1 addition & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yarn pre-push
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
"build": "next build",
"start": "next start",
"lint": "next lint",
"lint:ts": "tsc --noEmit",
"test": "playwright test",
"install-if-package-changed": "git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD | grep --quiet yarn.lock && yarn install || exit 0",
"prepare": "husky",
"pre-commit": "concurrently 'lint-staged'",
jeesunikim marked this conversation as resolved.
Show resolved Hide resolved
"pre-commit": "yarn lint-staged",
"pre-push": "yarn lint:ts",
"git-info": "rm -rf src/generated/ && mkdir src/generated/ && echo export default \"{\\\"commitHash\\\": \\\"$(git rev-parse --short HEAD)\\\", \\\"version\\\": \\\"$(git describe --tags --always)\\\"};\" > src/generated/gitInfo.ts"
},
"dependencies": {
Expand Down
9 changes: 3 additions & 6 deletions src/components/FormElements/AssetPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ type AssetPickerProps = {
labelSuffix?: string | React.ReactNode;
value: AssetObjectValue | undefined;
error: { code: string | undefined; issuer: string | undefined } | undefined;
// eslint-disable-next-line no-unused-vars
onChange: (asset: AssetObjectValue | undefined) => void;
onChange: (_asset: AssetObjectValue | undefined) => void;
assetInput: "issued" | "alphanumeric";
fitContent?: boolean;
includeNative?: boolean;
Expand Down Expand Up @@ -137,14 +136,12 @@ type AssetPickerFieldsProps = {
code: {
value: string;
error: string;
// eslint-disable-next-line no-unused-vars
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
onChange: (_e: React.ChangeEvent<HTMLInputElement>) => void;
};
issuer: {
value: string;
error: string;
// eslint-disable-next-line no-unused-vars
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
onChange: (_e: React.ChangeEvent<HTMLInputElement>) => void;
};
};

Expand Down
3 changes: 1 addition & 2 deletions src/components/FormElements/CursorPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ interface CursorPickerProps extends Omit<InputProps, "fieldSize"> {
placeholder?: string;
value: string;
error: string | undefined;
// eslint-disable-next-line no-unused-vars
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
onChange: (_e: React.ChangeEvent<HTMLInputElement>) => void;
}

export const CursorPicker = ({
Expand Down
3 changes: 1 addition & 2 deletions src/components/FormElements/IncludeFailedPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { RadioPicker } from "@/components/RadioPicker";
type IncludeFailedPickerProps = {
id: string;
selectedOption: string | undefined;
// eslint-disable-next-line no-unused-vars
onChange: (optionId: string | undefined, optionValue?: boolean) => void;
onChange: (_optionId: string | undefined, _optionValue?: boolean) => void;
labelSuffix?: string | React.ReactNode;
};

Expand Down
3 changes: 1 addition & 2 deletions src/components/FormElements/LimitPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ interface LimitPickerProps extends Omit<InputProps, "fieldSize"> {
placeholder?: string;
value: string;
error: string | undefined;
// eslint-disable-next-line no-unused-vars
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
onChange: (_e: React.ChangeEvent<HTMLInputElement>) => void;
}

export const LimitPicker = ({
Expand Down
3 changes: 1 addition & 2 deletions src/components/FormElements/OrderPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { RadioPicker } from "@/components/RadioPicker";
type OrderPickerProps = {
id: string;
selectedOption: string | undefined;
// eslint-disable-next-line no-unused-vars
onChange: (optionId: string | undefined, optionValue?: string) => void;
onChange: (_optionId: string | undefined, _optionValue?: string) => void;
labelSuffix?: string | React.ReactNode;
};

Expand Down
3 changes: 1 addition & 2 deletions src/components/FormElements/PubKeyPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ interface PubKeyPickerProps extends Omit<InputProps, "fieldSize"> {
readOnly?: boolean;
value: string;
error: string | undefined;
// eslint-disable-next-line no-unused-vars
onChange?: (e: React.ChangeEvent<any>) => void;
onChange?: (_e: React.ChangeEvent<any>) => void;
}

export const PubKeyPicker = ({
Expand Down
6 changes: 2 additions & 4 deletions src/components/RadioPicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ interface RadioPickerProps<TOptionValue = string> {
label?: string | React.ReactNode;
labelSuffix?: string | React.ReactNode;
onChange: (
// eslint-disable-next-line no-unused-vars
optionId: AssetType | undefined,
// eslint-disable-next-line no-unused-vars
optionValue?: TOptionValue,
_optionId: AssetType | undefined,
_optionValue?: TOptionValue,
) => void;
options: {
id: string;
Expand Down
3 changes: 1 addition & 2 deletions src/components/Tabs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ export const Tabs = ({
}: {
tabs: Tab[];
activeTabId: string;
// eslint-disable-next-line no-unused-vars
onChange: (id: string) => void;
onChange: (_id: string) => void;
}) => {
return (
<div className="Tabs">
Expand Down
15 changes: 5 additions & 10 deletions src/components/formComponentTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,26 @@ import { AnyObject, AssetObjectValue } from "@/types/types";
type TemplateRenderProps = {
value: string | undefined;
error: string | undefined;
// eslint-disable-next-line no-unused-vars
onChange: (val: any) => void;
onChange: (_val: any) => void;
isRequired?: boolean;
};

type TemplateRenderAssetProps = {
value: AssetObjectValue | undefined;
error: { code: string | undefined; issuer: string | undefined } | undefined;
// eslint-disable-next-line no-unused-vars
onChange: (asset: AssetObjectValue | undefined) => void;
onChange: (_asset: AssetObjectValue | undefined) => void;
isRequired?: boolean;
};

type TemplateRenderOrderProps = {
value: string | undefined;
// eslint-disable-next-line no-unused-vars
onChange: (optionId: string | undefined, optionValue?: string) => void;
onChange: (_optionId: string | undefined, _optionValue?: string) => void;
isRequired?: boolean;
};

type FormComponentTemplate = {
// eslint-disable-next-line no-unused-vars
render: (...args: any[]) => JSX.Element;
// eslint-disable-next-line no-unused-vars
validate: ((...args: any[]) => any) | null;
render: (..._args: any[]) => JSX.Element;
validate: ((..._args: any[]) => any) | null;
};

export const formComponentTemplate = (
Expand Down
27 changes: 9 additions & 18 deletions src/store/createStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import { AnyObject, EmptyObj, Network, MuxedAccount } from "@/types/types";
export interface Store {
// Shared
network: Network | EmptyObj;
// eslint-disable-next-line no-unused-vars
selectNetwork: (network: Network) => void;
selectNetwork: (_network: Network) => void;
resetStoredData: () => void;

// Account
Expand All @@ -19,16 +18,11 @@ export interface Store {
parsedMuxedAccountInput: string | undefined;
generatedMuxedAccount: MuxedAccount | EmptyObj;
parsedMuxedAccount: MuxedAccount | EmptyObj;
// eslint-disable-next-line no-unused-vars
updatePublicKey: (value: string) => void;
// eslint-disable-next-line no-unused-vars
updateGeneratedMuxedAccountInput: (value: Partial<MuxedAccount>) => void;
// eslint-disable-next-line no-unused-vars
updateParsedMuxedAccountInput: (value: string) => void;
// eslint-disable-next-line no-unused-vars
updateGeneratedMuxedAccount: (value: MuxedAccount) => void;
// eslint-disable-next-line no-unused-vars
updateParsedMuxedAccount: (value: MuxedAccount) => void;
updatePublicKey: (_value: string) => void;
updateGeneratedMuxedAccountInput: (_value: Partial<MuxedAccount>) => void;
updateParsedMuxedAccountInput: (_value: string) => void;
updateGeneratedMuxedAccount: (_value: MuxedAccount) => void;
updateParsedMuxedAccount: (_value: MuxedAccount) => void;
reset: () => void;
};

Expand All @@ -37,12 +31,9 @@ export interface Store {
network: Network | EmptyObj;
currentEndpoint: string | undefined;
params: AnyObject;
// eslint-disable-next-line no-unused-vars
updateNetwork: (network: Network) => void;
// eslint-disable-next-line no-unused-vars
updateCurrentEndpoint: (endpoint: string) => void;
// eslint-disable-next-line no-unused-vars
updateParams: (params: AnyObject) => void;
updateNetwork: (_network: Network) => void;
updateCurrentEndpoint: (_endpoint: string) => void;
updateParams: (_params: AnyObject) => void;
resetParams: () => void;
reset: () => void;
};
Expand Down
3 changes: 1 addition & 2 deletions src/store/useStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import { useStore as useZustandStore } from "zustand";
import { Store } from "@/store/createStore";
import { ZustandContext } from "@/store/StoreProvider";

// eslint-disable-next-line no-unused-vars
export const useStore = <T = Store>(selector?: (state: Store) => T) => {
export const useStore = <T = Store>(selector?: (_state: Store) => T) => {
selector ??= (state) => state as T;
const store = useContext(ZustandContext);
if (!store) throw new Error("Store is missing the provider");
Expand Down
Loading