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

Code Cleanup: Enforce Linting Rules & Update UNSAFE_ React Lifecycle Events #559

Merged
merged 33 commits into from Jun 4, 2020
Merged
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
75b0091
add linting for no-param-reassign and fix resulting linting errors
IAmThePan Apr 29, 2020
8d37082
add linting for prefer-object-spread and fix resulting linting errors
IAmThePan Apr 29, 2020
3049bd1
add linting for no-restricted-syntax and fix 1/2 of resulting errors
IAmThePan May 1, 2020
fe03ad7
add linting for no-prototype-builtins and fix resulting linting errors
IAmThePan May 4, 2020
f11bc18
add linting for class-methods-use-this and fix most resulting errors.…
IAmThePan May 5, 2020
5f3471e
finish linting for class-methods-use-this
IAmThePan May 6, 2020
d4d84dc
add linting for no-mixed-operators and fix resulting linting errors
IAmThePan May 6, 2020
17f90ed
add linting for import/prefer-default-export and fix resulting lintin…
IAmThePan May 8, 2020
a77cd1b
add linting for react/no-access-state-in-setstate and fix resulting l…
IAmThePan May 8, 2020
c31dbaf
add linting for react/jsx-props-no-spreading and fix resulting lintin…
IAmThePan May 11, 2020
3d50aff
finish linting errors for no-restricted-syntax. 1 remains: couldn't r…
IAmThePan May 12, 2020
227d012
Merge branch 'develop' into feature/update-linter
IAmThePan May 12, 2020
0988a29
Fix linting errors resulting from the merge with develop
IAmThePan May 12, 2020
b55be21
Refactor UNSAFE_componentWillMount into either constructor or compone…
IAmThePan May 14, 2020
241747c
Refactor UNSAFE_componentWillReceiveProps to componentDidUpdate or ge…
IAmThePan May 18, 2020
eb413fb
re-enable lint exception for no-prototype-builtins and revert calls b…
IAmThePan May 20, 2020
ac0ec93
add single line exception for no-restricted-syntax linting rule
IAmThePan May 20, 2020
fd954eb
add linting for react/destructuring-assignment and fix errors. ToDo: …
IAmThePan May 21, 2020
e815546
Fix minor bugs
IAmThePan May 22, 2020
ae8ffcc
Fix General Settings last updated text
IAmThePan May 22, 2020
4c56460
rework linting rule no-param-reassign to have more exceptions and par…
IAmThePan May 23, 2020
c5ef663
Remove file and line linting exceptions.
IAmThePan May 26, 2020
3ca2402
re-add linting rule react/sort-comp and fix resulting errors
IAmThePan May 26, 2020
4533fd7
remove added linting exception consistent-return and fix resulting er…
IAmThePan May 26, 2020
590aa60
remove added linting expression no-use-before-define and fix resultin…
IAmThePan May 26, 2020
ecb62e8
Fix linting error
IAmThePan May 26, 2020
f634c1d
fix minor bugs
IAmThePan May 26, 2020
ea51432
Code cleanup: fix PromoModal imports
IAmThePan May 26, 2020
75a88cb
Merge with develop. Fix resulting linting errors
IAmThePan May 26, 2020
68493d2
remove unnecessary hasOwnProperty calls after refactored for...in loops
IAmThePan May 28, 2020
6297062
Fix missing strings bug
IAmThePan May 28, 2020
9b4d16c
Fix last remaining string bug
IAmThePan May 28, 2020
2cb47a1
Merge branch 'develop' into feature/cleanup
IAmThePan Jun 4, 2020
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],
This conversation was marked as resolved by wlycdgr

This comment has been minimized.

This comment has been minimized.

@IAmThePan

IAmThePan Jun 11, 2020
Author Contributor

updated in feature/cleanup-cleanup as this PR was already merged.

This comment has been minimized.

@wlycdgr

wlycdgr Jun 11, 2020
Member

lgtm in feature/cleanup-cleanup


// 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.