ESLint: Re-enable rule no-restricted-globals (#10863)

* Re-enable rule no-restricted-globals

* Fix missing semicolons
This commit is contained in:
Kamil Gabryjelski
2020-09-14 19:39:46 +02:00
committed by GitHub
parent 7f1012360a
commit 1908a94c7e
12 changed files with 18 additions and 20 deletions

View File

@@ -96,7 +96,6 @@ module.exports = {
'no-multi-spaces': 0, 'no-multi-spaces': 0,
'no-plusplus': 0, 'no-plusplus': 0,
'no-prototype-builtins': 0, 'no-prototype-builtins': 0,
'no-restricted-globals': 0, // disabled temporarily
'no-restricted-properties': 0, 'no-restricted-properties': 0,
'no-restricted-syntax': 0, 'no-restricted-syntax': 0,
'no-restricted-imports': [ 'no-restricted-imports': [
@@ -208,7 +207,6 @@ module.exports = {
'jsx-a11y/mouse-events-have-key-events': 0, // re-enable up for discussion 'jsx-a11y/mouse-events-have-key-events': 0, // re-enable up for discussion
'lines-between-class-members': 0, // disabled temporarily 'lines-between-class-members': 0, // disabled temporarily
'new-cap': 0, 'new-cap': 0,
'no-restricted-globals': 0, // disabled temporarily
'no-else-return': 0, // disabled temporarily 'no-else-return': 0, // disabled temporarily
'no-bitwise': 0, 'no-bitwise': 0,
'no-continue': 0, 'no-continue': 0,

View File

@@ -153,7 +153,7 @@ class AceEditorWrapper extends React.PureComponent<Props, State> {
) { ) {
// If the prefix starts with a number, don't try to autocomplete with a // If the prefix starts with a number, don't try to autocomplete with a
// table name or schema or anything else // table name or schema or anything else
if (!isNaN(parseInt(prefix, 10))) { if (!Number.isNaN(parseInt(prefix, 10))) {
return; return;
} }
const completer = { const completer = {

View File

@@ -53,13 +53,13 @@ const commonStyles = `
cursor: pointer; cursor: pointer;
`; `;
const SearchIcon = styled(Icon)` const SearchIcon = styled(Icon)`
${commonStyles} ${commonStyles};
top: 1px; top: 1px;
left: 2px; left: 2px;
`; `;
const ClearIcon = styled(Icon)` const ClearIcon = styled(Icon)`
${commonStyles} ${commonStyles};
right: 0px; right: 0px;
top: 1px; top: 1px;
`; `;

View File

@@ -466,7 +466,7 @@ class Header extends React.PureComponent {
setColorSchemeAndUnsavedChanges(updates.colorScheme); setColorSchemeAndUnsavedChanges(updates.colorScheme);
dashboardTitleChanged(updates.title); dashboardTitleChanged(updates.title);
if (updates.slug) { if (updates.slug) {
history.pushState( window.history.pushState(
{ event: 'dashboard_properties_changed' }, { event: 'dashboard_properties_changed' },
'', '',
`/superset/dashboard/${updates.slug}/`, `/superset/dashboard/${updates.slug}/`,

View File

@@ -50,7 +50,7 @@ export default function getComponentWidthFromDrop({
let destinationCapacity = let destinationCapacity =
destinationWidth.width - destinationWidth.occupiedWidth; destinationWidth.width - destinationWidth.occupiedWidth;
if (isNaN(destinationCapacity)) { if (Number.isNaN(destinationCapacity)) {
const grandparentWidth = getDetailedComponentWidth({ const grandparentWidth = getDetailedComponentWidth({
id: findParentId({ id: findParentId({
childId: destination.id, childId: destination.id,
@@ -63,7 +63,7 @@ export default function getComponentWidthFromDrop({
grandparentWidth.width - grandparentWidth.occupiedWidth; grandparentWidth.width - grandparentWidth.occupiedWidth;
} }
if (isNaN(destinationCapacity) || isNaN(draggingWidth.width)) { if (Number.isNaN(destinationCapacity) || Number.isNaN(draggingWidth.width)) {
return draggingWidth.width; return draggingWidth.width;
} else if (destinationCapacity >= draggingWidth.width) { } else if (destinationCapacity >= draggingWidth.width) {
return draggingWidth.width; return draggingWidth.width;

View File

@@ -241,9 +241,9 @@ class ExploreViewContainer extends React.Component {
const longUrl = getExploreLongUrl(this.props.form_data, null, false); const longUrl = getExploreLongUrl(this.props.form_data, null, false);
try { try {
if (isReplace) { if (isReplace) {
history.replaceState(payload, title, longUrl); window.history.replaceState(payload, title, longUrl);
} else { } else {
history.pushState(payload, title, longUrl); window.history.pushState(payload, title, longUrl);
} }
} catch (e) { } catch (e) {
logging.warn( logging.warn(
@@ -268,7 +268,7 @@ class ExploreViewContainer extends React.Component {
} }
handlePopstate() { handlePopstate() {
const formData = history.state; const formData = window.history.state;
if (formData && Object.keys(formData).length) { if (formData && Object.keys(formData).length) {
this.props.actions.setExploreControls(formData); this.props.actions.setExploreControls(formData);
this.props.actions.postChartFormData( this.props.actions.postChartFormData(

View File

@@ -64,10 +64,10 @@ export default class BoundsControl extends React.Component {
onChange() { onChange() {
const mm = this.state.minMax; const mm = this.state.minMax;
const errors = []; 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')); 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')); errors.push(t('`Max` value should be numeric or empty'));
} }
if (errors.length === 0) { if (errors.length === 0) {

View File

@@ -114,9 +114,9 @@ export default class FilterBoxItemControl extends React.Component {
if (type === 'BOOLEAN') { if (type === 'BOOLEAN') {
typedValue = value === 'true'; typedValue = value === 'true';
} else if (INTEGRAL_TYPES.has(type)) { } 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)) { } else if (DECIMAL_TYPES.has(type)) {
typedValue = isNaN(value) ? null : parseFloat(value); typedValue = Number.isNaN(value) ? null : parseFloat(value);
} }
} }
} }

View File

@@ -117,9 +117,9 @@ export function getChartDataUri({ path, qs, allowDomainSharding = false }) {
// but can be specified with curUrl (used for unit tests to spoof // but can be specified with curUrl (used for unit tests to spoof
// the window.location). // the window.location).
let uri = new URI({ let uri = new URI({
protocol: location.protocol.slice(0, -1), protocol: window.location.protocol.slice(0, -1),
hostname: getHostName(allowDomainSharding), hostname: getHostName(allowDomainSharding),
port: location.port ? location.port : '', port: window.location.port ? window.location.port : '',
path, path,
}); });
if (qs) { if (qs) {

View File

@@ -65,7 +65,7 @@ export function getParam(name) {
/* eslint no-useless-escape: 0 */ /* eslint no-useless-escape: 0 */
const formattedName = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]'); const formattedName = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
const regex = new RegExp(`[\\?&]${formattedName}=([^&#]*)`); const regex = new RegExp(`[\\?&]${formattedName}=([^&#]*)`);
const results = regex.exec(location.search); const results = regex.exec(window.location.search);
return results === null return results === null
? '' ? ''
: decodeURIComponent(results[1].replace(/\+/g, ' ')); : decodeURIComponent(results[1].replace(/\+/g, ' '));

View File

@@ -75,7 +75,7 @@ export default function setupApp() {
url: ev.currentTarget.href, url: ev.currentTarget.href,
parseMethod: null, parseMethod: null,
}).then(() => { }).then(() => {
location.reload(); window.location.reload();
}); });
}); });
}); });

View File

@@ -23,7 +23,7 @@ function getDomainsConfig() {
} }
const bootstrapData = JSON.parse(appContainer.getAttribute('data-bootstrap')); const bootstrapData = JSON.parse(appContainer.getAttribute('data-bootstrap'));
const availableDomains = new Set([location.hostname]); const availableDomains = new Set([window.location.hostname]);
if ( if (
bootstrapData && bootstrapData &&
bootstrapData.common && bootstrapData.common &&