Skip to content

Commit 139551a

Browse files
AlexKValjustin808
authored andcommitted
Eslint (shakacode#320)
* Clean up js code linting rules These rules can be safely removed: - no-undef - space-before-function-paren - indent - id-length - jsx-quotes - react/display-name - react/jsx-boolean-value - react/jsx-curly-spacing - react/jsx-no-duplicate-props - react/jsx-no-undef - react/jsx-sort-prop-types - react/jsx-sort-props - react/jsx-uses-react - react/jsx-uses-vars - react/no-danger - react/no-did-mount-set-state - react/no-did-update-set-state - react/no-multi-comp - react/no-unknown-property - react/prop-types - react/react-in-jsx-scope - react/self-closing-comp - react/jsx-wrap-multilines - react/sort-comp [rules/react.yml#L5](https://github.com/shakacode/style-guide-javascript/blob/master/packages/eslint-config-shakacode/rules/react.yml#L5) - no-unused-vars [rules/javascript.yml#L14](https://github.com/shakacode/style-guide-javascript/blob/66a6c7100c4/packages/eslint-config-shakacode/rules/javascript.yml#L14) * no-unused-vars rule * no-underscore-dangle
1 parent c489439 commit 139551a

File tree

6 files changed

+38
-70
lines changed

6 files changed

+38
-70
lines changed

client/.eslintrc.yml

-32
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,6 @@ env:
1616
mocha: true
1717

1818
rules:
19-
### Variables
20-
no-undef: 2
21-
no-unused-vars: [2, { vars: all, args: none }]
22-
23-
### Stylistic issues
24-
indent: [1, 2, { SwitchCase: 1, VariableDeclarator: 2 }]
25-
id-length: [1, { min: 2, exceptions: [_, e, i, k, v] }]
26-
space-before-function-paren: [1, "never"]
27-
no-underscore-dangle: 0
28-
2919
### Imports
3020
# Can't do next one because of alias in webpack
3121
import/no-unresolved: 0
@@ -36,25 +26,3 @@ rules:
3626

3727
# https://github.com/eslint/eslint/issues/6876 SFC's marked as invalid
3828
new-cap: 0
39-
40-
### React
41-
jsx-quotes: [1, prefer-double]
42-
react/display-name: 0
43-
react/jsx-boolean-value: [1, always]
44-
react/jsx-curly-spacing: [1, never]
45-
react/jsx-no-duplicate-props: [2, { ignoreCase: true }]
46-
react/jsx-no-undef: 2
47-
react/jsx-sort-prop-types: 0
48-
react/jsx-sort-props: 0
49-
react/jsx-uses-react: 2
50-
react/jsx-uses-vars: 2
51-
react/no-danger: 0
52-
react/no-did-mount-set-state: 1
53-
react/no-did-update-set-state: 0
54-
react/no-multi-comp: 2
55-
react/no-unknown-property: 2
56-
react/prop-types: 1
57-
react/react-in-jsx-scope: 2
58-
react/self-closing-comp: 2
59-
react/sort-comp: 0 # Should be 1. `statics` should be on top.
60-
react/jsx-wrap-multilines: 2

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

+27-27
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,18 @@ export default class CommentForm extends BaseComponent {
2929
};
3030

3131
_.bindAll(this, [
32-
'_handleSelect',
33-
'_handleChange',
34-
'_handleSubmit',
35-
'_resetAndFocus',
32+
'handleSelect',
33+
'handleChange',
34+
'handleSubmit',
35+
'resetAndFocus',
3636
]);
3737
}
3838

39-
_handleSelect(selectedKey) {
39+
handleSelect(selectedKey) {
4040
this.setState({ formMode: selectedKey });
4141
}
4242

43-
_handleChange() {
43+
handleChange() {
4444
let comment;
4545

4646
switch (this.state.formMode) {
@@ -71,15 +71,15 @@ export default class CommentForm extends BaseComponent {
7171
this.setState({ comment });
7272
}
7373

74-
_handleSubmit(e) {
74+
handleSubmit(e) {
7575
e.preventDefault();
7676
const { actions } = this.props;
7777
actions
7878
.submitComment(this.state.comment)
79-
.then(this._resetAndFocus);
79+
.then(this.resetAndFocus);
8080
}
8181

82-
_resetAndFocus() {
82+
resetAndFocus() {
8383
// Don't reset a form that didn't submit, this results in data loss
8484
if (this.props.error) return;
8585

@@ -104,11 +104,11 @@ export default class CommentForm extends BaseComponent {
104104
ref.focus();
105105
}
106106

107-
_formHorizontal() {
107+
formHorizontal() {
108108
return (
109109
<div>
110110
<hr />
111-
<form className="commentForm form-horizontal" onSubmit={this._handleSubmit}>
111+
<form className="commentForm form-horizontal" onSubmit={this.handleSubmit}>
112112
<Input
113113
type="text"
114114
label="Name"
@@ -117,7 +117,7 @@ export default class CommentForm extends BaseComponent {
117117
wrapperClassName="col-sm-10"
118118
ref={node => { this.horizontalAuthorNode = node; }}
119119
value={this.state.comment.author}
120-
onChange={this._handleChange}
120+
onChange={this.handleChange}
121121
disabled={this.props.isSaving}
122122
/>
123123
<Input
@@ -128,7 +128,7 @@ export default class CommentForm extends BaseComponent {
128128
wrapperClassName="col-sm-10"
129129
ref={node => { this.horizontalTextNode = node; }}
130130
value={this.state.comment.text}
131-
onChange={this._handleChange}
131+
onChange={this.handleChange}
132132
disabled={this.props.isSaving}
133133
/>
134134
<div className="form-group">
@@ -146,18 +146,18 @@ export default class CommentForm extends BaseComponent {
146146
);
147147
}
148148

149-
_formStacked() {
149+
formStacked() {
150150
return (
151151
<div>
152152
<hr />
153-
<form className="commentForm form" onSubmit={this._handleSubmit}>
153+
<form className="commentForm form" onSubmit={this.handleSubmit}>
154154
<Input
155155
type="text"
156156
label="Name"
157157
placeholder="Your Name"
158158
ref={node => { this.stackedAuthorNode = node; }}
159159
value={this.state.comment.author}
160-
onChange={this._handleChange}
160+
onChange={this.handleChange}
161161
disabled={this.props.isSaving}
162162
/>
163163
<Input
@@ -166,7 +166,7 @@ export default class CommentForm extends BaseComponent {
166166
placeholder={textPlaceholder}
167167
ref={node => { this.stackedTextNode = node; }}
168168
value={this.state.comment.text}
169-
onChange={this._handleChange}
169+
onChange={this.handleChange}
170170
disabled={this.props.isSaving}
171171
/>
172172
<input
@@ -180,11 +180,11 @@ export default class CommentForm extends BaseComponent {
180180
);
181181
}
182182

183-
_formInline() {
183+
formInline() {
184184
return (
185185
<div>
186186
<hr />
187-
<form className="commentForm form" onSubmit={this._handleSubmit}>
187+
<form className="commentForm form" onSubmit={this.handleSubmit}>
188188
<Input label="Inline Form" wrapperClassName="wrapper">
189189
<Row>
190190
<Col xs={3}>
@@ -194,7 +194,7 @@ export default class CommentForm extends BaseComponent {
194194
placeholder="Your Name"
195195
ref={node => { this.inlineAuthorNode = node; }}
196196
value={this.state.comment.author}
197-
onChange={this._handleChange}
197+
onChange={this.handleChange}
198198
disabled={this.props.isSaving}
199199
/>
200200
</Col>
@@ -205,7 +205,7 @@ export default class CommentForm extends BaseComponent {
205205
placeholder={textPlaceholder}
206206
ref={node => { this.inlineTextNode = node; }}
207207
value={this.state.comment.text}
208-
onChange={this._handleChange}
208+
onChange={this.handleChange}
209209
disabled={this.props.isSaving}
210210
/>
211211
</Col>
@@ -224,7 +224,7 @@ export default class CommentForm extends BaseComponent {
224224
);
225225
}
226226

227-
_errorWarning() {
227+
errorWarning() {
228228
// If there is no error, there is nothing to add to the DOM
229229
if (!this.props.error) return null;
230230
return (
@@ -239,13 +239,13 @@ export default class CommentForm extends BaseComponent {
239239
let inputForm;
240240
switch (this.state.formMode) {
241241
case 0:
242-
inputForm = this._formHorizontal();
242+
inputForm = this.formHorizontal();
243243
break;
244244
case 1:
245-
inputForm = this._formStacked();
245+
inputForm = this.formStacked();
246246
break;
247247
case 2:
248-
inputForm = this._formInline();
248+
inputForm = this.formInline();
249249
break;
250250
default:
251251
throw new Error(`Unknown form mode: ${this.state.formMode}.`);
@@ -260,10 +260,10 @@ export default class CommentForm extends BaseComponent {
260260
transitionEnterTimeout={300}
261261
transitionLeaveTimeout={300}
262262
>
263-
{this._errorWarning()}
263+
{this.errorWarning()}
264264
</ReactCSSTransitionGroup>
265265

266-
<Nav bsStyle="pills" activeKey={this.state.formMode} onSelect={this._handleSelect}>
266+
<Nav bsStyle="pills" activeKey={this.state.formMode} onSelect={this.handleSelect}>
267267
<NavItem eventKey={0}>Horizontal Form</NavItem>
268268
<NavItem eventKey={1}>Stacked Form</NavItem>
269269
<NavItem eventKey={2}>Inline Form</NavItem>

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ export default class CommentList extends BaseComponent {
1717
constructor(props, context) {
1818
super(props, context);
1919
this.state = {};
20-
_.bindAll(this, '_errorWarning');
20+
_.bindAll(this, 'errorWarning');
2121
}
2222

23-
_errorWarning() {
23+
errorWarning() {
2424
// If there is no error, there is nothing to add to the DOM
2525
if (!this.props.error) return null;
2626
return (
@@ -52,7 +52,7 @@ export default class CommentList extends BaseComponent {
5252
transitionEnterTimeout={500}
5353
transitionLeaveTimeout={500}
5454
>
55-
{this._errorWarning()}
55+
{this.errorWarning()}
5656
</ReactCSSTransitionGroup>
5757

5858
<ReactCSSTransitionGroup

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default class CommentScreen extends BaseComponent {
1313
locationState: PropTypes.object,
1414
};
1515

16-
_renderNotification() {
16+
renderNotification() {
1717
const { locationState } = this.props;
1818

1919
if (!locationState || !locationState.redirectFrom) return null;
@@ -30,7 +30,7 @@ export default class CommentScreen extends BaseComponent {
3030

3131
return (
3232
<div>
33-
{this._renderNotification()}
33+
{this.renderNotification()}
3434
<div>
3535
<CommentBox
3636
pollInterval={60000}

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ export default class SimpleCommentScreen extends BaseComponent {
2020
submitCommentError: null,
2121
};
2222

23-
_.bindAll(this, '_fetchComments', '_handleCommentSubmit');
23+
_.bindAll(this, 'fetchComments', 'handleCommentSubmit');
2424
}
2525

2626
componentDidMount() {
27-
this._fetchComments();
27+
this.fetchComments();
2828
}
2929

30-
_fetchComments() {
30+
fetchComments() {
3131
return (
3232
request
3333
.get('comments.json', { responseType: 'json' })
@@ -36,7 +36,7 @@ export default class SimpleCommentScreen extends BaseComponent {
3636
);
3737
}
3838

39-
_handleCommentSubmit(comment) {
39+
handleCommentSubmit(comment) {
4040
this.setState({ isSaving: true });
4141

4242
const requestConfig = {
@@ -84,7 +84,7 @@ export default class SimpleCommentScreen extends BaseComponent {
8484
</p>
8585
<CommentForm
8686
isSaving={this.state.isSaving}
87-
actions={{ submitComment: this._handleCommentSubmit }}
87+
actions={{ submitComment: this.handleCommentSubmit }}
8888
error={this.state.submitCommentError}
8989
cssTransitionGroupClassNames={cssTransitionGroupClassNames}
9090
/>
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export const initialState = {};
22

3-
export default function railsContextReducer(state = initialState, action = null) {
3+
export default function railsContextReducer(state = initialState) {
44
return state;
55
}

0 commit comments

Comments
 (0)