Skip to content

Commit

Permalink
feat: new eslint config
Browse files Browse the repository at this point in the history
  • Loading branch information
Majorfi committed Sep 12, 2022
1 parent 096c1c3 commit ac14460
Show file tree
Hide file tree
Showing 12 changed files with 63 additions and 56 deletions.
6 changes: 4 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ module.exports = {
'plugin:react/recommended',
'plugin:react-hooks/recommended',
'plugin:tailwindcss/recommended',
'plugin:@typescript-eslint/recommended'
'plugin:@typescript-eslint/recommended',
'next/core-web-vitals'
],
'parser': '@typescript-eslint/parser',
'parserOptions': {
'ecmaFeatures': {
'jsx': true
},
'ecmaVersion': 12,
'ecmaVersion': 2022,
'sourceType': 'module',
'project': ['./tsconfig.json']
},
Expand Down Expand Up @@ -46,6 +47,7 @@ module.exports = {
'array-bracket-spacing': [2, 'never'],
'react/jsx-curly-brace-presence': ['error', {'props': 'always', 'children': 'always'}],
'semi': 'error',
'import/no-named-as-default-member': 2,
'tailwindcss/no-custom-classname': 0,
'unused-imports/no-unused-imports': 'error',
'unused-imports/no-unused-vars': ['warn', {
Expand Down
16 changes: 8 additions & 8 deletions components/common/AppWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React, {ReactElement} from 'react';
import {AppProps} from 'next/app';
import {KBarProvider} from 'kbar';
import {AnimatePresence, motion} from 'framer-motion';
import Header from 'components/common/StandardHeader';
import Footer from 'components/common/StandardFooter';
import Meta from 'components/common/Meta';
import KBar from 'components/common/Kbar';
import React, {ReactElement} from 'react';
import {AppProps} from 'next/app';
import {KBarProvider} from 'kbar';
import {AnimatePresence, motion} from 'framer-motion';
import Header from 'components/common/StandardHeader';
import Footer from 'components/common/StandardFooter';
import Meta from 'components/common/Meta';
import KBar from 'components/common/Kbar';

const transition = {duration: 0.3, ease: [0.17, 0.67, 0.83, 0.67]};
const thumbnailVariants = {
Expand Down
6 changes: 3 additions & 3 deletions components/common/KBarButton.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, {ReactElement} from 'react';
import {Search} from '@yearn-finance/web-lib/icons';
import {useKBar} from 'kbar';
import React, {ReactElement} from 'react';
import {Search} from '@yearn-finance/web-lib/icons';
import {useKBar} from 'kbar';

function KBarButton(): ReactElement {
const {query} = useKBar();
Expand Down
6 changes: 3 additions & 3 deletions components/common/Kbar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {ReactElement} from 'react';
import React, {ReactElement, forwardRef, useMemo} from 'react';
import {
ActionId,
ActionImpl,
Expand Down Expand Up @@ -40,12 +40,12 @@ const groupNameStyle = {
};

// eslint-disable-next-line react/display-name
const ResultItem = React.forwardRef((
const ResultItem = forwardRef((
{action, active, currentRootActionId}:
{action: ActionImpl; active: boolean; currentRootActionId: ActionId;},
ref: React.Ref<HTMLDivElement>
): ReactElement => {
const ancestors = React.useMemo((): unknown => {
const ancestors = useMemo((): unknown => {
if (!currentRootActionId) return action.ancestors;
const index = action.ancestors.findIndex((ancestor: any): any => ancestor.id === currentRootActionId);
// +1 removes the currentRootAction; e.g.
Expand Down
8 changes: 4 additions & 4 deletions components/common/Meta.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, {ReactElement} from 'react';
import Head from 'next/head';
import {DefaultSeo} from 'next-seo';
import meta from 'public/manifest.json';
import React, {ReactElement} from 'react';
import Head from 'next/head';
import {DefaultSeo} from 'next-seo';
import meta from 'public/manifest.json';

function Meta(): ReactElement {
return (
Expand Down
13 changes: 6 additions & 7 deletions components/common/StandardFooter.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React, {ReactElement} from 'react';
import Link from 'next/link';
import {SwitchTheme} from '@yearn-finance/web-lib/components';
import {useUI} from '@yearn-finance/web-lib/contexts';
import {SocialDiscord, SocialGithub,
SocialMedium, SocialTwitter} from '@yearn-finance/web-lib/icons';
import meta from 'public/manifest.json';
import React, {ReactElement} from 'react';
import Link from 'next/link';
import {SwitchTheme} from '@yearn-finance/web-lib/components';
import {useUI} from '@yearn-finance/web-lib/contexts';
import {SocialDiscord, SocialGithub, SocialMedium, SocialTwitter} from '@yearn-finance/web-lib/icons';
import meta from 'public/manifest.json';


function Footer(): ReactElement {
Expand Down
22 changes: 14 additions & 8 deletions components/common/StandardHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {ReactElement} from 'react';
import React, {ReactElement, useEffect, useState} from 'react';
import Link from 'next/link';
import {Card, Dropdown, ModalMobileMenu} from '@yearn-finance/web-lib/components';
import {useWeb3} from '@yearn-finance/web-lib/contexts';
Expand All @@ -8,7 +8,13 @@ import {Hamburger, NetworkArbitrum, NetworkEthereum,
import LogoYearn from 'components/icons/LogoYearn';
import KBarButton from 'components/common/KBarButton';

const options: any[] = [
type TOptions = {
icon: ReactElement;
label: string;
value: number;
}

const options: TOptions[] = [
{icon: <NetworkEthereum />, label: 'Ethereum', value: 1},
{icon: <NetworkOptimism />, label: 'Optimism', value: 10},
{icon: <NetworkFantom />, label: 'Fantom', value: 250},
Expand All @@ -20,11 +26,11 @@ function StandardHeader({
shouldUseNetworks = true
}): ReactElement {
const {chainID, onSwitchChain, isActive, address, ens, openLoginModal, onDesactivate} = useWeb3();
const [walletIdentity, set_walletIdentity] = React.useState('Connect wallet');
const [selectedOption, set_selectedOption] = React.useState(options[0]);
const [hasMobileMenu, set_hasMobileMenu] = React.useState(false);
const [walletIdentity, set_walletIdentity] = useState('Connect wallet');
const [selectedOption, set_selectedOption] = useState(options[0]);
const [hasMobileMenu, set_hasMobileMenu] = useState(false);

React.useEffect((): void => {
useEffect((): void => {
if (!isActive && address) {
set_walletIdentity('Invalid network');
} else if (ens) {
Expand All @@ -36,7 +42,7 @@ function StandardHeader({
}
}, [ens, address, isActive]);

React.useEffect((): void => {
useEffect((): void => {
const _selectedOption = options.find((e): boolean => e.value === Number(chainID)) || options[0];
set_selectedOption(_selectedOption);
}, [chainID, isActive]);
Expand Down Expand Up @@ -77,7 +83,7 @@ function StandardHeader({
defaultOption={options[0]}
options={options}
selected={selectedOption}
onSelect={(option: any): void => onSwitchChain(option.value as number, true)} />
onSelect={(option: TOptions): void => onSwitchChain(option.value as number, true)} />
</div>
) : null}
{shouldUseWallets ? (
Expand Down
2 changes: 1 addition & 1 deletion components/icons/LogoYearn.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {ReactElement} from 'react';
import React, {ReactElement} from 'react';

function LogoYearn(props: React.SVGProps<SVGSVGElement>): ReactElement {
return (
Expand Down
8 changes: 4 additions & 4 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, {ReactElement} from 'react';
import {AppProps} from 'next/app';
import {WithYearn} from '@yearn-finance/web-lib/contexts';
import AppWrapper from 'components/common/AppWrapper';
import React, {ReactElement} from 'react';
import {AppProps} from 'next/app';
import {WithYearn} from '@yearn-finance/web-lib/contexts';
import AppWrapper from 'components/common/AppWrapper';

import '../style.css';

Expand Down
8 changes: 4 additions & 4 deletions pages/disclaimer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, {ReactElement} from 'react';
import Link from 'next/link';
import {Card} from '@yearn-finance/web-lib/components';
import {Cross} from '@yearn-finance/web-lib/icons';
import React, {ReactElement} from 'react';
import Link from 'next/link';
import {Card} from '@yearn-finance/web-lib/components';
import {Cross} from '@yearn-finance/web-lib/icons';

function DisclaimerPage(): ReactElement {
return (
Expand Down
4 changes: 2 additions & 2 deletions pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, {ReactElement} from 'react';
import {Banner, Card, DescriptionList} from '@yearn-finance/web-lib/components';
import React, {ReactElement} from 'react';
import {Banner, Card, DescriptionList} from '@yearn-finance/web-lib/components';

function Content(): ReactElement {
return (
Expand Down
20 changes: 10 additions & 10 deletions pages/settings.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, {ReactElement} from 'react';
import {Card} from '@yearn-finance/web-lib/components';
import {useSettings} from '@yearn-finance/web-lib/contexts';
import React, {ReactElement, useMemo, useState} from 'react';
import {Card} from '@yearn-finance/web-lib/components';
import {useSettings} from '@yearn-finance/web-lib/contexts';

type TWrappedInput = {
title: string;
Expand All @@ -10,9 +10,9 @@ type TWrappedInput = {
}

function WrappedInput({title, caption, initialValue, onSave}: TWrappedInput): ReactElement {
const [isFocused, set_isFocused] = React.useState(false);
const [value, set_value] = React.useState(initialValue);
const isInitialValue = React.useMemo((): boolean => value === initialValue, [value, initialValue]);
const [isFocused, set_isFocused] = useState(false);
const [value, set_value] = useState(initialValue);
const isInitialValue = useMemo((): boolean => value === initialValue, [value, initialValue]);

return (
<label>
Expand Down Expand Up @@ -46,7 +46,7 @@ function WrappedInput({title, caption, initialValue, onSave}: TWrappedInput): Re

function SectionRPCEndpoints(): ReactElement {
const {onUpdateNetworks} = useSettings();
const [, set_nonce] = React.useState(0);
const [, set_nonce] = useState(0);

return (
<Card>
Expand Down Expand Up @@ -101,7 +101,7 @@ function SectionRPCEndpoints(): ReactElement {

function SectionSubGraphEndpoints(): ReactElement {
const {onUpdateNetworks, networks} = useSettings();
const [, set_nonce] = React.useState(0);
const [, set_nonce] = useState(0);

return (
<Card>
Expand Down Expand Up @@ -156,7 +156,7 @@ function SectionSubGraphEndpoints(): ReactElement {

function SectionExplorerBaseURI(): ReactElement {
const {onUpdateNetworks, networks} = useSettings();
const [, set_nonce] = React.useState(0);
const [, set_nonce] = useState(0);

return (
<Card>
Expand Down Expand Up @@ -211,7 +211,7 @@ function SectionExplorerBaseURI(): ReactElement {

function SectionOracleAddress(): ReactElement {
const {onUpdateNetworks, networks} = useSettings();
const [, set_nonce] = React.useState(0);
const [, set_nonce] = useState(0);

return (
<Card>
Expand Down

1 comment on commit ac14460

@vercel
Copy link

@vercel vercel bot commented on ac14460 Sep 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

web-lib-template – ./

web-template-bay.vercel.app
web-lib-template.yearn.farm
web-lib-template-git-main.yearn.farm
web.ycorpo.com

Please sign in to comment.