Skip to content

Commit

Permalink
Format everything
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinejaussoin committed Oct 17, 2024
1 parent 7b21157 commit a83a632
Show file tree
Hide file tree
Showing 87 changed files with 247 additions and 242 deletions.
9 changes: 7 additions & 2 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
"ignore": ["dist/**/*", ".next/**/*"],
"include": ["src/**/*.js", "src/**/*.ts"]
},
"formatter": { "enabled": true, "indentStyle": "space", "indentWidth": 2, "ignore": ["backend/src/db/migrations"] },
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2,
"ignore": ["backend/src/db/migrations"]
},
"organizeImports": { "enabled": true },
"linter": {
"enabled": true,
Expand All @@ -22,7 +27,7 @@
"linter": {
"rules": {
"correctness": {
"noUndeclaredVariables": "off"
"noUndeclaredVariables": "off"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/Theme.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type PaletteColorOptions, createTheme } from '@mui/material/styles';
import { colors } from '@mui/material';
import { type PaletteColorOptions, createTheme } from '@mui/material/styles';
import config from './utils/getConfig';

const theme = createTheme({
Expand Down
20 changes: 10 additions & 10 deletions frontend/src/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import type {
BackendCapabilities,
DeleteAccountPayload,
FullUser,
Product,
RegisterPayload,
ResetChangePasswordPayload,
ResetPasswordPayload,
Session,
SessionTemplate,
SessionMetadata,
RegisterPayload,
SessionTemplate,
ValidateEmailPayload,
ResetPasswordPayload,
ResetChangePasswordPayload,
FullUser,
Product,
BackendCapabilities,
DeleteAccountPayload,
} from 'common';
import config from '../utils/getConfig';
import { v4 } from 'uuid';
import { CHECK_PREFIX, encrypt } from '../crypto/crypto';
import config from '../utils/getConfig';
import { getItem, setItem } from '../utils/localStorage';
import {
fetchDelete,
fetchGet,
fetchPost,
fetchPostGet,
fetchDelete,
requestConfig,
} from './fetch';

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/common/models.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { SessionOptions, Session } from './types.js';
import type { Session, SessionOptions } from './types.js';

export const defaultOptions: SessionOptions = {
allowActions: true,
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/common/payloads.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type {
Plan,
Currency,
StripeLocales,
AccessErrorType,
CoachMessage,
Currency,
Plan,
Session,
StripeLocales,
} from './types.js';

export interface RegisterPayload {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/crypto/__tests__/crypto.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { encrypt, decrypt } from '../crypto';
import { describe, expect, it } from 'vitest';
import { decrypt, encrypt } from '../crypto';

describe('Cryptography', () => {
it('Can encrypt and decrypt successfuly with the correct key', () => {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/global/state.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { selector } from 'recoil';
import type { BackendCapabilities } from 'common';
import { fetchBackendCapabilities } from 'api';
import type { BackendCapabilities } from 'common';
import { selector } from 'recoil';

const defaultBackendCapabilities: BackendCapabilities = {
adminEmail: '',
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/hooks/useFormatDate.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
formatDistanceToNow as formatDistanceToNowBase,
type Locale,
formatDistanceToNow as formatDistanceToNowBase,
} from 'date-fns';
import englishLocale from 'date-fns/locale/en-GB';
import { useEffect, useState } from 'react';
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/hooks/useGiphy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState, useEffect, useCallback } from 'react';
import { useCallback, useEffect, useState } from 'react';
import { getGiphyUrl } from '../api';
import useOriginal from './useOriginal';
import { trackEvent } from '../track';
import useOriginal from './useOriginal';

/**
* Implements logic to show or hide the Gipy Image.
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/hooks/useOnHover.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useRef, useState, useEffect } from 'react';
import { useEffect, useRef, useState } from 'react';

export default function useOnHover<T extends HTMLElement>(): [
boolean,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/hooks/useOpenClose.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState, useCallback } from 'react';
import { useCallback, useState } from 'react';

type OpenCloseCallback = () => void;

Expand Down
4 changes: 2 additions & 2 deletions frontend/src/hooks/usePreviousSessions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { SessionMetadata } from 'common';
import useUser from '../state/user/useUser';
import { useCallback, useEffect, useState } from 'react';
import { fetchPreviousSessions } from '../api';
import { useState, useEffect, useCallback } from 'react';
import useUser from '../state/user/useUser';

let CACHE: SessionMetadata[] = [];

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/hooks/useQuota.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import type { Quota } from 'common';
import { useCallback, useMemo } from 'react';
import { useRecoilState } from 'recoil';
import {
quotaState,
DEFAULT_QUOTA,
LOCAL_STORAGE_POSTS_KEY,
quotaState,
} from '../auth/QuotaManager';
import useUser from '../state/user/useUser';
import { setItem } from '../utils/localStorage';
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/hooks/useStateFetch.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState, useEffect, type Dispatch, type SetStateAction } from 'react';
import { type Dispatch, type SetStateAction, useEffect, useState } from 'react';

type UseStateFetchValue<T> = [
T,
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/state/columns.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { ColumnDefinition, ColumnDefinitionType } from 'common';
import { v4 } from 'uuid';
import isEqual from 'lodash/isEqual';
import keyBy from 'lodash/keyBy';
import type { ColumnSettings, Template, TranslationFunction } from './types';
import { v4 } from 'uuid';
import { getTemplateColumns } from './templates';
import isEqual from 'lodash/isEqual';
import type { ColumnSettings, Template, TranslationFunction } from './types';

export function buildDefaults(
template: Template,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/stripe/get-stripe.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { loadStripe, type Stripe } from '@stripe/stripe-js';
import { type Stripe, loadStripe } from '@stripe/stripe-js';
import config from '../utils/getConfig';

let stripePromise: Promise<Stripe | null>;
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/track.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import ReactGA from 'react-ga4';
import type { Plan, TrackingEvent } from 'common';
import * as Sentry from '@sentry/browser';
import config from './utils/getConfig';
import type { Plan, TrackingEvent } from 'common';
import { isProduction } from 'is-production';
import { noop } from 'lodash';
import ReactGA from 'react-ga4';
import type { InitOptions } from 'react-ga4/types/ga4';
import config from './utils/getConfig';

let sentryErrorCount = 0;

Expand Down
4 changes: 2 additions & 2 deletions frontend/src/translations/i18n.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import i18n, { type CallbackError } from 'i18next';
import { initReactI18next } from 'react-i18next';
import LanguageDetector from 'i18next-browser-languagedetector';
import resourcesToBackend from 'i18next-resources-to-backend';
import config from 'utils/getConfig';
import { isProduction } from 'is-production';
import { initReactI18next } from 'react-i18next';
import config from 'utils/getConfig';

i18n
.use(
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/translations/languages.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Locale } from 'date-fns';
import type { StripeLocales } from 'common';
import type { Locale } from 'date-fns';
const arDZ = () => import('date-fns/locale/ar-DZ');
const zhCN = () => import('date-fns/locale/zh-CN');
const zhTW = () => import('date-fns/locale/zh-TW');
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/translations/useLanguage.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useCallback, useMemo } from 'react';
import languages, { type Language } from './languages';
import { useTranslation } from 'react-i18next';
import { updateLanguage } from 'api';
import { trackEvent } from 'track';
import type { TrackingEvent } from 'common';
import useUser from 'state/user/useUser';
import { useCallback, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { useSetUser } from 'state/user/useSetUser';
import useUser from 'state/user/useUser';
import { trackEvent } from 'track';
import languages, { type Language } from './languages';

type UseLanguageResult = [
language: Language,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/account/usePortalUrl.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getPortalUrl } from './api';
import { useEffect, useState } from 'react';
import useUser from '../../state/user/useUser';
import { getPortalUrl } from './api';

export default function usePortalUrl(): string | null {
const [url, setUrl] = useState<string | null>(null);
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/admin/api.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { fetchGet, fetchPatch, fetchPost } from '../../api/fetch';
import type {
AdminChangePasswordPayload,
AdminStats,
FullUser,
MergeUsersPayload,
} from 'common';
import { fetchGet, fetchPatch, fetchPost } from '../../api/fetch';

export async function changePassword(userId: string, password: string) {
return await fetchPatch<AdminChangePasswordPayload>('/api/admin/user', {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/game/__tests__/is-search-match.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { searchLogic } from '../is-search-match';
import { describe, expect, it } from 'vitest';
import { searchLogic } from '../is-search-match';

describe('Search Match logic', () => {
it('Should be a match if there is no search (as everything matches)', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { Participant } from 'common';
import { describe, expect, it } from 'vitest';
import {
getAddedParticipants,
getRemovedParticipants,
joinNames,
} from '../participants-notifiers';
import { describe, expect, it } from 'vitest';

function p(id: string, online = true): Participant {
return {
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/views/game/board/__tests__/moving-logic.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { getMovingEntities, calculateRank } from '../moving-logic';
import type { ColumnContent } from '../../types';
import type { Post, User, PostGroup } from 'common';
import { getMiddle, getNext, getPrevious } from '../../lexorank';
import type { Post, PostGroup, User } from 'common';
import { describe, expect, it } from 'vitest';
import { getMiddle, getNext, getPrevious } from '../../lexorank';
import type { ColumnContent } from '../../types';
import { calculateRank, getMovingEntities } from '../moving-logic';

function p(
id: string,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import {
postPermissionLogic,
sessionPermissionLogic,
} from '../permissions-logic';
import {
type BackendCapabilities,
type Post,
type Session,
type User,
type SessionOptions,
type User,
type VoteExtract,
type VoteType,
defaultOptions,
type VoteExtract,
type BackendCapabilities,
} from 'common';
import { v4 } from 'uuid';
import { describe, expect, it } from 'vitest';
import {
postPermissionLogic,
sessionPermissionLogic,
} from '../permissions-logic';

const userBase: User = {
photo: null,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/game/board/header/useRemainingVotes.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useMemo } from 'react';
import { numberOfVotes } from '../permissions-logic';
import useUser from '../../../../state/user/useUser';
import useSession from '../../useSession';
import { numberOfVotes } from '../permissions-logic';

interface RemainingVotes {
up: number | null;
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/views/game/board/usePostUserPermissions.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { Post } from 'common';
import {
postPermissionLogic,
type PostUserPermissions,
} from './permissions-logic';
import useBackendCapabilities from 'global/useBackendCapabilities';
import useUser from '../../../state/user/useUser';
import useSession from '../useSession';
import { useShouldLockSession } from '../useTimer';
import useBackendCapabilities from 'global/useBackendCapabilities';
import {
type PostUserPermissions,
postPermissionLogic,
} from './permissions-logic';

export function usePostUserPermissions(post: Post): PostUserPermissions {
const { session } = useSession();
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/views/game/board/useSessionUserPermissions.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import useUser from '../../../state/user/useUser';
import useCanDecrypt from '../../../crypto/useCanDecrypt';
import useIsDisabled from '../../../hooks/useIsDisabled';
import useUser from '../../../state/user/useUser';
import useSession from '../useSession';
import { useShouldLockSession } from '../useTimer';
import {
sessionPermissionLogic,
type SessionUserPermissions,
sessionPermissionLogic,
} from './permissions-logic';

export default function useSessionUserPermissions(): SessionUserPermissions {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/views/game/is-search-match.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { Post } from 'common';
import { postPermissionLogic } from './board/permissions-logic';
import { useCallback } from 'react';
import useBackendCapabilities from 'global/useBackendCapabilities';
import { useCallback } from 'react';
import useUser from 'state/user/useUser';
import { postPermissionLogic } from './board/permissions-logic';
import useSession from './useSession';

type SearchPredicate = (post: Post) => boolean;
Expand Down
12 changes: 6 additions & 6 deletions frontend/src/views/game/summary/useMarkdown.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { useMemo } from 'react';
import { format } from 'date-fns';
import flatten from 'lodash/flatten';
import sortedUniq from 'lodash/sortedUniq';
import sortBy from 'lodash/sortBy';
import { format } from 'date-fns';
import useColumns from '../useColumns';
import sortedUniq from 'lodash/sortedUniq';
import { useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { useSummary } from './useSummary';
import type { ColumnStatsItem, ActionItem } from './types';
import useColumns from '../useColumns';
import useSession from '../useSession';
import type { ActionItem, ColumnStatsItem } from './types';
import { useSummary } from './useSummary';

export default function useMarkdown() {
const { session } = useSession();
Expand Down
Loading

0 comments on commit a83a632

Please sign in to comment.