Skip to content

Commit 9590c42

Browse files
Fabien Rassinierleplatrem
authored andcommitted
Add some rules to keep JS and JSX well formatted (rjsf-team#361)
1 parent cc11737 commit 9590c42

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+157
-157
lines changed

.eslintrc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
"react/jsx-uses-react": 2,
55
"react/jsx-uses-vars": 2,
66
"react/react-in-jsx-scope": 2,
7+
"react/jsx-space-before-closing": [1, "never"],
8+
"react/jsx-closing-bracket-location": [1, "after-props"],
79

810
"curly": [2],
911
"indent": [2, 2, {"SwitchCase": 1}],
@@ -12,7 +14,8 @@
1214
"semi": [2, "always"],
1315
"comma-dangle": [0],
1416
"no-unused-vars": [2, {"vars": "all", "args": "none"}],
15-
"no-console": [0]
17+
"no-console": [0],
18+
"object-curly-spacing": [1, "never"]
1619
},
1720
"env": {
1821
"es6": true,

src/components/Form.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { Component, PropTypes } from "react";
1+
import React, {Component, PropTypes} from "react";
22

33
import SchemaField from "./fields/SchemaField";
44
import TitleField from "./fields/TitleField";
@@ -72,7 +72,7 @@ export default class Form extends Component {
7272
const {showErrorList} = this.props;
7373

7474
if (status !== "editing" && errors.length && showErrorList != false) {
75-
return <ErrorList errors={errors} />;
75+
return <ErrorList errors={errors}/>;
7676
}
7777
return null;
7878
}
@@ -175,7 +175,7 @@ export default class Form extends Component {
175175
formData={formData}
176176
onChange={this.onChange}
177177
registry={registry}
178-
safeRenderCompletion={safeRenderCompletion} />
178+
safeRenderCompletion={safeRenderCompletion}/>
179179
{ children ? children :
180180
<p>
181181
<button type="submit" className="btn btn-info">Submit</button>

src/components/fields/ArrayField.js

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { Component, PropTypes } from "react";
1+
import React, {Component, PropTypes} from "react";
22

33
import {
44
getAlternativeWidget,
@@ -20,19 +20,19 @@ import FileWidget from "./../widgets/FileWidget";
2020
function ArrayFieldTitle({TitleField, idSchema, title, required}) {
2121
if (!title) {
2222
// See #312: Ensure compatibility with old versions of React.
23-
return <div />;
23+
return <div/>;
2424
}
2525
const id = `${idSchema.$id}__title`;
26-
return <TitleField id={id} title={title} required={required} />;
26+
return <TitleField id={id} title={title} required={required}/>;
2727
}
2828

2929
function ArrayFieldDescription({DescriptionField, idSchema, description}) {
3030
if (!description) {
3131
// See #312: Ensure compatibility with old versions of React.
32-
return <div />;
32+
return <div/>;
3333
}
3434
const id = `${idSchema.$id}__description`;
35-
return <DescriptionField id={id} description={description} />;
35+
return <DescriptionField id={id} description={description}/>;
3636
}
3737

3838
class ArrayField extends Component {
@@ -179,12 +179,12 @@ class ArrayField extends Component {
179179
TitleField={TitleField}
180180
idSchema={idSchema}
181181
title={title}
182-
required={required} />
182+
required={required}/>
183183
{schema.description ?
184184
<ArrayFieldDescription
185185
DescriptionField={DescriptionField}
186186
idSchema={idSchema}
187-
description={schema.description} /> : null}
187+
description={schema.description}/> : null}
188188
<div className="row array-item-list">{
189189
items.map((item, index) => {
190190
const itemErrorSchema = errorSchema ? errorSchema[index] : undefined;
@@ -204,7 +204,7 @@ class ArrayField extends Component {
204204
})
205205
}</div>
206206
<AddButton
207-
onClick={this.onAddClick} disabled={disabled || readonly} />
207+
onClick={this.onAddClick} disabled={disabled || readonly}/>
208208
</fieldset>
209209
);
210210
}
@@ -229,8 +229,7 @@ class ArrayField extends Component {
229229
value={items}
230230
disabled={disabled}
231231
readonly={readonly}
232-
autofocus={autofocus}
233-
/>
232+
autofocus={autofocus}/>
234233
);
235234
}
236235

@@ -248,8 +247,7 @@ class ArrayField extends Component {
248247
value={items}
249248
disabled={disabled}
250249
readonly={readonly}
251-
autofocus={autofocus}
252-
/>
250+
autofocus={autofocus}/>
253251
);
254252
}
255253

@@ -286,7 +284,7 @@ class ArrayField extends Component {
286284
TitleField={TitleField}
287285
idSchema={idSchema}
288286
title={title}
289-
required={required} />
287+
required={required}/>
290288
{schema.description ?
291289
<div className="field-description">{schema.description}</div> : null}
292290
<div className="row array-item-list">{
@@ -319,7 +317,7 @@ class ArrayField extends Component {
319317
{
320318
additionalSchema ? <AddButton
321319
onClick={this.onAddClick}
322-
disabled={disabled || readonly} /> : null
320+
disabled={disabled || readonly}/> : null
323321
}
324322
</fieldset>
325323
);
@@ -363,7 +361,7 @@ class ArrayField extends Component {
363361
registry={this.props.registry}
364362
disabled={this.props.disabled}
365363
readonly={this.props.readonly}
366-
autofocus={autofocus} />
364+
autofocus={autofocus}/>
367365
</div>
368366
{
369367
hasToolbar ?

src/components/fields/BooleanField.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { PropTypes } from "react";
1+
import React, {PropTypes} from "react";
22

33
import {
44
defaultFieldValue,
@@ -56,9 +56,9 @@ function BooleanField(props) {
5656
};
5757
if (widget) {
5858
const Widget = getAlternativeWidget(schema, widget, widgets);
59-
return <Widget options={buildOptions(schema, uiSchema["ui:widget"])} {...commonProps} />;
59+
return <Widget options={buildOptions(schema, uiSchema["ui:widget"])} {...commonProps}/>;
6060
}
61-
return <CheckboxWidget {...commonProps} />;
61+
return <CheckboxWidget {...commonProps}/>;
6262
}
6363

6464
if (process.env.NODE_ENV !== "production") {

src/components/fields/DescriptionField.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function DescriptionField(props) {
44
const {id, description} = props;
55
if (!description) {
66
// See #312: Ensure compatibility with old versions of React.
7-
return <div />;
7+
return <div/>;
88
}
99
if (typeof description === "string") {
1010
return <p id={id} className="field-description">{description}</p>;

src/components/fields/NumberField.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import React, { PropTypes } from "react";
1+
import React, {PropTypes} from "react";
22

3-
import { asNumber } from "../../utils";
3+
import {asNumber} from "../../utils";
44
import StringField from "./StringField";
55

66
function NumberField(props) {
77
return (
88
<StringField {...props}
9-
onChange={(value) => props.onChange(asNumber(value))} />
9+
onChange={(value) => props.onChange(asNumber(value))}/>
1010
);
1111
}
1212

src/components/fields/ObjectField.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import React, { Component, PropTypes } from "react";
1+
import React, {Component, PropTypes} from "react";
22

3-
import { deepEquals } from "../../utils";
3+
import {deepEquals} from "../../utils";
44

55

66
import {
@@ -123,7 +123,7 @@ class ObjectField extends Component {
123123
<DescriptionField
124124
id={`${idSchema.$id}__description`}
125125
description={schema.description}
126-
formContext={formContext} /> : null}
126+
formContext={formContext}/> : null}
127127
{
128128
orderedProperties.map((name, index) => {
129129
return (
@@ -138,7 +138,7 @@ class ObjectField extends Component {
138138
onChange={this.onPropertyChange(name)}
139139
registry={this.props.registry}
140140
disabled={disabled}
141-
readonly={readonly} />
141+
readonly={readonly}/>
142142
);
143143
})
144144
}</fieldset>

src/components/fields/SchemaField.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { PropTypes } from "react";
1+
import React, {PropTypes} from "react";
22

33
import {
44
isMultiSelect,
@@ -38,7 +38,7 @@ function Label(props) {
3838
const {label, required, id} = props;
3939
if (!label) {
4040
// See #312: Ensure compatibility with old versions of React.
41-
return <div />;
41+
return <div/>;
4242
}
4343
return (
4444
<label className="control-label" htmlFor={id}>
@@ -51,7 +51,7 @@ function Help(props) {
5151
const {help} = props;
5252
if (!help) {
5353
// See #312: Ensure compatibility with old versions of React.
54-
return <div />;
54+
return <div/>;
5555
}
5656
if (typeof help === "string") {
5757
return <p className="help-block">{help}</p>;
@@ -62,7 +62,7 @@ function Help(props) {
6262
function ErrorList(props) {
6363
const {errors = []} = props;
6464
if (errors.length === 0) {
65-
return <div />;
65+
return <div/>;
6666
}
6767
return (
6868
<div>
@@ -95,7 +95,7 @@ function DefaultTemplate(props) {
9595

9696
return (
9797
<div className={classNames}>
98-
{displayLabel ? <Label label={label} required={required} id={id} /> : null}
98+
{displayLabel ? <Label label={label} required={required} id={id}/> : null}
9999
{displayLabel && description ? description : null}
100100
{children}
101101
{errors}
@@ -144,7 +144,7 @@ function SchemaField(props) {
144144

145145
if (Object.keys(schema).length === 0) {
146146
// See #312: Ensure compatibility with old versions of React.
147-
return <div />;
147+
return <div/>;
148148
}
149149

150150
let displayLabel = true;
@@ -167,7 +167,7 @@ function SchemaField(props) {
167167
disabled={disabled}
168168
readonly={readonly}
169169
autofocus={autofocus}
170-
formContext={formContext} />
170+
formContext={formContext}/>
171171
);
172172

173173
const {type} = schema;
@@ -188,11 +188,11 @@ function SchemaField(props) {
188188
const fieldProps = {
189189
description: <DescriptionField id={id + "__description"}
190190
description={description}
191-
formContext={formContext} />,
191+
formContext={formContext}/>,
192192
rawDescription: description,
193-
help: <Help help={help} />,
193+
help: <Help help={help}/>,
194194
rawHelp: typeof help === "string" ? help : undefined,
195-
errors: <ErrorList errors={errors} />,
195+
errors: <ErrorList errors={errors}/>,
196196
rawErrors: errors,
197197
id,
198198
label,

src/components/fields/StringField.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { PropTypes } from "react";
1+
import React, {PropTypes} from "react";
22

33
import {
44
defaultFieldValue,
@@ -44,15 +44,15 @@ function StringField(props) {
4444
const enumOptions = optionsList(schema);
4545
if (widget) {
4646
const Widget = getAlternativeWidget(schema, widget, widgets, {enumOptions});
47-
return <Widget {...commonProps} />;
47+
return <Widget {...commonProps}/>;
4848
}
49-
return <SelectWidget options={{enumOptions}} {...commonProps} />;
49+
return <SelectWidget options={{enumOptions}} {...commonProps}/>;
5050
}
5151
if (widget) {
5252
const Widget = getAlternativeWidget(schema, widget, widgets);
53-
return <Widget {...commonProps} placeholder={placeholder} />;
53+
return <Widget {...commonProps} placeholder={placeholder}/>;
5454
}
55-
return <TextWidget {...commonProps} placeholder={placeholder} />;
55+
return <TextWidget {...commonProps} placeholder={placeholder}/>;
5656
}
5757

5858
if (process.env.NODE_ENV !== "production") {

src/components/widgets/AltDateTimeWidget.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import React, { PropTypes } from "react";
1+
import React, {PropTypes} from "react";
22

33
import AltDateWidget from "./AltDateWidget";
44

55

66
function AltDateTimeWidget(props) {
7-
return <AltDateWidget time {...props} />;
7+
return <AltDateWidget time {...props}/>;
88
}
99

1010
if (process.env.NODE_ENV !== "production") {

0 commit comments

Comments
 (0)