diff --git a/sources/client/src/api/search-entities-options.ts b/sources/client/src/api/search-entities-options.ts index 4a4d8cf..8f32937 100644 --- a/sources/client/src/api/search-entities-options.ts +++ b/sources/client/src/api/search-entities-options.ts @@ -16,13 +16,12 @@ export async function searchEntitiesOptions< E >( postTypes: Kensaku.Kind< string >, queryArguments?: Kensaku.QueryArguments ): Promise< Set< Kensaku.ControlOption< E > > > { - const postsEntities = - await searchEntities< Kensaku.SearchEntityFields >( - type, - postTypes, - phrase, - queryArguments - ); + const postsEntities = await searchEntities< Kensaku.SearchEntityFields >( + type, + postTypes, + phrase, + queryArguments + ); const { fields = [] } = queryArguments ?? {}; const [ label = 'title', value = 'id', ...extraFields ] = fields; diff --git a/sources/client/src/components/composite-entities-by-kind.tsx b/sources/client/src/components/composite-entities-by-kind.tsx index 7b121c4..7b2a1f5 100644 --- a/sources/client/src/components/composite-entities-by-kind.tsx +++ b/sources/client/src/components/composite-entities-by-kind.tsx @@ -75,10 +75,7 @@ export function CompositeEntitiesByKind< E, K >( } ); } ) .catch( ( error ) => { - doAction( - 'kensaku.on-change-entities.error', - error - ); + doAction( 'kensaku.on-change-entities.error', error ); } ); }; diff --git a/sources/client/src/components/preset-entities-by-kind.tsx b/sources/client/src/components/preset-entities-by-kind.tsx index b333c16..5a35183 100644 --- a/sources/client/src/components/preset-entities-by-kind.tsx +++ b/sources/client/src/components/preset-entities-by-kind.tsx @@ -30,9 +30,7 @@ type EntitiesFinder = ( type EntitiesComponent = React.ComponentType< Kensaku.BaseControl< EntitiesValue > >; -type KindComponent = React.ComponentType< - Kensaku.BaseControl< KindValue > ->; +type KindComponent = React.ComponentType< Kensaku.BaseControl< KindValue > >; type PublicComponentProps = { entitiesFinder: EntitiesFinder; diff --git a/sources/client/src/components/search-control.tsx b/sources/client/src/components/search-control.tsx index ceb9ce4..a00330e 100644 --- a/sources/client/src/components/search-control.tsx +++ b/sources/client/src/components/search-control.tsx @@ -14,9 +14,7 @@ import { __ } from '@wordpress/i18n'; */ import { useId } from '../hooks/use-id'; -export function SearchControl( - props: Kensaku.SearchControl -): JSX.Element { +export function SearchControl( props: Kensaku.SearchControl ): JSX.Element { const id = useId( props.id ); const label = props.label || __( 'Search', 'kensaku' ); const [ searchValue, setSearchValue ] = React.useState( '' ); diff --git a/sources/client/src/hooks/use-entities-options-storage.ts b/sources/client/src/hooks/use-entities-options-storage.ts index b1ef276..265a740 100644 --- a/sources/client/src/hooks/use-entities-options-storage.ts +++ b/sources/client/src/hooks/use-entities-options-storage.ts @@ -27,16 +27,10 @@ type _Reducer< E, K > = Reducer< * @param searchEntities The function that will search the entities */ export function useEntitiesOptionsStorage< E, K >( - initialState: Pick< - Kensaku.EntitiesState< E, K >, - 'entities' | 'kind' - >, + initialState: Pick< Kensaku.EntitiesState< E, K >, 'entities' | 'kind' >, searchEntities: Kensaku.SearchEntitiesFunction< E, K > ): Readonly< - [ - Kensaku.EntitiesState< E, K >, - Dispatch< Kensaku.StoreAction< E, K > >, - ] + [ Kensaku.EntitiesState< E, K >, Dispatch< Kensaku.StoreAction< E, K > > ] > { const [ state, dispatch ] = useReducer< _Reducer< E, K > >( reducer, @@ -69,10 +63,7 @@ export function useEntitiesOptionsStorage< E, K >( } ); } ) .catch( ( error ) => { - doAction( - 'kensaku.on-storage-initialization.error', - error - ); + doAction( 'kensaku.on-storage-initialization.error', error ); } ); // eslint-disable-next-line react-hooks/exhaustive-deps }, [] ); diff --git a/sources/client/src/hooks/use-query-viewable-post-types.ts b/sources/client/src/hooks/use-query-viewable-post-types.ts index a5d41ec..a450377 100644 --- a/sources/client/src/hooks/use-query-viewable-post-types.ts +++ b/sources/client/src/hooks/use-query-viewable-post-types.ts @@ -16,9 +16,11 @@ import { useEntityRecords } from './use-entity-records'; * @public */ export function useQueryViewablePostTypes(): Kensaku.EntitiesRecords< Kensaku.ViewablePostType > { - const entitiesRecords = useEntityRecords< - Kensaku.PostType< 'edit' > - >( 'root', 'postType', { per_page: -1 } ); + const entitiesRecords = useEntityRecords< Kensaku.PostType< 'edit' > >( + 'root', + 'postType', + { per_page: -1 } + ); const viewablePostTypes = entitiesRecords .records() diff --git a/sources/client/src/hooks/use-query-viewable-taxonomies.ts b/sources/client/src/hooks/use-query-viewable-taxonomies.ts index dc15ebf..b43ddc5 100644 --- a/sources/client/src/hooks/use-query-viewable-taxonomies.ts +++ b/sources/client/src/hooks/use-query-viewable-taxonomies.ts @@ -16,9 +16,11 @@ import { useEntityRecords } from './use-entity-records'; * @public */ export function useQueryViewableTaxonomies(): Kensaku.EntitiesRecords< Kensaku.ViewableTaxonomy > { - const entitiesRecords = useEntityRecords< - Kensaku.Taxonomy< 'edit' > - >( 'root', 'taxonomy', { per_page: -1 } ); + const entitiesRecords = useEntityRecords< Kensaku.Taxonomy< 'edit' > >( + 'root', + 'taxonomy', + { per_page: -1 } + ); const viewableTaxonomies = entitiesRecords .records() diff --git a/sources/client/src/hooks/use-search.ts b/sources/client/src/hooks/use-search.ts index 09a950c..ee19c4b 100644 --- a/sources/client/src/hooks/use-search.ts +++ b/sources/client/src/hooks/use-search.ts @@ -15,9 +15,7 @@ import { doAction } from '@wordpress/hooks'; */ import { Set } from '../models/set'; -type SearchPhrase = Parameters< - Kensaku.SearchControl[ 'onChange' ] ->[ 0 ]; +type SearchPhrase = Parameters< Kensaku.SearchControl[ 'onChange' ] >[ 0 ]; type SearchFunc = ( phrase: SearchPhrase ) => void; /** @@ -50,9 +48,7 @@ export function useSearch< E, K >( ) .catch( ( error ) => { doAction( 'kensaku.on-search.error', error ); - const emptySet = new Set< - Kensaku.ControlOption< E > - >(); + const emptySet = new Set< Kensaku.ControlOption< E > >(); dispatch( { type: 'UPDATE_CURRENT_ENTITIES_OPTIONS', currentEntitiesOptions: emptySet, diff --git a/sources/client/src/logging/index.ts b/sources/client/src/logging/index.ts index c7dee24..0004f82 100644 --- a/sources/client/src/logging/index.ts +++ b/sources/client/src/logging/index.ts @@ -39,14 +39,10 @@ addAction( } ); -addAction( - 'kensaku.on-search.error', - 'kensaku/on-search.error', - ( error ) => { - console.error( - `Composite Entities by Kind - on Search Entities: ${ - error.message ?? error - }` - ); - } -); +addAction( 'kensaku.on-search.error', 'kensaku/on-search.error', ( error ) => { + console.error( + `Composite Entities by Kind - on Search Entities: ${ + error.message ?? error + }` + ); +} ); diff --git a/sources/client/src/storage/entities/reducer.ts b/sources/client/src/storage/entities/reducer.ts index 9ed3f12..b887bb7 100644 --- a/sources/client/src/storage/entities/reducer.ts +++ b/sources/client/src/storage/entities/reducer.ts @@ -41,8 +41,7 @@ export function reducer< E, K >( ...state, selectedEntitiesOptions: action.selectedEntitiesOptions, entities: action.selectedEntitiesOptions.map( - ( option: Kensaku.ControlOption< E > ) => - option.value + ( option: Kensaku.ControlOption< E > ) => option.value ), }; diff --git a/sources/client/src/value-objects/control-option.ts b/sources/client/src/value-objects/control-option.ts index 153bc9f..2215697 100644 --- a/sources/client/src/value-objects/control-option.ts +++ b/sources/client/src/value-objects/control-option.ts @@ -9,9 +9,7 @@ import Kensaku from '@types'; import { assert } from '../utils/assert'; import { ImmutableRecord } from '../models/immutable-record'; -export class ControlOption< V > - implements Kensaku.EnrichedControlOption< V > -{ +export class ControlOption< V > implements Kensaku.EnrichedControlOption< V > { public readonly label: string; public readonly value: V; public readonly extra: Kensaku.Record< unknown >; diff --git a/tests/client/integration/components/composite-entities-by-kind.test.tsx b/tests/client/integration/components/composite-entities-by-kind.test.tsx index a52eb92..7864b02 100644 --- a/tests/client/integration/components/composite-entities-by-kind.test.tsx +++ b/tests/client/integration/components/composite-entities-by-kind.test.tsx @@ -37,9 +37,7 @@ describe( 'CompositeEntitiesByKind', () => { const rendered = render( - Promise.resolve( - new Set< Kensaku.ControlOption< any > >() - ) + Promise.resolve( new Set< Kensaku.ControlOption< any > >() ) } entities={ { value: new Set(), @@ -96,9 +94,7 @@ describe( 'CompositeEntitiesByKind', () => { } } kind={ { value: new Set( [ 'post' ] ), - options: new Set< - Kensaku.ControlOption< any > - >(), + options: new Set< Kensaku.ControlOption< any > >(), onChange: () => {}, } } > @@ -178,9 +174,7 @@ describe( 'CompositeEntitiesByKind', () => { } ); it( 'Pass to the children the updated entities options when the kind change', async () => { - let expectedEntities = new Set< - Kensaku.ControlOption< string > - >(); + let expectedEntities = new Set< Kensaku.ControlOption< string > >(); const rendered = await act( () => render( @@ -325,9 +319,7 @@ describe( 'CompositeEntitiesByKind', () => { { label: 'Post 2', value: 'post-2' }, ] ) ) - ) as jest.Mock< - Kensaku.SearchEntitiesFunction< string, string > - >; + ) as jest.Mock< Kensaku.SearchEntitiesFunction< string, string > >; const rendered = await act( () => render( @@ -341,9 +333,7 @@ describe( 'CompositeEntitiesByKind', () => { } } kind={ { value: new Set( [ 'post' ] ), - options: new Set< - Kensaku.ControlOption< any > - >(), + options: new Set< Kensaku.ControlOption< any > >(), onChange: () => {}, } } > @@ -373,10 +363,7 @@ describe( 'CompositeEntitiesByKind', () => { const selectedEntities = new Set( [ '1', '2' ] ); const searchEntities = jest.fn() as jest.Mock< - Kensaku.CompositeEntitiesKinds< - string, - string - >[ 'searchEntities' ] + Kensaku.CompositeEntitiesKinds< string, string >[ 'searchEntities' ] >; await act( () => @@ -389,9 +376,7 @@ describe( 'CompositeEntitiesByKind', () => { } } kind={ { value: new Set( [ 'post' ] ), - options: new Set< - Kensaku.ControlOption< any > - >(), + options: new Set< Kensaku.ControlOption< any > >(), onChange: () => {}, } } > @@ -424,9 +409,7 @@ describe( 'CompositeEntitiesByKind', () => { } } kind={ { value: new Set( [ 'post' ] ), - options: new Set< - Kensaku.ControlOption< any > - >(), + options: new Set< Kensaku.ControlOption< any > >(), onChange: () => {}, } } > @@ -498,9 +481,7 @@ describe( 'CompositeEntitiesByKind', () => { const rendered = render( - Promise.resolve( - new Set< Kensaku.ControlOption< any > >() - ) + Promise.resolve( new Set< Kensaku.ControlOption< any > >() ) } entities={ { value: new Set(), diff --git a/tests/client/unit/components/singular-select-control.test.tsx b/tests/client/unit/components/singular-select-control.test.tsx index 6f7be3d..e750d36 100644 --- a/tests/client/unit/components/singular-select-control.test.tsx +++ b/tests/client/unit/components/singular-select-control.test.tsx @@ -24,8 +24,7 @@ describe( 'Post Types Select', () => { * in the React Select component, so we mock it. */ it( 'call the given onChange handler', ( done ) => { - let expectedValue: Kensaku.SingularControl< string >[ 'value' ] = - ''; + let expectedValue: Kensaku.SingularControl< string >[ 'value' ] = ''; const option: Kensaku.ControlOption< string > = { label: faker.word.words( 2 ), value: faker.word.noun(), diff --git a/tests/client/unit/hooks/use-entities-options-storage.test.tsx b/tests/client/unit/hooks/use-entities-options-storage.test.tsx index 83adc06..f652704 100644 --- a/tests/client/unit/hooks/use-entities-options-storage.test.tsx +++ b/tests/client/unit/hooks/use-entities-options-storage.test.tsx @@ -36,9 +36,7 @@ describe( 'Use Posts Options Storage', () => { }, ] ) ) - ) as jest.Mock< - Kensaku.SearchEntitiesFunction< number, string > - >; + ) as jest.Mock< Kensaku.SearchEntitiesFunction< number, string > >; const Component = () => { useEntitiesOptionsStorage< number, string >( @@ -103,9 +101,7 @@ describe( 'Use Posts Options Storage', () => { return options?.include ? Promise.resolve( selectedEntitiesOptions ) : Promise.resolve( currentEntitiesOptions ); - } ) as jest.Mock< - Kensaku.SearchEntitiesFunction< number, string > - >; + } ) as jest.Mock< Kensaku.SearchEntitiesFunction< number, string > >; const dispatch = jest.fn(); jest.spyOn( React, 'useReducer' ).mockImplementation( ( _, state ) => [ @@ -189,9 +185,7 @@ describe( 'Use Posts Options Storage', () => { }, ] ) ) - ) as jest.Mock< - Kensaku.SearchEntitiesFunction< number, string > - >; + ) as jest.Mock< Kensaku.SearchEntitiesFunction< number, string > >; const Component = () => { useEntitiesOptionsStorage< number, string >( diff --git a/tests/client/unit/utils/ordered-selected-options-at-the-top.test.ts b/tests/client/unit/utils/ordered-selected-options-at-the-top.test.ts index 78f739a..56e59b8 100644 --- a/tests/client/unit/utils/ordered-selected-options-at-the-top.test.ts +++ b/tests/client/unit/utils/ordered-selected-options-at-the-top.test.ts @@ -17,9 +17,7 @@ describe( 'Ordered Selected Options at the Top', () => { /* * Given options are always re-ordered to includes the given collection values at the top */ - function generateOptions(): Array< - Kensaku.ControlOption< string > - > { + function generateOptions(): Array< Kensaku.ControlOption< string > > { const options: Array< Kensaku.ControlOption< string > > = []; for ( let i = 1; i <= 10; i++ ) {