Skip to content

Commit

Permalink
PLT-8378 Run 'make check-style' on all js and jsx files (mattermost#492)
Browse files Browse the repository at this point in the history
* Removed deprecated ESLint rule

* Added .js files to style check

* Fixed ESLint styles

* Removed warnings for methods that don't use 'this'

* Fixed code style in webpack config

* Update 'make check-style' to check all js and jsx files

* Fixed code style

* Updates snapshots

* Additional style fixes
  • Loading branch information
hmhealey committed Jan 2, 2018
1 parent 8a886c4 commit f30237d
Show file tree
Hide file tree
Showing 79 changed files with 585 additions and 599 deletions.
6 changes: 3 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"it": true,
"expect": true,
"before": true,
"after": true
"after": true,
"beforeEach": true
},
"settings": {
"import/resolver": "webpack"
Expand All @@ -43,7 +44,7 @@
"brace-style": [2, "1tbs", { "allowSingleLine": false }],
"camelcase": [2, {"properties": "never"}],
"capitalized-comments": 0,
"class-methods-use-this": 1,
"class-methods-use-this": 0,
"comma-dangle": [2, "never"],
"comma-spacing": [2, {"before": false, "after": true}],
"comma-style": [2, "last"],
Expand Down Expand Up @@ -227,7 +228,6 @@
"react/jsx-no-target-blank": 2,
"react/jsx-no-undef": 2,
"react/jsx-pascal-case": 2,
"react/jsx-space-before-closing": [2, "never"],
"react/jsx-tag-spacing": [2, { "closingSlash": "never", "beforeSelfClosing": "never", "afterOpening": "never" }],
"react/jsx-uses-react": 2,
"react/jsx-uses-vars": 2,
Expand Down
20 changes: 10 additions & 10 deletions actions/integration_actions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -246,16 +246,16 @@ export function getSuggestedCommands(command, suggestionId, component) {

export function getYoutubeVideoInfo(googleKey, videoId, success, error) {
request.get('https://www.googleapis.com/youtube/v3/videos').
query({part: 'snippet', id: videoId, key: googleKey}).
end((err, res) => {
if (err) {
return error(err);
}
query({part: 'snippet', id: videoId, key: googleKey}).
end((err, res) => {
if (err) {
return error(err);
}

if (!res.body) {
console.error('Missing response body for getYoutubeVideoInfo'); // eslint-disable-line no-console
}
if (!res.body) {
console.error('Missing response body for getYoutubeVideoInfo'); // eslint-disable-line no-console
}

return success(res.body);
});
return success(res.body);
});
}
6 changes: 4 additions & 2 deletions actions/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,13 @@ export function storageRehydrate(incoming) {
return async (dispatch, persistor) => {
persistor.pause();
Object.keys(incoming).forEach((key) => {
let storage = {};
const storage = {};
try {
storage[key] = JSON.parse(incoming[key]);
} catch (err) {
if (process.env.NODE_ENV !== 'production') console.warn(`Error rehydrating data for key "storage"`, err)
if (process.env.NODE_ENV !== 'production') { // eslint-disable-line no-process-env
console.warn('Error rehydrating data for key "storage"', err); // eslint-disable-line no-console
}
}
dispatch({
type: StorageTypes.STORAGE_REHYDRATE,
Expand Down
10 changes: 5 additions & 5 deletions actions/views/create_comment.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import {makeGetMessageInHistoryItem, makeGetCommentCountForPost, getPost} from '
import {getCustomEmojisByName} from 'mattermost-redux/selectors/entities/emojis';

import {
addReaction,
removeReaction,
addMessageIntoHistory,
moveHistoryIndexBack,
moveHistoryIndexForward
addReaction,
removeReaction,
addMessageIntoHistory,
moveHistoryIndexBack,
moveHistoryIndexForward
} from 'mattermost-redux/actions/posts';

import {Posts} from 'mattermost-redux/constants';
Expand Down
12 changes: 7 additions & 5 deletions actions/views/modals.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

import {ActionTypes} from 'utils/constants';
import * as Utils from 'utils/utils';

export function openModal(modalData) {
return (dispatch, getState) => {
return (dispatch) => {
const action = {
type: ActionTypes.MODAL_OPEN,
modalId: modalData.modalId,
Expand All @@ -15,12 +17,12 @@ export function openModal(modalData) {
}

export function closeModal(modalId) {
return (dispatch, getState) => {
return (dispatch) => {
const action = {
type: ActionTypes.MODAL_CLOSE,
modalId: modalId
modalId
};

dispatch(action);
};
}
}
6 changes: 3 additions & 3 deletions actions/views/rhs.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export function getFlaggedPosts() {
await PostActions.getProfilesAndStatusesForPosts(result.posts, dispatch, getState);

const searchActions = getSearchActions(result, teamId);

dispatch(batchActions(searchActions));
};
}
Expand All @@ -154,7 +154,7 @@ export function showFlaggedPosts() {
let result;
try {
result = await Client4.getFlaggedPosts(userId, '', teamId);
} catch(error) {
} catch (error) {
dispatch({type: ActionTypes.SEARCH_FLAGGED_POSTS_FAILURE, error});
}

Expand Down Expand Up @@ -201,7 +201,7 @@ export function showPinnedPosts(channelId) {
let result;
try {
result = await Client4.getPinnedPosts(channelId || currentChannelId);
} catch(error) {
} catch (error) {
dispatch({type: ActionTypes.SEARCH_PINNED_POSTS_FAILURE, error});
}

Expand Down
13 changes: 7 additions & 6 deletions components/admin_console/admin_navbar_dropdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@

import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';

import {deferNavigation} from 'actions/admin_actions.jsx';
import {getNavigationBlocked} from 'selectors/views/admin';

import {getNavigationBlocked} from 'selectors/views/admin';

import AdminNavbarDropdown from './admin_navbar_dropdown.jsx';

function mapStateToProps(state, ownProps) {
function mapStateToProps(state) {
return {
...ownProps,
navigationBlocked: getNavigationBlocked(state)
navigationBlocked: getNavigationBlocked(state)
};
};
}

function mapDispatchToProps(dispatch) {
return {
Expand All @@ -23,4 +24,4 @@ function mapDispatchToProps(dispatch) {
};
}

export default connect(mapStateToProps, mapDispatchToProps)(AdminNavbarDropdown);
export default connect(mapStateToProps, mapDispatchToProps)(AdminNavbarDropdown);
9 changes: 4 additions & 5 deletions components/admin_console/blockable_link/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@

import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';

import {deferNavigation} from 'actions/admin_actions.jsx';
import {getNavigationBlocked} from 'selectors/views/admin';

import * as Selectors from 'mattermost-redux/selectors/entities/admin';
import {getNavigationBlocked} from 'selectors/views/admin';

import BlockableLink from './blockable_link.jsx';

function mapStateToProps(state, ownProps) {
function mapStateToProps(state) {
return {
...ownProps,
blocked: getNavigationBlocked(state),
blocked: getNavigationBlocked(state)
};
}

Expand Down
3 changes: 1 addition & 2 deletions components/admin_console/custom_plugin_settings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
// See License.txt for license information.

import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';

import CustomPluginSettings from './custom_plugin_settings.jsx';

function mapStateToProps(state, ownProps) {
const pluginId = ownProps.routeParams.plugin_id;

return {
...ownProps,
plugin: state.entities.admin.plugins[pluginId]
};
}
Expand Down
5 changes: 2 additions & 3 deletions components/admin_console/jobs/table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {JobStatuses} from 'utils/constants.jsx';
import * as Utils from 'utils/utils.jsx';

class JobTable extends React.PureComponent {

static propTypes = {

/**
Expand All @@ -27,7 +26,7 @@ class JobTable extends React.PureComponent {

actions: PropTypes.shape({

/**
/**
* Function to fetch jobs
*/
getJobsByType: PropTypes.func.isRequired
Expand Down Expand Up @@ -75,7 +74,7 @@ class JobTable extends React.PureComponent {
componentDidMount() {
this.props.actions.getJobsByType(this.props.jobType).then(
() => this.setState({loading: false})
);
);
}

componentWillUnmount() {
Expand Down
4 changes: 2 additions & 2 deletions components/backstage/backstage_controller.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ export default class BackstageController extends React.Component {
onTeamChange() {
const team = TeamStore.getCurrent();

this.state = {
this.setState({
team,
isAdmin: UserStore.isSystemAdminForCurrentUser(this.props.user) ||
TeamStore.isTeamAdminForCurrentTeam(team)
};
});
}

render() {
Expand Down
1 change: 0 additions & 1 deletion components/bootstrap_span.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import PropTypes from 'prop-types';
import React from 'react';

class BootstrapSpan extends React.PureComponent {

static propTypes = {
children: PropTypes.element
}
Expand Down
4 changes: 2 additions & 2 deletions components/channel_view/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {createSelector} from 'reselect';
import {get} from 'mattermost-redux/selectors/entities/preferences';

import {getDirectTeammate} from 'utils/utils.jsx';
import {Constants, TutorialSteps, Preferences} from 'utils/constants.jsx';
import {TutorialSteps, Preferences} from 'utils/constants.jsx';

import ChannelView from './channel_view.jsx';

Expand All @@ -21,7 +21,7 @@ const getDeactivatedChannel = createSelector(
}
);

function mapStateToProps(state, ownProps) {
function mapStateToProps(state) {
const channelId = state.entities.channels.currentChannelId;

return {
Expand Down
2 changes: 1 addition & 1 deletion components/create_comment/create_comment.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default class CreateComment extends React.PureComponent {
*/
ctrlSend: PropTypes.bool,

/**
/**
* The id of the latest post in this channel
*/
latestPostId: PropTypes.string,
Expand Down
2 changes: 1 addition & 1 deletion components/create_comment/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import CreateComment from './create_comment.jsx';

function mapStateToProps(state, ownProps) {
const err = state.requests.posts.createPost.error || {};

const getCommentDraft = makeGetCommentDraft(ownProps.rootId);

const draft = getCommentDraft(state);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ export default function deferComponentRender(WrappedComponent, PreRenderComponen

componentDidMount() {
window.requestAnimationFrame(() => {
window.requestAnimationFrame(() => this.setState({ shouldRender: true }));
window.requestAnimationFrame(() => this.setState({shouldRender: true}));
});
}

render() {
return this.state.shouldRender ? <WrappedComponent {...this.props} /> : PreRenderComponent;
return this.state.shouldRender ? <WrappedComponent {...this.props}/> : PreRenderComponent;
}
}

Expand Down
5 changes: 2 additions & 3 deletions components/edit_post_modal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {bindActionCreators} from 'redux';

import {addMessageIntoHistory} from 'mattermost-redux/actions/posts';
import {Preferences} from 'mattermost-redux/constants';
import {getBool} from 'mattermost-redux/selectors/entities/preferences';
import {getConfig} from 'mattermost-redux/selectors/entities/general';
import {getBool} from 'mattermost-redux/selectors/entities/preferences';

import {setEditingPost} from 'actions/post_actions';
import {editPost} from 'actions/views/edit_post_modal';
Expand All @@ -16,9 +16,8 @@ import {getEditingPost} from 'selectors/posts';

import EditPostModal from './edit_post_modal.jsx';

function mapStateToProps(state, ownProps) {
function mapStateToProps(state) {
return {
...ownProps,
ctrlSend: getBool(state, Preferences.CATEGORY_ADVANCED_SETTINGS, 'send_on_ctrl_enter'),
config: getConfig(state),
editingPost: getEditingPost(state)
Expand Down
2 changes: 1 addition & 1 deletion components/file_attachment_list/file_attachment_list.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export default class FileAttachmentList extends React.Component {
key={`fileCount-${i}`}
className='post-image__column post-image__column--placeholder'
/>
);
);
}
}

Expand Down
2 changes: 1 addition & 1 deletion components/header_footer_template/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ function mapStateToProps(state, ownProps) {
...ownProps,
config: getConfig(state)
};
};
}

export default connect(mapStateToProps)(NotLoggedIn);
Loading

0 comments on commit f30237d

Please sign in to comment.