Skip to content

Commit c489439

Browse files
authored
Merge pull request shakacode#317 from shakacode/update-linter
Update Linter
2 parents 05943fa + 21b44ae commit c489439

23 files changed

+1067
-1925
lines changed

client/.eslintrc.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,15 @@ rules:
2727
no-underscore-dangle: 0
2828

2929
### Imports
30+
# Can't do next one because of alias in webpack
3031
import/no-unresolved: 0
32+
import/extensions: [2, { js: "never", jsx: "never" }]
33+
34+
# https://github.com/benmosher/eslint-plugin-import/issues/340
35+
import/no-extraneous-dependencies: 0
36+
37+
# https://github.com/eslint/eslint/issues/6876 SFC's marked as invalid
38+
new-cap: 0
3139

3240
### React
3341
jsx-quotes: [1, prefer-double]
@@ -47,7 +55,6 @@ rules:
4755
react/no-unknown-property: 2
4856
react/prop-types: 1
4957
react/react-in-jsx-scope: 2
50-
react/require-extension: [1, { extensions: [.js, .jsx] }]
5158
react/self-closing-comp: 2
5259
react/sort-comp: 0 # Should be 1. `statics` should be on top.
53-
react/wrap-multilines: 2
60+
react/jsx-wrap-multilines: 2

client/.jscsrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"node_modules/**"
1111
],
1212
"esprima": "babel-jscs",
13+
"requirePaddingNewLinesAfterBlocks": false,
1314
"validateQuoteMarks": {
1415
"mark": "'",
1516
"escape": true,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import BaseComponent from 'libs/components/BaseComponent';
12
import React, { PropTypes } from 'react';
23

34
import CommentForm from './CommentForm/CommentForm';
45
import CommentList from './CommentList/CommentList';
56
import css from './CommentBox.scss';
6-
import BaseComponent from 'libs/components/BaseComponent';
77

88
export default class CommentBox extends BaseComponent {
99
static propTypes = {

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

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React, { PropTypes } from 'react';
2-
import ReactDOM from 'react-dom';
32
import Input from 'react-bootstrap/lib/Input';
43
import Row from 'react-bootstrap/lib/Row';
54
import Col from 'react-bootstrap/lib/Col';
@@ -44,18 +43,29 @@ export default class CommentForm extends BaseComponent {
4443
_handleChange() {
4544
let comment;
4645

47-
if (this.state.formMode < 2) {
48-
comment = {
49-
author: this.refs.author.getValue(),
50-
text: this.refs.text.getValue(),
51-
};
52-
} else {
53-
comment = {
54-
// This is different because the input is a native HTML element
55-
// rather than a React element.
56-
author: this.refs.inlineAuthor.value,
57-
text: this.refs.inlineText.value,
58-
};
46+
switch (this.state.formMode) {
47+
case 0:
48+
comment = {
49+
author: this.horizontalAuthorNode.getValue(),
50+
text: this.horizontalTextNode.getValue(),
51+
};
52+
break;
53+
case 1:
54+
comment = {
55+
author: this.stackedAuthorNode.getValue(),
56+
text: this.stackedTextNode.getValue(),
57+
};
58+
break;
59+
case 2:
60+
comment = {
61+
// This is different because the input is a native HTML element
62+
// rather than a React element.
63+
author: this.inlineAuthorNode.value,
64+
text: this.inlineTextNode.value,
65+
};
66+
break;
67+
default:
68+
throw new Error(`Unexpected state.formMode ${this.state.formMode}`);
5969
}
6070

6171
this.setState({ comment });
@@ -77,10 +87,18 @@ export default class CommentForm extends BaseComponent {
7787
this.setState({ comment });
7888

7989
let ref;
80-
if (this.state.formMode < 2) {
81-
ref = this.refs.text.getInputDOMNode();
82-
} else {
83-
ref = ReactDOM.findDOMNode(this.refs.inlineText);
90+
switch (this.state.formMode) {
91+
case 0:
92+
ref = this.horizontalTextNode.getInputDOMNode();
93+
break;
94+
case 1:
95+
ref = this.stackedTextNode.getInputDOMNode();
96+
break;
97+
case 2:
98+
ref = this.inlineTextNode;
99+
break;
100+
default:
101+
throw new Error(`Unexpected state.formMode ${this.state.formMode}`);
84102
}
85103

86104
ref.focus();
@@ -97,7 +115,7 @@ export default class CommentForm extends BaseComponent {
97115
placeholder="Your Name"
98116
labelClassName="col-sm-2"
99117
wrapperClassName="col-sm-10"
100-
ref="author"
118+
ref={node => { this.horizontalAuthorNode = node; }}
101119
value={this.state.comment.author}
102120
onChange={this._handleChange}
103121
disabled={this.props.isSaving}
@@ -108,7 +126,7 @@ export default class CommentForm extends BaseComponent {
108126
placeholder={textPlaceholder}
109127
labelClassName="col-sm-2"
110128
wrapperClassName="col-sm-10"
111-
ref="text"
129+
ref={node => { this.horizontalTextNode = node; }}
112130
value={this.state.comment.text}
113131
onChange={this._handleChange}
114132
disabled={this.props.isSaving}
@@ -137,7 +155,7 @@ export default class CommentForm extends BaseComponent {
137155
type="text"
138156
label="Name"
139157
placeholder="Your Name"
140-
ref="author"
158+
ref={node => { this.stackedAuthorNode = node; }}
141159
value={this.state.comment.author}
142160
onChange={this._handleChange}
143161
disabled={this.props.isSaving}
@@ -146,7 +164,7 @@ export default class CommentForm extends BaseComponent {
146164
type="textarea"
147165
label="Text"
148166
placeholder={textPlaceholder}
149-
ref="text"
167+
ref={node => { this.stackedTextNode = node; }}
150168
value={this.state.comment.text}
151169
onChange={this._handleChange}
152170
disabled={this.props.isSaving}
@@ -174,7 +192,7 @@ export default class CommentForm extends BaseComponent {
174192
type="text"
175193
className="form-control"
176194
placeholder="Your Name"
177-
ref="inlineAuthor"
195+
ref={node => { this.inlineAuthorNode = node; }}
178196
value={this.state.comment.author}
179197
onChange={this._handleChange}
180198
disabled={this.props.isSaving}
@@ -185,7 +203,7 @@ export default class CommentForm extends BaseComponent {
185203
type="text"
186204
className="form-control"
187205
placeholder={textPlaceholder}
188-
ref="inlineText"
206+
ref={node => { this.inlineTextNode = node; }}
189207
value={this.state.comment.text}
190208
onChange={this._handleChange}
191209
disabled={this.props.isSaving}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import BaseComponent from 'libs/components/BaseComponent';
12
import React, { PropTypes } from 'react';
2-
import marked from 'marked';
33

4+
import marked from 'marked';
45
import css from './Comment.scss';
5-
import BaseComponent from 'libs/components/BaseComponent';
66

77
export default class Comment extends BaseComponent {
88
static propTypes = {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import React, { PropTypes } from 'react';
2-
import Immutable from 'immutable';
31
import Alert from 'react-bootstrap/lib/Alert';
2+
import BaseComponent from 'libs/components/BaseComponent';
3+
import Immutable from 'immutable';
4+
import React, { PropTypes } from 'react';
45
import ReactCSSTransitionGroup from 'react/lib/ReactCSSTransitionGroup';
56
import _ from 'lodash';
67

78
import Comment from './Comment/Comment';
8-
import BaseComponent from 'libs/components/BaseComponent';
99

1010
export default class CommentList extends BaseComponent {
1111
static propTypes = {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import React, { PropTypes } from 'react';
22

3+
import BaseComponent from 'libs/components/BaseComponent';
4+
35
import CommentBox from '../CommentBox/CommentBox';
46
import css from './CommentScreen.scss';
5-
import BaseComponent from 'libs/components/BaseComponent';
67

78
export default class CommentScreen extends BaseComponent {
89

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

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
const href = 'https://github.com/shakacode/react_on_rails/blob/master/README.md#multiple-react-' +
44
'components-on-a-page-with-one-store';
55
const CommentsCount = (props) => (
66
<li>
7-
<a id='js-comment-count' href={href}>
7+
<a id="js-comment-count" href={href}>
88
Comments: {props.commentsCount}
99
</a>
1010
</li>

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

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
import React, {PropTypes} from 'react';
2-
import ReactOnRails from 'react-on-rails';
1+
// https://github.com/eslint/eslint/issues/6876
2+
// eslint-disable new-cap
3+
34
import classNames from 'classnames';
5+
import React, { PropTypes } from 'react';
6+
47
import CommentsCount from './CommentsCount';
58
import * as paths from '../../constants/paths';
69

@@ -18,9 +21,9 @@ const NavigationBar = (props) => {
1821
data-target="#bs-example-navbar-collapse-1"
1922
>
2023
<span className="sr-only">Toggle navigation</span>
21-
<span className="icon-bar"/>
22-
<span className="icon-bar"/>
23-
<span className="icon-bar"/>
24+
<span className="icon-bar" />
25+
<span className="icon-bar" />
26+
<span className="icon-bar" />
2427
</button>
2528
<a className="navbar-brand" href="http://www.shakacode.com">ShakaCode</a>
2629
</div>
@@ -39,27 +42,33 @@ const NavigationBar = (props) => {
3942
<a href={paths.RAILS_PATH}>Classic Rails</a>
4043
</li>
4144
<li>
42-
<a href={
45+
<a
46+
href={
4347
'https://github.com/' +
4448
'shakacode/react-webpack-rails-tutorial'
45-
}>
49+
}
50+
>
4651
Source on Github
4752
</a>
4853
</li>
4954
<li>
50-
<a href={
55+
<a
56+
href={
5157
'http://www.railsonmaui.com/' +
5258
'blog/2014/10/03/integrating' +
5359
'-webpack-and-the-es6-transpiler' +
5460
'-into-an-existing-rails-project/'
55-
}>Tutorials</a>
61+
}
62+
>Tutorials</a>
5663
</li>
5764
<li>
58-
<a href={
65+
<a
66+
href={
5967
'http://forum.shakacode.com/' +
6068
't/fast-rich-client-rails-development' +
6169
'-with-webpack-and-the-es6-transpiler/82/22'
62-
}>Forum</a>
70+
}
71+
>Forum</a>
6372
</li>
6473
{commentsCount && CommentsCount({ commentsCount })}
6574
</ul>

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ import Immutable from 'immutable';
33
import request from 'axios';
44
import _ from 'lodash';
55

6+
import BaseComponent from 'libs/components/BaseComponent';
67
import metaTagsManager from 'libs/metaTagsManager';
8+
79
import CommentForm from '../CommentBox/CommentForm/CommentForm';
810
import CommentList from '../CommentBox/CommentList/CommentList';
911
import css from './SimpleCommentScreen.scss';
10-
import BaseComponent from 'libs/components/BaseComponent';
1112

1213
export default class SimpleCommentScreen extends BaseComponent {
1314
constructor(props, context) {

0 commit comments

Comments
 (0)