diff --git a/.eslintrc.js b/.eslintrc.js
index d1af6c8b8..98d8b4329 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -40,7 +40,7 @@ module.exports = {
rules: {
'arrow-parens': [2, 'as-needed', { 'requireForBlockBody': true }],
'camelcase': [0],
- 'class-methods-use-this': [0],
+ 'class-methods-use-this': [1],
'comma-dangle': [2, {
'arrays': 'only-multiline',
'objects': 'only-multiline',
@@ -54,24 +54,30 @@ module.exports = {
'lines-between-class-members': [1],
'max-len': [0],
'newline-per-chained-call': [0, { 'ignoreChainWithDepth': 2 }],
- 'no-mixed-operators': [0],
+ 'no-mixed-operators': [1],
'no-nested-ternary': [0],
- 'no-param-reassign': [0], // TODO: enable this check
+ 'no-param-reassign': ['error', {
+ props: true,
+ ignorePropertyModificationsFor: [
+ 'acc', // for reduce accumulators
+ 'trackerEl', // for trackers.forEach()
+ 'categoryEl' // for categories.forEach()
+ ]
+ }],
'no-plusplus': [0],
- 'no-prototype-builtins': [0], // TODO: enable this check
- 'no-restricted-syntax': [0], // TODO: enable this check
+ 'no-prototype-builtins': [1],
+ 'no-restricted-syntax': [1],
'no-tabs': [0],
'no-underscore-dangle': [0],
'no-unused-vars': [1],
'no-useless-escape': [1],
'operator-linebreak': [0],
- 'prefer-object-spread': [0], // TODO: enable this check
+ 'prefer-object-spread': [1],
'space-before-function-paren': [2, 'never'],
- 'template-curly-spacing': [0],
// Plugin: Import
'import/no-cycle': [0],
- 'import/prefer-default-export': [0],
+ 'import/prefer-default-export': [1],
// Plugin: React
'react/destructuring-assignment': [0],
@@ -79,12 +85,12 @@ module.exports = {
'react/jsx-curly-newline': [0],
'react/jsx-indent': [1, 'tab'],
'react/jsx-indent-props': [1, 'tab'],
- 'react/jsx-props-no-spreading': [0], // TODO: enable this check
- 'react/no-access-state-in-setstate': [0], // TODO: enable this check
+ 'react/jsx-props-no-spreading': [1],
+ 'react/no-access-state-in-setstate': [1],
'react/no-danger': [0],
'react/prop-types': [0],
'react/jsx-fragments': [1, 'element'],
- 'react/sort-comp': [2, {
+ 'react/sort-comp': [0, { //TODO: enable this check
order: [
"static-variables",
"instance-variables",
diff --git a/app/Account/AccountReducer.js b/app/Account/AccountReducer.js
index 48076f6b0..8365f113a 100644
--- a/app/Account/AccountReducer.js
+++ b/app/Account/AccountReducer.js
@@ -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;
diff --git a/app/content-scripts/blocked_redirect.js b/app/content-scripts/blocked_redirect.js
index 0a4185f1a..e94acc1de 100644
--- a/app/content-scripts/blocked_redirect.js
+++ b/app/content-scripts/blocked_redirect.js
@@ -40,7 +40,8 @@ const { sendMessage, sendMessageInPromise } = msg;
* but another one, down the chain of redirects - is. It is loaded
* by app/blocked_redirect.html when we navigate browser to it.
*/
- (function BlockedRedirectContentScript(window, document) {
+ (function BlockedRedirectContentScript(window, doc) {
+ const document = doc;
/**
* Calculate window height.
* @memberof BlockedRedirectContentScript
diff --git a/app/content-scripts/click_to_play.js b/app/content-scripts/click_to_play.js
index 95c329857..7a41c9c82 100644
--- a/app/content-scripts/click_to_play.js
+++ b/app/content-scripts/click_to_play.js
@@ -57,11 +57,12 @@ const Click2PlayContentScript = (function(win, doc) {
* @memberof Click2PlayContentScript
* @package
*
- * @param {Object} c2pFrame iframe DOM element
+ * @param {Object} c2pFrameEl iframe DOM element
* @param {Object} c2pAppDef replacement data
* @param {string} html a fragment of html to be used in replacement.
*/
- const buildC2P = function(c2pFrame, c2pAppDef, html) {
+ const buildC2P = function(c2pFrameEl, c2pAppDef, html) {
+ const c2pFrame = c2pFrameEl;
c2pFrame.addEventListener('load', () => {
const idoc = c2pFrame.contentDocument;
idoc.documentElement.innerHTML = html;
@@ -160,8 +161,10 @@ const Click2PlayContentScript = (function(win, doc) {
if (name === 'c2p') {
if (message) {
// Dequeue C2P data stored while the script injection was taking place
- for (const app_id in message) {
- if (message.hasOwnProperty(app_id)) {
+ const messageKeys = Object.keys(message);
+ for (let i = 0; i < messageKeys.length; i++) {
+ const app_id = messageKeys[i];
+ if (Object.prototype.hasOwnProperty.call(message, app_id)) {
applyC2P(app_id, message[app_id].data, message[app_id].html);
delete message[app_id];
}
diff --git a/app/content-scripts/page_performance.js b/app/content-scripts/page_performance.js
index 2360367dc..467333c4d 100644
--- a/app/content-scripts/page_performance.js
+++ b/app/content-scripts/page_performance.js
@@ -27,7 +27,8 @@ const { sendMessage } = msg;
* Use to call init to initialize functionality
* @var {Object} initialized to an object with init method as its property
*/
-const PageInfo = (function(window, document) {
+const PageInfo = (function(window, doc) {
+ const document = doc;
let state = document.readyState;
/**
* Calculate page domain and latency. Send pageInfo to background.js.
diff --git a/app/hub/Views/AppView/AppViewContainer.jsx b/app/hub/Views/AppView/AppViewContainer.jsx
index 2d98688d3..8cf81288e 100644
--- a/app/hub/Views/AppView/AppViewContainer.jsx
+++ b/app/hub/Views/AppView/AppViewContainer.jsx
@@ -36,11 +36,13 @@ class AppViewContainer extends Component {
* @return {JSX} JSX for rendering the Home View of the Hub app
*/
render() {
- const childProps = {
- ...this.props,
- exitToast: this._exitToast,
- };
- return ;
+ const { app, children } = this.props;
+
+ return (
+
+ {children}
+
+ );
}
}
diff --git a/app/hub/Views/AppView/AppViewReducer.js b/app/hub/Views/AppView/AppViewReducer.js
index 970f51132..94ee686f2 100644
--- a/app/hub/Views/AppView/AppViewReducer.js
+++ b/app/hub/Views/AppView/AppViewReducer.js
@@ -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;
}
diff --git a/app/hub/Views/AppView/index.js b/app/hub/Views/AppView/index.js
index 8fc86ded9..9d9d20ffc 100644
--- a/app/hub/Views/AppView/index.js
+++ b/app/hub/Views/AppView/index.js
@@ -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;
diff --git a/app/hub/Views/CreateAccountView/CreateAccountViewContainer.jsx b/app/hub/Views/CreateAccountView/CreateAccountViewContainer.jsx
index f0099d3b2..f71c46f97 100644
--- a/app/hub/Views/CreateAccountView/CreateAccountViewContainer.jsx
+++ b/app/hub/Views/CreateAccountView/CreateAccountViewContainer.jsx
@@ -172,30 +172,26 @@ class CreateAccountViewContainer extends Component {
passwordInvalidError,
passwordLengthError,
} = this.state;
- const createAccountChildProps = {
- email,
- emailError,
- confirmEmail,
- confirmEmailError,
- firstName,
- lastName,
- legalConsentChecked,
- legalConsentNotCheckedError,
- password,
- passwordInvalidError,
- passwordLengthError,
- handleInputChange: this._handleInputChange,
- handleLegalConsentCheckboxChange: this._handleLegalConsentCheckboxChange,
- handleSubmit: this._handleCreateAccountAttempt
- };
- const signedInChildProps = {
- email: user && user.email || email,
- };
return loggedIn ? (
-
+
) : (
-
+
);
}
}
diff --git a/app/hub/Views/CreateAccountView/index.js b/app/hub/Views/CreateAccountView/index.js
index 2fe88b9f9..da18f1190 100644
--- a/app/hub/Views/CreateAccountView/index.js
+++ b/app/hub/Views/CreateAccountView/index.js
@@ -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);
diff --git a/app/hub/Views/HomeView/HomeViewContainer.jsx b/app/hub/Views/HomeView/HomeViewContainer.jsx
index c98e55b78..719651a5d 100644
--- a/app/hub/Views/HomeView/HomeViewContainer.jsx
+++ b/app/hub/Views/HomeView/HomeViewContainer.jsx
@@ -117,22 +117,13 @@ class HomeViewContainer extends Component {
_render() {
const { justInstalled } = this.state;
const { home, user } = this.props;
- const isPlus = user && user.subscriptionsPlus || false;
+ const isPlus = (user && user.subscriptionsPlus) || false;
const {
premium_promo_modal_shown,
setup_complete,
tutorial_complete,
enable_metrics,
} = home;
- const childProps = {
- justInstalled,
- setup_complete,
- tutorial_complete,
- enable_metrics,
- changeMetrics: this._handleToggleMetrics,
- email: user ? user.email : '',
- isPlus,
- };
const showPromoModal = !premium_promo_modal_shown && !this._premiumSubscriber();
@@ -147,7 +138,15 @@ class HomeViewContainer extends Component {
handleGetPlusClick={this._handleGetPlusClick}
handleTryMidnightClick={this._handleTryMidnightClick}
/>
-
+
);
}
diff --git a/app/hub/Views/HomeView/HomeViewReducer.js b/app/hub/Views/HomeView/HomeViewReducer.js
index 1582d7e62..2461abac6 100644
--- a/app/hub/Views/HomeView/HomeViewReducer.js
+++ b/app/hub/Views/HomeView/HomeViewReducer.js
@@ -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;
diff --git a/app/hub/Views/HomeView/index.js b/app/hub/Views/HomeView/index.js
index 4e4a35da3..9a947b809 100644
--- a/app/hub/Views/HomeView/index.js
+++ b/app/hub/Views/HomeView/index.js
@@ -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;
diff --git a/app/hub/Views/LogInView/LogInViewContainer.jsx b/app/hub/Views/LogInView/LogInViewContainer.jsx
index fb9cd1289..6c5ef5859 100644
--- a/app/hub/Views/LogInView/LogInViewContainer.jsx
+++ b/app/hub/Views/LogInView/LogInViewContainer.jsx
@@ -128,22 +128,18 @@ class LogInViewContainer extends Component {
emailError,
passwordError,
} = this.state;
- const logInChildProps = {
- email,
- password,
- emailError,
- passwordError,
- handleInputChange: this._handleInputChange,
- handleSubmit: this._handleLoginAttempt,
- };
- const signedInChildProps = {
- email: user && user.email || 'email',
- };
return loggedIn ? (
-
+
) : (
-
+
);
}
}
diff --git a/app/hub/Views/LogInView/index.js b/app/hub/Views/LogInView/index.js
index e53caf771..ebcd60244 100644
--- a/app/hub/Views/LogInView/index.js
+++ b/app/hub/Views/LogInView/index.js
@@ -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);
diff --git a/app/hub/Views/PlusView/PlusViewContainer.jsx b/app/hub/Views/PlusView/PlusViewContainer.jsx
index 5d8332ddc..bcd3b0d67 100644
--- a/app/hub/Views/PlusView/PlusViewContainer.jsx
+++ b/app/hub/Views/PlusView/PlusViewContainer.jsx
@@ -43,12 +43,12 @@ class PlusViewContainer extends Component {
* @return {JSX} JSX for rendering the Plus View of the Hub app
*/
render() {
- const childProps = {
- isPlus: this.props.user && this.props.user.subscriptionsPlus || false,
- onPlusClick: this._sendPlusPing,
- };
-
- return ;
+ return (
+
+ );
}
}
diff --git a/app/hub/Views/PlusView/index.js b/app/hub/Views/PlusView/index.js
index ee753c74b..cd19404b6 100644
--- a/app/hub/Views/PlusView/index.js
+++ b/app/hub/Views/PlusView/index.js
@@ -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);
diff --git a/app/hub/Views/ProductsView/index.js b/app/hub/Views/ProductsView/index.js
index 977e4bf28..955600e4c 100644
--- a/app/hub/Views/ProductsView/index.js
+++ b/app/hub/Views/ProductsView/index.js
@@ -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);
diff --git a/app/hub/Views/SetupView/SetupView.jsx b/app/hub/Views/SetupView/SetupView.jsx
index 690d2b475..8db394a37 100644
--- a/app/hub/Views/SetupView/SetupView.jsx
+++ b/app/hub/Views/SetupView/SetupView.jsx
@@ -36,7 +36,7 @@ const SetupView = (props) => {
path={step.path}
render={() => (
-
+
)}
diff --git a/app/hub/Views/SetupView/SetupViewReducer.js b/app/hub/Views/SetupView/SetupViewReducer.js
index e17dcf514..46c5c51a1 100644
--- a/app/hub/Views/SetupView/SetupViewReducer.js
+++ b/app/hub/Views/SetupView/SetupViewReducer.js
@@ -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;
diff --git a/app/hub/Views/SetupView/index.js b/app/hub/Views/SetupView/index.js
index ab86ba273..5bd10681d 100644
--- a/app/hub/Views/SetupView/index.js
+++ b/app/hub/Views/SetupView/index.js
@@ -18,15 +18,15 @@ import { withRouter } from 'react-router-dom';
import SetupViewContainer from './SetupViewContainer';
import SetupViewReducer from './SetupViewReducer';
import * as SetupViewActions from './SetupViewActions';
-import { setBlockingPolicy } from '../SetupViews/SetupBlockingView/SetupBlockingViewActions';
+import setBlockingPolicy from '../SetupViews/SetupBlockingView/SetupBlockingViewActions';
import {
setAntiTracking,
setAdBlock,
setSmartBlocking,
setGhosteryRewards
} from '../SetupViews/SetupAntiSuiteView/SetupAntiSuiteViewActions';
-import { setHumanWeb } from '../SetupViews/SetupHumanWebView/SetupHumanWebViewActions';
-import { setSetupComplete } from '../SetupViews/SetupDoneView/SetupDoneViewActions';
+import setHumanWeb from '../SetupViews/SetupHumanWebView/SetupHumanWebViewActions';
+import setSetupComplete from '../SetupViews/SetupDoneView/SetupDoneViewActions';
/**
* Map redux store state properties to the component's own properties.
@@ -34,7 +34,7 @@ import { setSetupComplete } from '../SetupViews/SetupDoneView/SetupDoneViewActio
* @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.setup, state.account);
+const mapStateToProps = state => ({ ...state.setup, ...state.account });
/**
* Bind the component's action creators using Redux's bindActionCreators.
@@ -43,15 +43,16 @@ const mapStateToProps = state => Object.assign({}, state.setup, state.account);
* @memberof SetupContainers
*/
const mapDispatchToProps = dispatch => ({
- actions: bindActionCreators(Object.assign({}, SetupViewActions, {
+ actions: bindActionCreators({
+ ...SetupViewActions,
setBlockingPolicy,
setAntiTracking,
setAdBlock,
setSmartBlocking,
setGhosteryRewards,
setHumanWeb,
- setSetupComplete,
- }), dispatch),
+ setSetupComplete
+ }, dispatch),
});
export const reducer = SetupViewReducer;
diff --git a/app/hub/Views/SetupViews/SetupAntiSuiteView/index.js b/app/hub/Views/SetupViews/SetupAntiSuiteView/index.js
index d07fd0ecc..9d5dfcf5d 100644
--- a/app/hub/Views/SetupViews/SetupAntiSuiteView/index.js
+++ b/app/hub/Views/SetupViews/SetupAntiSuiteView/index.js
@@ -24,7 +24,7 @@ import { setSetupStep, setSetupNavigation } from '../../SetupView/SetupViewActio
* @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.setup);
+const mapStateToProps = state => ({ ...state.setup });
/**
* Bind the component's action creators using Redux's bindActionCreators.
@@ -33,10 +33,11 @@ const mapStateToProps = state => Object.assign({}, state.setup);
* @memberof SetupContainers
*/
const mapDispatchToProps = dispatch => ({
- actions: bindActionCreators(Object.assign({}, SetupAntiSuiteViewActions, {
+ actions: bindActionCreators({
+ ...SetupAntiSuiteViewActions,
setSetupStep,
- setSetupNavigation,
- }), dispatch),
+ setSetupNavigation
+ }, dispatch),
});
export default connect(mapStateToProps, mapDispatchToProps)(SetupAntiSuiteViewContainer);
diff --git a/app/hub/Views/SetupViews/SetupBlockingDropdown/index.js b/app/hub/Views/SetupViews/SetupBlockingDropdown/index.js
index 3eedd4039..2c9066551 100644
--- a/app/hub/Views/SetupViews/SetupBlockingDropdown/index.js
+++ b/app/hub/Views/SetupViews/SetupBlockingDropdown/index.js
@@ -24,7 +24,7 @@ import * as SettingsActions from '../../../../panel/actions/SettingsActions';
* @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.settings);
+const mapStateToProps = state => ({ ...state.settings });
/**
* Bind the component's action creators using Redux's bindActionCreators.
@@ -33,7 +33,7 @@ const mapStateToProps = state => Object.assign({}, state.settings);
* @memberof SetupContainers
*/
const mapDispatchToProps = dispatch => ({
- actions: bindActionCreators(Object.assign({}, SettingsActions), dispatch),
+ actions: bindActionCreators({ ...SettingsActions }, dispatch),
});
export default withRouter(connect(mapStateToProps, mapDispatchToProps)(SetupBlockingDropdownContainer));
diff --git a/app/hub/Views/SetupViews/SetupBlockingView/SetupBlockingViewActions.js b/app/hub/Views/SetupViews/SetupBlockingView/SetupBlockingViewActions.js
index ce9eb31b9..de4b436ed 100644
--- a/app/hub/Views/SetupViews/SetupBlockingView/SetupBlockingViewActions.js
+++ b/app/hub/Views/SetupViews/SetupBlockingView/SetupBlockingViewActions.js
@@ -14,7 +14,7 @@
import { log, sendMessageInPromise } from '../../../utils';
import { SET_BLOCKING_POLICY } from '../../SetupView/SetupViewConstants';
-export function setBlockingPolicy(actionData) {
+export default function setBlockingPolicy(actionData) {
return function(dispatch) {
return sendMessageInPromise(SET_BLOCKING_POLICY, actionData).then((data) => {
dispatch({
diff --git a/app/hub/Views/SetupViews/SetupBlockingView/__tests__/SetupBlockingViewActions.test.js b/app/hub/Views/SetupViews/SetupBlockingView/__tests__/SetupBlockingViewActions.test.js
index 23504c3db..cfa80c6f0 100644
--- a/app/hub/Views/SetupViews/SetupBlockingView/__tests__/SetupBlockingViewActions.test.js
+++ b/app/hub/Views/SetupViews/SetupBlockingView/__tests__/SetupBlockingViewActions.test.js
@@ -14,7 +14,7 @@
import configureStore from 'redux-mock-store';
import thunk from 'redux-thunk';
import * as utils from '../../../../utils';
-import * as SetupBlockingViewActions from '../SetupBlockingViewActions';
+import setBlockingPolicy from '../SetupBlockingViewActions';
import { SET_BLOCKING_POLICY } from '../../../SetupView/SetupViewConstants';
const middlewares = [thunk];
@@ -39,7 +39,7 @@ describe('app/hub/Views/SetupViews/SetupBlockingView actions', () => {
const data = testData;
const expectedPayload = { data, type: SET_BLOCKING_POLICY };
- return store.dispatch(SetupBlockingViewActions.setBlockingPolicy(data)).then(() => {
+ return store.dispatch(setBlockingPolicy(data)).then(() => {
const actions = store.getActions();
expect(actions).toEqual([expectedPayload]);
});
diff --git a/app/hub/Views/SetupViews/SetupBlockingView/index.js b/app/hub/Views/SetupViews/SetupBlockingView/index.js
index 2c4e76a68..383bda7ff 100644
--- a/app/hub/Views/SetupViews/SetupBlockingView/index.js
+++ b/app/hub/Views/SetupViews/SetupBlockingView/index.js
@@ -16,7 +16,7 @@ import { bindActionCreators } from 'redux';
import { withRouter } from 'react-router-dom';
import SetupBlockingViewContainer from './SetupBlockingViewContainer';
-import * as SetupBlockingViewActions from './SetupBlockingViewActions';
+import setBlockingPolicy from './SetupBlockingViewActions';
import { setSetupStep, setSetupNavigation } from '../../SetupView/SetupViewActions';
/**
@@ -25,7 +25,7 @@ import { setSetupStep, setSetupNavigation } from '../../SetupView/SetupViewActio
* @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.setup);
+const mapStateToProps = state => ({ ...state.setup });
/**
* Bind the component's action creators using Redux's bindActionCreators.
@@ -34,10 +34,11 @@ const mapStateToProps = state => Object.assign({}, state.setup);
* @memberof SetupContainers
*/
const mapDispatchToProps = dispatch => ({
- actions: bindActionCreators(Object.assign({}, SetupBlockingViewActions, {
+ actions: bindActionCreators({
+ setBlockingPolicy,
setSetupStep,
- setSetupNavigation,
- }), dispatch),
+ setSetupNavigation
+ }, dispatch),
});
export default withRouter(connect(mapStateToProps, mapDispatchToProps)(SetupBlockingViewContainer));
diff --git a/app/hub/Views/SetupViews/SetupDoneView/SetupDoneViewActions.js b/app/hub/Views/SetupViews/SetupDoneView/SetupDoneViewActions.js
index 10ce3e7b4..8c11c0d6e 100644
--- a/app/hub/Views/SetupViews/SetupDoneView/SetupDoneViewActions.js
+++ b/app/hub/Views/SetupViews/SetupDoneView/SetupDoneViewActions.js
@@ -14,7 +14,7 @@
import { log, sendMessageInPromise } from '../../../utils';
import { SET_SETUP_COMPLETE } from '../../SetupView/SetupViewConstants';
-export function setSetupComplete(actionData) {
+export default function setSetupComplete(actionData) {
return function(dispatch) {
return sendMessageInPromise(SET_SETUP_COMPLETE, actionData).then((data) => {
dispatch({
diff --git a/app/hub/Views/SetupViews/SetupDoneView/__tests__/SetupDoneViewActions.test.js b/app/hub/Views/SetupViews/SetupDoneView/__tests__/SetupDoneViewActions.test.js
index 5c66ecd65..1e8a99a74 100644
--- a/app/hub/Views/SetupViews/SetupDoneView/__tests__/SetupDoneViewActions.test.js
+++ b/app/hub/Views/SetupViews/SetupDoneView/__tests__/SetupDoneViewActions.test.js
@@ -14,7 +14,7 @@
import configureStore from 'redux-mock-store';
import thunk from 'redux-thunk';
import * as utils from '../../../../utils';
-import * as SetupDoneViewActions from '../SetupDoneViewActions';
+import setSetupComplete from '../SetupDoneViewActions';
import { SET_SETUP_COMPLETE } from '../../../SetupView/SetupViewConstants';
const middlewares = [thunk];
@@ -39,7 +39,7 @@ describe('app/hub/Views/SetupViews/SetupDoneView actions', () => {
const data = testData;
const expectedPayload = { data, type: SET_SETUP_COMPLETE };
- return store.dispatch(SetupDoneViewActions.setSetupComplete(data)).then(() => {
+ return store.dispatch(setSetupComplete(data)).then(() => {
const actions = store.getActions();
expect(actions).toEqual([expectedPayload]);
});
diff --git a/app/hub/Views/SetupViews/SetupDoneView/index.js b/app/hub/Views/SetupViews/SetupDoneView/index.js
index bcce6c53d..47199b305 100644
--- a/app/hub/Views/SetupViews/SetupDoneView/index.js
+++ b/app/hub/Views/SetupViews/SetupDoneView/index.js
@@ -15,7 +15,7 @@ import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import SetupDoneViewContainer from './SetupDoneViewContainer';
-import * as SetupDoneViewActions from './SetupDoneViewActions';
+import setSetupComplete from './SetupDoneViewActions';
import { setSetupStep, setSetupNavigation } from '../../SetupView/SetupViewActions';
/**
@@ -24,7 +24,7 @@ import { setSetupStep, setSetupNavigation } from '../../SetupView/SetupViewActio
* @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.setup);
+const mapStateToProps = state => ({ ...state.setup });
/**
* Bind the component's action creators using Redux's bindActionCreators.
@@ -33,10 +33,11 @@ const mapStateToProps = state => Object.assign({}, state.setup);
* @memberof SetupContainers
*/
const mapDispatchToProps = dispatch => ({
- actions: bindActionCreators(Object.assign({}, SetupDoneViewActions, {
+ actions: bindActionCreators({
+ setSetupComplete,
setSetupStep,
- setSetupNavigation,
- }), dispatch),
+ setSetupNavigation
+ }, dispatch),
});
export default connect(mapStateToProps, mapDispatchToProps)(SetupDoneViewContainer);
diff --git a/app/hub/Views/SetupViews/SetupHumanWebView/SetupHumanWebViewActions.js b/app/hub/Views/SetupViews/SetupHumanWebView/SetupHumanWebViewActions.js
index 16cf28b1a..b18500b8a 100644
--- a/app/hub/Views/SetupViews/SetupHumanWebView/SetupHumanWebViewActions.js
+++ b/app/hub/Views/SetupViews/SetupHumanWebView/SetupHumanWebViewActions.js
@@ -14,7 +14,7 @@
import { log, sendMessageInPromise } from '../../../utils';
import { SET_HUMAN_WEB } from '../../SetupView/SetupViewConstants';
-export function setHumanWeb(actionData) {
+export default function setHumanWeb(actionData) {
return function(dispatch) {
return sendMessageInPromise(SET_HUMAN_WEB, actionData).then((data) => {
dispatch({
diff --git a/app/hub/Views/SetupViews/SetupHumanWebView/SetupHumanWebViewContainer.jsx b/app/hub/Views/SetupViews/SetupHumanWebView/SetupHumanWebViewContainer.jsx
index 3e6415082..e6bce8b7b 100644
--- a/app/hub/Views/SetupViews/SetupHumanWebView/SetupHumanWebViewContainer.jsx
+++ b/app/hub/Views/SetupViews/SetupHumanWebView/SetupHumanWebViewContainer.jsx
@@ -58,11 +58,12 @@ class SetupHumanWebViewContainer extends Component {
* @return {JSX} JSX for rendering the Setup Human Web View of the Hub app
*/
render() {
- const childProps = {
- enableHumanWeb: this.props.setup.enable_human_web,
- changeHumanWeb: this._handleToggle,
- };
- return ;
+ return (
+
+ );
}
}
diff --git a/app/hub/Views/SetupViews/SetupHumanWebView/__tests__/SetupHumanWebViewActions.test.js b/app/hub/Views/SetupViews/SetupHumanWebView/__tests__/SetupHumanWebViewActions.test.js
index e00a40c89..3b21c84be 100644
--- a/app/hub/Views/SetupViews/SetupHumanWebView/__tests__/SetupHumanWebViewActions.test.js
+++ b/app/hub/Views/SetupViews/SetupHumanWebView/__tests__/SetupHumanWebViewActions.test.js
@@ -14,7 +14,7 @@
import configureStore from 'redux-mock-store';
import thunk from 'redux-thunk';
import * as utils from '../../../../utils';
-import * as SetupHumanWebViewActions from '../SetupHumanWebViewActions';
+import setHumanWeb from '../SetupHumanWebViewActions';
import { SET_HUMAN_WEB } from '../../../SetupView/SetupViewConstants';
const middlewares = [thunk];
@@ -39,7 +39,7 @@ describe('app/hub/Views/SetupViews/SetupHumanWebView actions', () => {
const data = testData;
const expectedPayload = { data, type: SET_HUMAN_WEB };
- return store.dispatch(SetupHumanWebViewActions.setHumanWeb(data)).then(() => {
+ return store.dispatch(setHumanWeb(data)).then(() => {
const actions = store.getActions();
expect(actions).toEqual([expectedPayload]);
});
diff --git a/app/hub/Views/SetupViews/SetupHumanWebView/index.js b/app/hub/Views/SetupViews/SetupHumanWebView/index.js
index 9b207c564..745d9904e 100644
--- a/app/hub/Views/SetupViews/SetupHumanWebView/index.js
+++ b/app/hub/Views/SetupViews/SetupHumanWebView/index.js
@@ -15,7 +15,7 @@ import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import SetupHumanWebViewContainer from './SetupHumanWebViewContainer';
-import * as SetupHumanWebViewActions from './SetupHumanWebViewActions';
+import setHumanWeb from './SetupHumanWebViewActions';
import { setSetupStep, setSetupNavigation } from '../../SetupView/SetupViewActions';
/**
@@ -24,7 +24,7 @@ import { setSetupStep, setSetupNavigation } from '../../SetupView/SetupViewActio
* @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.setup);
+const mapStateToProps = state => ({ ...state.setup });
/**
* Bind the component's action creators using Redux's bindActionCreators.
@@ -33,10 +33,11 @@ const mapStateToProps = state => Object.assign({}, state.setup);
* @memberof SetupContainers
*/
const mapDispatchToProps = dispatch => ({
- actions: bindActionCreators(Object.assign({}, SetupHumanWebViewActions, {
+ actions: bindActionCreators({
+ setHumanWeb,
setSetupStep,
setSetupNavigation
- }), dispatch),
+ }, dispatch),
});
export default connect(mapStateToProps, mapDispatchToProps)(SetupHumanWebViewContainer);
diff --git a/app/hub/Views/SetupViews/SetupNavigation/SetupNavigationContainer.jsx b/app/hub/Views/SetupViews/SetupNavigation/SetupNavigationContainer.jsx
index 3a55f163a..072ba9d07 100644
--- a/app/hub/Views/SetupViews/SetupNavigation/SetupNavigationContainer.jsx
+++ b/app/hub/Views/SetupViews/SetupNavigation/SetupNavigationContainer.jsx
@@ -22,12 +22,19 @@ import { SteppedNavigation } from '../../../../shared-components';
*/
const SetupNavigationContainer = (props) => {
const { totalSteps, setup } = props;
- const childProps = {
- totalSteps,
- ...setup.navigation,
- };
- return ;
+ return (
+
+ );
};
// PropTypes ensure we pass required props of the correct type
diff --git a/app/hub/Views/SetupViews/SetupNavigation/index.js b/app/hub/Views/SetupViews/SetupNavigation/index.js
index 9f40ac618..cc9ae5f59 100644
--- a/app/hub/Views/SetupViews/SetupNavigation/index.js
+++ b/app/hub/Views/SetupViews/SetupNavigation/index.js
@@ -20,6 +20,6 @@ import SetupNavigationContainer from './SetupNavigationContainer';
* @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.setup);
+const mapStateToProps = state => ({ ...state.setup });
export default connect(mapStateToProps)(SetupNavigationContainer);
diff --git a/app/hub/Views/SideNavigationView/SideNavigationViewContainer.jsx b/app/hub/Views/SideNavigationView/SideNavigationViewContainer.jsx
index 1388a5ea7..c91e2cda3 100644
--- a/app/hub/Views/SideNavigationView/SideNavigationViewContainer.jsx
+++ b/app/hub/Views/SideNavigationView/SideNavigationViewContainer.jsx
@@ -68,13 +68,14 @@ class SideNavigationViewContainer extends Component {
icon: 'profile',
},
];
- const childProps = {
- menuItems,
- bottomItems,
- disableNav: disableRegEx.test(location.pathname),
- };
- return ;
+ return (
+
+ );
}
}
diff --git a/app/hub/Views/SideNavigationView/index.js b/app/hub/Views/SideNavigationView/index.js
index adf9d60dc..da287bf7d 100644
--- a/app/hub/Views/SideNavigationView/index.js
+++ b/app/hub/Views/SideNavigationView/index.js
@@ -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,11 +34,11 @@ const mapStateToProps = state => Object.assign({}, state.account);
* @memberof SetupContainers
*/
const mapDispatchToProps = dispatch => ({
- actions: bindActionCreators(Object.assign({}, {
+ actions: bindActionCreators({
setToast,
getUser,
- logout,
- }), dispatch),
+ logout
+ }, dispatch),
});
export default withRouter(connect(mapStateToProps, mapDispatchToProps)(SideNavigationViewContainer));
diff --git a/app/hub/Views/TutorialView/TutorialViewReducer.js b/app/hub/Views/TutorialView/TutorialViewReducer.js
index 3a4fc9016..cbbf8bed1 100644
--- a/app/hub/Views/TutorialView/TutorialViewReducer.js
+++ b/app/hub/Views/TutorialView/TutorialViewReducer.js
@@ -27,7 +27,8 @@ function TutorialViewReducer(state = initialState, action) {
textNext,
textDone,
} = action.data.navigation;
- return Object.assign({}, state, {
+ return {
+ ...state,
tutorial: {
navigation: {
activeIndex,
@@ -38,8 +39,8 @@ function TutorialViewReducer(state = initialState, action) {
textNext,
textDone,
}
- },
- });
+ }
+ };
}
case SET_TUTORIAL_NAVIGATION: {
const {
@@ -51,8 +52,10 @@ function TutorialViewReducer(state = initialState, action) {
textNext,
textDone,
} = action.data;
- return Object.assign({}, state, {
- tutorial: Object.assign({}, state.tutorial, {
+ return {
+ ...state,
+ tutorial: {
+ ...state.tutorial,
navigation: {
activeIndex,
hrefPrev,
@@ -61,9 +64,9 @@ function TutorialViewReducer(state = initialState, action) {
textPrev,
textNext,
textDone,
- },
- }),
- });
+ }
+ }
+ };
}
default: return state;
diff --git a/app/hub/Views/TutorialView/index.js b/app/hub/Views/TutorialView/index.js
index f9c1a0157..1b2d90d3b 100644
--- a/app/hub/Views/TutorialView/index.js
+++ b/app/hub/Views/TutorialView/index.js
@@ -26,7 +26,7 @@ import { sendPing } 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.tutorial);
+const mapStateToProps = state => ({ ...state.tutorial });
/**
* Bind the component's action creators using Redux's bindActionCreators.
@@ -35,7 +35,7 @@ const mapStateToProps = state => Object.assign({}, state.tutorial);
* @memberof SetupContainers
*/
const mapDispatchToProps = dispatch => ({
- actions: bindActionCreators(Object.assign({}, TutorialViewActions, { sendPing }), dispatch),
+ actions: bindActionCreators({ ...TutorialViewActions, sendPing }, dispatch),
});
export const reducer = TutorialViewReducer;
diff --git a/app/hub/Views/TutorialViews/TutorialAntiSuiteView/TutorialAntiSuiteViewActions.js b/app/hub/Views/TutorialViews/TutorialAntiSuiteView/TutorialAntiSuiteViewActions.js
index 019754ba7..ddf87b787 100644
--- a/app/hub/Views/TutorialViews/TutorialAntiSuiteView/TutorialAntiSuiteViewActions.js
+++ b/app/hub/Views/TutorialViews/TutorialAntiSuiteView/TutorialAntiSuiteViewActions.js
@@ -14,7 +14,7 @@
import { log, sendMessageInPromise } from '../../../utils';
import { SET_TUTORIAL_COMPLETE } from '../../TutorialView/TutorialViewConstants';
-export function setTutorialComplete(actionData) {
+export default function setTutorialComplete(actionData) {
return function(dispatch) {
return sendMessageInPromise(SET_TUTORIAL_COMPLETE, actionData).then((data) => {
dispatch({
diff --git a/app/hub/Views/TutorialViews/TutorialAntiSuiteView/__test__/TutorialAntiSuiteViewActions.test.js b/app/hub/Views/TutorialViews/TutorialAntiSuiteView/__test__/TutorialAntiSuiteViewActions.test.js
index 7864a354a..d0866e007 100644
--- a/app/hub/Views/TutorialViews/TutorialAntiSuiteView/__test__/TutorialAntiSuiteViewActions.test.js
+++ b/app/hub/Views/TutorialViews/TutorialAntiSuiteView/__test__/TutorialAntiSuiteViewActions.test.js
@@ -14,7 +14,7 @@
import configureStore from 'redux-mock-store';
import thunk from 'redux-thunk';
import * as utils from '../../../../utils';
-import * as TutorialAntiSuiteViewActions from '../TutorialAntiSuiteViewActions';
+import setTutorialComplete from '../TutorialAntiSuiteViewActions';
import { SET_TUTORIAL_COMPLETE } from '../../../TutorialView/TutorialViewConstants';
const middlewares = [thunk];
@@ -39,7 +39,7 @@ describe('app/hub/Views/TutorialViews/TutorialAntiSuiteView actions', () => {
const data = testData;
const expectedPayload = { data, type: SET_TUTORIAL_COMPLETE };
- return store.dispatch(TutorialAntiSuiteViewActions.setTutorialComplete(data)).then(() => {
+ return store.dispatch(setTutorialComplete(data)).then(() => {
const actions = store.getActions();
expect(actions).toEqual([expectedPayload]);
});
diff --git a/app/hub/Views/TutorialViews/TutorialAntiSuiteView/index.js b/app/hub/Views/TutorialViews/TutorialAntiSuiteView/index.js
index c0faf59dd..df5d858e3 100644
--- a/app/hub/Views/TutorialViews/TutorialAntiSuiteView/index.js
+++ b/app/hub/Views/TutorialViews/TutorialAntiSuiteView/index.js
@@ -15,7 +15,7 @@ import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import TutorialAntiSuiteViewContainer from './TutorialAntiSuiteViewContainer';
-import * as TutorialAntiSuiteViewActions from './TutorialAntiSuiteViewActions';
+import setTutorialComplete from './TutorialAntiSuiteViewActions';
import { setTutorialNavigation } from '../../TutorialView/TutorialViewActions';
/**
@@ -24,7 +24,7 @@ import { setTutorialNavigation } from '../../TutorialView/TutorialViewActions';
* @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.tutorial);
+const mapStateToProps = state => ({ ...state.tutorial });
/**
* Bind the component's action creators using Redux's bindActionCreators.
@@ -33,7 +33,7 @@ const mapStateToProps = state => Object.assign({}, state.tutorial);
* @memberof TutorialContainers
*/
const mapDispatchToProps = dispatch => ({
- actions: bindActionCreators(Object.assign({}, TutorialAntiSuiteViewActions, { setTutorialNavigation }), dispatch),
+ actions: bindActionCreators({ setTutorialComplete, setTutorialNavigation }, dispatch),
});
export default connect(mapStateToProps, mapDispatchToProps)(TutorialAntiSuiteViewContainer);
diff --git a/app/hub/Views/TutorialViews/TutorialBlockingView/index.js b/app/hub/Views/TutorialViews/TutorialBlockingView/index.js
index a2f19348a..9e8be0d15 100644
--- a/app/hub/Views/TutorialViews/TutorialBlockingView/index.js
+++ b/app/hub/Views/TutorialViews/TutorialBlockingView/index.js
@@ -23,7 +23,7 @@ import { setTutorialNavigation } from '../../TutorialView/TutorialViewActions';
* @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.tutorial);
+const mapStateToProps = state => ({ ...state.tutorial });
/**
* Bind the component's action creators using Redux's bindActionCreators.
@@ -32,7 +32,7 @@ const mapStateToProps = state => Object.assign({}, state.tutorial);
* @memberof TutorialContainers
*/
const mapDispatchToProps = dispatch => ({
- actions: bindActionCreators(Object.assign({}, { setTutorialNavigation }), dispatch),
+ actions: bindActionCreators({ setTutorialNavigation }, dispatch),
});
export default connect(mapStateToProps, mapDispatchToProps)(TutorialBlockingViewContainer);
diff --git a/app/hub/Views/TutorialViews/TutorialLayoutView/index.js b/app/hub/Views/TutorialViews/TutorialLayoutView/index.js
index 9929161b9..14f8e4bdf 100644
--- a/app/hub/Views/TutorialViews/TutorialLayoutView/index.js
+++ b/app/hub/Views/TutorialViews/TutorialLayoutView/index.js
@@ -23,7 +23,7 @@ import { setTutorialNavigation } from '../../TutorialView/TutorialViewActions';
* @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.tutorial);
+const mapStateToProps = state => ({ ...state.tutorial });
/**
* Bind the component's action creators using Redux's bindActionCreators.
@@ -32,7 +32,7 @@ const mapStateToProps = state => Object.assign({}, state.tutorial);
* @memberof TutorialContainers
*/
const mapDispatchToProps = dispatch => ({
- actions: bindActionCreators(Object.assign({}, { setTutorialNavigation }), dispatch),
+ actions: bindActionCreators({ setTutorialNavigation }, dispatch),
});
export default connect(mapStateToProps, mapDispatchToProps)(TutorialLayoutViewContainer);
diff --git a/app/hub/Views/TutorialViews/TutorialNavigation/TutorialNavigationContainer.jsx b/app/hub/Views/TutorialViews/TutorialNavigation/TutorialNavigationContainer.jsx
index f64c4f6d1..ed57d61eb 100644
--- a/app/hub/Views/TutorialViews/TutorialNavigation/TutorialNavigationContainer.jsx
+++ b/app/hub/Views/TutorialViews/TutorialNavigation/TutorialNavigationContainer.jsx
@@ -22,11 +22,19 @@ import { SteppedNavigation } from '../../../../shared-components';
*/
const TutorialNavigationContainer = (props) => {
const { totalSteps, tutorial } = props;
- const childProps = {
- totalSteps,
- ...tutorial.navigation,
- };
- return ;
+
+ return (
+
+ );
};
// PropTypes ensure we pass required props of the correct type
diff --git a/app/hub/Views/TutorialViews/TutorialNavigation/index.js b/app/hub/Views/TutorialViews/TutorialNavigation/index.js
index c4e9ae922..f83a26627 100644
--- a/app/hub/Views/TutorialViews/TutorialNavigation/index.js
+++ b/app/hub/Views/TutorialViews/TutorialNavigation/index.js
@@ -20,6 +20,6 @@ import TutorialNavigationContainer from './TutorialNavigationContainer';
* @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.tutorial);
+const mapStateToProps = state => ({ ...state.tutorial });
export default connect(mapStateToProps)(TutorialNavigationContainer);
diff --git a/app/hub/Views/TutorialViews/TutorialTrackerListView/index.js b/app/hub/Views/TutorialViews/TutorialTrackerListView/index.js
index bc09a915a..677b18f4f 100644
--- a/app/hub/Views/TutorialViews/TutorialTrackerListView/index.js
+++ b/app/hub/Views/TutorialViews/TutorialTrackerListView/index.js
@@ -23,7 +23,7 @@ import { setTutorialNavigation } from '../../TutorialView/TutorialViewActions';
* @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.tutorial);
+const mapStateToProps = state => ({ ...state.tutorial });
/**
* Bind the component's action creators using Redux's bindActionCreators.
@@ -32,7 +32,7 @@ const mapStateToProps = state => Object.assign({}, state.tutorial);
* @memberof TutorialContainers
*/
const mapDispatchToProps = dispatch => ({
- actions: bindActionCreators(Object.assign({}, { setTutorialNavigation }), dispatch),
+ actions: bindActionCreators({ setTutorialNavigation }, dispatch),
});
export default connect(mapStateToProps, mapDispatchToProps)(TutorialTrackerListViewContainer);
diff --git a/app/hub/Views/TutorialViews/TutorialTrustView/index.js b/app/hub/Views/TutorialViews/TutorialTrustView/index.js
index 56ab74c4b..f839f8805 100644
--- a/app/hub/Views/TutorialViews/TutorialTrustView/index.js
+++ b/app/hub/Views/TutorialViews/TutorialTrustView/index.js
@@ -23,7 +23,7 @@ import { setTutorialNavigation } from '../../TutorialView/TutorialViewActions';
* @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.tutorial);
+const mapStateToProps = state => ({ ...state.tutorial });
/**
* Bind the component's action creators using Redux's bindActionCreators.
@@ -32,7 +32,7 @@ const mapStateToProps = state => Object.assign({}, state.tutorial);
* @memberof TutorialContainers
*/
const mapDispatchToProps = dispatch => ({
- actions: bindActionCreators(Object.assign({}, { setTutorialNavigation }), dispatch),
+ actions: bindActionCreators({ setTutorialNavigation }, dispatch),
});
export default connect(mapStateToProps, mapDispatchToProps)(TutorialTrustViewContainer);
diff --git a/app/hub/Views/TutorialViews/TutorialVideoView/index.js b/app/hub/Views/TutorialViews/TutorialVideoView/index.js
index bd4d12e0b..3171af418 100644
--- a/app/hub/Views/TutorialViews/TutorialVideoView/index.js
+++ b/app/hub/Views/TutorialViews/TutorialVideoView/index.js
@@ -23,7 +23,7 @@ import { setTutorialNavigation } from '../../TutorialView/TutorialViewActions';
* @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.tutorial);
+const mapStateToProps = state => ({ ...state.tutorial });
/**
* Bind the component's action creators using Redux's bindActionCreators.
@@ -32,7 +32,7 @@ const mapStateToProps = state => Object.assign({}, state.tutorial);
* @memberof TutorialContainers
*/
const mapDispatchToProps = dispatch => ({
- actions: bindActionCreators(Object.assign({}, { setTutorialNavigation }), dispatch),
+ actions: bindActionCreators({ setTutorialNavigation }, dispatch),
});
export default connect(mapStateToProps, mapDispatchToProps)(TutorialVideoViewContainer);
diff --git a/app/licenses/License.jsx b/app/licenses/License.jsx
index e6951aab5..8f2e737d2 100644
--- a/app/licenses/License.jsx
+++ b/app/licenses/License.jsx
@@ -33,7 +33,7 @@ class License extends React.Component {
* Toggle expansion of a license full text.
*/
toggleLicenseText() {
- this.setState({ expanded: !this.state.expanded });
+ this.setState(prevState => ({ expanded: !prevState.expanded }));
}
/**
diff --git a/app/licenses/Licenses.jsx b/app/licenses/Licenses.jsx
index cd9aaf339..fb083fc9e 100644
--- a/app/licenses/Licenses.jsx
+++ b/app/licenses/Licenses.jsx
@@ -31,7 +31,7 @@ class Licenses extends React.Component {
* Wrapper function for dangerouslySetInnerHTML. Provides extra security
* @return {Object}
*/
- createFooterMarkup() {
+ static createFooterMarkup() {
return { __html: t('license_footer') };
}
@@ -60,7 +60,7 @@ class Licenses extends React.Component {
{ list }
);
diff --git a/app/panel-android/actions/cliqzActions.js b/app/panel-android/actions/cliqzActions.js
index 478d36bd1..f020abdaf 100644
--- a/app/panel-android/actions/cliqzActions.js
+++ b/app/panel-android/actions/cliqzActions.js
@@ -13,7 +13,7 @@
import { sendMessageInPromise } from '../../panel/utils/msg';
-export function getCliqzModuleData(tabId) {
+export default function getCliqzModuleData(tabId) {
return sendMessageInPromise('getCliqzModuleData', {
tabId,
});
diff --git a/app/panel-android/actions/trackerActions.js b/app/panel-android/actions/trackerActions.js
index 820224ed7..f5ea7cf84 100644
--- a/app/panel-android/actions/trackerActions.js
+++ b/app/panel-android/actions/trackerActions.js
@@ -21,8 +21,8 @@ function trustRestrictTracker({
const siteSpecificUnblocks = blocking.site_specific_unblocks;
const siteSpecificBlocks = blocking.site_specific_blocks;
- const pageUnblocks = siteSpecificUnblocks[pageHost] && siteSpecificUnblocks[pageHost].slice(0) || []; // clone
- const pageBlocks = siteSpecificBlocks[pageHost] && siteSpecificBlocks[pageHost].slice(0) || []; // clone
+ const pageUnblocks = (siteSpecificUnblocks[pageHost] && siteSpecificUnblocks[pageHost].slice(0)) || []; // clone
+ const pageBlocks = (siteSpecificBlocks[pageHost] && siteSpecificBlocks[pageHost].slice(0)) || []; // clone
let updated_site_specific_unblocks = {};
let updated_site_specific_blocks = {};
@@ -218,30 +218,30 @@ export function blockUnBlockAllTrackers({ actionData, state }) {
const app_ids = [];
if (isSiteTrackers) {
- updated_blocking_categories.forEach((category) => {
- if (categoryId && category.id !== categoryId) {
+ updated_blocking_categories.forEach((categoryEl) => {
+ if (categoryId && categoryEl.id !== categoryId) {
return;
}
- const updated_settings_category = updated_settings_categories.find(item => item.id === category.id);
- category.num_blocked = 0;
+ const updated_settings_category = updated_settings_categories.find(item => item.id === categoryEl.id);
+ categoryEl.num_blocked = 0;
// TODO: change the logic here
- category.trackers.forEach((tracker) => {
- if (tracker.shouldShow) {
- tracker.blocked = block;
- const key = tracker.id;
+ categoryEl.trackers.forEach((trackerEl) => {
+ if (trackerEl.shouldShow) {
+ trackerEl.blocked = block;
+ const key = trackerEl.id;
if (block) {
if (!app_ids.includes(key)) {
app_ids.push(key);
}
- tracker.ss_allowed = false;
- tracker.ss_blocked = false;
+ trackerEl.ss_allowed = false;
+ trackerEl.ss_blocked = false;
}
- if (block || tracker.ss_blocked) {
- category.num_blocked += 1;
+ if (block || trackerEl.ss_blocked) {
+ categoryEl.num_blocked += 1;
updated_app_ids[key] = 1;
} else {
delete updated_app_ids[key];
@@ -258,19 +258,19 @@ export function blockUnBlockAllTrackers({ actionData, state }) {
});
});
} else {
- updated_settings_categories.forEach((category) => {
- if (categoryId && category.id !== categoryId) {
+ updated_settings_categories.forEach((categoryEl) => {
+ if (categoryId && categoryEl.id !== categoryId) {
return;
}
- category.num_blocked = 0;
- category.trackers.forEach((tracker) => {
- if (tracker.shouldShow) {
- tracker.blocked = block;
- const key = tracker.id;
+ categoryEl.num_blocked = 0;
+ categoryEl.trackers.forEach((trackerEl) => {
+ if (trackerEl.shouldShow) {
+ trackerEl.blocked = block;
+ const key = trackerEl.id;
if (block) {
- category.num_blocked += 1;
+ categoryEl.num_blocked += 1;
updated_app_ids[key] = 1;
} else {
delete updated_app_ids[key];
@@ -279,13 +279,13 @@ export function blockUnBlockAllTrackers({ actionData, state }) {
});
});
- updated_blocking_categories.forEach((category) => {
- category.trackers.forEach((tracker) => {
- if (tracker.shouldShow && !tracker.ss_allowed && !tracker.ss_blocked) {
- tracker.blocked = block;
+ updated_blocking_categories.forEach((categoryEl) => {
+ categoryEl.trackers.forEach((trackerEl) => {
+ if (trackerEl.shouldShow && !trackerEl.ss_allowed && !trackerEl.ss_blocked) {
+ trackerEl.blocked = block;
}
});
- category.num_blocked = category.trackers.filter(tracker => tracker.blocked || tracker.ss_blocked).length;
+ categoryEl.num_blocked = categoryEl.trackers.filter(trackerEl => trackerEl.blocked || trackerEl.ss_blocked).length;
});
}
@@ -326,24 +326,24 @@ export function resetSettings({ state }) {
const blockingCategories = JSON.parse(JSON.stringify(blocking.categories)) || [];
const settingsCategories = JSON.parse(JSON.stringify(settings.categories)) || [];
- blockingCategories.forEach((category) => {
- category.num_blocked = 0;
- category.trackers.forEach((tracker) => {
- if (tracker.shouldShow) {
- tracker.blocked = false;
- tracker.ss_blocked = false;
- tracker.ss_allowed = false;
+ blockingCategories.forEach((categoryEl) => {
+ categoryEl.num_blocked = 0;
+ categoryEl.trackers.forEach((trackerEl) => {
+ if (trackerEl.shouldShow) {
+ trackerEl.blocked = false;
+ trackerEl.ss_blocked = false;
+ trackerEl.ss_allowed = false;
}
});
});
- settingsCategories.forEach((category) => {
- category.num_blocked = 0;
- category.trackers.forEach((tracker) => {
- if (tracker.shouldShow) {
- tracker.blocked = false;
- tracker.ss_blocked = false;
- tracker.ss_allowed = false;
+ settingsCategories.forEach((categoryEl) => {
+ categoryEl.num_blocked = 0;
+ categoryEl.trackers.forEach((trackerEl) => {
+ if (trackerEl.shouldShow) {
+ trackerEl.blocked = false;
+ trackerEl.ss_blocked = false;
+ trackerEl.ss_allowed = false;
}
});
});
diff --git a/app/panel-android/components/Overview.jsx b/app/panel-android/components/Overview.jsx
index 3a0913e1f..ce30ea60b 100644
--- a/app/panel-android/components/Overview.jsx
+++ b/app/panel-android/components/Overview.jsx
@@ -14,7 +14,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import TrackersChart from './content/TrackersChart';
-import { fromTrackersToChartData } from '../utils/chart';
+import fromTrackersToChartData from '../utils/chart';
export default class Overview extends React.Component {
get isTrusted() {
diff --git a/app/panel-android/components/Panel.jsx b/app/panel-android/components/Panel.jsx
index 6686379d3..01ea37368 100644
--- a/app/panel-android/components/Panel.jsx
+++ b/app/panel-android/components/Panel.jsx
@@ -23,9 +23,9 @@ import TrackersChart from './content/TrackersChart';
import {
getPanelData, getSummaryData, getSettingsData, getBlockingData
} from '../actions/panelActions';
-import { getCliqzModuleData } from '../actions/cliqzActions';
+import getCliqzModuleData from '../actions/cliqzActions';
import handleAllActions from '../actions/handler';
-import { fromTrackersToChartData } from '../utils/chart';
+import fromTrackersToChartData from '../utils/chart';
export default class Panel extends React.Component {
constructor(props) {
@@ -131,7 +131,7 @@ export default class Panel extends React.Component {
setGlobalState = (updated) => {
const newState = {};
Object.keys(updated).forEach((key) => {
- newState[key] = Object.assign({}, this.state[key], updated[key]);
+ newState[key] = { ...this.state[key], ...updated[key] };
});
this.setState(newState);
diff --git a/app/panel-android/components/content/Accordion.jsx b/app/panel-android/components/content/Accordion.jsx
index c21e8f9bc..7ec893cee 100644
--- a/app/panel-android/components/content/Accordion.jsx
+++ b/app/panel-android/components/content/Accordion.jsx
@@ -99,9 +99,9 @@ export default class Accordion extends React.Component {
const boundingRect = accordionContentNode.getBoundingClientRect();
// Try lo load more when needed
if (scrollTop + window.innerHeight - (accordionContentNode.offsetTop + boundingRect.height) > -needToUpdateHeight) {
- const itemsLength = Math.min(this.state.currentItemsLength + this.nExtraItems, this.props.numTotal);
- this.setState({
- currentItemsLength: itemsLength,
+ this.setState((prevState) => {
+ const itemsLength = Math.min(prevState.currentItemsLength + this.nExtraItems, this.props.numTotal);
+ return { currentItemsLength: itemsLength };
});
}
}
diff --git a/app/panel-android/components/content/FixedMenu.jsx b/app/panel-android/components/content/FixedMenu.jsx
index 4951b58b3..61d826b63 100644
--- a/app/panel-android/components/content/FixedMenu.jsx
+++ b/app/panel-android/components/content/FixedMenu.jsx
@@ -20,11 +20,11 @@ export default class FixedMenu extends React.Component {
super(props);
this.state = {
open: false,
- currentMenuItemText: this.defaultHeaderText,
+ currentMenuItemText: FixedMenu.defaultHeaderText,
};
}
- get defaultHeaderText() {
+ static get defaultHeaderText() {
return 'Enhanced Options';
}
@@ -47,10 +47,14 @@ export default class FixedMenu extends React.Component {
getCount = (type) => {
let total = 0;
switch (type) {
- case 'enable_anti_tracking':
- for (const category in this.antiTrackingData) {
- if (this.antiTrackingData.hasOwnProperty(category)) {
- for (const app in this.antiTrackingData[category]) {
+ case 'enable_anti_tracking': {
+ const categories = Object.keys(this.antiTrackingData);
+ for (let i = 0; i < categories.length; i++) {
+ const category = categories[i];
+ if (Object.prototype.hasOwnProperty.call(this.antiTrackingData, category)) {
+ const apps = Object.keys(this.antiTrackingData[category]);
+ for (let j = 0; j < apps.length; j++) {
+ const app = apps[j];
if (this.antiTrackingData[category][app] === 'unsafe') {
total++;
}
@@ -58,8 +62,9 @@ export default class FixedMenu extends React.Component {
}
}
return total;
+ }
case 'enable_ad_block':
- return this.adBlockData && this.adBlockData.totalCount || 0;
+ return (this.adBlockData && this.adBlockData.totalCount) || 0;
case 'enable_smart_block':
Object.keys(this.smartBlockData.blocked || {}).forEach(() => {
total++;
@@ -81,7 +86,7 @@ export default class FixedMenu extends React.Component {
}
updateHeadeText = (text) => {
- const textToShow = text || this.defaultHeaderText;
+ const textToShow = text || FixedMenu.defaultHeaderText;
this.setState({
currentMenuItemText: textToShow,
diff --git a/app/panel-android/components/content/Path.jsx b/app/panel-android/components/content/Path.jsx
index 3d7ffff0b..2ee06c8fd 100644
--- a/app/panel-android/components/content/Path.jsx
+++ b/app/panel-android/components/content/Path.jsx
@@ -42,8 +42,8 @@ export default class Path extends React.Component {
this.props.handler();
}
- polarToCartesian(centerX, centerY, radius, angleInDegrees) {
- const angleInRadians = (angleInDegrees - 90) * Math.PI / 180.0;
+ static polarToCartesian(centerX, centerY, radius, angleInDegrees) {
+ const angleInRadians = (angleInDegrees - 90) * (Math.PI / 180.0);
return {
x: centerX + (radius * Math.cos(angleInRadians)),
@@ -51,9 +51,9 @@ export default class Path extends React.Component {
};
}
- describeArc(x, y, radius, startAngle, endAngle) {
- const start = this.polarToCartesian(x, y, radius, startAngle);
- const end = this.polarToCartesian(x, y, radius, endAngle);
+ static describeArc(x, y, radius, startAngle, endAngle) {
+ const start = Path.polarToCartesian(x, y, radius, startAngle);
+ const end = Path.polarToCartesian(x, y, radius, endAngle);
const largeArcFlag = endAngle - startAngle <= 180 ? '0' : '1';
@@ -71,7 +71,7 @@ export default class Path extends React.Component {
// Fix error for single path
const end = path.end === 360 ? 359.9999 : path.end;
- const d = this.describeArc(0, 0, radius, start, end);
+ const d = Path.describeArc(0, 0, radius, start, end);
return (
tracker.numTotal).reduce((a, b) => a + b, 0);
for (let i = 0; i < trackers.length; i += 1) {
- const endAngle = startAngle + (trackers[i].numTotal * 360 / sum);
+ const endAngle = startAngle + (trackers[i].numTotal * (360 / sum));
arcs.push({
start: startAngle,
diff --git a/app/panel/actions/DetailActions.js b/app/panel/actions/DetailActions.js
index 00dc5aa7c..20fba18ed 100644
--- a/app/panel/actions/DetailActions.js
+++ b/app/panel/actions/DetailActions.js
@@ -17,7 +17,7 @@ import { TOGGLE_EXPANDED } from '../constants/constants';
* Called from Detail and picked up by Panel reducer
* @return {Object}
*/
-export function toggleExpanded() {
+export default function toggleExpanded() {
return {
type: TOGGLE_EXPANDED,
};
diff --git a/app/panel/actions/SummaryActions.js b/app/panel/actions/SummaryActions.js
index 3dd212710..c987333c9 100644
--- a/app/panel/actions/SummaryActions.js
+++ b/app/panel/actions/SummaryActions.js
@@ -72,10 +72,9 @@ export function updateGhosteryPaused(data) {
});
if (data.time) {
setTimeout(() => {
- data.ghosteryPaused = !data.ghosteryPaused;
dispatch({
type: UPDATE_GHOSTERY_PAUSED,
- data
+ data: { ...data, ghosteryPaused: !data.ghosteryPaused }
});
}, data.time);
}
diff --git a/app/panel/components/Blocking.jsx b/app/panel/components/Blocking.jsx
index cd430a761..07c9b2e30 100644
--- a/app/panel/components/Blocking.jsx
+++ b/app/panel/components/Blocking.jsx
@@ -15,7 +15,7 @@ import React from 'react';
import Categories from './Blocking/Categories';
import BlockingHeader from './Blocking/BlockingHeader';
import NotScanned from './BuildingBlocks/NotScanned';
-import { DynamicUIPortContext } from '../contexts/DynamicUIPortContext';
+import DynamicUIPortContext from '../contexts/DynamicUIPortContext';
import { updateSummaryBlockingCount } from '../utils/blocking';
/**
@@ -75,7 +75,7 @@ class Blocking extends React.Component {
// Update the summary blocking count whenever the blocking component updated.
// This will also show pending blocking changes if the panel is re-opened
// before a page refresh
- const smartBlock = this.props.smartBlockActive && this.props.smartBlock || { blocked: {}, unblocked: {} };
+ const smartBlock = (this.props.smartBlockActive && this.props.smartBlock) || { blocked: {}, unblocked: {} };
updateSummaryBlockingCount(this.props.categories, smartBlock, this.props.actions.updateTrackerCounts);
}
@@ -95,21 +95,21 @@ class Blocking extends React.Component {
const updated_categories = JSON.parse(JSON.stringify(this.props.categories)); // deep clone
const updatedUnknownCategory = JSON.parse(JSON.stringify(this.props.unknownCategory)); // deep clone
- updated_categories.forEach((category) => {
+ updated_categories.forEach((categoryEl) => {
let count = 0;
let show = true;
// filter by donut wheel categories
- if (filterName !== 'all' && filterName !== category.id) {
+ if (filterName !== 'all' && filterName !== categoryEl.id) {
show = false;
}
- category.trackers.forEach((tracker) => {
- tracker.shouldShow = show;
+ categoryEl.trackers.forEach((trackerEl) => {
+ trackerEl.shouldShow = show;
count++;
});
- category.num_shown = (show) ? count : 0;
+ categoryEl.num_shown = (show) ? count : 0;
});
updatedUnknownCategory.hide = !(filterName === 'all' || filterName === 'unknown');
@@ -124,18 +124,18 @@ class Blocking extends React.Component {
setBlockedShow() {
const updated_categories = JSON.parse(JSON.stringify(this.props.categories)); // deep clone
- updated_categories.forEach((category) => {
+ updated_categories.forEach((categoryEl) => {
let count = 0;
- category.trackers.forEach((tracker) => {
- const isSbBlocked = this.props.smartBlockActive && tracker.warningSmartBlock;
- if ((tracker.blocked && !tracker.ss_allowed) || isSbBlocked || tracker.ss_blocked) {
- tracker.shouldShow = true;
+ categoryEl.trackers.forEach((trackerEl) => {
+ const isSbBlocked = this.props.smartBlockActive && trackerEl.warningSmartBlock;
+ if ((trackerEl.blocked && !trackerEl.ss_allowed) || isSbBlocked || trackerEl.ss_blocked) {
+ trackerEl.shouldShow = true;
count++;
} else {
- tracker.shouldShow = false;
+ trackerEl.shouldShow = false;
}
});
- category.num_shown = count;
+ categoryEl.num_shown = count;
});
this.props.actions.updateCategories(updated_categories);
@@ -148,18 +148,18 @@ class Blocking extends React.Component {
setWarningShow() {
const updated_categories = JSON.parse(JSON.stringify(this.props.categories)); // deep clone
- updated_categories.forEach((category) => {
+ updated_categories.forEach((categoryEl) => {
let count = 0;
- category.trackers.forEach((tracker) => {
- if (tracker.warningCompatibility || tracker.warningInsecure || tracker.warningSlow) {
- tracker.shouldShow = true;
+ categoryEl.trackers.forEach((trackerEl) => {
+ if (trackerEl.warningCompatibility || trackerEl.warningInsecure || trackerEl.warningSlow) {
+ trackerEl.shouldShow = true;
count++;
} else {
- tracker.shouldShow = false;
+ trackerEl.shouldShow = false;
}
});
- category.num_shown = count;
+ categoryEl.num_shown = count;
});
this.props.actions.updateCategories(updated_categories);
@@ -172,18 +172,18 @@ class Blocking extends React.Component {
setWarningCompatibilityShow() {
const updated_categories = JSON.parse(JSON.stringify(this.props.categories)); // deep clone
- updated_categories.forEach((category) => {
+ updated_categories.forEach((categoryEl) => {
let count = 0;
- category.trackers.forEach((tracker) => {
- if (tracker.warningCompatibility) {
- tracker.shouldShow = true;
+ categoryEl.trackers.forEach((trackerEl) => {
+ if (trackerEl.warningCompatibility) {
+ trackerEl.shouldShow = true;
count++;
} else {
- tracker.shouldShow = false;
+ trackerEl.shouldShow = false;
}
});
- category.num_shown = count;
+ categoryEl.num_shown = count;
});
this.props.actions.updateCategories(updated_categories);
@@ -196,18 +196,18 @@ class Blocking extends React.Component {
setWarningSlowInsecureShow() {
const updated_categories = JSON.parse(JSON.stringify(this.props.categories)); // deep clone
- updated_categories.forEach((category) => {
+ updated_categories.forEach((categoryEl) => {
let count = 0;
- category.trackers.forEach((tracker) => {
- if (tracker.warningInsecure || tracker.warningSlow) {
- tracker.shouldShow = true;
+ categoryEl.trackers.forEach((trackerEl) => {
+ if (trackerEl.warningInsecure || trackerEl.warningSlow) {
+ trackerEl.shouldShow = true;
count++;
} else {
- tracker.shouldShow = false;
+ trackerEl.shouldShow = false;
}
});
- category.num_shown = count;
+ categoryEl.num_shown = count;
});
this.props.actions.updateCategories(updated_categories);
diff --git a/app/panel/components/Blocking/BlockingHeader.jsx b/app/panel/components/Blocking/BlockingHeader.jsx
index 6f778e11e..a03645407 100644
--- a/app/panel/components/Blocking/BlockingHeader.jsx
+++ b/app/panel/components/Blocking/BlockingHeader.jsx
@@ -56,7 +56,7 @@ class BlockingHeader extends React.Component {
if (typeof this.props.actions.updateTrackerCounts === 'function') {
// if we're on GlobalSettings, we don't need to run this function
- const smartBlock = this.props.smartBlockActive && this.props.smartBlock || { blocked: {}, unblocked: {} };
+ const smartBlock = (this.props.smartBlockActive && this.props.smartBlock) || { blocked: {}, unblocked: {} };
updateSummaryBlockingCount(this.props.categories, smartBlock, this.props.actions.updateTrackerCounts);
}
}
@@ -133,7 +133,7 @@ class BlockingHeader extends React.Component {
if (typeof this.props.actions.updateTrackerCounts === 'function') {
// if we're on GlobalSettings, we don't need to run this function
- const smartBlock = this.props.smartBlockActive && this.props.smartBlock || { blocked: {}, unblocked: {} };
+ const smartBlock = (this.props.smartBlockActive && this.props.smartBlock) || { blocked: {}, unblocked: {} };
updateSummaryBlockingCount(this.props.categories, smartBlock, this.props.actions.updateTrackerCounts);
}
@@ -186,7 +186,7 @@ class BlockingHeader extends React.Component {
* @param {Object} event mouseclick event
*/
clickFilterText() {
- this.setState({ filterMenuOpened: !this.state.filterMenuOpened });
+ this.setState(prevState => ({ filterMenuOpened: !prevState.filterMenuOpened }));
}
/**
diff --git a/app/panel/components/Blocking/Category.jsx b/app/panel/components/Blocking/Category.jsx
index 4dafc5879..29905d940 100644
--- a/app/panel/components/Blocking/Category.jsx
+++ b/app/panel/components/Blocking/Category.jsx
@@ -13,7 +13,7 @@
import React from 'react';
import ClassNames from 'classnames';
-import { ThemeContext } from '../../contexts/ThemeContext';
+import ThemeContext from '../../contexts/ThemeContext';
import Trackers from './Trackers';
/**
diff --git a/app/panel/components/Blocking/GlobalTracker.jsx b/app/panel/components/Blocking/GlobalTracker.jsx
index 9169c3d1a..8bade7666 100644
--- a/app/panel/components/Blocking/GlobalTracker.jsx
+++ b/app/panel/components/Blocking/GlobalTracker.jsx
@@ -47,7 +47,7 @@ class GlobalTracker extends React.Component {
*/
toggleDescription() {
const { tracker } = this.props;
- this.setState({ showMoreInfo: !this.state.showMoreInfo });
+ this.setState(prevState => ({ showMoreInfo: !prevState.showMoreInfo }));
if (this.state.description) {
return;
diff --git a/app/panel/components/Blocking/Tracker.jsx b/app/panel/components/Blocking/Tracker.jsx
index 917a13457..b0a73a710 100644
--- a/app/panel/components/Blocking/Tracker.jsx
+++ b/app/panel/components/Blocking/Tracker.jsx
@@ -16,7 +16,7 @@
import React from 'react';
import ClassNames from 'classnames';
-import { ThemeContext } from '../../contexts/ThemeContext';
+import ThemeContext from '../../contexts/ThemeContext';
import globals from '../../../../src/classes/Globals';
import { log } from '../../../../src/utils/common';
import { sendMessageInPromise } from '../../utils/msg';
@@ -82,7 +82,7 @@ class Tracker extends React.Component {
*/
toggleDescription() {
const { tracker } = this.props;
- this.setState({ showMoreInfo: !this.state.showMoreInfo });
+ this.setState(prevState => ({ showMoreInfo: !prevState.showMoreInfo }));
if (this.state.description) {
return;
@@ -242,14 +242,14 @@ class Tracker extends React.Component {
{(oneOrMoreCookies || oneOrMoreFingerprints) && (
{this._renderCliqzCookiesAndFingerprintsIcon()}
- {oneOrMoreCookies && this._renderCliqzCookieStat(cliqzCookieCount)}
- {oneOrMoreFingerprints && this._renderCliqzFingerprintStat(cliqzFingerprintCount)}
+ {oneOrMoreCookies && Tracker._renderCliqzCookieStat(cliqzCookieCount)}
+ {oneOrMoreFingerprints && Tracker._renderCliqzFingerprintStat(cliqzFingerprintCount)}
)}
{oneOrMoreAds && (
{this._renderCliqzAdsIcon()}
- {this._renderCliqzAdStat(cliqzAdCount)}
+ {Tracker._renderCliqzAdStat(cliqzAdCount)}
)}
@@ -275,13 +275,13 @@ class Tracker extends React.Component {
);
}
- _renderCliqzCookieStat(count) { return this._renderCliqzStat(count, 'cookie'); }
+ static _renderCliqzCookieStat(count) { return Tracker._renderCliqzStat(count, 'cookie'); }
- _renderCliqzFingerprintStat(count) { return this._renderCliqzStat(count, 'fingerprint'); }
+ static _renderCliqzFingerprintStat(count) { return Tracker._renderCliqzStat(count, 'fingerprint'); }
- _renderCliqzAdStat(count) { return this._renderCliqzStat(count, 'ad'); }
+ static _renderCliqzAdStat(count) { return Tracker._renderCliqzStat(count, 'ad'); }
- _renderCliqzStat(count, type) {
+ static _renderCliqzStat(count, type) {
const exactlyOne = count === 1;
const label = exactlyOne ?
t(`${type}`) :
diff --git a/app/panel/components/BuildingBlocks/CliqzFeature.jsx b/app/panel/components/BuildingBlocks/CliqzFeature.jsx
index b699e387a..353cf635c 100644
--- a/app/panel/components/BuildingBlocks/CliqzFeature.jsx
+++ b/app/panel/components/BuildingBlocks/CliqzFeature.jsx
@@ -46,15 +46,15 @@ class CliqzFeature extends React.Component {
clickButton({
feature: `enable_${featureType}`,
status: active,
- text: this._getAlertText(active, type),
+ text: CliqzFeature._getAlertText(active, type),
});
}
- _getStatus(active) {
+ static _getStatus(active) {
return active ? t('on') : t('off');
}
- _getTooltipBodyText(active, isTooltipBody, type) {
+ static _getTooltipBodyText(active, isTooltipBody, type) {
if (!isTooltipBody) return false;
if (active) {
@@ -82,7 +82,7 @@ class CliqzFeature extends React.Component {
}
}
- _getTooltipHeaderText(isTooltipHeader, type) {
+ static _getTooltipHeaderText(isTooltipHeader, type) {
if (!isTooltipHeader) return false;
switch (type) {
@@ -97,7 +97,7 @@ class CliqzFeature extends React.Component {
}
}
- _getAlertText(active, type) {
+ static _getAlertText(active, type) {
return active ?
t(`alert_${type}_off`) :
t(`alert_${type}_on`);
@@ -145,11 +145,11 @@ class CliqzFeature extends React.Component {
return (
-
{this._getStatus(active)}
+
{CliqzFeature._getStatus(active)}
diff --git a/app/panel/components/BuildingBlocks/DonutGraph.jsx b/app/panel/components/BuildingBlocks/DonutGraph.jsx
index 67a9bd90a..dec7cb5da 100644
--- a/app/panel/components/BuildingBlocks/DonutGraph.jsx
+++ b/app/panel/components/BuildingBlocks/DonutGraph.jsx
@@ -142,14 +142,14 @@ class DonutGraph extends React.Component {
/**
* Helper function that calculates domain value for greyscale / redscale rendering
*/
- getTone(catCount, catIndex) {
- return catCount > 1 ? 100 / (catCount - 1) * catIndex * 0.01 : 0;
+ static getTone(catCount, catIndex) {
+ return catCount > 1 ? (100 / (catCount - 1)) * catIndex * 0.01 : 0;
}
/**
* Helper to retrieve a category's tooltip from the DOM
*/
- grabTooltip(d) {
+ static grabTooltip(d) {
return document.getElementById(`${d.data.id}_tooltip`);
}
@@ -264,9 +264,11 @@ class DonutGraph extends React.Component {
this._endAngles.set(catId, d.endAngle);
return function(t) {
- d.startAngle = lerpStartAngle(t);
- d.endAngle = lerpEndAngle(t);
- return trackerArc(d);
+ return trackerArc({
+ ...d,
+ startAngle: lerpStartAngle(t),
+ endAngle: lerpEndAngle(t),
+ });
};
});
@@ -276,10 +278,10 @@ class DonutGraph extends React.Component {
.append('path')
.style('fill', (d, i) => {
if (renderGreyscale) {
- return this.colors.greyscale(this.getTone(categoryCount, i));
+ return this.colors.greyscale(DonutGraph.getTone(categoryCount, i));
}
if (renderRedscale) {
- return this.colors.redscale(this.getTone(categoryCount, i));
+ return this.colors.redscale(DonutGraph.getTone(categoryCount, i));
}
return this.colors.regular(d.data.id);
})
@@ -293,7 +295,7 @@ class DonutGraph extends React.Component {
const centroid = trackerArc.centroid(d);
const pX = centroid[0] + this.donutRadius;
const pY = centroid[1] + this.donutRadius;
- const tooltip = this.grabTooltip(d);
+ const tooltip = DonutGraph.grabTooltip(d);
if (tooltip) {
tooltip.style.left = `${pX - (tooltip.offsetWidth / 2)}px`;
tooltip.style.top = `${pY - (tooltip.offsetHeight + 8)}px`;
@@ -301,7 +303,7 @@ class DonutGraph extends React.Component {
}
})
.on('mouseout', (d) => {
- const tooltip = this.grabTooltip(d);
+ const tooltip = DonutGraph.grabTooltip(d);
if (tooltip) {
tooltip.classList.remove('DonutGraph__tooltip--show');
}
@@ -320,8 +322,10 @@ class DonutGraph extends React.Component {
const i = interpolate(d.startAngle, d.endAngle);
return function(t) {
- d.endAngle = i(t);
- return trackerArc(d);
+ return trackerArc({
+ ...d,
+ endAngle: i(t)
+ });
};
})
.ease(easeLinear);
diff --git a/app/panel/components/BuildingBlocks/GhosteryFeature.jsx b/app/panel/components/BuildingBlocks/GhosteryFeature.jsx
index afd498a35..8d127474e 100644
--- a/app/panel/components/BuildingBlocks/GhosteryFeature.jsx
+++ b/app/panel/components/BuildingBlocks/GhosteryFeature.jsx
@@ -40,7 +40,7 @@ class GhosteryFeature extends React.Component {
this.props.handleClick(this.props.type);
}
- _getButtonText(sitePolicy, showText, type) {
+ static _getButtonText(sitePolicy, showText, type) {
if (!showText) {
return '';
}
@@ -59,7 +59,7 @@ class GhosteryFeature extends React.Component {
}
}
- _getTooltipText(sitePolicy, type) {
+ static _getTooltipText(sitePolicy, type) {
switch (type) {
case 'trust':
return (sitePolicy === WHITELISTED ?
@@ -74,7 +74,7 @@ class GhosteryFeature extends React.Component {
}
}
- _isFeatureActive(type, sitePolicy) {
+ static _isFeatureActive(type, sitePolicy) {
switch (type) {
case 'trust':
return sitePolicy === WHITELISTED;
@@ -96,7 +96,7 @@ class GhosteryFeature extends React.Component {
type
} = this.props;
- const active = this._isFeatureActive(type, sitePolicy);
+ const active = GhosteryFeature._isFeatureActive(type, sitePolicy);
// TODO Foundation dependency: button
const ghosteryFeatureClassNames = ClassNames(
'button',
@@ -120,10 +120,10 @@ class GhosteryFeature extends React.Component {
- {this._getButtonText(sitePolicy, showText, type)}
+ {GhosteryFeature._getButtonText(sitePolicy, showText, type)}
-
+
);
}
diff --git a/app/panel/components/BuildingBlocks/StatsGraph.jsx b/app/panel/components/BuildingBlocks/StatsGraph.jsx
index 80e89ec4d..5b9b34088 100644
--- a/app/panel/components/BuildingBlocks/StatsGraph.jsx
+++ b/app/panel/components/BuildingBlocks/StatsGraph.jsx
@@ -14,7 +14,7 @@
import { isEqual } from 'underscore';
import React from 'react';
import * as D3 from 'd3';
-import { ThemeContext } from '../../contexts/ThemeContext';
+import ThemeContext from '../../contexts/ThemeContext';
/**
* Generates an animated graph displaying locally stored stats
* @memberof PanelBuildingBlocks
@@ -79,7 +79,8 @@ class StatsGraph extends React.Component {
}
const data = JSON.parse(JSON.stringify(this.props.data));
- data.forEach((entry) => {
+ data.forEach((e) => {
+ const entry = e;
entry.date = parseMonth(entry.date);
});
diff --git a/app/panel/components/BuildingBlocks/ToggleSlider.jsx b/app/panel/components/BuildingBlocks/ToggleSlider.jsx
index 1f467cbca..185e4ee5b 100644
--- a/app/panel/components/BuildingBlocks/ToggleSlider.jsx
+++ b/app/panel/components/BuildingBlocks/ToggleSlider.jsx
@@ -50,9 +50,7 @@ class ToggleSlider extends React.Component {
if (typeof this.props.onChange === 'function') {
this.props.onChange(event);
} else {
- this.setState({
- checked: !this.state.checked,
- });
+ this.setState(prevState => ({ checked: !prevState.checked }));
}
}
diff --git a/app/panel/components/DetailMenu.jsx b/app/panel/components/DetailMenu.jsx
index 9443029d5..275174694 100644
--- a/app/panel/components/DetailMenu.jsx
+++ b/app/panel/components/DetailMenu.jsx
@@ -41,12 +41,14 @@ class DetailMenu extends React.Component {
* @param {Object} event click event
*/
setActiveTab(event) {
- const menu = Object.assign({}, this.state.menu);
const selectionId = event.currentTarget.id;
-
- Object.keys(menu).forEach((key) => { menu[key] = selectionId === key; });
sendMessage('ping', DetailMenu.pings[selectionId]);
- this.setState({ menu });
+
+ this.setState((prevState) => {
+ const menu = { ...prevState.menu };
+ Object.keys(menu).forEach((key) => { menu[key] = selectionId === key; });
+ return { menu };
+ });
}
/**
diff --git a/app/panel/components/Header.jsx b/app/panel/components/Header.jsx
index 5f31d701a..ac3e19448 100644
--- a/app/panel/components/Header.jsx
+++ b/app/panel/components/Header.jsx
@@ -65,7 +65,7 @@ class Header extends React.Component {
* Handles toggling the drop-down pane open/closed
*/
toggleDropdown = () => {
- this.setState({ dropdownOpen: !this.state.dropdownOpen });
+ this.setState(prevState => ({ dropdownOpen: !prevState.dropdownOpen }));
}
handleSignin = () => {
@@ -109,7 +109,7 @@ class Header extends React.Component {
}
let accountIcon;
- if (!loggedIn || loggedIn && user && !user.emailValidated) {
+ if (!loggedIn || (loggedIn && user && !user.emailValidated)) {
accountIcon = (