Skip to content

Commit 6b5de4d

Browse files
committed
Improvements
1 parent f1504dd commit 6b5de4d

File tree

19 files changed

+371
-268
lines changed

19 files changed

+371
-268
lines changed

.editorconfig

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
charset = utf-8
33
end_of_line = lf
44
indent_size = 4
5-
indent_style = tab
5+
indent_style = space
66
insert_final_newline = true
77
max_line_length = 120
88
tab_width = 4
@@ -16,7 +16,9 @@ ij_visual_guides = 100
1616
ij_wrap_on_typing = false
1717

1818
[*.css]
19-
ij_continuation_indent_size = 4
19+
indent_size = 2
20+
tab_width = 2
21+
ij_continuation_indent_size = 2
2022
ij_visual_guides = none
2123
ij_css_align_closing_brace_with_properties = false
2224
ij_css_blank_lines_around_nested_selector = 1
@@ -38,7 +40,9 @@ ij_css_use_double_quotes = true
3840
ij_css_value_alignment = do_not_align
3941

4042
[*.sass]
41-
ij_continuation_indent_size = 4
43+
indent_size = 2
44+
tab_width = 2
45+
ij_continuation_indent_size = 2
4246
ij_visual_guides = none
4347
ij_sass_align_closing_brace_with_properties = false
4448
ij_sass_blank_lines_around_nested_selector = 1
@@ -61,7 +65,9 @@ ij_sass_use_double_quotes = true
6165
ij_sass_value_alignment = 0
6266

6367
[*.scss]
64-
ij_continuation_indent_size = 4
68+
indent_size = 2
69+
tab_width = 2
70+
ij_continuation_indent_size = 2
6571
ij_visual_guides = none
6672
ij_scss_align_closing_brace_with_properties = false
6773
ij_scss_blank_lines_around_nested_selector = 1
@@ -115,7 +121,7 @@ ij_xml_space_inside_empty_tag = false
115121
ij_xml_text_wrap = normal
116122

117123
[{*.ats,*.cts,*.mts,*.ts,*.tsx}]
118-
ij_continuation_indent_size = 4
124+
ij_continuation_indent_size = 2
119125
ij_typescript_align_imports = false
120126
ij_typescript_align_multiline_array_initializer_expression = false
121127
ij_typescript_align_multiline_binary_operation = false
@@ -286,6 +292,8 @@ ij_typescript_while_on_new_line = false
286292
ij_typescript_wrap_comments = false
287293

288294
[{*.bash,*.sh,*.zsh}]
295+
indent_size = 2
296+
tab_width = 2
289297
ij_visual_guides = none
290298
ij_shell_binary_ops_start_line = false
291299
ij_shell_keep_column_alignment_padding = false
@@ -295,7 +303,7 @@ ij_shell_switch_cases_indented = false
295303
ij_shell_use_unix_line_separator = true
296304

297305
[{*.cjs,*.js}]
298-
ij_continuation_indent_size = 4
306+
ij_continuation_indent_size = 2
299307
ij_javascript_align_imports = false
300308
ij_javascript_align_multiline_array_initializer_expression = false
301309
ij_javascript_align_multiline_binary_operation = false
@@ -462,9 +470,6 @@ ij_javascript_while_on_new_line = false
462470
ij_javascript_wrap_comments = false
463471

464472
[{*.ctp,*.hphp,*.inc,*.module,*.php,*.php4,*.php5,*.phtml}]
465-
tab_width = 2
466-
indent_size = 2
467-
indent_style = space
468473
max_line_length = 100
469474
ij_continuation_indent_size = 4
470475
ij_visual_guides = 80
@@ -691,6 +696,7 @@ ij_php_while_brace_force = never
691696
ij_php_while_on_new_line = false
692697

693698
[{*.har,*.jsb2,*.jsb3,*.json,.babelrc,.eslintrc,.prettierrc,.stylelintrc,bowerrc,composer.lock,jest.config}]
699+
indent_size = 2
694700
ij_visual_guides = none
695701
ij_json_array_wrapping = split_into_lines
696702
ij_json_keep_blank_lines_in_code = 0
@@ -708,9 +714,9 @@ ij_json_spaces_within_brackets = false
708714
ij_json_wrap_long_lines = false
709715

710716
[{*.htm,*.html,*.sht,*.shtm,*.shtml}]
711-
tab_width = 2
712717
indent_size = 2
713-
ij_continuation_indent_size = 4
718+
tab_width = 2
719+
ij_continuation_indent_size = 2
714720
ij_html_add_new_line_before_tags = body,div,p,form,h1,h2,h3
715721
ij_html_align_attributes = true
716722
ij_html_align_text = false
@@ -757,7 +763,6 @@ ij_markdown_wrap_text_if_long = true
757763
ij_markdown_wrap_text_inside_blockquotes = true
758764

759765
[{*.yaml,*.yml}]
760-
tab_width = 2
761766
indent_size = 2
762767
ij_visual_guides = none
763768
ij_yaml_align_values_properties = do_not_align

@types/index.d.ts

Lines changed: 55 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import React from 'react';
2-
import type { Set } from '../sources/client/src/vo/set';
32

43
import { BaseEntityRecords, Context } from '@wordpress/core-data';
54

5+
import type { Set } from '../sources/client/src/vo/set';
6+
67
export default EntitiesSearch;
78

89
// TODO Try to convert it to a module.
@@ -19,7 +20,7 @@ declare namespace EntitiesSearch {
1920
fields: EntitiesSearch.SearchQueryFields;
2021
[p: string]: unknown;
2122
}>
22-
> { }
23+
> {}
2324

2425
interface SearchEntityFields
2526
extends Readonly<{
@@ -28,7 +29,7 @@ declare namespace EntitiesSearch {
2829
url: string;
2930
type: string;
3031
subtype: string;
31-
}> { }
32+
}> {}
3233

3334
type ControlOption<V extends any> = Readonly<{
3435
value: V;
@@ -37,35 +38,35 @@ declare namespace EntitiesSearch {
3738

3839
type SingularControl<V> = {
3940
[K in keyof BaseControl<V>]: K extends 'value'
40-
? V
41-
: K extends 'onChange'
42-
? (value: V) => void
43-
: BaseControl<V>[K];
41+
? V
42+
: K extends 'onChange'
43+
? (value: V) => void
44+
: BaseControl<V>[K];
4445
};
4546

4647
interface BaseControl<V>
4748
extends Readonly<{
4849
value: Set<V>;
4950
options: Set<ControlOption<V>>;
5051
onChange(values: BaseControl<V>['value']): void;
51-
}> { }
52+
}> {}
5253

5354
/*
5455
* Hooks
5556
*/
5657
type ViewablePostType = Readonly<{
5758
[K in keyof PostType<'edit'>]: K extends 'viewable'
58-
? true
59-
: PostType<'edit'>[K];
59+
? true
60+
: PostType<'edit'>[K];
6061
}>;
6162

6263
// TODO Need Type Test.
6364
type ViewableTaxonomy = Readonly<{
6465
[K in keyof Taxonomy<'edit'>]: K extends 'visibility'
65-
? BaseEntityRecords.TaxonomyVisibility & {
66-
publicly_queryable: true;
67-
}
68-
: Taxonomy<'edit'>[K];
66+
? BaseEntityRecords.TaxonomyVisibility & {
67+
publicly_queryable: true;
68+
}
69+
: Taxonomy<'edit'>[K];
6970
}>;
7071

7172
type EntitiesRecords<Entity> = Readonly<{
@@ -90,43 +91,51 @@ declare namespace EntitiesSearch {
9091
K,
9192
OptionSet = Set<EntitiesSearch.ControlOption<E>>
9293
> extends Readonly<{
93-
entities: BaseControl<E>['value'];
94-
kind: BaseControl<K>['value'];
95-
contextualEntitiesOptions: OptionSet;
96-
currentEntitiesOptions: OptionSet;
97-
selectedEntitiesOptions: OptionSet;
98-
}> { }
94+
entities: BaseControl<E>['value'];
95+
kind: BaseControl<K>['value'];
96+
contextualEntitiesOptions: OptionSet;
97+
currentEntitiesOptions: OptionSet;
98+
selectedEntitiesOptions: OptionSet;
99+
}> {}
99100

100101
type StoreAction<E, K> =
101102
| {
102-
type: 'UPDATE_ENTITIES';
103-
entities: EntitiesState<E, K>['entities'];
104-
}
103+
type: 'UPDATE_ENTITIES';
104+
entities: EntitiesState<E, K>['entities'];
105+
}
106+
| {
107+
type: 'UPDATE_KIND';
108+
kind: EntitiesState<E, K>['kind'];
109+
}
110+
| {
111+
type: 'UPDATE_CURRENT_ENTITIES_OPTIONS';
112+
currentEntitiesOptions: EntitiesState<
113+
E,
114+
K
115+
>['currentEntitiesOptions'];
116+
}
105117
| {
106-
type: 'UPDATE_KIND';
107-
kind: EntitiesState<E, K>['kind'];
108-
}
118+
type: 'UPDATE_CONTEXTUAL_ENTITIES_OPTIONS';
119+
contextualEntitiesOptions: EntitiesState<
120+
E,
121+
K
122+
>['contextualEntitiesOptions'];
123+
}
109124
| {
110-
type: 'UPDATE_CURRENT_ENTITIES_OPTIONS';
111-
currentEntitiesOptions: EntitiesState<
112-
E,
113-
K
114-
>['currentEntitiesOptions'];
115-
}
125+
type: 'UPDATE_SELECTED_ENTITIES_OPTIONS';
126+
selectedEntitiesOptions: EntitiesState<
127+
E,
128+
K
129+
>['selectedEntitiesOptions'];
130+
}
116131
| {
117-
type: 'UPDATE_CONTEXTUAL_ENTITIES_OPTIONS';
118-
contextualEntitiesOptions: EntitiesState<
119-
E,
120-
K
121-
>['contextualEntitiesOptions'];
122-
}
132+
type: 'CLEAN_ENTITIES_OPTIONS';
133+
}
123134
| {
124-
type: 'UPDATE_SELECTED_ENTITIES_OPTIONS';
125-
selectedEntitiesOptions: EntitiesState<
126-
E,
127-
K
128-
>['selectedEntitiesOptions'];
129-
};
135+
type: 'UPDATE_ENTITIES_OPTIONS_FOR_NEW_KIND';
136+
entitiesOptions: Set<EntitiesSearch.ControlOption<E>>;
137+
kind: EntitiesState<E, K>['kind'];
138+
};
130139

131140
/*
132141
* Components
@@ -135,7 +144,7 @@ declare namespace EntitiesSearch {
135144
extends Readonly<{
136145
id?: string;
137146
onChange(phrase: string | React.ChangeEvent<HTMLInputElement>);
138-
}> { }
147+
}> {}
139148

140149
interface CompositeEntitiesKinds<E, K>
141150
extends Readonly<{
@@ -155,5 +164,5 @@ declare namespace EntitiesSearch {
155164
phrase: Parameters<SearchControl<E, K>['search']>[0]
156165
) => ReturnType<SearchControl<E, K>['search']>
157166
): React.ReactNode;
158-
}> { }
167+
}> {}
159168
}

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"@wordpress/components": "~23.1.0",
3737
"@wordpress/compose": "^6.23.0",
3838
"@wordpress/core-data": "~6.12.0",
39+
"@wordpress/hooks": "^3.49.0",
3940
"@wordpress/i18n": "~4.24.0",
4041
"classnames": "^2.3.2",
4142
"react": "~18.2.0"
@@ -48,6 +49,7 @@
4849
"cs:fix": "wp-scripts format ./sources/client",
4950
"lint:js": "wp-scripts lint-js",
5051
"lint:js:fix": "wp-scripts lint-js --fix",
51-
"test": "jest"
52+
"test": "jest",
53+
"test:update-snapshots": "yarn test -u"
5254
}
5355
}

0 commit comments

Comments
 (0)