From 09de8050174d48a3fde1c3a8e9a65a6ab21f8f0c Mon Sep 17 00:00:00 2001 From: Erik Ritter Date: Thu, 16 Jul 2020 19:13:59 -0700 Subject: [PATCH] chore: enable no-unused-vars and prefer-template eslint rules (#10350) --- superset-frontend/.eslintrc.js | 6 +----- superset-frontend/package.json | 1 - superset-frontend/spec/__mocks__/svgrMock.js | 2 -- .../components/AnchorLink_spec.jsx | 2 +- .../components/ColumnTypeLabel_spec.jsx | 2 +- .../components/ListView/ListView_spec.jsx | 2 -- .../components/OnPasteSelect_spec.jsx | 7 +------ .../components/RefreshIntervalModal_spec.jsx | 2 +- .../components/ExploreChartHeader_spec.jsx | 1 - .../components/MetricsControl_spec.jsx | 2 +- .../messageToasts/components/Toast_spec.jsx | 1 - .../javascripts/sqllab/SqlEditor_spec.jsx | 1 - .../javascripts/sqllab/actions/sqlLab_spec.js | 2 +- .../src/CRUD/CollectionTable.jsx | 2 +- .../src/SqlLab/actions/sqlLab.js | 4 ++-- .../src/SqlLab/components/HighlightedSql.jsx | 2 +- .../src/SqlLab/components/QuerySearch.jsx | 4 ++-- .../src/SqlLab/components/ResultSet.tsx | 2 +- .../SqlLab/components/ShareSqlLabQuery.jsx | 7 +++---- .../src/SqlLab/components/TabStatusIcon.jsx | 2 +- .../SqlLab/components/TabbedSqlEditors.jsx | 2 +- superset-frontend/src/chart/ChartRenderer.jsx | 1 - superset-frontend/src/chart/chartAction.js | 2 -- superset-frontend/src/chart/chartReducer.js | 19 ++++++++----------- .../src/components/AlteredSliceTag.jsx | 1 - .../FilterableTable/FilterableTable.tsx | 2 +- superset-frontend/src/components/Link.tsx | 2 +- .../src/components/PopoverSection.jsx | 2 +- .../src/components/TableLoader.jsx | 4 ++-- .../src/components/TableSelector.jsx | 6 +++--- .../src/components/VictoryTheme.js | 2 -- .../components/gridComponents/Markdown.jsx | 2 +- superset-frontend/src/explore/AdhocFilter.js | 2 +- superset-frontend/src/explore/AdhocMetric.js | 2 +- superset-frontend/src/explore/App.jsx | 2 +- ...AdhocFilterEditPopoverSimpleTabContent.jsx | 4 ++-- .../AdhocFilterEditPopoverSqlTabContent.jsx | 2 +- .../components/AdhocMetricEditPopover.jsx | 4 ++-- .../explore/components/AdhocMetricOption.jsx | 1 - .../components/ControlPanelsContainer.jsx | 5 +---- .../explore/components/EmbedCodeButton.jsx | 6 +++--- .../components/ExploreViewContainer.jsx | 2 +- .../controls/AdhocFilterControl.jsx | 4 ++-- .../components/controls/DateFilterControl.jsx | 3 +-- .../components/controls/MetricsControl.jsx | 4 ++-- .../controls/SelectAsyncControl.jsx | 2 +- .../components/controls/SelectControl.jsx | 1 - .../components/controls/ViewportControl.jsx | 8 +++----- .../src/explore/controlPanels/DeckHex.js | 5 +---- .../explore/controlPanels/Shared_DeckGL.jsx | 11 +---------- superset-frontend/src/explore/controlUtils.js | 1 - superset-frontend/src/explore/controls.jsx | 8 ++------ superset-frontend/src/explore/exploreUtils.js | 1 - superset-frontend/src/modules/utils.js | 2 +- superset-frontend/src/setup/setupApp.ts | 4 ++-- superset-frontend/src/utils/common.js | 2 +- 56 files changed, 66 insertions(+), 119 deletions(-) diff --git a/superset-frontend/.eslintrc.js b/superset-frontend/.eslintrc.js index 6b28a21bb..b40dabed8 100644 --- a/superset-frontend/.eslintrc.js +++ b/superset-frontend/.eslintrc.js @@ -34,7 +34,7 @@ module.exports = { rules: { 'import/no-unresolved': 0, 'global-require': 0, - } + }, }, { files: ['*.ts', '*.tsx'], @@ -88,10 +88,8 @@ module.exports = { 'no-prototype-builtins': 0, 'no-restricted-properties': 0, 'no-restricted-syntax': 0, - 'no-unused-vars': 0, 'padded-blocks': 0, 'prefer-arrow-callback': 0, - 'prefer-template': 0, 'react/forbid-prop-types': 0, 'react/jsx-filename-extension': [1, { extensions: ['.jsx', '.tsx'] }], 'react/jsx-no-bind': 0, @@ -150,11 +148,9 @@ module.exports = { 'no-prototype-builtins': 0, 'no-restricted-properties': 0, 'no-restricted-syntax': 0, - 'no-unused-vars': 0, 'padded-blocks': 0, 'prefer-arrow-callback': 0, 'prefer-object-spread': 1, - 'prefer-template': 0, 'react/forbid-prop-types': 0, 'react/jsx-filename-extension': [1, { extensions: ['.jsx', '.tsx'] }], 'react/jsx-no-bind': 0, diff --git a/superset-frontend/package.json b/superset-frontend/package.json index b6fa1dbbc..747c94b76 100644 --- a/superset-frontend/package.json +++ b/superset-frontend/package.json @@ -129,7 +129,6 @@ "d3-scale": "^2.1.2", "dnd-core": "^2.6.0", "dom-to-image": "^2.6.0", - "dompurify": "^2.0.7", "geolib": "^2.0.24", "immutable": "^3.8.2", "interweave": "^11.2.0", diff --git a/superset-frontend/spec/__mocks__/svgrMock.js b/superset-frontend/spec/__mocks__/svgrMock.js index 20b43380a..46bda7832 100644 --- a/superset-frontend/spec/__mocks__/svgrMock.js +++ b/superset-frontend/spec/__mocks__/svgrMock.js @@ -16,7 +16,5 @@ * specific language governing permissions and limitations * under the License. */ -import * as React from 'react'; - export default 'SvgrURL'; export const ReactComponent = 'svg'; diff --git a/superset-frontend/spec/javascripts/components/AnchorLink_spec.jsx b/superset-frontend/spec/javascripts/components/AnchorLink_spec.jsx index 6b9dc4b5b..7cdb1d85e 100644 --- a/superset-frontend/spec/javascripts/components/AnchorLink_spec.jsx +++ b/superset-frontend/spec/javascripts/components/AnchorLink_spec.jsx @@ -31,7 +31,7 @@ describe('AnchorLink', () => { global.window = Object.create(window); Object.defineProperty(window, 'location', { value: { - hash: '#' + props.anchorLinkId, + hash: `#${props.anchorLinkId}`, }, }); }); diff --git a/superset-frontend/spec/javascripts/components/ColumnTypeLabel_spec.jsx b/superset-frontend/spec/javascripts/components/ColumnTypeLabel_spec.jsx index d78577be9..d85a165b4 100644 --- a/superset-frontend/spec/javascripts/components/ColumnTypeLabel_spec.jsx +++ b/superset-frontend/spec/javascripts/components/ColumnTypeLabel_spec.jsx @@ -19,7 +19,7 @@ import React from 'react'; import { shallow } from 'enzyme'; -import { ColumnOption, ColumnTypeLabel } from '@superset-ui/chart-controls'; +import { ColumnTypeLabel } from '@superset-ui/chart-controls'; describe('ColumnOption', () => { const defaultProps = { diff --git a/superset-frontend/spec/javascripts/components/ListView/ListView_spec.jsx b/superset-frontend/spec/javascripts/components/ListView/ListView_spec.jsx index 6f62e4ef0..de0d179df 100644 --- a/superset-frontend/spec/javascripts/components/ListView/ListView_spec.jsx +++ b/superset-frontend/spec/javascripts/components/ListView/ListView_spec.jsx @@ -20,7 +20,6 @@ import React from 'react'; import { mount, shallow } from 'enzyme'; import { act } from 'react-dom/test-utils'; import { MenuItem } from 'react-bootstrap'; -import Select from 'src/components/Select'; import { QueryParamProvider } from 'use-query-params'; import { supersetTheme, ThemeProvider } from '@superset-ui/style'; @@ -29,7 +28,6 @@ import ListViewFilters from 'src/components/ListView/Filters'; import ListViewPagination from 'src/components/ListView/Pagination'; import Pagination from 'src/components/Pagination'; import Button from 'src/components/Button'; -import { areArraysShallowEqual } from 'src/reduxUtils'; import waitForComponentToPaint from 'spec/helpers/waitForComponentToPaint'; import IndeterminateCheckbox from 'src/components/IndeterminateCheckbox'; diff --git a/superset-frontend/spec/javascripts/components/OnPasteSelect_spec.jsx b/superset-frontend/spec/javascripts/components/OnPasteSelect_spec.jsx index ec9cb953c..9c6af28d7 100644 --- a/superset-frontend/spec/javascripts/components/OnPasteSelect_spec.jsx +++ b/superset-frontend/spec/javascripts/components/OnPasteSelect_spec.jsx @@ -20,12 +20,7 @@ import React from 'react'; import sinon from 'sinon'; import { shallow } from 'enzyme'; -import { - Select, - AsyncSelect, - OnPasteSelect, - CreatableSelect, -} from 'src/components/Select'; +import { Select, OnPasteSelect, CreatableSelect } from 'src/components/Select'; const defaultProps = { onChange: sinon.spy(), diff --git a/superset-frontend/spec/javascripts/dashboard/components/RefreshIntervalModal_spec.jsx b/superset-frontend/spec/javascripts/dashboard/components/RefreshIntervalModal_spec.jsx index 92f34ba9d..33a2bdca0 100644 --- a/superset-frontend/spec/javascripts/dashboard/components/RefreshIntervalModal_spec.jsx +++ b/superset-frontend/spec/javascripts/dashboard/components/RefreshIntervalModal_spec.jsx @@ -21,7 +21,7 @@ import { mount, shallow } from 'enzyme'; import ModalTrigger from 'src/components/ModalTrigger'; import RefreshIntervalModal from 'src/dashboard/components/RefreshIntervalModal'; -import { Modal, Alert } from 'react-bootstrap'; +import { Alert } from 'react-bootstrap'; describe('RefreshIntervalModal', () => { const mockedProps = { diff --git a/superset-frontend/spec/javascripts/explore/components/ExploreChartHeader_spec.jsx b/superset-frontend/spec/javascripts/explore/components/ExploreChartHeader_spec.jsx index 5cd51f42b..f819bdf74 100644 --- a/superset-frontend/spec/javascripts/explore/components/ExploreChartHeader_spec.jsx +++ b/superset-frontend/spec/javascripts/explore/components/ExploreChartHeader_spec.jsx @@ -66,7 +66,6 @@ describe('ExploreChartHeader', () => { }); it('should update title but not save', () => { - const newTitle = 'New Chart Title'; const editableTitle = wrapper.find(EditableTitle); expect(editableTitle.props().onSaveTitle).toBe(updateChartTitleStub); }); diff --git a/superset-frontend/spec/javascripts/explore/components/MetricsControl_spec.jsx b/superset-frontend/spec/javascripts/explore/components/MetricsControl_spec.jsx index 6876230d6..741179584 100644 --- a/superset-frontend/spec/javascripts/explore/components/MetricsControl_spec.jsx +++ b/superset-frontend/spec/javascripts/explore/components/MetricsControl_spec.jsx @@ -85,7 +85,7 @@ describe('MetricsControl', () => { { optionName: '_col_value', type: 'DOUBLE', column_name: 'value' }, ...Object.keys(AGGREGATES).map(aggregate => ({ aggregate_name: aggregate, - optionName: '_aggregate_' + aggregate, + optionName: `_aggregate_${aggregate}`, })), { optionName: 'sum__value', diff --git a/superset-frontend/spec/javascripts/messageToasts/components/Toast_spec.jsx b/superset-frontend/spec/javascripts/messageToasts/components/Toast_spec.jsx index d4110933b..bc8afdeca 100644 --- a/superset-frontend/spec/javascripts/messageToasts/components/Toast_spec.jsx +++ b/superset-frontend/spec/javascripts/messageToasts/components/Toast_spec.jsx @@ -19,7 +19,6 @@ import { Alert } from 'react-bootstrap'; import React from 'react'; import { mount } from 'enzyme'; -import { act } from 'react-dom/test-utils'; import Toast from 'src/messageToasts/components/Toast'; import mockMessageToasts from '../mockMessageToasts'; diff --git a/superset-frontend/spec/javascripts/sqllab/SqlEditor_spec.jsx b/superset-frontend/spec/javascripts/sqllab/SqlEditor_spec.jsx index 2ee46897f..ca43a785a 100644 --- a/superset-frontend/spec/javascripts/sqllab/SqlEditor_spec.jsx +++ b/superset-frontend/spec/javascripts/sqllab/SqlEditor_spec.jsx @@ -18,7 +18,6 @@ */ import React from 'react'; import { shallow } from 'enzyme'; -import { Checkbox } from 'react-bootstrap'; import { SQL_EDITOR_GUTTER_HEIGHT, SQL_EDITOR_GUTTER_MARGIN, diff --git a/superset-frontend/spec/javascripts/sqllab/actions/sqlLab_spec.js b/superset-frontend/spec/javascripts/sqllab/actions/sqlLab_spec.js index 5701d490b..c0ebbc219 100644 --- a/superset-frontend/spec/javascripts/sqllab/actions/sqlLab_spec.js +++ b/superset-frontend/spec/javascripts/sqllab/actions/sqlLab_spec.js @@ -58,7 +58,7 @@ describe('async actions', () => { ); const runQueryEndpoint = 'glob:*/superset/sql_json/*'; - fetchMock.post(runQueryEndpoint, '{ "data": ' + mockBigNumber + ' }'); + fetchMock.post(runQueryEndpoint, `{ "data": ${mockBigNumber} }`); describe('saveQuery', () => { const saveQueryEndpoint = 'glob:*/savedqueryviewapi/api/create'; diff --git a/superset-frontend/src/CRUD/CollectionTable.jsx b/superset-frontend/src/CRUD/CollectionTable.jsx index 2612646ba..74c62277c 100644 --- a/superset-frontend/src/CRUD/CollectionTable.jsx +++ b/superset-frontend/src/CRUD/CollectionTable.jsx @@ -213,7 +213,7 @@ export default class CRUDCollection extends React.PureComponent { ]; if (isExpanded) { trs.push( - + dispatch(addSuccessToast(t('Query was stopped.')))) .catch(() => dispatch( - addDangerToast(t('Failed at stopping query. ') + `'${query.id}'`), + addDangerToast(`${t('Failed at stopping query. ')}'${query.id}'`), ), ); }; @@ -1230,7 +1230,7 @@ export function popDatasourceQuery(datasourceKey, sql) { .then(({ json }) => dispatch( addQueryEditor({ - title: 'Query ' + json.name, + title: `Query ${json.name}`, dbId: json.database.id, schema: json.schema, autorun: sql !== undefined, diff --git a/superset-frontend/src/SqlLab/components/HighlightedSql.jsx b/superset-frontend/src/SqlLab/components/HighlightedSql.jsx index 8d75be726..0c343cae0 100644 --- a/superset-frontend/src/SqlLab/components/HighlightedSql.jsx +++ b/superset-frontend/src/SqlLab/components/HighlightedSql.jsx @@ -60,7 +60,7 @@ class HighlightedSql extends React.Component { return lines .map(line => { if (line.length > this.props.maxWidth) { - return line.slice(0, this.props.maxWidth) + '{...}'; + return `${line.slice(0, this.props.maxWidth)}{...}`; } return line; }) diff --git a/superset-frontend/src/SqlLab/components/QuerySearch.jsx b/superset-frontend/src/SqlLab/components/QuerySearch.jsx index ee5660bdb..d7f0e9084 100644 --- a/superset-frontend/src/SqlLab/components/QuerySearch.jsx +++ b/superset-frontend/src/SqlLab/components/QuerySearch.jsx @@ -136,7 +136,7 @@ class QuerySearch extends React.PureComponent { const validParams = params.filter(function (p) { return p !== ''; }); - return baseUrl + '?' + validParams.join('&'); + return `${baseUrl}?${validParams.join('&')}`; } changeStatus(status) { @@ -150,7 +150,7 @@ class QuerySearch extends React.PureComponent { userLabel(user) { if (user.first_name && user.last_name) { - return user.first_name + ' ' + user.last_name; + return `${user.first_name} ${user.last_name}`; } return user.username; } diff --git a/superset-frontend/src/SqlLab/components/ResultSet.tsx b/superset-frontend/src/SqlLab/components/ResultSet.tsx index 7de117568..dd2dd6f00 100644 --- a/superset-frontend/src/SqlLab/components/ResultSet.tsx +++ b/superset-frontend/src/SqlLab/components/ResultSet.tsx @@ -167,7 +167,7 @@ export default class ResultSet extends React.PureComponent< {this.props.csv && ( diff --git a/superset-frontend/src/SqlLab/components/ShareSqlLabQuery.jsx b/superset-frontend/src/SqlLab/components/ShareSqlLabQuery.jsx index f80ececbe..cb7d1331a 100644 --- a/superset-frontend/src/SqlLab/components/ShareSqlLabQuery.jsx +++ b/superset-frontend/src/SqlLab/components/ShareSqlLabQuery.jsx @@ -77,10 +77,9 @@ class ShareSqlLabQuery extends React.Component { let savedQueryToastContent; if (this.props.queryEditor.remoteId) { - savedQueryToastContent = - window.location.origin + - window.location.pathname + - `?savedQueryId=${this.props.queryEditor.remoteId}`; + savedQueryToastContent = `${ + window.location.origin + window.location.pathname + }?savedQueryId=${this.props.queryEditor.remoteId}`; this.setState({ shortUrl: savedQueryToastContent }); } else { savedQueryToastContent = t('Please save the query to enable sharing'); diff --git a/superset-frontend/src/SqlLab/components/TabStatusIcon.jsx b/superset-frontend/src/SqlLab/components/TabStatusIcon.jsx index 1eeedd1e1..c36861c73 100644 --- a/superset-frontend/src/SqlLab/components/TabStatusIcon.jsx +++ b/superset-frontend/src/SqlLab/components/TabStatusIcon.jsx @@ -20,7 +20,7 @@ import React from 'react'; import PropTypes from 'prop-types'; export default function TabStatusIcon(props) { - return
; + return
; } TabStatusIcon.propTypes = { diff --git a/superset-frontend/src/SqlLab/components/TabbedSqlEditors.jsx b/superset-frontend/src/SqlLab/components/TabbedSqlEditors.jsx index e1f465f2f..13a57b09d 100644 --- a/superset-frontend/src/SqlLab/components/TabbedSqlEditors.jsx +++ b/superset-frontend/src/SqlLab/components/TabbedSqlEditors.jsx @@ -304,7 +304,7 @@ class TabbedSqlEditors extends React.PureComponent { {isSelected && ( diff --git a/superset-frontend/src/chart/ChartRenderer.jsx b/superset-frontend/src/chart/ChartRenderer.jsx index e45130a08..7d51761b5 100644 --- a/superset-frontend/src/chart/ChartRenderer.jsx +++ b/superset-frontend/src/chart/ChartRenderer.jsx @@ -16,7 +16,6 @@ * specific language governing permissions and limitations * under the License. */ -import dompurify from 'dompurify'; import { snakeCase } from 'lodash'; import PropTypes from 'prop-types'; import React from 'react'; diff --git a/superset-frontend/src/chart/chartAction.js b/superset-frontend/src/chart/chartAction.js index b4328bafa..67f83b59c 100644 --- a/superset-frontend/src/chart/chartAction.js +++ b/superset-frontend/src/chart/chartAction.js @@ -18,7 +18,6 @@ */ /* eslint no-undef: 'error' */ /* eslint no-param-reassign: ["error", { "props": false }] */ -import URI from 'urijs'; import moment from 'moment'; import { t } from '@superset-ui/translation'; import { SupersetClient } from '@superset-ui/connection'; @@ -26,7 +25,6 @@ import { isFeatureEnabled, FeatureFlag } from '../featureFlags'; import { getAnnotationJsonUrl, getExploreUrl, - getHostName, getLegacyEndpointType, buildV1ChartDataPayload, postForm, diff --git a/superset-frontend/src/chart/chartReducer.js b/superset-frontend/src/chart/chartReducer.js index 1409623da..d3e22365c 100644 --- a/superset-frontend/src/chart/chartReducer.js +++ b/superset-frontend/src/chart/chartReducer.js @@ -89,17 +89,14 @@ export default function chartReducer(charts = {}, action) { return { ...state, chartStatus: 'failed', - chartAlert: - `${t('Query timeout')} - ` + - t( - `visualization queries are set to timeout at ${action.timeout} seconds. `, - ) + - t( - 'Perhaps your data has grown, your database is under unusual load, ' + - 'or you are simply querying a data source that is too large ' + - 'to be processed within the timeout range. ' + - 'If that is the case, we recommend that you summarize your data further.', - ), + chartAlert: `${t('Query timeout')} - ${t( + `visualization queries are set to timeout at ${action.timeout} seconds. `, + )}${t( + 'Perhaps your data has grown, your database is under unusual load, ' + + 'or you are simply querying a data source that is too large ' + + 'to be processed within the timeout range. ' + + 'If that is the case, we recommend that you summarize your data further.', + )}`, chartUpdateEndTime: now(), }; }, diff --git a/superset-frontend/src/components/AlteredSliceTag.jsx b/superset-frontend/src/components/AlteredSliceTag.jsx index dbba032e0..d1584614a 100644 --- a/superset-frontend/src/components/AlteredSliceTag.jsx +++ b/superset-frontend/src/components/AlteredSliceTag.jsx @@ -20,7 +20,6 @@ import React from 'react'; import PropTypes from 'prop-types'; import { Table, Tr, Td, Thead, Th } from 'reactable-arc'; import { isEqual, isEmpty } from 'lodash'; -import { getChartControlPanelRegistry } from '@superset-ui/chart'; import getControlsForVizType from 'src/utils/getControlsForVizType'; import { t } from '@superset-ui/translation'; import TooltipWrapper from './TooltipWrapper'; diff --git a/superset-frontend/src/components/FilterableTable/FilterableTable.tsx b/superset-frontend/src/components/FilterableTable/FilterableTable.tsx index 236f25d87..1ecd6180f 100644 --- a/superset-frontend/src/components/FilterableTable/FilterableTable.tsx +++ b/superset-frontend/src/components/FilterableTable/FilterableTable.tsx @@ -143,7 +143,7 @@ export default class FilterableTable extends PureComponent< this.complexColumns = props.orderedColumnKeys.reduce( (obj, key) => ({ ...obj, - [key]: props.expandedColumns.some(name => name.startsWith(key + '.')), + [key]: props.expandedColumns.some(name => name.startsWith(`${key}.`)), }), {}, ); diff --git a/superset-frontend/src/components/Link.tsx b/superset-frontend/src/components/Link.tsx index 913429f75..f35bdf725 100644 --- a/superset-frontend/src/components/Link.tsx +++ b/superset-frontend/src/components/Link.tsx @@ -44,7 +44,7 @@ const Link = ({ href={href} onClick={onClick} style={style} - className={'Link ' + className} + className={`Link ${className}`} > {children} diff --git a/superset-frontend/src/components/PopoverSection.jsx b/superset-frontend/src/components/PopoverSection.jsx index 9fbc8f0ff..8c19f4b2b 100644 --- a/superset-frontend/src/components/PopoverSection.jsx +++ b/superset-frontend/src/components/PopoverSection.jsx @@ -36,7 +36,7 @@ export default function PopoverSection({ info, }) { return ( -
+
{title}   {info && ( diff --git a/superset-frontend/src/components/TableLoader.jsx b/superset-frontend/src/components/TableLoader.jsx index 0a83a7211..785109670 100644 --- a/superset-frontend/src/components/TableLoader.jsx +++ b/superset-frontend/src/components/TableLoader.jsx @@ -90,9 +90,9 @@ class TableLoader extends React.PureComponent { {this.state.data.map((row, i) => ( {columns.map(col => { - if (row.hasOwnProperty('_' + col)) { + if (row.hasOwnProperty(`_${col}`)) { return ( - + {row[col]} ); diff --git a/superset-frontend/src/components/TableSelector.jsx b/superset-frontend/src/components/TableSelector.jsx index a477c85a5..0acff8025 100644 --- a/superset-frontend/src/components/TableSelector.jsx +++ b/superset-frontend/src/components/TableSelector.jsx @@ -103,11 +103,11 @@ export default class TableSelector extends React.PureComponent { }); } - onDatabaseChange(db, selectChangeMeta) { - return this.changeDataBase(db); + onDatabaseChange(db, force) { + return this.changeDataBase(db, force); } - onSchemaChange(schemaOpt, selectActionMeta) { + onSchemaChange(schemaOpt) { return this.changeSchema(schemaOpt); } diff --git a/superset-frontend/src/components/VictoryTheme.js b/superset-frontend/src/components/VictoryTheme.js index b673119eb..ad2469c69 100644 --- a/superset-frontend/src/components/VictoryTheme.js +++ b/superset-frontend/src/components/VictoryTheme.js @@ -16,8 +16,6 @@ * specific language governing permissions and limitations * under the License. */ -const { assign } = Object; - const A11Y_BABU = '#00A699'; const AXIS_LINE_GRAY = '#484848'; diff --git a/superset-frontend/src/dashboard/components/gridComponents/Markdown.jsx b/superset-frontend/src/dashboard/components/gridComponents/Markdown.jsx index 31415dc27..e46472065 100644 --- a/superset-frontend/src/dashboard/components/gridComponents/Markdown.jsx +++ b/superset-frontend/src/dashboard/components/gridComponents/Markdown.jsx @@ -167,7 +167,7 @@ class Markdown extends React.PureComponent { } } - componentDidCatch(error, info) { + componentDidCatch() { if (this.state.editor && this.state.editorMode === 'preview') { this.props.addDangerToast( t( diff --git a/superset-frontend/src/explore/AdhocFilter.js b/superset-frontend/src/explore/AdhocFilter.js index e023b9662..ef9bcbc2b 100644 --- a/superset-frontend/src/explore/AdhocFilter.js +++ b/superset-frontend/src/explore/AdhocFilter.js @@ -144,7 +144,7 @@ export default class AdhocFilter { getDefaultLabel() { const label = this.translateToSql(); - return label.length < 43 ? label : label.substring(0, 40) + '...'; + return label.length < 43 ? label : `${label.substring(0, 40)}...`; } translateToSql() { diff --git a/superset-frontend/src/explore/AdhocMetric.js b/superset-frontend/src/explore/AdhocMetric.js index 82d4923ac..1e29bf129 100644 --- a/superset-frontend/src/explore/AdhocMetric.js +++ b/superset-frontend/src/explore/AdhocMetric.js @@ -87,7 +87,7 @@ export default class AdhocMetric { getDefaultLabel() { const label = this.translateToSql(); - return label.length < 43 ? label : label.substring(0, 40) + '...'; + return label.length < 43 ? label : `${label.substring(0, 40)}...`; } translateToSql() { diff --git a/superset-frontend/src/explore/App.jsx b/superset-frontend/src/explore/App.jsx index 0d3d55a35..58f391abd 100644 --- a/superset-frontend/src/explore/App.jsx +++ b/superset-frontend/src/explore/App.jsx @@ -19,7 +19,7 @@ import React from 'react'; import { hot } from 'react-hot-loader/root'; import { Provider } from 'react-redux'; -import { styled, supersetTheme, ThemeProvider } from '@superset-ui/style'; +import { supersetTheme, ThemeProvider } from '@superset-ui/style'; import ToastPresenter from '../messageToasts/containers/ToastPresenter'; import ExploreViewContainer from './components/ExploreViewContainer'; import setupApp from '../setup/setupApp'; diff --git a/superset-frontend/src/explore/components/AdhocFilterEditPopoverSimpleTabContent.jsx b/superset-frontend/src/explore/components/AdhocFilterEditPopoverSimpleTabContent.jsx index 0b5a02df3..cc3ed2f3b 100644 --- a/superset-frontend/src/explore/components/AdhocFilterEditPopoverSimpleTabContent.jsx +++ b/superset-frontend/src/explore/components/AdhocFilterEditPopoverSimpleTabContent.jsx @@ -19,7 +19,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { FormGroup } from 'react-bootstrap'; -import { Select, Creatable } from 'src/components/Select'; +import { Select } from 'src/components/Select'; import { t } from '@superset-ui/translation'; import { SupersetClient } from '@superset-ui/connection'; @@ -236,7 +236,7 @@ export default class AdhocFilterEditPopoverSimpleTabContent extends React.Compon loading: false, })); }) - .catch(error => { + .catch(() => { this.setState(() => ({ suggestions: [], abortActiveRequest: null, diff --git a/superset-frontend/src/explore/components/AdhocFilterEditPopoverSqlTabContent.jsx b/superset-frontend/src/explore/components/AdhocFilterEditPopoverSqlTabContent.jsx index 39b094953..2d7083253 100644 --- a/superset-frontend/src/explore/components/AdhocFilterEditPopoverSqlTabContent.jsx +++ b/superset-frontend/src/explore/components/AdhocFilterEditPopoverSqlTabContent.jsx @@ -144,7 +144,7 @@ export default class AdhocFilterEditPopoverSqlTabContent extends React.Component ref={this.handleAceEditorRef} mode="sql" theme="github" - height={height - 100 + 'px'} + height={`${height - 100}px`} onChange={this.onSqlExpressionChange} width="100%" showGutter={false} diff --git a/superset-frontend/src/explore/components/AdhocMetricEditPopover.jsx b/superset-frontend/src/explore/components/AdhocMetricEditPopover.jsx index 064385ef6..ad0c8338d 100644 --- a/superset-frontend/src/explore/components/AdhocMetricEditPopover.jsx +++ b/superset-frontend/src/explore/components/AdhocMetricEditPopover.jsx @@ -35,7 +35,7 @@ import 'brace/ext/language_tools'; import { t } from '@superset-ui/translation'; import { ColumnOption } from '@superset-ui/chart-controls'; -import { AGGREGATES, AGGREGATES_OPTIONS } from '../constants'; +import { AGGREGATES_OPTIONS } from '../constants'; import AdhocMetricEditPopoverTitle from './AdhocMetricEditPopoverTitle'; import columnType from '../propTypes/columnType'; import AdhocMetric, { EXPRESSION_TYPES } from '../AdhocMetric'; @@ -283,7 +283,7 @@ export default class AdhocMetricEditPopover extends React.Component { ref={this.handleAceEditorRef} mode="sql" theme="github" - height={this.state.height - 43 + 'px'} + height={`${this.state.height - 43}px`} onChange={this.onSqlExpressionChange} width="100%" showGutter={false} diff --git a/superset-frontend/src/explore/components/AdhocMetricOption.jsx b/superset-frontend/src/explore/components/AdhocMetricOption.jsx index 9bdca1f3a..60e0a9ce7 100644 --- a/superset-frontend/src/explore/components/AdhocMetricOption.jsx +++ b/superset-frontend/src/explore/components/AdhocMetricOption.jsx @@ -19,7 +19,6 @@ import React from 'react'; import PropTypes from 'prop-types'; import { Label, OverlayTrigger } from 'react-bootstrap'; -import { thresholdScott } from 'd3-array'; import AdhocMetricEditPopover from './AdhocMetricEditPopover'; import AdhocMetric from '../AdhocMetric'; diff --git a/superset-frontend/src/explore/components/ControlPanelsContainer.jsx b/superset-frontend/src/explore/components/ControlPanelsContainer.jsx index 861d30199..67c9857f1 100644 --- a/superset-frontend/src/explore/components/ControlPanelsContainer.jsx +++ b/superset-frontend/src/explore/components/ControlPanelsContainer.jsx @@ -22,10 +22,7 @@ import PropTypes from 'prop-types'; import { bindActionCreators } from 'redux'; import { connect } from 'react-redux'; import { Alert, Tab, Tabs } from 'react-bootstrap'; -import { isPlainObject } from 'lodash'; import { t } from '@superset-ui/translation'; -import { getChartControlPanelRegistry } from '@superset-ui/chart'; -import { sharedControls } from '@superset-ui/chart-controls'; import ControlPanelSection from './ControlPanelSection'; import ControlRow from './ControlRow'; @@ -64,7 +61,7 @@ class ControlPanelsContainer extends React.Component { } renderControl({ name, config }) { - const { actions, controls, exploreState, form_data: formData } = this.props; + const { actions, controls, form_data: formData } = this.props; const { visibility } = config; // If the control item is not an object, we have to look up the control data from diff --git a/superset-frontend/src/explore/components/EmbedCodeButton.jsx b/superset-frontend/src/explore/components/EmbedCodeButton.jsx index 7f3217c08..5a6618fd2 100644 --- a/superset-frontend/src/explore/components/EmbedCodeButton.jsx +++ b/superset-frontend/src/explore/components/EmbedCodeButton.jsx @@ -47,10 +47,10 @@ export default class EmbedCodeButton extends React.Component { } generateEmbedHTML() { - const srcLink = + const srcLink = `${ window.location.origin + - getExploreLongUrl(this.props.latestQueryFormData, 'standalone') + - `&height=${this.state.height}`; + getExploreLongUrl(this.props.latestQueryFormData, 'standalone') + }&height=${this.state.height}`; return ( ' { dataEndpoint={dataEndpoint} onChange={onSelectionChange} onAsyncError={errorMsg => - this.props.addDangerToast(onAsyncErrorMessage + ': ' + errorMsg) + this.props.addDangerToast(`${onAsyncErrorMessage}: ${errorMsg}`) } mutator={mutator} multi={multi} diff --git a/superset-frontend/src/explore/components/controls/SelectControl.jsx b/superset-frontend/src/explore/components/controls/SelectControl.jsx index b858342a0..fc2180f6d 100644 --- a/superset-frontend/src/explore/components/controls/SelectControl.jsx +++ b/superset-frontend/src/explore/components/controls/SelectControl.jsx @@ -139,7 +139,6 @@ export default class SelectControl extends React.PureComponent { } else if (props.choices) { // Accepts different formats of input options = props.choices.map(c => { - let option; if (Array.isArray(c)) { const [value, label] = c.length > 1 ? c : [c[0], c[0]]; return { label, [props.valueKey]: value }; diff --git a/superset-frontend/src/explore/components/controls/ViewportControl.jsx b/superset-frontend/src/explore/components/controls/ViewportControl.jsx index e5057a022..b04484f1d 100644 --- a/superset-frontend/src/explore/components/controls/ViewportControl.jsx +++ b/superset-frontend/src/explore/components/controls/ViewportControl.jsx @@ -85,11 +85,9 @@ export default class ViewportControl extends React.Component { } renderLabel() { if (this.props.value.longitude && this.props.value.latitude) { - return ( - decimal2sexagesimal(this.props.value.longitude) + - ' | ' + - decimal2sexagesimal(this.props.value.latitude) - ); + return `${decimal2sexagesimal( + this.props.value.longitude, + )} | ${decimal2sexagesimal(this.props.value.latitude)}`; } return 'N/A'; } diff --git a/superset-frontend/src/explore/controlPanels/DeckHex.js b/superset-frontend/src/explore/controlPanels/DeckHex.js index 7c9c874d7..b67bcfb92 100644 --- a/superset-frontend/src/explore/controlPanels/DeckHex.js +++ b/superset-frontend/src/explore/controlPanels/DeckHex.js @@ -17,10 +17,7 @@ * under the License. */ import { t } from '@superset-ui/translation'; -import { - formatSelectOptions, - formatSelectOptionsForRange, -} from '../../modules/utils'; +import { formatSelectOptions } from '../../modules/utils'; import { filterNulls, autozoom, diff --git a/superset-frontend/src/explore/controlPanels/Shared_DeckGL.jsx b/superset-frontend/src/explore/controlPanels/Shared_DeckGL.jsx index 4bdbb4c39..b5c504cf0 100644 --- a/superset-frontend/src/explore/controlPanels/Shared_DeckGL.jsx +++ b/superset-frontend/src/explore/controlPanels/Shared_DeckGL.jsx @@ -22,19 +22,10 @@ import React from 'react'; import { t } from '@superset-ui/translation'; import { validateNonEmpty } from '@superset-ui/validator'; -import { ColumnOption, sharedControls } from '@superset-ui/chart-controls'; +import { sharedControls } from '@superset-ui/chart-controls'; import { D3_FORMAT_OPTIONS, columnChoices, PRIMARY_COLOR } from '../controls'; import { DEFAULT_VIEWPORT } from '../../explore/components/controls/ViewportControl'; -const timeColumnOption = { - verbose_name: 'Time', - column_name: '__timestamp', - description: t( - 'A reference to the [Time] configuration, taking granularity into ' + - 'account', - ), -}; - const sandboxUrl = 'https://github.com/apache/incubator-superset/' + 'blob/master/superset-frontend/src/modules/sandbox.js'; diff --git a/superset-frontend/src/explore/controlUtils.js b/superset-frontend/src/explore/controlUtils.js index ce3022e17..3ad056153 100644 --- a/superset-frontend/src/explore/controlUtils.js +++ b/superset-frontend/src/explore/controlUtils.js @@ -19,7 +19,6 @@ import memoizeOne from 'memoize-one'; import { getChartControlPanelRegistry } from '@superset-ui/chart'; import { expandControlConfig } from '@superset-ui/chart-controls'; -import { controls as SHARED_CONTROLS } from './controls'; import * as SECTIONS from './controlPanels/sections'; export function getFormDataFromControls(controlsState) { diff --git a/superset-frontend/src/explore/controls.jsx b/superset-frontend/src/explore/controls.jsx index 5d880fe70..07ca75a02 100644 --- a/superset-frontend/src/explore/controls.jsx +++ b/superset-frontend/src/explore/controls.jsx @@ -68,11 +68,7 @@ import { } from '@superset-ui/validator'; import { ColumnOption } from '@superset-ui/chart-controls'; -import { - formatSelectOptionsForRange, - formatSelectOptions, - mainMetric, -} from '../modules/utils'; +import { formatSelectOptions, mainMetric } from '../modules/utils'; import { TIME_FILTER_LABELS } from './constants'; const categoricalSchemeRegistry = getCategoricalSchemeRegistry(); @@ -136,7 +132,7 @@ const groupByControl = { valueRenderer: c => , valueKey: 'column_name', allowAll: true, - filterOption: ({ label, value, data: opt }, text) => + filterOption: ({ data: opt }, text) => (opt.column_name && opt.column_name.toLowerCase().indexOf(text.toLowerCase()) >= 0) || (opt.verbose_name && diff --git a/superset-frontend/src/explore/exploreUtils.js b/superset-frontend/src/explore/exploreUtils.js index 22dc53437..af89a281f 100644 --- a/superset-frontend/src/explore/exploreUtils.js +++ b/superset-frontend/src/explore/exploreUtils.js @@ -18,7 +18,6 @@ */ /* eslint camelcase: 0 */ import URI from 'urijs'; -import { SupersetClient } from '@superset-ui/connection'; import { buildQueryContext } from '@superset-ui/query'; import { availableDomains } from 'src/utils/hostNamesConfig'; import { safeStringify } from 'src/utils/safeStringify'; diff --git a/superset-frontend/src/modules/utils.js b/superset-frontend/src/modules/utils.js index 017c51cc4..bf54b83a1 100644 --- a/superset-frontend/src/modules/utils.js +++ b/superset-frontend/src/modules/utils.js @@ -64,7 +64,7 @@ export function getDatasourceParameter(datasourceId, datasourceType) { export function getParam(name) { /* eslint no-useless-escape: 0 */ const formattedName = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]'); - const regex = new RegExp('[\\?&]' + formattedName + '=([^&#]*)'); + const regex = new RegExp(`[\\?&]${formattedName}=([^&#]*)`); const results = regex.exec(location.search); return results === null ? '' diff --git a/superset-frontend/src/setup/setupApp.ts b/superset-frontend/src/setup/setupApp.ts index 5d9e8e184..b9852678a 100644 --- a/superset-frontend/src/setup/setupApp.ts +++ b/superset-frontend/src/setup/setupApp.ts @@ -31,7 +31,7 @@ function showApiMessage(resp: ClientErrorObject) { 'data-dismiss="alert">\xD7
'; const severity = resp.severity || 'info'; $(template) - .addClass('alert-' + severity) + .addClass(`alert-${severity}`) .append(resp.message || '') .appendTo($('#alert-container')); } @@ -58,7 +58,7 @@ export default function setupApp() { const $this = $(this); const prefix = $this.data('checkbox-api-prefix'); const id = $this.attr('id'); - toggleCheckbox(prefix, '#' + id); + toggleCheckbox(prefix, `#${id}`); }); // for language picker dropdown diff --git a/superset-frontend/src/utils/common.js b/superset-frontend/src/utils/common.js index 521ad9064..268182748 100644 --- a/superset-frontend/src/utils/common.js +++ b/superset-frontend/src/utils/common.js @@ -117,7 +117,7 @@ export function optionFromValue(opt) { export function prepareCopyToClipboardTabularData(data) { let result = ''; for (let i = 0; i < data.length; ++i) { - result += Object.values(data[i]).join('\t') + '\n'; + result += `${Object.values(data[i]).join('\t')}\n`; } return result; }