Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions superset-frontend/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ module.exports = {
'no-use-before-define': 0, // disabled temporarily
'padded-blocks': 0,
'prefer-arrow-callback': 0,
'prefer-destructuring': 0, // disabled temporarily
'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,
Expand Down Expand Up @@ -240,7 +240,7 @@ module.exports = {
'padded-blocks': 0,
'prefer-arrow-callback': 0,
'prefer-object-spread': 1,
'prefer-destructuring': 0, // disabled temporarily
'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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('Dashboard load', () => {

cy.get('#app').then(data => {
const bootstrapData = JSON.parse(data[0].dataset.bootstrap);
const slices = bootstrapData.dashboard_data.slices;
const { slices } = bootstrapData.dashboard_data;
// then define routes and create alias for each requests
slices.forEach(slice => {
const alias = `getJson_${slice.slice_id}`;
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/spec/helpers/shim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ configure({ adapter: new Adapter() });

const exposedProperties = ['window', 'navigator', 'document'];

const defaultView = document.defaultView;
const { defaultView } = document;
if (defaultView != null) {
Object.keys(defaultView).forEach(property => {
if (typeof global[property] === 'undefined') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('CollectionTable', () => {
});

it('renders a table', () => {
const length = mockDatasource['7__table'].columns.length;
const { length } = mockDatasource['7__table'].columns;
expect(wrapper.find('table')).toExist();
expect(wrapper.find('tbody tr.row')).toHaveLength(length);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ describe('dashboardState actions', () => {
const thunk = saveDashboardRequest(newDashboardData, 1, 'save_dash');
thunk(dispatch, getState);
expect(postStub.callCount).toBe(1);
const postPayload = postStub.getCall(0).args[0].postPayload;
const { postPayload } = postStub.getCall(0).args[0];
expect(postPayload.data.positions[DASHBOARD_GRID_ID].parents).toBe(
mockParentsList,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import {
import { filterComponent } from '../fixtures/mockDashboardLayout';

describe('dashboardFilters reducer', () => {
const form_data = sliceEntitiesForDashboard.slices[filterId].form_data;
const { form_data } = sliceEntitiesForDashboard.slices[filterId];
const component = filterComponent;
const directPathToFilter = (component.parents || []).slice();
directPathToFilter.push(component.id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ describe('SaveModal', () => {
it('should save slice', () => {
const wrapper = getWrapper();
wrapper.instance().saveOrOverwrite(true);
const args = defaultProps.actions.saveSlice.getCall(0).args;
const { args } = defaultProps.actions.saveSlice.getCall(0);
expect(args[0]).toEqual(defaultProps.form_data);
});

Expand All @@ -168,7 +168,7 @@ describe('SaveModal', () => {

wrapper.setState({ saveToDashboardId });
wrapper.instance().saveOrOverwrite(true);
const args = defaultProps.actions.saveSlice.getCall(0).args;
const { args } = defaultProps.actions.saveSlice.getCall(0);
expect(args[1].save_to_dashboard_id).toBe(saveToDashboardId);
});

Expand All @@ -178,7 +178,7 @@ describe('SaveModal', () => {

wrapper.setState({ newDashboardName });
wrapper.instance().saveOrOverwrite(true);
const args = defaultProps.actions.saveSlice.getCall(0).args;
const { args } = defaultProps.actions.saveSlice.getCall(0);
expect(args[1].new_dashboard_name).toBe(newDashboardName);
});

Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/spec/javascripts/explore/utils_spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import * as hostNamesConfig from 'src/utils/hostNamesConfig';
import { getChartMetadataRegistry } from '@superset-ui/core';

describe('exploreUtils', () => {
const location = window.location;
const { location } = window;
const formData = {
datasource: '1__table',
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ describe('logger middleware', () => {
clock.tick(2000);

expect(SupersetClient.post.callCount).toBe(1);
const events = SupersetClient.post.getCall(0).args[0].postPayload.events;
const { events } = SupersetClient.post.getCall(0).args[0].postPayload;
const mockEventdata = action.payload.eventData;
const mockEventname = action.payload.eventName;
expect(events[0]).toMatchObject({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe('QuerySearch', () => {
});

it('refreshes queries when enter (only) is pressed on the input', () => {
const callCount = search.callCount;
const { callCount } = search;
wrapper.find('input').simulate('keyDown', { keyCode: 'a'.charCodeAt(0) });
expect(search.callCount).toBe(callCount);
wrapper.find('input').simulate('keyDown', { keyCode: '\r'.charCodeAt(0) });
Expand All @@ -81,7 +81,7 @@ describe('QuerySearch', () => {
});

it('refreshes queries when clicked', () => {
const callCount = search.callCount;
const { callCount } = search;
wrapper.find(Button).simulate('click');
expect(search.callCount).toBe(callCount + 1);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class AceEditorWrapper extends React.PureComponent<Props, State> {
});
}
getAceAnnotations() {
const validationResult = this.props.queryEditor.validationResult;
const { validationResult } = this.props.queryEditor;
const resultIsReady = validationResult && validationResult.completed;
if (resultIsReady && validationResult.errors.length > 0) {
const errors = validationResult.errors.map((err: any) => ({
Expand Down
6 changes: 3 additions & 3 deletions superset-frontend/src/SqlLab/components/ColumnElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ interface ColumnElementProps {
}

export default function ColumnElement({ column }: ColumnElementProps) {
let name: React.ReactNode = column.name;
let columnName: React.ReactNode = column.name;
let icons;
if (column.keys && column.keys.length > 0) {
name = <strong>{column.name}</strong>;
columnName = <strong>{column.name}</strong>;
icons = column.keys.map((key, i) => (
<span key={i} className="ColumnElement">
<OverlayTrigger
Expand All @@ -73,7 +73,7 @@ export default function ColumnElement({ column }: ColumnElementProps) {
return (
<div className="clearfix table-column">
<div className="pull-left m-l-10 col-name">
{name}
{columnName}
{icons}
</div>
<div className="pull-right text-muted">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class ExploreResultsButton extends React.PureComponent {
);
}
onClick() {
const timeout = this.props.timeout;
const { timeout } = this.props;
const msg = this.renderInvalidColumnMessage();
if (Math.round(this.getQueryDuration()) > timeout) {
this.dialog.show({
Expand Down Expand Up @@ -86,7 +86,7 @@ class ExploreResultsButton extends React.PureComponent {
}
}
getColumns() {
const props = this.props;
const { props } = this;
if (
props.query &&
props.query.results &&
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/SqlLab/components/LimitControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export default class LimitControl extends React.PureComponent<
}

renderPopover() {
const textValue = this.state.textValue;
const { textValue } = this.state;
const isValid = this.isValidLimit(textValue);
const errorMsg =
t('Row limit must be positive integer') +
Expand Down
12 changes: 6 additions & 6 deletions superset-frontend/src/SqlLab/components/ResultSet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ export default class ResultSet extends React.PureComponent<
}
renderControls() {
if (this.props.search || this.props.visualize || this.props.csv) {
let data = this.props.query.results.data;
let { data } = this.props.query.results;
if (this.props.cache && this.props.query.cached) {
data = this.state.data;
({ data } = this.state);
}
return (
<div className="ResultSetControls">
Expand Down Expand Up @@ -199,7 +199,7 @@ export default class ResultSet extends React.PureComponent<
return <div className="noControls" />;
}
render() {
const query = this.props.query;
const { query } = this.props;
const height = Math.max(
0,
this.props.search ? this.props.height - SEARCH_HEIGHT : this.props.height,
Expand Down Expand Up @@ -263,12 +263,12 @@ export default class ResultSet extends React.PureComponent<
</div>
);
} else if (query.state === 'success' && query.results) {
const results = query.results;
const { results } = query;
let data;
if (this.props.cache && query.cached) {
data = this.state.data;
({ data } = this.state);
} else if (results && results.data) {
data = results.data;
({ data } = results);
}
if (data && data.length > 0) {
const expandedColumns = results.expanded_columns
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/SqlLab/components/SouthPane.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class SouthPane extends React.PureComponent {
}
const innerTabContentHeight = this.state.height - TAB_HEIGHT;
let latestQuery;
const props = this.props;
const { props } = this;
if (props.editorQueries.length > 0) {
// get the latest query
latestQuery = props.editorQueries.find(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class TabbedSqlEditors extends React.PureComponent {
if (dbId) {
dbId = parseInt(dbId, 10);
} else {
const databases = this.props.databases;
const { databases } = this.props;
const dbName = query.dbname;
if (dbName) {
Object.keys(databases).forEach(db => {
Expand Down
10 changes: 5 additions & 5 deletions superset-frontend/src/SqlLab/components/TableElement.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ class TableElement extends React.PureComponent {
}

renderWell() {
const table = this.props.table;
const { table } = this.props;
let header;
if (table.partitions) {
let partitionQuery;
let partitionClipBoard;
if (table.partitions.partitionQuery) {
partitionQuery = table.partitions.partitionQuery;
({ partitionQuery } = table.partitions.partitionQuery);
const tt = t('Copy partition query to clipboard');
partitionClipBoard = (
<CopyToClipboard
Expand Down Expand Up @@ -129,7 +129,7 @@ class TableElement extends React.PureComponent {
}
renderControls() {
let keyLink;
const table = this.props.table;
const { table } = this.props;
if (table.indexes && table.indexes.length > 0) {
keyLink = (
<ModalTrigger
Expand Down Expand Up @@ -191,7 +191,7 @@ class TableElement extends React.PureComponent {
);
}
renderHeader() {
const table = this.props.table;
const { table } = this.props;
return (
<div className="clearfix">
<div className="pull-left">
Expand Down Expand Up @@ -228,7 +228,7 @@ class TableElement extends React.PureComponent {
);
}
renderBody() {
const table = this.props.table;
const { table } = this.props;
let cols;
if (table.columns) {
cols = table.columns.slice();
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/SqlLab/reducers/getInitialState.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export default function getInitialState({
localStorage.getItem('redux') &&
JSON.parse(localStorage.getItem('redux')).sqlLab
) {
const sqlLab = JSON.parse(localStorage.getItem('redux')).sqlLab;
const { sqlLab } = JSON.parse(localStorage.getItem('redux'));

if (sqlLab.queryEditors.length === 0) {
// migration was successful
Expand Down
8 changes: 4 additions & 4 deletions superset-frontend/src/SqlLab/reducers/sqlLab.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ export default function sqlLabReducer(state = {}, action) {
},
[actions.MIGRATE_QUERY_EDITOR]() {
// remove migrated query editor from localStorage
const sqlLab = JSON.parse(localStorage.getItem('redux')).sqlLab;
const { sqlLab } = JSON.parse(localStorage.getItem('redux'));
sqlLab.queryEditors = sqlLab.queryEditors.filter(
qe => qe.id !== action.oldQueryEditor.id,
);
Expand All @@ -390,7 +390,7 @@ export default function sqlLabReducer(state = {}, action) {
},
[actions.MIGRATE_TABLE]() {
// remove migrated table from localStorage
const sqlLab = JSON.parse(localStorage.getItem('redux')).sqlLab;
const { sqlLab } = JSON.parse(localStorage.getItem('redux'));
sqlLab.tables = sqlLab.tables.filter(
table => table.id !== action.oldTable.id,
);
Expand All @@ -405,7 +405,7 @@ export default function sqlLabReducer(state = {}, action) {
},
[actions.MIGRATE_TAB_HISTORY]() {
// remove migrated tab from localStorage tabHistory
const sqlLab = JSON.parse(localStorage.getItem('redux')).sqlLab;
const { sqlLab } = JSON.parse(localStorage.getItem('redux'));
sqlLab.tabHistory = sqlLab.tabHistory.filter(
tabId => tabId !== action.oldId,
);
Expand Down Expand Up @@ -492,7 +492,7 @@ export default function sqlLabReducer(state = {}, action) {
let newQueries = { ...state.queries };
// Fetch the updates to the queries present in the store.
let change = false;
let queriesLastUpdate = state.queriesLastUpdate;
let { queriesLastUpdate } = state;
for (const id in action.alteredQueries) {
const changedQuery = action.alteredQueries[id];
if (
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/components/AlteredSliceTag.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export default class AlteredSliceTag extends React.Component {
}

renderRows() {
const diffs = this.state.diffs;
const { diffs } = this.state;
const rows = [];
for (const key in diffs) {
rows.push(
Expand Down
4 changes: 1 addition & 3 deletions superset-frontend/src/components/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,7 @@ export default function Button(props: ButtonProps) {
bsSize: props.buttonSize,
placement: props.placement || 'top',
};
const tooltip = props.tooltip;
const placement = props.placement;
const dropdownItems = props.dropdownItems;
const { tooltip, placement, dropdownItems } = props;
delete buttonProps.tooltip;
delete buttonProps.placement;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export default function WindowedMenuList<OptionType extends OptionTypeBase>({
} = selectProps;

// try get default option height from theme configs
let optionHeight = selectProps.optionHeight;
let { optionHeight } = selectProps;
if (!optionHeight) {
optionHeight = theme ? detectHeight(theme) : DEFAULT_OPTION_HEIGHT;
}
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/dashboard/actions/sliceEntities.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function fetchAllSlices(userId) {
const slices = {};
json.result.forEach(slice => {
let form_data = JSON.parse(slice.params);
let datasource = form_data.datasource;
let { datasource } = form_data;
if (!datasource) {
datasource = getDatasourceParameter(
slice.datasource_id,
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/dashboard/components/CodeModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default class CodeModal extends React.PureComponent {
}

beforeOpen() {
let code = this.props.code;
let { code } = this.props;
if (!code && this.props.codeCallback) {
code = this.props.codeCallback();
}
Expand Down
4 changes: 2 additions & 2 deletions superset-frontend/src/dashboard/components/Dashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class Dashboard extends React.PureComponent {
componentDidUpdate() {
const { hasUnsavedChanges, editMode } = this.props.dashboardState;

const appliedFilters = this.appliedFilters;
const { appliedFilters } = this;
const { activeFilters } = this.props;
// do not apply filter when dashboard in edit mode
if (!editMode && !areObjectsEqual(appliedFilters, activeFilters)) {
Expand Down Expand Up @@ -186,7 +186,7 @@ class Dashboard extends React.PureComponent {
}

applyFilters() {
const appliedFilters = this.appliedFilters;
const { appliedFilters } = this;
const { activeFilters } = this.props;

// refresh charts if a filter was removed, added, or changed
Expand Down
Loading