diff --git a/assets/.eslintrc b/assets/.eslintrc index 093d45a337a4b3fa88d0d30a82d3db0f7529807c..b5a42757e9a1a08eb9a06f0544d38506cc6c2cc3 100644 --- a/assets/.eslintrc +++ b/assets/.eslintrc @@ -16,6 +16,7 @@ "comma-dangle": [2,"never"], "comma-spacing": ["error", { "before": false, "after": true }], "curly": "error", + "keyword-spacing": ["error", {"before": true}], "linebreak-style": ["error", "unix"], "no-console": "off", "no-extra-parens": [2,"all"], diff --git a/assets/package.json b/assets/package.json index 2facfc7edb44092e2d90f5cefe46befef49e3eaa..5255916eb2d2c4a08af77831ee65232aef6c4627 100644 --- a/assets/package.json +++ b/assets/package.json @@ -22,7 +22,7 @@ "hash-assets": "gulp --gulpfile ./gulpfile.js revall", "lint": "run-p lint:*", "lint:cs": "stylelint src/styles/**/*.scss", - "lint:js": "eslint src/scripts", + "lint:js": "eslint --fix src/scripts", "serve:python": "../wdfn-server/env/bin/python ../wdfn-server/run.py", "start": "run-p watch serve:python", "watch": "run-p watch:*", diff --git a/assets/src/scripts/d3-rendering/legend.js b/assets/src/scripts/d3-rendering/legend.js index de4e9032a8bd57f8e8bc368be71552b794fe0525..1065fc979d71dbe5936de932db862f2d5ae7295e 100644 --- a/assets/src/scripts/d3-rendering/legend.js +++ b/assets/src/scripts/d3-rendering/legend.js @@ -47,7 +47,7 @@ export const drawSimpleLegend = function(div, {legendMarkerRows, layout}) { try { const markerGroupBBox = markerGroup.node().getBBox(); return markerGroupBBox.x + markerGroupBBox.width + MARKER_GROUP_X_OFFSET; - } catch(error) { + } catch (error) { // See above explanation return lastXPosition; } @@ -95,7 +95,7 @@ export const drawSimpleLegend = function(div, {legendMarkerRows, layout}) { let bBox; try { bBox = legend.node().getBBox(); - } catch(error) { + } catch (error) { return; } svg.attr('viewBox', `0 0 ${layout.width} ${bBox.height + 10}`); diff --git a/assets/src/scripts/d3-rendering/markers.js b/assets/src/scripts/d3-rendering/markers.js index 1942c81559f97591b5705981fde86883cd56ba7a..277eea1d3cf6c71e87027b3747eaf76e6497722f 100644 --- a/assets/src/scripts/d3-rendering/markers.js +++ b/assets/src/scripts/d3-rendering/markers.js @@ -8,7 +8,7 @@ const markerText = function(group, y, text) { let groupBBox; try { groupBBox = group.node().getBBox(); - } catch(error) { + } catch (error) { // Set defaults groupBBox = { x: 0, diff --git a/assets/src/scripts/monitoring-location/components/daily-value-hydrograph/graph-brush.test.js b/assets/src/scripts/monitoring-location/components/daily-value-hydrograph/graph-brush.test.js index b2f4ef678d47639509e95537b50f95e23aab823d..147e6598adf4e6d77ff26a4c46ae46a42a871865 100644 --- a/assets/src/scripts/monitoring-location/components/daily-value-hydrograph/graph-brush.test.js +++ b/assets/src/scripts/monitoring-location/components/daily-value-hydrograph/graph-brush.test.js @@ -2,7 +2,7 @@ import {select} from 'd3-selection'; import * as utils from 'ui/utils'; -import{configureStore} from 'ml/store'; +import {configureStore} from 'ml/store'; import {drawGraphBrush} from './graph-brush'; diff --git a/assets/src/scripts/monitoring-location/components/hydrograph/graph-brush.test.js b/assets/src/scripts/monitoring-location/components/hydrograph/graph-brush.test.js index 873b8509ea2655ce6c21457afc7a598a6b7aeea0..5f1c7a6721baf93648ad04cefe38c28acd584070 100644 --- a/assets/src/scripts/monitoring-location/components/hydrograph/graph-brush.test.js +++ b/assets/src/scripts/monitoring-location/components/hydrograph/graph-brush.test.js @@ -2,7 +2,7 @@ import {select} from 'd3-selection'; import * as utils from 'ui/utils'; -import{configureStore} from 'ml/store'; +import {configureStore} from 'ml/store'; import {initializeGraphBrush, drawGraphBrush} from './graph-brush'; import {TEST_CURRENT_TIME_RANGE, TEST_PRIMARY_IV_DATA, TEST_GW_LEVELS} from './mock-hydrograph-state'; diff --git a/assets/src/scripts/monitoring-location/components/hydrograph/method-picker.js b/assets/src/scripts/monitoring-location/components/hydrograph/method-picker.js index 3cfcb930d5ff0c2d55bfafc58b0135260931cb2f..9cfb1e125d26303793e122dd64e12ccd4a99484d 100644 --- a/assets/src/scripts/monitoring-location/components/hydrograph/method-picker.js +++ b/assets/src/scripts/monitoring-location/components/hydrograph/method-picker.js @@ -44,7 +44,7 @@ export const drawMethodPicker = function(container, sortedIVMethods, store) { 'location and describe sampling details used to distinguish time-series of the same type--examples ' + 'include variations in physical location and sensor type.'); - if(hasMethodsWithNoPointsInTimeRange) { + if (hasMethodsWithNoPointsInTimeRange) { pickerContainer.append('span') .attr('id', 'no-data-points-note') .text(' note - some methods/sub-locations are disabled, because there are no data points for these in ' + diff --git a/assets/src/scripts/monitoring-location/components/hydrograph/tooltip.js b/assets/src/scripts/monitoring-location/components/hydrograph/tooltip.js index 9a0e3cd3ba75fe8978a932e3c8c3e2e1bc1c8ed9..a6398481d9b76f70ec6ce9b9bfb7e250b5b9ae75 100644 --- a/assets/src/scripts/monitoring-location/components/hydrograph/tooltip.js +++ b/assets/src/scripts/monitoring-location/components/hydrograph/tooltip.js @@ -66,7 +66,7 @@ const createTooltipTextGroup = function(elem, { if (currentPoint) { tooltipTextData.push(getIVDataTooltipTextInfo(currentPoint, 'primary', unitCode)); } - if(comparePoint) { + if (comparePoint) { tooltipTextData.push(getIVDataTooltipTextInfo(comparePoint, 'compare', unitCode)); } if (gwLevelPoint) { diff --git a/assets/src/scripts/monitoring-location/components/map/legend.js b/assets/src/scripts/monitoring-location/components/map/legend.js index 8c26a91bab1758bf367fbda8ce14dc536c9ee7b4..f69cc5ea58428c22166267d88a4a35f8eacef429 100644 --- a/assets/src/scripts/monitoring-location/components/map/legend.js +++ b/assets/src/scripts/monitoring-location/components/map/legend.js @@ -26,7 +26,7 @@ const fetchLayerLegend = async function(layer, defaultName) { console.error(`Received bad status, ${response.status} at ${url}`); return []; } - } catch(error) { + } catch (error) { console.error(`Failed fetch for ${url}`); return []; } diff --git a/assets/src/scripts/monitoring-location/components/network-list.js b/assets/src/scripts/monitoring-location/components/network-list.js index 0f6fd9753ca1c0ad3342d437d458cd5de8f8f44b..6fe5f3bde6043e032dff53fbd5c694ff2d1bcf4c 100644 --- a/assets/src/scripts/monitoring-location/components/network-list.js +++ b/assets/src/scripts/monitoring-location/components/network-list.js @@ -34,7 +34,7 @@ const addNetworkRows = function(node, {hasData, networkList}) { .text(network.title); }); - } else{ + } else { node.html('<p>This site is not in any networks</p>'); } }; diff --git a/assets/src/scripts/monitoring-location/parameter-code-utils.js b/assets/src/scripts/monitoring-location/parameter-code-utils.js index 849ae1ab24facb019f792ec47306948dc40806f9..2271e511d06500f87e6baf1d114495f34b0b66ac 100644 --- a/assets/src/scripts/monitoring-location/parameter-code-utils.js +++ b/assets/src/scripts/monitoring-location/parameter-code-utils.js @@ -17,7 +17,7 @@ import config from 'ui/config'; */ export const hasMeasuredFahrenheitParameter = function(parameterCode, allParameterCodes) { let isParameterMatching; - switch(parameterCode) { + switch (parameterCode) { case '00020': isParameterMatching = allParameterCodes.includes('00021'); break; diff --git a/assets/src/scripts/monitoring-location/store/flood-data.js b/assets/src/scripts/monitoring-location/store/flood-data.js index ceae0dbbc58e02a612a5b7c5b65091f0893ef07c..db7d6ef0bfff2ed5ba3d9e56c41140533cf6807c 100644 --- a/assets/src/scripts/monitoring-location/store/flood-data.js +++ b/assets/src/scripts/monitoring-location/store/flood-data.js @@ -51,7 +51,7 @@ export const retrieveFIMFloodData = function(siteno) { * Slice reducer */ export const floodDataReducer = function(floodData=INITIAL_DATA, action) { - switch(action.type) { + switch (action.type) { case 'SET_FLOOD_FEATURES': return { ...floodData, @@ -109,7 +109,7 @@ const retrieveFloodLevels = function(siteno) { */ export const floodStateReducer = function(floodState={}, action) { - switch(action.type) { + switch (action.type) { case 'SET_GAGE_HEIGHT': return { ...floodState, diff --git a/assets/src/scripts/monitoring-location/store/groundwater-level-field-visits.js b/assets/src/scripts/monitoring-location/store/groundwater-level-field-visits.js index 91b0d1f0357430c6f2ecc8e4f5d6a9164ebdb443..cf42d5bac273d28a595bf420ee20ba07697b9bf2 100644 --- a/assets/src/scripts/monitoring-location/store/groundwater-level-field-visits.js +++ b/assets/src/scripts/monitoring-location/store/groundwater-level-field-visits.js @@ -79,7 +79,7 @@ export const retrieveGroundwaterLevelData = function(siteno, agencyCd) { * Slice reducer */ export const groundwaterLevelDataReducer = function(data=INITIAL_DATA, action) { - switch(action.type) { + switch (action.type) { case 'UPDATE_GROUNDWATER_LEVEL_DATA': return { ...data, diff --git a/assets/src/scripts/monitoring-location/store/hydrograph-data.js b/assets/src/scripts/monitoring-location/store/hydrograph-data.js index 23d492480d13e8bac72e22c6bbedf3dc553bd10c..f3b59516624f445a6cfce5c73ea755730fbe0fff 100644 --- a/assets/src/scripts/monitoring-location/store/hydrograph-data.js +++ b/assets/src/scripts/monitoring-location/store/hydrograph-data.js @@ -351,7 +351,7 @@ export const retrieveHydrographData = function(siteno, agencyCode, {parameterCod }; export const hydrographDataReducer = function(hydrographData = {}, action) { - switch(action.type) { + switch (action.type) { case 'SET_HYDROGRAPH_TIME_RANGE': { let newData = {}; newData[`${action.timeRangeKind}TimeRange`] = action.timeRange; diff --git a/assets/src/scripts/monitoring-location/store/hydrograph-parameters.js b/assets/src/scripts/monitoring-location/store/hydrograph-parameters.js index 8674f458b48f570c017af54d03d7705090deada7..1db3ffd9d4840dbc5e75524f06b67ae0315f3d7c 100644 --- a/assets/src/scripts/monitoring-location/store/hydrograph-parameters.js +++ b/assets/src/scripts/monitoring-location/store/hydrograph-parameters.js @@ -134,7 +134,7 @@ export const initializeParameters = function() { }; export const hydrographParametersReducer = function(hydrographParameters= {}, action) { - switch(action.type) { + switch (action.type) { case 'UPDATE_HYDROGRAPH_PARAMETERS': { return { ...action.parameters diff --git a/assets/src/scripts/monitoring-location/store/network.js b/assets/src/scripts/monitoring-location/store/network.js index 4cac773972bf7a36d6ccda2f44dad842df47f401..a34ebef6373230e204dceade59888530dfd73d4e 100644 --- a/assets/src/scripts/monitoring-location/store/network.js +++ b/assets/src/scripts/monitoring-location/store/network.js @@ -25,7 +25,7 @@ const retrieveNetworkListData = function(siteno) { return item['rel'] == 'collection'; }); dispatch(setNetworkList(networkList)); - } else{ + } else { dispatch(setNetworkList([])); } @@ -37,7 +37,7 @@ const retrieveNetworkListData = function(siteno) { * Slice reducer */ export const networkDataReducer = function(networkData=INITIAL_DATA, action) { - switch(action.type) { + switch (action.type) { case 'SET_NETWORK_LIST': return { ...networkData, diff --git a/assets/src/scripts/monitoring-location/store/nldi-data.js b/assets/src/scripts/monitoring-location/store/nldi-data.js index 98c91ab434978c4a87278e168366a45ceec33242..c8753105773bf813558c82e8fd11abe44c2f51cc 100644 --- a/assets/src/scripts/monitoring-location/store/nldi-data.js +++ b/assets/src/scripts/monitoring-location/store/nldi-data.js @@ -45,7 +45,7 @@ const retrieveNldiData = function(siteno) { * Slice reducer */ export const nldiDataReducer = function(nldiData=INITIAL_DATA, action) { - switch(action.type) { + switch (action.type) { case 'SET_NLDI_FEATURES': return { ...nldiData, diff --git a/assets/src/scripts/monitoring-location/store/ui-state.js b/assets/src/scripts/monitoring-location/store/ui-state.js index c1a18031ffa18ba1e35a334e837f620128b615e3..25cdeabaae3b9c917053c0aa85949c674a8c6a83 100644 --- a/assets/src/scripts/monitoring-location/store/ui-state.js +++ b/assets/src/scripts/monitoring-location/store/ui-state.js @@ -13,7 +13,7 @@ const resizeUI = function(windowWidth, width) { }; export const uiReducer = function(ui={}, action) { - switch(action.type) { + switch (action.type) { case 'RESIZE_UI': return { ...ui, diff --git a/assets/src/scripts/network/components/network-sites/map.js b/assets/src/scripts/network/components/network-sites/map.js index 7f1a0f95d192f7903e6d193a481951503b47aad7..7a1836e71c6c0c84bdfa9005379e90a3778c8665 100644 --- a/assets/src/scripts/network/components/network-sites/map.js +++ b/assets/src/scripts/network/components/network-sites/map.js @@ -73,7 +73,7 @@ export const addSitesLayer = function(map, networkSites) { }); }; - if(networkSites.length > 0 && networkSites.length < 10000) { + if (networkSites.length > 0 && networkSites.length < 10000) { const sitesLayer = getSitesLayer(networkSites, geojsonMarkerOptions); if (networkSites.length > 50) { const markers = new MarkerClusterGroup({chunkedLoading: true}); diff --git a/assets/src/scripts/network/store/network-data-reducer.js b/assets/src/scripts/network/store/network-data-reducer.js index 6e1bace2252a886761dfa070301aac7899ae4c1a..bc9705eff38117ddeaa5559dfec619780a16c416 100644 --- a/assets/src/scripts/network/store/network-data-reducer.js +++ b/assets/src/scripts/network/store/network-data-reducer.js @@ -16,7 +16,7 @@ const setNetworkMonitoringLocations = function(networkData, action) { * Slice reducer */ export const networkDataReducer = function(networkData=INITIAL_STATE, action) { - switch(action.type) { + switch (action.type) { case 'SET_NETWORK_MONITORING_LOCATIONS': return setNetworkMonitoringLocations(networkData, action); default: return networkData; } diff --git a/assets/src/scripts/web-services/camera-images.js b/assets/src/scripts/web-services/camera-images.js index 98b77ef5ce2ad15fd90bdc7bd098f6bbd060f878..2a3f6389a8349d94b846210815c6da192dab4fc4 100644 --- a/assets/src/scripts/web-services/camera-images.js +++ b/assets/src/scripts/web-services/camera-images.js @@ -26,7 +26,7 @@ export const fetchCameraMetaData = async function(siteno) { success: false }; } - } catch(error) { + } catch (error) { console.error(`Failed fetch for ${url}`); return { success: false diff --git a/assets/src/scripts/web-services/fim-data.js b/assets/src/scripts/web-services/fim-data.js index 3de1b0b5125112fc2ba5e958a4680f4ac2d16dd2..413aa0bb312ca375afbe33c86bb8d7e4f93aa501 100644 --- a/assets/src/scripts/web-services/fim-data.js +++ b/assets/src/scripts/web-services/fim-data.js @@ -22,7 +22,7 @@ export const fetchFIMPublicStatus = async function(siteno) { console.error(`Received bad status, ${response.status} from ${url}`); return false; } - } catch(error) { + } catch (error) { console.error(`Failed fetch for ${url}`); return false; } @@ -47,7 +47,7 @@ export const fetchFloodFeatures = async function(siteno) { console.error(`Received bad status, ${response.status} for ${url}`); return []; } - } catch(error) { + } catch (error) { console.error(`Failed fetch for ${url}`); return []; } @@ -71,7 +71,7 @@ export const fetchFloodExtent = async function(siteno) { console.error(`Received bad status, ${response.status} for ${url}`); return {}; } - } catch(error) { + } catch (error) { console.error(`Failed fetch for ${url}`); return {}; } diff --git a/assets/src/scripts/web-services/flood-levels.js b/assets/src/scripts/web-services/flood-levels.js index a9f23d9ed4d22ae6afc51f0c2c44ab776c11f2d2..7e359c23e9778849a725e1b3eb75f07285a20106 100644 --- a/assets/src/scripts/web-services/flood-levels.js +++ b/assets/src/scripts/web-services/flood-levels.js @@ -18,7 +18,7 @@ export const fetchFloodLevels = async function(siteno) { console.error(`Received bad status, ${response.status} for ${url}`); return null; } - } catch(error) { + } catch (error) { console.error(`Failed fetch for ${url}`); return null; } diff --git a/assets/src/scripts/web-services/groundwater-levels.js b/assets/src/scripts/web-services/groundwater-levels.js index de63f3c6bc60e7a7a874e673fe4aa8570c3d97e2..e12dc7a1698c46ab90412fb1a149a90d69c19205 100644 --- a/assets/src/scripts/web-services/groundwater-levels.js +++ b/assets/src/scripts/web-services/groundwater-levels.js @@ -41,7 +41,7 @@ export const fetchGroundwaterLevels = async function({siteno, agencyCd}) { console.error('`Received bad status, ${response.status} at ${url}`'); return {}; } - } catch(error) { + } catch (error) { console.error(`Failed fetch for ${url}`); return {}; } diff --git a/assets/src/scripts/web-services/instantaneous-values.js b/assets/src/scripts/web-services/instantaneous-values.js index 3e3253ae76677ddbc51a23fd2c54d4b082228200..8e12bf78a8dc2de5113788ae6f99ffce54c7548d 100644 --- a/assets/src/scripts/web-services/instantaneous-values.js +++ b/assets/src/scripts/web-services/instantaneous-values.js @@ -99,7 +99,7 @@ export const fetchTimeSeries = async function({siteno, parameterCode=null, perio console.error(`Received bad status, ${response.status} at ${url}`); return {}; } - } catch(error) { + } catch (error) { console.error(`Failed fetch for ${url}`); return {}; } diff --git a/assets/src/scripts/web-services/nldi-data.js b/assets/src/scripts/web-services/nldi-data.js index a5df0f59137b9cfb7ecedbaf4ac5d06b6a366340..e05280f9a582cfeea00dd65f3801d15906a06051 100644 --- a/assets/src/scripts/web-services/nldi-data.js +++ b/assets/src/scripts/web-services/nldi-data.js @@ -26,7 +26,7 @@ const fetchNldiData = async function(nldiQuery) { console.error(`Received bad status, ${response.status} at ${nldiQuery}`); return []; } - } catch(error) { + } catch (error) { console.error(`Failed fetch for ${nldiQuery}`); return []; } diff --git a/assets/src/scripts/web-services/observations.js b/assets/src/scripts/web-services/observations.js index 162df097368d34c4565147b295c5d4f77de59a21..db0dfd1e8d85b954325de16de76fc50c58be66f6 100644 --- a/assets/src/scripts/web-services/observations.js +++ b/assets/src/scripts/web-services/observations.js @@ -26,7 +26,7 @@ const fetchObservationsData = async function(queryUrl, parameters={}) { console.error(`Received bad status, ${response.status} at ${url}`); return {}; } - } catch(error) { + } catch (error) { console.error(`Failed fetch for ${url}`); return {}; } diff --git a/assets/src/scripts/web-services/sensor-things.js b/assets/src/scripts/web-services/sensor-things.js index 3466bbd235314163f2810fdbe5b9956c5df2da7d..20cf36fefe89f9c33c5531946dd629dd0733bf6d 100644 --- a/assets/src/scripts/web-services/sensor-things.js +++ b/assets/src/scripts/web-services/sensor-things.js @@ -31,7 +31,7 @@ export const fetchDataFromSensorThings = async function(agencySiteNumberCode, pa console.error(`Received bad status, ${response.status} at ${url}`); return {}; } - } catch(error) { + } catch (error) { console.error(`Failed fetch for ${url}`); return {}; } diff --git a/assets/src/scripts/web-services/statistics-data.js b/assets/src/scripts/web-services/statistics-data.js index 289e74c5cb7884b81d5ce334635996772761d1a9..33d6bbdfd571ac9678eca779ab692cc789099c64 100644 --- a/assets/src/scripts/web-services/statistics-data.js +++ b/assets/src/scripts/web-services/statistics-data.js @@ -40,7 +40,7 @@ const fetchSitesStatisticsRDB = async function({siteno, statType, parameterCode} console.error(`Received bad status, ${response.status} at ${url}`); return null; } - } catch(error) { + } catch (error) { console.error(`Failed fetch for ${url}`); return null; }