Skip to content
This repository was archived by the owner on Jul 19, 2019. It is now read-only.

Commit 0eccd59

Browse files
committed
Enable eslint rule: object-curly-spacing
1 parent 43ed614 commit 0eccd59

File tree

7 files changed

+79
-80
lines changed

7 files changed

+79
-80
lines changed

.eslintrc

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"react/jsx-uses-vars": "error",
99
"array-bracket-spacing": 0,
1010
"comma-dangle": 0,
11-
"object-curly-spacing": 0,
1211
"quotes": 0,
1312
"semi": 0,
1413
"space-before-blocks": 0,

examples/async-data/app.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ let App = React.createClass({
2525
</p>
2626
<label htmlFor="states-autocomplete">Choose a state from the US</label>
2727
<Autocomplete
28-
inputProps={{name: "US state", id: "states-autocomplete"}}
28+
inputProps={{ name: "US state", id: "states-autocomplete" }}
2929
ref="autocomplete"
3030
value={this.state.value}
3131
items={this.state.unitedStates}

examples/custom-menu/app.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ let App = React.createClass({
2525
<label htmlFor="states-autocomplete">Choose a state from the US</label>
2626
<Autocomplete
2727
value={this.state.value}
28-
inputProps={{name: "US state", id: "states-autocomplete"}}
28+
inputProps={{ name: "US state", id: "states-autocomplete" }}
2929
items={this.state.unitedStates}
3030
getItemValue={(item) => item.name}
3131
onSelect={(value, state) => this.setState({ value, unitedStates: [state] }) }
@@ -43,13 +43,13 @@ let App = React.createClass({
4343
>{item.name}</div>
4444
)}
4545
renderMenu={(items, value, style) => (
46-
<div style={{...styles.menu, ...style}}>
46+
<div style={{ ...styles.menu, ...style }}>
4747
{value === '' ? (
48-
<div style={{padding: 6}}>Type of the name of a United State</div>
48+
<div style={{ padding: 6 }}>Type of the name of a United State</div>
4949
) : this.state.loading ? (
50-
<div style={{padding: 6}}>Loading...</div>
50+
<div style={{ padding: 6 }}>Loading...</div>
5151
) : items.length === 0 ? (
52-
<div style={{padding: 6}}>No matches for {value}</div>
52+
<div style={{ padding: 6 }}>No matches for {value}</div>
5353
) : this.renderItems(items)}
5454
</div>
5555
)}

examples/static-data/app.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ let App = React.createClass({
1818
<label htmlFor="states-autocomplete">Choose a state from the US</label>
1919
<Autocomplete
2020
value={this.state.value}
21-
inputProps={{name: "US state", id: "states-autocomplete"}}
21+
inputProps={{ name: "US state", id: "states-autocomplete" }}
2222
items={getStates()}
2323
getItemValue={(item) => item.name}
2424
shouldItemRender={matchStateToTerm}

lib/Autocomplete.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ let Autocomplete = React.createClass({
123123
onChange () {},
124124
onSelect () {},
125125
renderMenu (items, value, style) {
126-
return <div style={{...style, ...this.menuStyle}} children={items}/>
126+
return <div style={{ ...style, ...this.menuStyle }} children={items}/>
127127
},
128128
menuStyle: {
129129
borderRadius: '3px',
@@ -370,7 +370,7 @@ let Autocomplete = React.createClass({
370370
const element = this.props.renderItem(
371371
item,
372372
this.state.highlightedIndex === index,
373-
{cursor: 'default'}
373+
{ cursor: 'default' }
374374
)
375375
return React.cloneElement(element, {
376376
onMouseDown: () => this.setIgnoreBlur(true), // Ignore blur to prevent menu from de-rendering before we can process click
@@ -445,7 +445,7 @@ let Autocomplete = React.createClass({
445445
const { inputProps } = this.props
446446
const open = this.isOpen()
447447
return (
448-
<div style={{...this.props.wrapperStyle}} {...this.props.wrapperProps}>
448+
<div style={{ ...this.props.wrapperStyle }} {...this.props.wrapperProps}>
449449
<input
450450
{...inputProps}
451451
role="combobox"
@@ -463,7 +463,7 @@ let Autocomplete = React.createClass({
463463
/>
464464
{open && this.renderMenu()}
465465
{this.props.debug && (
466-
<pre style={{marginLeft: 300}}>
466+
<pre style={{ marginLeft: 300 }}>
467467
{JSON.stringify(_debugStates.slice(_debugStates.length - 5, _debugStates.length), null, 2)}
468468
</pre>
469469
)}

lib/__tests__/Autocomplete-test.js

+18-18
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function AutocompleteComponentJSX (extraProps) {
1010
return (
1111
<Autocomplete
1212
labelText="Choose a state from the US"
13-
inputProps={{name: "US state"}}
13+
inputProps={{ name: "US state" }}
1414
getItemValue={(item) => item.name}
1515
items={getStates()}
1616
renderItem={(item, isHighlighted) => (
@@ -186,8 +186,8 @@ describe('Autocomplete kewDown->ArrowDown event handlers', () => {
186186
const autocompleteInputWrapper = autocompleteWrapper.find('input');
187187

188188
it('should highlight the 1st item in the menu when none is selected', () => {
189-
autocompleteWrapper.setState({'isOpen': true});
190-
autocompleteWrapper.setState({'highlightedIndex': null});
189+
autocompleteWrapper.setState({ 'isOpen': true });
190+
autocompleteWrapper.setState({ 'highlightedIndex': null });
191191

192192
autocompleteInputWrapper.simulate('keyDown', { key : "ArrowDown", keyCode: 40, which: 40 });
193193

@@ -196,12 +196,12 @@ describe('Autocomplete kewDown->ArrowDown event handlers', () => {
196196
});
197197

198198
it('should highlight the "n+1" item in the menu when "n" is selected', () => {
199-
autocompleteWrapper.setState({'isOpen': true});
199+
autocompleteWrapper.setState({ 'isOpen': true });
200200

201201
const n = 4;
202202
// Set input to be an empty value, which displays all 50 states as items in the menu
203203
autocompleteInputWrapper.simulate('change', { target: { value: '' } });
204-
autocompleteWrapper.setState({'highlightedIndex': n});
204+
autocompleteWrapper.setState({ 'highlightedIndex': n });
205205

206206
autocompleteInputWrapper.simulate('keyDown', { key : "ArrowDown", keyCode: 40, which: 40 });
207207

@@ -210,11 +210,11 @@ describe('Autocomplete kewDown->ArrowDown event handlers', () => {
210210
});
211211

212212
it('should highlight the 1st item in the menu when the last is selected', () => {
213-
autocompleteWrapper.setState({'isOpen': true});
213+
autocompleteWrapper.setState({ 'isOpen': true });
214214

215215
// Set input to be an empty value, which displays all 50 states as items in the menu
216216
autocompleteInputWrapper.simulate('change', { target: { value: '' } });
217-
autocompleteWrapper.setState({'highlightedIndex': 49});
217+
autocompleteWrapper.setState({ 'highlightedIndex': 49 });
218218

219219
autocompleteInputWrapper.simulate('keyDown', { key : "ArrowDown", keyCode: 40, which: 40 });
220220

@@ -230,8 +230,8 @@ describe('Autocomplete kewDown->ArrowUp event handlers', () => {
230230
const autocompleteInputWrapper = autocompleteWrapper.find('input');
231231

232232
it('should highlight the last item in the menu when none is selected', () => {
233-
autocompleteWrapper.setState({'isOpen': true});
234-
autocompleteWrapper.setState({'highlightedIndex': null});
233+
autocompleteWrapper.setState({ 'isOpen': true });
234+
autocompleteWrapper.setState({ 'highlightedIndex': null });
235235
// Set input to be an empty value, which displays all 50 states as items in the menu
236236
autocompleteInputWrapper.simulate('change', { target: { value: '' } });
237237

@@ -242,12 +242,12 @@ describe('Autocomplete kewDown->ArrowUp event handlers', () => {
242242
});
243243

244244
it('should highlight the "n-1" item in the menu when "n" is selected', () => {
245-
autocompleteWrapper.setState({'isOpen': true});
245+
autocompleteWrapper.setState({ 'isOpen': true });
246246

247247
const n = 4;
248248
// Set input to be an empty value, which displays all 50 states as items in the menu
249249
autocompleteInputWrapper.simulate('change', { target: { value: '' } });
250-
autocompleteWrapper.setState({'highlightedIndex': n});
250+
autocompleteWrapper.setState({ 'highlightedIndex': n });
251251

252252
autocompleteInputWrapper.simulate('keyDown', { key : 'ArrowUp', keyCode: 38, which: 38 });
253253

@@ -256,11 +256,11 @@ describe('Autocomplete kewDown->ArrowUp event handlers', () => {
256256
});
257257

258258
it('should highlight the last item in the menu when the 1st is selected', () => {
259-
autocompleteWrapper.setState({'isOpen': true});
259+
autocompleteWrapper.setState({ 'isOpen': true });
260260

261261
// Set input to be an empty value, which displays all 50 states as items in the menu
262262
autocompleteInputWrapper.simulate('change', { target: { value: '' } });
263-
autocompleteWrapper.setState({'highlightedIndex': 0});
263+
autocompleteWrapper.setState({ 'highlightedIndex': 0 });
264264

265265
autocompleteInputWrapper.simulate('keyDown', { key : 'ArrowUp', keyCode: 38, which: 38 });
266266

@@ -276,14 +276,14 @@ describe('Autocomplete kewDown->Enter event handlers', () => {
276276
const autocompleteInputWrapper = autocompleteWrapper.find('input');
277277

278278
it('should do nothing if the menu is closed', () => {
279-
autocompleteWrapper.setState({'isOpen': false});
279+
autocompleteWrapper.setState({ 'isOpen': false });
280280
autocompleteWrapper.simulate('keyDown', { key : 'Enter', keyCode: 13, which: 13 });
281281
expect(autocompleteWrapper.state('isOpen')).toBe(false);
282282
});
283283

284284
it('should close menu if input has focus but no item has been selected and then the Enter key is hit', () => {
285285
let value = '';
286-
autocompleteWrapper.setState({'isOpen': true});
286+
autocompleteWrapper.setState({ 'isOpen': true });
287287
autocompleteInputWrapper.simulate('focus');
288288
autocompleteWrapper.setProps({ value, onSelect(v) { value = v; } });
289289

@@ -301,7 +301,7 @@ describe('Autocomplete kewDown->Enter event handlers', () => {
301301
it('should invoke `onSelect` with the selected menu item and close the menu', () => {
302302
let value = 'Ar';
303303
let defaultPrevented = false;
304-
autocompleteWrapper.setState({'isOpen': true});
304+
autocompleteWrapper.setState({ 'isOpen': true });
305305
autocompleteInputWrapper.simulate('focus');
306306
autocompleteWrapper.setProps({ value, onSelect(v) { value = v; } });
307307

@@ -324,8 +324,8 @@ describe('Autocomplete kewDown->Escape event handlers', () => {
324324
const autocompleteInputWrapper = autocompleteWrapper.find('input');
325325

326326
it('should unhighlight any selected menu item + close the menu', () => {
327-
autocompleteWrapper.setState({'isOpen': true});
328-
autocompleteWrapper.setState({'highlightedIndex': 0});
327+
autocompleteWrapper.setState({ 'isOpen': true });
328+
autocompleteWrapper.setState({ 'highlightedIndex': 0 });
329329

330330
autocompleteInputWrapper.simulate('keyDown', { key : 'Escape', keyCode: 27, which: 27 });
331331

lib/utils.js

+50-50
Original file line numberDiff line numberDiff line change
@@ -57,56 +57,56 @@ export function fakeRequest (value, cb) {
5757

5858
export function getStates() {
5959
return [
60-
{ abbr: "AL", name: "Alabama"},
61-
{ abbr: "AK", name: "Alaska"},
62-
{ abbr: "AZ", name: "Arizona"},
63-
{ abbr: "AR", name: "Arkansas"},
64-
{ abbr: "CA", name: "California"},
65-
{ abbr: "CO", name: "Colorado"},
66-
{ abbr: "CT", name: "Connecticut"},
67-
{ abbr: "DE", name: "Delaware"},
68-
{ abbr: "FL", name: "Florida"},
69-
{ abbr: "GA", name: "Georgia"},
70-
{ abbr: "HI", name: "Hawaii"},
71-
{ abbr: "ID", name: "Idaho"},
72-
{ abbr: "IL", name: "Illinois"},
73-
{ abbr: "IN", name: "Indiana"},
74-
{ abbr: "IA", name: "Iowa"},
75-
{ abbr: "KS", name: "Kansas"},
76-
{ abbr: "KY", name: "Kentucky"},
77-
{ abbr: "LA", name: "Louisiana"},
78-
{ abbr: "ME", name: "Maine"},
79-
{ abbr: "MD", name: "Maryland"},
80-
{ abbr: "MA", name: "Massachusetts"},
81-
{ abbr: "MI", name: "Michigan"},
82-
{ abbr: "MN", name: "Minnesota"},
83-
{ abbr: "MS", name: "Mississippi"},
84-
{ abbr: "MO", name: "Missouri"},
85-
{ abbr: "MT", name: "Montana"},
86-
{ abbr: "NE", name: "Nebraska"},
87-
{ abbr: "NV", name: "Nevada"},
88-
{ abbr: "NH", name: "New Hampshire"},
89-
{ abbr: "NJ", name: "New Jersey"},
90-
{ abbr: "NM", name: "New Mexico"},
91-
{ abbr: "NY", name: "New York"},
92-
{ abbr: "NC", name: "North Carolina"},
93-
{ abbr: "ND", name: "North Dakota"},
94-
{ abbr: "OH", name: "Ohio"},
95-
{ abbr: "OK", name: "Oklahoma"},
96-
{ abbr: "OR", name: "Oregon"},
97-
{ abbr: "PA", name: "Pennsylvania"},
98-
{ abbr: "RI", name: "Rhode Island"},
99-
{ abbr: "SC", name: "South Carolina"},
100-
{ abbr: "SD", name: "South Dakota"},
101-
{ abbr: "TN", name: "Tennessee"},
102-
{ abbr: "TX", name: "Texas"},
103-
{ abbr: "UT", name: "Utah"},
104-
{ abbr: "VT", name: "Vermont"},
105-
{ abbr: "VA", name: "Virginia"},
106-
{ abbr: "WA", name: "Washington"},
107-
{ abbr: "WV", name: "West Virginia"},
108-
{ abbr: "WI", name: "Wisconsin"},
109-
{ abbr: "WY", name: "Wyoming"}
60+
{ abbr: "AL", name: "Alabama" },
61+
{ abbr: "AK", name: "Alaska" },
62+
{ abbr: "AZ", name: "Arizona" },
63+
{ abbr: "AR", name: "Arkansas" },
64+
{ abbr: "CA", name: "California" },
65+
{ abbr: "CO", name: "Colorado" },
66+
{ abbr: "CT", name: "Connecticut" },
67+
{ abbr: "DE", name: "Delaware" },
68+
{ abbr: "FL", name: "Florida" },
69+
{ abbr: "GA", name: "Georgia" },
70+
{ abbr: "HI", name: "Hawaii" },
71+
{ abbr: "ID", name: "Idaho" },
72+
{ abbr: "IL", name: "Illinois" },
73+
{ abbr: "IN", name: "Indiana" },
74+
{ abbr: "IA", name: "Iowa" },
75+
{ abbr: "KS", name: "Kansas" },
76+
{ abbr: "KY", name: "Kentucky" },
77+
{ abbr: "LA", name: "Louisiana" },
78+
{ abbr: "ME", name: "Maine" },
79+
{ abbr: "MD", name: "Maryland" },
80+
{ abbr: "MA", name: "Massachusetts" },
81+
{ abbr: "MI", name: "Michigan" },
82+
{ abbr: "MN", name: "Minnesota" },
83+
{ abbr: "MS", name: "Mississippi" },
84+
{ abbr: "MO", name: "Missouri" },
85+
{ abbr: "MT", name: "Montana" },
86+
{ abbr: "NE", name: "Nebraska" },
87+
{ abbr: "NV", name: "Nevada" },
88+
{ abbr: "NH", name: "New Hampshire" },
89+
{ abbr: "NJ", name: "New Jersey" },
90+
{ abbr: "NM", name: "New Mexico" },
91+
{ abbr: "NY", name: "New York" },
92+
{ abbr: "NC", name: "North Carolina" },
93+
{ abbr: "ND", name: "North Dakota" },
94+
{ abbr: "OH", name: "Ohio" },
95+
{ abbr: "OK", name: "Oklahoma" },
96+
{ abbr: "OR", name: "Oregon" },
97+
{ abbr: "PA", name: "Pennsylvania" },
98+
{ abbr: "RI", name: "Rhode Island" },
99+
{ abbr: "SC", name: "South Carolina" },
100+
{ abbr: "SD", name: "South Dakota" },
101+
{ abbr: "TN", name: "Tennessee" },
102+
{ abbr: "TX", name: "Texas" },
103+
{ abbr: "UT", name: "Utah" },
104+
{ abbr: "VT", name: "Vermont" },
105+
{ abbr: "VA", name: "Virginia" },
106+
{ abbr: "WA", name: "Washington" },
107+
{ abbr: "WV", name: "West Virginia" },
108+
{ abbr: "WI", name: "Wisconsin" },
109+
{ abbr: "WY", name: "Wyoming" }
110110
]
111111
}
112112

0 commit comments

Comments
 (0)