Skip to content

Commit 7144b23

Browse files
committed
Run prettier
1 parent 21491d3 commit 7144b23

20 files changed

Lines changed: 129 additions & 205 deletions

File tree

client/app/bundles/comments/components/CommentBox/CommentBox.jsx

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ class CommentBox extends BaseComponent {
2929

3030
constructor() {
3131
super();
32-
_.bindAll(this, [
33-
'refreshComments',
34-
]);
32+
_.bindAll(this, ['refreshComments']);
3533
this.cable = null;
3634
}
3735

@@ -42,17 +40,20 @@ class CommentBox extends BaseComponent {
4240
this.cable = ActionCable.createConsumer(cableUrl);
4341

4442
/* eslint no-console: ["error", { allow: ["log"] }] */
45-
this.cable.subscriptions.create({ channel: 'CommentsChannel' }, {
46-
connected: () => {
47-
console.log('connected');
43+
this.cable.subscriptions.create(
44+
{ channel: 'CommentsChannel' },
45+
{
46+
connected: () => {
47+
console.log('connected');
48+
},
49+
disconnected: () => {
50+
console.log('disconnected');
51+
},
52+
received: (comment) => {
53+
messageReceived(Immutable.fromJS(comment));
54+
},
4855
},
49-
disconnected: () => {
50-
console.log('disconnected');
51-
},
52-
received: (comment) => {
53-
messageReceived(Immutable.fromJS(comment));
54-
},
55-
});
56+
);
5657
}
5758

5859
componentDidMount() {
@@ -88,14 +89,14 @@ class CommentBox extends BaseComponent {
8889
{formatMessage(defaultMessages.comments)}
8990
{data.get('isFetching') && formatMessage(defaultMessages.loading)}
9091
</h2>
91-
{ SelectLanguage(actions.setLocale, locale) }
92+
{SelectLanguage(actions.setLocale, locale)}
9293
<ul>
9394
<li>
94-
{ (data.get('isFetching') && <br />) ||
95-
<button type="button" className={css.anchorButton} onClick={this.refreshComments} >
95+
{(data.get('isFetching') && <br />) || (
96+
<button type="button" className={css.anchorButton} onClick={this.refreshComments}>
9697
{formatMessage(defaultMessages.descriptionForceRefrech)}
9798
</button>
98-
}
99+
)}
99100
</li>
100101
<li>{formatMessage(defaultMessages.descriptionSupportMarkdown)}</li>
101102
<li>{formatMessage(defaultMessages.descriptionDeleteRule)}</li>

client/app/bundles/comments/components/CommentBox/CommentForm/CommentForm.jsx

Lines changed: 22 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const emptyComment = { author: '', text: '' };
2626
function bsStyleFor(propName, error) {
2727
if (error) {
2828
const errorData = (error && error.response && error.response.data) || {};
29-
return (propName in errorData) ? 'error' : 'success';
29+
return propName in errorData ? 'error' : 'success';
3030
}
3131

3232
return null;
@@ -48,12 +48,7 @@ class CommentForm extends BaseComponent {
4848
comment: emptyComment,
4949
};
5050

51-
_.bindAll(this, [
52-
'handleSelect',
53-
'handleChange',
54-
'handleSubmit',
55-
'resetAndFocus',
56-
]);
51+
_.bindAll(this, ['handleSelect', 'handleChange', 'handleSubmit', 'resetAndFocus']);
5752
}
5853

5954
handleSelect(selectedKey) {
@@ -94,9 +89,7 @@ class CommentForm extends BaseComponent {
9489
handleSubmit(e) {
9590
e.preventDefault();
9691
const { actions } = this.props;
97-
actions
98-
.submitComment(this.state.comment)
99-
.then(this.resetAndFocus);
92+
actions.submitComment(this.state.comment).then(this.resetAndFocus);
10093
}
10194

10295
resetAndFocus() {
@@ -165,11 +158,7 @@ class CommentForm extends BaseComponent {
165158
</FormGroup>
166159
<FormGroup controlId="formHorizontalSubmit">
167160
<Col smOffset={2} sm={10}>
168-
<Button
169-
type="submit"
170-
className="btn btn-primary"
171-
disabled={this.props.isSaving}
172-
>
161+
<Button type="submit" className="btn btn-primary" disabled={this.props.isSaving}>
173162
{this.props.isSaving
174163
? `${formatMessage(defaultMessages.inputSaving)}...`
175164
: formatMessage(defaultMessages.inputPost)}
@@ -199,9 +188,7 @@ class CommentForm extends BaseComponent {
199188
bsStyle={bsStyleFor('author', this.props.error)}
200189
/>
201190
</FormGroup>
202-
<FormGroup
203-
controlId="formBasicText"
204-
>
191+
<FormGroup controlId="formBasicText">
205192
<ControlLabel>{formatMessage(defaultMessages.inputTextLabel)}</ControlLabel>
206193
<FormControl
207194
type="textarea"
@@ -215,11 +202,7 @@ class CommentForm extends BaseComponent {
215202
/>
216203
</FormGroup>
217204
<FormGroup controlId="formBasicSubmit">
218-
<Button
219-
type="submit"
220-
className="btn btn-primary"
221-
disabled={this.props.isSaving}
222-
>
205+
<Button type="submit" className="btn btn-primary" disabled={this.props.isSaving}>
223206
{this.props.isSaving
224207
? `${formatMessage(defaultMessages.inputSaving)}...`
225208
: formatMessage(defaultMessages.inputPost)}
@@ -237,10 +220,8 @@ class CommentForm extends BaseComponent {
237220
<div>
238221
<hr />
239222
<Form inline className="commentForm" onSubmit={this.handleSubmit}>
240-
<FormGroup controlId="formInlineName" >
241-
<ControlLabel>
242-
{formatMessage(defaultMessages.inputNameLabel)}
243-
</ControlLabel>
223+
<FormGroup controlId="formInlineName">
224+
<ControlLabel>{formatMessage(defaultMessages.inputNameLabel)}</ControlLabel>
244225
<FormControl
245226
type="text"
246227
placeholder={formatMessage(defaultMessages.inputNamePlaceholder)}
@@ -253,9 +234,7 @@ class CommentForm extends BaseComponent {
253234
/>
254235
</FormGroup>
255236
<FormGroup controlId="formInlineName">
256-
<ControlLabel>
257-
{formatMessage(defaultMessages.inputTextLabel)}
258-
</ControlLabel>
237+
<ControlLabel>{formatMessage(defaultMessages.inputTextLabel)}</ControlLabel>
259238
<FormControl
260239
type="textarea"
261240
label="Text"
@@ -268,11 +247,7 @@ class CommentForm extends BaseComponent {
268247
className={css.textFormControl}
269248
/>
270249
</FormGroup>
271-
<Button
272-
type="submit"
273-
className="btn btn-primary"
274-
disabled={this.props.isSaving}
275-
>
250+
<Button type="submit" className="btn btn-primary" disabled={this.props.isSaving}>
276251
{this.props.isSaving
277252
? `${formatMessage(defaultMessages.inputSaving)}...`
278253
: formatMessage(defaultMessages.inputPost)}
@@ -290,16 +265,22 @@ class CommentForm extends BaseComponent {
290265

291266
const errorData = error.response && error.response.data;
292267

293-
const errorElements = _.transform(errorData, (result, errorText, errorFor) => {
294-
result.push(<li key={errorFor}><b>{_.upperFirst(errorFor)}:</b> {errorText}</li>);
295-
}, []);
268+
const errorElements = _.transform(
269+
errorData,
270+
(result, errorText, errorFor) => {
271+
result.push(
272+
<li key={errorFor}>
273+
<b>{_.upperFirst(errorFor)}:</b> {errorText}
274+
</li>,
275+
);
276+
},
277+
[],
278+
);
296279

297280
return (
298281
<Alert bsStyle="danger" key="commentSubmissionError">
299282
<strong>Your comment was not saved!</strong>
300-
<ul>
301-
{errorElements}
302-
</ul>
283+
<ul>{errorElements}</ul>
303284
</Alert>
304285
);
305286
}

client/app/bundles/comments/components/CommentBox/CommentList/Comment/Comment.jsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,8 @@ export default class Comment extends BaseComponent {
1818
/* eslint-disable react/no-danger */
1919
return (
2020
<div className={css.comment}>
21-
<h2 className={`${css.commentAuthor} js-comment-author`}>
22-
{author}
23-
</h2>
24-
<span
25-
dangerouslySetInnerHTML={{ __html: rawMarkup }}
26-
className="js-comment-text"
27-
/>
21+
<h2 className={`${css.commentAuthor} js-comment-author`}>{author}</h2>
22+
<span dangerouslySetInnerHTML={{ __html: rawMarkup }} className="js-comment-text" />
2823
</div>
2924
);
3025
}

client/app/bundles/comments/components/CommentBox/CommentList/Comment/Comment.spec.jsx

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,11 @@ import { React, TestUtils } from '../../../../../../libs/testHelper';
22

33
import Comment from './Comment.jsx';
44

5-
const {
6-
renderIntoDocument,
7-
findRenderedDOMComponentWithClass,
8-
findRenderedDOMComponentWithTag,
9-
} = TestUtils;
5+
const { renderIntoDocument, findRenderedDOMComponentWithClass, findRenderedDOMComponentWithTag } = TestUtils;
106

117
describe('Comment', () => {
128
it('renders an author and comment with proper css classes', () => {
13-
const component = renderIntoDocument(
14-
<Comment author="Frank" text="Hi!" />,
15-
);
9+
const component = renderIntoDocument(<Comment author="Frank" text="Hi!" />);
1610

1711
const comment = findRenderedDOMComponentWithTag(component, 'div');
1812
expect(comment.className).toEqual('comment');
@@ -23,18 +17,14 @@ describe('Comment', () => {
2317
});
2418

2519
it('shows the author', () => {
26-
const component = renderIntoDocument(
27-
<Comment author="Frank" text="Hi!" />,
28-
);
20+
const component = renderIntoDocument(<Comment author="Frank" text="Hi!" />);
2921

3022
const author = findRenderedDOMComponentWithClass(component, 'js-comment-author');
3123
expect(author.textContent).toEqual('Frank');
3224
});
3325

3426
it('shows the comment text in markdown', () => {
35-
const component = renderIntoDocument(
36-
<Comment author="Frank" text="Hi!" />,
37-
);
27+
const component = renderIntoDocument(<Comment author="Frank" text="Hi!" />);
3828

3929
const comment = findRenderedDOMComponentWithClass(component, 'js-comment-text');
4030
expect(comment.textContent).toEqual('Hi!\n');

client/app/bundles/comments/components/CommentBox/CommentList/CommentList.jsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,24 @@ export default class CommentList extends BaseComponent {
2828
if (!this.props.error) return null;
2929
return (
3030
<Alert bsStyle="danger" key="commentFetchError">
31-
<strong>Comments could not be retrieved. </strong>
32-
A server error prevented loading comments. Please try again.
31+
<strong>Comments could not be retrieved. </strong>A server error prevented loading comments. Please
32+
try again.
3333
</Alert>
3434
);
3535
}
3636

3737
render() {
3838
const { $$comments, cssTransitionGroupClassNames } = this.props;
39-
const commentNodes = $$comments.map(($$comment, index) =>
40-
39+
const commentNodes = $$comments.map(($$comment, index) => (
4140
// `key` is a React-specific concept and is not mandatory for the
4241
// purpose of this tutorial. if you're curious, see more here:
4342
// http://facebook.github.io/react/docs/multiple-components.html#dynamic-children
44-
(<Comment
43+
<Comment
4544
key={$$comment.get('id') || index}
4645
author={$$comment.get('author')}
4746
text={$$comment.get('text')}
48-
/>));
47+
/>
48+
));
4949

5050
// For animation with ReactCSSTransitionGroup
5151
// https://facebook.github.io/react/docs/animation.html

client/app/bundles/comments/components/CommentBox/CommentList/CommentList.spec.jsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@ import { React, TestUtils } from '../../../../../libs/testHelper';
44
import CommentList from './CommentList.jsx';
55
import Comment from './Comment/Comment.jsx';
66

7-
const {
8-
renderIntoDocument,
9-
findRenderedDOMComponentWithTag,
10-
scryRenderedComponentsWithType,
11-
} = TestUtils;
7+
const { renderIntoDocument, findRenderedDOMComponentWithTag, scryRenderedComponentsWithType } = TestUtils;
128

139
const cssTransitionGroupClassNames = {
1410
enter: 'elementEnter',
@@ -33,10 +29,7 @@ describe('CommentList', () => {
3329

3430
it('renders a list of Comments in normal order', () => {
3531
const component = renderIntoDocument(
36-
<CommentList
37-
$$comments={comments}
38-
cssTransitionGroupClassNames={cssTransitionGroupClassNames}
39-
/>,
32+
<CommentList $$comments={comments} cssTransitionGroupClassNames={cssTransitionGroupClassNames} />,
4033
);
4134
const list = scryRenderedComponentsWithType(component, Comment);
4235
expect(list.length).toEqual(2);

client/app/bundles/comments/components/CommentScreen/CommentScreen.jsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ export default class CommentScreen extends BaseComponent {
2121
return (
2222
<div className={`bg-success ${css.notification}`}>
2323
You have been redirected from
24-
<strong>
25-
{locationState.redirectFrom}
26-
</strong>
24+
<strong>{locationState.redirectFrom}</strong>
2725
</div>
2826
);
2927
}

client/app/bundles/comments/components/NavigationBar/CommentsCount.jsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33

4-
const href = 'https://github.com/shakacode/react_on_rails/blob/master/README.md#multiple-react-' +
4+
const href =
5+
'https://github.com/shakacode/react_on_rails/blob/master/README.md#multiple-react-' +
56
'components-on-a-page-with-one-store';
67
function CommentsCount(props) {
78
const { commentsCount } = props;
8-
return <li>
9-
<a id="js-comment-count" href={href}>
10-
Comments: {commentsCount}
11-
</a>
12-
</li>
9+
return (
10+
<li>
11+
<a id="js-comment-count" href={href}>
12+
Comments: {commentsCount}
13+
</a>
14+
</li>
15+
);
1316
}
1417

1518
CommentsCount.propTypes = {

client/app/bundles/comments/components/NavigationBar/NavigationBar.jsx

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,33 +28,30 @@ function NavigationBar(props) {
2828
<span className="icon-bar" />
2929
<span className="icon-bar" />
3030
</button>
31-
<a className="navbar-brand" href="http://www.shakacode.com">ShakaCode</a>
31+
<a className="navbar-brand" href="http://www.shakacode.com">
32+
ShakaCode
33+
</a>
3234
</div>
3335
<div className="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
3436
<ul className="nav navbar-nav">
35-
<li className={classNames(
36-
{ active: (pathname === paths.ROUTER_PATH || pathname === paths.REACT_ROUTER_PATH) },
37-
)}>
37+
<li
38+
className={classNames({
39+
active: pathname === paths.ROUTER_PATH || pathname === paths.REACT_ROUTER_PATH,
40+
})}
41+
>
3842
<a href={paths.ROUTER_PATH}>React Router Demo</a>
3943
</li>
40-
<li className={classNames({ active: (pathname === paths.NO_ROUTER_PATH) })}>
44+
<li className={classNames({ active: pathname === paths.NO_ROUTER_PATH })}>
4145
<a href={paths.NO_ROUTER_PATH}>React Demo</a>
4246
</li>
43-
<li className={classNames({ active: (pathname === paths.SIMPLE_REACT_PATH) })}>
47+
<li className={classNames({ active: pathname === paths.SIMPLE_REACT_PATH })}>
4448
<a href={paths.SIMPLE_REACT_PATH}>Simple React</a>
4549
</li>
46-
<li className={classNames({ active: (pathname === paths.RAILS_PATH) })}>
50+
<li className={classNames({ active: pathname === paths.RAILS_PATH })}>
4751
<a href={paths.RAILS_PATH}>Classic Rails</a>
4852
</li>
4953
<li>
50-
<a
51-
href={
52-
'https://github.com/' +
53-
'shakacode/react-webpack-rails-tutorial'
54-
}
55-
>
56-
Source
57-
</a>
54+
<a href="https://github.com/shakacode/react-webpack-rails-tutorial">Source</a>
5855
</li>
5956
<li>
6057
<a href="https://forum.shakacode.com/c/reactjs">Forum</a>

0 commit comments

Comments
 (0)