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 #552

Closed
wants to merge 13 commits into from
Closed
Changes from 1 commit
Commits
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

add linting for import/prefer-default-export and fix resulting lintin…

…g errors
  • Loading branch information
IAmThePan committed May 8, 2020
commit 17f90ed75df1752fbedbcd021fcbf60b3abe4436
@@ -77,7 +77,7 @@ module.exports = {

// Plugin: Import
'import/no-cycle': [0],
'import/prefer-default-export': [0], // TODO: enable this check
'import/prefer-default-export': [1],

// Plugin: React
'react/destructuring-assignment': [0],
@@ -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.
@@ -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({
@@ -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]);
});
@@ -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';

/**
@@ -35,7 +35,7 @@ const mapStateToProps = state => ({ ...state.setup });
*/
const mapDispatchToProps = dispatch => ({
actions: bindActionCreators({
...SetupBlockingViewActions,
setBlockingPolicy,
setSetupStep,
setSetupNavigation
}, dispatch),
@@ -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({
@@ -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]);
});
@@ -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';

/**
@@ -34,7 +34,7 @@ const mapStateToProps = state => ({ ...state.setup });
*/
const mapDispatchToProps = dispatch => ({
actions: bindActionCreators({
...SetupDoneViewActions,
setSetupComplete,
setSetupStep,
setSetupNavigation
}, dispatch),
@@ -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({
@@ -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]);
});
@@ -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';

/**
@@ -34,7 +34,7 @@ const mapStateToProps = state => ({ ...state.setup });
*/
const mapDispatchToProps = dispatch => ({
actions: bindActionCreators({
...SetupHumanWebViewActions,
setHumanWeb,
setSetupStep,
setSetupNavigation
}, dispatch),
@@ -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({
@@ -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]);
});
@@ -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';

/**
@@ -33,7 +33,7 @@ const mapStateToProps = state => ({ ...state.tutorial });
* @memberof TutorialContainers
*/
const mapDispatchToProps = dispatch => ({
actions: bindActionCreators({ ...TutorialAntiSuiteViewActions, setTutorialNavigation }, dispatch),
actions: bindActionCreators({ setTutorialComplete, setTutorialNavigation }, dispatch),
});

export default connect(mapStateToProps, mapDispatchToProps)(TutorialAntiSuiteViewContainer);
@@ -13,7 +13,7 @@

import { sendMessageInPromise } from '../../panel/utils/msg';

export function getCliqzModuleData(tabId) {
export default function getCliqzModuleData(tabId) {
return sendMessageInPromise('getCliqzModuleData', {
tabId,
});
@@ -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() {
@@ -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) {
@@ -14,7 +14,7 @@
* @namespace PanelAndroidUtils
*/

export function fromTrackersToChartData(trackers) {
export default function fromTrackersToChartData(trackers) {
if (trackers.length < 1) {
return {
sum: 0,
@@ -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,
};
@@ -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';

/**
@@ -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';

/**
@@ -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';
@@ -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
@@ -15,8 +15,8 @@ import React from 'react';
import { NavLink } from 'react-router-dom';
import Header from '../containers/HeaderContainer';
import PromoModalContainer from '../../shared-components/PromoModal/PromoModalContainer';
import { ThemeContext } from '../contexts/ThemeContext';
import { DynamicUIPortContext } from '../contexts/DynamicUIPortContext';
import ThemeContext from '../contexts/ThemeContext';
import DynamicUIPortContext from '../contexts/DynamicUIPortContext';
import { sendMessage } from '../utils/msg';
import { setTheme } from '../utils/utils';

@@ -15,7 +15,7 @@ import React, { Fragment } from 'react';
import ClassNames from 'classnames';
import { Route } from 'react-router-dom';
import { ToggleSlider } from './BuildingBlocks';
import { DynamicUIPortContext } from '../contexts/DynamicUIPortContext';
import DynamicUIPortContext from '../contexts/DynamicUIPortContext';
import { sendMessage } from '../utils/msg';
import globals from '../../../src/classes/Globals';
import { log } from '../../../src/utils/common';
@@ -24,7 +24,7 @@ import Notifications from './Settings/Notifications';
import OptIn from './Settings/OptIn';
import Purplebox from './Settings/Purplebox';
import Account from './Settings/Account';
import { DynamicUIPortContext } from '../contexts/DynamicUIPortContext';
import DynamicUIPortContext from '../contexts/DynamicUIPortContext';
/**
* @class Implement base Settings view which routes navigation to all settings subviews
* @memberof PanelClasses
@@ -15,7 +15,7 @@ import React from 'react';
import { ReactSVG } from 'react-svg';
import ClassNames from 'classnames';
import Tooltip from './Tooltip';
import { DynamicUIPortContext } from '../contexts/DynamicUIPortContext';
import DynamicUIPortContext from '../contexts/DynamicUIPortContext';
import { sendMessage } from '../utils/msg';
import globals from '../../../src/classes/Globals';
import {
@@ -15,7 +15,7 @@ import React from 'react';
import renderer from 'react-test-renderer';
import { MemoryRouter } from 'react-router';
import Rewards from '../Rewards';
import { DynamicUIPortContext } from '../../contexts/DynamicUIPortContext';
import DynamicUIPortContext from '../../contexts/DynamicUIPortContext';


// Fake the translation function to only return the translation key
@@ -14,7 +14,7 @@
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import Detail from '../components/Detail';
import * as actions from '../actions/DetailActions';
import toggleExpanded from '../actions/DetailActions';
/**
* Map redux store state properties to Detailed view own properties.
* @memberOf PanelContainers
@@ -37,7 +37,7 @@ const mapStateToProps = state => ({
* @param {Object} ownProps Detailed view component own props
* @return {function} to be used as an argument in redux connect call
*/
const mapDispatchToProps = dispatch => ({ actions: bindActionCreators(actions, dispatch) });
const mapDispatchToProps = dispatch => ({ actions: bindActionCreators({ toggleExpanded }, dispatch) });
/**
* Connects Detailed view component to the Redux store.
* @memberOf PanelContainers
@@ -14,7 +14,7 @@ import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import Settings from '../components/Settings';
import * as settingsActions from '../actions/SettingsActions';
import { toggleExpanded } from '../actions/DetailActions';
import toggleExpanded from '../actions/DetailActions';
import { updateSitePolicy } from '../actions/SummaryActions';
import { sendSignal } from '../actions/RewardsActions';
/**
@@ -13,4 +13,5 @@

import React from 'react';

export const DynamicUIPortContext = React.createContext(null);
const DynamicUIPortContext = React.createContext(null);
export default DynamicUIPortContext;
@@ -13,4 +13,5 @@

import React from 'react';

export const ThemeContext = React.createContext(null);
const ThemeContext = React.createContext(null);
export default ThemeContext;
@@ -50,7 +50,7 @@ import { allowAllwaysC2P } from './utils/click2play';
import * as common from './utils/common';
import * as utils from './utils/utils';
import { _getJSONAPIErrorsObject } from './utils/api';
import { importCliqzSettings } from './utils/cliqzSettingImport';
import importCliqzSettings from './utils/cliqzSettingImport';
import { sendCliqzModuleCounts } from './utils/cliqzModulesData';

// For debug purposes, provide Access to the internals of `browser-core`
@@ -93,7 +93,7 @@ function _runCliqzSettingsImport(cliqz, c) {
* @param {Object} cliqz
* @param {Object} c conf
*/
export function importCliqzSettings(cliqz, c) {
export default function importCliqzSettings(cliqz, c) {
const conf = c;
log('checking cliqz import', conf.cliqz_import_state);
if (!conf.cliqz_import_state) {
ProTip! Use n and p to navigate between commits in a pull request.