MM-22155 ESLint configuration updates part 1 (#4311)
* MM-22155 Disable no-undefined * MM-22155 Disable react-jsx-filename-extension * MM-22155 Disable no-magic-numbers * MM-22155 Re-enable camelcase * MM-22155 Re-enable no-nested-ternary * Update no-unused-vars to match other repos
This commit is contained in:
parent
81fb199feb
commit
c7ef3fe1d3
16 changed files with 37 additions and 143 deletions
|
|
@ -23,14 +23,23 @@
|
|||
},
|
||||
"rules": {
|
||||
"global-require": 0,
|
||||
"react/display-name": [2, { "ignoreTranspilerName": false }],
|
||||
"react/jsx-filename-extension": [2, {"extensions": [".js"]}],
|
||||
"no-undefined": 0,
|
||||
"no-nested-ternary": 0,
|
||||
"@typescript-eslint/camelcase": 0,
|
||||
"@typescript-eslint/no-undefined": 0,
|
||||
"react/display-name": [2, { "ignoreTranspilerName": false }],
|
||||
"react/jsx-filename-extension": 0,
|
||||
"@typescript-eslint/camelcase": [
|
||||
2,
|
||||
{
|
||||
"properties": "never"
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/no-non-null-assertion": 0,
|
||||
"@typescript-eslint/no-unused-vars": 2,
|
||||
"@typescript-eslint/no-unused-vars": [
|
||||
2,
|
||||
{
|
||||
"vars": "all",
|
||||
"args": "after-used"
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/no-explicit-any": "warn",
|
||||
"@typescript-eslint/no-use-before-define": 0,
|
||||
"@typescript-eslint/no-var-requires": 0,
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import {DeviceTypes} from 'app/constants';
|
|||
export function connection(isOnline) {
|
||||
return async (dispatch, getState) => {
|
||||
const state = getState();
|
||||
if (isOnline !== undefined && isOnline !== state.device.connection) { //eslint-disable-line no-undefined
|
||||
if (isOnline !== undefined && isOnline !== state.device.connection) {
|
||||
dispatch({
|
||||
type: DeviceTypes.CONNECTION_CHANGED,
|
||||
data: isOnline,
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import EventEmitter from '@mm-redux/utils/event_emitter';
|
|||
|
||||
import * as Actions from '@actions/websocket';
|
||||
import {WebsocketEvents} from '@constants';
|
||||
import initial_state from '@store/initial_state';
|
||||
import globalInitialState from '@store/initial_state';
|
||||
|
||||
import TestHelper from 'test/test_helper';
|
||||
import configureStore from 'test/test_store';
|
||||
|
|
@ -415,7 +415,7 @@ describe('Actions.Websocket', () => {
|
|||
it('Websocket Handle Channel Member Updated', async () => {
|
||||
const channelMember = TestHelper.basicChannelMember;
|
||||
const mockStore = configureMockStore([thunk]);
|
||||
const st = mockStore(initial_state);
|
||||
const st = mockStore(globalInitialState);
|
||||
await st.dispatch(Actions.init({websocketUrl: Client4.getUrl().replace(/^http:/, 'ws:')}));
|
||||
channelMember.roles = 'channel_user channel_admin';
|
||||
const rolesToLoad = channelMember.roles.split(' ');
|
||||
|
|
|
|||
|
|
@ -202,12 +202,12 @@ export default class PostBody extends PureComponent {
|
|||
}
|
||||
|
||||
const postId = postProps.add_channel_member.post_id;
|
||||
const noGroupsUsernames = postProps.add_channel_member?.not_in_groups_usernames;
|
||||
let userIds = postProps.add_channel_member?.not_in_channel_user_ids;
|
||||
let usernames = postProps.add_channel_member?.not_in_channel_usernames;
|
||||
const noGroupsUsernames = postProps.add_channel_member?.not_in_groups_usernames; // eslint-disable-line camelcase
|
||||
let userIds = postProps.add_channel_member?.not_in_channel_user_ids; // eslint-disable-line camelcase
|
||||
let usernames = postProps.add_channel_member?.not_in_channel_usernames; // eslint-disable-line camelcase
|
||||
|
||||
if (!userIds) {
|
||||
userIds = postProps.add_channel_member?.user_ids;
|
||||
userIds = postProps.add_channel_member?.user_ids; // eslint-disable-line camelcase
|
||||
}
|
||||
if (!usernames) {
|
||||
usernames = postProps.add_channel_member?.usernames;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ function makeMapStateToProps() {
|
|||
const config = getConfig(state);
|
||||
const post = ownProps.post;
|
||||
const commentedOnPost = ownProps.commentedOnPost;
|
||||
const commentedOnUserId = commentedOnPost?.user_id;
|
||||
const commentedOnUserId = commentedOnPost?.user_id; // eslint-disable-line camelcase
|
||||
const commentedOnUser = commentedOnUserId ? getUser(state, commentedOnUserId) : null;
|
||||
const user = getUser(state, post.user_id) || {};
|
||||
const currentUser = getCurrentUser(state);
|
||||
|
|
|
|||
|
|
@ -296,7 +296,7 @@ describe('Actions.Posts', () => {
|
|||
|
||||
const state = store.getState();
|
||||
const {stats} = state.entities.channels;
|
||||
const pinned_post_count = stats.channel1.pinnedpost_count;
|
||||
const pinnedPostCount = stats.channel1.pinnedpost_count;
|
||||
|
||||
expect(state.entities.posts.posts).toEqual({
|
||||
post1,
|
||||
|
|
@ -310,7 +310,7 @@ describe('Actions.Posts', () => {
|
|||
expect(state.entities.posts.postsInThread).toEqual({
|
||||
post1: ['post4'],
|
||||
});
|
||||
expect(pinned_post_count).toEqual(1);
|
||||
expect(pinnedPostCount).toEqual(1);
|
||||
});
|
||||
|
||||
it('removePostWithReaction', async () => {
|
||||
|
|
@ -1174,11 +1174,11 @@ describe('Actions.Posts', () => {
|
|||
const state = getState();
|
||||
const {stats} = state.entities.channels;
|
||||
const post = state.entities.posts.posts[post1.id];
|
||||
const pinned_post_count = stats[TestHelper.basicChannel.id].pinnedpost_count;
|
||||
const pinnedPostCount = stats[TestHelper.basicChannel.id].pinnedpost_count;
|
||||
|
||||
assert.ok(post);
|
||||
assert.ok(post.is_pinned === true);
|
||||
assert.ok(pinned_post_count === 1);
|
||||
assert.ok(pinnedPostCount === 1);
|
||||
});
|
||||
|
||||
it('unpinPost', async () => {
|
||||
|
|
@ -1218,11 +1218,11 @@ describe('Actions.Posts', () => {
|
|||
const state = getState();
|
||||
const {stats} = state.entities.channels;
|
||||
const post = state.entities.posts.posts[post1.id];
|
||||
const pinned_post_count = stats[TestHelper.basicChannel.id].pinnedpost_count;
|
||||
const pinnedPostCount = stats[TestHelper.basicChannel.id].pinnedpost_count;
|
||||
|
||||
assert.ok(post);
|
||||
assert.ok(post.is_pinned === false);
|
||||
assert.ok(pinned_post_count === 0);
|
||||
assert.ok(pinnedPostCount === 0);
|
||||
});
|
||||
|
||||
it('addReaction', async () => {
|
||||
|
|
|
|||
|
|
@ -473,9 +473,9 @@ export function addUsersToTeamGracefully(teamId: string, userIds: Array<string>)
|
|||
return {error};
|
||||
}
|
||||
|
||||
const added_members = result ? result.filter((m) => !m.error) : [];
|
||||
const profiles: Partial<UserProfile>[] = added_members.map((m) => ({id: m.user_id}));
|
||||
const members = added_members.map((m) => m.member);
|
||||
const addedMembers = result ? result.filter((m) => !m.error) : [];
|
||||
const profiles: Partial<UserProfile>[] = addedMembers.map((m) => ({id: m.user_id}));
|
||||
const members = addedMembers.map((m) => m.member);
|
||||
dispatch(batchActions([
|
||||
{
|
||||
type: UserTypes.RECEIVED_PROFILES_LIST_IN_TEAM,
|
||||
|
|
|
|||
|
|
@ -34,5 +34,5 @@ export default ((url?: string, options: Options = {headers: {}}) => {
|
|||
}
|
||||
|
||||
// all other requests go straight to fetch
|
||||
return Reflect.apply(fetch, undefined, [url, options]); //eslint-disable-line no-undefined
|
||||
return Reflect.apply(fetch, undefined, [url, options]);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import * as action_types from './action_types';
|
||||
import * as actions from './actions';
|
||||
import * as client from './client';
|
||||
import * as constants from './constants';
|
||||
import * as reducers from './reducers';
|
||||
import * as selectors from './selectors';
|
||||
import * as types from './types';
|
||||
import * as utils from './utils';
|
||||
|
||||
export {action_types, actions, client, constants, reducers, selectors, types, utils};
|
||||
|
|
@ -45,9 +45,9 @@ export function getGroupMembers(state: GlobalState, id: string) {
|
|||
return groupMemberData.members;
|
||||
}
|
||||
|
||||
const teamGroupIDs = (state: GlobalState, teamID: string) => (state.entities.teams.groupsAssociatedToTeam[teamID] == null ? undefined : state.entities.teams.groupsAssociatedToTeam[teamID].ids == null ? undefined : state.entities.teams.groupsAssociatedToTeam[teamID].ids) || [];
|
||||
const teamGroupIDs = (state: GlobalState, teamID: string) => state.entities.teams.groupsAssociatedToTeam[teamID]?.ids || [];
|
||||
|
||||
const channelGroupIDs = (state: GlobalState, channelID: string) => (state.entities.channels.groupsAssociatedToChannel[channelID] == null ? undefined : state.entities.channels.groupsAssociatedToChannel[channelID].ids == null ? undefined : state.entities.channels.groupsAssociatedToChannel[channelID].ids) || [];
|
||||
const channelGroupIDs = (state: GlobalState, channelID: string) => state.entities.channels.groupsAssociatedToChannel[channelID]?.ids || [];
|
||||
|
||||
const getTeamGroupIDSet = reselect.createSelector(
|
||||
teamGroupIDs,
|
||||
|
|
|
|||
|
|
@ -1,46 +0,0 @@
|
|||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import * as bots from './bots';
|
||||
import * as channels from './channels';
|
||||
import * as common from './common';
|
||||
import * as emojis from './emojis';
|
||||
import * as files from './files';
|
||||
import * as general from './general';
|
||||
import * as groups from './groups';
|
||||
import * as i18n from './i18n';
|
||||
import * as integrations from './integrations';
|
||||
import * as jobs from './jobs';
|
||||
import * as posts from './posts';
|
||||
import * as preferences from './preferences';
|
||||
import * as roles_helpers from './roles_helpers';
|
||||
import * as roles from './roles';
|
||||
import * as schemes from './schemes';
|
||||
import * as search from './search';
|
||||
import * as teams from './teams';
|
||||
import * as timezone from './timezone';
|
||||
import * as typing from './typing';
|
||||
import * as users from './users';
|
||||
|
||||
export {
|
||||
bots,
|
||||
channels,
|
||||
common,
|
||||
emojis,
|
||||
files,
|
||||
general,
|
||||
groups,
|
||||
i18n,
|
||||
integrations,
|
||||
jobs,
|
||||
posts,
|
||||
preferences,
|
||||
roles_helpers,
|
||||
roles,
|
||||
schemes,
|
||||
search,
|
||||
teams,
|
||||
timezone,
|
||||
typing,
|
||||
users,
|
||||
};
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import * as entities from './entities';
|
||||
import * as errors from './errors';
|
||||
|
||||
export {errors, entities};
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import * as channel_utils from './channel_utils';
|
||||
import * as deep_freeze from './deep_freeze';
|
||||
import * as delayed_action from './delayed_action';
|
||||
import * as emoji_utils from './emoji_utils';
|
||||
import * as event_emitter from './event_emitter';
|
||||
import * as file_utils from './file_utils';
|
||||
import * as gfycat_sdk from './gfycat_sdk';
|
||||
import * as helpers from './helpers';
|
||||
import * as i18n_utils from './i18n_utils';
|
||||
import * as integration_utils from './integration_utils';
|
||||
import * as key_mirror from './key_mirror';
|
||||
import * as notify_props from './notify_props';
|
||||
import * as post_list from './post_list';
|
||||
import * as post_utils from './post_utils';
|
||||
import * as preference_utils from './preference_utils';
|
||||
import * as sentry from './sentry';
|
||||
import * as team_utils from './team_utils';
|
||||
import * as theme_utils from './theme_utils';
|
||||
import * as timezone_utils from './timezone_utils';
|
||||
import * as user_utils from './user_utils';
|
||||
|
||||
export {
|
||||
channel_utils,
|
||||
deep_freeze,
|
||||
delayed_action,
|
||||
emoji_utils,
|
||||
event_emitter,
|
||||
file_utils,
|
||||
gfycat_sdk,
|
||||
helpers,
|
||||
i18n_utils,
|
||||
integration_utils,
|
||||
key_mirror,
|
||||
notify_props,
|
||||
post_list,
|
||||
post_utils,
|
||||
preference_utils,
|
||||
sentry,
|
||||
team_utils,
|
||||
theme_utils,
|
||||
timezone_utils,
|
||||
user_utils,
|
||||
};
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
/* eslint-disable
|
||||
no-magic-numbers */
|
||||
|
||||
import {StyleSheet} from 'react-native';
|
||||
|
||||
export const GlobalStyles = StyleSheet.create({
|
||||
|
|
|
|||
|
|
@ -207,7 +207,7 @@ export function getExtensionFromMime(type) {
|
|||
|
||||
function populateMaps() {
|
||||
// source preference (least -> most)
|
||||
const preference = ['nginx', 'apache', undefined, 'iana']; //eslint-disable-line no-undefined
|
||||
const preference = ['nginx', 'apache', undefined, 'iana'];
|
||||
|
||||
Object.keys(mimeDB).forEach((type) => {
|
||||
const mime = mimeDB[type];
|
||||
|
|
|
|||
|
|
@ -31,6 +31,6 @@ describe('selectFirstAvailableTeam', () => {
|
|||
|
||||
it('should return undefined is no team is found', () => {
|
||||
const defaultTeam = selectFirstAvailableTeam([]);
|
||||
expect(defaultTeam).toBe(undefined); //eslint-disable-line no-undefined
|
||||
expect(defaultTeam).toBe(undefined);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue