diff --git a/superset-frontend/.eslintrc.js b/superset-frontend/.eslintrc.js index 24d700806..27c1bcca0 100644 --- a/superset-frontend/.eslintrc.js +++ b/superset-frontend/.eslintrc.js @@ -96,7 +96,6 @@ module.exports = { 'no-multi-spaces': 0, 'no-plusplus': 0, 'no-prototype-builtins': 0, - 'no-restricted-globals': 0, // disabled temporarily 'no-restricted-properties': 0, 'no-restricted-syntax': 0, 'no-restricted-imports': [ @@ -208,7 +207,6 @@ module.exports = { 'jsx-a11y/mouse-events-have-key-events': 0, // re-enable up for discussion 'lines-between-class-members': 0, // disabled temporarily 'new-cap': 0, - 'no-restricted-globals': 0, // disabled temporarily 'no-else-return': 0, // disabled temporarily 'no-bitwise': 0, 'no-continue': 0, diff --git a/superset-frontend/src/SqlLab/components/AceEditorWrapper.tsx b/superset-frontend/src/SqlLab/components/AceEditorWrapper.tsx index 587ba4950..f3779b90a 100644 --- a/superset-frontend/src/SqlLab/components/AceEditorWrapper.tsx +++ b/superset-frontend/src/SqlLab/components/AceEditorWrapper.tsx @@ -153,7 +153,7 @@ class AceEditorWrapper extends React.PureComponent { ) { // If the prefix starts with a number, don't try to autocomplete with a // table name or schema or anything else - if (!isNaN(parseInt(prefix, 10))) { + if (!Number.isNaN(parseInt(prefix, 10))) { return; } const completer = { diff --git a/superset-frontend/src/components/SearchInput.tsx b/superset-frontend/src/components/SearchInput.tsx index d73817402..d5f30f324 100644 --- a/superset-frontend/src/components/SearchInput.tsx +++ b/superset-frontend/src/components/SearchInput.tsx @@ -53,13 +53,13 @@ const commonStyles = ` cursor: pointer; `; const SearchIcon = styled(Icon)` - ${commonStyles} + ${commonStyles}; top: 1px; left: 2px; `; const ClearIcon = styled(Icon)` - ${commonStyles} + ${commonStyles}; right: 0px; top: 1px; `; diff --git a/superset-frontend/src/dashboard/components/Header.jsx b/superset-frontend/src/dashboard/components/Header.jsx index d815799c3..55ab3a82e 100644 --- a/superset-frontend/src/dashboard/components/Header.jsx +++ b/superset-frontend/src/dashboard/components/Header.jsx @@ -466,7 +466,7 @@ class Header extends React.PureComponent { setColorSchemeAndUnsavedChanges(updates.colorScheme); dashboardTitleChanged(updates.title); if (updates.slug) { - history.pushState( + window.history.pushState( { event: 'dashboard_properties_changed' }, '', `/superset/dashboard/${updates.slug}/`, diff --git a/superset-frontend/src/dashboard/util/getComponentWidthFromDrop.js b/superset-frontend/src/dashboard/util/getComponentWidthFromDrop.js index 21c9b3a0e..6f326f91f 100644 --- a/superset-frontend/src/dashboard/util/getComponentWidthFromDrop.js +++ b/superset-frontend/src/dashboard/util/getComponentWidthFromDrop.js @@ -50,7 +50,7 @@ export default function getComponentWidthFromDrop({ let destinationCapacity = destinationWidth.width - destinationWidth.occupiedWidth; - if (isNaN(destinationCapacity)) { + if (Number.isNaN(destinationCapacity)) { const grandparentWidth = getDetailedComponentWidth({ id: findParentId({ childId: destination.id, @@ -63,7 +63,7 @@ export default function getComponentWidthFromDrop({ grandparentWidth.width - grandparentWidth.occupiedWidth; } - if (isNaN(destinationCapacity) || isNaN(draggingWidth.width)) { + if (Number.isNaN(destinationCapacity) || Number.isNaN(draggingWidth.width)) { return draggingWidth.width; } else if (destinationCapacity >= draggingWidth.width) { return draggingWidth.width; diff --git a/superset-frontend/src/explore/components/ExploreViewContainer.jsx b/superset-frontend/src/explore/components/ExploreViewContainer.jsx index 2049972c0..ba82542d3 100644 --- a/superset-frontend/src/explore/components/ExploreViewContainer.jsx +++ b/superset-frontend/src/explore/components/ExploreViewContainer.jsx @@ -241,9 +241,9 @@ class ExploreViewContainer extends React.Component { const longUrl = getExploreLongUrl(this.props.form_data, null, false); try { if (isReplace) { - history.replaceState(payload, title, longUrl); + window.history.replaceState(payload, title, longUrl); } else { - history.pushState(payload, title, longUrl); + window.history.pushState(payload, title, longUrl); } } catch (e) { logging.warn( @@ -268,7 +268,7 @@ class ExploreViewContainer extends React.Component { } handlePopstate() { - const formData = history.state; + const formData = window.history.state; if (formData && Object.keys(formData).length) { this.props.actions.setExploreControls(formData); this.props.actions.postChartFormData( diff --git a/superset-frontend/src/explore/components/controls/BoundsControl.jsx b/superset-frontend/src/explore/components/controls/BoundsControl.jsx index bdd364f5c..0815495b3 100644 --- a/superset-frontend/src/explore/components/controls/BoundsControl.jsx +++ b/superset-frontend/src/explore/components/controls/BoundsControl.jsx @@ -64,10 +64,10 @@ export default class BoundsControl extends React.Component { onChange() { const mm = this.state.minMax; const errors = []; - if (mm[0] && isNaN(mm[0])) { + if (mm[0] && Number.isNaN(mm[0])) { errors.push(t('`Min` value should be numeric or empty')); } - if (mm[1] && isNaN(mm[1])) { + if (mm[1] && Number.isNaN(mm[1])) { errors.push(t('`Max` value should be numeric or empty')); } if (errors.length === 0) { diff --git a/superset-frontend/src/explore/components/controls/FilterBoxItemControl.jsx b/superset-frontend/src/explore/components/controls/FilterBoxItemControl.jsx index 192c701a6..5a82c39fe 100644 --- a/superset-frontend/src/explore/components/controls/FilterBoxItemControl.jsx +++ b/superset-frontend/src/explore/components/controls/FilterBoxItemControl.jsx @@ -114,9 +114,9 @@ export default class FilterBoxItemControl extends React.Component { if (type === 'BOOLEAN') { typedValue = value === 'true'; } else if (INTEGRAL_TYPES.has(type)) { - typedValue = isNaN(value) ? null : parseInt(value, 10); + typedValue = Number.isNaN(value) ? null : parseInt(value, 10); } else if (DECIMAL_TYPES.has(type)) { - typedValue = isNaN(value) ? null : parseFloat(value); + typedValue = Number.isNaN(value) ? null : parseFloat(value); } } } diff --git a/superset-frontend/src/explore/exploreUtils.js b/superset-frontend/src/explore/exploreUtils.js index d2d578d30..e69ce0bf7 100644 --- a/superset-frontend/src/explore/exploreUtils.js +++ b/superset-frontend/src/explore/exploreUtils.js @@ -117,9 +117,9 @@ export function getChartDataUri({ path, qs, allowDomainSharding = false }) { // but can be specified with curUrl (used for unit tests to spoof // the window.location). let uri = new URI({ - protocol: location.protocol.slice(0, -1), + protocol: window.location.protocol.slice(0, -1), hostname: getHostName(allowDomainSharding), - port: location.port ? location.port : '', + port: window.location.port ? window.location.port : '', path, }); if (qs) { diff --git a/superset-frontend/src/modules/utils.js b/superset-frontend/src/modules/utils.js index bf54b83a1..1c5117cc2 100644 --- a/superset-frontend/src/modules/utils.js +++ b/superset-frontend/src/modules/utils.js @@ -65,7 +65,7 @@ export function getParam(name) { /* eslint no-useless-escape: 0 */ const formattedName = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]'); const regex = new RegExp(`[\\?&]${formattedName}=([^&#]*)`); - const results = regex.exec(location.search); + const results = regex.exec(window.location.search); return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' ')); diff --git a/superset-frontend/src/setup/setupApp.ts b/superset-frontend/src/setup/setupApp.ts index d97ea1ac1..c51b42a50 100644 --- a/superset-frontend/src/setup/setupApp.ts +++ b/superset-frontend/src/setup/setupApp.ts @@ -75,7 +75,7 @@ export default function setupApp() { url: ev.currentTarget.href, parseMethod: null, }).then(() => { - location.reload(); + window.location.reload(); }); }); }); diff --git a/superset-frontend/src/utils/hostNamesConfig.js b/superset-frontend/src/utils/hostNamesConfig.js index 98ac055fc..a216cbee1 100644 --- a/superset-frontend/src/utils/hostNamesConfig.js +++ b/superset-frontend/src/utils/hostNamesConfig.js @@ -23,7 +23,7 @@ function getDomainsConfig() { } const bootstrapData = JSON.parse(appContainer.getAttribute('data-bootstrap')); - const availableDomains = new Set([location.hostname]); + const availableDomains = new Set([window.location.hostname]); if ( bootstrapData && bootstrapData.common &&