[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,13 +1,13 @@
|
||||
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 { 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,
|
||||
@@ -29,7 +29,7 @@ export const store = configureStore({
|
||||
})
|
||||
.concat(
|
||||
loadingBarMiddleware({
|
||||
promiseTypeSuffixes: ['REQUEST', 'SUCCESS', 'FAIL'],
|
||||
promiseTypeSuffixes: ["REQUEST", "SUCCESS", "FAIL"],
|
||||
}),
|
||||
)
|
||||
.concat(errorsMiddleware)
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
import type { AnyAction, Middleware } from 'redux';
|
||||
import { type AnyAction, type Middleware } from "redux";
|
||||
|
||||
import { showAlertForError } from 'flavours/glitch/actions/alerts';
|
||||
import { showAlertForError } from "flavours/glitch/actions/alerts";
|
||||
|
||||
import type { RootState } from '..';
|
||||
import { type RootState } from "..";
|
||||
|
||||
const defaultFailSuffix = 'FAIL';
|
||||
const defaultFailSuffix = "FAIL";
|
||||
|
||||
export const errorsMiddleware: Middleware<Record<string, never>, 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 'flavours/glitch/ready';
|
||||
import { assetHost } from 'flavours/glitch/utils/config';
|
||||
import ready from "flavours/glitch/ready";
|
||||
import { assetHost } from "flavours/glitch/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;
|
||||
@@ -44,24 +44,24 @@ export const soundsMiddleware = (): Middleware<
|
||||
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);
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user