Skip to content

Commit 2985922

Browse files
committed
Currently options are an all or nothing parameter. Split the Options type to OptionParams and Options so that properties can be independently specified in options
1 parent 178d9cb commit 2985922

File tree

3 files changed

+1190
-3
lines changed

3 files changed

+1190
-3
lines changed

Diff for: src/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import formatTree from './formatter/formatTree';
44
import parseReactElement from './parser/parseReactElement';
55
import type { Element as ReactElement } from 'react';
6-
import type { Options } from './options';
6+
import type { OptionParams } from './options';
77

88
const reactElementToJsxString = (
99
element: ReactElement<any>,
@@ -18,7 +18,7 @@ const reactElementToJsxString = (
1818
sortProps = true,
1919
maxInlineAttributesLineLength,
2020
displayName,
21-
}: Options = {}
21+
}: OptionParams = {}
2222
) => {
2323
if (!element) {
2424
throw new Error('react-element-to-jsx-string: Expected a ReactElement');

Diff for: src/options.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,25 @@
22

33
import * as React from 'react';
44

5+
export type OptionParams = {|
6+
filterProps?: string[],
7+
showDefaultProps?: boolean,
8+
showFunctions?: boolean,
9+
functionValue?: Function,
10+
tabStop?: number,
11+
useBooleanShorthandSyntax?: boolean,
12+
useFragmentShortSyntax?: boolean,
13+
sortProps?: boolean,
14+
15+
maxInlineAttributesLineLength?: number,
16+
displayName?: (element: React.Element<*>) => string,
17+
|};
18+
519
export type Options = {|
620
filterProps: string[],
721
showDefaultProps: boolean,
822
showFunctions: boolean,
9-
functionValue: Function,
23+
functionValue?: Function,
1024
tabStop: number,
1125
useBooleanShorthandSyntax: boolean,
1226
useFragmentShortSyntax: boolean,

0 commit comments

Comments
 (0)