fix: Enable ESLint rule default-props-match-prop-types (#11058)

* Re-enable ESLint rule default-props-match-props-types

* Add cypress test for switching tabs

* fix

* Typo fix

* Test fix
This commit is contained in:
Kamil Gabryjelski 2020-10-03 00:54:56 +02:00 committed by GitHub
parent d95b7c2a73
commit 07f87149e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 33 additions and 35 deletions

View File

@ -122,7 +122,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'] }],
@ -233,7 +232,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'] }],

View File

@ -91,6 +91,22 @@ describe('Dashboard tabs', () => {
});
});
it('should switch active tab on click', () => {
cy.wait('@filterRequest');
cy.wait('@treemapRequest');
cy.get('.dashboard-component-tabs')
.first()
.find('ul.nav.nav-tabs li')
.as('tabs');
cy.get('@tabs').first().click().should('have.class', 'active');
cy.get('@tabs').last().should('not.have.class', 'active');
cy.get('@tabs').last().click().should('have.class', 'active');
cy.get('@tabs').first().should('not.have.class', 'active');
});
it('should load charts when tab is visible', () => {
// landing in first tab, should see 2 charts
cy.wait('@filterRequest');

View File

@ -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 {

View File

@ -25,7 +25,7 @@ import { t } from '@superset-ui/core';
import { InfoTooltipWithTrigger } from '@superset-ui/chart-controls';
import Button from 'src/components/Button';
import { exploreChart } from '../../explore/exploreUtils';
import { exploreChart } from 'src/explore/exploreUtils';
import * as actions from '../actions/sqlLab';
const propTypes = {
@ -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 {

View File

@ -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,

View File

@ -33,8 +33,6 @@ const propTypes = {
};
const defaultProps = {
label: null,
description: null,
onChange: () => {},
code: '{}',
};

View File

@ -28,7 +28,7 @@ const propTypes = {
descr: PropTypes.string.isRequired,
func: PropTypes.func,
}),
).isRequired,
),
header: PropTypes.string,
placement: PropTypes.string,
};

View File

@ -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,

View File

@ -24,7 +24,7 @@ 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,
};

View File

@ -54,7 +54,7 @@ const propTypes = {
dashboardLayout: PropTypes.object.isRequired,
deleteTopLevelTabs: PropTypes.func.isRequired,
editMode: PropTypes.bool.isRequired,
showBuilderPane: PropTypes.func.isRequired,
showBuilderPane: PropTypes.func,
colorScheme: PropTypes.string,
setColorSchemeAndUnsavedChanges: PropTypes.func.isRequired,
handleComponentDrop: PropTypes.func.isRequired,

View File

@ -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,

View File

@ -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,
};

View File

@ -53,7 +53,6 @@ const propTypes = {
const defaultProps = {
innerRef: null,
forceRefresh: () => ({}),
removeSlice: () => ({}),
updateSliceName: () => ({}),
toggleExpandSlice: () => ({}),
exploreChart: () => ({}),

View File

@ -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;

View File

@ -69,7 +69,6 @@ const propTypes = {
};
const defaultProps = {
children: null,
renderTabContent: true,
renderHoverMenu: true,
availableColumnCount: 0,

View File

@ -35,7 +35,6 @@ const defaultProps = {
children: null,
disableClick: false,
onChangeFocus: null,
onPressDelete() {},
menuItems: [],
isFocused: false,
shouldFocus: (event, container) =>

View File

@ -21,6 +21,8 @@ import PropTypes from 'prop-types';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { logEvent } from 'src/logger/actions';
import { addDangerToast } from 'src/messageToasts/actions';
import ComponentLookup from '../components/gridComponents';
import getDetailedComponentWidth from '../util/getDetailedComponentWidth';
import { getActiveFilters } from '../util/activeDashboardFilters';
@ -34,8 +36,6 @@ import {
handleComponentDrop,
} from '../actions/dashboardLayout';
import { setDirectPathToChild, setMountedTab } from '../actions/dashboardState';
import { logEvent } from '../../logger/actions';
import { addDangerToast } from '../../messageToasts/actions';
const propTypes = {
component: componentShape.isRequired,
@ -48,6 +48,7 @@ const propTypes = {
directPathToChild: PropTypes.arrayOf(PropTypes.string),
directPathLastUpdated: PropTypes.number,
dashboardId: PropTypes.number.isRequired,
isComponentVisible: PropTypes.bool,
};
const defaultProps = {

View File

@ -37,7 +37,6 @@ const propTypes = {
const defaultProps = {
onStop: () => {},
onSave: () => {},
disabled: false,
};
// Prolly need to move this to a global context

View File

@ -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,
};

View File

@ -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,