Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Linter & Remove Unsafe React Lifecycle Events #553

Closed
wants to merge 15 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

add linting for prefer-object-spread and fix resulting linting errors

  • Loading branch information
IAmThePan committed Apr 29, 2020
commit 8d37082d9591de536dcde05b5efafb2aa19a09cf
@@ -72,7 +72,7 @@ module.exports = {
'no-unused-vars': [1],
'no-useless-escape': [1],
'operator-linebreak': [0],
'prefer-object-spread': [0], // TODO: enable this check
'prefer-object-spread': ['error'],
'space-before-function-paren': [2, 'never'],
'template-curly-spacing': [0],

@@ -39,61 +39,62 @@ export default (state = initialState, action) => {
case UPDATE_PANEL_DATA: {
const { account } = action.data;
if (account === null) {
return Object.assign({}, initialState);
return { ...initialState };
}
const {
userID, user, userSettings, subscriptionData
} = account;
return Object.assign({}, state, {
return {
...state,
loggedIn: true,
userID,
user,
userSettings,
subscriptionData,
});
subscriptionData
};
}
case REGISTER_SUCCESS:
case LOGIN_SUCCESS: {
return Object.assign({}, state, {
loggedIn: true,
});
return { ...state, loggedIn: true };
}
case LOGOUT_SUCCESS: {
return Object.assign({}, initialState);
return { ...initialState };
}
case GET_USER_SUCCESS: {
const { user } = action.payload;
return Object.assign({}, state, {
return {
...state,
loggedIn: true,
user
});
};
}
case GET_USER_SETTINGS_SUCCESS: {
const { settings } = action.payload;
return Object.assign({}, state, {
return {
...state,
loggedIn: true,
userSettings: settings
});
};
}
case GET_USER_SUBSCRIPTION_DATA_FAIL: {
const { subscriptionData } = initialState;
return Object.assign({}, state, {
subscriptionData,
});
return { ...state, subscriptionData };
}
case GET_USER_SUBSCRIPTION_DATA_SUCCESS: {
const { subscriptionData } = action.payload;
return Object.assign({}, state, {
return {
...state,
loggedIn: true,
subscriptionData
});
};
}
case RESET_PASSWORD_SUCCESS: {
const toastMessage = t('banner_check_your_email_title');
return Object.assign({}, state, {
return {
...state,
toastMessage,
resetPasswordError: false
});
};
}
case RESET_PASSWORD_FAIL: {
const { errors } = action.payload;
@@ -108,10 +109,11 @@ export default (state = initialState, action) => {
errorText = t('server_error_message');
}
});
return Object.assign({}, state, {
return {
...state,
toastMessage: errorText,
resetPasswordError: true
});
};
}

default: return state;
@@ -19,12 +19,13 @@ function AppViewReducer(state = initialState, action) {
switch (action.type) {
case SET_TOAST: {
const { toastMessage, toastClass } = action.data;
return Object.assign({}, state, {
app: Object.assign({}, {
return {
...state,
app: {
toastMessage,
toastClass
}),
});
}
};
}
default: return state;
}
@@ -23,7 +23,7 @@ import AppViewReducer from './AppViewReducer';
* @return {function} this function returns a plain object, which will be merged into the component's props
* @memberof HubContainers
*/
const mapStateToProps = state => Object.assign({}, state.app);
const mapStateToProps = state => ({ ...state.app });

/**
* Bind the component's action creators using Redux's bindActionCreators.
@@ -32,7 +32,7 @@ const mapStateToProps = state => Object.assign({}, state.app);
* @memberof SetupContainers
*/
const mapDispatchToProps = dispatch => ({
actions: bindActionCreators(Object.assign({}, { setToast }), dispatch),
actions: bindActionCreators({ setToast }, dispatch),
});

export const reducer = AppViewReducer;
@@ -24,7 +24,7 @@ import { setToast } from '../AppView/AppViewActions';
* @return {function} this function returns a plain object, which will be merged into the component's props
* @memberof HubContainers
*/
const mapStateToProps = state => Object.assign({}, state.account);
const mapStateToProps = state => ({ ...state.account });

/**
* Bind the component's action creators using Redux's bindActionCreators.
@@ -33,11 +33,11 @@ const mapStateToProps = state => Object.assign({}, state.account);
* @memberof SetupContainers
*/
const mapDispatchToProps = dispatch => ({
actions: bindActionCreators(Object.assign({}, {
actions: bindActionCreators({
setToast,
register,
getUser,
}), dispatch),
getUser
}, dispatch),
});

export default connect(mapStateToProps, mapDispatchToProps)(CreateAccountViewContainer);
@@ -23,26 +23,25 @@ function HomeViewReducer(state = initialState, action) {
tutorial_complete,
enable_metrics,
} = action.data;
return Object.assign({}, state, {
home: Object.assign({}, state.home, {
return {
...state,
home: {
...state.home,
setup_complete,
tutorial_complete,
enable_metrics,
}),
});
enable_metrics
}
};
}
case MARK_PREMIUM_PROMO_MODAL_SHOWN: {
return Object.assign({}, state, {
home: Object.assign({}, state.home, {
premium_promo_modal_shown: true,
})
});
return {
...state,
home: { ...state.home, premium_promo_modal_shown: true }
};
}
case SET_METRICS: {
const { enable_metrics } = action.data;
return Object.assign({}, state, {
home: Object.assign({}, state.home, { enable_metrics }),
});
return { ...state, home: { ...state.home, enable_metrics } };
}

default: return state;
@@ -25,7 +25,7 @@ import { getUser } from '../../../Account/AccountActions';
* @return {function} this function returns a plain object, which will be merged into the component's props
* @memberof HubContainers
*/
const mapStateToProps = state => Object.assign({}, state.home, state.account);
const mapStateToProps = state => ({ ...state.home, ...state.account });

/**
* Bind the component's action creators using Redux's bindActionCreators.
@@ -34,7 +34,7 @@ const mapStateToProps = state => Object.assign({}, state.home, state.account);
* @memberof SetupContainers
*/
const mapDispatchToProps = dispatch => ({
actions: bindActionCreators(Object.assign({}, HomeViewActions, { getUser }), dispatch),
actions: bindActionCreators({ ...HomeViewActions, getUser }, dispatch),
});

export const reducer = HomeViewReducer;
@@ -25,7 +25,7 @@ import { setToast } from '../AppView/AppViewActions';
* @return {function} this function returns a plain object, which will be merged into the component's props
* @memberof HubContainers
*/
const mapStateToProps = state => Object.assign({}, state.account);
const mapStateToProps = state => ({ ...state.account });

/**
* Bind the component's action creators using Redux's bindActionCreators.
@@ -34,13 +34,13 @@ const mapStateToProps = state => Object.assign({}, state.account);
* @memberof SetupContainers
*/
const mapDispatchToProps = dispatch => ({
actions: bindActionCreators(Object.assign({}, {
actions: bindActionCreators({
setToast,
login,
getUser,
getUserSettings,
getTheme,
}), dispatch),
getTheme
}, dispatch),
});

export default connect(mapStateToProps, mapDispatchToProps)(LogInViewContainer);
@@ -24,7 +24,7 @@ import { getUser } from '../../../Account/AccountActions';
* @return {function} this function returns a plain object, which will be merged into the component's props
* @memberof HubContainers
*/
const mapStateToProps = state => Object.assign({}, state.account);
const mapStateToProps = state => ({ ...state.account });

/**
* Bind the component's action creators using Redux's bindActionCreators.
@@ -33,10 +33,10 @@ const mapStateToProps = state => Object.assign({}, state.account);
* @memberof TutorialContainers
*/
const mapDispatchToProps = dispatch => ({
actions: bindActionCreators(Object.assign({}, {
actions: bindActionCreators({
sendPing,
getUser,
}), dispatch),
getUser
}, dispatch),
});

export default connect(mapStateToProps, mapDispatchToProps)(PlusViewContainer);
@@ -24,7 +24,7 @@ import { sendPing } from '../AppView/AppViewActions';
* @memberof TutorialContainers
*/
const mapDispatchToProps = dispatch => ({
actions: bindActionCreators(Object.assign({}, { sendPing }), dispatch),
actions: bindActionCreators({ sendPing }, dispatch),
});

export default connect(null, mapDispatchToProps)(ProductsViewContainer);
@@ -32,9 +32,7 @@ function SetupViewReducer(state = initialState, action) {
case GET_SETUP_SHOW_WARNING_OVERRIDE: // Same as SET_SETUP_SHOW_WARNING_OVERRIDE
case SET_SETUP_SHOW_WARNING_OVERRIDE: {
const { setup_show_warning_override } = action.data;
return Object.assign({}, state, {
setup: Object.assign({}, state.setup, { setup_show_warning_override }),
});
return { ...state, setup: { ...state.setup, setup_show_warning_override } };
}
case INIT_SETUP_PROPS: {
const {
@@ -56,7 +54,8 @@ function SetupViewReducer(state = initialState, action) {
textNext,
textDone,
} = navigation;
return Object.assign({}, state, {
return {
...state,
setup: {
navigation: {
activeIndex,
@@ -74,8 +73,8 @@ function SetupViewReducer(state = initialState, action) {
enable_smart_block,
enable_ghostery_rewards,
enable_human_web,
},
});
}
};
}
case SET_SETUP_NAVIGATION: {
const {
@@ -87,8 +86,10 @@ function SetupViewReducer(state = initialState, action) {
textNext,
textDone,
} = action.data;
return Object.assign({}, state, {
setup: Object.assign({}, state.setup, {
return {
...state,
setup: {
...state.setup,
navigation: {
activeIndex,
hrefPrev,
@@ -97,51 +98,39 @@ function SetupViewReducer(state = initialState, action) {
textPrev,
textNext,
textDone,
},
}),
});
}
}
};
}

// Setup Blocking View
case SET_BLOCKING_POLICY: {
const { blockingPolicy } = action.data;
return Object.assign({}, state, {
setup: Object.assign({}, state.setup, { blockingPolicy }),
});
return { ...state, setup: { ...state.setup, blockingPolicy } };
}

// Setup Anti-Suite View
case SET_ANTI_TRACKING: {
const { enable_anti_tracking } = action.data;
return Object.assign({}, state, {
setup: Object.assign({}, state.setup, { enable_anti_tracking }),
});
return { ...state, setup: { ...state.setup, enable_anti_tracking } };
}
case SET_AD_BLOCK: {
const { enable_ad_block } = action.data;
return Object.assign({}, state, {
setup: Object.assign({}, state.setup, { enable_ad_block }),
});
return { ...state, setup: { ...state.setup, enable_ad_block } };
}
case SET_SMART_BLOCK: {
const { enable_smart_block } = action.data;
return Object.assign({}, state, {
setup: Object.assign({}, state.setup, { enable_smart_block }),
});
return { ...state, setup: { ...state.setup, enable_smart_block } };
}
case SET_GHOSTERY_REWARDS: {
const { enable_ghostery_rewards } = action.data;
return Object.assign({}, state, {
setup: Object.assign({}, state.setup, { enable_ghostery_rewards }),
});
return { ...state, setup: { ...state.setup, enable_ghostery_rewards } };
}

// Setup Human Web View
case SET_HUMAN_WEB: {
const { enable_human_web } = action.data;
return Object.assign({}, state, {
setup: Object.assign({}, state.setup, { enable_human_web }),
});
return { ...state, setup: { ...state.setup, enable_human_web } };
}

default: return state;
ProTip! Use n and p to navigate between commits in a pull request.