From b0a3307700131eec37b08ad473b30c8a4f170ffe Mon Sep 17 00:00:00 2001 From: Chika Date: Sun, 29 May 2022 15:12:03 +0300 Subject: [PATCH] eslint: apply fixes to code in project --- Components/Layout/Auth.jsx | 1 + UIKit/grid.js | 1 + apollo/client.js | 3 +-- apollo/hooks.js | 1 + pages/_document.jsx | 3 +-- services/user/index.ts | 5 ++++- stores/Provider.jsx | 1 + stores/calculation/options/index.ts | 5 ++++- stores/calculation/statuses/index.ts | 2 +- stores/calculation/validation/index.ts | 2 +- stores/user.ts | 4 +++- 11 files changed, 19 insertions(+), 9 deletions(-) diff --git a/Components/Layout/Auth.jsx b/Components/Layout/Auth.jsx index 439d702..a9d942f 100644 --- a/Components/Layout/Auth.jsx +++ b/Components/Layout/Auth.jsx @@ -20,6 +20,7 @@ const UserText = styled.span` const User = observer(() => { const { $user } = useStore(); + return {$user?.user?.displayName}; }); diff --git a/UIKit/grid.js b/UIKit/grid.js index 406aa45..4c1a5c5 100644 --- a/UIKit/grid.js +++ b/UIKit/grid.js @@ -1,2 +1,3 @@ import { Box, Flex } from 'rebass/styled-components'; + export { Box, Flex }; diff --git a/apollo/client.js b/apollo/client.js index 5c5750c..18d53f0 100644 --- a/apollo/client.js +++ b/apollo/client.js @@ -5,8 +5,7 @@ import { ApolloClient, InMemoryCache } from '@apollo/client'; /** @type {import('@apollo/client').ApolloClient} */ let apolloClient; -const uri = - typeof window === 'undefined' +const uri = typeof window === 'undefined' ? process.env.URL_CRM_GRAPHQL_DIRECT : process.env.NEXT_PUBLIC_URL_CRM_GRAPHQL_PROXY; diff --git a/apollo/hooks.js b/apollo/hooks.js index a3fc807..b1de89f 100644 --- a/apollo/hooks.js +++ b/apollo/hooks.js @@ -4,5 +4,6 @@ import initializeApollo from './client'; export function useApollo(initialState) { const client = useMemo(() => initializeApollo(initialState), [initialState]); + return client; } diff --git a/pages/_document.jsx b/pages/_document.jsx index 3e92df8..32e99a5 100644 --- a/pages/_document.jsx +++ b/pages/_document.jsx @@ -7,8 +7,7 @@ export default class MyDocument extends Document { const originalRenderPage = ctx.renderPage; try { - ctx.renderPage = () => - originalRenderPage({ + ctx.renderPage = () => originalRenderPage({ enhanceApp: (App) => (props) => sheet.collectStyles(), }); diff --git a/services/user/index.ts b/services/user/index.ts index a38a71b..d466528 100644 --- a/services/user/index.ts +++ b/services/user/index.ts @@ -1,10 +1,13 @@ /* eslint-disable import/prefer-default-export */ -import axios, { AxiosRequestConfig } from 'axios'; +import type { AxiosRequestConfig } from 'axios'; +import axios from 'axios'; import type { User } from './types'; function love(user: User) { const superUsers: string[] = JSON.parse(process.env.USERS_SUPER || ''); + // eslint-disable-next-line no-param-reassign if (superUsers?.includes(user.username)) user.displayName += '🧡'; + return user; } diff --git a/stores/Provider.jsx b/stores/Provider.jsx index 470eb54..aad7379 100644 --- a/stores/Provider.jsx +++ b/stores/Provider.jsx @@ -3,5 +3,6 @@ import { initializeStore, StoreContext } from '.'; export default function StoreProvider({ children, ...initialData }) { const store = initializeStore(initialData); + return {children}; } diff --git a/stores/calculation/options/index.ts b/stores/calculation/options/index.ts index e3aeb3c..e6628a2 100644 --- a/stores/calculation/options/index.ts +++ b/stores/calculation/options/index.ts @@ -7,7 +7,7 @@ import type { Elements } from 'Components/Calculation/config/map-values'; import type { BaseOption } from 'Elements/types'; import { mergeWith } from 'lodash'; import { makeAutoObservable } from 'mobx'; -import RootStore from 'stores/root'; +import type RootStore from 'stores/root'; import type { CalculationOptions, Filter, OptionsFilters } from './types'; const EXCLUDE_RESET_ELEMENTS: Elements[] = ['selectTechnicalCard', 'selectTownRegistration']; @@ -43,6 +43,7 @@ export default class OptionsStore { /** **************** OPTIONS **************** */ getOption(elementName: Elements) { const value = this.root.$calculation.$values.getValueByElement(elementName); + return this.options[elementName]?.find((x) => x.value === value); } @@ -57,6 +58,7 @@ export default class OptionsStore { if (!settings?.filtered) return options; const filter = this.filters[elementName]; + return filter ? options && filter(options) : options; } @@ -97,6 +99,7 @@ export default class OptionsStore { if (!filteredOptons?.length || !filteredOptons.some((x) => x.value === elementValue)) { this.root.$calculation.$values.clearValueOfElement(elementName); } + return; } diff --git a/stores/calculation/statuses/index.ts b/stores/calculation/statuses/index.ts index 1cd812c..5c2ab0b 100644 --- a/stores/calculation/statuses/index.ts +++ b/stores/calculation/statuses/index.ts @@ -3,7 +3,7 @@ import type { Elements } from 'Components/Calculation/config/map-values'; import type { Status } from 'Elements/types'; import { makeAutoObservable } from 'mobx'; -import RootStore from 'stores/root'; +import type RootStore from 'stores/root'; import type { CalculationStatuses } from './types'; export default class StatusStore { diff --git a/stores/calculation/validation/index.ts b/stores/calculation/validation/index.ts index dbb250c..c574147 100644 --- a/stores/calculation/validation/index.ts +++ b/stores/calculation/validation/index.ts @@ -3,7 +3,7 @@ /* eslint-disable object-curly-newline */ import type { Elements } from 'Components/Calculation/config/map-values'; import { makeAutoObservable, observable } from 'mobx'; -import RootStore from 'stores/root'; +import type RootStore from 'stores/root'; import type { Error, Messages } from './types'; export default class ValidationStore { diff --git a/stores/user.ts b/stores/user.ts index 7e1545b..552077b 100644 --- a/stores/user.ts +++ b/stores/user.ts @@ -1,7 +1,7 @@ /* eslint-disable import/no-cycle */ import { makeAutoObservable } from 'mobx'; import type { User } from 'services/user/types'; -import RootStore from './root'; +import type RootStore from './root'; export default class UserStore { root: RootStore; @@ -18,8 +18,10 @@ export default class UserStore { getDomainName() { if (this.user) { const { username, domain } = this.user; + return `${domain}\\${username}`; } + return ''; } }