Skip to content

Commit 23f2d12

Browse files
committed
Lint sources
1 parent 822d67d commit 23f2d12

File tree

7 files changed

+56
-14
lines changed

7 files changed

+56
-14
lines changed

.eslintrc.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
parser: babel-eslint
3+
env:
4+
browser: true
5+
extends: [airbnb, plugin:react/recommended]
6+
plugins: [import, react]
7+
settings:
8+
import/resolver:
9+
node: {}
10+
webpack:
11+
config: webpack.config.js
12+
13+
rules:
14+
camelcase: off
15+
comma-dangle: [1, only-multiline]
16+
no-else-return: 0
17+
no-param-reassign: 0
18+
quotes: 0
19+
space-infix-ops: 0
20+
no-multiple-empty-lines: ["error", { "max": 2, "maxEOF": 0 }]
21+
no-underscore-dangle: [2, {"allowAfterThis": true}]
22+
object-curly-newline: [2, {"consistent": true}]
23+
operator-linebreak: [1, after]
24+
jsx-a11y/click-events-have-key-events: 0
25+
jsx-a11y/label-has-associated-control: 0
26+
jsx-a11y/control-has-associated-label: 0

static/js/components/Examples.jsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@ class Examples extends React.Component {
1010

1111
_handleSubmit(event) {
1212
event.preventDefault();
13-
this.props.compute(this.n.value);
13+
14+
const { compute } = this.props;
15+
compute(this.n.value);
1416
}
1517

1618
render() {
17-
const resultItems = this.props.results.map((result, index) => (
19+
const { results } = this.props;
20+
const resultItems = results.map((result, index) => (
1821
// eslint-disable-next-line react/no-array-index-key
1922
<li key={index}>{result.join(", ")}</li>
2023
));
@@ -25,7 +28,13 @@ class Examples extends React.Component {
2528

2629
<form onSubmit={this._handleSubmit}>
2730
Calculate squares of &nbsp;
28-
<input type="text" defaultValue="5" size="2" ref={(n) => { this.n = n; }} /> numbers. &nbsp;
31+
<input
32+
type="text"
33+
defaultValue="5"
34+
size="2"
35+
ref={(n) => { this.n = n; }}
36+
/>
37+
numbers. &nbsp;
2938
<input type="submit" value="Go!" />
3039
</form>
3140

static/js/components/Main.jsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import messageHandler from 'baselayer/MessageHandler';
77
import WebSocket from 'baselayer/components/WebSocket';
88
import { Notifications, showNotification } from 'baselayer/components/Notifications';
99

10+
import * as API from 'baselayer/API';
1011
import configureStore from '../store';
1112
import '../customMessageHandler';
1213

@@ -19,7 +20,6 @@ import Examples from '../containers/Examples';
1920

2021
import * as Action from '../actions';
2122

22-
import * as API from 'baselayer/API';
2323

2424
// Set up store and message handling
2525

@@ -38,18 +38,19 @@ class MainContent extends React.Component {
3838
}
3939

4040
render() {
41+
const { root } = this.props;
4142
return (
4243
<div>
4344

4445
<div style={{ float: "right" }}>
4546
<b>WebSocket connection: </b>
4647
<WebSocket
47-
url={`${window.location.protocol === 'https:' ? 'wss' : 'ws'}://${this.props.root}websocket`}
48-
auth_url={`${window.location.protocol}//${this.props.root}baselayer/socket_auth_token`}
48+
url={`${window.location.protocol === 'https:' ? 'wss' : 'ws'}://${root}websocket`}
49+
auth_url={`${window.location.protocol}//${root}baselayer/socket_auth_token`}
4950
messageHandler={messageHandler}
5051
dispatch={store.dispatch}
51-
/>
52-
<Profile />
52+
/>
53+
<Profile />
5354
</div>
5455

5556
<Notifications style={{}} />
@@ -60,6 +61,7 @@ class MainContent extends React.Component {
6061
<h3>Example of a frontend-generated notification</h3>
6162

6263
<button
64+
type="button"
6365
href="#"
6466
onClick={() => store.dispatch(showNotification("Hello from Baselayer"))}
6567
>
@@ -69,6 +71,7 @@ class MainContent extends React.Component {
6971
<h3>Example of a backend-generated notification</h3>
7072

7173
<button
74+
type="button"
7275
href="#"
7376
onClick={() => { store.dispatch(API.GET('/push_notification', 'PUSH_NOTIFICATION')); }}
7477
>

static/js/components/Profile.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ import React from 'react';
22
import PropTypes from 'prop-types';
33

44
const Profile = ({ username }) => (
5-
<div><b>Username:</b> { username }</div>
5+
<div>
6+
<b>Username:</b>
7+
{' '}
8+
{ username }
9+
</div>
610
);
711

812
Profile.propTypes = {

static/js/containers/Examples.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ import * as API from 'baselayer/API';
55
import Examples from '../components/Examples';
66

77

8-
const mapStateToProps = (state, ownProps) => (
8+
const mapStateToProps = (state) => (
99
{
1010
results: state.examples.results
1111
}
1212
);
1313

14-
const mapDispatchToProps = (dispatch, ownProps) => (
14+
const mapDispatchToProps = (dispatch) => (
1515
{
16-
compute: n => dispatch(
16+
compute: (n) => dispatch(
1717
API.POST('/example_compute', 'template_app/SEND_COMPUTE', { n })
1818
)
1919
}

static/js/containers/Profile.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { connect } from 'react-redux';
22

33
import Profile from '../components/Profile';
44

5-
const mapStateToProps = (state, ownProps) => (
5+
const mapStateToProps = (state) => (
66
state.profile
77
);
88

static/js/store.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default function configureStore(preloadedState) {
1818
applyMiddleware(thunk, logger),
1919
// Enable the Chrome developer plugin
2020
// https://github.com/zalmoxisus/redux-devtools-extension
21-
window.devToolsExtension ? window.devToolsExtension() : f => f,
21+
window.devToolsExtension ? window.devToolsExtension() : (f) => f,
2222
)
2323
);
2424
}

0 commit comments

Comments
 (0)