From d8058c657639a17bf2e54ef0911b241b3a473b01 Mon Sep 17 00:00:00 2001 From: Pavel Mineev Date: Thu, 6 May 2021 01:24:08 +0300 Subject: [PATCH] use named imports --- frontend/app/__stubs__/store.ts | 4 +-- frontend/app/common/api.getLastComments.ts | 2 +- frontend/app/common/copy.ts | 2 +- frontend/app/common/settings.ts | 2 +- frontend/app/common/user-info-settings.ts | 2 +- .../components/auth-panel/auth-panel.test.tsx | 2 +- .../app/components/auth-panel/auth-panel.tsx | 15 ++++---- frontend/app/components/auth-panel/index.ts | 2 +- .../app/components/auth/auth.messsages.ts | 4 +-- frontend/app/components/auth/auth.spec.tsx | 6 ++-- frontend/app/components/auth/auth.tsx | 12 +++---- frontend/app/components/auth/auth.utils.ts | 2 +- .../app/components/auth/components/button.tsx | 2 +- .../components/auth/components/oauth.spec.tsx | 6 ++-- .../app/components/auth/components/oauth.tsx | 12 +++---- .../components/auth/components/oauth.utils.ts | 2 +- frontend/app/components/auth/index.ts | 2 +- .../comment-form__subscribe-by-email.tsx | 6 ++-- .../comment-form__subscribe-by-rss.tsx | 2 +- .../comment-form/comment-form.test.tsx | 2 +- .../components/comment-form/comment-form.tsx | 6 ++-- .../markdown-toolbar-icons/bold-icon.tsx | 2 +- .../markdown-toolbar-icons/code-icon.tsx | 2 +- .../markdown-toolbar-icons/header-icon.tsx | 2 +- .../markdown-toolbar-icons/image-icon.tsx | 2 +- .../markdown-toolbar-icons/italic-icon.tsx | 2 +- .../markdown-toolbar-icons/link-icon.tsx | 2 +- .../ordered-list-icon.tsx | 2 +- .../markdown-toolbar-icons/quote-icon.tsx | 2 +- .../unordered-list-icon.tsx | 2 +- .../comment-form/markdown-toolbar.tsx | 20 +++++------ .../components/comment-form/text-expander.tsx | 2 +- .../app/components/comment/comment.test.tsx | 2 +- frontend/app/components/comment/comment.tsx | 12 +++---- .../components/comment/connected-comment.tsx | 2 +- frontend/app/components/comment/index.ts | 2 +- frontend/app/components/countdown/index.tsx | 2 +- .../app/components/list-comments/index.ts | 2 +- .../list-comments/list-comments.tsx | 12 +++---- frontend/app/components/preloader/index.ts | 2 +- .../app/components/preloader/preloader.tsx | 12 +++---- .../app/components/root/in-view/in-view.tsx | 8 ++--- frontend/app/components/root/root.tsx | 8 ++--- frontend/app/components/settings/index.ts | 5 +-- frontend/app/components/settings/settings.tsx | 10 ++++-- frontend/app/components/textarea-autosize.tsx | 34 ++++++++----------- frontend/app/components/thread/thread.tsx | 2 +- .../user-info/last-comments-list.tsx | 17 ++++++---- .../app/components/user-info/user-info.tsx | 4 +-- frontend/app/components/with-theme/index.tsx | 22 ------------ frontend/app/hooks/useTheme.ts | 2 +- frontend/app/last-comments.tsx | 4 +-- frontend/app/remark.tsx | 8 ++--- frontend/app/store/comments/actions.test.ts | 4 +-- frontend/app/store/comments/reducers.ts | 2 +- frontend/app/store/index.ts | 9 +++-- frontend/app/store/reducers.ts | 8 ++--- frontend/app/store/user/actions.test.ts | 16 ++++----- frontend/app/store/user/actions.ts | 2 +- .../app/utils/capitalize-first-letter.spec.ts | 2 +- frontend/app/utils/capitalize-first-letter.ts | 2 +- frontend/app/utils/debounce.ts | 5 +-- frontend/app/utils/get-hidden-users.test.ts | 2 +- frontend/app/utils/get-hidden-users.ts | 2 +- frontend/app/utils/noop.ts | 2 -- frontend/app/utils/parseQuery.test.ts | 2 +- frontend/app/utils/parseQuery.ts | 2 +- frontend/app/utils/postMessage.ts | 2 +- frontend/app/utils/shallowCompare.ts | 2 +- 69 files changed, 168 insertions(+), 203 deletions(-) delete mode 100644 frontend/app/components/with-theme/index.tsx delete mode 100644 frontend/app/utils/noop.ts diff --git a/frontend/app/__stubs__/store.ts b/frontend/app/__stubs__/store.ts index cd97280d..ccb6da27 100644 --- a/frontend/app/__stubs__/store.ts +++ b/frontend/app/__stubs__/store.ts @@ -2,6 +2,4 @@ import createMockStore from 'redux-mock-store'; import thunk from 'redux-thunk'; // eslint-disable-next-line @typescript-eslint/no-explicit-any -const mockStore = createMockStore([thunk]); - -export default mockStore; +export const mockStore = createMockStore([thunk]); diff --git a/frontend/app/common/api.getLastComments.ts b/frontend/app/common/api.getLastComments.ts index 305619a7..4ec377cf 100644 --- a/frontend/app/common/api.getLastComments.ts +++ b/frontend/app/common/api.getLastComments.ts @@ -1,6 +1,6 @@ import { Comment } from './types'; import { apiFetcher } from './fetcher'; -export default function getLastComments(siteId: string, max: number): Promise { +export function getLastComments(siteId: string, max: number): Promise { return apiFetcher.get(`/last/${max}`, { site: siteId }); } diff --git a/frontend/app/common/copy.ts b/frontend/app/common/copy.ts index 7ad3cda7..188a603e 100644 --- a/frontend/app/common/copy.ts +++ b/frontend/app/common/copy.ts @@ -1,5 +1,5 @@ // based on https://github.com/sindresorhus/copy-text-to-clipboard, but improved to copy text styles too -export default function copy(input: string): boolean { +export function copy(input: string): boolean { const element = document.createElement('textarea') as HTMLTextAreaElement; const previouslyFocusedElement = document.activeElement as HTMLElement; diff --git a/frontend/app/common/settings.ts b/frontend/app/common/settings.ts index 0b20e1b2..d7dfa51f 100644 --- a/frontend/app/common/settings.ts +++ b/frontend/app/common/settings.ts @@ -1,4 +1,4 @@ -import parseQuery from 'utils/parseQuery'; +import { parseQuery } from 'utils/parseQuery'; import type { Theme } from './types'; import { THEMES, MAX_SHOWN_ROOT_COMMENTS } from './constants'; diff --git a/frontend/app/common/user-info-settings.ts b/frontend/app/common/user-info-settings.ts index b352baac..79400215 100644 --- a/frontend/app/common/user-info-settings.ts +++ b/frontend/app/common/user-info-settings.ts @@ -1,4 +1,4 @@ -import parseQuery from 'utils/parseQuery'; +import { parseQuery } from 'utils/parseQuery'; import type { UserInfo } from './types'; diff --git a/frontend/app/components/auth-panel/auth-panel.test.tsx b/frontend/app/components/auth-panel/auth-panel.test.tsx index 6fc42597..63d16544 100644 --- a/frontend/app/components/auth-panel/auth-panel.test.tsx +++ b/frontend/app/components/auth-panel/auth-panel.test.tsx @@ -8,7 +8,7 @@ import { IntlProvider } from 'react-intl'; import type { User } from 'common/types'; import enMessages from 'locales/en.json'; -import AuthPanel, { Props } from './auth-panel'; +import { AuthPanel, Props } from './auth-panel'; const DefaultProps = { postInfo: { diff --git a/frontend/app/components/auth-panel/auth-panel.tsx b/frontend/app/components/auth-panel/auth-panel.tsx index 3970ec13..19134f87 100644 --- a/frontend/app/components/auth-panel/auth-panel.tsx +++ b/frontend/app/components/auth-panel/auth-panel.tsx @@ -6,16 +6,15 @@ import b from 'bem-react-helper'; import { User, Sorting, Theme, PostInfo } from 'common/types'; import { IS_STORAGE_AVAILABLE, IS_THIRD_PARTY } from 'common/constants'; import { requestDeletion } from 'utils/email'; -import postMessage from 'utils/postMessage'; +import { postMessage } from 'utils/postMessage'; import { getHandleClickProps } from 'common/accessibility'; import { StoreState } from 'store'; import { Dropdown, DropdownItem } from 'components/dropdown'; import { Button } from 'components/button'; -import Auth from 'components/auth'; +import { Auth } from 'components/auth'; +import { useTheme } from 'hooks/useTheme'; -import useTheme from 'hooks/useTheme'; - -export interface OwnProps { +interface OwnProps { user: User | null; hiddenUsers: StoreState['hiddenUsers']; isCommentsDisabled: boolean; @@ -40,7 +39,7 @@ interface State { sortSelectFocused: boolean; } -export class AuthPanel extends Component { +class AuthPanelComponent extends Component { state = { isBlockedVisible: false, anonymousUsernameInputValue: 'anon', @@ -319,10 +318,10 @@ function getSortArray(currentSort: Sorting, intl: IntlShape) { }); } -export default function AuthPanelConnected(props: OwnProps) { +export function AuthPanel(props: OwnProps) { const intl = useIntl(); const theme = useTheme(); const sort = useSelector((state) => state.comments.sort); - return ; + return ; } diff --git a/frontend/app/components/auth-panel/index.ts b/frontend/app/components/auth-panel/index.ts index f4ce12a6..ed33afe2 100644 --- a/frontend/app/components/auth-panel/index.ts +++ b/frontend/app/components/auth-panel/index.ts @@ -15,4 +15,4 @@ import './_theme/_light/auth-panel_theme_light.css'; import './_logged-in/auth-panel_logged-in.css'; -export { default } from './auth-panel'; +export * from './auth-panel'; diff --git a/frontend/app/components/auth/auth.messsages.ts b/frontend/app/components/auth/auth.messsages.ts index ff48198c..faa98cd5 100644 --- a/frontend/app/components/auth/auth.messsages.ts +++ b/frontend/app/components/auth/auth.messsages.ts @@ -1,6 +1,6 @@ import { defineMessages } from 'react-intl'; -const messages = defineMessages({ +export const messages = defineMessages({ signin: { id: 'auth.signin', defaultMessage: 'Sign In', @@ -58,5 +58,3 @@ const messages = defineMessages({ defaultMessage: 'Submit', }, }); - -export default messages; diff --git a/frontend/app/components/auth/auth.spec.tsx b/frontend/app/components/auth/auth.spec.tsx index f5db67b8..a4ce0bca 100644 --- a/frontend/app/components/auth/auth.spec.tsx +++ b/frontend/app/components/auth/auth.spec.tsx @@ -5,7 +5,7 @@ import { fireEvent, render, waitFor } from '@testing-library/preact'; import { OAuthProvider, User } from 'common/types'; import { StaticStore } from 'common/static-store'; -import Auth from './auth'; +import { Auth } from './auth'; import * as utils from './auth.utils'; import * as api from './auth.api'; import { getProviderData } from './components/oauth.utils'; @@ -14,7 +14,9 @@ jest.mock('react-redux', () => ({ useDispatch: () => jest.fn(), })); -jest.mock('hooks/useTheme', () => () => 'light'); +jest.mock('hooks/useTheme', () => ({ + useTheme: () => 'light', +})); describe('', () => { let defaultProviders = StaticStore.config.auth_providers; diff --git a/frontend/app/components/auth/auth.tsx b/frontend/app/components/auth/auth.tsx index 1e4f7e1b..8ca79359 100644 --- a/frontend/app/components/auth/auth.tsx +++ b/frontend/app/components/auth/auth.tsx @@ -6,18 +6,18 @@ import { useDispatch } from 'react-redux'; import { setUser } from 'store/user/actions'; import { Input } from 'components/input'; -import TextareaAutosize from 'components/textarea-autosize'; +import { TextareaAutosize } from 'components/textarea-autosize'; -import Button from './components/button'; -import OAuthProviders from './components/oauth'; -import messages from './auth.messsages'; +import { Button } from './components/button'; +import { OAuth } from './components/oauth'; +import { messages } from './auth.messsages'; import { useDropdown } from './auth.hooks'; import { getProviders, getTokenInvalidReason } from './auth.utils'; import { emailSignin, verifyEmailSignin, anonymousSignin } from './auth.api'; import styles from './auth.module.css'; -export default function Auth() { +export function Auth() { const intl = useIntl(); const dispath = useDispatch(); const [oauthProviders, formProviders] = getProviders(); @@ -199,7 +199,7 @@ export default function Auth() {
{intl.formatMessage(messages.oauthSource)}
- + )} {hasOAuthProviders && hasFormProviders && ( diff --git a/frontend/app/components/auth/auth.utils.ts b/frontend/app/components/auth/auth.utils.ts index acdbb628..1e3c7dbd 100644 --- a/frontend/app/components/auth/auth.utils.ts +++ b/frontend/app/components/auth/auth.utils.ts @@ -3,7 +3,7 @@ import { StaticStore } from 'common/static-store'; import type { FormProvider, OAuthProvider } from 'common/types'; import { OAUTH_PROVIDERS } from './components/oauth.consts'; -import messages from './auth.messsages'; +import { messages } from './auth.messsages'; export function getProviders(): [OAuthProvider[], FormProvider[]] { const oauthProviders: OAuthProvider[] = []; diff --git a/frontend/app/components/auth/components/button.tsx b/frontend/app/components/auth/components/button.tsx index d5b41c56..00a61469 100644 --- a/frontend/app/components/auth/components/button.tsx +++ b/frontend/app/components/auth/components/button.tsx @@ -11,7 +11,7 @@ type Props = Omit, 'size'> & { selected?: boolean; }; -export default function Button({ children, size, kind, suffix, selected, className, ...props }: Props) { +export function Button({ children, size, kind, suffix, selected, className, ...props }: Props) { return (