Skip to content

Commit 555ee4e

Browse files
reconstructionsjustin808
authored andcommitted
Updated Eslint Packages and Fixed All Lint Errors (shakacode#368)
1 parent fc1262e commit 555ee4e

File tree

10 files changed

+95
-89
lines changed

10 files changed

+95
-89
lines changed

Diff for: client/app/bundles/comments/components/CommentBox/CommentBox.jsx

+24-18
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
import BaseComponent from 'libs/components/BaseComponent';
21
import React, { PropTypes } from 'react';
3-
import { FormattedMessage, injectIntl, intlShape } from 'react-intl';
4-
import CommentForm from './CommentForm/CommentForm';
5-
import CommentList, { CommentPropTypes } from './CommentList/CommentList';
6-
import css from './CommentBox.scss';
72
import Immutable from 'immutable';
83
import ActionCable from 'actioncable';
9-
import { SelectLanguage } from 'libs/i18n/selectLanguage';
4+
import _ from 'lodash';
5+
import BaseComponent from 'libs/components/BaseComponent';
6+
import { injectIntl, intlShape } from 'react-intl';
7+
import SelectLanguage from 'libs/i18n/selectLanguage';
108
import { defaultMessages, defaultLocale } from 'libs/i18n/default';
119

10+
import CommentForm from './CommentForm/CommentForm';
11+
import CommentList, { CommentPropTypes } from './CommentList/CommentList';
12+
import css from './CommentBox.scss';
13+
1214
class CommentBox extends BaseComponent {
1315
static propTypes = {
1416
pollInterval: PropTypes.number.isRequired,
@@ -34,18 +36,21 @@ class CommentBox extends BaseComponent {
3436

3537
subscribeChannel() {
3638
const { messageReceived } = this.props.actions;
37-
const protocol = window.location.protocol === "https:" ? "wss://" : "ws://"
38-
this.cable = ActionCable.createConsumer(protocol+window.location.hostname+":"+window.location.port+"/cable");
39-
this.cable.subscriptions.create({channel: "CommentsChannel"}, {
39+
const protocol = window.location.protocol === 'https:' ? 'wss://' : 'ws://';
40+
const cableUrl = `${protocol}${window.location.hostname}:${window.location.port}/cable`;
41+
this.cable = ActionCable.createConsumer(cableUrl);
42+
43+
/* eslint no-console: ["error", { allow: ["log"] }] */
44+
this.cable.subscriptions.create({ channel: 'CommentsChannel' }, {
4045
connected: () => {
41-
console.log("connected")
46+
console.log('connected');
4247
},
4348
disconnected: () => {
44-
console.log("disconnected")
49+
console.log('disconnected');
4550
},
4651
received: (comment) => {
4752
messageReceived(Immutable.fromJS(comment));
48-
}
53+
},
4954
});
5055
}
5156

@@ -56,7 +61,7 @@ class CommentBox extends BaseComponent {
5661
}
5762

5863
componentWillUnmount() {
59-
this.cable.subscriptions.remove({ channel: "CommentsChannel" });
64+
this.cable.subscriptions.remove({ channel: 'CommentsChannel' });
6065
}
6166

6267
refreshComments() {
@@ -75,6 +80,7 @@ class CommentBox extends BaseComponent {
7580
};
7681
const locale = data.get('locale') || defaultLocale;
7782

83+
/* eslint-disable no-script-url */
7884
return (
7985
<div className="commentBox container">
8086
<h2>
@@ -84,11 +90,11 @@ class CommentBox extends BaseComponent {
8490
{ SelectLanguage(actions.setLocale, locale) }
8591
<ul>
8692
<li>
87-
{data.get('isFetching') && <br/> ||
88-
<a href="javascript:void(0)" onClick={this.refreshComments}>
89-
{formatMessage(defaultMessages.descriptionForceRefrech)}
90-
</a>
91-
}
93+
{ (data.get('isFetching') && <br />) ||
94+
<a href="javascript:void(0)" onClick={this.refreshComments}>
95+
{formatMessage(defaultMessages.descriptionForceRefrech)}
96+
</a>
97+
}
9298
</li>
9399
<li>{formatMessage(defaultMessages.descriptionSupportMarkdown)}</li>
94100
<li>{formatMessage(defaultMessages.descriptionDeleteRule)}</li>

Diff for: client/app/bundles/comments/components/CommentBox/CommentForm/CommentForm.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ class CommentForm extends BaseComponent {
294294
}, []);
295295

296296
return (
297-
<Alert bsStyle='danger' key='commentSubmissionError'>
297+
<Alert bsStyle="danger" key="commentSubmissionError">
298298
<strong>Your comment was not saved!</strong>
299299
<ul>
300300
{errorElements}
@@ -336,7 +336,7 @@ class CommentForm extends BaseComponent {
336336
{this.errorWarning()}
337337
</ReactCSSTransitionGroup>
338338

339-
<Nav bsStyle='pills' activeKey={this.state.formMode} onSelect={this.handleSelect}>
339+
<Nav bsStyle="pills" activeKey={this.state.formMode} onSelect={this.handleSelect}>
340340
<NavItem eventKey={0}>{formatMessage(defaultMessages.formHorizontal)}</NavItem>
341341
<NavItem eventKey={1}>{formatMessage(defaultMessages.formStacked)}</NavItem>
342342
<NavItem eventKey={2}>{formatMessage(defaultMessages.formInline)}</NavItem>

Diff for: client/app/bundles/comments/components/SimpleCommentScreen/SimpleCommentScreen.jsx

+38-38
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,17 @@
1+
import React from 'react';
12
import request from 'axios';
23
import Immutable from 'immutable';
34
import _ from 'lodash';
4-
import React from 'react';
55
import ReactOnRails from 'react-on-rails';
6-
import { IntlProvider, injectIntl, intlShape } from 'react-intl';
6+
import { IntlProvider, injectIntl } from 'react-intl';
77
import BaseComponent from 'libs/components/BaseComponent';
8+
import SelectLanguage from 'libs/i18n/selectLanguage';
9+
import { defaultMessages, defaultLocale } from 'libs/i18n/default';
10+
import { translations } from 'libs/i18n/translations';
811

912
import CommentForm from '../CommentBox/CommentForm/CommentForm';
1013
import CommentList from '../CommentBox/CommentList/CommentList';
1114
import css from './SimpleCommentScreen.scss';
12-
import { SelectLanguage } from 'libs/i18n/selectLanguage';
13-
import { defaultMessages, defaultLocale } from 'libs/i18n/default';
14-
import { translations } from 'libs/i18n/translations';
15-
16-
export default class I18nWrapper extends BaseComponent {
17-
constructor(props) {
18-
super(props);
19-
20-
this.state = {
21-
locale: defaultLocale,
22-
};
23-
24-
_.bindAll(this, 'handleSetLocale');
25-
}
26-
27-
handleSetLocale(locale) {
28-
this.setState({ locale: locale });
29-
}
30-
31-
render() {
32-
const { locale } = this.state;
33-
const messages = translations[locale];
34-
const InjectedSimpleCommentScreen = injectIntl(SimpleCommentScreen);
35-
36-
return (
37-
<IntlProvider locale={locale} key={locale} messages={messages}>
38-
<InjectedSimpleCommentScreen
39-
{...this.props}
40-
locale={locale}
41-
handleSetLocale={this.handleSetLocale}
42-
/>
43-
</IntlProvider>
44-
);
45-
}
46-
}
4715

4816
class SimpleCommentScreen extends BaseComponent {
4917
constructor(props) {
@@ -113,7 +81,7 @@ class SimpleCommentScreen extends BaseComponent {
11381
};
11482

11583
return (
116-
<div className='commentBox container'>
84+
<div className="commentBox container">
11785
<h2>
11886
{formatMessage(defaultMessages.comments)}
11987
</h2>
@@ -138,3 +106,35 @@ class SimpleCommentScreen extends BaseComponent {
138106
);
139107
}
140108
}
109+
110+
export default class I18nWrapper extends BaseComponent {
111+
constructor(props) {
112+
super(props);
113+
114+
this.state = {
115+
locale: defaultLocale,
116+
};
117+
118+
_.bindAll(this, 'handleSetLocale');
119+
}
120+
121+
handleSetLocale(locale) {
122+
this.setState({ locale });
123+
}
124+
125+
render() {
126+
const { locale } = this.state;
127+
const messages = translations[locale];
128+
const InjectedSimpleCommentScreen = injectIntl(SimpleCommentScreen);
129+
130+
return (
131+
<IntlProvider locale={locale} key={locale} messages={messages}>
132+
<InjectedSimpleCommentScreen
133+
{...this.props}
134+
locale={locale}
135+
handleSetLocale={this.handleSetLocale}
136+
/>
137+
</IntlProvider>
138+
);
139+
}
140+
}

Diff for: client/app/bundles/comments/containers/NonRouterCommentsContainer.jsx

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
import React, { PropTypes } from 'react';
22
import { connect } from 'react-redux';
33
import { bindActionCreators } from 'redux';
4-
54
import BaseComponent from 'libs/components/BaseComponent';
6-
7-
import CommentScreen from '../components/CommentScreen/CommentScreen';
8-
import * as commentsActionCreators from '../actions/commentsActionCreators';
95
import { IntlProvider } from 'react-intl';
106
import { translations } from 'libs/i18n/translations';
117
import { defaultLocale } from 'libs/i18n/default';
12-
138
// polyfill for server-side rendering, required by react-intl
149
import Intl from 'intl';
10+
11+
import CommentScreen from '../components/CommentScreen/CommentScreen';
12+
import * as commentsActionCreators from '../actions/commentsActionCreators';
13+
1514
global.Intl = Intl;
1615

1716
function select(state) {

Diff for: client/app/bundles/comments/containers/RouterCommentsContainer.jsx

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
import React, { PropTypes } from 'react';
22
import { connect } from 'react-redux';
33
import { bindActionCreators } from 'redux';
4-
5-
import BaseComponent from 'libs/components/BaseComponent';
64
import { IntlProvider } from 'react-intl';
5+
import Intl from 'intl';
6+
import { defaultLocale } from 'libs/i18n/default';
7+
import { translations } from 'libs/i18n/translations';
8+
import BaseComponent from 'libs/components/BaseComponent';
9+
710
import CommentScreen from '../components/CommentScreen/CommentScreen';
811
import * as commentsActionCreators from '../actions/commentsActionCreators';
9-
import { translations } from 'libs/i18n/translations';
10-
import { defaultLocale } from 'libs/i18n/default';
1112

12-
// polyfill for server-side rendering, required by react-intl
13-
import Intl from 'intl';
1413
global.Intl = Intl;
1514

1615
function select(state) {

Diff for: client/app/bundles/comments/startup/clientRegistration.jsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import ReactOnRails from 'react-on-rails';
22

3+
import { addLocaleData } from 'react-intl';
4+
import en from 'react-intl/locale-data/en';
5+
import de from 'react-intl/locale-data/de';
6+
import ja from 'react-intl/locale-data/ja';
7+
import zh from 'react-intl/locale-data/zh';
8+
39
import App from './App';
410
import RouterApp from './ClientRouterApp';
511
import SimpleCommentScreen from '../components/SimpleCommentScreen/SimpleCommentScreen';
612
import routerCommentsStore from '../store/routerCommentsStore';
713
import commentsStore from '../store/commentsStore';
814
import NavigationBarApp from './NavigationBarApp';
915

10-
import { addLocaleData } from 'react-intl';
11-
import en from 'react-intl/locale-data/en';
12-
import de from 'react-intl/locale-data/de';
13-
import ja from 'react-intl/locale-data/ja';
14-
import zh from 'react-intl/locale-data/zh';
15-
1616
// Initizalize all locales for react-intl.
1717
addLocaleData([...en, ...de, ...ja, ...zh]);
1818

Diff for: client/app/libs/components/BaseComponent.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import React from 'react';
22

3-
export default class BaseComponent extends React.PureComponent {
4-
};
3+
/* eslint-disable react/prefer-stateless-function */
4+
export default class BaseComponent extends React.PureComponent { }

Diff for: client/app/libs/i18n/selectLanguage.jsx

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import React from 'react';
22

3+
import { defaultLocale } from 'libs/i18n/default';
4+
35
const SelectLanguage = (onChange, locale = defaultLocale) => (
46
<select onChange={(e) => onChange(e.target.value)} value={locale} >
5-
<option value='en'>English</option>
6-
<option value='de'>Deutsch</option>
7-
<option value='ja'>日本語</option>
8-
<option value='zh-CN'>简体中文</option>
9-
<option value='zh-TW'>正體中文</option>
7+
<option value="en">English</option>
8+
<option value="de">Deutsch</option>
9+
<option value="ja">日本語</option>
10+
<option value="zh-CN">简体中文</option>
11+
<option value="zh-TW">正體中文</option>
1012
</select>
1113
);
1214

13-
export { SelectLanguage };
15+
export default SelectLanguage;

Diff for: client/package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,12 @@
9696
"body-parser": "^1.15.2",
9797
"chai": "^3.5.0",
9898
"chai-immutable": "^1.6.0",
99-
"eslint": "^3.10.2",
100-
"eslint-config-shakacode": "^13.2.0-beta.1",
101-
"eslint-import-resolver-webpack": "^0.7.0",
99+
"eslint": "^3.18.0",
100+
"eslint-config-shakacode": "^14.1.1",
101+
"eslint-import-resolver-webpack": "^0.8.1",
102102
"eslint-plugin-import": "^2.2.0",
103-
"eslint-plugin-jsx-a11y": "^2.2.3",
104-
"eslint-plugin-react": "^6.7.1",
103+
"eslint-plugin-jsx-a11y": "^4.0.0",
104+
"eslint-plugin-react": "^6.10.3",
105105
"estraverse-fb": "^1.3.1",
106106
"express": "^4.14.0",
107107
"jsdom": "^9.8.3",

Diff for: lib/tasks/linters.rake

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ if %w(development test).include? Rails.env
3838

3939
desc "eslint"
4040
task :eslint do
41-
cmd = "cd client && $(npm bin)/eslint . -- --ext .jsx,.js"
41+
cmd = "npm run lint"
4242
puts "Running eslint via `#{cmd}`"
4343
sh cmd
4444
end

0 commit comments

Comments
 (0)