Skip to content

Commit 3d45888

Browse files
pedrottimarkcpojer
authored andcommitted
Define separate type for pretty-format plugin Options (#3802)
* Define separate type for pretty-format plugin Options * Rename separate type as PluginOptions
1 parent ea00d16 commit 3d45888

15 files changed

+99
-33
lines changed

packages/pretty-format/src/index.js

-4
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,12 @@ type Theme = {|
3636
type InitialOptions = {|
3737
callToJSON?: boolean,
3838
escapeRegex?: boolean,
39-
edgeSpacing?: string,
4039
highlight?: boolean,
4140
indent?: number,
4241
maxDepth?: number,
4342
min?: boolean,
4443
plugins?: Plugins,
4544
printFunctionName?: boolean,
46-
spacing?: string,
4745
theme?: Theme,
4846
|};
4947

@@ -794,15 +792,13 @@ function print(
794792

795793
const DEFAULTS: Options = {
796794
callToJSON: true,
797-
edgeSpacing: '\n',
798795
escapeRegex: false,
799796
highlight: false,
800797
indent: 2,
801798
maxDepth: Infinity,
802799
min: false,
803800
plugins: [],
804801
printFunctionName: true,
805-
spacing: '\n',
806802
theme: {
807803
comment: 'gray',
808804
content: 'reset',

packages/pretty-format/src/plugins/asymmetric_matcher.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88
* @flow
99
*/
1010

11-
import type {Colors, Indent, Options, Print, Plugin} from 'types/PrettyFormat';
11+
import type {
12+
Colors,
13+
Indent,
14+
PluginOptions,
15+
Print,
16+
Plugin,
17+
} from 'types/PrettyFormat';
1218

1319
const asymmetricMatcher = Symbol.for('jest.asymmetricMatcher');
1420
const SPACE = ' ';
@@ -20,7 +26,7 @@ const print = (
2026
val: any,
2127
print: Print,
2228
indent: Indent,
23-
opts: Options,
29+
opts: PluginOptions,
2430
colors: Colors,
2531
) => {
2632
const stringedValue = val.toString();

packages/pretty-format/src/plugins/convert_ansi.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88
* @flow
99
*/
1010

11-
import type {Colors, Indent, Options, Print, Plugin} from 'types/PrettyFormat';
11+
import type {
12+
Colors,
13+
Indent,
14+
PluginOptions,
15+
Print,
16+
Plugin,
17+
} from 'types/PrettyFormat';
1218

1319
import ansiRegex from 'ansi-regex';
1420
import style from 'ansi-styles';
@@ -42,7 +48,7 @@ const print = (
4248
val: any,
4349
print: Print,
4450
indent: Indent,
45-
opts: Options,
51+
opts: PluginOptions,
4652
colors: Colors,
4753
) => print(toHumanReadableAnsi(val));
4854

packages/pretty-format/src/plugins/html_element.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88
* @flow
99
*/
1010

11-
import type {Colors, Indent, Options, Print, Plugin} from 'types/PrettyFormat';
11+
import type {
12+
Colors,
13+
Indent,
14+
PluginOptions,
15+
Print,
16+
Plugin,
17+
} from 'types/PrettyFormat';
1218

1319
import escapeHTML from './lib/escape_html';
1420

@@ -85,7 +91,7 @@ const print = (
8591
element: HTMLElement | HTMLText | HTMLComment,
8692
print: Print,
8793
indent: Indent,
88-
opts: Options,
94+
opts: PluginOptions,
8995
colors: Colors,
9096
): string => {
9197
if (element.nodeType === 3) {

packages/pretty-format/src/plugins/immutable_list.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88
* @flow
99
*/
1010

11-
import type {Colors, Indent, Options, Print, Plugin} from 'types/PrettyFormat';
11+
import type {
12+
Colors,
13+
Indent,
14+
PluginOptions,
15+
Print,
16+
Plugin,
17+
} from 'types/PrettyFormat';
1218

1319
import printImmutable from './lib/print_immutable';
1420

@@ -19,7 +25,7 @@ const print = (
1925
val: any,
2026
print: Print,
2127
indent: Indent,
22-
opts: Options,
28+
opts: PluginOptions,
2329
colors: Colors,
2430
) => printImmutable(val, print, indent, opts, colors, 'List', false);
2531

packages/pretty-format/src/plugins/immutable_map.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88
* @flow
99
*/
1010

11-
import type {Colors, Indent, Options, Print, Plugin} from 'types/PrettyFormat';
11+
import type {
12+
Colors,
13+
Indent,
14+
PluginOptions,
15+
Print,
16+
Plugin,
17+
} from 'types/PrettyFormat';
1218

1319
import printImmutable from './lib/print_immutable';
1420

@@ -21,7 +27,7 @@ const print = (
2127
val: any,
2228
print: Print,
2329
indent: Indent,
24-
opts: Options,
30+
opts: PluginOptions,
2531
colors: Colors,
2632
) => printImmutable(val, print, indent, opts, colors, 'Map', true);
2733

packages/pretty-format/src/plugins/immutable_ordered_map.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88
* @flow
99
*/
1010

11-
import type {Colors, Indent, Options, Print, Plugin} from 'types/PrettyFormat';
11+
import type {
12+
Colors,
13+
Indent,
14+
PluginOptions,
15+
Print,
16+
Plugin,
17+
} from 'types/PrettyFormat';
1218

1319
import printImmutable from './lib/print_immutable';
1420

@@ -21,7 +27,7 @@ const print = (
2127
val: any,
2228
print: Print,
2329
indent: Indent,
24-
opts: Options,
30+
opts: PluginOptions,
2531
colors: Colors,
2632
) => printImmutable(val, print, indent, opts, colors, 'OrderedMap', true);
2733

packages/pretty-format/src/plugins/immutable_ordered_set.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88
* @flow
99
*/
1010

11-
import type {Colors, Indent, Options, Print, Plugin} from 'types/PrettyFormat';
11+
import type {
12+
Colors,
13+
Indent,
14+
PluginOptions,
15+
Print,
16+
Plugin,
17+
} from 'types/PrettyFormat';
1218

1319
import printImmutable from './lib/print_immutable';
1420

@@ -21,7 +27,7 @@ const print = (
2127
val: any,
2228
print: Print,
2329
indent: Indent,
24-
opts: Options,
30+
opts: PluginOptions,
2531
colors: Colors,
2632
) => printImmutable(val, print, indent, opts, colors, 'OrderedSet', false);
2733

packages/pretty-format/src/plugins/immutable_record.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88
* @flow
99
*/
1010

11-
import type {Colors, Indent, Options, Print, Plugin} from 'types/PrettyFormat';
11+
import type {
12+
Colors,
13+
Indent,
14+
PluginOptions,
15+
Print,
16+
Plugin,
17+
} from 'types/PrettyFormat';
1218

1319
import printImmutable from './lib/print_immutable';
1420

@@ -19,7 +25,7 @@ const print = (
1925
val: any,
2026
print: Print,
2127
indent: Indent,
22-
opts: Options,
28+
opts: PluginOptions,
2329
colors: Colors,
2430
) => printImmutable(val, print, indent, opts, colors, 'Record', true);
2531

packages/pretty-format/src/plugins/immutable_set.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88
* @flow
99
*/
1010

11-
import type {Colors, Indent, Options, Print, Plugin} from 'types/PrettyFormat';
11+
import type {
12+
Colors,
13+
Indent,
14+
PluginOptions,
15+
Print,
16+
Plugin,
17+
} from 'types/PrettyFormat';
1218

1319
import printImmutable from './lib/print_immutable';
1420

@@ -21,7 +27,7 @@ const print = (
2127
val: any,
2228
print: Print,
2329
indent: Indent,
24-
opts: Options,
30+
opts: PluginOptions,
2531
colors: Colors,
2632
) => printImmutable(val, print, indent, opts, colors, 'Set', false);
2733

packages/pretty-format/src/plugins/immutable_stack.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88
* @flow
99
*/
1010

11-
import type {Colors, Indent, Options, Print, Plugin} from 'types/PrettyFormat';
11+
import type {
12+
Colors,
13+
Indent,
14+
PluginOptions,
15+
Print,
16+
Plugin,
17+
} from 'types/PrettyFormat';
1218

1319
import printImmutable from './lib/print_immutable';
1420

@@ -19,7 +25,7 @@ const print = (
1925
val: any,
2026
print: Print,
2127
indent: Indent,
22-
opts: Options,
28+
opts: PluginOptions,
2329
colors: Colors,
2430
) => printImmutable(val, print, indent, opts, colors, 'Stack', false);
2531

packages/pretty-format/src/plugins/lib/print_immutable.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* @flow
99
*/
1010

11-
import type {Colors, Indent, Options, Print} from 'types/PrettyFormat';
11+
import type {Colors, Indent, PluginOptions, Print} from 'types/PrettyFormat';
1212

1313
const IMMUTABLE_NAMESPACE = 'Immutable.';
1414
const SPACE = ' ';
@@ -22,7 +22,7 @@ const printImmutable = (
2222
val: any,
2323
print: Print,
2424
indent: Indent,
25-
opts: Options,
25+
opts: PluginOptions,
2626
colors: Colors,
2727
immutableDataStructureName: string,
2828
isMap: boolean,

packages/pretty-format/src/plugins/react_element.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88
* @flow
99
*/
1010

11-
import type {Colors, Indent, Options, Print, Plugin} from 'types/PrettyFormat';
11+
import type {
12+
Colors,
13+
Indent,
14+
PluginOptions,
15+
Print,
16+
Plugin,
17+
} from 'types/PrettyFormat';
1218

1319
import escapeHTML from './lib/escape_html';
1420

@@ -71,7 +77,7 @@ const print = (
7177
element: React$Element<*>,
7278
print: Print,
7379
indent: Indent,
74-
opts: Options,
80+
opts: PluginOptions,
7581
colors: Colors,
7682
) => {
7783
let result = colors.tag.open + '<';

packages/pretty-format/src/plugins/react_test_component.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import type {
1212
Colors,
1313
Indent,
14-
Options,
14+
PluginOptions,
1515
Print,
1616
Plugin,
1717
ReactTestObject,
@@ -73,7 +73,7 @@ const print = (
7373
instance: ReactTestObject,
7474
print: Print,
7575
indent: Indent,
76-
opts: Options,
76+
opts: PluginOptions,
7777
colors: Colors,
7878
) => {
7979
let closeInNewLine = false;

types/PrettyFormat.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,13 @@ export type StringOrNull = string | null;
2222

2323
export type Options = {|
2424
callToJSON: boolean,
25-
edgeSpacing: string,
2625
escapeRegex: boolean,
2726
highlight: boolean,
2827
indent: number,
2928
maxDepth: number,
3029
min: boolean,
3130
plugins: Plugins,
3231
printFunctionName: boolean,
33-
spacing: string,
3432
theme: {|
3533
comment: string,
3634
content: string,
@@ -40,12 +38,18 @@ export type Options = {|
4038
|},
4139
|};
4240

41+
export type PluginOptions = {|
42+
edgeSpacing: string,
43+
min: boolean,
44+
spacing: string,
45+
|};
46+
4347
export type Plugin = {
4448
print: (
4549
val: any,
4650
serialize: Print,
4751
indent: Indent,
48-
opts: Options,
52+
opts: PluginOptions,
4953
colors: Colors,
5054
) => string,
5155
test: any => boolean,

0 commit comments

Comments
 (0)