Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

fix `no-restricted-globals` errors

Jason Kent3fa41626df1b
diff --git a/.eslintrc b/.eslintrc
index e4872f2cf..95ccdf262 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -84,7 +84,6 @@
"class-methods-use-this": "off",
"max-len": "off",
- "no-restricted-globals": "off",
"no-multi-assign": "off",
"consistent-return": "off",
"no-underscore-dangle": "off",
diff --git a/web/js/components/date-selector/input.js b/web/js/components/date-selector/input.js
index a22f55342..caf96a0c9 100644
--- a/web/js/components/date-selector/input.js
+++ b/web/js/components/date-selector/input.js
@@ -125,7 +125,7 @@ class DateInputColumn extends Component {
case 'month':
newDate = this.monthValidation(value);
// transform month number to string (e.g., 3 -> 'MAR')
- if (newDate !== null && !isNaN(value)) {
+ if (newDate !== null && !Number.isNaN(value)) {
value = util.monthStringArray[value - 1];
}
break;
@@ -164,7 +164,7 @@ class DateInputColumn extends Component {
monthValidation = (input) => {
const date = new Date(this.props.date);
let newDate;
- if (!isNaN(input) && input < 13 && input > 0) {
+ if (!Number.isNaN(input) && input < 13 && input > 0) {
newDate = new Date(date.setUTCMonth(input - 1));
if (newDate) {
return this.validateDate(newDate);
@@ -263,7 +263,7 @@ class DateInputColumn extends Component {
? this.props.value
: inputValue;
- if (type === 'month' && !isNaN(value)) {
+ if (type === 'month' && !Number.isNaN(value)) {
value = util.monthStringArray[value - 1];
} else if (value.length === 1) {
value = `0${value}`;
diff --git a/web/js/components/layer/product-picker/search-layer-row.js b/web/js/components/layer/product-picker/search-layer-row.js
index 341905e79..816692860 100644
--- a/web/js/components/layer/product-picker/search-layer-row.js
+++ b/web/js/components/layer/product-picker/search-layer-row.js
@@ -16,6 +16,8 @@ class LayerRow extends React.Component {
this.state = {
checked: props.isEnabled,
};
+ this.toggleCheck = this.toggleCheck.bind(this);
+ this.toggleShowMetadata = this.toggleShowMetadata.bind(this);
}
/**
@@ -111,12 +113,12 @@ class LayerRow extends React.Component {
type="checkbox"
id={`${layer.id}-checkbox`}
title={title}
- name={name}
+ name={`${layer.id}-checkbox`}
checked={checked}
- onChange={this.toggleCheck.bind(this)}
+ onChange={this.toggleCheck}
/>
</div>
- <div className="layers-all-header" onClick={this.toggleShowMetadata.bind(this)}>
+ <div className="layers-all-header" onClick={this.toggleShowMetadata}>
{!track ? this.renderSplitTitle(layerTitle) : <h3>{layerTitle}</h3>}
{subtitle && <h5>{subtitle}</h5>}
{description && !isMetadataShowing && (
diff --git a/web/js/containers/share.js b/web/js/containers/share.js
index 07184c0dd..f84dcdc1b 100644
--- a/web/js/containers/share.js
+++ b/web/js/containers/share.js
@@ -19,7 +19,7 @@ import { history } from '../main';
const getShortenRequestString = function(mock, permalink) {
const mockStr = mock || '';
- if (/localhost/.test(location)) {
+ if (/localhost/.test(window.location)) {
return 'mock/short_link.json';
}
return (
diff --git a/web/js/containers/sidebar/layer.js b/web/js/containers/sidebar/layer.js
index cd56a5192..f73b805dd 100644
--- a/web/js/containers/sidebar/layer.js
+++ b/web/js/containers/sidebar/layer.js
@@ -237,7 +237,7 @@ class Layer extends React.Component {
<div className="layer-main">
<div className="layer-info">
{this.renderControls()}
- <h4 title={name.title}>{names.title}</h4>
+ <h4 title={names.title}>{names.title}</h4>
<p dangerouslySetInnerHTML={{ __html: names.subtitle }} />
{hasPalette ? this.getPaletteLegend() : ''}
</div>
diff --git a/web/js/containers/sidebar/sidebar.js b/web/js/containers/sidebar/sidebar.js
index b858fc04e..1d1008984 100644
--- a/web/js/containers/sidebar/sidebar.js
+++ b/web/js/containers/sidebar/sidebar.js
@@ -38,7 +38,7 @@ const resetWorldview = function(e) {
e.preventDefault();
if (window.location.search === '') return; // Nothing to reset
const msg = 'Do you want to reset Worldview to its defaults? You will lose your current state.';
- if (confirm(msg)) {
+ if (window.confirm(msg)) {
googleTagManager.pushEvent({
event: 'logo_page_reset',
});
diff --git a/web/js/debug.js b/web/js/debug.js
index 28999dd00..ea041df9f 100644
--- a/web/js/debug.js
+++ b/web/js/debug.js
@@ -4,7 +4,7 @@ import lodashParseInt from 'lodash/parseInt';
import util from './util/util';
export const debug = (function() {
- const parameters = util.fromQueryString(location.search);
+ const parameters = util.fromQueryString(window.location.search);
const self = {};
const init = function() {
diff --git a/web/js/edsc/geoutil.js b/web/js/edsc/geoutil.js
index 2495c7186..889486ffa 100644
--- a/web/js/edsc/geoutil.js
+++ b/web/js/edsc/geoutil.js
@@ -39,7 +39,7 @@ export default function (L, Coordinate, Arc, config) {
lat = RAD_TO_DEG * atan2(z, sqrt(x * x + y * y));
lon = RAD_TO_DEG * atan2(y, x);
// Guard against the points being the same or antipodal
- if (isNaN(lat) || isNaN(lon)) {
+ if (Number.isNaN(lat) || Number.isNaN(lon)) {
return p1;
}
while (lon < p1.lng - EPSILON) {
diff --git a/web/js/feedback.js b/web/js/feedback.js
index e5f1a76f2..42218d713 100644
--- a/web/js/feedback.js
+++ b/web/js/feedback.js
@@ -20,7 +20,7 @@ export function feedbackUi() {
feedback.showForm();
feedbackInit = true;
} else {
- location.href = 'mailto:@MAIL@?subject=Feedback for @LONG_NAME@ tool';
+ window.location.href = 'mailto:@MAIL@?subject=Feedback for @LONG_NAME@ tool';
}
};
return self;
diff --git a/web/js/main.js b/web/js/main.js
index f92527876..cf4982829 100644
--- a/web/js/main.js
+++ b/web/js/main.js
@@ -45,7 +45,7 @@ const startTime = new Date().getTime();
// ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({ latency: 0 }) ||
// defaultCompose
// : defaultCompose;
-const parameters = util.fromQueryString(location.search);
+const parameters = util.fromQueryString(window.location.search);
let { elapsed } = util;
const errors = [];
// Document ready function
diff --git a/web/js/map/map.js b/web/js/map/map.js
index a27c4e1d8..ca30762e2 100644
--- a/web/js/map/map.js
+++ b/web/js/map/map.js
@@ -64,7 +64,7 @@ export function mapIsExtentValid(extent) {
extent = extent.toArray();
}
lodashEach(extent, (value) => {
- if (isNaN(value)) {
+ if (Number.isNaN(value)) {
valid = false;
return false;
}
diff --git a/web/js/map/model.js b/web/js/map/model.js
index bb75f856b..fa6b8e07c 100644
--- a/web/js/map/model.js
+++ b/web/js/map/model.js
@@ -93,7 +93,7 @@ export function mapModel(models, config) {
}
// get rotation if it exists
if (state.p === 'arctic' || state.p === 'antarctic') {
- if (!isNaN(state.r)) {
+ if (!Number.isNaN(state.r)) {
self.rotation = state.r * (Math.PI / 180.0);
} // convert to radians
}
diff --git a/web/js/map/precachetile.js b/web/js/map/precachetile.js
index adf1f1e95..faec4a03a 100644
--- a/web/js/map/precachetile.js
+++ b/web/js/map/precachetile.js
@@ -11,6 +11,7 @@ export function mapPrecacheTile(models, config, cache, parent) {
* @param {object} date Date of data to be displayed on the map.
* @return {object} Promise.all
*/
+ /* eslint-disable no-restricted-globals */
self.promiseDay = function(date) {
let viewState;
let frameState;
@@ -92,7 +93,7 @@ export function mapPrecacheTile(models, config, cache, parent) {
// Current day (within map extent)
extent = getExtent(extent, viewportExtent);
}
- if (!isFinite(extent[0])) {
+ if (!Number.isFinite(extent[0])) {
return null;
}
return extent;
diff --git a/web/js/modules/feedback/util.js b/web/js/modules/feedback/util.js
index 060cf627c..0e6fb20b0 100644
--- a/web/js/modules/feedback/util.js
+++ b/web/js/modules/feedback/util.js
@@ -9,6 +9,7 @@ import util from '../../util/util';
export function onClickFeedback(wasInitiated) {
if (!util.browser.small && window.feedback) {
+ // eslint-disable-next-line no-restricted-globals
event.preventDefault();
if (!wasInitiated) {
feedback.init({
diff --git a/web/js/modules/layers/util.js b/web/js/modules/layers/util.js
index f7afef6c4..30d2b7831 100644
--- a/web/js/modules/layers/util.js
+++ b/web/js/modules/layers/util.js
@@ -496,7 +496,7 @@ const createLayerArrayFromState = function(state, config) {
}
if (attr.id === 'opacity') {
opacity = util.clamp(parseFloat(attr.value), 0, 1);
- if (isNaN(opacity)) opacity = 0; // "opacity=0.0" is opacity in URL, resulting in NaN
+ if (Number.isNaN(opacity)) opacity = 0; // "opacity=0.0" is opacity in URL, resulting in NaN
}
if (attr.id === 'disabled') {
const values = util.toArray(attr.value.split(';'));
diff --git a/web/js/modules/map/util.js b/web/js/modules/map/util.js
index 66ba868e6..a9ce043b8 100644
--- a/web/js/modules/map/util.js
+++ b/web/js/modules/map/util.js
@@ -58,7 +58,7 @@ export function getMapParameterSetup(
initialState: 0,
options: {
serializeNeedsGlobalState: true,
- parse: (state) => (!isNaN(state) ? state * (Math.PI / 180.0) : 0),
+ parse: (state) => (!Number.isNaN(state) ? state * (Math.PI / 180.0) : 0),
serialize: (currentItemState, currentState) => (currentItemState
&& currentState.proj.selected.id !== 'geographic'
? (currentItemState * (180.0 / Math.PI)).toPrecision(6)
@@ -87,7 +87,7 @@ export function mapIsExtentValid(extent) {
extent = extent.toArray();
}
lodashEach(extent, (value) => {
- if (isNaN(value)) {
+ if (Number.isNaN(value)) {
valid = false;
return false;
}
@@ -191,7 +191,7 @@ export function calculateExtent(extent, viewportExtent) {
// Current day (within map extent)
extent = getExtent(extent, viewportExtent);
}
- if (!isFinite(extent[0])) {
+ if (!Number.isFinite(extent[0])) {
return null;
}
return extent;
diff --git a/web/js/modules/palettes/selectors.js b/web/js/modules/palettes/selectors.js
index 0ebff1bf4..a8f384d05 100644
--- a/web/js/modules/palettes/selectors.js
+++ b/web/js/modules/palettes/selectors.js
@@ -418,7 +418,7 @@ export function setDisabledSelector(
maps: {
[index]: {
$merge: {
- disabled: isNaN(classIndex) ? [] : oldDisabled,
+ disabled: Number.isNaN(classIndex) ? [] : oldDisabled,
},
},
},
diff --git a/web/js/polyfill.js b/web/js/polyfill.js
index a3e15b9f9..e75d7b147 100644
--- a/web/js/polyfill.js
+++ b/web/js/polyfill.js
@@ -1,3 +1,4 @@
+/* eslint-disable no-restricted-globals */
// ===========================================================================
// Polyfills and browser quirks - DEPRECATED
// This file is full of lots of old hacks, that are kept around to avoid
diff --git a/web/js/util/util.js b/web/js/util/util.js
index 562b52230..f9424a259 100644
--- a/web/js/util/util.js
+++ b/web/js/util/util.js
@@ -216,7 +216,7 @@ export default (function(self) {
}
const date = new Date(Date.UTC(year, month, day, hour, minute, second,
millisecond));
- if (isNaN(date.getTime())) {
+ if (Number.isNaN(date.getTime())) {
throw new Error(`Invalid date: ${dateAsString}`);
}
return date;
@@ -245,7 +245,7 @@ export default (function(self) {
* @param {Object} d | Date object
*/
self.isValidDate = function(d) {
- return d instanceof Date && !isNaN(d);
+ return d instanceof Date && !Number.isNaN(d);
};
/**
* Parses a UTC ISO 8601 date to a non UTC date
@@ -281,7 +281,7 @@ export default (function(self) {
}
const date = new Date(year, month, day, hour, minute, second,
millisecond);
- if (isNaN(date.getTime())) {
+ if (Number.isNaN(date.getTime())) {
throw new Error(`Invalid date: ${dateAsString}`);
}
return date;