From 9f01a7fdf8dd834c9aaa04cfe06d512ead6a19ef Mon Sep 17 00:00:00 2001 From: Kamil Gabryjelski Date: Tue, 22 Sep 2020 22:17:41 +0200 Subject: [PATCH] ESLint: Re-enable rule default-props-match-prop-types (#10868) * Re-enable rule default-props-match-prop-types * Restore default props and remove isRequired * Remove unused props --- superset-frontend/.eslintrc.js | 2 -- .../components/DashboardBuilder_spec.jsx | 3 --- superset-frontend/src/CRUD/Field.jsx | 3 +-- .../components/ExploreCtasResultsButton.jsx | 5 ----- .../src/SqlLab/components/SqlEditorLeftBar.jsx | 2 +- .../SqlLab/components/TemplateParamsEditor.jsx | 2 -- superset-frontend/src/components/Hotkeys.jsx | 5 ----- .../src/components/Select/OnPasteSelect.jsx | 6 +++--- .../components/ColorSchemeControlWrapper.jsx | 4 ++-- .../dashboard/components/DashboardBuilder.jsx | 17 +---------------- .../dashboard/components/PropertiesModal.jsx | 2 +- .../src/dashboard/components/SliceAdder.jsx | 2 +- .../src/dashboard/components/SliceHeader.jsx | 1 - .../dashboard/components/gridComponents/Row.jsx | 5 ----- .../components/gridComponents/Tabs.jsx | 1 - .../components/menu/WithPopoverMenu.jsx | 1 - .../dashboard/containers/DashboardBuilder.jsx | 4 ---- .../dashboard/containers/DashboardComponent.jsx | 1 - .../src/explore/components/QueryAndSaveBtns.jsx | 1 - .../components/controls/ColorSchemeControl.jsx | 4 ++-- .../components/controls/ViewportControl.jsx | 2 +- 21 files changed, 13 insertions(+), 60 deletions(-) diff --git a/superset-frontend/.eslintrc.js b/superset-frontend/.eslintrc.js index 1d5c49220..ed437f9cc 100644 --- a/superset-frontend/.eslintrc.js +++ b/superset-frontend/.eslintrc.js @@ -117,7 +117,6 @@ module.exports = { 'padded-blocks': 0, 'prefer-arrow-callback': 0, 'prefer-destructuring': ['error', { object: true, array: false }], - 'react/default-props-match-prop-types': 0, // disabled temporarily 'react/destructuring-assignment': 0, // re-enable up for discussion 'react/forbid-prop-types': 0, 'react/jsx-filename-extension': [1, { extensions: ['.jsx', '.tsx'] }], @@ -228,7 +227,6 @@ module.exports = { 'prefer-arrow-callback': 0, 'prefer-object-spread': 1, 'prefer-destructuring': ['error', { object: true, array: false }], - 'react/default-props-match-prop-types': 0, // disabled temporarily 'react/destructuring-assignment': 0, // re-enable up for discussion 'react/forbid-prop-types': 0, 'react/jsx-filename-extension': [1, { extensions: ['.jsx', '.tsx'] }], diff --git a/superset-frontend/spec/javascripts/dashboard/components/DashboardBuilder_spec.jsx b/superset-frontend/spec/javascripts/dashboard/components/DashboardBuilder_spec.jsx index 82211c4ca..5de21354c 100644 --- a/superset-frontend/spec/javascripts/dashboard/components/DashboardBuilder_spec.jsx +++ b/superset-frontend/spec/javascripts/dashboard/components/DashboardBuilder_spec.jsx @@ -62,9 +62,6 @@ describe('DashboardBuilder', () => { dashboardLayout, deleteTopLevelTabs() {}, editMode: false, - showBuilderPane() {}, - setColorSchemeAndUnsavedChanges() {}, - colorScheme: undefined, handleComponentDrop() {}, setDirectPathToChild: sinon.spy(), }; diff --git a/superset-frontend/src/CRUD/Field.jsx b/superset-frontend/src/CRUD/Field.jsx index 3d56019fa..3ed439f2e 100644 --- a/superset-frontend/src/CRUD/Field.jsx +++ b/superset-frontend/src/CRUD/Field.jsx @@ -39,10 +39,9 @@ const propTypes = { compact: PropTypes.bool, }; const defaultProps = { - controlProps: {}, onChange: () => {}, compact: false, - desc: null, + description: null, }; export default class Field extends React.PureComponent { diff --git a/superset-frontend/src/SqlLab/components/ExploreCtasResultsButton.jsx b/superset-frontend/src/SqlLab/components/ExploreCtasResultsButton.jsx index 0fac3d115..3c3e2036c 100644 --- a/superset-frontend/src/SqlLab/components/ExploreCtasResultsButton.jsx +++ b/superset-frontend/src/SqlLab/components/ExploreCtasResultsButton.jsx @@ -37,10 +37,6 @@ const propTypes = { templateParams: PropTypes.string, }; -const defaultProps = { - vizRequest: {}, -}; - class ExploreCtasResultsButton extends React.PureComponent { constructor(props) { super(props); @@ -113,7 +109,6 @@ class ExploreCtasResultsButton extends React.PureComponent { } } ExploreCtasResultsButton.propTypes = propTypes; -ExploreCtasResultsButton.defaultProps = defaultProps; function mapStateToProps({ sqlLab, common }) { return { diff --git a/superset-frontend/src/SqlLab/components/SqlEditorLeftBar.jsx b/superset-frontend/src/SqlLab/components/SqlEditorLeftBar.jsx index 552ba4ce6..66a538584 100644 --- a/superset-frontend/src/SqlLab/components/SqlEditorLeftBar.jsx +++ b/superset-frontend/src/SqlLab/components/SqlEditorLeftBar.jsx @@ -25,7 +25,7 @@ import TableSelector from '../../components/TableSelector'; const propTypes = { queryEditor: PropTypes.object.isRequired, - height: PropTypes.number.isRequired, + height: PropTypes.number, tables: PropTypes.array, actions: PropTypes.object, database: PropTypes.object, diff --git a/superset-frontend/src/SqlLab/components/TemplateParamsEditor.jsx b/superset-frontend/src/SqlLab/components/TemplateParamsEditor.jsx index a15f5638b..455257688 100644 --- a/superset-frontend/src/SqlLab/components/TemplateParamsEditor.jsx +++ b/superset-frontend/src/SqlLab/components/TemplateParamsEditor.jsx @@ -33,8 +33,6 @@ const propTypes = { }; const defaultProps = { - label: null, - description: null, onChange: () => {}, code: '{}', }; diff --git a/superset-frontend/src/components/Hotkeys.jsx b/superset-frontend/src/components/Hotkeys.jsx index c0d4707bf..546d3ed07 100644 --- a/superset-frontend/src/components/Hotkeys.jsx +++ b/superset-frontend/src/components/Hotkeys.jsx @@ -33,10 +33,6 @@ const propTypes = { placement: PropTypes.string, }; -const defaultProps = { - hotkeys: [], -}; - export default class Hotkeys extends React.PureComponent { componentDidMount() { this.props.hotkeys.forEach(keyConfig => { @@ -86,4 +82,3 @@ export default class Hotkeys extends React.PureComponent { } Hotkeys.propTypes = propTypes; -Hotkeys.defaultProps = defaultProps; diff --git a/superset-frontend/src/components/Select/OnPasteSelect.jsx b/superset-frontend/src/components/Select/OnPasteSelect.jsx index fcf1e1034..e7d08aea0 100644 --- a/superset-frontend/src/components/Select/OnPasteSelect.jsx +++ b/superset-frontend/src/components/Select/OnPasteSelect.jsx @@ -81,12 +81,12 @@ export default class OnPasteSelect extends React.Component { } OnPasteSelect.propTypes = { - separator: PropTypes.array.isRequired, + separator: PropTypes.array, selectWrap: PropTypes.elementType, selectRef: PropTypes.func, onChange: PropTypes.func.isRequired, - valueKey: PropTypes.string.isRequired, - labelKey: PropTypes.string.isRequired, + valueKey: PropTypes.string, + labelKey: PropTypes.string, options: PropTypes.array, isMulti: PropTypes.bool, value: PropTypes.any, diff --git a/superset-frontend/src/dashboard/components/ColorSchemeControlWrapper.jsx b/superset-frontend/src/dashboard/components/ColorSchemeControlWrapper.jsx index b2e14d103..d60794640 100644 --- a/superset-frontend/src/dashboard/components/ColorSchemeControlWrapper.jsx +++ b/superset-frontend/src/dashboard/components/ColorSchemeControlWrapper.jsx @@ -24,13 +24,13 @@ import { getCategoricalSchemeRegistry, t } from '@superset-ui/core'; import ColorSchemeControl from 'src/explore/components/controls/ColorSchemeControl'; const propTypes = { - onChange: PropTypes.func.isRequired, + onChange: PropTypes.func, colorScheme: PropTypes.string, }; const defaultProps = { - colorScheme: undefined, onChange: () => {}, + colorScheme: undefined, }; class ColorSchemeControlWrapper extends React.PureComponent { diff --git a/superset-frontend/src/dashboard/components/DashboardBuilder.jsx b/superset-frontend/src/dashboard/components/DashboardBuilder.jsx index ecaf3cf2e..3f798c110 100644 --- a/superset-frontend/src/dashboard/components/DashboardBuilder.jsx +++ b/superset-frontend/src/dashboard/components/DashboardBuilder.jsx @@ -54,9 +54,6 @@ const propTypes = { dashboardLayout: PropTypes.object.isRequired, deleteTopLevelTabs: PropTypes.func.isRequired, editMode: PropTypes.bool.isRequired, - showBuilderPane: PropTypes.func.isRequired, - colorScheme: PropTypes.string, - setColorSchemeAndUnsavedChanges: PropTypes.func.isRequired, handleComponentDrop: PropTypes.func.isRequired, directPathToChild: PropTypes.arrayOf(PropTypes.string), setDirectPathToChild: PropTypes.func.isRequired, @@ -64,9 +61,7 @@ const propTypes = { }; const defaultProps = { - showBuilderPane: false, directPathToChild: [], - colorScheme: undefined, }; class DashboardBuilder extends React.Component { @@ -155,14 +150,7 @@ class DashboardBuilder extends React.Component { } render() { - const { - handleComponentDrop, - dashboardLayout, - editMode, - showBuilderPane, - setColorSchemeAndUnsavedChanges, - colorScheme, - } = this.props; + const { handleComponentDrop, dashboardLayout, editMode } = this.props; const { tabIndex } = this.state; const dashboardRoot = dashboardLayout[DASHBOARD_ROOT_ID]; const rootChildId = dashboardRoot.children[0]; @@ -272,9 +260,6 @@ class DashboardBuilder extends React.Component { {editMode && ( )} diff --git a/superset-frontend/src/dashboard/components/PropertiesModal.jsx b/superset-frontend/src/dashboard/components/PropertiesModal.jsx index 57f348282..2637f519e 100644 --- a/superset-frontend/src/dashboard/components/PropertiesModal.jsx +++ b/superset-frontend/src/dashboard/components/PropertiesModal.jsx @@ -35,7 +35,7 @@ import '../stylesheets/buttons.less'; const propTypes = { dashboardId: PropTypes.number.isRequired, - show: PropTypes.bool.isRequired, + show: PropTypes.bool, onHide: PropTypes.func, colorScheme: PropTypes.object, setColorSchemeAndUnsavedChanges: PropTypes.func, diff --git a/superset-frontend/src/dashboard/components/SliceAdder.jsx b/superset-frontend/src/dashboard/components/SliceAdder.jsx index 9034a8105..80d80cbf4 100644 --- a/superset-frontend/src/dashboard/components/SliceAdder.jsx +++ b/superset-frontend/src/dashboard/components/SliceAdder.jsx @@ -39,7 +39,7 @@ const propTypes = { lastUpdated: PropTypes.number.isRequired, errorMessage: PropTypes.string, userId: PropTypes.string.isRequired, - selectedSliceIds: PropTypes.arrayOf(PropTypes.number).isRequired, + selectedSliceIds: PropTypes.arrayOf(PropTypes.number), editMode: PropTypes.bool, height: PropTypes.number, }; diff --git a/superset-frontend/src/dashboard/components/SliceHeader.jsx b/superset-frontend/src/dashboard/components/SliceHeader.jsx index 941c0ad25..276d36a6d 100644 --- a/superset-frontend/src/dashboard/components/SliceHeader.jsx +++ b/superset-frontend/src/dashboard/components/SliceHeader.jsx @@ -53,7 +53,6 @@ const propTypes = { const defaultProps = { innerRef: null, forceRefresh: () => ({}), - removeSlice: () => ({}), updateSliceName: () => ({}), toggleExpandSlice: () => ({}), exploreChart: () => ({}), diff --git a/superset-frontend/src/dashboard/components/gridComponents/Row.jsx b/superset-frontend/src/dashboard/components/gridComponents/Row.jsx index f9076bcf4..f98cac937 100644 --- a/superset-frontend/src/dashboard/components/gridComponents/Row.jsx +++ b/superset-frontend/src/dashboard/components/gridComponents/Row.jsx @@ -56,10 +56,6 @@ const propTypes = { updateComponents: PropTypes.func.isRequired, }; -const defaultProps = { - rowHeight: null, -}; - class Row extends React.PureComponent { constructor(props) { super(props); @@ -192,6 +188,5 @@ class Row extends React.PureComponent { } Row.propTypes = propTypes; -Row.defaultProps = defaultProps; export default Row; diff --git a/superset-frontend/src/dashboard/components/gridComponents/Tabs.jsx b/superset-frontend/src/dashboard/components/gridComponents/Tabs.jsx index b765cbf93..1765ebb0a 100644 --- a/superset-frontend/src/dashboard/components/gridComponents/Tabs.jsx +++ b/superset-frontend/src/dashboard/components/gridComponents/Tabs.jsx @@ -69,7 +69,6 @@ const propTypes = { }; const defaultProps = { - children: null, renderTabContent: true, renderHoverMenu: true, availableColumnCount: 0, diff --git a/superset-frontend/src/dashboard/components/menu/WithPopoverMenu.jsx b/superset-frontend/src/dashboard/components/menu/WithPopoverMenu.jsx index 42158dccf..eb4390115 100644 --- a/superset-frontend/src/dashboard/components/menu/WithPopoverMenu.jsx +++ b/superset-frontend/src/dashboard/components/menu/WithPopoverMenu.jsx @@ -35,7 +35,6 @@ const defaultProps = { children: null, disableClick: false, onChangeFocus: null, - onPressDelete() {}, menuItems: [], isFocused: false, shouldFocus: (event, container) => diff --git a/superset-frontend/src/dashboard/containers/DashboardBuilder.jsx b/superset-frontend/src/dashboard/containers/DashboardBuilder.jsx index dacdb7b81..9d06e773a 100644 --- a/superset-frontend/src/dashboard/containers/DashboardBuilder.jsx +++ b/superset-frontend/src/dashboard/containers/DashboardBuilder.jsx @@ -21,7 +21,6 @@ import { connect } from 'react-redux'; import DashboardBuilder from '../components/DashboardBuilder'; import { - setColorSchemeAndUnsavedChanges, showBuilderPane, setDirectPathToChild, setMountedTab, @@ -35,9 +34,7 @@ function mapStateToProps({ dashboardLayout: undoableLayout, dashboardState }) { return { dashboardLayout: undoableLayout.present, editMode: dashboardState.editMode, - showBuilderPane: dashboardState.showBuilderPane, directPathToChild: dashboardState.directPathToChild, - colorScheme: dashboardState.colorScheme, }; } @@ -47,7 +44,6 @@ function mapDispatchToProps(dispatch) { deleteTopLevelTabs, handleComponentDrop, showBuilderPane, - setColorSchemeAndUnsavedChanges, setDirectPathToChild, setMountedTab, }, diff --git a/superset-frontend/src/dashboard/containers/DashboardComponent.jsx b/superset-frontend/src/dashboard/containers/DashboardComponent.jsx index d4a403f75..aaa7da3ec 100644 --- a/superset-frontend/src/dashboard/containers/DashboardComponent.jsx +++ b/superset-frontend/src/dashboard/containers/DashboardComponent.jsx @@ -53,7 +53,6 @@ const propTypes = { const defaultProps = { directPathToChild: [], directPathLastUpdated: 0, - isComponentVisible: true, }; function mapStateToProps( diff --git a/superset-frontend/src/explore/components/QueryAndSaveBtns.jsx b/superset-frontend/src/explore/components/QueryAndSaveBtns.jsx index e23348400..9eaec3c7e 100644 --- a/superset-frontend/src/explore/components/QueryAndSaveBtns.jsx +++ b/superset-frontend/src/explore/components/QueryAndSaveBtns.jsx @@ -37,7 +37,6 @@ const propTypes = { const defaultProps = { onStop: () => {}, onSave: () => {}, - disabled: false, }; // Prolly need to move this to a global context diff --git a/superset-frontend/src/explore/components/controls/ColorSchemeControl.jsx b/superset-frontend/src/explore/components/controls/ColorSchemeControl.jsx index 4b9d6e4f4..0d3a56e6f 100644 --- a/superset-frontend/src/explore/components/controls/ColorSchemeControl.jsx +++ b/superset-frontend/src/explore/components/controls/ColorSchemeControl.jsx @@ -35,8 +35,8 @@ const propTypes = { choices: PropTypes.oneOfType([ PropTypes.arrayOf(PropTypes.array), PropTypes.func, - ]).isRequired, - schemes: PropTypes.oneOfType([PropTypes.object, PropTypes.func]).isRequired, + ]), + schemes: PropTypes.oneOfType([PropTypes.object, PropTypes.func]), isLinear: PropTypes.bool, }; diff --git a/superset-frontend/src/explore/components/controls/ViewportControl.jsx b/superset-frontend/src/explore/components/controls/ViewportControl.jsx index 9aa6be166..11731b14c 100644 --- a/superset-frontend/src/explore/components/controls/ViewportControl.jsx +++ b/superset-frontend/src/explore/components/controls/ViewportControl.jsx @@ -37,7 +37,7 @@ export const DEFAULT_VIEWPORT = { const PARAMS = ['longitude', 'latitude', 'zoom', 'bearing', 'pitch']; const propTypes = { - onChange: PropTypes.func.isRequired, + onChange: PropTypes.func, value: PropTypes.shape({ longitude: PropTypes.number, latitude: PropTypes.number,