[build] upgrade eslint to 9.37.0 (#88)
Co-authored-by: tobi <tobi.smethurst@protonmail.com> Reviewed-on: https://codeberg.org/superseriousbusiness/masto-fe-standalone/pulls/88 Co-authored-by: Zoë Bijl <moiety@noreply.codeberg.org> Co-committed-by: Zoë Bijl <moiety@noreply.codeberg.org>
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
export { store } from './store';
|
||||
export type { GetState, AppDispatch, RootState } from './store';
|
||||
export { store } from "./store";
|
||||
export type { GetState, AppDispatch, RootState } from "./store";
|
||||
|
||||
export {
|
||||
createAppAsyncThunk,
|
||||
useAppDispatch,
|
||||
useAppSelector,
|
||||
} from './typed_functions';
|
||||
} from "./typed_functions";
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
import type { AnyAction, Middleware } from 'redux';
|
||||
import { type AnyAction, type Middleware } from "redux";
|
||||
|
||||
import type { RootState } from '..';
|
||||
import { showAlertForError } from '../../actions/alerts';
|
||||
import { type RootState } from "..";
|
||||
import { showAlertForError } from "../../actions/alerts";
|
||||
|
||||
const defaultFailSuffix = 'FAIL';
|
||||
const defaultFailSuffix = "FAIL";
|
||||
|
||||
export const errorsMiddleware: Middleware<unknown, RootState> =
|
||||
({ dispatch }) =>
|
||||
(next) =>
|
||||
(action: AnyAction & { skipAlert?: boolean; skipNotFound?: boolean }) => {
|
||||
if (action.type && !action.skipAlert) {
|
||||
const isFail = new RegExp(`${defaultFailSuffix}$`, 'g');
|
||||
(next) =>
|
||||
(action: AnyAction & { skipAlert?: boolean, skipNotFound?: boolean }) => {
|
||||
if (action.type && !action.skipAlert) {
|
||||
const isFail = new RegExp(`${defaultFailSuffix}$`, "g");
|
||||
|
||||
if (typeof action.type === 'string' && action.type.match(isFail)) {
|
||||
dispatch(showAlertForError(action.error, action.skipNotFound));
|
||||
}
|
||||
}
|
||||
if (typeof action.type === "string" && action.type.match(isFail)) {
|
||||
dispatch(showAlertForError(action.error, action.skipNotFound));
|
||||
}
|
||||
}
|
||||
|
||||
return next(action);
|
||||
};
|
||||
return next(action);
|
||||
};
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import { showLoading, hideLoading } from 'react-redux-loading-bar';
|
||||
import type { AnyAction, Middleware } from 'redux';
|
||||
import { showLoading, hideLoading } from "react-redux-loading-bar";
|
||||
import { type AnyAction, type Middleware } from "redux";
|
||||
|
||||
import type { RootState } from '..';
|
||||
import { type RootState } from "..";
|
||||
|
||||
interface Config {
|
||||
promiseTypeSuffixes?: string[];
|
||||
promiseTypeSuffixes?: string[],
|
||||
}
|
||||
|
||||
const defaultTypeSuffixes: Config['promiseTypeSuffixes'] = [
|
||||
'PENDING',
|
||||
'FULFILLED',
|
||||
'REJECTED',
|
||||
const defaultTypeSuffixes: Config["promiseTypeSuffixes"] = [
|
||||
"PENDING",
|
||||
"FULFILLED",
|
||||
"REJECTED",
|
||||
];
|
||||
|
||||
export const loadingBarMiddleware = (
|
||||
@@ -20,26 +20,26 @@ export const loadingBarMiddleware = (
|
||||
|
||||
return ({ dispatch }) =>
|
||||
(next) =>
|
||||
(action: AnyAction) => {
|
||||
if (action.type && !action.skipLoading) {
|
||||
const [PENDING, FULFILLED, REJECTED] = promiseTypeSuffixes;
|
||||
(action: AnyAction) => {
|
||||
if (action.type && !action.skipLoading) {
|
||||
const [PENDING, FULFILLED, REJECTED] = promiseTypeSuffixes;
|
||||
|
||||
const isPending = new RegExp(`${PENDING}$`, 'g');
|
||||
const isFulfilled = new RegExp(`${FULFILLED}$`, 'g');
|
||||
const isRejected = new RegExp(`${REJECTED}$`, 'g');
|
||||
const isPending = new RegExp(`${PENDING}$`, "g");
|
||||
const isFulfilled = new RegExp(`${FULFILLED}$`, "g");
|
||||
const isRejected = new RegExp(`${REJECTED}$`, "g");
|
||||
|
||||
if (typeof action.type === 'string') {
|
||||
if (action.type.match(isPending)) {
|
||||
dispatch(showLoading());
|
||||
} else if (
|
||||
action.type.match(isFulfilled) ??
|
||||
if (typeof action.type === "string") {
|
||||
if (action.type.match(isPending)) {
|
||||
dispatch(showLoading());
|
||||
} else if (
|
||||
action.type.match(isFulfilled) ??
|
||||
action.type.match(isRejected)
|
||||
) {
|
||||
dispatch(hideLoading());
|
||||
) {
|
||||
dispatch(hideLoading());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return next(action);
|
||||
};
|
||||
return next(action);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
import type { Middleware, AnyAction } from 'redux';
|
||||
import { type Middleware, type AnyAction } from "redux";
|
||||
|
||||
import ready from 'mastodon/ready';
|
||||
import { assetHost } from 'mastodon/utils/config';
|
||||
import ready from "mastodon/ready";
|
||||
import { assetHost } from "mastodon/utils/config";
|
||||
|
||||
import type { RootState } from '..';
|
||||
import { type RootState } from "..";
|
||||
|
||||
interface AudioSource {
|
||||
src: string;
|
||||
type: string;
|
||||
src: string,
|
||||
type: string,
|
||||
}
|
||||
|
||||
const createAudio = (sources: AudioSource[]) => {
|
||||
const audio = new Audio();
|
||||
sources.forEach(({ type, src }) => {
|
||||
const source = document.createElement('source');
|
||||
const source = document.createElement("source");
|
||||
source.type = type;
|
||||
source.src = src;
|
||||
audio.appendChild(source);
|
||||
@@ -24,7 +24,7 @@ const createAudio = (sources: AudioSource[]) => {
|
||||
const play = (audio: HTMLAudioElement) => {
|
||||
if (!audio.paused) {
|
||||
audio.pause();
|
||||
if (typeof audio.fastSeek === 'function') {
|
||||
if (typeof audio.fastSeek === "function") {
|
||||
audio.fastSeek(0);
|
||||
} else {
|
||||
audio.currentTime = 0;
|
||||
@@ -41,24 +41,24 @@ export const soundsMiddleware = (): Middleware<unknown, RootState> => {
|
||||
soundCache.boop = createAudio([
|
||||
{
|
||||
src: `${assetHost}/sounds/boop.ogg`,
|
||||
type: 'audio/ogg',
|
||||
type: "audio/ogg",
|
||||
},
|
||||
{
|
||||
src: `${assetHost}/sounds/boop.mp3`,
|
||||
type: 'audio/mpeg',
|
||||
type: "audio/mpeg",
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
return () =>
|
||||
(next) =>
|
||||
(action: AnyAction & { meta?: { sound?: string } }) => {
|
||||
const sound = action.meta?.sound;
|
||||
(action: AnyAction & { meta?: { sound?: string } }) => {
|
||||
const sound = action.meta?.sound;
|
||||
|
||||
if (sound && Object.hasOwn(soundCache, sound)) {
|
||||
play(soundCache[sound]);
|
||||
}
|
||||
if (sound && Object.hasOwn(soundCache, sound)) {
|
||||
play(soundCache[sound]);
|
||||
}
|
||||
|
||||
return next(action);
|
||||
};
|
||||
return next(action);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { configureStore } from '@reduxjs/toolkit';
|
||||
import { configureStore } from "@reduxjs/toolkit";
|
||||
|
||||
import { rootReducer } from '../reducers';
|
||||
import { rootReducer } from "../reducers";
|
||||
|
||||
import { errorsMiddleware } from './middlewares/errors';
|
||||
import { loadingBarMiddleware } from './middlewares/loading_bar';
|
||||
import { soundsMiddleware } from './middlewares/sounds';
|
||||
import { errorsMiddleware } from "./middlewares/errors";
|
||||
import { loadingBarMiddleware } from "./middlewares/loading_bar";
|
||||
import { soundsMiddleware } from "./middlewares/sounds";
|
||||
|
||||
export const store = configureStore({
|
||||
reducer: rootReducer,
|
||||
@@ -26,7 +26,7 @@ export const store = configureStore({
|
||||
})
|
||||
.concat(
|
||||
loadingBarMiddleware({
|
||||
promiseTypeSuffixes: ['REQUEST', 'SUCCESS', 'FAIL'],
|
||||
promiseTypeSuffixes: ["REQUEST", "SUCCESS", "FAIL"],
|
||||
}),
|
||||
)
|
||||
.concat(errorsMiddleware)
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import type { TypedUseSelectorHook } from 'react-redux';
|
||||
import { useDispatch, useSelector } from 'react-redux';
|
||||
import { type TypedUseSelectorHook } from "react-redux";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
|
||||
import { createAsyncThunk } from '@reduxjs/toolkit';
|
||||
import { createAsyncThunk } from "@reduxjs/toolkit";
|
||||
|
||||
import type { AppDispatch, RootState } from './store';
|
||||
import { type AppDispatch, type RootState } from "./store";
|
||||
|
||||
export const useAppDispatch: () => AppDispatch = useDispatch;
|
||||
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;
|
||||
|
||||
export const createAppAsyncThunk = createAsyncThunk.withTypes<{
|
||||
state: RootState;
|
||||
dispatch: AppDispatch;
|
||||
rejectValue: string;
|
||||
state: RootState,
|
||||
dispatch: AppDispatch,
|
||||
rejectValue: string,
|
||||
}>();
|
||||
|
||||
Reference in New Issue
Block a user