Use `import type` in some places

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2022-06-09 21:08:51 +02:00
parent 95e037f8c0
commit 2786fa257b
43 changed files with 46 additions and 52 deletions

View File

@ -1,8 +1,9 @@
import { jest } from '@jest/globals';
import { AxiosInstance, AxiosResponse } from 'axios';
import MockAdapter from 'axios-mock-adapter';
import LinkHeader from 'http-link-header';
import type { AxiosInstance, AxiosResponse } from 'axios';
const api = jest.requireActual('../api') as Record<string, Function>;
let mocks: Array<Function> = [];

View File

@ -1,10 +1,10 @@
import { AxiosError } from 'axios';
import { mockStore } from 'soapbox/jest/test-helpers';
import rootReducer from 'soapbox/reducers';
import { dismissAlert, showAlert, showAlertForError } from '../alerts';
import type { AxiosError } from 'axios';
const buildError = (message: string, status: number) => new AxiosError<any>(message, String(status), null, null, {
data: {
error: message,

View File

@ -1,7 +1,7 @@
import { AnyAction } from 'redux';
import { staticClient } from '../api';
import type { AnyAction } from 'redux';
const FETCH_ABOUT_PAGE_REQUEST = 'FETCH_ABOUT_PAGE_REQUEST';
const FETCH_ABOUT_PAGE_SUCCESS = 'FETCH_ABOUT_PAGE_SUCCESS';
const FETCH_ABOUT_PAGE_FAIL = 'FETCH_ABOUT_PAGE_FAIL';

View File

@ -1,10 +1,10 @@
import { AnyAction } from '@reduxjs/toolkit';
import { AxiosError } from 'axios';
import { defineMessages, MessageDescriptor } from 'react-intl';
import { httpErrorMessages } from 'soapbox/utils/errors';
import { SnackbarActionSeverity } from './snackbar';
import type { SnackbarActionSeverity } from './snackbar';
import type { AnyAction } from '@reduxjs/toolkit';
import type { AxiosError } from 'axios';
const messages = defineMessages({
unexpectedTitle: { id: 'alert.unexpected.title', defaultMessage: 'Oops!' },

View File

@ -1,6 +1,3 @@
import { AnyAction } from '@reduxjs/toolkit';
import { AxiosError } from 'axios';
import { isLoggedIn } from 'soapbox/utils/auth';
import { getNextLinkName } from 'soapbox/utils/quirks';
@ -9,6 +6,9 @@ import api, { getLinks } from '../api';
import { fetchRelationships } from './accounts';
import { importFetchedAccounts } from './importer';
import type { AnyAction } from '@reduxjs/toolkit';
import type { AxiosError } from 'axios';
const BLOCKS_FETCH_REQUEST = 'BLOCKS_FETCH_REQUEST';
const BLOCKS_FETCH_SUCCESS = 'BLOCKS_FETCH_SUCCESS';
const BLOCKS_FETCH_FAIL = 'BLOCKS_FETCH_FAIL';

View File

@ -27,7 +27,6 @@ export const submit = (routerHistory) => (dispatch, getState) => {
}
};
export const create = (title, description, coverImage, routerHistory) => (dispatch, getState) => {
if (!isLoggedIn(getState)) return;
@ -47,7 +46,6 @@ export const create = (title, description, coverImage, routerHistory) => (dispat
}).catch(err => dispatch(createFail(err)));
};
export const createRequest = id => ({
type: GROUP_CREATE_REQUEST,
id,
@ -82,7 +80,6 @@ export const update = (groupId, title, description, coverImage, routerHistory) =
}).catch(err => dispatch(updateFail(err)));
};
export const updateRequest = id => ({
type: GROUP_UPDATE_REQUEST,
id,

View File

@ -90,7 +90,6 @@ class ModalRoot extends React.PureComponent {
}
};
handleKeyDown = (e) => {
if (e.key === 'Tab') {
const focusable = Array.from(this.node.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter((x) => window.getComputedStyle(x).display !== 'none');

View File

@ -29,7 +29,6 @@ const MoreFollows: React.FC<IMoreFollows> = ({ visible = true, count, type }) =>
return intl.formatMessage(messages[type], { count });
};
// If the instance isn't federating, there are no remote followers
if (!features.federating) {
return null;

View File

@ -34,7 +34,6 @@ const StillImage: React.FC<IStillImage> = ({ alt, className, src, style }) => {
}
};
return (
<div data-testid='still-image-container' className={classNames(className, 'still-image', { 'still-image--play-on-hover': hoverToPlay })} style={style}>
<img src={src} alt={alt} ref={img} onLoad={handleImageLoad} />

View File

@ -169,7 +169,6 @@ const PollForm = (props: IPollForm) => {
const handleToggleMultiple = () => onChangeSettings(expiresIn, !isMultiple);
if (!options) {
return null;
}

View File

@ -6,7 +6,6 @@ import { changeSettingImmediate } from 'soapbox/actions/settings';
import snackbar from 'soapbox/actions/snackbar';
import { Button, Form, FormActions, FormGroup, Input, Text } from 'soapbox/components/ui';
import Column from '../ui/components/column';
const messages = defineMessages({

View File

@ -13,7 +13,6 @@ const emojiMap = require('./emoji_map.json');
const { unicodeToFilename } = require('./unicode_to_filename');
const { unicodeToUnifiedName } = require('./unicode_to_unified_name');
if (data.compressed) {
data = emojiMartUncompress(data);
}

View File

@ -48,7 +48,6 @@ const mapStateToProps = state => ({
filters: state.get('filters'),
});
export default @connect(mapStateToProps)
@injectIntl
class Filters extends ImmutablePureComponent {

View File

@ -21,7 +21,6 @@ const CSVImporter: React.FC<ICSVImporter> = ({ messages, action }) => {
const [isLoading, setIsLoading] = useState(false);
const [file, setFile] = useState<File | null | undefined>(null);
const handleSubmit: React.FormEventHandler = (event) => {
const params = new FormData();
params.append('list', file!);

View File

@ -1,4 +1,3 @@
import { AxiosError } from 'axios';
import * as React from 'react';
import { FormattedMessage } from 'react-intl';
import { useDispatch } from 'react-redux';
@ -8,6 +7,8 @@ import snackbar from 'soapbox/actions/snackbar';
import { Button, Card, CardBody, FormGroup, Stack, Text, Textarea } from 'soapbox/components/ui';
import { useOwnAccount } from 'soapbox/hooks';
import type { AxiosError } from 'axios';
const BioStep = ({ onNext }: { onNext: () => void }) => {
const dispatch = useDispatch();

View File

@ -1,4 +1,3 @@
import { AxiosError } from 'axios';
import classNames from 'classnames';
import * as React from 'react';
import { FormattedMessage } from 'react-intl';
@ -11,6 +10,8 @@ import { Avatar, Button, Card, CardBody, Icon, Spinner, Stack, Text } from 'soap
import { useOwnAccount } from 'soapbox/hooks';
import resizeImage from 'soapbox/utils/resize_image';
import type { AxiosError } from 'axios';
/** Default header filenames from various backends */
const DEFAULT_HEADERS = [
'/headers/original/missing.png', // Mastodon

View File

@ -1,4 +1,3 @@
import { AxiosError } from 'axios';
import * as React from 'react';
import { FormattedMessage } from 'react-intl';
import { useDispatch } from 'react-redux';
@ -8,6 +7,8 @@ import snackbar from 'soapbox/actions/snackbar';
import { Button, Card, CardBody, FormGroup, Input, Stack, Text } from 'soapbox/components/ui';
import { useOwnAccount } from 'soapbox/hooks';
import type { AxiosError } from 'axios';
const DisplayNameStep = ({ onNext }: { onNext: () => void }) => {
const dispatch = useDispatch();

View File

@ -14,7 +14,6 @@ const messages = defineMessages({
passwordPlaceholder: { id: 'mfa.mfa_setup.password_placeholder', defaultMessage: 'Password' },
});
const DisableOtpForm: React.FC = () => {
const [isLoading, setIsLoading] = useState(false);
const [password, setPassword] = useState('');
@ -39,7 +38,6 @@ const DisableOtpForm: React.FC = () => {
setPassword(event.target.value);
};
return (
<Form onSubmit={handleSubmit}>
<Stack>

View File

@ -29,7 +29,6 @@ const MfaForm: React.FC = () => {
dispatch(fetchMfa());
}, []);
const handleSetupProceedClick = (event: React.MouseEvent) => {
event.preventDefault();
setDisplayOtpForm(true);

View File

@ -525,7 +525,6 @@ class ActionBar extends React.PureComponent<IActionBar, IActionBarState> {
const canShare = ('share' in navigator) && status.visibility === 'public';
let reblogIcon = require('@tabler/icons/icons/repeat.svg');
if (status.visibility === 'direct') {

View File

@ -39,7 +39,6 @@ import BundleContainer from '../containers/bundle_container';
import BundleModalError from './bundle_modal_error';
import ModalLoading from './modal_loading';
const MODAL_COMPONENTS = {
'MEDIA': MediaModal,
'VIDEO': VideoModal,

View File

@ -1,4 +1,3 @@
import { AxiosError } from 'axios';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
@ -15,6 +14,8 @@ import ConfirmationStep from './steps/confirmation-step';
import OtherActionsStep from './steps/other-actions-step';
import ReasonStep from './steps/reason-step';
import type { AxiosError } from 'axios';
const messages = defineMessages({
blankslate: { id: 'report.reason.blankslate', defaultMessage: 'You have removed all statuses from being selected.' },
done: { id: 'report.done', defaultMessage: 'Done' },

View File

@ -1,4 +1,3 @@
import { AxiosError } from 'axios';
import classNames from 'classnames';
import React, { useRef, useState } from 'react';
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
@ -15,6 +14,8 @@ import { useOwnAccount, useSoapboxConfig } from 'soapbox/hooks';
import ProfileDropdown from './profile-dropdown';
import type { AxiosError } from 'axios';
const messages = defineMessages({
login: { id: 'navbar.login.action', defaultMessage: 'Log in' },
username: { id: 'navbar.login.username.placeholder', defaultMessage: 'Email or username' },

View File

@ -3,7 +3,6 @@ import { connect } from 'react-redux';
import { fetchBundleRequest, fetchBundleSuccess, fetchBundleFail } from '../../../actions/bundles';
import Bundle from '../components/bundle';
const mapDispatchToProps = dispatch => ({
onFetch() {
dispatch(fetchBundleRequest());

View File

@ -1,4 +1,3 @@
import { AxiosError } from 'axios';
import * as React from 'react';
import { defineMessages, useIntl } from 'react-intl';
import { useDispatch } from 'react-redux';
@ -8,6 +7,8 @@ import snackbar from 'soapbox/actions/snackbar';
import { confirmEmailVerification } from 'soapbox/actions/verification';
import { Icon, Spinner, Stack, Text } from 'soapbox/components/ui';
import type { AxiosError } from 'axios';
const Statuses = {
IDLE: 'IDLE',
SUCCESS: 'SUCCESS',

View File

@ -1,4 +1,3 @@
import { AxiosError } from 'axios';
import * as React from 'react';
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
import { useDispatch } from 'react-redux';
@ -13,6 +12,8 @@ import { Button, Form, FormGroup, Input } from 'soapbox/components/ui';
import { useAppSelector } from 'soapbox/hooks';
import { getRedirectUrl } from 'soapbox/utils/redirect';
import type { AxiosError } from 'axios';
const messages = defineMessages({
success: {
id: 'registrations.success',

View File

@ -165,5 +165,4 @@ const SmsVerification = () => {
);
};
export { SmsVerification as default, validPhoneNumberRegex };

View File

@ -7,7 +7,6 @@ import reducer from '../accounts_counters';
// import accounts_counter_unfollow from 'soapbox/__fixtures__/accounts_counter_unfollow.json';
// import accounts_counter_follow from 'soapbox/__fixtures__/accounts_counter_follow.json';
describe('accounts_counters reducer', () => {
it('should return the initial state', () => {
expect(reducer(undefined, {})).toEqual(ImmutableMap());

View File

@ -1,5 +1,4 @@
import { Record as ImmutableRecord } from 'immutable';
import { AnyAction } from 'redux';
import {
ACCOUNT_NOTE_INIT_MODAL,
@ -9,6 +8,8 @@ import {
ACCOUNT_NOTE_SUBMIT_SUCCESS,
} from '../actions/account-notes';
import type { AnyAction } from 'redux';
const EditRecord = ImmutableRecord({
isSubmitting: false,
account: null,

View File

@ -4,7 +4,6 @@ import {
OrderedSet as ImmutableOrderedSet,
fromJS,
} from 'immutable';
import { AnyAction } from 'redux';
import {
ADMIN_USERS_FETCH_SUCCESS,
@ -39,6 +38,8 @@ import { STREAMING_CHAT_UPDATE } from 'soapbox/actions/streaming';
import { normalizeAccount } from 'soapbox/normalizers/account';
import { normalizeId } from 'soapbox/utils/normalizers';
import type { AnyAction } from 'redux';
type AccountRecord = ReturnType<typeof normalizeAccount>;
type AccountMap = ImmutableMap<string, any>;
type APIEntity = Record<string, any>;

View File

@ -10,7 +10,6 @@ import {
import type { AnyAction } from 'redux';
import type { APIEntity } from 'soapbox/types/entities';
const ReducerRecord = ImmutableRecord({
aliases: ImmutableRecord({
items: ImmutableList<string>(),

View File

@ -257,7 +257,6 @@ const importMastodonPreload = (state, data) => {
});
};
const persistAuthAccount = account => {
if (account && account.url) {
const key = `authAccount:${account.url}`;

View File

@ -1,5 +1,4 @@
import { Map as ImmutableMap, OrderedSet as ImmutableOrderedSet } from 'immutable';
import { AnyAction } from 'redux';
import {
CHATS_FETCH_SUCCESS,
@ -11,6 +10,8 @@ import {
} from 'soapbox/actions/chats';
import { STREAMING_CHAT_UPDATE } from 'soapbox/actions/streaming';
import type { AnyAction } from 'redux';
type APIEntity = Record<string, any>;
type APIEntities = Array<APIEntity>;

View File

@ -1,5 +1,4 @@
import { Map as ImmutableMap, fromJS } from 'immutable';
import { AnyAction } from 'redux';
import {
CHATS_FETCH_SUCCESS,
@ -13,6 +12,8 @@ import {
import { STREAMING_CHAT_UPDATE } from 'soapbox/actions/streaming';
import { normalizeChatMessage } from 'soapbox/normalizers';
import type { AnyAction } from 'redux';
type ChatMessageRecord = ReturnType<typeof normalizeChatMessage>;
type APIEntity = Record<string, any>;
type APIEntities = Array<APIEntity>;

View File

@ -1,9 +1,10 @@
import { List as ImmutableList, Map as ImmutableMap, Record as ImmutableRecord } from 'immutable';
import { AnyAction } from 'redux';
import { HISTORY_FETCH_REQUEST, HISTORY_FETCH_SUCCESS, HISTORY_FETCH_FAIL } from 'soapbox/actions/history';
import { normalizeStatusEdit } from 'soapbox/normalizers';
import type { AnyAction } from 'redux';
type StatusEditRecord = ReturnType<typeof normalizeStatusEdit>;
const HistoryRecord = ImmutableRecord({

View File

@ -1,5 +1,4 @@
import { Map as ImmutableMap, List as ImmutableList, fromJS } from 'immutable';
import { AnyAction } from 'redux';
import { ADMIN_CONFIG_UPDATE_REQUEST, ADMIN_CONFIG_UPDATE_SUCCESS } from 'soapbox/actions/admin';
import { PLEROMA_PRELOAD_IMPORT } from 'soapbox/actions/preload';
@ -13,6 +12,8 @@ import {
fetchNodeinfo,
} from '../actions/instance';
import type { AnyAction } from 'redux';
const initialState = normalizeInstance(ImmutableMap());
const nodeinfoToInstance = (nodeinfo: ImmutableMap<string, any>) => {

View File

@ -1,5 +1,4 @@
import { List as ImmutableList, Record as ImmutableRecord } from 'immutable';
import { AnyAction } from 'redux';
import {
LIST_ADDER_RESET,
@ -11,6 +10,8 @@ import {
LIST_EDITOR_REMOVE_SUCCESS,
} from '../actions/lists';
import type { AnyAction } from 'redux';
const ListsRecord = ImmutableRecord({
items: ImmutableList<string>(),
loaded: false,

View File

@ -1,5 +1,4 @@
import { List as ImmutableList, Record as ImmutableRecord } from 'immutable';
import { AnyAction } from 'redux';
import {
LIST_CREATE_REQUEST,
@ -21,6 +20,8 @@ import {
LIST_EDITOR_REMOVE_SUCCESS,
} from '../actions/lists';
import type { AnyAction } from 'redux';
const AccountsRecord = ImmutableRecord({
items: ImmutableList<string>(),
loaded: false,

View File

@ -1,5 +1,4 @@
import { Map as ImmutableMap } from 'immutable';
import { AnyAction } from 'redux';
import {
LIST_FETCH_SUCCESS,
@ -11,6 +10,8 @@ import {
} from 'soapbox/actions/lists';
import { normalizeList } from 'soapbox/normalizers';
import type { AnyAction } from 'redux';
type ListRecord = ReturnType<typeof normalizeList>;
type APIEntity = Record<string, any>;
type APIEntities = Array<APIEntity>;

View File

@ -4,7 +4,6 @@ import { MODAL_OPEN, MODAL_CLOSE } from '../actions/modals';
import type { AnyAction } from 'redux';
const ModalRecord = ImmutableRecord({
modalType: '',
modalProps: null as Record<string, any> | null,

View File

@ -1,6 +1,5 @@
import { OrderedSet as ImmutableOrderedSet, Record as ImmutableRecord } from 'immutable';
import { ACCOUNT_BLOCK_SUCCESS, ACCOUNT_MUTE_SUCCESS } from 'soapbox/actions/accounts';
import { DOMAIN_BLOCK_SUCCESS } from 'soapbox/actions/domain_blocks';
import {

View File

@ -1,11 +1,12 @@
import { configureStore } from '@reduxjs/toolkit';
import { AnyAction } from 'redux';
import thunk, { ThunkDispatch } from 'redux-thunk';
import errorsMiddleware from './middleware/errors';
import soundsMiddleware from './middleware/sounds';
import appReducer from './reducers';
import type { AnyAction } from 'redux';
export const store = configureStore({
reducer: appReducer,
middleware: [

View File

@ -100,7 +100,6 @@ manageTranslations({
},
});
// Check variable interpolations and print error messages if variables are
// used in translations which are not used in the default message.
/* eslint-disable no-console */