Interactive interface for browsing global, full-resolution satellite imagery
WV-2813: Re-Enabling various ESLint rules and code refactoring (#6274)
Jason Hurleya0f1d1d1619a
diff --git a/web/.eslintrc b/web/.eslintrcindex 373f6b819..07d0cdee6 100644--- a/web/.eslintrc+++ b/web/.eslintrc@@ -87,9 +87,9 @@// Base rule overrides"no-nested-ternary": "off", // 164 errors across 40 files"no-shadow": "warn", // 110 errors across 40 files- "max-len": "error", // 315 errors across 109 files+ "max-len": "error","consistent-return": "off", // 95 errors across 58 files- "no-underscore-dangle": "off", // 40 errors across 7 files+ "no-underscore-dangle": "error","no-param-reassign": [ // 198 errors across 46 files"warn",{@@ -110,9 +110,9 @@"jsx-a11y/no-static-element-interactions": "off", // 71 errors across 39 files"jsx-a11y/click-events-have-key-events": "off", // 70 errors across 39 files// React rules overrides- "react/jsx-props-no-spreading": "warn", // 6 errors across 2 files+ "react/jsx-props-no-spreading": "error","react/jsx-filename-extension": "off", // 206 errors across 206 files- "react/jsx-no-bind": "warn", // 9 errors across 5 files+ "react/jsx-no-bind": "error","react/sort-comp": ["error",{@@ -156,15 +156,15 @@"react/forbid-prop-types": "off", // 411 errors across 139 files"react/require-default-props": "off", // 1644 errors across > 80 files"class-methods-use-this": "warn", // 15 errors across 13 files- "react/no-unused-class-component-methods": "warn", // 8 errors across 7 files- "react/no-unknown-property": "warn", // 2 errors across 2 files- "react/jsx-no-useless-fragment": "warn", // 3 errors across 3 files- "react/no-unstable-nested-components": "warn", // 1 error across 1 file+ "react/no-unused-class-component-methods": "error",+ "react/no-unknown-property": "error",+ "react/jsx-no-useless-fragment": "error",+ "react/no-unstable-nested-components": "error","react/prop-types": "warn", // 58 errors across 22 files"react/no-unused-prop-types": "warn", // 9 errors across 9 files"default-param-last": "warn", // 42 errors across 34 files- "prefer-regex-literals": "warn", // 3 errors across 1 file- "no-promise-executor-return": "warn" // 1 error across 1 file+ "prefer-regex-literals": "error",+ "no-promise-executor-return": "error"}}]diff --git a/web/js/app.js b/web/js/app.jsindex e52e4fe10..b6d23cdde 100644--- a/web/js/app.js+++ b/web/js/app.js@@ -109,12 +109,12 @@ class App extends React.Component {};onload() {- const self = this;- const state = self.props.parameters;- const { config } = self.props;+ const { props, getScreenInfo, setVhCSSProperty } = this;+ const { config, parameters } = props;+ const state = parameters;config.parameters = state;- const main = function() {+ const main = () => {// Load any additional scripts as neededif (config.scripts) {util.loadScripts(config.scripts);@@ -133,14 +133,14 @@ class App extends React.Component {console.warn('Development version');}window.addEventListener('resize', () => {- self.getScreenInfo();+ getScreenInfo();});window.addEventListener('orientationchange', () => {- self.getScreenInfo();+ getScreenInfo();});- self.getScreenInfo();+ getScreenInfo();events.trigger(STARTUP);- self.setVhCSSProperty();+ setVhCSSProperty();};util.wrap(main)();}@@ -272,6 +272,7 @@ App.propTypes = {parameters: PropTypes.object,setScreenInfoAction: PropTypes.func,hideNotificationsPopup: PropTypes.bool,+ config: PropTypes.object,};App.defaultProps = {diff --git a/web/js/components/animation-widget/play-queue.js b/web/js/components/animation-widget/play-queue.jsindex 3121fc67d..3da6b9dc2 100644--- a/web/js/components/animation-widget/play-queue.js+++ b/web/js/components/animation-widget/play-queue.js@@ -184,8 +184,6 @@ class PlayQueue extends React.Component {}}- getAverageFetchTime = () => this.fetchTimes.reduce((a, b) => a + b) / this.fetchTimes.length;-isPreloadSufficient() {const { numberOfFrames } = this.props;const currentBufferSize = util.objectLength(this.bufferObject);@@ -344,7 +342,6 @@ class PlayQueue extends React.Component {this.abortController.abort();this.setState({ isAnimating: false });this.hasPlayStarted = false;- // console.debug('Stopped', this.getAverageFetchTime(), this.fetchTimes);}animationInterval(ms, callback) {diff --git a/web/js/components/charting/chart-component.js b/web/js/components/charting/chart-component.jsindex 4a182b086..0e3d6361a 100644--- a/web/js/components/charting/chart-component.js+++ b/web/js/components/charting/chart-component.js@@ -27,6 +27,114 @@ import {} from 'ol/style';import util from '../../util/util';+// Gets the indices of the tick positions so that they are evenly spaced+function getTickPositions(dataLength) {+ // If dataLength is too small, just show first and last tick+ if (dataLength < 8) return [0, dataLength - 1];++ const numGaps = dataLength < 15 ? 4 : 5;+ const gapsArr = Array(numGaps).fill(Math.floor(dataLength / numGaps));++ // Last gap must be at least 3 to give extra room for end-aligned label+ gapsArr[gapsArr.length - 1] = Math.max(Math.floor(dataLength / 4), 3);++ const gapsTotal = gapsArr.reduce((a, b) => a + b, 0);+ let leftoverGap = (dataLength - 1) - gapsTotal;++ let i = 0;+ // Reduce gaps that are too large due to last gap size+ while (leftoverGap < 0 && i < numGaps - 1) {+ gapsArr[i] -= 1;+ leftoverGap += 1;+ i = (i + 1) % (numGaps - 1);+ }++ i = 0;+ // Distribute extra gaps across existing gaps+ while (leftoverGap > 0 && i < numGaps - 1) {+ gapsArr[i] += 1;+ leftoverGap -= 1;+ i = (i + 1) % (numGaps - 1);+ }++ // Build final array of tick positions based on calculated gaps+ const tickPosArr = [0];+ for (let j = 0; j < gapsArr.length; j += 1) {+ tickPosArr.push(tickPosArr[tickPosArr.length - 1] + gapsArr[j]);+ }+ tickPosArr[tickPosArr.length - 1] = dataLength - 1;++ return tickPosArr;+}+++function CustomXAxisTick(props) {+ const {+ x, y, fill, textAnchor, visibleTicksCount, index, payload, data,+ } = props;+ const tickPositions = getTickPositions(data.length);+ const anchorPos = index === visibleTicksCount - 1 ? 'end' : textAnchor;+ const isLabeled = tickPositions.includes(index);+ if (isLabeled) {+ return (+ <g transform={`translate(${x}, ${y})`}>+ <line x1="0" y1="0" x2="0" y2="-8" stroke={fill} />+ <text x={anchorPos === 'end' ? 10 : 0} y={0} dy={16} textAnchor={anchorPos} fill={fill}>+ {payload.value}+ </text>+ </g>+ );+ }+ return (+ <g transform={`translate(${x}, ${y})`}>+ <line x1="0" y1="-4" x2="0" y2="-8" stroke={fill} />+ </g>+ );+}++function formatToThreeDigits(str) {+ if (parseFloat(str).toFixed(3).split('.')[0].length > 4) {+ return Number(parseFloat(str).toFixed(3)).toPrecision(3);+ }+ return parseFloat(str).toFixed(3);+}++function CustomTooltip({+ active, payload, label, unit,+}) {+ const formattedUnit = unit ? ` (${unit})` : '';+ if (active && payload && payload.length) {+ if (!Number.isNaN(payload[0].value)) {+ return (+ <div className="custom-tooltip">+ <p className="label" style={{ color: 'gray' }}>+ {label}+ </p>+ <p className="label" style={{ color: '#000' }}>+ <span className="custom-data-rect" style={{ backgroundColor: payload[0].color }} />+ {`${payload[0].name}${formattedUnit}: `}+ <b>+ {formatToThreeDigits(payload[0].value)}+ </b>+ </p>+ </div>+ );+ }+ return (+ <div className="custom-tooltip">+ <p className="label" style={{ color: 'gray' }}>+ {label}+ </p>+ <p className="label" style={{ color: '#000' }}>+ No data+ </p>+ </div>+ );+ }++ return null;+}+function ChartComponent (props) {const {liveData,@@ -95,12 +203,7 @@ function ChartComponent (props) {const lineColors = ['#A3905D', '#82CA9D', 'orange', 'pink', 'green', 'red', 'yellow', 'aqua', 'maroon'];const formattedUnit = unit ? ` (${unit})` : '';- function formatToThreeDigits(str) {- if (parseFloat(str).toFixed(3).split('.')[0].length > 4) {- return Number(parseFloat(str).toFixed(3)).toPrecision(3);- }- return parseFloat(str).toFixed(3);- }+/*** Return an array of provided min & max values buffered by 10%@@ -133,103 +236,10 @@ function ChartComponent (props) {return bufferYAxisMinAndMax(lowestMin, highestMax);}- function CustomTooltip({ active, payload, label }) {- if (active && payload && payload.length) {- if (!Number.isNaN(payload[0].value)) {- return (- <div className="custom-tooltip">- <p className="label" style={{ color: 'gray' }}>- {label}- </p>- <p className="label" style={{ color: '#000' }}>- <span className="custom-data-rect" style={{ backgroundColor: payload[0].color }} />- {`${payload[0].name}${formattedUnit}: `}- <b>- {formatToThreeDigits(payload[0].value)}- </b>- </p>- </div>- );- }- return (- <div className="custom-tooltip">- <p className="label" style={{ color: 'gray' }}>- {label}- </p>- <p className="label" style={{ color: '#000' }}>- No data- </p>- </div>- );- }-- return null;- }-- // Gets the indices of the tick positions so that they are evenly spaced- function getTickPositions(dataLength) {- // If dataLength is too small, just show first and last tick- if (dataLength < 8) return [0, dataLength - 1];-- const numGaps = dataLength < 15 ? 4 : 5;- const gapsArr = Array(numGaps).fill(Math.floor(dataLength / numGaps));- // Last gap must be at least 3 to give extra room for end-aligned label- gapsArr[gapsArr.length - 1] = Math.max(Math.floor(dataLength / 4), 3);- const gapsTotal = gapsArr.reduce((a, b) => a + b, 0);- let leftoverGap = (dataLength - 1) - gapsTotal;- let i = 0;- // Reduce gaps that are too large due to last gap size- while (leftoverGap < 0 && i < numGaps - 1) {- gapsArr[i] -= 1;- leftoverGap += 1;- i = (i + 1) % (numGaps - 1);- }-- i = 0;- // Distribute extra gaps across existing gaps- while (leftoverGap > 0 && i < numGaps - 1) {- gapsArr[i] += 1;- leftoverGap -= 1;- i = (i + 1) % (numGaps - 1);- }- // Build final array of tick positions based on calculated gaps- const tickPosArr = [0];- for (let i = 0; i < gapsArr.length; i += 1) {- tickPosArr.push(tickPosArr[tickPosArr.length - 1] + gapsArr[i]);- }- tickPosArr[tickPosArr.length - 1] = dataLength - 1;-- return tickPosArr;- }-- const tickPositions = getTickPositions(data.length);-- function CustomXAxisTick(obj) {- const {- x, y, fill, textAnchor, visibleTicksCount, index, payload,- } = obj;- const anchorPos = index === visibleTicksCount - 1 ? 'end' : textAnchor;- const isLabeled = tickPositions.includes(index);- if (isLabeled) {- return (- <g transform={`translate(${x}, ${y})`}>- <line x1="0" y1="0" x2="0" y2="-8" stroke={fill} />- <text x={anchorPos === 'end' ? 10 : 0} y={0} dy={16} textAnchor={anchorPos} fill={fill}>- {payload.value}- </text>- </g>- );- }- return (- <g transform={`translate(${x}, ${y})`}>- <line x1="0" y1="-4" x2="0" y2="-8" stroke={fill} />- </g>- );- }const yAxisValuesArr = getYAxisValues(data);@@ -415,10 +425,10 @@ function ChartComponent (props) {bottom: 10,}}>- <Tooltip content={CustomTooltip} />+ <Tooltip content={<CustomTooltip unit={unit} />} />{' '}{getLineChart(data)}- <XAxis dataKey="name" stroke="#a6a5a6" interval={0} tick={<CustomXAxisTick />} tickLine={false} />+ <XAxis dataKey="name" stroke="#a6a5a6" interval={0} tick={<CustomXAxisTick data={data} />} tickLine={false} /><YAxistype="number"stroke="#a6a5a6"@@ -574,6 +584,24 @@ ChartComponent.propTypes = {overviewMapLayerDef: PropTypes.object,};+CustomXAxisTick.propTypes = {+ x: PropTypes.number,+ y: PropTypes.number,+ fill: PropTypes.string,+ textAnchor: PropTypes.string,+ visibleTicksCount: PropTypes.number,+ index: PropTypes.number,+ payload: PropTypes.object,+ data: PropTypes.array,+};++CustomTooltip.propTypes = {+ active: PropTypes.bool,+ payload: PropTypes.array,+ label: PropTypes.string,+ unit: PropTypes.string,+};+export default connect(mapStateToProps,)(ChartComponent);diff --git a/web/js/components/charting/charting-date-selector.js b/web/js/components/charting/charting-date-selector.jsindex 00bfe0214..7dbc6b8b3 100644--- a/web/js/components/charting/charting-date-selector.js+++ b/web/js/components/charting/charting-date-selector.js@@ -23,7 +23,7 @@ function ChartingDateSelector (props) {const validStartDate = startdate < layerStartDate ? layerStartDate : startdate;const validEndDate = endDate > layerEndDate ? layerEndDate : endDate;- function onDateChange([newStartDate, newEndDate]) {+ const onDateChange = ([newStartDate, newEndDate]) => {if (newStartDate !== timeSpanStartDate) {onUpdateStartDate(newStartDate);}@@ -31,13 +31,13 @@ function ChartingDateSelector (props) {if (newEndDate !== timeSpanEndDate) {onUpdateEndDate(newEndDate);}- }+ };- function onSingleDateChange(newStartDate) {+ const onSingleDateChange = (newStartDate) => {if (newStartDate !== timeSpanStartDate) {onUpdateStartDate(newStartDate);}- }+ };return (<div className="charting-date-container wv-date-range-selector">diff --git a/web/js/components/feature-alert/alert.js b/web/js/components/feature-alert/alert.jsindex 94e5bbe24..76b505f04 100644--- a/web/js/components/feature-alert/alert.js+++ b/web/js/components/feature-alert/alert.js@@ -13,11 +13,6 @@ class FeaturedAlert extends React.Component {};}- dismissAlert() {- // safeLocalStorage.setItem('<alert-name-goes-here>', true);- this.setState({ showAlert: false });- }-render() {// const { showAlert } = this.state;return '';diff --git a/web/js/components/image-download/image-download-panel.js b/web/js/components/image-download/image-download-panel.jsindex 5f9cd03c1..456b0c259 100644--- a/web/js/components/image-download/image-download-panel.js+++ b/web/js/components/image-download/image-download-panel.js@@ -129,7 +129,7 @@ function ImageDownloadPanel(props) {onPanelChange(type, valueIn);};- const _renderFileTypeSelect = () => {+ const renderFileTypeSelect = () => {if (fileTypeOptions) {return (<div className="wv-image-header">@@ -146,7 +146,7 @@ function ImageDownloadPanel(props) {}};- const _renderWorldfileSelect = () => {+ const renderWorldfileSelect = () => {if (worldFileOptions) {const value = currIsWorldfile ? 1 : 0;return (@@ -184,8 +184,8 @@ function ImageDownloadPanel(props) {const dimensions = getDimensions(projection.id, lonlats, currResolution);const { height } = dimensions;const { width } = dimensions;- const filetypeSelect = _renderFileTypeSelect();- const worldfileSelect = _renderWorldfileSelect();+ const filetypeSelect = renderFileTypeSelect();+ const worldfileSelect = renderWorldfileSelect();const layerList = getLayers();return (diff --git a/web/js/components/layer/product-picker/browse/measurement-layer-row.js b/web/js/components/layer/product-picker/browse/measurement-layer-row.jsindex dbf5af78b..1724f60ed 100644--- a/web/js/components/layer/product-picker/browse/measurement-layer-row.js+++ b/web/js/components/layer/product-picker/browse/measurement-layer-row.js@@ -37,13 +37,13 @@ function MeasurementLayerRow (props) {const itemElementId = `checkbox-case-${layer.id.split('.').join('-')}`;const checkboxId = `${layer.id.split('.').join('-')}-checkbox`;- function onCheck() {+ const onCheck = () => {if (isEnabled) {removeLayer(layer.id);} else {addLayer(layer.id);}- }+ };return (<ListGroupItem@@ -81,7 +81,7 @@ function MeasurementLayerRow (props) {</MonospaceDate></div>)}- {layerNotices && (<div dangerouslySetInnerHTML={{ __html: layerNotices }} />)}+ {layerNotices && (<div>{{ __html: layerNotices }}</div>)}</UncontrolledTooltip>)}</Checkbox>diff --git a/web/js/components/layer/product-picker/header.js b/web/js/components/layer/product-picker/header.jsindex c0a363b4f..b6508109f 100644--- a/web/js/components/layer/product-picker/header.js+++ b/web/js/components/layer/product-picker/header.js@@ -36,7 +36,7 @@ class ProductPickerHeader extends React.Component {componentDidMount() {const { isMobile } = this.props;setTimeout(() => {- if (this._input && !isMobile) this._input.focus();+ if (this.input && !isMobile) this.input.focus();}, 500);}@@ -212,7 +212,7 @@ class ProductPickerHeader extends React.Component {placeholder="Search"type="search"// eslint-disable-next-line no-return-assign- innerRef={(c) => (this._input = c)}+ innerRef={(c) => (this.input = c)}/></InputGroup>diff --git a/web/js/components/layer/settings/layer-settings.js b/web/js/components/layer/settings/layer-settings.jsindex 5ec45c5fc..c52f1512d 100644--- a/web/js/components/layer/settings/layer-settings.js+++ b/web/js/components/layer/settings/layer-settings.js@@ -10,7 +10,6 @@ import Opacity from './opacity';import Palette from './palette';import BandSelection from './band-selection/band-selection-parent-info-menu';import AssociatedLayers from './associated-layers-toggle';-import VectorStyle from './vector-style';import PaletteThreshold from './palette-threshold';import GranuleLayerDateList from './granule-date-list';import GranuleCountSlider from './granule-count-slider';@@ -272,34 +271,6 @@ class LayerSettings extends React.Component {);}- /**- * Render Opacity, threshold, and custom palette options- */- renderVectorStyles() {- const {- setStyle,- clearStyle,- groupName,- layer,- vectorStyles,- } = this.props;- let customStyle;- if (layer.custom && layer.custom[0]) {- [customStyle] = layer.custom;- }- return (- <VectorStyle- setStyle={setStyle}- clearStyle={clearStyle}- activeVectorStyle={customStyle || layer.id}- layer={layer}- index={0}- groupName={groupName}- vectorStyles={vectorStyles}- />- );- }-/*** Render Granule count slider and granule date list settings (if granule layer)*/diff --git a/web/js/components/location-search/location-search.js b/web/js/components/location-search/location-search.jsindex d8b9ce40b..41e3d562b 100644--- a/web/js/components/location-search/location-search.js+++ b/web/js/components/location-search/location-search.js@@ -17,7 +17,7 @@ class LocationSearch extends Component {}componentDidUpdate(prevProps) {- const { isExpanded, isMobile, toggleShowLocationSearch } = this.props;+ const { isExpanded, isMobile } = this.props;if (isExpanded && prevProps.isMobile !== isMobile) {toggleShowLocationSearch();}@@ -58,9 +58,9 @@ class LocationSearch extends Component {const shouldShowComponent = isMobile || (isExpanded && !shouldCollapseFromOtherUI);return (- <>+ <div>{shouldShowComponent && this.renderSearchComponent()}- </>+ </div>);}}@@ -108,7 +108,6 @@ LocationSearch.propTypes = {isFeatureEnabled: PropTypes.bool,isMobile: PropTypes.bool,shouldCollapseFromOtherUI: PropTypes.bool,- toggleShowLocationSearch: PropTypes.func,};export default connect(diff --git a/web/js/components/selected-date.js b/web/js/components/selected-date.jsindex 7f4bf1eff..28994cc5d 100644--- a/web/js/components/selected-date.js+++ b/web/js/components/selected-date.js@@ -6,7 +6,7 @@ import { formatDisplayDate } from '../modules/date/util';// A simple component to re-use anywhere we want to display the selected datefunction SelectedDate({ selectedDate }) {- return <>{selectedDate}</>;+ return <div>{selectedDate}</div>;}SelectedDate.propTypes = {diff --git a/web/js/components/sidebar/charting-mode-options.js b/web/js/components/sidebar/charting-mode-options.jsindex c2c4c93c7..9a7c133b8 100644--- a/web/js/components/sidebar/charting-mode-options.js+++ b/web/js/components/sidebar/charting-mode-options.js@@ -538,7 +538,7 @@ function ChartingModeOptions(props) {}}, [isChartOpen, renderedPalettes]);- function onDateIconClick() {+ const onDateIconClick = () => {const layerInfo = getActiveChartingLayer();const layerStartDate = layerInfo.startDate ? new Date(layerInfo.startDate) : date.selected;const layerEndDate = layerInfo.endDate ? new Date(layerInfo.endDate) : date.appNow;@@ -548,7 +548,7 @@ function ChartingModeOptions(props) {};document.body.style.setProperty('--charting-date-modal-offset', `${sidebarHeight - 50}px`);openChartingDateModal(dateModalInput, timeSpanSelection);- }+ };useEffect(() => {const isOpen = modalId === 'CHARTING-DATE-MODAL' && isModalOpen;@@ -609,7 +609,7 @@ function ChartingModeOptions(props) {** @returns {null}*/- function onBoundaryUpdate(boundaries) {+ const onBoundaryUpdate = (boundaries) => {const {x, y, width, height,} = boundaries;@@ -631,9 +631,9 @@ function ChartingModeOptions(props) {const inRightWing = bottomLeft[0] > maxExtent[2] && topRight[0] > maxExtent[2];setIsWithinWings(inLeftWing || inRightWing);}- }+ };- function onLatLongChange(coordsArray) {+ const onLatLongChange = (coordsArray) => {const bottomLeft = [coordsArray[0], coordsArray[1]];const topRight = [coordsArray[2], coordsArray[3]];const bottomLeftPixel = olMap.getPixelFromCoordinate(bottomLeft);@@ -654,9 +654,9 @@ function ChartingModeOptions(props) {const inRightWing = bottomLeft[0] > maxExtent[2] && topRight[0] > maxExtent[2];setIsWithinWings(inLeftWing || inRightWing);}- }+ };- function toggleMapView() {+ const toggleMapView = () => {if (!mapViewChecked) {onLatLongChange(viewExtent);} else {@@ -669,7 +669,7 @@ function ChartingModeOptions(props) {onBoundaryUpdate(boundaries);}setMapViewChecked(!mapViewChecked);- }+ };const spinnerStyle = {diff --git a/web/js/components/sidebar/paletteLegend.js b/web/js/components/sidebar/paletteLegend.jsindex 9b2cb4dbb..c1f2de172 100644--- a/web/js/components/sidebar/paletteLegend.js+++ b/web/js/components/sidebar/paletteLegend.js@@ -471,7 +471,6 @@ class PaletteLegend extends React.Component {? `active-legend wv-palettes-panel${customClass}`: `wv-palettes-panel${customClass}`}- datalayer={layer.id}id={`${paletteId}_panel`}>{this.renderPaletteLegends()}diff --git a/web/js/components/timeline/custom-interval-selector/interval-select.js b/web/js/components/timeline/custom-interval-selector/interval-select.jsindex 965b1a5d7..3d3e6fa84 100644--- a/web/js/components/timeline/custom-interval-selector/interval-select.js+++ b/web/js/components/timeline/custom-interval-selector/interval-select.js@@ -40,7 +40,7 @@ function IntervalSelect(props) {};return (- <>+ <div>{isMobile ? (<div className="mobile-timescale-dropdown"><Dropdown isOpen={dropdownOpen} toggle={toggle}>@@ -104,7 +104,7 @@ function IntervalSelect(props) {</select></form>)}- </>+ </div>);}diff --git a/web/js/components/timeline/timeline-draggers/dragger-container.js b/web/js/components/timeline/timeline-draggers/dragger-container.jsindex 9141df900..1bbed2bb4 100644--- a/web/js/components/timeline/timeline-draggers/dragger-container.js+++ b/web/js/components/timeline/timeline-draggers/dragger-container.js@@ -279,15 +279,6 @@ class DraggerContainer extends PureComponent {draggerWidth,} = this.state;- const sharedProps = {- axisWidth,- toggleShowDraggerTime,- transformX,- isCompareModeActive,- handleDragDragger: this.handleDragDragger,- selectDragger: this.selectDragger,- };-const selectedDraggerClipAClipWidth = Math.max(draggerWidth, draggerWidth + draggerPosition);const selectedDraggerClipBClipWidth = Math.max(draggerWidth, draggerWidth + draggerPositionB);return (@@ -307,7 +298,12 @@ class DraggerContainer extends PureComponent {{isCompareModeActive? (<Dragger- {...sharedProps}+ axisWidth={axisWidth}+ toggleShowDraggerTime={toggleShowDraggerTime}+ transformX={transformX}+ isCompareModeActive={isCompareModeActive}+ handleDragDragger={this.handleDragDragger}+ selectDragger={this.selectDragger}disableddraggerName="selected"draggerPosition={draggerPosition}@@ -316,7 +312,12 @@ class DraggerContainer extends PureComponent {): null}<Dragger- {...sharedProps}+ axisWidth={axisWidth}+ toggleShowDraggerTime={toggleShowDraggerTime}+ transformX={transformX}+ isCompareModeActive={isCompareModeActive}+ handleDragDragger={this.handleDragDragger}+ selectDragger={this.selectDragger}disabled={false}draggerName="selectedB"draggerPosition={draggerPositionB}@@ -339,7 +340,12 @@ class DraggerContainer extends PureComponent {{isCompareModeActive? (<Dragger- {...sharedProps}+ axisWidth={axisWidth}+ toggleShowDraggerTime={toggleShowDraggerTime}+ transformX={transformX}+ isCompareModeActive={isCompareModeActive}+ handleDragDragger={this.handleDragDragger}+ selectDragger={this.selectDragger}disableddraggerName="selectedB"draggerPosition={draggerPositionB}@@ -348,7 +354,12 @@ class DraggerContainer extends PureComponent {): null}<Dragger- {...sharedProps}+ axisWidth={axisWidth}+ toggleShowDraggerTime={toggleShowDraggerTime}+ transformX={transformX}+ isCompareModeActive={isCompareModeActive}+ handleDragDragger={this.handleDragDragger}+ selectDragger={this.selectDragger}disabled={false}draggerName="selected"draggerPosition={draggerPosition}@@ -371,7 +382,6 @@ DraggerContainer.propTypes = {draggerVisible: PropTypes.bool,draggerVisibleB: PropTypes.bool,frontDate: PropTypes.string,- isAnimationPlaying: PropTypes.bool,isCompareModeActive: PropTypes.bool,isDraggerDragging: PropTypes.bool,onChangeSelectedDragger: PropTypes.func,diff --git a/web/js/components/tour/joyride-wrapper.js b/web/js/components/tour/joyride-wrapper.jsindex 600756fd1..c2c6577fe 100644--- a/web/js/components/tour/joyride-wrapper.js+++ b/web/js/components/tour/joyride-wrapper.js@@ -151,7 +151,7 @@ export default function JoyrideWrapper ({incrementKey();}- function joyrideStateCallback(data) {+ const joyrideStateCallback = (data) => {joyrideProps = data;const {action, index, type, status,@@ -168,7 +168,7 @@ export default function JoyrideWrapper ({setStepIndex(0);setRun(false);}- }+ };/*** Forcing a re-render on a target resize (by calling incrementKey())diff --git a/web/js/components/tour/modal-tour-complete.js b/web/js/components/tour/modal-tour-complete.jsindex 800d1dd9c..adb467f0e 100644--- a/web/js/components/tour/modal-tour-complete.js+++ b/web/js/components/tour/modal-tour-complete.js@@ -24,9 +24,8 @@ function ModalComplete(props) {<><p>Read more about this story at the links below:</p><ul>- {readMoreLinks.map((linkId, i) => (- /* eslint react/no-array-index-key: 1 */- <li key={i} index={i}>+ {readMoreLinks.map((linkId) => (+ <li key={linkId}><a href={linkId.link} target="_blank" rel="noopener noreferrer">{linkId.title}</a>diff --git a/web/js/components/util/alert.js b/web/js/components/util/alert.jsindex 22f4403cf..4e20304f4 100644--- a/web/js/components/util/alert.js+++ b/web/js/components/util/alert.js@@ -24,10 +24,6 @@ export default class AlertUtil extends React.Component {};}- componentDidMount() {- this.mounted = true;- }-componentWillUnmount() {if (this.timeout) {clearTimeout(this.timeout);diff --git a/web/js/containers/modal.js b/web/js/containers/modal.jsindex ec5347be3..dcc57c6af 100644--- a/web/js/containers/modal.js+++ b/web/js/containers/modal.js@@ -120,6 +120,54 @@ class ModalContainer extends Component {);}+ handleCreateChildren = (children) => {+ const {+ customProps,+ id,+ isCustom,+ screenHeight,+ screenWidth,+ } = this.props;+ const { width, height } = this.state;+ const style = this.getStyle();+ const newProps = isCustom && id ? update(this.props, { $merge: customProps }) : this.props;+ const {+ dragHandle,+ isDraggable,+ isResizable,+ stayOnscreen,+ } = newProps;+ const bounds = stayOnscreen ? {+ left: -(screenWidth / 2 - width / 2),+ right: screenWidth / 2 - width / 2,+ top: -style.top,+ bottom: screenHeight - height - style.top - 5,+ } : '';+ <Draggable+ handle={dragHandle}+ disabled={!isDraggable}+ bounds={bounds}+ >+ {isResizable+ ? (+ <Resizable+ className="resize-box"+ resizeHandles={['se']}+ width={width || newProps.width}+ height={height || newProps.height}+ minConstraints={[250, 250]}+ maxConstraints={[495, screenHeight]}+ handleSize={[8, 8]}+ onResize={this.onResize}+ draggableOpts={{ disabled: !isResizable }}+ >+ {children}+ </Resizable>+ )+ : children}+ </Draggable>;+ };+render() {const {customProps,@@ -130,9 +178,9 @@ class ModalContainer extends Component {isOpen,isTemplateModal,screenHeight,- screenWidth,} = this.props;const { width, height } = this.state;+const newProps = isCustom && id ? update(this.props, { $merge: customProps }) : this.props;const {autoFocus,@@ -145,7 +193,6 @@ class ModalContainer extends Component {clickableBehindModal,CompletelyCustomModal,desktopOnly,- dragHandle,headerComponent,headerText,isDraggable,@@ -158,7 +205,6 @@ class ModalContainer extends Component {timeout,type,wrapClassName,- stayOnscreen,} = newProps;const isRestrictedDisplay = (isMobile && desktopOnly)@@ -178,41 +224,12 @@ class ModalContainer extends Component {×</button>);- const bounds = stayOnscreen ? {- left: -(screenWidth / 2 - width / 2),- right: screenWidth / 2 - width / 2,- top: -style.top,- bottom: screenHeight - height - style.top - 5,- } : '';+return (<ErrorBoundary><InteractionWrapcondition={isDraggable || isResizable}- wrapper={(children) => (- <Draggable- handle={dragHandle}- disabled={!isDraggable}- bounds={bounds}- >- {isResizable- ? (- <Resizable- className="resize-box"- resizeHandles={['se']}- width={width || newProps.width}- height={height || newProps.height}- minConstraints={[250, 250]}- maxConstraints={[495, screenHeight]}- handleSize={[8, 8]}- onResize={this.onResize}- draggableOpts={{ disabled: !isResizable }}- >- {children}- </Resizable>- )- : children}- </Draggable>- )}+ wrapper={this.handleCreateChildren}><ModalisOpen={isOpen}@@ -233,6 +250,7 @@ class ModalContainer extends Component {key={`custom_${lowerCaseId}`}modalHeight={height || newProps.height}modalWidth={width || newProps.width}+ // eslint-disable-next-line react/jsx-props-no-spreading{...customProps}toggleWithClose={toggleFunction}/>@@ -243,14 +261,15 @@ class ModalContainer extends Component {disabled={allowOuterClick}>{(headerComponent || headerText) && (- <ModalHeader toggle={toggleFunction} close={closeBtn}>- {headerComponent ? <headerComponent /> : headerText || ''}- </ModalHeader>+ <ModalHeader toggle={toggleFunction} close={closeBtn}>+ {headerComponent ? <headerComponent /> : headerText || ''}+ </ModalHeader>)}<ModalBody>{bodyHeader && <h3>{bodyHeader}</h3>}{BodyComponent ? (<BodyComponent+ // eslint-disable-next-line react/jsx-props-no-spreading{...bodyComponentProps}parentId={id}screenHeight={screenHeight}@@ -327,13 +346,10 @@ ModalContainer.propTypes = {customProps: PropTypes.object,id: PropTypes.string,isCustom: PropTypes.bool,- isDraggable: PropTypes.bool,isEmbedModeActive: PropTypes.bool,isMobile: PropTypes.bool,isOpen: PropTypes.bool,isTemplateModal: PropTypes.bool,- orientation: PropTypes.string,screenHeight: PropTypes.number,screenWidth: PropTypes.number,- stayOnscreen: PropTypes.bool,};diff --git a/web/js/containers/sidebar/sidebar.js b/web/js/containers/sidebar/sidebar.jsindex 82bfcb66e..7c7f88ceb 100644--- a/web/js/containers/sidebar/sidebar.js+++ b/web/js/containers/sidebar/sidebar.js@@ -371,6 +371,7 @@ class Sidebar extends React.Component {id="products-holder"className="products-holder-case"style={productsHolderStyle}+ // eslint-disable-next-line react/no-unused-class-component-methodsref={(el) => { this.sidebarElement = el; }}><NavCase@@ -388,6 +389,7 @@ class Sidebar extends React.Component {<TabPane tabId="layers">{this.getProductsToRender(activeTab, isCompareMode, isChartMode)}<AddLayersContent+ // eslint-disable-next-line react/no-unused-class-component-methodsref={(el) => { this.addLayersElement = el; }}isActive={activeTab === 'layers'}compareState={activeString}@@ -415,6 +417,7 @@ class Sidebar extends React.Component {{!isKioskModeActive && (<FooterContent+ // eslint-disable-next-line react/no-unused-class-component-methodsref={(el) => { this.footerElement = el; }}tabTypes={tabTypes}activeTab={activeTab}diff --git a/web/js/containers/timeline/timeline.js b/web/js/containers/timeline/timeline.jsindex 0119fcc8a..da9ba7212 100644--- a/web/js/containers/timeline/timeline.js+++ b/web/js/containers/timeline/timeline.js@@ -658,16 +658,6 @@ class Timeline extends React.Component {}};- /**- * @desc show/hide custom interval modal- * @param {Boolean} isOpen- * @returns {void}- */- toggleCustomIntervalModal = (isOpen) => {- const { toggleCustomModal } = this.props;- toggleCustomModal(isOpen, customModalType.TIMELINE);- };-/*** @desc Change the timescale parent state* @param {Number} timeScaleNumber@@ -1073,18 +1063,6 @@ class Timeline extends React.Component {};};- getStringFromDate = (dateObj, hasSubdailyLayers) => {- const months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];- const day = dateObj.getDate().toString().padStart(2, '0');- const month = months[dateObj.getMonth()];- const year = dateObj.getFullYear().toString();- const hours = dateObj.getUTCHours();- const minutes = dateObj.getUTCMinutes();- const timeString = hasSubdailyLayers ? ` ${`0${hours}`.slice(-2)}:${`0${minutes}`.slice(-2)}` : '';-- return `${year} ${month} ${day}${timeString}`;- };-renderDateChangeArrows = () => {const {isMobile, leftArrowDisabled, rightArrowDisabled, nowButtonDisabled,diff --git a/web/js/map/natural-events/event-markers.js b/web/js/map/natural-events/event-markers.jsindex 65f473996..c7891ea47 100644--- a/web/js/map/natural-events/event-markers.js+++ b/web/js/map/natural-events/event-markers.js@@ -203,7 +203,7 @@ class EventMarkers extends React.Component {const category = event.categories[0];let willSelect = true;let moveCount = 0;- const pinEl = marker.pin.element_ || marker.pin.element;+ const pinEl = marker.pin.element;// Use passiveSupport detect in ui.// Passive applied if supported, capture will be false either way.const options = mapUi.supportsPassive ? { passive: true } : false;diff --git a/web/js/mapUI/components/kiosk/kiosk-animations/kiosk-animations.js b/web/js/mapUI/components/kiosk/kiosk-animations/kiosk-animations.jsindex d8fd679da..10218279a 100644--- a/web/js/mapUI/components/kiosk/kiosk-animations/kiosk-animations.js+++ b/web/js/mapUI/components/kiosk/kiosk-animations/kiosk-animations.js@@ -74,6 +74,7 @@ function KioskAnimations({ ui }) {// if subdaily animation check that date moved back one day// otherwise check if animation should playconst checkAnimationSettings = () => {+ // eslint-disable-next-line no-underscore-dangleif (!ui.selected.frameState_) return;if (eic === 'sa' && !subdailyAnimationDateUpdated) {const prevDayDate = new Date(selectedDate);diff --git a/web/js/mapUI/components/kiosk/tile-measurement/tile-measurement.js b/web/js/mapUI/components/kiosk/tile-measurement/tile-measurement.jsindex f648406cf..efb1a3be9 100644--- a/web/js/mapUI/components/kiosk/tile-measurement/tile-measurement.js+++ b/web/js/mapUI/components/kiosk/tile-measurement/tile-measurement.js@@ -137,7 +137,7 @@ function TileMeasurement({ ui }) {}};- const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));+ const delay = (ms) => new Promise((resolve) => { setTimeout(resolve, ms); });const verifyTilesAndHandleErrors = async () => {console.log('Verifying tiles on map...');diff --git a/web/js/mapUI/components/kiosk/tile-measurement/utils/verify-map-tiles.js b/web/js/mapUI/components/kiosk/tile-measurement/utils/verify-map-tiles.jsindex 1165ecfa2..6277a190b 100644--- a/web/js/mapUI/components/kiosk/tile-measurement/utils/verify-map-tiles.js+++ b/web/js/mapUI/components/kiosk/tile-measurement/utils/verify-map-tiles.js@@ -68,6 +68,7 @@ const processTileLayer = (layer, map, view) => {const tileState = tile.getState();expectedTileCount += 1;if (tileState === 2) {+ // eslint-disable-next-line no-underscore-dangleconst image = tile.image_;const isTileImageValid = checkTileImage(image);if (!isTileImageValid) {diff --git a/web/js/mapUI/components/update-opacity/updateOpacity.js b/web/js/mapUI/components/update-opacity/updateOpacity.jsindex a815b7fd3..7382d4324 100644--- a/web/js/mapUI/components/update-opacity/updateOpacity.js+++ b/web/js/mapUI/components/update-opacity/updateOpacity.js@@ -25,6 +25,7 @@ function UpdateOpacity(props) {const layers = ui.selected.getLayers().getArray();lodashEach(Object.keys(layers), (index) => {const layer = layers[index];+ // eslint-disable-next-line no-underscore-dangleif (layer.className_ === 'ol-layer') {if (compare && isCompareActive) {const layerGroup = layer.getLayers().getArray();diff --git a/web/js/mapUI/mapUI.js b/web/js/mapUI/mapUI.jsindex 4a1491e4b..0bd0e7364 100644--- a/web/js/mapUI/mapUI.js+++ b/web/js/mapUI/mapUI.js@@ -299,7 +299,7 @@ function MapUI(props) {};};- async function preloadNextTiles(date, compareString) {+ const preloadNextTiles = async (date, compareString) => {const map = { ui };const state = {proj, embed, layers, palettes, vectorStyles, compare, map, ui,@@ -321,14 +321,14 @@ function MapUI(props) {if (!date && !arrowDown) {preloadNextTiles(subsequentDate, useActiveString);}- }+ };- function preloadForCompareMode() {+ const preloadForCompareMode = () => {preloadNextTiles(selectedDate, 'active');if (compare.active) {preloadNextTiles(selectedDateB, 'activeB');}- }+ };// Initial hook that initiates the map after it has been created in CreateMap.jsuseEffect(() => {diff --git a/web/js/modules/link/constants.js b/web/js/modules/link/constants.jsindex dde9f22be..77a96e025 100644--- a/web/js/modules/link/constants.js+++ b/web/js/modules/link/constants.js@@ -21,15 +21,15 @@ export const MOCK_SHORT_LINK_RESPONSE = {export const ENCODING_EXCEPTIONS = [{- match: new RegExp('%2C', 'g'),+ match: /%2C/g,replace: ',',},{- match: new RegExp('%3B', 'g'),+ match: /%3B/g,replace: ';',},{- match: new RegExp('%3D', 'g'),+ match: /%3D/g,replace: '=',},];diff --git a/web/js/ol/lookupimagetile.js b/web/js/ol/lookupimagetile.jsindex e7a3cd41a..436bc412a 100644--- a/web/js/ol/lookupimagetile.js+++ b/web/js/ol/lookupimagetile.js@@ -1,3 +1,4 @@+/* eslint-disable no-underscore-dangle *//* eslint-disable func-names */import OlImageTile from 'ol/ImageTile';import OlTileState from 'ol/TileState';diff --git a/web/js/util/util.js b/web/js/util/util.jsindex 1b95ceb61..1667c2ceb 100644--- a/web/js/util/util.js+++ b/web/js/util/util.js@@ -481,12 +481,14 @@ export default (function(self) {self.fetch = function(url, mimeType) {return new Promise(- (resolve, reject) => fetch(url)- .then((response) => (mimeType === 'application/json'- ? response.json()- : response.text()))- .then(resolve)- .catch(reject),+ (resolve, reject) => {+ fetch(url)+ .then((response) => (mimeType === 'application/json'+ ? response.json()+ : response.text()))+ .then(resolve)+ .catch(reject);+ },);};