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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 18 additions and 20 deletions

View File

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

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
// table name or schema or anything else
if (!isNaN(parseInt(prefix, 10))) {
if (!Number.isNaN(parseInt(prefix, 10))) {
return;
}
const completer = {

View File

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

View File

@ -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}/`,

View File

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

View File

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

View File

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

View File

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

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
// 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) {

View File

@ -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, ' '));

View File

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

View File

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