Skip to content

Commit 0cfe4dc

Browse files
committed
fix: run lint --fix
1 parent 1e88eff commit 0cfe4dc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1375
-890
lines changed

.eslintrc.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ module.exports = {
6565
// https://github.com/kriasoft/react-starter-kit/pull/961
6666
'react/prefer-stateless-function': 'off',
6767

68+
'react/jsx-no-bind': 'off',
69+
'react/forbid-prop-types': 'off',
70+
6871
// ESLint plugin for prettier formatting
6972
// https://github.com/prettier/eslint-plugin-prettier
7073
'prettier/prettier': [

.stylelintrc.js

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
// stylelint configuration
1111
// https://stylelint.io/user-guide/configuration/
1212
module.exports = {
13-
1413
// The standard config based on a handful of CSS style guides
1514
// https://github.com/stylelint/stylelint-config-standard
1615
extends: 'stylelint-config-standard',
@@ -22,21 +21,27 @@ module.exports = {
2221
],
2322

2423
rules: {
25-
'property-no-unknown': [true, {
26-
ignoreProperties: [
27-
// CSS Modules composition
28-
// https://github.com/css-modules/css-modules#composition
29-
'composes',
30-
],
31-
}],
24+
'property-no-unknown': [
25+
true,
26+
{
27+
ignoreProperties: [
28+
// CSS Modules composition
29+
// https://github.com/css-modules/css-modules#composition
30+
'composes',
31+
],
32+
},
33+
],
3234

33-
'selector-pseudo-class-no-unknown': [true, {
34-
ignorePseudoClasses: [
35-
// CSS Modules :global scope
36-
// https://github.com/css-modules/css-modules#exceptions
37-
'global',
38-
],
39-
}],
35+
'selector-pseudo-class-no-unknown': [
36+
true,
37+
{
38+
ignorePseudoClasses: [
39+
// CSS Modules :global scope
40+
// https://github.com/css-modules/css-modules#exceptions
41+
'global',
42+
],
43+
},
44+
],
4045

4146
// Opinionated rule, you can disable it if you want
4247
'string-quotes': 'single',

jest.config.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ module.exports = {
2222
// collectCoverage: false, // [boolean]
2323

2424
// https://facebook.github.io/jest/docs/en/configuration.html#collectcoveragefrom-array
25-
collectCoverageFrom: ['src/**/*.{js,jsx}', '!**/node_modules/**', '!**/vendor/**'],
25+
collectCoverageFrom: [
26+
'src/**/*.{js,jsx}',
27+
'!**/node_modules/**',
28+
'!**/vendor/**',
29+
],
2630

2731
// https://facebook.github.io/jest/docs/en/configuration.html#coveragedirectory-string
2832
coverageDirectory: '<rootDir>/coverage', // [string]
@@ -48,7 +52,8 @@ module.exports = {
4852
// like images or styles with a single module.
4953
moduleNameMapper: {
5054
'\\.(css|less|scss|sss)$': 'identity-obj-proxy',
51-
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': 'GlobalImageStub',
55+
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
56+
'GlobalImageStub',
5257
},
5358

5459
// modulePathIgnorePatterns: // [array<string>]
@@ -77,7 +82,8 @@ module.exports = {
7782

7883
transform: {
7984
'\\.jsx?$': 'babel-jest',
80-
'\\.(jpe?g|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '<rootDir>/jest/fileTransformer.js',
85+
'\\.(jpe?g|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
86+
'<rootDir>/jest/fileTransformer.js',
8187
},
8288

8389
// transformIgnorePatterns: // [array<string>]

src/DOMUtils.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
*/
99

1010
export function updateTag(tagName, keyName, keyValue, attrName, attrValue) {
11-
const node = document.head.querySelector(`${tagName}[${keyName}="${keyValue}"]`);
11+
const node = document.head.querySelector(
12+
`${tagName}[${keyName}="${keyValue}"]`,
13+
);
1214
if (node && node.getAttribute(attrName) === attrValue) return;
1315

1416
// Remove and create a new tag in order to make it work with bookmarks in Safari

src/actions/posts.js

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ export const FETCH_POSTS_REQUEST = 'FETCH_POSTS_REQUEST';
66
export const FETCH_POSTS_SUCCESS = 'FETCH_POSTS_SUCCESS';
77
export const FETCH_POSTS_FAILURE = 'FETCH_POSTS_FAILURE';
88

9-
109
function createPostInitial() {
1110
return {
1211
type: CREATE_POST_INITIAL,
@@ -41,7 +40,7 @@ function createPostError(message) {
4140
function requestFetchPosts() {
4241
return {
4342
type: FETCH_POSTS_REQUEST,
44-
isFetching: true
43+
isFetching: true,
4544
};
4645
}
4746

@@ -61,7 +60,7 @@ function fetchPostsError(message) {
6160
};
6261
}
6362

64-
export function createPost(post) {
63+
export function createPost(postData) {
6564
const config = {
6665
method: 'post',
6766
headers: {
@@ -70,7 +69,7 @@ export function createPost(post) {
7069
},
7170
body: JSON.stringify({
7271
query: `mutation {
73-
addPost(title: "${post.title}", content: "${post.content}"){
72+
addPost(title: "${postData.title}", content: "${postData.content}"){
7473
id,
7574
title,
7675
content
@@ -80,26 +79,27 @@ export function createPost(post) {
8079
credentials: 'include',
8180
};
8281

83-
return (dispatch) => {
82+
return dispatch => {
8483
// We dispatch requestCreatePost to kickoff the call to the API
85-
dispatch(requestCreatePost(post));
84+
dispatch(requestCreatePost(postData));
8685

8786
return fetch('/graphql', config)
88-
.then(response =>
89-
response.json().then(post => ({ post, response })),
90-
).then(({ post, response }) => {
87+
.then(response => response.json().then(post => ({ post, response })))
88+
.then(({ post, response }) => {
9189
if (!response.ok) {
9290
// If there was a problem, we want to
9391
// dispatch the error condition
9492
dispatch(createPostError(post.message));
9593
return Promise.reject(post);
9694
}
97-
// Dispatch the success action
95+
// Dispatch the success action
9896
dispatch(createPostSuccess(post));
9997
setTimeout(() => {
10098
dispatch(createPostInitial());
10199
}, 5000);
102-
}).catch(err => console.log('Error: ', err));
100+
return Promise.resolve(post);
101+
})
102+
.catch(err => console.error('Error: ', err));
103103
};
104104
}
105105

@@ -116,21 +116,27 @@ export function fetchPosts() {
116116
credentials: 'include',
117117
};
118118

119-
return (dispatch) => {
119+
return dispatch => {
120120
dispatch(requestFetchPosts());
121121

122122
return fetch('/graphql', config)
123123
.then(response =>
124-
response.json().then(response => ({ posts: response.data.posts, response })),
125-
).then(({ posts, response }) => {
126-
if (!response.data.posts) {
124+
response.json().then(responseJson => ({
125+
posts: responseJson.data.posts,
126+
responseJson,
127+
})),
128+
)
129+
.then(({ posts, responseJson }) => {
130+
if (!responseJson.data.posts) {
127131
// If there was a problem, we want to
128132
// dispatch the error condition
129133
dispatch(fetchPostsError(posts.message));
130134
return Promise.reject(posts);
131135
}
132136
// Dispatch the success action
133137
dispatch(fetchPostsSuccess(posts));
134-
}).catch(err => console.log('Error: ', err));
138+
return Promise.resolve(posts);
139+
})
140+
.catch(err => console.error('Error: ', err));
135141
};
136142
}

src/actions/user.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ export const LOGOUT_REQUEST = 'LOGOUT_REQUEST';
55
export const LOGOUT_SUCCESS = 'LOGOUT_SUCCESS';
66
export const LOGOUT_FAILURE = 'LOGOUT_FAILURE';
77

8-
98
function requestLogin(creds) {
109
return {
1110
type: LOGIN_REQUEST,
@@ -51,7 +50,7 @@ export function receiveLogout() {
5150

5251
// Logs the user out
5352
export function logoutUser() {
54-
return (dispatch) => {
53+
return dispatch => {
5554
dispatch(requestLogout());
5655
localStorage.removeItem('id_token');
5756
document.cookie = 'id_token=;expires=Thu, 01 Jan 1970 00:00:01 GMT;';
@@ -67,14 +66,13 @@ export function loginUser(creds) {
6766
body: `login=${creds.login}&password=${creds.password}`,
6867
};
6968

70-
return (dispatch) => {
69+
return dispatch => {
7170
// We dispatch requestLogin to kickoff the call to the API
7271
dispatch(requestLogin(creds));
7372

7473
return fetch('/login', config)
75-
.then(response =>
76-
response.json().then(user => ({ user, response })),
77-
).then(({ user, response }) => {
74+
.then(response => response.json().then(user => ({ user, response })))
75+
.then(({ user, response }) => {
7876
if (!response.ok) {
7977
// If there was a problem, we want to
8078
// dispatch the error condition
@@ -84,8 +82,10 @@ export function loginUser(creds) {
8482
// in posts create new action and check http status, if malign logout
8583
// If login was successful, set the token in local storage
8684
localStorage.setItem('id_token', user.id_token);
87-
// Dispatch the success action
85+
// Dispatch the success action
8886
dispatch(receiveLogin(user));
89-
}).catch(err => console.log('Error: ', err));
87+
return Promise.resolve(user);
88+
})
89+
.catch(err => console.error('Error: ', err));
9090
};
9191
}

src/client.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import React from 'react';
1212
import ReactDOM from 'react-dom';
1313
import { Router } from 'react-router';
1414
import deepForceUpdate from 'react-deep-force-update';
15-
import queryString from 'query-string';
1615
import { createPath } from 'history/PathUtils';
1716
import history from './history';
1817
import App from './components/App';
@@ -31,7 +30,9 @@ const context = {
3130
insertCss: (...styles) => {
3231
// eslint-disable-next-line no-underscore-dangle
3332
const removeCss = styles.map(x => x._insertCss());
34-
return () => { removeCss.forEach(f => f()); };
33+
return () => {
34+
removeCss.forEach(f => f());
35+
};
3536
},
3637
// Universal HTTP client
3738
fetch: createFetch(self.fetch, {
@@ -110,9 +111,7 @@ async function onLocationChange(location, action) {
110111
}
111112

112113
appInstance = ReactDOM.render(
113-
<Router
114-
history={history}
115-
>
114+
<Router history={history}>
116115
<App store={context.store} context={context} />
117116
</Router>,
118117
container,

src/components/App.js

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,11 @@ import loadNotFound from 'bundle-loader?lazy!../pages/notFound/NotFound';
2222
import LayoutComponent from '../components/Layout/Layout';
2323
import LoginComponent from '../pages/login/Login';
2424

25-
2625
// import { auth } from '../config';
2726

2827
const RegisterBundle = Bundle.generateBundle(loadRegister);
2928
const NotFoundBundle = Bundle.generateBundle(loadNotFound);
3029

31-
3230
const ContextType = {
3331
// Enables critical path CSS rendering
3432
// https://github.com/kriasoft/isomorphic-style-loader
@@ -40,44 +38,33 @@ const ContextType = {
4038
...ReduxProvider.childContextTypes,
4139
};
4240

43-
// let isAuthenticated = function() {
44-
// let t = jwt.verify(cookie.load('id_token'), auth.jwt.secret);
45-
//
46-
// console.log(t);
47-
//
48-
// return true;
49-
// };
50-
51-
52-
const PrivateRoute = ({ component, isAuthenticated, ...rest }) => (
41+
/* eslint-disable */
42+
const PrivateRoute = ({ component, isAuthenticated, ...rest }) =>
5343
<Route
54-
{...rest} render={props => (
55-
isAuthenticated ? (
56-
React.createElement(component, props)
57-
) : (
58-
<Redirect
59-
to={{
60-
pathname: '/login',
61-
state: { from: props.location },
62-
}}
63-
/>
64-
)
65-
)}
66-
/>
67-
);
44+
{...rest}
45+
render={props =>
46+
isAuthenticated
47+
? React.createElement(component, props)
48+
: <Redirect
49+
to={{
50+
pathname: '/login',
51+
state: { from: props.location },
52+
}}
53+
/>}
54+
/>;
55+
/* eslint-enable */
6856

6957
class App extends React.PureComponent {
70-
7158
static propTypes = {
7259
context: PropTypes.shape(ContextType),
73-
store: PropTypes.any,
60+
isAuthenticated: PropTypes.bool,
7461
};
7562

7663
static defaultProps = {
7764
context: null,
65+
isAuthenticated: false,
7866
};
7967

80-
8168
static contextTypes = {
8269
router: PropTypes.any,
8370
store: PropTypes.any,
@@ -94,7 +81,11 @@ class App extends React.PureComponent {
9481
return (
9582
<Switch>
9683
<Route path="/" exact render={() => <Redirect to="/app" />} />
97-
<PrivateRoute isAuthenticated={this.props.isAuthenticated} path="/app" component={LayoutComponent} />
84+
<PrivateRoute
85+
isAuthenticated={this.props.isAuthenticated}
86+
path="/app"
87+
component={LayoutComponent}
88+
/>
9889
<Route path="/login" exact component={LoginComponent} />
9990
<Route path="/register" exact component={RegisterBundle} />
10091
<Route component={NotFoundBundle} />

0 commit comments

Comments
 (0)