fix(frontend): reformat source files

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2022-11-30 22:10:23 +01:00 committed by David Mehren
parent e260b77760
commit e390c0dd15
669 changed files with 1741 additions and 2354 deletions

View file

@ -3,15 +3,14 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import type { OptionalUserState } from './user/types'
import type { Config } from '../api/config/types'
import type { EditorConfig } from './editor/types'
import type { DarkModeConfig } from './dark-mode/types'
import type { NoteDetails } from './note-details/types/note-details'
import type { RendererStatus } from './renderer-status/types'
import type { HistoryEntryWithOrigin } from '../api/history/types'
import type { DarkModeConfig } from './dark-mode/types'
import type { EditorConfig } from './editor/types'
import type { NoteDetails } from './note-details/types/note-details'
import type { RealtimeState } from './realtime/types'
import type { RendererStatus } from './renderer-status/types'
import type { OptionalUserState } from './user/types'
export interface ApplicationState {
user: OptionalUserState

View file

@ -3,7 +3,6 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { store } from '..'
import type { Config } from '../../api/config/types'
import type { SetConfigAction } from './types'

View file

@ -3,11 +3,10 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import type { Reducer } from 'redux'
import type { Config } from '../../api/config/types'
import type { ConfigActions } from './types'
import { ConfigActionType } from './types'
import type { Reducer } from 'redux'
export const initialState: Config = {
allowAnonymous: true,

View file

@ -3,9 +3,8 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import type { Action } from 'redux'
import type { Config } from '../../api/config/types'
import type { Action } from 'redux'
export enum ConfigActionType {
SET_CONFIG = 'config/set'

View file

@ -3,7 +3,6 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { store } from '..'
import type { DarkModeConfigAction, DarkModePreference } from './types'
import { DarkModeConfigActionType } from './types'

View file

@ -3,10 +3,9 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import type { Reducer } from 'redux'
import type { DarkModeConfig, DarkModeConfigAction } from './types'
import { DarkModeConfigActionType, DarkModePreference } from './types'
import type { Reducer } from 'redux'
const initialState: DarkModeConfig = {
darkModePreference: DarkModePreference.AUTO

View file

@ -3,7 +3,6 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import type { Action } from 'redux'
export enum DarkModeConfigActionType {

View file

@ -3,8 +3,8 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { store } from '..'
import { Logger } from '../../utils/logger'
import type {
EditorConfig,
SetEditorLigaturesAction,
@ -12,7 +12,6 @@ import type {
SetEditorSyncScrollAction
} from './types'
import { EditorConfigActionType } from './types'
import { Logger } from '../../utils/logger'
const log = new Logger('Redux > Editor')

View file

@ -3,11 +3,10 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import type { Reducer } from 'redux'
import { loadFromLocalStorage, saveToLocalStorage } from './methods'
import type { EditorConfig, EditorConfigActions } from './types'
import { EditorConfigActionType } from './types'
import type { Reducer } from 'redux'
const initialState: EditorConfig = {
ligatures: true,

View file

@ -3,7 +3,6 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import type { Action } from 'redux'
export enum EditorConfigActionType {

View file

@ -3,12 +3,6 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { getGlobalState, store } from '../index'
import type { HistoryExportJson, RemoveEntryAction, SetEntriesAction, UpdateEntryAction, V1HistoryEntry } from './types'
import { HistoryActionType } from './types'
import { download } from '../../components/common/download/download'
import { DateTime } from 'luxon'
import {
deleteRemoteHistory,
deleteRemoteHistoryEntry,
@ -17,9 +11,14 @@ import {
updateRemoteHistoryEntryPinStatus
} from '../../api/history'
import { addRemoteOriginToHistoryEntry, historyEntryToHistoryEntryPutDto } from '../../api/history/dto-methods'
import { Logger } from '../../utils/logger'
import type { HistoryEntry, HistoryEntryWithOrigin } from '../../api/history/types'
import { HistoryEntryOrigin } from '../../api/history/types'
import { download } from '../../components/common/download/download'
import { Logger } from '../../utils/logger'
import { getGlobalState, store } from '../index'
import type { HistoryExportJson, RemoveEntryAction, SetEntriesAction, UpdateEntryAction, V1HistoryEntry } from './types'
import { HistoryActionType } from './types'
import { DateTime } from 'luxon'
const log = new Logger('Redux > History')

View file

@ -3,11 +3,10 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import type { Reducer } from 'redux'
import type { HistoryEntryWithOrigin } from '../../api/history/types'
import type { HistoryActions } from './types'
import { HistoryActionType } from './types'
import type { HistoryEntryWithOrigin } from '../../api/history/types'
import type { Reducer } from 'redux'
// Q: Why is the reducer initialized with an empty array instead of the actual history entries like in the config reducer?
// A: The history reducer will be created without entries because of async entry retrieval.

View file

@ -3,9 +3,8 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import type { Action } from 'redux'
import type { HistoryEntryWithOrigin } from '../../api/history/types'
import type { Action } from 'redux'
export interface V1HistoryEntry {
id: string

View file

@ -3,11 +3,10 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { allReducers } from './reducers'
import type { ApplicationState } from './application-state'
import { configureStore } from '@reduxjs/toolkit'
import { isDevMode } from '../utils/test-modes'
import type { ApplicationState } from './application-state'
import { allReducers } from './reducers'
import { configureStore } from '@reduxjs/toolkit'
export const store = configureStore({
reducer: allReducers,

View file

@ -3,14 +3,13 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import type { NoteDetails } from './types/note-details'
import { extractFrontmatter } from './frontmatter-extractor/extractor'
import { initialState } from './initial-state'
import type { PresentFrontmatterExtractionResult } from './frontmatter-extractor/types'
import { createNoteFrontmatterFromYaml } from './raw-note-frontmatter-parser/parser'
import { generateNoteTitle } from './generate-note-title'
import { calculateLineStartIndexes } from './calculate-line-start-indexes'
import { extractFrontmatter } from './frontmatter-extractor/extractor'
import type { PresentFrontmatterExtractionResult } from './frontmatter-extractor/types'
import { generateNoteTitle } from './generate-note-title'
import { initialState } from './initial-state'
import { createNoteFrontmatterFromYaml } from './raw-note-frontmatter-parser/parser'
import type { NoteDetails } from './types/note-details'
/**
* Copies a {@link NoteDetails} but with another markdown content.

View file

@ -3,7 +3,6 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { calculateLineStartIndexes } from './calculate-line-start-indexes'
describe('calculateLineStartIndexes', () => {

View file

@ -3,7 +3,6 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { extractFrontmatter } from './extractor'
import type { PresentFrontmatterExtractionResult } from './types'

View file

@ -3,7 +3,6 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { generateNoteTitle } from './generate-note-title'
import { initialState } from './initial-state'

View file

@ -3,7 +3,6 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import type { NoteFrontmatter } from './types/note-details'
/**

View file

@ -3,7 +3,6 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import type { NoteDetails } from './types/note-details'
import { NoteTextDirection, NoteType } from './types/note-details'
import type { SlideOptions } from './types/slide-show-options'

View file

@ -3,9 +3,10 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { store } from '..'
import { getNoteMetadata } from '../../api/notes'
import type { Note, NotePermissions } from '../../api/notes/types'
import type { CursorSelection } from '../../components/editor-page/editor-pane/tool-bar/formatters/types/cursor-selection'
import type {
SetNoteDetailsFromServerAction,
SetNoteDocumentContentAction,
@ -15,8 +16,6 @@ import type {
UpdateNoteTitleByFirstHeadingAction
} from './types'
import { NoteDetailsActionType } from './types'
import type { CursorSelection } from '../../components/editor-page/editor-pane/tool-bar/formatters/types/cursor-selection'
import { getNoteMetadata } from '../../api/notes'
/**
* Sets the content of the current note, extracts and parses the frontmatter and extracts the markdown content part.

View file

@ -3,7 +3,6 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { createNoteFrontmatterFromYaml } from './parser'
describe('yaml frontmatter', () => {

View file

@ -3,14 +3,13 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { load } from 'js-yaml'
import type { SlideOptions } from '../types/slide-show-options'
import { initialSlideOptions, initialState } from '../initial-state'
import { ISO6391 } from '../types/iso6391'
import type { Iso6391Language, NoteFrontmatter, OpenGraph } from '../types/note-details'
import { NoteTextDirection, NoteType } from '../types/note-details'
import { ISO6391 } from '../types/iso6391'
import type { SlideOptions } from '../types/slide-show-options'
import type { RawNoteFrontmatter } from './types'
import { initialSlideOptions, initialState } from '../initial-state'
import { load } from 'js-yaml'
/**
* Creates a new frontmatter metadata instance based on a raw yaml string.

View file

@ -3,18 +3,17 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import type { Reducer } from 'redux'
import { buildStateFromUpdatedMarkdownContent } from './build-state-from-updated-markdown-content'
import { initialState } from './initial-state'
import { buildStateFromFirstHeadingUpdate } from './reducers/build-state-from-first-heading-update'
import { buildStateFromMetadataUpdate } from './reducers/build-state-from-metadata-update'
import { buildStateFromServerPermissions } from './reducers/build-state-from-server-permissions'
import { buildStateFromServerDto } from './reducers/build-state-from-set-note-data-from-server'
import { buildStateFromUpdateCursorPosition } from './reducers/build-state-from-update-cursor-position'
import type { NoteDetailsActions } from './types'
import { NoteDetailsActionType } from './types'
import { initialState } from './initial-state'
import type { NoteDetails } from './types/note-details'
import { buildStateFromUpdatedMarkdownContent } from './build-state-from-updated-markdown-content'
import { buildStateFromUpdateCursorPosition } from './reducers/build-state-from-update-cursor-position'
import { buildStateFromFirstHeadingUpdate } from './reducers/build-state-from-first-heading-update'
import { buildStateFromServerDto } from './reducers/build-state-from-set-note-data-from-server'
import { buildStateFromServerPermissions } from './reducers/build-state-from-server-permissions'
import { buildStateFromMetadataUpdate } from './reducers/build-state-from-metadata-update'
import type { Reducer } from 'redux'
export const NoteDetailsReducer: Reducer<NoteDetails, NoteDetailsActions> = (
state: NoteDetails = initialState,

View file

@ -3,8 +3,8 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { buildStateFromFirstHeadingUpdate } from './build-state-from-first-heading-update'
import { initialState } from '../initial-state'
import { buildStateFromFirstHeadingUpdate } from './build-state-from-first-heading-update'
// noinspection JSUnusedGlobalSymbols
jest.mock('../generate-note-title', () => ({

View file

@ -3,9 +3,8 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import type { NoteDetails } from '../types/note-details'
import { generateNoteTitle } from '../generate-note-title'
import type { NoteDetails } from '../types/note-details'
/**
* Builds a {@link NoteDetails} redux state with an updated note title from frontmatter data and the first heading.

View file

@ -3,8 +3,8 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { initialState } from '../initial-state'
import type { NoteMetadata } from '../../../api/notes/types'
import { initialState } from '../initial-state'
import type { NoteDetails } from '../types/note-details'
import { buildStateFromMetadataUpdate } from './build-state-from-metadata-update'

View file

@ -3,10 +3,10 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { initialState } from '../initial-state'
import type { NotePermissions } from '../../../api/notes/types'
import { buildStateFromServerPermissions } from './build-state-from-server-permissions'
import { initialState } from '../initial-state'
import type { NoteDetails } from '../types/note-details'
import { buildStateFromServerPermissions } from './build-state-from-server-permissions'
describe('build state from server permissions', () => {
it('creates a new state with the given permissions', () => {

View file

@ -3,8 +3,8 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import type { NoteDetails } from '../types/note-details'
import type { NotePermissions } from '../../../api/notes/types'
import type { NoteDetails } from '../types/note-details'
/**
* Builds the updated state from a given previous state and updated NotePermissions data.

View file

@ -3,14 +3,14 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { buildStateFromServerDto } from './build-state-from-set-note-data-from-server'
import type { Note } from '../../../api/notes/types'
import * as buildStateFromUpdatedMarkdownContentModule from '../build-state-from-updated-markdown-content'
import { Mock } from 'ts-mockery'
import { initialSlideOptions } from '../initial-state'
import type { NoteDetails } from '../types/note-details'
import { NoteTextDirection, NoteType } from '../types/note-details'
import { buildStateFromServerDto } from './build-state-from-set-note-data-from-server'
import { DateTime } from 'luxon'
import { initialSlideOptions } from '../initial-state'
import type { Note } from '../../../api/notes/types'
import { Mock } from 'ts-mockery'
jest.mock('../build-state-from-updated-markdown-content')

View file

@ -3,12 +3,11 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import type { NoteDetails } from '../types/note-details'
import { buildStateFromUpdatedMarkdownContent } from '../build-state-from-updated-markdown-content'
import { initialState } from '../initial-state'
import { calculateLineStartIndexes } from '../calculate-line-start-indexes'
import type { Note } from '../../../api/notes/types'
import { buildStateFromUpdatedMarkdownContent } from '../build-state-from-updated-markdown-content'
import { calculateLineStartIndexes } from '../calculate-line-start-indexes'
import { initialState } from '../initial-state'
import type { NoteDetails } from '../types/note-details'
import { buildStateFromMetadataUpdate } from './build-state-from-metadata-update'
/**

View file

@ -3,12 +3,11 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { initialState } from '../initial-state'
import * as buildStateFromUpdatedMarkdownContentLinesModule from '../build-state-from-updated-markdown-content'
import { Mock } from 'ts-mockery'
import { initialState } from '../initial-state'
import type { NoteDetails } from '../types/note-details'
import { buildStateFromTaskListUpdate } from './build-state-from-task-list-update'
import { Mock } from 'ts-mockery'
jest.mock('../build-state-from-updated-markdown-content')

View file

@ -3,10 +3,9 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { buildStateFromUpdatedMarkdownContentLines } from '../build-state-from-updated-markdown-content'
import type { NoteDetails } from '../types/note-details'
import { Optional } from '@mrdrogdrog/optional'
import { buildStateFromUpdatedMarkdownContentLines } from '../build-state-from-updated-markdown-content'
const TASK_REGEX = /(\s*(?:[-*+]|\d+[.)]) )\[[ xX]?]( .*)/
/**

View file

@ -3,11 +3,10 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { initialState } from '../initial-state'
import { Mock } from 'ts-mockery'
import { buildStateFromUpdateCursorPosition } from './build-state-from-update-cursor-position'
import type { CursorSelection } from '../../../components/editor-page/editor-pane/tool-bar/formatters/types/cursor-selection'
import { initialState } from '../initial-state'
import { buildStateFromUpdateCursorPosition } from './build-state-from-update-cursor-position'
import { Mock } from 'ts-mockery'
describe('build state from update cursor position', () => {
it('creates a new state with the given cursor', () => {

View file

@ -3,9 +3,8 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import type { NoteDetails } from '../types/note-details'
import type { CursorSelection } from '../../../components/editor-page/editor-pane/tool-bar/formatters/types/cursor-selection'
import type { NoteDetails } from '../types/note-details'
export const buildStateFromUpdateCursorPosition = (state: NoteDetails, selection: CursorSelection): NoteDetails => {
const correctedSelection = isFromAfterTo(selection)

View file

@ -3,10 +3,9 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import type { Action } from 'redux'
import type { Note, NoteMetadata, NotePermissions } from '../../api/notes/types'
import type { CursorSelection } from '../../components/editor-page/editor-pane/tool-bar/formatters/types/cursor-selection'
import type { Action } from 'redux'
export enum NoteDetailsActionType {
SET_DOCUMENT_CONTENT = 'note-details/content/set',

View file

@ -3,11 +3,10 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import type { SlideOptions } from './slide-show-options'
import type { ISO6391 } from './iso6391'
import type { NoteMetadata } from '../../../api/notes/types'
import type { CursorSelection } from '../../../components/editor-page/editor-pane/tool-bar/formatters/types/cursor-selection'
import type { ISO6391 } from './iso6391'
import type { SlideOptions } from './slide-show-options'
type UnnecessaryNoteAttributes = 'updatedAt' | 'createdAt' | 'tags' | 'description'

View file

@ -3,7 +3,6 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import type { RevealOptions } from 'reveal.js'
type WantedRevealOptions = 'autoSlide' | 'autoSlideStoppable' | 'transition' | 'backgroundTransition' | 'slideNumber'

View file

@ -3,7 +3,6 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { store } from '..'
import type { AddOnlineUserAction, OnlineUser, RemoveOnlineUserAction } from './types'
import { RealtimeActionType } from './types'

View file

@ -3,12 +3,11 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { buildStateFromAddUser } from './reducers/build-state-from-add-user'
import { buildStateFromRemoveUser } from './reducers/build-state-from-remove-user'
import type { RealtimeActions, RealtimeState } from './types'
import { RealtimeActionType } from './types'
import type { Reducer } from 'redux'
import { buildStateFromRemoveUser } from './reducers/build-state-from-remove-user'
import { buildStateFromAddUser } from './reducers/build-state-from-add-user'
const initialState: RealtimeState = {
users: []

View file

@ -3,7 +3,6 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import type { OnlineUser, RealtimeState } from '../types'
/**

View file

@ -3,7 +3,6 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import type { RealtimeState } from '../types'
/**

View file

@ -3,7 +3,6 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import type { Action } from 'redux'
export enum RealtimeActionType {

View file

@ -3,18 +3,17 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import type { ApplicationState } from './application-state'
import { ConfigReducer } from './config/reducers'
import { DarkModeConfigReducer } from './dark-mode/reducers'
import { EditorConfigReducer } from './editor/reducers'
import { HistoryReducer } from './history/reducers'
import { NoteDetailsReducer } from './note-details/reducer'
import { RealtimeReducer } from './realtime/reducers'
import { RendererStatusReducer } from './renderer-status/reducers'
import { UserReducer } from './user/reducers'
import type { Reducer } from 'redux'
import { combineReducers } from 'redux'
import { UserReducer } from './user/reducers'
import { ConfigReducer } from './config/reducers'
import { HistoryReducer } from './history/reducers'
import { EditorConfigReducer } from './editor/reducers'
import { DarkModeConfigReducer } from './dark-mode/reducers'
import { NoteDetailsReducer } from './note-details/reducer'
import { RendererStatusReducer } from './renderer-status/reducers'
import type { ApplicationState } from './application-state'
import { RealtimeReducer } from './realtime/reducers'
export const allReducers: Reducer<ApplicationState> = combineReducers<ApplicationState>({
user: UserReducer,

View file

@ -3,7 +3,6 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { store } from '..'
import type { SetRendererStatusAction } from './types'
import { RendererStatusActionType } from './types'

View file

@ -3,7 +3,6 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import type { RendererStatus, RendererStatusActions } from './types'
import { RendererStatusActionType } from './types'
import type { Reducer } from 'redux'

View file

@ -3,7 +3,6 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import type { Action } from 'redux'
export enum RendererStatusActionType {

View file

@ -3,11 +3,10 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { store } from './index'
import type { PropsWithChildren } from 'react'
import React from 'react'
import { Provider } from 'react-redux'
import { store } from './index'
/**
* Sets the redux store for the children components.

View file

@ -3,11 +3,10 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { store } from '..'
import type { LoginUserInfo } from '../../api/me/types'
import type { ClearUserAction, SetUserAction } from './types'
import { UserActionType } from './types'
import type { LoginUserInfo } from '../../api/me/types'
/**
* Sets the given user state into the redux.

View file

@ -3,10 +3,9 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import type { Reducer } from 'redux'
import type { OptionalUserState, UserActions } from './types'
import { UserActionType } from './types'
import type { Reducer } from 'redux'
export const UserReducer: Reducer<OptionalUserState, UserActions> = (
state: OptionalUserState = null,

View file

@ -3,9 +3,8 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import type { Action } from 'redux'
import type { LoginUserInfo } from '../../api/me/types'
import type { Action } from 'redux'
export enum UserActionType {
SET_USER = 'user/set',