Skip to content

Commit 8a57825

Browse files
committed
Make sources prettier
1 parent 0c36ebd commit 8a57825

19 files changed

+320
-363
lines changed

dev-server.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,23 @@ const compiler = webpack({ ...config, mode: 'development' });
1010
const PORT = 4000;
1111

1212
app.use(
13-
require('webpack-dev-middleware')(compiler, {
14-
noInfo: true,
15-
publicPath: config.output.publicPath,
16-
})
13+
require('webpack-dev-middleware')(compiler, {
14+
noInfo: true,
15+
publicPath: config.output.publicPath,
16+
}),
1717
);
1818

1919
app.use(require('webpack-hot-middleware')(compiler));
2020

2121
app.get('*', (req, res) =>
22-
res.sendFile(path.join(__dirname, 'src/play/index.html'))
22+
res.sendFile(path.join(__dirname, 'src/play/index.html')),
2323
);
2424

2525
app.listen(PORT, 'localhost', err => {
26-
if (err) {
27-
console.log(err);
28-
return;
29-
}
26+
if (err) {
27+
console.log(err);
28+
return;
29+
}
3030

31-
console.log(`Listening at http://localhost:${PORT}`);
31+
console.log(`Listening at http://localhost:${PORT}`);
3232
});

src/Comps/Decorators/fromDefaultValue.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ function updateDefault({
2626
return val;
2727
}
2828

29-
function fromDefaultValue<P extends Props>(
30-
Comp: React.ComponentType<P>,
31-
) {
29+
function fromDefaultValue<P extends Props>(Comp: React.ComponentType<P>) {
3230
class DefaultValue extends React.Component<P, { val?: {}; init: boolean }> {
3331
static getDerivedStateFromProps(nextProps: P, state: { init: boolean }) {
3432
if (state.init) {

src/Comps/Decorators/validator.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type Props = {
1717
function validated<P extends Props>(
1818
Comp: React.ComponentType<P & { errorMessage?: string[] }>,
1919
) {
20-
class Validator extends React.Component<P & { __tree: any, path: string[] }> {
20+
class Validator extends React.Component<P & { __tree: any; path: string[] }> {
2121
onChange = (val?: {}) => {
2222
const validation = validate(
2323
val,

src/Comps/Decorators/visible.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ type Props = {
99
dispatch: (action: Action, ...args: {}[]) => any;
1010
};
1111
function visibility<P extends Props>(
12-
Comp: React.ComponentType<P>
12+
Comp: React.ComponentType<P>,
1313
): React.FunctionComponent<P> {
1414
return function Visible(props: P) {
1515
const {

src/Comps/Fields/Undefined.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import { WidgetProps } from '../../../typings/types';
44

55
function Undefined(props: WidgetProps) {
66
return (
7-
<div
8-
>{`Undefined field type "${props.schema.type!.toString()}", [${props.path.toString()}]`}</div>
7+
<div>{`Undefined field type "${props.schema.type!.toString()}", [${props.path.toString()}]`}</div>
98
);
109
}
1110

src/Comps/Views/ArrayWidget.js

+23-25
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,33 @@ import PropTypes from 'prop-types';
33
import labeled from './labeled';
44

55
function ArrayWidget(props) {
6-
function renderChild(child, index) {
7-
return (
8-
<div>
9-
<button
10-
onClick={function remove() {
11-
props.onChildRemove(index);
12-
}}
13-
>
14-
-
15-
</button>
16-
{child}
17-
</div>
18-
);
19-
}
20-
21-
const children = React.Children.map(props.children, renderChild);
6+
function renderChild(child, index) {
227
return (
23-
<div>
24-
<div>
25-
{children}
26-
</div>
27-
<button onClick={() => props.onChildAdd()}>+</button>
28-
</div>
8+
<div>
9+
<button
10+
onClick={function remove() {
11+
props.onChildRemove(index);
12+
}}
13+
>
14+
-
15+
</button>
16+
{child}
17+
</div>
2918
);
19+
}
20+
21+
const children = React.Children.map(props.children, renderChild);
22+
return (
23+
<div>
24+
<div>{children}</div>
25+
<button onClick={() => props.onChildAdd()}>+</button>
26+
</div>
27+
);
3028
}
3129

3230
ArrayWidget.propTypes = {
33-
children: PropTypes.arrayOf(PropTypes.element).isRequired,
34-
onChildRemove: PropTypes.func.isRequired, // eslint-disable-line react/no-unused-prop-types
35-
onChildAdd: PropTypes.func.isRequired
31+
children: PropTypes.arrayOf(PropTypes.element).isRequired,
32+
onChildRemove: PropTypes.func.isRequired, // eslint-disable-line react/no-unused-prop-types
33+
onChildAdd: PropTypes.func.isRequired,
3634
};
3735
export default labeled(ArrayWidget);

src/Comps/Views/ArrowNumberWidget.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@ import labeled from './labeled';
33
import Input from './Input';
44

55
function ArrowNumberWidget(props) {
6-
return (
7-
<Input
8-
{...props}
9-
type="number"
10-
/>
11-
);
6+
return <Input {...props} type="number" />;
127
}
138

149
export default labeled(ArrowNumberWidget);

src/Comps/Views/CheckboxWidget.js

+2-8
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,11 @@ import labeled from './labeled';
44
import Input from './Input';
55

66
function CheckboxWidget(props) {
7-
return (
8-
<Input
9-
{...props}
10-
type="checkbox"
11-
checked={props.value}
12-
/>
13-
);
7+
return <Input {...props} type="checkbox" checked={props.value} />;
148
}
159

1610
CheckboxWidget.propTypes = {
17-
value: PropTypes.bool
11+
value: PropTypes.bool,
1812
};
1913
CheckboxWidget.defaultProps = { value: false };
2014

src/Comps/Views/ObjectWidget.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,11 @@ import PropTypes from 'prop-types';
33
import labeled from './labeled';
44

55
function ObjectWidget(props) {
6-
return (
7-
<div>
8-
{props.children}
9-
</div>
10-
);
6+
return <div>{props.children}</div>;
117
}
128

139
ObjectWidget.propTypes = {
14-
children: PropTypes.arrayOf(PropTypes.element).isRequired
10+
children: PropTypes.arrayOf(PropTypes.element).isRequired,
1511
};
1612

1713
export default labeled(ObjectWidget);

src/Comps/Views/SelectWidget.js

+21-21
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,28 @@ import React from 'react';
22
import PropTypes from 'prop-types';
33

44
function SelectWidget(props) {
5-
const { view, value, onChange } = props;
6-
const choices = view.choices.map(c => (
7-
<option key={c.value} value={c.value}>
8-
{c.label}
9-
</option>
10-
));
11-
return (
12-
<select value={value} onChange={e => onChange(e.target.value)}>
13-
{choices}
14-
</select>
15-
);
5+
const { view, value, onChange } = props;
6+
const choices = view.choices.map(c => (
7+
<option key={c.value} value={c.value}>
8+
{c.label}
9+
</option>
10+
));
11+
return (
12+
<select value={value} onChange={e => onChange(e.target.value)}>
13+
{choices}
14+
</select>
15+
);
1616
}
1717
SelectWidget.propTypes = {
18-
view: PropTypes.shape({
19-
choices: PropTypes.arrayOf(
20-
PropTypes.shape({
21-
value: PropTypes.any,
22-
label: PropTypes.string.isRequired
23-
})
24-
).isRequired
25-
}).isRequired,
26-
value: PropTypes.any, // eslint-disable-line
27-
onChange: PropTypes.func.isRequired
18+
view: PropTypes.shape({
19+
choices: PropTypes.arrayOf(
20+
PropTypes.shape({
21+
value: PropTypes.any,
22+
label: PropTypes.string.isRequired,
23+
}),
24+
).isRequired,
25+
}).isRequired,
26+
value: PropTypes.any, // eslint-disable-line
27+
onChange: PropTypes.func.isRequired,
2828
};
2929
export default SelectWidget;

src/Comps/Views/TextWidget.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@ import labeled from './labeled';
33
import Input from './Input';
44

55
function TextWidget(props) {
6-
return (
7-
<Input
8-
{...props}
9-
type="text"
10-
/>
11-
);
6+
return <Input {...props} type="text" />;
127
}
138

149
export default labeled(TextWidget);

src/Store/index.tsx

+9-11
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,15 @@ interface StoreProps {
55
value?: {};
66
schema: {};
77
onValueChange: (value: {}) => void;
8-
children: (
9-
props: {
10-
dispatch: (
11-
action: (state: any, ...extraArgs: any[]) => void,
12-
...args: any[]
13-
) => void;
14-
schema: {};
15-
value: {};
16-
status: {};
17-
},
18-
) => JSX.Element;
8+
children: (props: {
9+
dispatch: (
10+
action: (state: any, ...extraArgs: any[]) => void,
11+
...args: any[]
12+
) => void;
13+
schema: {};
14+
value: {};
15+
status: {};
16+
}) => JSX.Element;
1917
}
2018
const FormContext = React.createContext<{
2119
value?: {};

src/Utils/customValidator.ts

+8-11
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,16 @@ const customValidator = new jsonschema.Validator();
66
customValidator.attributes.errored = function validateErrored(
77
instance: {},
88
schema: { errored?: ErrorFn },
9-
options: { formValue: {}, ctx: {basePath?: string[]} },
10-
ctx : { propertyPath : String},
9+
options: { formValue: {}; ctx: { basePath?: string[] } },
10+
ctx: { propertyPath: String },
1111
) {
1212
if (typeof schema.errored !== 'function') {
1313
throw new jsonschema.SchemaError('"errored" expects a function');
1414
}
15-
const path = (options.ctx.basePath || [])
16-
.concat(ctx.propertyPath.split('.').slice(1));
17-
const msg = schema.errored(
18-
instance,
19-
options.formValue,
20-
path,
21-
);
15+
const path = (options.ctx.basePath || []).concat(
16+
ctx.propertyPath.split('.').slice(1),
17+
);
18+
const msg = schema.errored(instance, options.formValue, path);
2219
if (msg) {
2320
return msg;
2421
}
@@ -33,8 +30,8 @@ function validate(
3330
return customValidator.validate(value, schema, {
3431
formValue: formValue || {},
3532
ctx: {
36-
basePath,
37-
}
33+
basePath,
34+
},
3835
});
3936
}
4037

0 commit comments

Comments
 (0)